1/*! For license information please see main.2fe2d754.js.LICENSE.txt */ 2(()=>{var e={85:(e,t,n)=>{"use strict";var a=n(340),r=n(950),s=n(119);function i(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!==(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function c(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function d(e){if(l(e)!==e)throw Error(i(188))}function u(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e;for(e=e.child;null!==e;){if(null!==(t=u(e)))return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for("react.element"),p=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),v=Symbol.for("react.consumer"),w=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),N=Symbol.for("react.lazy");Symbol.for("react.scope");var F=Symbol.for("react.activity");Symbol.for("react.legacy_hidden"),Symbol.for("react.tracing_marker");var S=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var E=Symbol.iterator;function A(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=E&&e[E]||e["@@iterator"])?e:null}var T=Symbol.for("react.client.reference");function M(e){if(null==e)return null;if("function"===typeof e)return e.$$typeof===T?null:e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case x:return"Fragment";case b:return"Profiler";case f:return"StrictMode";case j:return"Suspense";case D:return"SuspenseList";case F:return"Activity"}if("object"===typeof e)switch(e.$$typeof){case g:return"Portal";case w:return(e.displayName||"Context")+".Provider";case v:return(e._context.displayName||"Context")+".Consumer";case k:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case C:return null!==(t=e.displayName||null)?t:M(e.type)||"Memo";case N:t=e._payload,e=e._init;try{return M(e(t))}catch(n){}}return null}var _=Array.isArray,B=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function O(e){0>R||(e.current=L[R],L[R]=null,R--)}function U(e,t){R++,L[R]=e.current,e.current=t}var V=z(null),H=z(null),q=z(null),W=z(null);function Y(e,t){switch(U(q,t),U(H,e),U(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ru(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)e=su(t=ru(t),e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}O(V),U(V,e)}function G(){O(V),O(H),O(q)}function K(e){null!==e.memoizedState&&U(W,e);var t=V.current,n=su(t,e.type);t!==n&&(U(H,e),U(V,n))}function X(e){H.current===e&&(O(V),O(H)),W.current===e&&(O(W),Ku._currentValue=P)}var J=Object.prototype.hasOwnProperty,$=a.unstable_scheduleCallback,Q=a.unstable_cancelCallback,Z=a.unstable_shouldYield,ee=a.unstable_requestPaint,te=a.unstable_now,ne=a.unstable_getCurrentPriorityLevel,ae=a.unstable_ImmediatePriority,re=a.unstable_UserBlockingPriority,se=a.unstable_NormalPriority,ie=a.unstable_LowPriority,oe=a.unstable_IdlePriority,le=a.log,ce=a.unstable_setDisableYieldValue,de=null,ue=null;function me(e){if("function"===typeof le&&ce(e),ue&&"function"===typeof ue.setStrictMode)try{ue.setStrictMode(de,e)}catch(t){}}var he=Math.clz32?Math.clz32:function(e){return 0===(e>>>=0)?32:31-(pe(e)/ge|0)|0}
vendor: 5,261 bytes, line 2
2,pe=Math.log,ge=Math.LN2;var xe=256,fe=4194304;function be(e){var t=42&e;if(0!==t)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:case 262144:case 524288:case 1048576:case 2097152:return 4194048&e;case 4194304:case 8388608:case 16777216:case 33554432:return 62914560&e;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ye(e,t,n){var a=e.pendingLanes;if(0===a)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes;e=e.warmLanes;var o=134217727&a;return 0!==o?0!==(a=o&~s)?r=be(a):0!==(i&=o)?r=be(i):n||0!==(n=o&~e)&&(r=be(n)):0!==(o=a&~s)?r=be(o):0!==i?r=be(i):n||0!==(n=a&~e)&&(r=be(n)),0===r?0:0!==t&&t!==r&&0===(t&s)&&((s=r&-r)>=(n=t&-t)||32===s&&0!==(4194048&n))?t:r}function ve(e,t){return 0===(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)}function we(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;default:return-1}}function ke(){var e=xe;return 0===(4194048&(xe<<=1))&&(xe=256),e}function je(){var e=fe;return 0===(62914560&(fe<<=1))&&(fe=4194304),e}function De(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ce(e,t){e.pendingLanes|=t,268435456!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ne(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var a=31-he(t);e.entangledLanes|=t,e.entanglements[a]=1073741824|e.entanglements[a]|4194090&n}function Fe(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var a=31-he(n),r=1<<a;r&t|e[a]&t&&(e[a]|=t),n&=~r}}function Se(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 Ee(e){return 2<(e&=-e)?8<e?0!==(134217727&e)?32:268435456:8:2}function Ae(){var e=I.p;return 0!==e?e:void 0===(e=window.event)?32:cm(e.type)}var Te=Math.random().toString(36).slice(2),Me="__reactFiber$"+Te,_e="__reactProps$"+Te,Be="__reactContainer$"+Te,Ie="__reactEvents$"+Te,Pe="__reactListeners$"+Te,Le="__reactHandles$"+Te,Re="__reactResources$"+Te,ze="__reactMarker$"+Te;function Oe(e){delete e[Me],delete e[_e],delete e[Ie],delete e[Pe],delete e[Le]}function Ue(e){var t=e[Me];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Be]||n[Me]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=yu(e);null!==e;){if(n=e[Me])return n;e=yu(e)}return t}n=(e=n).parentNode}return null}function Ve(e){if(e=e[Me]||e[Be]){var t=e.tag;if(5===t||6===t||13===t||26===t||27===t||3===t)return e}return null}function He(e){var t=e.tag;if(5===t||26===t||27===t||6===t)return e.stateNode;throw Error(i(33))}function qe(e){var t=e[Re];return t||(t=e[Re]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function We(e){e[ze]=!0}var Ye=new Set,Ge={};function Ke(e,t){Xe(e,t),Xe(e+"Capture",t)}function Xe(e,t){for(Ge[e]=t,e=0;e<t.length;e++)Ye.add(t[e])}var Je,$e,Qe=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]*$"),Ze={},et={};function tt(e,t,n){if(r=t,J.call(et,r)||!J.call(Ze,r)&&(Qe.test(r)?et[r]=!0:(Ze[r]=!0,0)))if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":return void e.removeAttribute(t);case"boolean":var a=t.toLowerCase().slice(0,5);if("data-"!==a&&"aria-"!==a)return void e.removeAttribute(t)}e.setAttribute(t,""+n)}var r}function nt(e,t,n){if(null===n)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(t)}e.setAttribute(t,""+n)}}function at(e,t,n,a){if(null===a)e.removeAttribute(n);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":return void e.removeAttribute(n)}e.setAttributeNS(t,n,""+a)}}function rt(e){if(void 0===Je)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Je=t&&t[1]||"",$e=-1<n.stack.indexOf("\n at")?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return"\n"+Je+e+$e}var st=!1;function it(e,t){if(!e||st)return"";st=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var a={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(n,[])}catch(r){var a=r}Reflect.construct(e,[],n)}
2else{try{n.call()}catch(s){a=s}e.call(n.prototype)}}else{try{throw Error()}catch(i){a=i}(n=e())&&"function"===typeof n.catch&&n.catch(function(){})}}catch(o){if(o&&a&&"string"===typeof o.stack)return[o.stack,a.stack]}return[null,null]}};a.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(a.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(a.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var s=a.DetermineComponentFrameRoot(),i=s[0],o=s[1];if(i&&o){var l=i.split("\n"),c=o.split("\n");for(r=a=0;a<l.length&&!l[a].includes("DetermineComponentFrameRoot");)a++;for(;r<c.length&&!c[r].includes("DetermineComponentFrameRoot");)r++;if(a===l.length||r===c.length)for(a=l.length-1,r=c.length-1;1<=a&&0<=r&&l[a]!==c[r];)r--;for(;1<=a&&0<=r;a--,r--)if(l[a]!==c[r]){if(1!==a||1!==r)do{if(a--,0>--r||l[a]!==c[r]){var d="\n"+l[a].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),d}}while(1<=a&&0<=r);break}}}finally{st=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?rt(n):""}function ot(e){switch(e.tag){case 26:case 27:case 5:return rt(e.type);case 16:return rt("Lazy");case 13:return rt("Suspense");case 19:return rt("SuspenseList");case 0:case 15:return it(e.type,!1);case 11:return it(e.type.render,!1);case 1:return it(e.type,!0);case 31:return rt("Activity");default:return""}}function lt(e){try{var t="";do{t+=ot(e),e=e.return}while(e);return t}catch(n){return"\nError generating stack: "+n.message+"\n"+n.stack}}function ct(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function dt(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function ut(e){e._valueTracker||(e._valueTracker=function(e){var t=dt(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),a=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof n&&"function"===typeof n.get&&"function"===typeof n.set){var r=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(e){a=""+e,s.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return a},setValue:function(e){a=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function mt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),a="";return e&&(a=dt(e)?e.checked?"true":"false":e.value),(e=a)!==n&&(t.setValue(e),!0)}function ht(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}var pt=/[\n"\\]/g;function gt(e){return e.replace(pt,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function xt(e,t,n,a,r,s,i,o){e.name="",null!=i&&"function"!==typeof i&&"symbol"!==typeof i&&"boolean"!==typeof i?e.type=i:e.removeAttribute("type"),null!=t?"number"===i?(0===t&&""===e.value||e.value!=t)&&(e.value=""+ct(t)):e.value!==""+ct(t)&&(e.value=""+ct(t)):"submit"!==i&&"reset"!==i||e.removeAttribute("value"),null!=t?bt(e,i,ct(t)):null!=n?bt(e,i,ct(n)):null!=a&&e.removeAttribute("value"),null==r&&null!=s&&(e.defaultChecked=!!s),null!=r&&(e.checked=r&&"function"!==typeof r&&"symbol"!==typeof r),null!=o&&"function"!==typeof o&&"symbol"!==typeof o&&"boolean"!==typeof o?e.name=""+ct(o):e.removeAttribute("name")}function ft(e,t,n,a,r,s,i,o){if(null!=s&&"function"!==typeof s&&"symbol"!==typeof s&&"boolean"!==typeof s&&(e.type=s),null!=t||null!=n){if(!("submit"!==s&&"reset"!==s||void 0!==t&&null!==t))return;n=null!=n?""+ct(n):"",t=null!=t?""+ct(t):n,o||t===e.value||(e.value=t),e.defaultValue=t}a="function"!==typeof(a=null!=a?a:r)&&"symbol"!==typeof a&&!!a,e.checked=o?e.checked:!!a,e.defaultChecked=!!a,null!=i&&"function"!==typeof i&&"symbol"!==typeof i&&"boolean"!==typeof i&&(e.name=i)}function bt(e,t,n){"number"===t&&ht(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function yt(e,t,n,a){if(e=e.options,t){t={};for(var r=0;r<n.length;r++)t["$"+n[r]]=!0;for(n=0;n<e.length;n++)r=t.hasOwnProperty("$"+e[n].value),e[n].selected!==r&&(e[n].selected=r),r&&a&&(e[n].defaultSelected=!0)}else{for(n=""+ct(n),t=null,r=0;r<e.length;r++){if(e[r].value===n)return e[r].selected=!0,void(a&&(e[r].defaultSelected=!0));null!==t||e[r].disabled||(t=e[r])}null!==t&&(t.selected=!0)}}function vt(e,t,n){null==t||((t=""+ct(t))!==e.value&&(e.value=t),null!=n)?e.defaultValue=null!=n?""+ct(n):"":e.defaultValue!==t&&(e.defaultValue=t)}
vendor: 4,415 bytes, line 2
2function wt(e,t,n,a){if(null==t){if(null!=a){if(null!=n)throw Error(i(92));if(_(a)){if(1<a.length)throw Error(i(93));a=a[0]}n=a}null==n&&(n=""),t=n}n=ct(t),e.defaultValue=n,(a=e.textContent)===n&&""!==a&&null!==a&&(e.value=a)}function kt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var jt=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 Dt(e,t,n){var a=0===t.indexOf("--");null==n||"boolean"===typeof n||""===n?a?e.setProperty(t,""):"float"===t?e.cssFloat="":e[t]="":a?e.setProperty(t,n):"number"!==typeof n||0===n||jt.has(t)?"float"===t?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Ct(e,t,n){if(null!=t&&"object"!==typeof t)throw Error(i(62));if(e=e.style,null!=n){for(var a in n)!n.hasOwnProperty(a)||null!=t&&t.hasOwnProperty(a)||(0===a.indexOf("--")?e.setProperty(a,""):"float"===a?e.cssFloat="":e[a]="");for(var r in t)a=t[r],t.hasOwnProperty(r)&&n[r]!==a&&Dt(e,r,a)}else for(var s in t)t.hasOwnProperty(s)&&Dt(e,s,t[s])}function Nt(e){if(-1===e.indexOf("-"))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 Ft=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"],["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
2-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"]]),St=/^[\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 Et(e){return St.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}var At=null;function Tt(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Mt=null,_t=null;function Bt(e){var t=Ve(e);if(t&&(e=t.stateNode)){var n=e[_e]||null;e:switch(e=t.stateNode,t.type){case"input":if(xt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+gt(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var a=n[t];if(a!==e&&a.form===e.form){var r=a[_e]||null;if(!r)throw Error(i(90));xt(a,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name)}}for(t=0;t<n.length;t++)(a=n[t]).form===e.form&&mt(a)}break e;case"textarea":vt(e,n.value,n.defaultValue);break e;case"select":null!=(t=n.value)&&yt(e,!!n.multiple,t,!1)}}}var It=!1;function Pt(e,t,n){if(It)return e(t,n);It=!0;try{return e(t)}finally{if(It=!1,(null!==Mt||null!==_t)&&(Uc(),Mt&&(t=Mt,e=_t,_t=Mt=null,Bt(t),e)))for(t=0;t<e.length;t++)Bt(e[t])}}function Lt(e,t){var n=e.stateNode;if(null===n)return null;var a=n[_e]||null;if(null===a)return null;n=a[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(a=!a.disabled)||(a=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!a;break e;default:e=!1}if(e)return null;if(n&&"function"!==typeof n)throw Error(i(231,t,typeof n));return n}var Rt=!("undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement),zt=!1;if(Rt)try{var Ot={};Object.defineProperty(Ot,"passive",{get:function(){zt=!0}}),window.addEventListener("test",Ot,Ot),window.removeEventListener("test",Ot,Ot)}catch(_m){zt=!1}var Ut=null,Vt=null,Ht=null;function qt(){if(Ht)return Ht;var e,t,n=Vt,a=n.length,r="value"in Ut?Ut.value:Ut.textContent,s=r.length;for(e=0;e<a&&n[e]===r[e];e++);var i=a-e;for(t=1;t<=i&&n[a-t]===r[s-t];t++);return Ht=r.slice(e,1<t?1-t:void 0)}function Wt(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function Yt(){return!0}function Gt(){return!1}function Kt(e){function t(t,n,a,r,s){for(var i in this._reactName=t,this._targetInst=a,this.type=n,this.nativeEvent=r,this.target=s,this.currentTarget=null,e)e.hasOwnProperty(i)&&(t=e[i],this[i]=t?t(r):r[i]);return this.isDefaultPrevented=(null!=r.defaultPrevented?r.defaultPrevented:!1===r.returnValue)?Yt:Gt,this.isPropagationStopped=Gt,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!==typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=Yt)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!==typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=Yt)},persist:function(){},isPersistent:Yt}),t}var Xt,Jt,$t,Qt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zt=Kt(Qt),en=m({},Qt,{view:0,detail:0}),tn=Kt(en),nn=m({},en,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pn,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.from
vendor: 4,404 bytes, line 2
2Element===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==$t&&($t&&"mousemove"===e.type?(Xt=e.screenX-$t.screenX,Jt=e.screenY-$t.screenY):Jt=Xt=0,$t=e),Xt)},movementY:function(e){return"movementY"in e?e.movementY:Jt}}),an=Kt(nn),rn=Kt(m({},nn,{dataTransfer:0})),sn=Kt(m({},en,{relatedTarget:0})),on=Kt(m({},Qt,{animationName:0,elapsedTime:0,pseudoElement:0})),ln=Kt(m({},Qt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}})),cn=Kt(m({},Qt,{data:0})),dn={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},un={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"},mn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=mn[e])&&!!t[e]}function pn(){return hn}var gn=Kt(m({},en,{key:function(e){if(e.key){var t=dn[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=Wt(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?un[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pn,charCode:function(e){return"keypress"===e.type?Wt(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?Wt(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}})),xn=Kt(m({},nn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),fn=Kt(m({},en,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pn})),bn=Kt(m({},Qt,{propertyName:0,elapsedTime:0,pseudoElement:0})),yn=Kt(m({},nn,{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})),vn=Kt(m({},Qt,{newState:0,oldState:0})),wn=[9,13,27,32],kn=Rt&&"CompositionEvent"in window,jn=null;Rt&&"documentMode"in document&&(jn=document.documentMode);var Dn=Rt&&"TextEvent"in window&&!jn,Cn=Rt&&(!kn||jn&&8<jn&&11>=jn),Nn=String.fromCharCode(32),Fn=!1;function Sn(e,t){switch(e){case"keyup":return-1!==wn.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function En(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var An=!1;var Tn={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 Mn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!Tn[e.type]:"textarea"===t}function _n(e,t,n,a){Mt?_t?_t.push(a):_t=[a]:Mt=a,0<(t=qd(t,"onChange")).length&&(n=new Zt("onChange","change",null,n,a),e.push({event:n,listeners:t}))}var Bn=null,In=null;function Pn(e){Pd(e,0)}function Ln(e){if(mt(He(e)))return e}function Rn(e,t){if("change"===e)return t}var zn=!1;if(Rt){var On;if(Rt){var Un="oninput"in document;if(!Un){var Vn=document.createElement("div");Vn.setAttribute("oninput","return;"),Un="function"===typeof Vn.oninput}On=Un}else On=!1;zn=On&&(!document.documentMode||9<document.documentMode)}function Hn(){Bn&&(Bn.detachEvent("onpropertychange",qn),In=Bn=null)}function qn(e){if("value"===e.propertyName&&Ln(In)){var t=[];_n(t,In,e,Tt(e)),Pt(Pn,t)}}function Wn(e,t,n){"focusin"===e?(Hn(),In=n,(Bn=t).attachEvent("onpropertychange",qn)):"focusout"===e&&Hn()}function Yn(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Ln(In)}function Gn(e,t){if("click"===e)return Ln(t)}function Kn(e,t){if("input"===e||"change"===e)return Ln(t)}var Xn="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t};function Jn(e,t){if(Xn(e,t))return!0;
vendor: 4,257 bytes, line 2
2if("object"!==typeof e||null===e||"object"!==typeof t||null===t)return!1;var n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(a=0;a<n.length;a++){var r=n[a];if(!J.call(t,r)||!Xn(e[r],t[r]))return!1}return!0}function $n(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Qn(e,t){var n,a=$n(e);for(e=0;a;){if(3===a.nodeType){if(n=e+a.textContent.length,e<=t&&n>=t)return{node:a,offset:t-e};e=n}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=$n(a)}}function Zn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?Zn(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function ea(e){for(var t=ht((e=null!=e&&null!=e.ownerDocument&&null!=e.ownerDocument.defaultView?e.ownerDocument.defaultView:window).document);t instanceof e.HTMLIFrameElement;){try{var n="string"===typeof t.contentWindow.location.href}catch(a){n=!1}if(!n)break;t=ht((e=t.contentWindow).document)}return t}function ta(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var na=Rt&&"documentMode"in document&&11>=document.documentMode,aa=null,ra=null,sa=null,ia=!1;function oa(e,t,n){var a=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;ia||null==aa||aa!==ht(a)||("selectionStart"in(a=aa)&&ta(a)?a={start:a.selectionStart,end:a.selectionEnd}:a={anchorNode:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset},sa&&Jn(sa,a)||(sa=a,0<(a=qd(ra,"onSelect")).length&&(t=new Zt("onSelect","select",null,t,n),e.push({event:t,listeners:a}),t.target=aa)))}function la(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ca={animationend:la("Animation","AnimationEnd"),animationiteration:la("Animation","AnimationIteration"),animationstart:la("Animation","AnimationStart"),transitionrun:la("Transition","TransitionRun"),transitionstart:la("Transition","TransitionStart"),transitioncancel:la("Transition","TransitionCancel"),transitionend:la("Transition","TransitionEnd")},da={},ua={};function ma(e){if(da[e])return da[e];if(!ca[e])return e;var t,n=ca[e];for(t in n)if(n.hasOwnProperty(t)&&t in ua)return da[e]=n[t];return e}Rt&&(ua=document.createElement("div").style,"AnimationEvent"in window||(delete ca.animationend.animation,delete ca.animationiteration.animation,delete ca.animationstart.animation),"TransitionEvent"in window||delete ca.transitionend.transition);var ha=ma("animationend"),pa=ma("animationiteration"),ga=ma("animationstart"),xa=ma("transitionrun"),fa=ma("transitionstart"),ba=ma("transitioncancel"),ya=ma("transitionend"),va=new Map,wa="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error 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(" ");function ka(e,t){va.set(e,t),Ke(t,[e])}wa.push("scrollEnd");var ja=new WeakMap;function Da(e,t){if("object"===typeof e&&null!==e){var n=ja.get(e);return void 0!==n?n:(t={value:e,source:t,stack:lt(t)},ja.set(e,t),t)}return{value:e,source:t,stack:lt(t)}}var Ca=[],Na=0,Fa=0;function Sa(){for(var e=Na,t=Fa=Na=0;t<e;){var n=Ca[t];Ca[t++]=null;var a=Ca[t];Ca[t++]=null;var r=Ca[t];Ca[t++]=null;var s=Ca[t];if(Ca[t++]=null,null!==a&&null!==r){var i=a.pending;null===i?r.next=r:(r.next=i.next,i.next=r),a.pending=r}0!==s&&Ma(n,r,s)}}function Ea(e,t,n,a){Ca[Na++]=e,Ca[Na++]=t,Ca[Na++]=n,Ca[Na++]=a,Fa|=a,e.lanes|=a,null!==(e=e.alternate)&&(e.lanes|=a)}function Aa(e,t,n,a){return Ea(e,t,n,a),_a(e)}function Ta(e,t){return Ea(e,null,null,t),_a(e)}
vendor: 7,335 bytes, line 2
2function Ma(e,t,n){e.lanes|=n;var a=e.alternate;null!==a&&(a.lanes|=n);for(var r=!1,s=e.return;null!==s;)s.childLanes|=n,null!==(a=s.alternate)&&(a.childLanes|=n),22===s.tag&&(null===(e=s.stateNode)||1&e._visibility||(r=!0)),e=s,s=s.return;return 3===e.tag?(s=e.stateNode,r&&null!==t&&(r=31-he(n),null===(a=(e=s.hiddenUpdates)[r])?e[r]=[t]:a.push(t),t.lane=536870912|n),s):null}function _a(e){if(50<Mc)throw Mc=0,_c=null,Error(i(185));for(var t=e.return;null!==t;)t=(e=t).return;return 3===e.tag?e.stateNode:null}var Ba={};function Ia(e,t,n,a){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=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Pa(e,t,n,a){return new Ia(e,t,n,a)}function La(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Ra(e,t){var n=e.alternate;return null===n?((n=Pa(e.tag,t,e.key,e.mode)).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=65011712&e.flags,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=null===t?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 za(e,t){e.flags&=65011714;var n=e.alternate;return null===n?(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=null===t?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Oa(e,t,n,a,r,s){var o=0;if(a=e,"function"===typeof e)La(e)&&(o=1);else if("string"===typeof e)o=function(e,t,n){if(1===n||null!=t.itemProp)return!1;switch(e){case"meta":case"title":return!0;case"style":if("string"!==typeof t.precedence||"string"!==typeof t.href||""===t.href)break;return!0;case"link":if("string"!==typeof t.rel||"string"!==typeof t.href||""===t.href||t.onLoad||t.onError)break;return"stylesheet"!==t.rel||(e=t.disabled,"string"===typeof t.precedence&&null==e);case"script":if(t.async&&"function"!==typeof t.async&&"symbol"!==typeof t.async&&!t.onLoad&&!t.onError&&t.src&&"string"===typeof t.src)return!0}return!1}(e,n,V.current)?26:"html"===e||"head"===e||"body"===e?27:5;else e:switch(e){case F:return(e=Pa(31,n,t,r)).elementType=F,e.lanes=s,e;case x:return Ua(n.children,r,s,t);case f:o=8,r|=24;break;case b:return(e=Pa(12,n,t,2|r)).elementType=b,e.lanes=s,e;case j:return(e=Pa(13,n,t,r)).elementType=j,e.lanes=s,e;case D:return(e=Pa(19,n,t,r)).elementType=D,e.lanes=s,e;default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case y:case w:o=10;break e;case v:o=9;break e;case k:o=11;break e;case C:o=14;break e;case N:o=16,a=null;break e}o=29,n=Error(i(130,null===e?"null":typeof e,"")),a=null}return(t=Pa(o,n,t,r)).elementType=e,t.type=a,t.lanes=s,t}function Ua(e,t,n,a){return(e=Pa(7,e,a,t)).lanes=n,e}function Va(e,t,n){return(e=Pa(6,e,null,t)).lanes=n,e}function Ha(e,t,n){return(t=Pa(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var qa=[],Wa=0,Ya=null,Ga=0,Ka=[],Xa=0,Ja=null,$a=1,Qa="";function Za(e,t){qa[Wa++]=Ga,qa[Wa++]=Ya,Ya=e,Ga=t}function er(e,t,n){Ka[Xa++]=$a,Ka[Xa++]=Qa,Ka[Xa++]=Ja,Ja=e;var a=$a;e=Qa;var r=32-he(a)-1;a&=~(1<<r),n+=1;var s=32-he(t)+r;if(30<s){var i=r-r%5;s=(a&(1<<i)-1).toString(32),a>>=i,r-=i,$a=1<<32-he(t)+r|n<<r|a,Qa=s+e}else $a=1<<s|n<<r|a,Qa=e}function tr(e){null!==e.return&&(Za(e,1),er(e,1,0))}function nr(e){for(;e===Ya;)Ya=qa[--Wa],qa[Wa]=null,Ga=qa[--Wa],qa[Wa]=null;for(;e===Ja;)Ja=Ka[--Xa],Ka[Xa]=null,Qa=Ka[--Xa],Ka[Xa]=null,$a=Ka[--Xa],Ka[Xa]=null}var ar=null,rr=null,sr=!1,ir=null,or=!1,lr=Error(i(519));function cr(e){throw gr(Da(Error(i(418,"")),e)),lr}function dr(e){var t=e.stateNode,n=e.type,a=e.memoizedProps;switch(t[Me]=e,t[_e]=a,n){case"dialog":Ld("cancel",t),Ld("close",t);break;case"iframe":case"object":case"embed":Ld("load",t);break;case"video":case"audio":for(n=0;n<Bd.length;n++)Ld(Bd[n],t);break;case"source":Ld("error",t);break;case"img":case"image":case"link":Ld("error",t),Ld("load",t);break;case"details":Ld("toggle",t);break;case"input":Ld("invalid",t),ft(t,a.value,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name,!0),ut(t);break;case"select":Ld("invalid",t);break;case"textarea":Ld("invalid",t),wt(t,a.value,a.defaultValue,a.children),ut(t)}"string"!==typeof(n=a.children)&&"number"!==typeof n&&"bigint"!==typeof n||t.textContent===""+n||!0===a.suppressHydrationWarning||Jd(t.textContent,n)?(null!=a.popover&&(Ld("beforetoggle",t),Ld("toggle",t)),null!=a.onScroll&&Ld("scroll",t),null!=a.onScrollEnd&&Ld("scrollend",t),null!=a.onClick&&(t.onclick=$d),t=!0):t=!1,t||cr(e)}function ur(e){for(ar=e.return;ar;)switch(ar.tag){case 5:case 13:return void(or=!1);case 27:case 3:return void(or=!0);default:ar=ar.return}}function mr(e){if(e!==ar)return!1;if(!sr)return ur(e),sr=!0,!1;var t,n=e.tag;if((t=3!==n&&27!==n)&&((t=5===n)&&(t=!("form"!==(t=e.type)&&"button"!==t)||iu(e.type,e.memoizedProps)),t=!t),t&&rr&&cr(e),ur(e),13===n){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));e:{for(e=e.nextSibling,n=0;e;){if(8===e.nodeType)if("/$"===(t=e.data)){if(0===n){rr=fu(e.nextSibling);break e}n--}else"$"!==t&&"$!"!==t&&"$?"!==t||n++;e=e.nextSibling}rr=null}}else 27===n?(n=rr,hu(e.type)?(e=bu,bu=null,rr=e):rr=n):rr=ar?fu(e.stateNode.nextSibling):null;return!0}function hr(){rr=ar=null,sr=!1}function pr(){var e=ir;return null!==e&&(null===yc?yc=e:yc.push.apply(yc,e),ir=null),e}function gr(e){null===ir?ir=[e]:ir.push(e)}var xr=z(null),fr=null,br=null;function yr(e,t,n){U(xr,t._currentValue),t._currentValue=n}function vr(e){e._currentValue=xr.current,O(xr)}function wr(e,t,n){for(;null!==e;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==a&&(a.childLanes|=t)):null!==a&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===n)break;e=e.return}}function kr(e,t,n,a){var r=e.child;for(null!==r&&(r.return=e);null!==r;){var s=r.dependencies;if(null!==s){var o=r.child;s=s.firstContext;e:for(;null!==s;){var l=s;s=r;for(var c=0;c<t.length;c++)if(l.context===t[c]){s.lanes|=n,null!==(l=s.alternate)&&(l.lanes|=n),wr(s.return,n,e),a||(o=null);break e}s=l.next}}else if(18===r.tag){if(null===(o=r.return))throw Error(i(341));o.lanes|=n,null!==(s=o.alternate)&&(s.lanes|=n),wr(o,n,e),o=null}else o=r.child;if(null!==o)o.return=r;else for(o=r;null!==o;){if(o===e){o=null;break}if(null!==(r=o.sibling)){r.return=o.return,o=r;break}o=o.return}r=o}}function jr(e,t,n,a){e=null;for(var r=t,s=!1;null!==r;){if(!s)if(0!==(524288&r.flags))s=!0;else if(0!==(262144&r.flags))break;if(10===r.tag){var o=r.alternate;if(null===o)throw Error(i(387));if(null!==(o=o.memoizedProps)){var l=r.type;
vendor: 21,469 bytes, line 2
2Xn(r.pendingProps.value,o.value)||(null!==e?e.push(l):e=[l])}}else if(r===W.current){if(null===(o=r.alternate))throw Error(i(387));o.memoizedState.memoizedState!==r.memoizedState.memoizedState&&(null!==e?e.push(Ku):e=[Ku])}r=r.return}null!==e&&kr(t,e,n,a),t.flags|=262144}function Dr(e){for(e=e.firstContext;null!==e;){if(!Xn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Cr(e){fr=e,br=null,null!==(e=e.dependencies)&&(e.firstContext=null)}function Nr(e){return Sr(fr,e)}function Fr(e,t){return null===fr&&Cr(e),Sr(e,t)}function Sr(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},null===br){if(null===e)throw Error(i(308));br=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else br=br.next=t;return n}var Er="undefined"!==typeof AbortController?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()})}},Ar=a.unstable_scheduleCallback,Tr=a.unstable_NormalPriority,Mr={$$typeof:w,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function _r(){return{controller:new Er,data:new Map,refCount:0}}function Br(e){e.refCount--,0===e.refCount&&Ar(Tr,function(){e.controller.abort()})}var Ir=null,Pr=0,Lr=0,Rr=null;function zr(){if(0===--Pr&&null!==Ir){null!==Rr&&(Rr.status="fulfilled");var e=Ir;Ir=null,Lr=0,Rr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}var Or=B.S;B.S=function(e,t){"object"===typeof t&&null!==t&&"function"===typeof t.then&&function(e,t){if(null===Ir){var n=Ir=[];Pr=0,Lr=Ed(),Rr={status:"pending",value:void 0,then:function(e){n.push(e)}}}Pr++,t.then(zr,zr)}(0,t),null!==Or&&Or(e,t)};var Ur=z(null);function Vr(){var e=Ur.current;return null!==e?e:ac.pooledCache}function Hr(e,t){U(Ur,null===t?Ur.current:t.pool)}function qr(){var e=Vr();return null===e?null:{parent:Mr._currentValue,pool:e}}var Wr=Error(i(460)),Yr=Error(i(474)),Gr=Error(i(542)),Kr={then:function(){}};function Xr(e){return"fulfilled"===(e=e.status)||"rejected"===e}function Jr(){}function $r(e,t,n){switch(void 0===(n=e[n])?e.push(t):n!==t&&(t.then(Jr,Jr),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw es(e=t.reason),e;default:if("string"===typeof t.status)t.then(Jr,Jr);else{if(null!==(e=ac)&&100<e.shellSuspendCounter)throw Error(i(482));(e=t).status="pending",e.then(function(e){if("pending"===t.status){var n=t;n.status="fulfilled",n.value=e}},function(e){if("pending"===t.status){var n=t;n.status="rejected",n.reason=e}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw es(e=t.reason),e}throw Qr=t,Wr}}var Qr=null;function Zr(){if(null===Qr)throw Error(i(459));var e=Qr;return Qr=null,e}function es(e){if(e===Wr||e===Gr)throw Error(i(483))}var ts=!1;function ns(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function as(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 rs(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ss(e,t,n){var a=e.updateQueue;if(null===a)return null;if(a=a.shared,0!==(2&nc)){var r=a.pending;return null===r?t.next=t:(t.next=r.next,r.next=t),a.pending=t,t=_a(e),Ma(e,null,n),t}return Ea(e,a,t,n),_a(e)}function is(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!==(4194048&n))){var a=t.lanes;n|=a&=e.pendingLanes,t.lanes=n,Fe(e,n)}}function os(e,t){var n=e.updateQueue,a=e.alternate;if(null!==a&&n===(a=a.updateQueue)){var r=null,s=null;if(null!==(n=n.firstBaseUpdate)){do{var i={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};null===s?r=s=i:s=s.next=i,n=n.next}while(null!==n);null===s?r=s=t:s=s.next=t}else r=s=t;return n={baseState:a.baseState,firstBaseUpdate:r,lastBaseUpdate:s,shared:a.shared,callbacks:a.callbacks},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var ls=!1;function cs(){if(ls){if(null!==Rr)throw Rr}}function ds(e,t,n,a){ls=!1;var r=e.updateQueue;ts=!1;var s=r.firstBaseUpdate,i=r.lastBaseUpdate,o=r.shared.pending;if(null!==o){r.shared.pending=null;var l=o,c=l.next;l.next=null,null===i?s=c:i.next=c,i=l;var d=e.alternate;null!==d&&((o=(d=d.updateQueue).lastBaseUpdate)!==i&&(null===o?d.firstBaseUpdate=c:o.next=c,d.lastBaseUpdate=l))}if(null!==s){var u=r.baseState;for(i=0,d=c=l=null,o=s;;){var h=-536870913&o.lane,p=h!==o.lane;if(p?(sc&h)===h:(a&h)===h){0!==h&&h===Lr&&(ls=!0),null!==d&&(d=d.next={lane:0,tag:o.tag,payload:o.payload,callback:null,next:null});e:{var g=e,x=o;h=t;var f=n;switch(x.tag){case 1:if("function"===typeof(g=x.payload)){u=g.call(f,u,h);break e}u=g;break e;case 3:g.flags=-65537&g.flags|128;case 0:if(null===(h="function"===typeof(g=x.payload)?g.call(f,u,h):g)||void 0===h)break e;u=m({},u,h);break e;case 2:ts=!0}}null!==(h=o.callback)&&(e.flags|=64,p&&(e.flags|=8192),null===(p=r.callbacks)?r.callbacks=[h]:p.push(h))}else p={lane:h,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===d?(c=d=p,l=u):d=d.next=p,i|=h;if(null===(o=o.next)){if(null===(o=r.shared.pending))break;o=(p=o).next,p.next=null,r.lastBaseUpdate=p,r.shared.pending=null}}null===d&&(l=u),r.baseState=l,r.firstBaseUpdate=c,r.lastBaseUpdate=d,null===s&&(r.shared.lanes=0),hc|=i,e.lanes=i,e.memoizedState=u}}function us(e,t){if("function"!==typeof e)throw Error(i(191,e));e.call(t)}function ms(e,t){var n=e.callbacks;if(null!==n)for(e.callbacks=null,e=0;e<n.length;e++)us(n[e],t)}var hs=z(null),ps=z(0);function gs(e,t){U(ps,e=uc),U(hs,t),uc=e|t.baseLanes}function xs(){U(ps,uc),U(hs,hs.current)}function fs(){uc=ps.current,O(hs),O(ps)}var bs=0,ys=null,vs=null,ws=null,ks=!1,js=!1,Ds=!1,Cs=0,Ns=0,Fs=null,Ss=0;function Es(){throw Error(i(321))}function As(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Xn(e[n],t[n]))return!1;return!0}function Ts(e,t,n,a,r,s){return bs=s,ys=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,B.H=null===e||null===e.memoizedState?Wi:Yi,Ds=!1,s=n(a,r),Ds=!1,js&&(s=_s(t,n,a,r)),Ms(e),s}function Ms(e){B.H=qi;var t=null!==vs&&null!==vs.next;if(bs=0,ws=vs=ys=null,ks=!1,Ns=0,Fs=null,t)throw Error(i(300));null===e||Fo||null!==(e=e.dependencies)&&Dr(e)&&(Fo=!0)}function _s(e,t,n,a){ys=e;var r=0;do{if(js&&(Fs=null),Ns=0,js=!1,25<=r)throw Error(i(301));if(r+=1,ws=vs=null,null!=e.updateQueue){var s=e.updateQueue;s.lastEffect=null,s.events=null,s.stores=null,null!=s.memoCache&&(s.memoCache.index=0)}B.H=Gi,s=t(n,a)}while(js);return s}function Bs(){var e=B.H,t=e.useState()[0];return t="function"===typeof t.then?Os(t):t,e=e.useState()[0],(null!==vs?vs.memoizedState:null)!==e&&(ys.flags|=1024),t}function Is(){var e=0!==Cs;return Cs=0,e}function Ps(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Ls(e){if(ks){for(e=e.memoizedState;null!==e;){var t=e.queue;null!==t&&(t.pending=null),e=e.next}ks=!1}bs=0,ws=vs=ys=null,js=!1,Ns=Cs=0,Fs=null}function Rs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===ws?ys.memoizedState=ws=e:ws=ws.next=e,ws}function zs(){if(null===vs){var e=ys.alternate;e=null!==e?e.memoizedState:null}else e=vs.next;var t=null===ws?ys.memoizedState:ws.next;if(null!==t)ws=t,vs=e;else{if(null===e){if(null===ys.alternate)throw Error(i(467));throw Error(i(310))}e={memoizedState:(vs=e).memoizedState,baseState:vs.baseState,baseQueue:vs.baseQueue,queue:vs.queue,next:null},null===ws?ys.memoizedState=ws=e:ws=ws.next=e}return ws}function Os(e){var t=Ns;return Ns+=1,null===Fs&&(Fs=[]),e=$r(Fs,e,t),t=ys,null===(null===ws?t.memoizedState:ws.next)&&(t=t.alternate,B.H=null===t||null===t.memoizedState?Wi:Yi),e}function Us(e){if(null!==e&&"object"===typeof e){if("function"===typeof e.then)return Os(e);if(e.$$typeof===w)return Nr(e)}throw Error(i(438,String(e)))}function Vs(e){var t=null,n=ys.updateQueue;if(null!==n&&(t=n.memoCache),null==t){var a=ys.alternate;null!==a&&(null!==(a=a.updateQueue)&&(null!=(a=a.memoCache)&&(t={data:a.data.map(function(e){return e.slice()}),index:0})))}if(null==t&&(t={data:[],index:0}),null===n&&(n={lastEffect:null,events:null,stores:null,memoCache:null},ys.updateQueue=n),n.memoCache=t,void 0===(n=t.data[t.index]))for(n=t.data[t.index]=Array(e),a=0;a<e;a++)n[a]=S;return t.index++,n}function Hs(e,t){return"function"===typeof t?t(e):t}function qs(e){return Ws(zs(),vs,e)}function Ws(e,t,n){var a=e.queue;if(null===a)throw Error(i(311));a.lastRenderedReducer=n;var r=e.baseQueue,s=a.pending;if(null!==s){if(null!==r){var o=r.next;r.next=s.next,s.next=o}t.baseQueue=r=s,a.pending=null}if(s=e.baseState,null===r)e.memoizedState=s;else{var l=o=null,c=null,d=t=r.next,u=!1;do{var m=-536870913&d.lane;if(m!==d.lane?(sc&m)===m:(bs&m)===m){var h=d.revertLane;if(0===h)null!==c&&(c=c.next={lane:0,revertLane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),m===Lr&&(u=!0);else{if((bs&h)===h){d=d.next,h===Lr&&(u=!0);continue}m={lane:0,revertLane:d.revertLane,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null},null===c?(l=c=m,o=s):c=c.next=m,ys.lanes|=h,hc|=h}m=d.action,Ds&&n(s,m),s=d.hasEagerState?d.eagerState:n(s,m)}else h={lane:m,revertLane:d.revertLane,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null},null===c?(l=c=h,o=s):c=c.next=h,ys.lanes|=m,hc|=m;d=d.next}while(null!==d&&d!==t);if(null===c?o=s:c.next=l,!Xn(s,e.memoizedState)&&(Fo=!0,u&&null!==(n=Rr)))throw n;e.memoizedState=s,e.baseState=o,e.baseQueue=c,a.lastRenderedState=s}return null===r&&(a.lanes=0),[e.memoizedState,a.dispatch]}function Ys(e){var t=zs(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var a=n.dispatch,r=n.pending,s=t.memoizedState;if(null!==r){n.pending=null;var o=r=r.next;do{s=e(s,o.action),o=o.next}while(o!==r);Xn(s,t.memoizedState)||(Fo=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,a]}function Gs(e,t,n){var a=ys,r=zs(),s=sr;if(s){if(void 0===n)throw Error(i(407));n=n()}else n=t();var o=!Xn((vs||r).memoizedState,n);if(o&&(r.memoizedState=n,Fo=!0),r=r.queue,xi(2048,8,Js.bind(null,a,r,e),[e]),r.getSnapshot!==t||o||null!==ws&&1&ws.memoizedState.tag){if(a.flags|=2048,hi(9,{destroy:void 0,resource:void 0},Xs.bind(null,a,r,n,t),null),null===ac)throw Error(i(349));s||0!==(124&bs)||Ks(a,t,n)}return n}function Ks(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=ys.updateQueue)?(t={lastEffect:null,events:null,stores:null,memoCache:null},ys.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Xs(e,t,n,a){t.value=n,t.getSnapshot=a,$s(t)&&Qs(e)}function Js(e,t,n){return n(function(){$s(t)&&Qs(e)})}function $s(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Xn(e,n)}catch(a){return!0}}function Qs(e){var t=Ta(e,2);null!==t&&Pc(t,e,2)}function Zs(e){var t=Rs();if("function"===typeof e){var n=e;if(e=n(),Ds){me(!0);try{n()}finally{me(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:e},t}function ei(e,t,n,a){return e.baseState=n,Ws(e,vs,"function"===typeof a?a:Hs)}function ti(e,t,n,a,r){if(Ui(e))throw Error(i(485));if(null!==(e=t.action)){var s={payload:r,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(e){s.listeners.push(e)}};null!==B.T?n(!0):s.isTransition=!1,a(s),null===(n=t.pending)?(s.next=t.pending=s,ni(t,s)):(s.next=n.next,t.pending=n.next=s)}}function ni(e,t){var n=t.action,a=t.payload,r=e.state;if(t.isTransition){var s=B.T,i={};B.T=i;try{var o=n(r,a),l=B.S;null!==l&&l(i,o),ai(e,t,o)}catch(c){si(e,t,c)}finally{B.T=s}}else try{ai(e,t,s=n(r,a))}catch(d){si(e,t,d)}}function ai(e,t,n){null!==n&&"object"===typeof n&&"function"===typeof n.then?n.then(function(n){ri(e,t,n)},function(n){return si(e,t,n)}):ri(e,t,n)}function ri(e,t,n){t.status="fulfilled",t.value=n,ii(t),e.state=n,null!==(t=e.pending)&&((n=t.next)===t?e.pending=null:(n=n.next,t.next=n,ni(e,n)))}function si(e,t,n){var a=e.pending;if(e.pending=null,null!==a){a=a.next;do{t.status="rejected",t.reason=n,ii(t),t=t.next}while(t!==a)}e.action=null}function ii(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function oi(e,t){return t}function li(e,t){if(sr){var n=ac.formState;if(null!==n){e:{var a=ys;if(sr){if(rr){t:{for(var r=rr,s=or;8!==r.nodeType;){if(!s){r=null;break t}if(null===(r=fu(r.nextSibling))){r=null;break t}}r="F!"===(s=r.data)||"F"===s?r:null}if(r){rr=fu(r.nextSibling),a="F!"===r.data;break e}}cr(a)}a=!1}a&&(t=n[0])}}return(n=Rs()).memoizedState=n.baseState=t,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:oi,lastRenderedState:t},n.queue=a,n=Ri.bind(null,ys,a),a.dispatch=n,a=Zs(!1),s=Oi.bind(null,ys,!1,a.queue),r={state:t,dispatch:null,action:e,pending:null},(a=Rs()).queue=r,n=ti.bind(null,ys,r,s,n),r.dispatch=n,a.memoizedState=e,[t,n,!1]}function ci(e){return di(zs(),vs,e)}function di(e,t,n){if(t=Ws(e,t,oi)[0],e=qs(Hs)[0],"object"===typeof t&&null!==t&&"function"===typeof t.then)try{var a=Os(t)}catch(i){if(i===Wr)throw Gr;throw i}else a=t;var r=(t=zs()).queue,s=r.dispatch;return n!==t.memoizedState&&(ys.flags|=2048,hi(9,{destroy:void 0,resource:void 0},ui.bind(null,r,n),null)),[a,s,e]}function ui(e,t){e.action=t}function mi(e){var t=zs(),n=vs;if(null!==n)return di(t,n,e);zs(),t=t.memoizedState;var a=(n=zs()).queue.dispatch;return n.memoizedState=e,[t,a,!1]}function hi(e,t,n,a){return e={tag:e,create:n,deps:a,inst:t,next:null},null===(t=ys.updateQueue)&&(t={lastEffect:null,events:null,stores:null,memoCache:null},ys.updateQueue=t),null===(n=t.lastEffect)?t.lastEffect=e.next=e:(a=n.next,n.next=e,e.next=a,t.lastEffect=e),e}function pi(){return zs().memoizedState}function gi(e,t,n,a){var r=Rs();a=void 0===a?null:a,ys.flags|=e,r.memoizedState=hi(1|t,{destroy:void 0,resource:void 0},n,a)}function xi(e,t,n,a){var r=zs();a=void 0===a?null:a;var s=r.memoizedState.inst;null!==vs&&null!==a&&As(a,vs.memoizedState.deps)?r.memoizedState=hi(t,s,n,a):(ys.flags|=e,r.memoizedState=hi(1|t,s,n,a))}function fi(e,t){gi(8390656,8,e,t)}function bi(e,t){xi(2048,8,e,t)}function yi(e,t){return xi(4,2,e,t)}function vi(e,t){return xi(4,4,e,t)}function wi(e,t){if("function"===typeof t){e=e();var n=t(e);return function(){"function"===typeof n?n():t(null)}}if(null!==t&&void 0!==t)return e=e(),t.current=e,function(){t.current=null}}function ki(e,t,n){n=null!==n&&void 0!==n?n.concat([e]):null,xi(4,4,wi.bind(null,t,e),n)}function ji(){}function Di(e,t){var n=zs();t=void 0===t?null:t;var a=n.memoizedState;return null!==t&&As(t,a[1])?a[0]:(n.memoizedState=[e,t],e)}function Ci(e,t){var n=zs();t=void 0===t?null:t;var a=n.memoizedState;if(null!==t&&As(t,a[1]))return a[0];if(a=e(),Ds){me(!0);try{e()}finally{me(!1)}}return n.memoizedState=[a,t],a}function Ni(e,t,n){return void 0===n||0!==(1073741824&bs)?e.memoizedState=t:(e.memoizedState=n,e=Ic(),ys.lanes|=e,hc|=e,n)}function Fi(e,t,n,a){return Xn(n,t)?n:null!==hs.current?(e=Ni(e,n,a),Xn(e,t)||(Fo=!0),e):0===(42&bs)?(Fo=!0,e.memoizedState=n):(e=Ic(),ys.lanes|=e,hc|=e,t)}function Si(e,t,n,a,r){var s=I.p;I.p=0!==s&&8>s?s:8;var i=B.T,o={};B.T=o,Oi(e,!1,t,n);try{var l=r(),c=B.S;if(null!==c&&c(o,l),null!==l&&"object"===typeof l&&"function"===typeof l.then)zi(e,t,function(e,t){var n=[],a={status:"pending",value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){a.status="fulfilled",a.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(a.status="rejected",a.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),a}(l,a),Bc());else zi(e,t,a,Bc())}catch(d){zi(e,t,{then:function(){},status:"rejected",reason:d},Bc())}finally{I.p=s,B.T=i}}function Ei(){}function Ai(e,t,n,a){if(5!==e.tag)throw Error(i(476));var r=Ti(e).queue;Si(e,r,t,P,null===n?Ei:function(){return Mi(e),n(a)})}function Ti(e){var t=e.memoizedState;if(null!==t)return t;var n={};return(t={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:P},next:null}).next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:n},next:null},e.memoizedState=t,null!==(e=e.alternate)&&(e.memoizedState=t),t}function Mi(e){zi(e,Ti(e).next.queue,{},Bc())}function _i(){return Nr(Ku)}function Bi(){return zs().memoizedState}function Ii(){return zs().memoizedState}function Pi(e){for(var t=e.return;null!==t;){switch(t.tag){case 24:case 3:var n=Bc(),a=ss(t,e=rs(n),n);return null!==a&&(Pc(a,t,n),is(a,t,n)),t={cache:_r()},void(e.payload=t)}t=t.return}}function Li(e,t,n){var a=Bc();n={lane:a,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null},Ui(e)?Vi(t,n):null!==(n=Aa(e,t,n,a))&&(Pc(n,e,a),Hi(n,t,a))}function Ri(e,t,n){zi(e,t,n,Bc())}function zi(e,t,n,a){var r={lane:a,revertLane:0,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ui(e))Vi(t,r);else{var s=e.alternate;if(0===e.lanes&&(null===s||0===s.lanes)&&null!==(s=t.lastRenderedReducer))try{var i=t.lastRenderedState,o=s(i,n);if(r.hasEagerState=!0,r.eagerState=o,Xn(o,i))return Ea(e,t,r,0),null===ac&&Sa(),!1}catch(l){}if(null!==(n=Aa(e,t,r,a)))return Pc(n,e,a),Hi(n,t,a),!0}return!1}function Oi(e,t,n,a){if(a={lane:2,revertLane:Ed(),action:a,hasEagerState:!1,eagerState:null,next:null},Ui(e)){if(t)throw Error(i(479))}else null!==(t=Aa(e,n,a,2))&&Pc(t,e,2)}function Ui(e){var t=e.alternate;return e===ys||null!==t&&t===ys}function Vi(e,t){js=ks=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Hi(e,t,n){if(0!==(4194048&n)){var a=t.lanes;n|=a&=e.pendingLanes,t.lanes=n,Fe(e,n)}}var qi={readContext:Nr,use:Us,useCallback:Es,useContext:Es,useEffect:Es,useImperativeHandle:Es,useLayoutEffect:Es,useInsertionEffect:Es,useMemo:Es,useReducer:Es,useRef:Es,useState:Es,useDebugValue:Es,useDeferredValue:Es,useTransition:Es,useSyncExternalStore:Es,useId:Es,useHostTransitionStatus:Es,useFormState:Es,useActionState:Es,useOptimistic:Es,useMemoCache:Es,useCacheRefresh:Es},Wi={readContext:Nr,use:Us,useCallback:function(e,t){return Rs().memoizedState=[e,void 0===t?null:t],e},useContext:Nr,useEffect:fi,useImperativeHandle:function(e,t,n){n=null!==n&&void 0!==n?n.concat([e]):null,gi(4194308,4,wi.bind(null,t,e),n)},useLayoutEffect:function(e,t){return gi(4194308,4,e,t)},useInsertionEffect:function(e,t){gi(4,2,e,t)},useMemo:function(e,t){var n=Rs();t=void 0===t?null:t;var a=e();if(Ds){me(!0);try{e()}finally{me(!1)}}return n.memoizedState=[a,t],a},useReducer:function(e,t,n){var a=Rs();if(void 0!==n){var r=n(t);if(Ds){me(!0);try{n(t)}finally{me(!1)}}}else r=t;return a.memoizedState=a.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},a.queue=e,e=e.dispatch=Li.bind(null,ys,e),[a.memoizedState,e]},useRef:function(e){return e={current:e},Rs().memoizedState=e},useState:function(e){var t=(e=Zs(e)).queue,n=Ri.bind(null,ys,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ji,useDeferredValue:function(e,t){return Ni(Rs(),e,t)},useTransition:function(){var e=Zs(!1);return e=Si.bind(null,ys,e.queue,!0,!1),Rs().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var a=ys,r=Rs();if(sr){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===ac)throw Error(i(349));0!==(124&sc)||Ks(a,t,n)}r.memoizedState=n;var s={value:n,getSnapshot:t};return r.queue=s,fi(Js.bind(null,a,s,e),[e]),a.flags|=2048,hi(9,{destroy:void 0,resource:void 0},Xs.bind(null,a,s,n,t),null),n},useId:function(){var e=Rs(),t=ac.identifierPrefix;if(sr){var n=Qa;t="\xab"+t+"R"+(n=($a&~(1<<32-he($a)-1)).toString(32)+n),0<(n=Cs++)&&(t+="H"+n.toString(32)),t+="\xbb"}else t="\xab"+t+"r"+(n=Ss++).toString(32)+"\xbb";return e.memoizedState=t},useHostTransitionStatus:_i,useFormState:li,useActionState:li,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=Oi.bind(null,ys,!0,n),n.dispatch=t,[e,t]},useMemoCache:Vs,useCacheRefresh:function(){return Rs().memoizedState=Pi.bind(null,ys)}},Yi={readContext:Nr,use:Us,useCallback:Di,useContext:Nr,useEffect:bi,useImperativeHandle:ki,useInsertionEffect:yi,useLayoutEffect:vi,useMemo:Ci,useReducer:qs,useRef:pi,useState:function(){return qs(Hs)},useDebugValue:ji,useDeferredValue:function(e,t){return Fi(zs(),vs.memoizedState,e,t)},useTransition:function(){var e=qs(Hs)[0],t=zs().memoizedState;return["boolean"===typeof e?e:Os(e),t]},useSyncExternalStore:Gs,useId:Bi,useHostTransitionStatus:_i,useFormState:ci,useActionState:ci,useOptimistic:function(e,t){return ei(zs(),0,e,t)},useMemoCache:Vs,useCacheRefresh:Ii},Gi={readContext:Nr,use:Us,useCallback:Di,useContext:Nr,useEffect:bi,useImperativeHandle:ki,useInsertionEffect:yi,useLayoutEffect:vi,useMemo:Ci,useReducer:Ys,useRef:pi,useState:function(){return Ys(Hs)},useDebugValue:ji,useDeferredValue:function(e,t){var n=zs();return null===vs?Ni(n,e,t):Fi(n,vs.memoizedState,e,t)},useTransition:function(){var e=Ys(Hs)[0],t=zs().memoizedState;return["boolean"===typeof e?e:Os(e),t]},useSyncExternalStore:Gs,useId:Bi,useHostTransitionStatus:_i,useFormState:mi,useActionState:mi,useOptimistic:function(e,t){var n=zs();return null!==vs?ei(n,0,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:Vs,useCacheRefresh:Ii},Ki=null,Xi=0;function Ji(e){var t=Xi;return Xi+=1,null===Ki&&(Ki=[]),$r(Ki,e,t)}
vendor: 4,179 bytes, line 2
2function $i(e,t){t=t.props.ref,e.ref=void 0!==t?t:null}function Qi(e,t){if(t.$$typeof===h)throw Error(i(525));throw e=Object.prototype.toString.call(t),Error(i(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Zi(e){return(0,e._init)(e._payload)}function eo(e){function t(t,n){if(e){var a=t.deletions;null===a?(t.deletions=[n],t.flags|=16):a.push(n)}}function n(n,a){if(!e)return null;for(;null!==a;)t(n,a),a=a.sibling;return null}function a(e){for(var t=new Map;null!==e;)null!==e.key?t.set(e.key,e):t.set(e.index,e),e=e.sibling;return t}function r(e,t){return(e=Ra(e,t)).index=0,e.sibling=null,e}function s(t,n,a){return t.index=a,e?null!==(a=t.alternate)?(a=a.index)<n?(t.flags|=67108866,n):a:(t.flags|=67108866,n):(t.flags|=1048576,n)}function o(t){return e&&null===t.alternate&&(t.flags|=67108866),t}function l(e,t,n,a){return null===t||6!==t.tag?((t=Va(n,e.mode,a)).return=e,t):((t=r(t,n)).return=e,t)}function c(e,t,n,a){var s=n.type;return s===x?u(e,t,n.props.children,a,n.key):null!==t&&(t.elementType===s||"object"===typeof s&&null!==s&&s.$$typeof===N&&Zi(s)===t.type)?($i(t=r(t,n.props),n),t.return=e,t):($i(t=Oa(n.type,n.key,n.props,null,e.mode,a),n),t.return=e,t)}function d(e,t,n,a){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Ha(n,e.mode,a)).return=e,t):((t=r(t,n.children||[])).return=e,t)}function u(e,t,n,a,s){return null===t||7!==t.tag?((t=Ua(n,e.mode,a,s)).return=e,t):((t=r(t,n)).return=e,t)}function m(e,t,n){if("string"===typeof t&&""!==t||"number"===typeof t||"bigint"===typeof t)return(t=Va(""+t,e.mode,n)).return=e,t;if("object"===typeof t&&null!==t){switch(t.$$typeof){case p:return $i(n=Oa(t.type,t.key,t.props,null,e.mode,n),t),n.return=e,n;case g:return(t=Ha(t,e.mode,n)).return=e,t;case N:return m(e,t=(0,t._init)(t._payload),n)}if(_(t)||A(t))return(t=Ua(t,e.mode,n,null)).return=e,t;if("function"===typeof t.then)return m(e,Ji(t),n);if(t.$$typeof===w)return m(e,Fr(e,t),n);Qi(e,t)}return null}function h(e,t,n,a){var r=null!==t?t.key:null;if("string"===typeof n&&""!==n||"number"===typeof n||"bigint"===typeof n)return null!==r?null:l(e,t,""+n,a);if("object"===typeof n&&null!==n){switch(n.$$typeof){case p:return n.key===r?c(e,t,n,a):null;case g:return n.key===r?d(e,t,n,a):null;case N:return h(e,t,n=(r=n._init)(n._payload),a)}if(_(n)||A(n))return null!==r?null:u(e,t,n,a,null);if("function"===typeof n.then)return h(e,t,Ji(n),a);if(n.$$typeof===w)return h(e,t,Fr(e,n),a);Qi(e,n)}return null}function f(e,t,n,a,r){if("string"===typeof a&&""!==a||"number"===typeof a||"bigint"===typeof a)return l(t,e=e.get(n)||null,""+a,r);if("object"===typeof a&&null!==a){switch(a.$$typeof){case p:return c(t,e=e.get(null===a.key?n:a.key)||null,a,r);case g:return d(t,e=e.get(null===a.key?n:a.key)||null,a,r);case N:return f(e,t,n,a=(0,a._init)(a._payload),r)}if(_(a)||A(a))return u(t,e=e.get(n)||null,a,r,null);if("function"===typeof a.then)return f(e,t,n,Ji(a),r);if(a.$$typeof===w)return f(e,t,n,Fr(t,a),r);Qi(t,a)}return null}function b(l,c,d,u){if("object"===typeof d&&null!==d&&d.type===x&&null===d.key&&(d=d.props.children),"object"===typeof d&&null!==d){switch(d.$$typeof){case p:e:{for(var y=d.key;null!==c;){if(c.key===y){if((y=d.type)===x){if(7===c.tag){n(l,c.sibling),(u=r(c,d.props.children)).return=l,l=u;break e}}else if(c.elementType===y||"object"===typeof y&&null!==y&&y.$$typeof===N&&Zi(y)===c.type){n(l,c.sibling),$i(u=r(c,d.props),d),u.return=l,l=u;break e}n(l,c);break}t(l,c),c=c.sibling}d.type===x?((u=Ua(d.props.children,l.mode,u,d.key)).return=l,l=u):($i(u=Oa(d.type,d.key,d.props,null,l.mode,u),d),u.return=l,l=u)}return o(l);case g:e:{for(y=d.key;null!==c;){if(c.key===y){if(4===c.tag&&c.stateNode.containerInfo===d.containerInfo&&c.stateNode.implementation===d.implementation){n(l,c.sibling),(u=r(c,d.children||[])).return=l,l=u;break e}n(l,c);break}t(l,c),c=c.sibling}(u=Ha(d,l.mode,u)).return=l,l=u}return o(l);case N:return b(l,c,d=(y=d._init)(d._payload),u)}if(_(d))return function(r,i,o,l){for(var c=null,d=null,u=i,p=i=0,g=null;null!==u&&p<o.length;p++){u.index>p?(g=u,u=null):g=u.sibling;var x=h(r,u,o[p],l);
2if(null===x){null===u&&(u=g);break}e&&u&&null===x.alternate&&t(r,u),i=s(x,i,p),null===d?c=x:d.sibling=x,d=x,u=g}if(p===o.length)return n(r,u),sr&&Za(r,p),c;if(null===u){for(;p<o.length;p++)null!==(u=m(r,o[p],l))&&(i=s(u,i,p),null===d?c=u:d.sibling=u,d=u);return sr&&Za(r,p),c}for(u=a(u);p<o.length;p++)null!==(g=f(u,r,p,o[p],l))&&(e&&null!==g.alternate&&u.delete(null===g.key?p:g.key),i=s(g,i,p),null===d?c=g:d.sibling=g,d=g);return e&&u.forEach(function(e){return t(r,e)}),sr&&Za(r,p),c}(l,c,d,u);if(A(d)){if("function"!==typeof(y=A(d)))throw Error(i(150));return function(r,o,l,c){if(null==l)throw Error(i(151));for(var d=null,u=null,p=o,g=o=0,x=null,b=l.next();null!==p&&!b.done;g++,b=l.next()){p.index>g?(x=p,p=null):x=p.sibling;var y=h(r,p,b.value,c);if(null===y){null===p&&(p=x);break}e&&p&&null===y.alternate&&t(r,p),o=s(y,o,g),null===u?d=y:u.sibling=y,u=y,p=x}if(b.done)return n(r,p),sr&&Za(r,g),d;if(null===p){for(;!b.done;g++,b=l.next())null!==(b=m(r,b.value,c))&&(o=s(b,o,g),null===u?d=b:u.sibling=b,u=b);return sr&&Za(r,g),d}for(p=a(p);!b.done;g++,b=l.next())null!==(b=f(p,r,g,b.value,c))&&(e&&null!==b.alternate&&p.delete(null===b.key?g:b.key),o=s(b,o,g),null===u?d=b:u.sibling=b,u=b);return e&&p.forEach(function(e){return t(r,e)}),sr&&Za(r,g),d}(l,c,d=y.call(d),u)}if("function"===typeof d.then)return b(l,c,Ji(d),u);if(d.$$typeof===w)return b(l,c,Fr(l,d),u);Qi(l,d)}return"string"===typeof d&&""!==d||"number"===typeof d||"bigint"===typeof d?(d=""+d,null!==c&&6===c.tag?(n(l,c.sibling),(u=r(c,d)).return=l,l=u):(n(l,c),(u=Va(d,l.mode,u)).return=l,l=u),o(l)):n(l,c)}return function(e,t,n,a){try{Xi=0;var r=b(e,t,n,a);return Ki=null,r}catch(i){if(i===Wr||i===Gr)throw i;var s=Pa(29,i,null,e.mode);return s.lanes=a,s.return=e,s}}}var to=eo(!0),no=eo(!1),ao=z(null),ro=null;function so(e){var t=e.alternate;U(co,1&co.current),U(ao,e),null===ro&&(null===t||null!==hs.current||null!==t.memoizedState)&&(ro=e)}function io(e){if(22===e.tag){if(U(co,co.current),U(ao,e),null===ro){var t=e.alternate;null!==t&&null!==t.memoizedState&&(ro=e)}}else oo()}function oo(){U(co,co.current),U(ao,ao.current)}function lo(e){O(ao),ro===e&&(ro=null),O(co)}var co=z(0);function uo(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||xu(n)))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!==(128&t.flags))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function mo(e,t,n,a){n=null===(n=n(a,t=e.memoizedState))||void 0===n?t:m({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var ho={enqueueSetState:function(e,t,n){e=e._reactInternals;var a=Bc(),r=rs(a);r.payload=t,void 0!==n&&null!==n&&(r.callback=n),null!==(t=ss(e,r,a))&&(Pc(t,e,a),is(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var a=Bc(),r=rs(a);r.tag=1,r.payload=t,void 0!==n&&null!==n&&(r.callback=n),null!==(t=ss(e,r,a))&&(Pc(t,e,a),is(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Bc(),a=rs(n);a.tag=2,void 0!==t&&null!==t&&(a.callback=t),null!==(t=ss(e,a,n))&&(Pc(t,e,n),is(t,e,n))}};function po(e,t,n,a,r,s,i){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(a,s,i):!t.prototype||!t.prototype.isPureReactComponent||(!Jn(n,a)||!Jn(r,s))}function go(e,t,n,a){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,a),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,a),t.state!==e&&ho.enqueueReplaceState(t,t.state,null)}function xo(e,t){var n=t;if("ref"in t)for(var a in n={},t)"ref"!==a&&(n[a]=t[a]);if(e=e.defaultProps)for(var r in n===t&&(n=m({},n)),e)void 0===n[r]&&(n[r]=e[r]);return n}var fo="function"===typeof reportError?reportError:function(e){if("object"===typeof window&&"function"===typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"===typeof e&&null!==e&&"string"===typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"===typeof process&&"function"===typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)};function bo(e){fo(e)}function yo(e){console.error(e)}function vo(e){fo(e)}function wo(e,t){try{(0,e.onUncaughtError)(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function ko(e,t,n){try{(0,e.onCaughtError)(n.value,{componentStack:n.stack,errorBoundary:1===t.tag?t.stateNode:null})}catch(a){setTimeout(function(){throw a})}}function jo(e,t,n){return(n=rs(n)).tag=3,n.payload={element:null},n.callback=function(){wo(e,t)},n}function Do(e){return(e=rs(e)).tag=3,e}function Co(e,t,n,a){var r=n.type.getDerivedStateFromError;if("function"===typeof r){var s=a.value;e.payload=function(){return r(s)},e.callback=function(){ko(t,n,a)}}var i=n.stateNode;null!==i&&"function"===typeof i.componentDidCatch&&(e.callback=function(){ko(t,n,a),"function"!==typeof r&&(null===Dc?Dc=new Set([this]):Dc.add(this));var e=a.stack;this.componentDidCatch(a.value,{componentStack:null!==e?e:""})})}var No=Error(i(461)),Fo=!1;function So(e,t,n,a){t.child=null===e?no(t,null,n,a):to(t,e.child,n,a)}function Eo(e,t,n,a,r){n=n.render;var s=t.ref;if("ref"in a){var i={};for(var o in a)"ref"!==o&&(i[o]=a[o])}else i=a;return Cr(t),a=Ts(e,t,n,i,s,r),o=Is(),null===e||Fo?(sr&&o&&tr(t),t.flags|=1,So(e,t,a,r),t.child):(Ps(e,t,r),Xo(e,t,r))}function Ao(e,t,n,a,r){if(null===e){var s=n.type;return"function"!==typeof s||La(s)||void 0!==s.defaultProps||null!==n.compare?((e=Oa(n.type,null,a,t,t.mode,r)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=s,To(e,t,s,a,r))}if(s=e.child,!Jo(e,r)){var i=s.memoizedProps;
2if((n=null!==(n=n.compare)?n:Jn)(i,a)&&e.ref===t.ref)return Xo(e,t,r)}return t.flags|=1,(e=Ra(s,a)).ref=t.ref,e.return=t,t.child=e}function To(e,t,n,a,r){if(null!==e){var s=e.memoizedProps;if(Jn(s,a)&&e.ref===t.ref){if(Fo=!1,t.pendingProps=a=s,!Jo(e,r))return t.lanes=e.lanes,Xo(e,t,r);0!==(131072&e.flags)&&(Fo=!0)}}return Io(e,t,n,a,r)}function Mo(e,t,n){var a=t.pendingProps,r=a.children,s=null!==e?e.memoizedState:null;if("hidden"===a.mode){if(0!==(128&t.flags)){if(a=null!==s?s.baseLanes|n:n,null!==e){for(r=t.child=e.child,s=0;null!==r;)s=s|r.lanes|r.childLanes,r=r.sibling;t.childLanes=s&~a}else t.childLanes=0,t.child=null;return _o(e,t,a,n)}if(0===(536870912&n))return t.lanes=t.childLanes=536870912,_o(e,t,null!==s?s.baseLanes|n:n,n);t.memoizedState={baseLanes:0,cachePool:null},null!==e&&Hr(0,null!==s?s.cachePool:null),null!==s?gs(t,s):xs(),io(t)}else null!==s?(Hr(0,s.cachePool),gs(t,s),oo(),t.memoizedState=null):(null!==e&&Hr(0,null),xs(),oo());return So(e,t,r,n),t.child}function _o(e,t,n,a){var r=Vr();return r=null===r?null:{parent:Mr._currentValue,pool:r},t.memoizedState={baseLanes:n,cachePool:r},null!==e&&Hr(0,null),xs(),io(t),null!==e&&jr(e,t,a,!0),null}function Bo(e,t){var n=t.ref;if(null===n)null!==e&&null!==e.ref&&(t.flags|=4194816);else{if("function"!==typeof n&&"object"!==typeof n)throw Error(i(284));null!==e&&e.ref===n||(t.flags|=4194816)}}function Io(e,t,n,a,r){return Cr(t),n=Ts(e,t,n,a,void 0,r),a=Is(),null===e||Fo?(sr&&a&&tr(t),t.flags|=1,So(e,t,n,r),t.child):(Ps(e,t,r),Xo(e,t,r))}function Po(e,t,n,a,r,s){return Cr(t),t.updateQueue=null,n=_s(t,a,n,r),Ms(e),a=Is(),null===e||Fo?(sr&&a&&tr(t),t.flags|=1,So(e,t,n,s),t.child):(Ps(e,t,s),Xo(e,t,s))}function Lo(e,t,n,a,r){if(Cr(t),null===t.stateNode){var s=Ba,i=n.contextType;"object"===typeof i&&null!==i&&(s=Nr(i)),s=new n(a,s),t.memoizedState=null!==s.state&&void 0!==s.state?s.state:null,s.updater=ho,t.stateNode=s,s._reactInternals=t,(s=t.stateNode).props=a,s.state=t.memoizedState,s.refs={},ns(t),i=n.contextType,s.context="object"===typeof i&&null!==i?Nr(i):Ba,s.state=t.memoizedState,"function"===typeof(i=n.getDerivedStateFromProps)&&(mo(t,n,i,a),s.state=t.memoizedState),"function"===typeof n.getDerivedStateFromProps||"function"===typeof s.getSnapshotBeforeUpdate||"function"!==typeof s.UNSAFE_componentWillMount&&"function"!==typeof s.componentWillMount||(i=s.state,"function"===typeof s.componentWillMount&&s.componentWillMount(),"function"===typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount(),i!==s.state&&ho.enqueueReplaceState(s,s.state,null),ds(t,a,s,r),cs(),s.state=t.memoizedState),"function"===typeof s.componentDidMount&&(t.flags|=4194308),a=!0}else if(null===e){s=t.stateNode;var o=t.memoizedProps,l=xo(n,o);s.props=l;var c=s.context,d=n.contextType;i=Ba,"object"===typeof d&&null!==d&&(i=Nr(d));var u=n.getDerivedStateFromProps;d="function"===typeof u||"function"===typeof s.getSnapshotBeforeUpdate,o=t.pendingProps!==o,d||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(o||c!==i)&&go(t,s,a,i),ts=!1;var m=t.memoizedState;s.state=m,ds(t,a,s,r),cs(),c=t.memoizedState,o||m!==c||ts?("function"===typeof u&&(mo(t,n,u,a),c=t.memoizedState),(l=ts||po(t,n,l,a,m,c,i))?(d||"function"!==typeof s.UNSAFE_componentWillMount&&"function"!==typeof s.componentWillMount||("function"===typeof s.componentWillMount&&s.componentWillMount(),"function"===typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount()),"function"===typeof s.componentDidMount&&(t.flags|=4194308)):("function"===typeof s.componentDidMount&&(t.flags|=4194308),t.memoizedProps=a,t.memoizedState=c),s.props=a,s.state=c,s.context=i,a=l):("function"===typeof s.componentDidMount&&(t.flags|=4194308),a=!1)}else{s=t.stateNode,as(e,t),d=xo(n,i=t.memoizedProps),s.props=d,u=t.pendingProps,m=s.context,c=n.contextType,l=Ba,"object"===typeof c&&null!==c&&(l=Nr(c)),(c="function"===typeof(o=n.getDerivedStateFromProps)||"function"===typeof s.getSnapshotBeforeUpdate)||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(i!==u||m!==l)&&go(t,s,a,l),ts=!1,m=t.memoizedState,s.state=m,ds(t,a,s,r),cs();var h=t.memoizedState;
vendor: 10,609 bytes, line 2
2i!==u||m!==h||ts||null!==e&&null!==e.dependencies&&Dr(e.dependencies)?("function"===typeof o&&(mo(t,n,o,a),h=t.memoizedState),(d=ts||po(t,n,d,a,m,h,l)||null!==e&&null!==e.dependencies&&Dr(e.dependencies))?(c||"function"!==typeof s.UNSAFE_componentWillUpdate&&"function"!==typeof s.componentWillUpdate||("function"===typeof s.componentWillUpdate&&s.componentWillUpdate(a,h,l),"function"===typeof s.UNSAFE_componentWillUpdate&&s.UNSAFE_componentWillUpdate(a,h,l)),"function"===typeof s.componentDidUpdate&&(t.flags|=4),"function"===typeof s.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof s.componentDidUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=a,t.memoizedState=h),s.props=a,s.state=h,s.context=l,a=d):("function"!==typeof s.componentDidUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||i===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),a=!1)}return s=a,Bo(e,t),a=0!==(128&t.flags),s||a?(s=t.stateNode,n=a&&"function"!==typeof n.getDerivedStateFromError?null:s.render(),t.flags|=1,null!==e&&a?(t.child=to(t,e.child,null,r),t.child=to(t,null,n,r)):So(e,t,n,r),t.memoizedState=s.state,e=t.child):e=Xo(e,t,r),e}function Ro(e,t,n,a){return hr(),t.flags|=256,So(e,t,n,a),t.child}var zo={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Oo(e){return{baseLanes:e,cachePool:qr()}}function Uo(e,t,n){return e=null!==e?e.childLanes&~n:0,t&&(e|=xc),e}function Vo(e,t,n){var a,r=t.pendingProps,s=!1,o=0!==(128&t.flags);if((a=o)||(a=(null===e||null!==e.memoizedState)&&0!==(2&co.current)),a&&(s=!0,t.flags&=-129),a=0!==(32&t.flags),t.flags&=-33,null===e){if(sr){if(s?so(t):oo(),sr){var l,c=rr;if(l=c){e:{for(l=c,c=or;8!==l.nodeType;){if(!c){c=null;break e}if(null===(l=fu(l.nextSibling))){c=null;break e}}c=l}null!==c?(t.memoizedState={dehydrated:c,treeContext:null!==Ja?{id:$a,overflow:Qa}:null,retryLane:536870912,hydrationErrors:null},(l=Pa(18,null,null,0)).stateNode=c,l.return=t,t.child=l,ar=t,rr=null,l=!0):l=!1}l||cr(t)}if(null!==(c=t.memoizedState)&&null!==(c=c.dehydrated))return xu(c)?t.lanes=32:t.lanes=536870912,null;lo(t)}return c=r.children,r=r.fallback,s?(oo(),c=qo({mode:"hidden",children:c},s=t.mode),r=Ua(r,s,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,(s=t.child).memoizedState=Oo(n),s.childLanes=Uo(e,a,n),t.memoizedState=zo,r):(so(t),Ho(t,c))}if(null!==(l=e.memoizedState)&&null!==(c=l.dehydrated)){if(o)256&t.flags?(so(t),t.flags&=-257,t=Wo(e,t,n)):null!==t.memoizedState?(oo(),t.child=e.child,t.flags|=128,t=null):(oo(),s=r.fallback,c=t.mode,r=qo({mode:"visible",children:r.children},c),(s=Ua(s,c,n,null)).flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,to(t,e.child,null,n),(r=t.child).memoizedState=Oo(n),r.childLanes=Uo(e,a,n),t.memoizedState=zo,t=s);else if(so(t),xu(c)){if(a=c.nextSibling&&c.nextSibling.dataset)var d=a.dgst;a=d,(r=Error(i(419))).stack="",r.digest=a,gr({value:r,source:null,stack:null}),t=Wo(e,t,n)}else if(Fo||jr(e,t,n,!1),a=0!==(n&e.childLanes),Fo||a){if(null!==(a=ac)&&(0!==(r=0!==((r=0!==(42&(r=n&-n))?1:Se(r))&(a.suspendedLanes|n))?0:r)&&r!==l.retryLane))throw l.retryLane=r,Ta(e,r),Pc(a,e,r),No;"$?"===c.data||Gc(),t=Wo(e,t,n)}else"$?"===c.data?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,rr=fu(c.nextSibling),ar=t,sr=!0,ir=null,or=!1,null!==e&&(Ka[Xa++]=$a,Ka[Xa++]=Qa,Ka[Xa++]=Ja,$a=e.id,Qa=e.overflow,Ja=t),(t=Ho(t,r.children)).flags|=4096);return t}return s?(oo(),s=r.fallback,c=t.mode,d=(l=e.child).sibling,(r=Ra(l,{mode:"hidden",children:r.children})).subtreeFlags=65011712&l.subtreeFlags,null!==d?s=Ra(d,s):(s=Ua(s,c,n,null)).flags|=2,s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,null===(c=e.child.memoizedState)?c=Oo(n):(null!==(l=c.cachePool)?(d=Mr._currentValue,l=l.parent!==d?{parent:d,pool:d}:l):l=qr(),c={baseLanes:c.baseLanes|n,cachePool:l}),s.memoizedState=c,s.childLanes=Uo(e,a,n),t.memoizedState=zo,r):(so(t),e=(n=e.child).sibling,(n=Ra(n,{mode:"visible",children:r.children})).return=t,n.sibling=null,null!==e&&(null===(a=t.deletions)?(t.deletions=[e],t.flags|=16):a.push(e)),t.child=n,t.memoizedState=null,n)}function Ho(e,t){return(t=qo({mode:"visible",children:t},e.mode)).return=e,e.child=t}function qo(e,t){return(e=Pa(22,e,null,t)).lanes=0,e.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null},e}function Wo(e,t,n){return to(t,e.child,null,n),(e=Ho(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function Yo(e,t,n){e.lanes|=t;var a=e.alternate;null!==a&&(a.lanes|=t),wr(e.return,t,n)}function Go(e,t,n,a,r){var s=e.memoizedState;null===s?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:a,tail:n,tailMode:r}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=a,s.tail=n,s.tailMode=r)}function Ko(e,t,n){var a=t.pendingProps,r=a.revealOrder,s=a.tail;if(So(e,t,a.children,n),0!==(2&(a=co.current)))a=1&a|2,t.flags|=128;else{if(null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&Yo(e,n,t);else if(19===e.tag)Yo(e,n,t);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}a&=1}switch(U(co,a),r){case"forwards":for(n=t.child,r=null;null!==n;)null!==(e=n.alternate)&&null===uo(e)&&(r=n),n=n.sibling;null===(n=r)?(r=t.child,t.child=null):(r=n.sibling,n.sibling=null),Go(t,!1,r,n,s);break;case"backwards":for(n=null,r=t.child,t.child=null;null!==r;){if(null!==(e=r.alternate)&&null===uo(e)){t.child=r;break}e=r.sibling,r.sibling=n,n=r,r=e}Go(t,!0,n,null,s);break;case"together":Go(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Xo(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),hc|=t.lanes,0===(n&t.childLanes)){if(null===e)return null;if(jr(e,t,n,!1),0===(n&t.childLanes))return null}if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=Ra(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Ra(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function Jo(e,t){return 0!==(e.lanes&t)||!(null===(e=e.dependencies)||!Dr(e))}function $o(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps)Fo=!0;else{if(!Jo(e,n)&&0===(128&t.flags))return Fo=!1,function(e,t,n){switch(t.tag){case 3:Y(t,t.stateNode.containerInfo),yr(0,Mr,e.memoizedState.cache),hr();break;case 27:case 5:K(t);break;case 4:Y(t,t.stateNode.containerInfo);break;case 10:yr(0,t.type,t.memoizedProps.value);break;case 13:var a=t.memoizedState;if(null!==a)return null!==a.dehydrated?(so(t),t.flags|=128,null):0!==(n&t.child.childLanes)?Vo(e,t,n):(so(t),null!==(e=Xo(e,t,n))?e.sibling:null);so(t);break;case 19:var r=0!==(128&e.flags);if((a=0!==(n&t.childLanes))||(jr(e,t,n,!1),a=0!==(n&t.childLanes)),r){if(a)return Ko(e,t,n);t.flags|=128}if(null!==(r=t.memoizedState)&&(r.rendering=null,r.tail=null,r.lastEffect=null),U(co,co.current),a)break;return null;case 22:case 23:return t.lanes=0,Mo(e,t,n);case 24:yr(0,Mr,e.memoizedState.cache)}return Xo(e,t,n)}(e,t,n);Fo=0!==(131072&e.flags)}else Fo=!1,sr&&0!==(1048576&t.flags)&&er(t,Ga,t.index);switch(t.lanes=0,t.tag){case 16:e:{e=t.pendingProps;var a=t.elementType,r=a._init;if(a=r(a._payload),t.type=a,"function"!==typeof a){if(void 0!==a&&null!==a){if((r=a.$$typeof)===k){t.tag=11,t=Eo(null,t,a,e,n);break e}if(r===C){t.tag=14,t=Ao(null,t,a,e,n);break e}}throw t=M(a)||a,Error(i(306,t,""))}La(a)?(e=xo(a,e),t.tag=1,t=Lo(null,t,a,e,n)):(t.tag=0,t=Io(null,t,a,e,n))}return t;case 0:return Io(e,t,t.type,t.pendingProps,n);case 1:return Lo(e,t,a=t.type,r=xo(a,t.pendingProps),n);case 3:e:{if(Y(t,t.stateNode.containerInfo),null===e)throw Error(i(387));a=t.pendingProps;var s=t.memoizedState;r=s.element,as(e,t),ds(t,a,null,n);var o=t.memoizedState;if(a=o.cache,yr(0,Mr,a),a!==s.cache&&kr(t,[Mr],n,!0),cs(),a=o.element,s.isDehydrated){if(s={element:a,isDehydrated:!1,cache:o.cache},t.updateQueue.baseState=s,t.memoizedState=s,256&t.flags){t=Ro(e,t,a,n);break e}if(a!==r){gr(r=Da(Error(i(424)),t)),t=Ro(e,t,a,n);break e}if(9===(e=t.stateNode.containerInfo).nodeType)e=e.body;else e="HTML"===e.nodeName?e.ownerDocument.body:e;for(rr=fu(e.firstChild),ar=t,sr=!0,ir=null,or=!0,n=no(t,null,a,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(hr(),a===r){t=Xo(e,t,n);break e}So(e,t,a,n)}t=t.child}return t;case 26:return Bo(e,t),null===e?(n=Su(t.type,null,t.pendingProps,null))?t.memoizedState=n:sr||(n=t.type,e=t.pendingProps,(a=au(q.current).createElement(n))[Me]=t,a[_e]=e,eu(a,n,e),We(a),t.stateNode=a):t.memoizedState=Su(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return K(t),null===e&&sr&&(a=t.stateNode=vu(t.type,t.pendingProps,q.current),ar=t,or=!0,r=rr,hu(t.type)?(bu=r,rr=fu(a.firstChild)):rr=r),So(e,t,t.pendingProps.children,n),Bo(e,t),null===e&&(t.flags|=4194304),t.child;case 5:return null===e&&sr&&((r=a=rr)&&(null!==(a=function(e,t,n,a){for(;1===e.nodeType;){var r=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!a&&("INPUT"!==e.nodeName||"hidden"!==e.type))break}else if(a){if(!e[ze])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if("stylesheet"===(s=e.getAttribute("rel"))&&e.hasAttribute("data-precedence"))break;if(s!==r.rel||e.getAttribute("href")!==(null==r.href||""===r.href?null:r.href)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin)||e.getAttribute("title")!==(null==r.title?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(((s=e.getAttribute("src"))!==(null==r.src?null:r.src)||e.getAttribute("type")!==(null==r.type?null:r.type)||e.getAttribute("crossorigin")!==(null==r.crossOrigin?null:r.crossOrigin))&&s&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else{if("input"!==t||"hidden"!==e.type)return e;var s=null==r.name?null:""+r.name;if("hidden"===r.type&&e.getAttribute("name")===s)return e}if(null===(e=fu(e.nextSibling)))break}return null}(a,t.type,t.pendingProps,or))?(t.stateNode=a,ar=t,rr=fu(a.firstChild),or=!1,r=!0):r=!1),r||cr(t)),K(t),r=t.type,s=t.pendingProps,o=null!==e?e.memoizedProps:null,a=s.children,iu(r,s)?a=null:null!==o&&iu(r,o)&&(t.flags|=32),null!==t.memoizedState&&(r=Ts(e,t,Bs,null,null,n),Ku._currentValue=r),Bo(e,t),So(e,t,a,n),t.child;case 6:return null===e&&sr&&((e=n=rr)&&(null!==(n=function(e,t,n){if(""===t)return null;for(;3!==e.nodeType;
vendor: 9,632 bytes, line 2
2){if((1!==e.nodeType||"INPUT"!==e.nodeName||"hidden"!==e.type)&&!n)return null;if(null===(e=fu(e.nextSibling)))return null}return e}(n,t.pendingProps,or))?(t.stateNode=n,ar=t,rr=null,e=!0):e=!1),e||cr(t)),null;case 13:return Vo(e,t,n);case 4:return Y(t,t.stateNode.containerInfo),a=t.pendingProps,null===e?t.child=to(t,null,a,n):So(e,t,a,n),t.child;case 11:return Eo(e,t,t.type,t.pendingProps,n);case 7:return So(e,t,t.pendingProps,n),t.child;case 8:case 12:return So(e,t,t.pendingProps.children,n),t.child;case 10:return a=t.pendingProps,yr(0,t.type,a.value),So(e,t,a.children,n),t.child;case 9:return r=t.type._context,a=t.pendingProps.children,Cr(t),a=a(r=Nr(r)),t.flags|=1,So(e,t,a,n),t.child;case 14:return Ao(e,t,t.type,t.pendingProps,n);case 15:return To(e,t,t.type,t.pendingProps,n);case 19:return Ko(e,t,n);case 31:return a=t.pendingProps,n=t.mode,a={mode:a.mode,children:a.children},null===e?((n=qo(a,n)).ref=t.ref,t.child=n,n.return=t,t=n):((n=Ra(e.child,a)).ref=t.ref,t.child=n,n.return=t,t=n),t;case 22:return Mo(e,t,n);case 24:return Cr(t),a=Nr(Mr),null===e?(null===(r=Vr())&&(r=ac,s=_r(),r.pooledCache=s,s.refCount++,null!==s&&(r.pooledCacheLanes|=n),r=s),t.memoizedState={parent:a,cache:r},ns(t),yr(0,Mr,r)):(0!==(e.lanes&n)&&(as(e,t),ds(t,null,null,n),cs()),r=e.memoizedState,s=t.memoizedState,r.parent!==a?(r={parent:a,cache:a},t.memoizedState=r,0===t.lanes&&(t.memoizedState=t.updateQueue.baseState=r),yr(0,Mr,a)):(a=s.cache,yr(0,Mr,a),a!==r.cache&&kr(t,[Mr],n,!0))),So(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Qo(e){e.flags|=4}function Zo(e,t){if("stylesheet"!==t.type||0!==(4&t.state.loading))e.flags&=-16777217;else if(e.flags|=16777216,!Uu(t)){if(null!==(t=ao.current)&&((4194048&sc)===sc?null!==ro:(62914560&sc)!==sc&&0===(536870912&sc)||t!==ro))throw Qr=Kr,Yr;e.flags|=8192}}function el(e,t){null!==t&&(e.flags|=4),16384&e.flags&&(t=22!==e.tag?je():536870912,e.lanes|=t,fc|=t)}function tl(e,t){if(!sr)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var a=null;null!==n;)null!==n.alternate&&(a=n),n=n.sibling;null===a?t||null===e.tail?e.tail=null:e.tail.sibling=null:a.sibling=null}}function nl(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,a=0;if(t)for(var r=e.child;null!==r;)n|=r.lanes|r.childLanes,a|=65011712&r.subtreeFlags,a|=65011712&r.flags,r.return=e,r=r.sibling;else for(r=e.child;null!==r;)n|=r.lanes|r.childLanes,a|=r.subtreeFlags,a|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=a,e.childLanes=n,t}function al(e,t,n){var a=t.pendingProps;switch(nr(t),t.tag){case 31:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:case 1:return nl(t),null;case 3:return n=t.stateNode,a=null,null!==e&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),vr(Mr),G(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(mr(t)?Qo(t):null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,pr())),nl(t),null;case 26:return n=t.memoizedState,null===e?(Qo(t),null!==n?(nl(t),Zo(t,n)):(nl(t),t.flags&=-16777217)):n?n!==e.memoizedState?(Qo(t),nl(t),Zo(t,n)):(nl(t),t.flags&=-16777217):(e.memoizedProps!==a&&Qo(t),nl(t),t.flags&=-16777217),null;case 27:X(t),n=q.current;var r=t.type;if(null!==e&&null!=t.stateNode)e.memoizedProps!==a&&Qo(t);else{if(!a){if(null===t.stateNode)throw Error(i(166));return nl(t),null}e=V.current,mr(t)?dr(t):(e=vu(r,a,n),t.stateNode=e,Qo(t))}return nl(t),null;case 5:if(X(t),n=t.type,null!==e&&null!=t.stateNode)e.memoizedProps!==a&&Qo(t);else{if(!a){if(null===t.stateNode)throw Error(i(166));return nl(t),null}if(e=V.current,mr(t))dr(t);else{switch(r=au(q.current),e){case 1:e=r.createElementNS("http://www.w3.org/2000/svg",n);break;case 2:e=r.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;default:switch(n){case"svg":e=r.createElementNS("http://www.w3.org/2000/svg",n);break;case"math":e=r.createElementNS("http://www.w3.org/1998/Math/MathML",n);break;case"script":(e=r.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild);break;case"select":e="string"===typeof a.is?r.createElement("select",{is:a.is}):r.createElement("select"),a.multiple?e.multiple=!0:a.size&&(e.size=a.size);break;default:e="string"===typeof a.is?r.createElement(n,{is:a.is}):r.createElement(n)}}e[Me]=t,e[_e]=a;e:for(r=t.child;null!==r;){if(5===r.tag||6===r.tag)e.appendChild(r.stateNode);else if(4!==r.tag&&27!==r.tag&&null!==r.child){r.child.return=r,r=r.child;continue}if(r===t)break e;for(;null===r.sibling;){if(null===r.return||r.return===t)break e;r=r.return}r.sibling.return=r.return,r=r.sibling}t.stateNode=e;e:switch(eu(e,n,a),n){case"button":case"input":case"select":case"textarea":e=!!a.autoFocus;break e;case"img":e=!0;break e;default:e=!1}e&&Qo(t)}}return nl(t),t.flags&=-16777217,null;case 6:if(e&&null!=t.stateNode)e.memoizedProps!==a&&Qo(t);else{if("string"!==typeof a&&null===t.stateNode)throw Error(i(166));if(e=q.current,mr(t)){if(e=t.stateNode,n=t.memoizedProps,a=null,null!==(r=ar))switch(r.tag){case 27:case 5:a=r.memoizedProps}e[Me]=t,(e=!!(e.nodeValue===n||null!==a&&!0===a.suppressHydrationWarning||Jd(e.nodeValue,n)))||cr(t)}else(e=au(e).createTextNode(a))[Me]=t,t.stateNode=e}return nl(t),null;case 13:if(a=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(r=mr(t),null!==a&&null!==a.dehydrated){if(null===e){if(!r)throw Error(i(318));if(!(r=null!==(r=t.memoizedState)?r.dehydrated:null))throw Error(i(317));r[Me]=t}else hr(),0===(128&t.flags)&&(t.memoizedState=null),t.flags|=4;nl(t),r=!1}else r=pr(),null!==e&&null!==e.memoizedState&&(e.memoizedState.hydrationErrors=r),r=!0;if(!r)return 256&t.flags?(lo(t),t):(lo(t),null)}if(lo(t),0!==(128&t.flags))return t.lanes=n,t;if(n=null!==a,e=null!==e&&null!==e.memoizedState,n){r=null,null!==(a=t.child).alternate&&null!==a.alternate.memoizedState&&null!==a.alternate.memoizedState.cachePool&&(r=a.alternate.memoizedState.cachePool.pool);var s=null;null!==a.memoizedState&&null!==a.memoizedState.cachePool&&(s=a.memoizedState.cachePool.pool),s!==r&&(a.flags|=2048)}return n!==e&&n&&(t.child.flags|=8192),el(t,t.updateQueue),nl(t),null;case 4:return G(),null===e&&Od(t.stateNode.containerInfo),nl(t),null;case 10:return vr(t.type),nl(t),null;case 19:if(O(co),null===(r=t.memoizedState))return nl(t),null;if(a=0!==(128&t.flags),null===(s=r.rendering))if(a)tl(r,!1);else{if(0!==mc||null!==e&&0!==(128&e.flags))for(e=t.child;null!==e;){if(null!==(s=uo(e))){for(t.flags|=128,tl(r,!1),e=s.updateQueue,t.updateQueue=e,el(t,e),t.subtreeFlags=0,e=n,n=t.child;null!==n;)za(n,e),n=n.sibling;return U(co,1&co.current|2),t.child}e=e.sibling}null!==r.tail&&te()>kc&&(t.flags|=128,a=!0,tl(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=uo(s))){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,el(t,e),tl(r,!0),null===r.tail&&"hidden"===r.tailMode&&!s.alternate&&!sr)return nl(t),null}else 2*te()-r.renderingStartTime>kc&&536870912!==n&&(t.flags|=128,a=!0,tl(r,!1),t.lanes=4194304);r.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=r.last)?e.sibling=s:t.child=s,r.last=s)}return null!==r.tail?(t=r.tail,r.rendering=t,r.tail=t.sibling,r.renderingStartTime=te(),t.sibling=null,e=co.current,U(co,a?1&e|2:1&e),t):(nl(t),null);case 22:case 23:return lo(t),fs(),a=null!==t.memoizedState,null!==e?null!==e.memoizedState!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?0!==(536870912&n)&&0===(128&t.flags)&&(nl(t),6&t.subtreeFlags&&(t.flags|=8192)):nl(t),null!==(n=t.updateQueue)&&el(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),a=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(a=t.memoizedState.cachePool.pool),a!==n&&(t.flags|=2048),null!==e&&O(Ur),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),vr(Mr),nl(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}function rl(e,t){switch(nr(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return vr(Mr),G(),0!==(65536&(e=t.flags))&&0===(128&e)?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return X(t),null;case 13:if(lo(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));hr()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return O(co),null;case 4:return G(),null;case 10:return vr(t.type),null;case 22:case 23:return lo(t),fs(),null!==e&&O(Ur),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return vr(Mr),null;default:return null}}function sl(e,t){switch(nr(t),t.tag){case 3:vr(Mr),G();break;case 26:case 27:case 5:X(t);break;case 4:G();break;case 13:lo(t);break;case 19:O(co);break;case 10:vr(t.type);break;case 22:case 23:lo(t),fs(),null!==e&&O(Ur);break;case 24:vr(Mr)}}function il(e,t){try{var n=t.updateQueue,a=null!==n?n.lastEffect:null;if(null!==a){var r=a.next;n=r;do{if((n.tag&e)===e){a=void 0;var s=n.create,i=n.inst;a=s(),i.destroy=a}n=n.next}while(n!==r)}}catch(o){dd(t,t.return,o)}}function ol(e,t,n){try{var a=t.updateQueue,r=null!==a?a.lastEffect:null;if(null!==r){var s=r.next;a=s;do{if((a.tag&e)===e){var i=a.inst,o=i.destroy;if(void 0!==o){i.destroy=void 0,r=t;var l=n,c=o;try{c()}catch(d){dd(r,l,d)}}}a=a.next}while(a!==s)}}catch(d){dd(t,t.return,d)}}function ll(e){var t=e.updateQueue;if(null!==t){var n=e.stateNode;try{ms(t,n)}catch(a){dd(e,e.return,a)}}}function cl(e,t,n){n.props=xo(e.type,e.memoizedProps),n.state=e.memoizedState;
vendor: 4,114 bytes, line 2
2try{n.componentWillUnmount()}catch(a){dd(e,t,a)}}function dl(e,t){try{var n=e.ref;if(null!==n){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;default:a=e.stateNode}"function"===typeof n?e.refCleanup=n(a):n.current=a}}catch(r){dd(e,t,r)}}function ul(e,t){var n=e.ref,a=e.refCleanup;if(null!==n)if("function"===typeof a)try{a()}catch(r){dd(e,t,r)}finally{e.refCleanup=null,null!=(e=e.alternate)&&(e.refCleanup=null)}else if("function"===typeof n)try{n(null)}catch(s){dd(e,t,s)}else n.current=null}function ml(e){var t=e.type,n=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&a.focus();break e;case"img":n.src?a.src=n.src:n.srcSet&&(a.srcset=n.srcSet)}}catch(r){dd(e,e.return,r)}}function hl(e,t,n){try{var a=e.stateNode;!function(e,t,n,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var r=null,s=null,o=null,l=null,c=null,d=null,u=null;for(p in n){var m=n[p];if(n.hasOwnProperty(p)&&null!=m)switch(p){case"checked":case"value":break;case"defaultValue":c=m;default:a.hasOwnProperty(p)||Qd(e,t,p,null,a,m)}}for(var h in a){var p=a[h];if(m=n[h],a.hasOwnProperty(h)&&(null!=p||null!=m))switch(h){case"type":s=p;break;case"name":r=p;break;case"checked":d=p;break;case"defaultChecked":u=p;break;case"value":o=p;break;case"defaultValue":l=p;break;case"children":case"dangerouslySetInnerHTML":if(null!=p)throw Error(i(137,t));break;default:p!==m&&Qd(e,t,h,p,a,m)}}return void xt(e,o,l,c,d,u,s,r);case"select":for(s in p=o=l=h=null,n)if(c=n[s],n.hasOwnProperty(s)&&null!=c)switch(s){case"value":break;case"multiple":p=c;default:a.hasOwnProperty(s)||Qd(e,t,s,null,a,c)}for(r in a)if(s=a[r],c=n[r],a.hasOwnProperty(r)&&(null!=s||null!=c))switch(r){case"value":h=s;break;case"defaultValue":l=s;break;case"multiple":o=s;default:s!==c&&Qd(e,t,r,s,a,c)}return t=l,n=o,a=p,void(null!=h?yt(e,!!n,h,!1):!!a!==!!n&&(null!=t?yt(e,!!n,t,!0):yt(e,!!n,n?[]:"",!1)));case"textarea":for(l in p=h=null,n)if(r=n[l],n.hasOwnProperty(l)&&null!=r&&!a.hasOwnProperty(l))switch(l){case"value":case"children":break;default:Qd(e,t,l,null,a,r)}for(o in a)if(r=a[o],s=n[o],a.hasOwnProperty(o)&&(null!=r||null!=s))switch(o){case"value":h=r;break;case"defaultValue":p=r;break;case"children":break;case"dangerouslySetInnerHTML":if(null!=r)throw Error(i(91));break;default:r!==s&&Qd(e,t,o,r,a,s)}return void vt(e,h,p);case"option":for(var g in n)if(h=n[g],n.hasOwnProperty(g)&&null!=h&&!a.hasOwnProperty(g))if("selected"===g)e.selected=!1;else Qd(e,t,g,null,a,h);for(c in a)if(h=a[c],p=n[c],a.hasOwnProperty(c)&&h!==p&&(null!=h||null!=p))if("selected"===c)e.selected=h&&"function"!==typeof h&&"symbol"!==typeof h;else Qd(e,t,c,h,a,p);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 x in n)h=n[x],n.hasOwnProperty(x)&&null!=h&&!a.hasOwnProperty(x)&&Qd(e,t,x,null,a,h);for(d in a)if(h=a[d],p=n[d],a.hasOwnProperty(d)&&h!==p&&(null!=h||null!=p))switch(d){case"children":case"dangerouslySetInnerHTML":if(null!=h)throw Error(i(137,t));break;default:Qd(e,t,d,h,a,p)}return;default:if(Nt(t)){for(var f in n)h=n[f],n.hasOwnProperty(f)&&void 0!==h&&!a.hasOwnProperty(f)&&Zd(e,t,f,void 0,a,h);for(u in a)h=a[u],p=n[u],!a.hasOwnProperty(u)||h===p||void 0===h&&void 0===p||Zd(e,t,u,h,a,p);return}}for(var b in n)h=n[b],n.hasOwnProperty(b)&&null!=h&&!a.hasOwnProperty(b)&&Qd(e,t,b,null,a,h);for(m in a)h=a[m],p=n[m],!a.hasOwnProperty(m)||h===p||null==h&&null==p||Qd(e,t,m,h,a,p)}(a,e.type,n,t),a[_e]=t}catch(r){dd(e,e.return,r)}}function pl(e){return 5===e.tag||3===e.tag||26===e.tag||27===e.tag&&hu(e.type)||4===e.tag}function gl(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||pl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(27===e.tag&&hu(e.type))continue e;if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function xl(e,t,n){var a=e.tag;
vendor: 23,356 bytes, line 2
2if(5===a||6===a)e=e.stateNode,t?(9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).insertBefore(e,t):((t=9===n.nodeType?n.body:"HTML"===n.nodeName?n.ownerDocument.body:n).appendChild(e),null!==(n=n._reactRootContainer)&&void 0!==n||null!==t.onclick||(t.onclick=$d));else if(4!==a&&(27===a&&hu(e.type)&&(n=e.stateNode,t=null),null!==(e=e.child)))for(xl(e,t,n),e=e.sibling;null!==e;)xl(e,t,n),e=e.sibling}function fl(e,t,n){var a=e.tag;if(5===a||6===a)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==a&&(27===a&&hu(e.type)&&(n=e.stateNode),null!==(e=e.child)))for(fl(e,t,n),e=e.sibling;null!==e;)fl(e,t,n),e=e.sibling}function bl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var a=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);eu(t,a,n),t[Me]=e,t[_e]=n}catch(s){dd(e,e.return,s)}}var yl=!1,vl=!1,wl=!1,kl="function"===typeof WeakSet?WeakSet:Set,jl=null;function Dl(e,t,n){var a=n.flags;switch(n.tag){case 0:case 11:case 15:Ll(e,n),4&a&&il(5,n);break;case 1:if(Ll(e,n),4&a)if(e=n.stateNode,null===t)try{e.componentDidMount()}catch(i){dd(n,n.return,i)}else{var r=xo(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(o){dd(n,n.return,o)}}64&a&&ll(n),512&a&&dl(n,n.return);break;case 3:if(Ll(e,n),64&a&&null!==(e=n.updateQueue)){if(t=null,null!==n.child)switch(n.child.tag){case 27:case 5:case 1:t=n.child.stateNode}try{ms(e,t)}catch(i){dd(n,n.return,i)}}break;case 27:null===t&&4&a&&bl(n);case 26:case 5:Ll(e,n),null===t&&4&a&&ml(n),512&a&&dl(n,n.return);break;case 12:Ll(e,n);break;case 13:Ll(e,n),4&a&&Al(e,n),64&a&&(null!==(e=n.memoizedState)&&(null!==(e=e.dehydrated)&&function(e,t){var n=e.ownerDocument;if("$?"!==e.data||"complete"===n.readyState)t();else{var a=function(){t(),n.removeEventListener("DOMContentLoaded",a)};n.addEventListener("DOMContentLoaded",a),e._reactRetry=a}}(e,n=pd.bind(null,n))));break;case 22:if(!(a=null!==n.memoizedState||yl)){t=null!==t&&null!==t.memoizedState||vl,r=yl;var s=vl;yl=a,(vl=t)&&!s?zl(e,n,0!==(8772&n.subtreeFlags)):Ll(e,n),yl=r,vl=s}break;case 30:break;default:Ll(e,n)}}function Cl(e){var t=e.alternate;null!==t&&(e.alternate=null,Cl(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&Oe(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 Nl=null,Fl=!1;function Sl(e,t,n){for(n=n.child;null!==n;)El(e,t,n),n=n.sibling}function El(e,t,n){if(ue&&"function"===typeof ue.onCommitFiberUnmount)try{ue.onCommitFiberUnmount(de,n)}catch(s){}switch(n.tag){case 26:vl||ul(n,t),Sl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode).parentNode.removeChild(n);break;case 27:vl||ul(n,t);var a=Nl,r=Fl;hu(n.type)&&(Nl=n.stateNode,Fl=!1),Sl(e,t,n),wu(n.stateNode),Nl=a,Fl=r;break;case 5:vl||ul(n,t);case 6:if(a=Nl,r=Fl,Nl=null,Sl(e,t,n),Fl=r,null!==(Nl=a))if(Fl)try{(9===Nl.nodeType?Nl.body:"HTML"===Nl.nodeName?Nl.ownerDocument.body:Nl).removeChild(n.stateNode)}catch(i){dd(n,t,i)}else try{Nl.removeChild(n.stateNode)}catch(i){dd(n,t,i)}break;case 18:null!==Nl&&(Fl?(pu(9===(e=Nl).nodeType?e.body:"HTML"===e.nodeName?e.ownerDocument.body:e,n.stateNode),Fm(e)):pu(Nl,n.stateNode));break;case 4:a=Nl,r=Fl,Nl=n.stateNode.containerInfo,Fl=!0,Sl(e,t,n),Nl=a,Fl=r;break;case 0:case 11:case 14:case 15:vl||ol(2,n,t),vl||ol(4,n,t),Sl(e,t,n);break;case 1:vl||(ul(n,t),"function"===typeof(a=n.stateNode).componentWillUnmount&&cl(n,t,a)),Sl(e,t,n);break;case 21:Sl(e,t,n);break;case 22:vl=(a=vl)||null!==n.memoizedState,Sl(e,t,n),vl=a;break;default:Sl(e,t,n)}}function Al(e,t){if(null===t.memoizedState&&(null!==(e=t.alternate)&&(null!==(e=e.memoizedState)&&null!==(e=e.dehydrated))))try{Fm(e)}catch(n){dd(t,t.return,n)}}function Tl(e,t){var n=function(e){switch(e.tag){case 13:case 19:var t=e.stateNode;return null===t&&(t=e.stateNode=new kl),t;case 22:return null===(t=(e=e.stateNode)._retryCache)&&(t=e._retryCache=new kl),t;default:throw Error(i(435,e.tag))}}(e);t.forEach(function(t){var a=gd.bind(null,e,t);n.has(t)||(n.add(t),t.then(a,a))})}function Ml(e,t){var n=t.deletions;if(null!==n)for(var a=0;a<n.length;a++){var r=n[a],s=e,o=t,l=o;e:for(;null!==l;){switch(l.tag){case 27:if(hu(l.type)){Nl=l.stateNode,Fl=!1;break e}break;case 5:Nl=l.stateNode,Fl=!1;break e;case 3:case 4:Nl=l.stateNode.containerInfo,Fl=!0;break e}l=l.return}if(null===Nl)throw Error(i(160));El(s,o,r),Nl=null,Fl=!1,null!==(s=r.alternate)&&(s.return=null),r.return=null}if(13878&t.subtreeFlags)for(t=t.child;null!==t;)Bl(t,e),t=t.sibling}var _l=null;function Bl(e,t){var n=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ml(t,e),Il(e),4&a&&(ol(3,e,e.return),il(3,e),ol(5,e,e.return));break;case 1:Ml(t,e),Il(e),512&a&&(vl||null===n||ul(n,n.return)),64&a&&yl&&(null!==(e=e.updateQueue)&&(null!==(a=e.callbacks)&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=null===n?a:n.concat(a))));break;case 26:var r=_l;if(Ml(t,e),Il(e),512&a&&(vl||null===n||ul(n,n.return)),4&a){var s=null!==n?n.memoizedState:null;if(a=e.memoizedState,null===n)if(null===a)if(null===e.stateNode){e:{a=e.type,n=e.memoizedProps,r=r.ownerDocument||r;t:switch(a){case"title":(!(s=r.getElementsByTagName("title")[0])||s[ze]||s[Me]||"http://www.w3.org/2000/svg"===s.namespaceURI||s.hasAttribute("itemprop"))&&(s=r.createElement(a),r.head.insertBefore(s,r.querySelector("head > title"))),eu(s,a,n),s[Me]=e,We(s),a=s;break e;case"link":var o=zu("link","href",r).get(a+(n.href||""));if(o)for(var l=0;l<o.length;l++)if((s=o[l]).getAttribute("href")===(null==n.href||""===n.href?null:n.href)&&s.getAttribute("rel")===(null==n.rel?null:n.rel)&&s.getAttribute("title")===(null==n.title?null:n.title)&&s.getAttribute("crossorigin")===(null==n.crossOrigin?null:n.crossOrigin)){o.splice(l,1);break t}eu(s=r.createElement(a),a,n),r.head.appendChild(s);break;case"meta":if(o=zu("meta","content",r).get(a+(n.content||"")))for(l=0;l<o.length;l++)if((s=o[l]).getAttribute("content")===(null==n.content?null:""+n.content)&&s.getAttribute("name")===(null==n.name?null:n.name)&&s.getAttribute("property")===(null==n.property?null:n.property)&&s.getAttribute("http-equiv")===(null==n.httpEquiv?null:n.httpEquiv)&&s.getAttribute("charset")===(null==n.charSet?null:n.charSet)){o.splice(l,1);break t}eu(s=r.createElement(a),a,n),r.head.appendChild(s);break;default:throw Error(i(468,a))}s[Me]=e,We(s),a=s}e.stateNode=a}else Ou(r,e.type,e.stateNode);else e.stateNode=Bu(r,a,e.memoizedProps);else s!==a?(null===s?null!==n.stateNode&&(n=n.stateNode).parentNode.removeChild(n):s.count--,null===a?Ou(r,e.type,e.stateNode):Bu(r,a,e.memoizedProps)):null===a&&null!==e.stateNode&&hl(e,e.memoizedProps,n.memoizedProps)}break;case 27:Ml(t,e),Il(e),512&a&&(vl||null===n||ul(n,n.return)),null!==n&&4&a&&hl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Ml(t,e),Il(e),512&a&&(vl||null===n||ul(n,n.return)),32&e.flags){r=e.stateNode;try{kt(r,"")}catch(p){dd(e,e.return,p)}}4&a&&null!=e.stateNode&&hl(e,r=e.memoizedProps,null!==n?n.memoizedProps:r),1024&a&&(wl=!0);break;case 6:if(Ml(t,e),Il(e),4&a){if(null===e.stateNode)throw Error(i(162));a=e.memoizedProps,n=e.stateNode;try{n.nodeValue=a}catch(p){dd(e,e.return,p)}}break;case 3:if(Ru=null,r=_l,_l=Du(t.containerInfo),Ml(t,e),_l=r,Il(e),4&a&&null!==n&&n.memoizedState.isDehydrated)try{Fm(t.containerInfo)}catch(p){dd(e,e.return,p)}wl&&(wl=!1,Pl(e));break;case 4:a=_l,_l=Du(e.stateNode.containerInfo),Ml(t,e),Il(e),_l=a;break;case 12:default:Ml(t,e),Il(e);break;case 13:Ml(t,e),Il(e),8192&e.child.flags&&null!==e.memoizedState!==(null!==n&&null!==n.memoizedState)&&(wc=te()),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Tl(e,a)));break;case 22:r=null!==e.memoizedState;var c=null!==n&&null!==n.memoizedState,d=yl,u=vl;if(yl=d||r,vl=u||c,Ml(t,e),vl=u,yl=d,Il(e),8192&a)e:for(t=e.stateNode,t._visibility=r?-2&t._visibility:1|t._visibility,r&&(null===n||c||yl||vl||Rl(e)),n=null,t=e;;){if(5===t.tag||26===t.tag){if(null===n){c=n=t;try{if(s=c.stateNode,r)"function"===typeof(o=s.style).setProperty?o.setProperty("display","none","important"):o.display="none";else{l=c.stateNode;var m=c.memoizedProps.style,h=void 0!==m&&null!==m&&m.hasOwnProperty("display")?m.display:null;l.style.display=null==h||"boolean"===typeof h?"":(""+h).trim()}}catch(p){dd(c,c.return,p)}}}else if(6===t.tag){if(null===n){c=t;try{c.stateNode.nodeValue=r?"":c.memoizedProps}catch(p){dd(c,c.return,p)}}}else if((22!==t.tag&&23!==t.tag||null===t.memoizedState||t===e)&&null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;null===t.sibling;){if(null===t.return||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}4&a&&(null!==(a=e.updateQueue)&&(null!==(n=a.retryQueue)&&(a.retryQueue=null,Tl(e,n))));break;case 19:Ml(t,e),Il(e),4&a&&(null!==(a=e.updateQueue)&&(e.updateQueue=null,Tl(e,a)));case 30:case 21:}}function Il(e){var t=e.flags;if(2&t){try{for(var n,a=e.return;null!==a;){if(pl(a)){n=a;break}a=a.return}if(null==n)throw Error(i(160));switch(n.tag){case 27:var r=n.stateNode;fl(e,gl(e),r);break;case 5:var s=n.stateNode;32&n.flags&&(kt(s,""),n.flags&=-33),fl(e,gl(e),s);break;case 3:case 4:var o=n.stateNode.containerInfo;xl(e,gl(e),o);break;default:throw Error(i(161))}}catch(l){dd(e,e.return,l)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function Pl(e){if(1024&e.subtreeFlags)for(e=e.child;null!==e;){var t=e;Pl(t),5===t.tag&&1024&t.flags&&t.stateNode.reset(),e=e.sibling}}function Ll(e,t){if(8772&t.subtreeFlags)for(t=t.child;null!==t;)Dl(e,t.alternate,t),t=t.sibling}function Rl(e){for(e=e.child;null!==e;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:ol(4,t,t.return),Rl(t);break;case 1:ul(t,t.return);var n=t.stateNode;"function"===typeof n.componentWillUnmount&&cl(t,t.return,n),Rl(t);break;case 27:wu(t.stateNode);case 26:case 5:ul(t,t.return),Rl(t);break;case 22:null===t.memoizedState&&Rl(t);break;default:Rl(t)}e=e.sibling}}function zl(e,t,n){for(n=n&&0!==(8772&t.subtreeFlags),t=t.child;null!==t;){var a=t.alternate,r=e,s=t,i=s.flags;switch(s.tag){case 0:case 11:case 15:zl(r,s,n),il(4,s);break;case 1:if(zl(r,s,n),"function"===typeof(r=(a=s).stateNode).componentDidMount)try{r.componentDidMount()}catch(c){dd(a,a.return,c)}if(null!==(r=(a=s).updateQueue)){var o=a.stateNode;try{var l=r.shared.hiddenCallbacks;if(null!==l)for(r.shared.hiddenCallbacks=null,r=0;r<l.length;r++)us(l[r],o)}catch(c){dd(a,a.return,c)}}n&&64&i&&ll(s),dl(s,s.return);break;case 27:bl(s);case 26:case 5:zl(r,s,n),n&&null===a&&4&i&&ml(s),dl(s,s.return);break;case 12:zl(r,s,n);break;case 13:zl(r,s,n),n&&4&i&&Al(r,s);break;case 22:null===s.memoizedState&&zl(r,s,n),dl(s,s.return);break;case 30:break;default:zl(r,s,n)}t=t.sibling}}function Ol(e,t){var n=null;null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),e=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(e=t.memoizedState.cachePool.pool),e!==n&&(null!=e&&e.refCount++,null!=n&&Br(n))}function Ul(e,t){e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Br(e))}function Vl(e,t,n,a){if(10256&t.subtreeFlags)for(t=t.child;null!==t;)Hl(e,t,n,a),t=t.sibling}function Hl(e,t,n,a){var r=t.flags;switch(t.tag){case 0:case 11:case 15:Vl(e,t,n,a),2048&r&&il(9,t);break;case 1:case 13:default:Vl(e,t,n,a);break;case 3:Vl(e,t,n,a),2048&r&&(e=null,null!==t.alternate&&(e=t.alternate.memoizedState.cache),(t=t.memoizedState.cache)!==e&&(t.refCount++,null!=e&&Br(e)));break;case 12:if(2048&r){Vl(e,t,n,a),e=t.stateNode;try{var s=t.memoizedProps,i=s.id,o=s.onPostCommit;"function"===typeof o&&o(i,null===t.alternate?"mount":"update",e.passiveEffectDuration,-0)}catch(l){dd(t,t.return,l)}}else Vl(e,t,n,a);break;case 23:break;case 22:s=t.stateNode,i=t.alternate,null!==t.memoizedState?2&s._visibility?Vl(e,t,n,a):Wl(e,t):2&s._visibility?Vl(e,t,n,a):(s._visibility|=2,ql(e,t,n,a,0!==(10256&t.subtreeFlags))),2048&r&&Ol(i,t);break;case 24:Vl(e,t,n,a),2048&r&&Ul(t.alternate,t)}}function ql(e,t,n,a,r){for(r=r&&0!==(10256&t.subtreeFlags),t=t.child;null!==t;){var s=e,i=t,o=n,l=a,c=i.flags;switch(i.tag){case 0:case 11:case 15:ql(s,i,o,l,r),il(8,i);break;case 23:break;case 22:var d=i.stateNode;null!==i.memoizedState?2&d._visibility?ql(s,i,o,l,r):Wl(s,i):(d._visibility|=2,ql(s,i,o,l,r)),r&&2048&c&&Ol(i.alternate,i);break;case 24:ql(s,i,o,l,r),r&&2048&c&&Ul(i.alternate,i);break;default:ql(s,i,o,l,r)}t=t.sibling}}function Wl(e,t){if(10256&t.subtreeFlags)for(t=t.child;null!==t;){var n=e,a=t,r=a.flags;switch(a.tag){case 22:Wl(n,a),2048&r&&Ol(a.alternate,a);break;case 24:Wl(n,a),2048&r&&Ul(a.alternate,a);break;default:Wl(n,a)}t=t.sibling}}var Yl=8192;function Gl(e){if(e.subtreeFlags&Yl)for(e=e.child;null!==e;)Kl(e),e=e.sibling}function Kl(e){switch(e.tag){case 26:Gl(e),e.flags&Yl&&null!==e.memoizedState&&function(e,t,n){if(null===Vu)throw Error(i(475));var a=Vu;if("stylesheet"===t.type&&("string"!==typeof n.media||!1!==matchMedia(n.media).matches)&&0===(4&t.state.loading)){if(null===t.instance){var r=Eu(n.href),s=e.querySelector(Au(r));if(s)return null!==(e=s._p)&&"object"===typeof e&&"function"===typeof e.then&&(a.count++,a=qu.bind(a),e.then(a,a)),t.state.loading|=4,t.instance=s,void We(s);s=e.ownerDocument||e,n=Tu(n),(r=ku.get(r))&&Pu(n,r),We(s=s.createElement("link"));var o=s;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),eu(s,"link",n),t.instance=s}null===a.stylesheets&&(a.stylesheets=new Map),a.stylesheets.set(t,e),(e=t.state.preload)&&0===(3&t.state.loading)&&(a.count++,t=qu.bind(a),e.addEventListener("load",t),e.addEventListener("error",t))}}(_l,e.memoizedState,e.memoizedProps);break;case 5:default:Gl(e);break;case 3:case 4:var t=_l;_l=Du(e.stateNode.containerInfo),Gl(e),_l=t;break;case 22:null===e.memoizedState&&(null!==(t=e.alternate)&&null!==t.memoizedState?(t=Yl,Yl=16777216,Gl(e),Yl=t):Gl(e))}}function Xl(e){var t=e.alternate;if(null!==t&&null!==(e=t.child)){t.child=null;do{t=e.sibling,e.sibling=null,e=t}while(null!==e)}}function Jl(e){var t=e.deletions;if(0!==(16&e.flags)){if(null!==t)for(var n=0;n<t.length;n++){var a=t[n];jl=a,Zl(a,e)}Xl(e)}if(10256&e.subtreeFlags)for(e=e.child;null!==e;)$l(e),e=e.sibling}function $l(e){switch(e.tag){case 0:case 11:case 15:Jl(e),2048&e.flags&&ol(9,e,e.return);break;case 3:case 12:default:Jl(e);break;case 22:var t=e.stateNode;null!==e.memoizedState&&2&t._visibility&&(null===e.return||13!==e.return.tag)?(t._visibility&=-3,Ql(e)):Jl(e)}}function Ql(e){var t=e.deletions;if(0!==(16&e.flags)){if(null!==t)for(var n=0;n<t.length;n++){var a=t[n];jl=a,Zl(a,e)}Xl(e)}for(e=e.child;null!==e;){switch((t=e).tag){case 0:case 11:case 15:ol(8,t,t.return),Ql(t);break;case 22:2&(n=t.stateNode)._visibility&&(n._visibility&=-3,Ql(t));break;default:Ql(t)}e=e.sibling}}function Zl(e,t){for(;null!==jl;){var n=jl;switch(n.tag){case 0:case 11:case 15:ol(8,n,t);break;case 23:case 22:if(null!==n.memoizedState&&null!==n.memoizedState.cachePool){var a=n.memoizedState.cachePool.pool;null!=a&&a.refCount++}break;case 24:Br(n.memoizedState.cache)}if(null!==(a=n.child))a.return=n,jl=a;else e:for(n=e;null!==jl;){var r=(a=jl).sibling,s=a.return;if(Cl(a),a===n){jl=null;break e}if(null!==r){r.return=s,jl=r;break e}jl=s}}}var ec={getCacheForType:function(e){var t=Nr(Mr),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n}},tc="function"===typeof WeakMap?WeakMap:Map,nc=0,ac=null,rc=null,sc=0,ic=0,oc=null,lc=!1,cc=!1,dc=!1,uc=0,mc=0,hc=0,pc=0,gc=0,xc=0,fc=0,bc=null,yc=null,vc=!1,wc=0,kc=1/0,jc=null,Dc=null,Cc=0,Nc=null,Fc=null,Sc=0,Ec=0,Ac=null,Tc=null,Mc=0,_c=null;function Bc(){if(0!==(2&nc)&&0!==sc)return sc&-sc;if(null!==B.T){return 0!==Lr?Lr:Ed()}return Ae()}function Ic(){0===xc&&(xc=0===(536870912&sc)||sr?ke():536870912);var e=ao.current;return null!==e&&(e.flags|=32),xc}function Pc(e,t,n){(e!==ac||2!==ic&&9!==ic)&&null===e.cancelPendingCommit||(Hc(e,0),Oc(e,sc,xc,!1)),Ce(e,n),0!==(2&nc)&&e===ac||(e===ac&&(0===(2&nc)&&(pc|=n),4===mc&&Oc(e,sc,xc,!1)),kd(e))}function Lc(e,t,n){if(0!==(6&nc))throw Error(i(327));for(var a=!n&&0===(124&t)&&0===(t&e.expiredLanes)||ve(e,t),r=a?function(e,t){var n=nc;nc|=2;var a=Wc(),r=Yc();ac!==e||sc!==t?(jc=null,kc=te()+500,Hc(e,t)):cc=ve(e,t);e:for(;;)try{if(0!==ic&&null!==rc){t=rc;var s=oc;t:switch(ic){case 1:ic=0,oc=null,Zc(e,t,s,1);break;case 2:case 9:if(Xr(s)){ic=0,oc=null,Qc(t);break}t=function(){2!==ic&&9!==ic||ac!==e||(ic=7),kd(e)},s.then(t,t);break e;case 3:ic=7;break e;case 4:ic=5;break e;case 7:Xr(s)?(ic=0,oc=null,Qc(t)):(ic=0,oc=null,Zc(e,t,s,7));break;case 5:var o=null;switch(rc.tag){case 26:o=rc.memoizedState;case 5:case 27:var l=rc;if(!o||Uu(o)){ic=0,oc=null;var c=l.sibling;if(null!==c)rc=c;else{var d=l.return;null!==d?(rc=d,ed(d)):rc=null}break t}}ic=0,oc=null,Zc(e,t,s,5);break;case 6:ic=0,oc=null,Zc(e,t,s,6);break;case 8:Vc(),mc=6;break e;default:throw Error(i(462))}}Jc();break}catch(u){qc(e,u)}return br=fr=null,B.H=a,B.A=r,nc=n,null!==rc?0:(ac=null,sc=0,Sa(),mc)}(e,t):Kc(e,t,!0),s=a;;){if(0===r){cc&&!a&&Oc(e,t,0,!1);break}if(n=e.current.alternate,!s||zc(n)){if(2===r){if(s=t,e.errorRecoveryDisabledLanes&s)var o=0;else o=0!==(o=-536870913&e.pendingLanes)?o:536870912&o?536870912:0;if(0!==o){t=o;e:{var l=e;r=bc;var c=l.current.memoizedState.isDehydrated;if(c&&(Hc(l,o).flags|=256),2!==(o=Kc(l,o,!1))){if(dc&&!c){l.errorRecoveryDisabledLanes|=s,pc|=s,r=4;break e}s=yc,yc=r,null!==s&&(null===yc?yc=s:yc.push.apply(yc,s))}r=o}if(s=!1,2!==r)continue}}if(1===r){Hc(e,0),Oc(e,t,0,!0);break}e:{switch(a=e,s=r){case 0:case 1:throw Error(i(345));case 4:if((4194048&t)!==t)break;case 6:Oc(a,t,xc,!lc);break e;case 2:yc=null;break;case 3:case 5:break;default:throw Error(i(329))}if((62914560&t)===t&&10<(r=wc+300-te())){if(Oc(a,t,xc,!lc),0!==ye(a,0,!0))break e;a.timeoutHandle=lu(Rc.bind(null,a,n,yc,jc,vc,t,xc,pc,fc,lc,s,2,-0,0),r)}else Rc(a,n,yc,jc,vc,t,xc,pc,fc,lc,s,0,-0,0)}break}r=Kc(e,t,!1),s=!1}kd(e)}function Rc(e,t,n,a,r,s,o,l,c,d,u,m,h,p){if(e.timeoutHandle=-1,(8192&(m=t.subtreeFlags)||16785408===(16785408&m))&&(Vu={stylesheets:null,count:0,unsuspend:Hu},Kl(t),null!==(m=function(){if(null===Vu)throw Error(i(475));var e=Vu;return e.stylesheets&&0===e.count&&Yu(e,e.stylesheets),0<e.count?function(t){var n=setTimeout(function(){if(e.stylesheets&&Yu(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4);return e.unsuspend=t,function(){e.unsuspend=null,clearTimeout(n)}}:null}())))return e.cancelPendingCommit=m(nd.bind(null,e,t,s,n,a,r,o,l,c,u,1,h,p)),void Oc(e,s,o,!d);nd(e,t,s,n,a,r,o,l,c)}function zc(e){for(var t=e;;){var n=t.tag;if((0===n||11===n||15===n)&&16384&t.flags&&(null!==(n=t.updateQueue)&&null!==(n=n.stores)))for(var a=0;a<n.length;a++){var r=n[a],s=r.getSnapshot;r=r.value;try{if(!Xn(s(),r))return!1}catch(i){return!1}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Oc(e,t,n,a){t&=~gc,t&=~pc,e.suspendedLanes|=t,e.pingedLanes&=~t,a&&(e.warmLanes|=t),a=e.expirationTimes;for(var r=t;0<r;){var s=31-he(r),i=1<<s;a[s]=-1,r&=~i}0!==n&&Ne(e,n,t)}function Uc(){return 0!==(6&nc)||(jd(0,!1),!1)}function Vc(){if(null!==rc){if(0===ic)var e=rc.return;else br=fr=null,Ls(e=rc),Ki=null,Xi=0,e=rc;for(;null!==e;)sl(e.alternate,e),e=e.return;rc=null}}function Hc(e,t){var n=e.timeoutHandle;-1!==n&&(e.timeoutHandle=-1,cu(n)),null!==(n=e.cancelPendingCommit)&&(e.cancelPendingCommit=null,n()),Vc(),ac=e,rc=n=Ra(e.current,null),sc=t,ic=0,oc=null,lc=!1,cc=ve(e,t),dc=!1,fc=xc=gc=pc=hc=mc=0,yc=bc=null,vc=!1,0!==(8&t)&&(t|=32&t);var a=e.entangledLanes;if(0!==a)for(e=e.entanglements,a&=t;0<a;){var r=31-he(a),s=1<<r;t|=e[r],a&=~s}return uc=t,Sa(),n}function qc(e,t){ys=null,B.H=qi,t===Wr||t===Gr?(t=Zr(),ic=3):t===Yr?(t=Zr(),ic=4):ic=t===No?8:null!==t&&"object"===typeof t&&"function"===typeof t.then?6:1,oc=t,null===rc&&(mc=1,wo(e,Da(t,e.current)))}function Wc(){var e=B.H;return B.H=qi,null===e?qi:e}function Yc(){var e=B.A;return B.A=ec,e}function Gc(){mc=4,lc||(4194048&sc)!==sc&&null!==ao.current||(cc=!0),0===(134217727&hc)&&0===(134217727&pc)||null===ac||Oc(ac,sc,xc,!1)}function Kc(e,t,n){var a=nc;nc|=2;var r=Wc(),s=Yc();ac===e&&sc===t||(jc=null,Hc(e,t)),t=!1;var i=mc;e:for(;;)try{if(0!==ic&&null!==rc){var o=rc,l=oc;switch(ic){case 8:Vc(),i=6;break e;case 3:case 2:case 9:case 6:null===ao.current&&(t=!0);var c=ic;if(ic=0,oc=null,Zc(e,o,l,c),n&&cc){i=0;break e}break;default:c=ic,ic=0,oc=null,Zc(e,o,l,c)}}Xc(),i=mc;break}catch(d){qc(e,d)}return t&&e.shellSuspendCounter++,br=fr=null,nc=a,B.H=r,B.A=s,null===rc&&(ac=null,sc=0,Sa()),i}function Xc(){for(;null!==rc;)$c(rc)}function Jc(){for(;null!==rc&&!Z();)$c(rc)}function $c(e){var t=$o(e.alternate,e,uc);e.memoizedProps=e.pendingProps,null===t?ed(e):rc=t}function Qc(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Po(n,t,t.pendingProps,t.type,void 0,sc);break;case 11:t=Po(n,t,t.pendingProps,t.type.render,t.ref,sc);break;case 5:Ls(t);default:sl(n,t),t=$o(n,t=rc=za(t,uc),uc)}e.memoizedProps=e.pendingProps,null===t?ed(e):rc=t}function Zc(e,t,n,a){br=fr=null,Ls(t),Ki=null,Xi=0;var r=t.return;try{if(function(e,t,n,a,r){if(n.flags|=32768,null!==a&&"object"===typeof a&&"function"===typeof a.then){if(null!==(t=n.alternate)&&jr(t,n,r,!0),null!==(n=ao.current)){switch(n.tag){case 13:return null===ro?Gc():null===n.alternate&&0===mc&&(mc=3),n.flags&=-257,n.flags|=65536,n.lanes=r,a===Kr?n.flags|=16384:(null===(t=n.updateQueue)?n.updateQueue=new Set([a]):t.add(a),ud(e,a,r)),!1;case 22:return n.flags|=65536,a===Kr?n.flags|=16384:(null===(t=n.updateQueue)?(t={transitions:null,markerInstances:null,retryQueue:new Set([a])},n.updateQueue=t):null===(n=t.retryQueue)?t.retryQueue=new Set([a]):n.add(a),ud(e,a,r)),!1}throw Error(i(435,n.tag))}return ud(e,a,r),Gc(),!1}if(sr)return null!==(t=ao.current)?(0===(65536&t.flags)&&(t.flags|=256),t.flags|=65536,t.lanes=r,a!==lr&&gr(Da(e=Error(i(422),{cause:a}),n))):(a!==lr&&gr(Da(t=Error(i(423),{cause:a}),n)),(e=e.current.alternate).flags|=65536,r&=-r,e.lanes|=r,a=Da(a,n),os(e,r=jo(e.stateNode,a,r)),4!==mc&&(mc=2)),!1;var s=Error(i(520),{cause:a});if(s=Da(s,n),null===bc?bc=[s]:bc.push(s),4!==mc&&(mc=2),null===t)return!0;a=Da(a,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=r&-r,n.lanes|=e,os(n,e=jo(n.stateNode,a,e)),!1;case 1:if(t=n.type,s=n.stateNode,0===(128&n.flags)&&("function"===typeof t.getDerivedStateFromError||null!==s&&"function"===typeof s.componentDidCatch&&(null===Dc||!Dc.has(s))))return n.flags|=65536,r&=-r,n.lanes|=r,Co(r=Do(r),e,n,a),os(n,r),!1}n=n.return}while(null!==n);return!1}(e,r,t,n,sc))return mc=1,wo(e,Da(n,e.current)),void(rc=null)}catch(s){if(null!==r)throw rc=r,s;return mc=1,wo(e,Da(n,e.current)),void(rc=null)}32768&t.flags?(sr||1===a?e=!0:cc||0!==(536870912&sc)?e=!1:(lc=e=!0,(2===a||9===a||3===a||6===a)&&(null!==(a=ao.current)&&13===a.tag&&(a.flags|=16384))),td(t,e)):ed(t)}function ed(e){var t=e;do{if(0!==(32768&t.flags))return void td(t,lc);e=t.return;var n=al(t.alternate,t,uc);if(null!==n)return void(rc=n);if(null!==(t=t.sibling))return void(rc=t);rc=t=e}while(null!==t);0===mc&&(mc=5)}function td(e,t){do{var n=rl(e.alternate,e);if(null!==n)return n.flags&=32767,void(rc=n);if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deleti
2ons=null),!t&&null!==(e=e.sibling))return void(rc=e);rc=e=n}while(null!==e);mc=6,rc=null}function nd(e,t,n,a,r,s,o,l,c){e.cancelPendingCommit=null;do{od()}while(0!==Cc);if(0!==(6&nc))throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(s=t.lanes|t.childLanes,function(e,t,n,a,r,s){var i=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 o=e.entanglements,l=e.expirationTimes,c=e.hiddenUpdates;for(n=i&~n;0<n;){var d=31-he(n),u=1<<d;o[d]=0,l[d]=-1;var m=c[d];if(null!==m)for(c[d]=null,d=0;d<m.length;d++){var h=m[d];null!==h&&(h.lane&=-536870913)}n&=~u}0!==a&&Ne(e,a,0),0!==s&&0===r&&0!==e.tag&&(e.suspendedLanes|=s&~(i&~t))}(e,n,s|=Fa,o,l,c),e===ac&&(rc=ac=null,sc=0),Fc=t,Nc=e,Sc=n,Ec=s,Ac=r,Tc=a,0!==(10256&t.subtreeFlags)||0!==(10256&t.flags)?(e.callbackNode=null,e.callbackPriority=0,$(se,function(){return ld(),null})):(e.callbackNode=null,e.callbackPriority=0),a=0!==(13878&t.flags),0!==(13878&t.subtreeFlags)||a){a=B.T,B.T=null,r=I.p,I.p=2,o=nc,nc|=4;try{!function(e,t){if(e=e.containerInfo,tu=nm,ta(e=ea(e))){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var a=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(a&&0!==a.rangeCount){n=a.anchorNode;var r=a.anchorOffset,s=a.focusNode;a=a.focusOffset;try{n.nodeType,s.nodeType}catch(x){n=null;break e}var o=0,l=-1,c=-1,d=0,u=0,m=e,h=null;t:for(;;){for(var p;m!==n||0!==r&&3!==m.nodeType||(l=o+r),m!==s||0!==a&&3!==m.nodeType||(c=o+a),3===m.nodeType&&(o+=m.nodeValue.length),null!==(p=m.firstChild);)h=m,m=p;for(;;){if(m===e)break t;if(h===n&&++d===r&&(l=o),h===s&&++u===a&&(c=o),null!==(p=m.nextSibling))break;h=(m=h).parentNode}m=p}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(nu={focusedElem:e,selectionRange:n},nm=!1,jl=t;null!==jl;)if(e=(t=jl).child,0!==(1024&t.subtreeFlags)&&null!==e)e.return=t,jl=e;else for(;null!==jl;){switch(s=(t=jl).alternate,e=t.flags,t.tag){case 0:case 11:case 15:case 5:case 26:case 27:case 6:case 4:case 17:break;case 1:if(0!==(1024&e)&&null!==s){e=void 0,n=t,r=s.memoizedProps,s=s.memoizedState,a=n.stateNode;try{var g=xo(n.type,r,(n.elementType,n.type));e=a.getSnapshotBeforeUpdate(g,s),a.__reactInternalSnapshotBeforeUpdate=e}catch(f){dd(n,n.return,f)}}break;case 3:if(0!==(1024&e))if(9===(n=(e=t.stateNode.containerInfo).nodeType))gu(e);else if(1===n)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":gu(e);break;default:e.textContent=""}break;default:if(0!==(1024&e))throw Error(i(163))}if(null!==(e=t.sibling)){e.return=t.return,jl=e;break}jl=t.return}}(e,t)}finally{nc=o,I.p=r,B.T=a}}Cc=1,ad(),rd(),sd()}}function ad(){if(1===Cc){Cc=0;var e=Nc,t=Fc,n=0!==(13878&t.flags);if(0!==(13878&t.subtreeFlags)||n){n=B.T,B.T=null;var a=I.p;I.p=2;var r=nc;nc|=4;try{Bl(t,e);var s=nu,i=ea(e.containerInfo),o=s.focusedElem,l=s.selectionRange;if(i!==o&&o&&o.ownerDocument&&Zn(o.ownerDocument.documentElement,o)){if(null!==l&&ta(o)){var c=l.start,d=l.end;if(void 0===d&&(d=c),"selectionStart"in o)o.selectionStart=c,o.selectionEnd=Math.min(d,o.value.length);else{var u=o.ownerDocument||document,m=u&&u.defaultView||window;if(m.getSelection){var h=m.getSelection(),p=o.textContent.length,g=Math.min(l.start,p),x=void 0===l.end?g:Math.min(l.end,p);!h.extend&&g>x&&(i=x,x=g,g=i);var f=Qn(o,g),b=Qn(o,x);if(f&&b&&(1!==h.rangeCount||h.anchorNode!==f.node||h.anchorOffset!==f.offset||h.focusNode!==b.node||h.focusOffset!==b.offset)){var y=u.createRange();y.setStart(f.node,f.offset),h.removeAllRanges(),g>x?(h.addRange(y),h.extend(b.node,b.offset)):(y.setEnd(b.node,b.offset),h.addRange(y))}}}}for(u=[],h=o;h=h.parentNode;)1===h.nodeType&&u.push({element:h,left:h.scrollLeft,top:h.scrollTop});for("function"===typeof o.focus&&o.focus(),o=0;o<u.length;o++){var v=u[o];v.element.scrollLeft=v.left,v.element.scrollTop=v.top}}nm=!!tu,nu=tu=null}finally{nc=r,I.p=a,B.T=n}}e.current=t,Cc=2}}function rd(){if(2===Cc){Cc=0;var e=Nc,t=Fc,n=0!==(8772&t.flags);if(0!==(8772&t.subtreeFlags)||n){n=B.T,B.T=null;var a=I.p;I.p=2;var r=nc;nc|=4;try{Dl(e,t.alternate,t)}finally{nc=r,I.p=a,B.T=n}}Cc=3}}
2function sd(){if(4===Cc||3===Cc){Cc=0,ee();var e=Nc,t=Fc,n=Sc,a=Tc;0!==(10256&t.subtreeFlags)||0!==(10256&t.flags)?Cc=5:(Cc=0,Fc=Nc=null,id(e,e.pendingLanes));var r=e.pendingLanes;if(0===r&&(Dc=null),Ee(n),t=t.stateNode,ue&&"function"===typeof ue.onCommitFiberRoot)try{ue.onCommitFiberRoot(de,t,void 0,128===(128&t.current.flags))}catch(l){}if(null!==a){t=B.T,r=I.p,I.p=2,B.T=null;try{for(var s=e.onRecoverableError,i=0;i<a.length;i++){var o=a[i];s(o.value,{componentStack:o.stack})}}finally{B.T=t,I.p=r}}0!==(3&Sc)&&od(),kd(e),r=e.pendingLanes,0!==(4194090&n)&&0!==(42&r)?e===_c?Mc++:(Mc=0,_c=e):Mc=0,jd(0,!1)}}function id(e,t){0===(e.pooledCacheLanes&=t)&&(null!=(t=e.pooledCache)&&(e.pooledCache=null,Br(t)))}function od(e){return ad(),rd(),sd(),ld()}function ld(){if(5!==Cc)return!1;var e=Nc,t=Ec;Ec=0;var n=Ee(Sc),a=B.T,r=I.p;try{I.p=32>n?32:n,B.T=null,n=Ac,Ac=null;var s=Nc,o=Sc;if(Cc=0,Fc=Nc=null,Sc=0,0!==(6&nc))throw Error(i(331));var l=nc;if(nc|=4,$l(s.current),Hl(s,s.current,o,n),nc=l,jd(0,!1),ue&&"function"===typeof ue.onPostCommitFiberRoot)try{ue.onPostCommitFiberRoot(de,s)}catch(c){}return!0}finally{I.p=r,B.T=a,id(e,t)}}function cd(e,t,n){t=Da(n,t),null!==(e=ss(e,t=jo(e.stateNode,t,2),2))&&(Ce(e,2),kd(e))}function dd(e,t,n){if(3===e.tag)cd(e,e,n);else for(;null!==t;){if(3===t.tag){cd(t,e,n);break}if(1===t.tag){var a=t.stateNode;if("function"===typeof t.type.getDerivedStateFromError||"function"===typeof a.componentDidCatch&&(null===Dc||!Dc.has(a))){e=Da(n,e),null!==(a=ss(t,n=Do(2),2))&&(Co(n,a,t,e),Ce(a,2),kd(a));break}}t=t.return}}function ud(e,t,n){var a=e.pingCache;if(null===a){a=e.pingCache=new tc;var r=new Set;a.set(t,r)}else void 0===(r=a.get(t))&&(r=new Set,a.set(t,r));r.has(n)||(dc=!0,r.add(n),e=md.bind(null,e,t,n),t.then(e,e))}function md(e,t,n){var a=e.pingCache;null!==a&&a.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,ac===e&&(sc&n)===n&&(4===mc||3===mc&&(62914560&sc)===sc&&300>te()-wc?0===(2&nc)&&Hc(e,0):gc|=n,fc===sc&&(fc=0)),kd(e)}function hd(e,t){0===t&&(t=je()),null!==(e=Ta(e,t))&&(Ce(e,t),kd(e))}function pd(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),hd(e,n)}function gd(e,t){var n=0;switch(e.tag){case 13:var a=e.stateNode,r=e.memoizedState;null!==r&&(n=r.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==a&&a.delete(t),hd(e,n)}var xd=null,fd=null,bd=!1,yd=!1,vd=!1,wd=0;function kd(e){e!==fd&&null===e.next&&(null===fd?xd=fd=e:fd=fd.next=e),yd=!0,bd||(bd=!0,uu(function(){0!==(6&nc)?$(ae,Dd):Cd()}))}function jd(e,t){if(!vd&&yd){vd=!0;do{for(var n=!1,a=xd;null!==a;){if(!t)if(0!==e){var r=a.pendingLanes;if(0===r)var s=0;else{var i=a.suspendedLanes,o=a.pingedLanes;s=(1<<31-he(42|e)+1)-1,s=201326741&(s&=r&~(i&~o))?201326741&s|1:s?2|s:0}0!==s&&(n=!0,Sd(a,s))}else s=sc,0===(3&(s=ye(a,a===ac?s:0,null!==a.cancelPendingCommit||-1!==a.timeoutHandle)))||ve(a,s)||(n=!0,Sd(a,s));a=a.next}}while(n);vd=!1}}function Dd(){Cd()}function Cd(){yd=bd=!1;var e=0;0!==wd&&(function(){var e=window.event;if(e&&"popstate"===e.type)return e!==ou&&(ou=e,!0);return ou=null,!1}()&&(e=wd),wd=0);for(var t=te(),n=null,a=xd;null!==a;){var r=a.next,s=Nd(a,t);0===s?(a.next=null,null===n?xd=r:n.next=r,null===r&&(fd=n)):(n=a,(0!==e||0!==(3&s))&&(yd=!0)),a=r}jd(e,!1)}function Nd(e,t){for(var n=e.suspendedLanes,a=e.pingedLanes,r=e.expirationTimes,s=-62914561&e.pendingLanes;0<s;){var i=31-he(s),o=1<<i,l=r[i];-1===l?0!==(o&n)&&0===(o&a)||(r[i]=we(o,t)):l<=t&&(e.expiredLanes|=o),s&=~o}if(n=sc,n=ye(e,e===(t=ac)?n:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle),a=e.callbackNode,0===n||e===t&&(2===ic||9===ic)||null!==e.cancelPendingCommit)return null!==a&&null!==a&&Q(a),e.callbackNode=null,e.callbackPriority=0;if(0===(3&n)||ve(e,n)){if((t=n&-n)===e.callbackPriority)return t;switch(null!==a&&Q(a),Ee(n)){case 2:case 8:n=re;break;case 32:default:n=se;break;case 268435456:n=oe}return a=Fd.bind(null,e),n=$(n,a),e.callbackPriority=t,e.callbackNode=n,t}return null!==a&&null!==a&&Q(a),e.callbackPriority=2,e.callbackNode=null,2}function Fd(e,t){if(0!==Cc&&5!==Cc)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(od()&&e.callbackNode!==n)return null;var a=sc;return 0===(a=ye(e,e===ac?a:0,null!==e.cancelPendingCommit||-1!==e.timeoutHandle))?null:(Lc(e,a,t),Nd(e,te()),null!=e.callbackNode&&e.callbackNode===n?Fd.bind(null,e):null)}function Sd(e,t){if(od())return null;Lc(e,t,!0)}function Ed(){return 0===wd&&(wd=ke()),wd}function Ad(e){return null==e||"symbol"===typeof e||"boolean"===typeof e?null:"function"===typeof e?e:Et(""+e)}function Td(e,t){var n=t.ownerDocument.createElement("input");
vendor: 4,574 bytes, line 2
2return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}for(var Md=0;Md<wa.length;Md++){var _d=wa[Md];ka(_d.toLowerCase(),"on"+(_d[0].toUpperCase()+_d.slice(1)))}ka(ha,"onAnimationEnd"),ka(pa,"onAnimationIteration"),ka(ga,"onAnimationStart"),ka("dblclick","onDoubleClick"),ka("focusin","onFocus"),ka("focusout","onBlur"),ka(xa,"onTransitionRun"),ka(fa,"onTransitionStart"),ka(ba,"onTransitionCancel"),ka(ya,"onTransitionEnd"),Xe("onMouseEnter",["mouseout","mouseover"]),Xe("onMouseLeave",["mouseout","mouseover"]),Xe("onPointerEnter",["pointerout","pointerover"]),Xe("onPointerLeave",["pointerout","pointerover"]),Ke("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ke("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ke("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ke("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ke("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ke("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bd="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(" "),Id=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Bd));function Pd(e,t){t=0!==(4&t);for(var n=0;n<e.length;n++){var a=e[n],r=a.event;a=a.listeners;e:{var s=void 0;if(t)for(var i=a.length-1;0<=i;i--){var o=a[i],l=o.instance,c=o.currentTarget;if(o=o.listener,l!==s&&r.isPropagationStopped())break e;s=o,r.currentTarget=c;try{s(r)}catch(d){fo(d)}r.currentTarget=null,s=l}else for(i=0;i<a.length;i++){if(l=(o=a[i]).instance,c=o.currentTarget,o=o.listener,l!==s&&r.isPropagationStopped())break e;s=o,r.currentTarget=c;try{s(r)}catch(d){fo(d)}r.currentTarget=null,s=l}}}}function Ld(e,t){var n=t[Ie];void 0===n&&(n=t[Ie]=new Set);var a=e+"__bubble";n.has(a)||(Ud(t,e,2,!1),n.add(a))}function Rd(e,t,n){var a=0;t&&(a|=4),Ud(n,e,a,t)}var zd="_reactListening"+Math.random().toString(36).slice(2);function Od(e){if(!e[zd]){e[zd]=!0,Ye.forEach(function(t){"selectionchange"!==t&&(Id.has(t)||Rd(t,!1,e),Rd(t,!0,e))});var t=9===e.nodeType?e:e.ownerDocument;null===t||t[zd]||(t[zd]=!0,Rd("selectionchange",!1,t))}}function Ud(e,t,n,a){switch(cm(t)){case 2:var r=am;break;case 8:r=rm;break;default:r=sm}n=r.bind(null,t,n,e),r=void 0,!zt||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(r=!0),a?void 0!==r?e.addEventListener(t,n,{capture:!0,passive:r}):e.addEventListener(t,n,!0):void 0!==r?e.addEventListener(t,n,{passive:r}):e.addEventListener(t,n,!1)}function Vd(e,t,n,a,r){var s=a;if(0===(1&t)&&0===(2&t)&&null!==a)e:for(;;){if(null===a)return;var i=a.tag;if(3===i||4===i){var o=a.stateNode.containerInfo;if(o===r)break;if(4===i)for(i=a.return;null!==i;){var c=i.tag;if((3===c||4===c)&&i.stateNode.containerInfo===r)return;i=i.return}for(;null!==o;){if(null===(i=Ue(o)))return;if(5===(c=i.tag)||6===c||26===c||27===c){a=s=i;continue e}o=o.parentNode}}a=a.return}Pt(function(){var a=s,r=Tt(n),i=[];e:{var o=va.get(e);if(void 0!==o){var c=Zt,d=e;switch(e){case"keypress":if(0===Wt(n))break e;case"keydown":case"keyup":c=gn;break;case"focusin":d="focus",c=sn;break;case"focusout":d="blur",c=sn;break;case"beforeblur":case"afterblur":c=sn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=an;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=rn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=fn;break;case ha:case pa:case ga:c=on;break;case ya:c=bn;break;case"scroll":case"scrollend":c=tn;break;case"wheel":c=yn;break;case"copy":case"cut":case"paste":c=ln;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=xn;break;case"toggle":case"beforetoggle":c=vn}var u=0!==(4&t),m=!u&&("scroll"===e||"scrollend"===e),h=u?null!==o?o+"Capture":null:o;u=[];for(var p,g=a;null!==g;){var x=g;if(p=x.stateNode,5!==(x=x.tag)&&26!==x&&27!==x||null===p||null===h||null!=(x=Lt(g,h))&&u.push(Hd(g,x,p)),m)break;g=g.return}
vendor: 6,062 bytes, line 2
20<u.length&&(o=new c(o,d,null,n,r),i.push({event:o,listeners:u}))}}if(0===(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(o="mouseover"===e||"pointerover"===e)||n===At||!(d=n.relatedTarget||n.fromElement)||!Ue(d)&&!d[Be])&&(c||o)&&(o=r.window===r?r:(o=r.ownerDocument)?o.defaultView||o.parentWindow:window,c?(c=a,null!==(d=(d=n.relatedTarget||n.toElement)?Ue(d):null)&&(m=l(d),u=d.tag,d!==m||5!==u&&27!==u&&6!==u)&&(d=null)):(c=null,d=a),c!==d)){if(u=an,x="onMouseLeave",h="onMouseEnter",g="mouse","pointerout"!==e&&"pointerover"!==e||(u=xn,x="onPointerLeave",h="onPointerEnter",g="pointer"),m=null==c?o:He(c),p=null==d?o:He(d),(o=new u(x,g+"leave",c,n,r)).target=m,o.relatedTarget=p,x=null,Ue(r)===a&&((u=new u(h,g+"enter",d,n,r)).target=p,u.relatedTarget=m,x=u),m=x,c&&d)e:{for(h=d,g=0,p=u=c;p;p=Wd(p))g++;for(p=0,x=h;x;x=Wd(x))p++;for(;0<g-p;)u=Wd(u),g--;for(;0<p-g;)h=Wd(h),p--;for(;g--;){if(u===h||null!==h&&u===h.alternate)break e;u=Wd(u),h=Wd(h)}u=null}else u=null;null!==c&&Yd(i,o,c,u,!1),null!==d&&null!==m&&Yd(i,m,d,u,!0)}if("select"===(c=(o=a?He(a):window).nodeName&&o.nodeName.toLowerCase())||"input"===c&&"file"===o.type)var f=Rn;else if(Mn(o))if(zn)f=Kn;else{f=Yn;var b=Wn}else!(c=o.nodeName)||"input"!==c.toLowerCase()||"checkbox"!==o.type&&"radio"!==o.type?a&&Nt(a.elementType)&&(f=Rn):f=Gn;switch(f&&(f=f(e,a))?_n(i,f,n,r):(b&&b(e,o,a),"focusout"===e&&a&&"number"===o.type&&null!=a.memoizedProps.value&&bt(o,"number",o.value)),b=a?He(a):window,e){case"focusin":(Mn(b)||"true"===b.contentEditable)&&(aa=b,ra=a,sa=null);break;case"focusout":sa=ra=aa=null;break;case"mousedown":ia=!0;break;case"contextmenu":case"mouseup":case"dragend":ia=!1,oa(i,n,r);break;case"selectionchange":if(na)break;case"keydown":case"keyup":oa(i,n,r)}var y;if(kn)e:{switch(e){case"compositionstart":var v="onCompositionStart";break e;case"compositionend":v="onCompositionEnd";break e;case"compositionupdate":v="onCompositionUpdate";break e}v=void 0}else An?Sn(e,n)&&(v="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(v="onCompositionStart");v&&(Cn&&"ko"!==n.locale&&(An||"onCompositionStart"!==v?"onCompositionEnd"===v&&An&&(y=qt()):(Vt="value"in(Ut=r)?Ut.value:Ut.textContent,An=!0)),0<(b=qd(a,v)).length&&(v=new cn(v,e,null,n,r),i.push({event:v,listeners:b}),y?v.data=y:null!==(y=En(n))&&(v.data=y))),(y=Dn?function(e,t){switch(e){case"compositionend":return En(t);case"keypress":return 32!==t.which?null:(Fn=!0,Nn);case"textInput":return(e=t.data)===Nn&&Fn?null:e;default:return null}}(e,n):function(e,t){if(An)return"compositionend"===e||!kn&&Sn(e,t)?(e=qt(),Ht=Vt=Ut=null,An=!1,e):null;switch(e){case"paste":default: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 Cn&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(v=qd(a,"onBeforeInput")).length&&(b=new cn("onBeforeInput","beforeinput",null,n,r),i.push({event:b,listeners:v}),b.data=y)),function(e,t,n,a,r){if("submit"===t&&n&&n.stateNode===r){var s=Ad((r[_e]||null).action),i=a.submitter;i&&null!==(t=(t=i[_e]||null)?Ad(t.formAction):i.getAttribute("formAction"))&&(s=t,i=null);var o=new Zt("action","action",null,a,r);e.push({event:o,listeners:[{instance:null,listener:function(){if(a.defaultPrevented){if(0!==wd){var e=i?Td(r,i):new FormData(r);Ai(n,{pending:!0,data:e,method:r.method,action:s},null,e)}}else"function"===typeof s&&(o.preventDefault(),e=i?Td(r,i):new FormData(r),Ai(n,{pending:!0,data:e,method:r.method,action:s},s,e))},currentTarget:r}]})}}(i,e,a,n,r)}Pd(i,t)})}function Hd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function qd(e,t){for(var n=t+"Capture",a=[];null!==e;){var r=e,s=r.stateNode;if(5!==(r=r.tag)&&26!==r&&27!==r||null===s||(null!=(r=Lt(e,n))&&a.unshift(Hd(e,r,s)),null!=(r=Lt(e,t))&&a.push(Hd(e,r,s))),3===e.tag)return a;e=e.return}return[]}function Wd(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag&&27!==e.tag);return e||null}function Yd(e,t,n,a,r){for(var s=t._reactName,i=[];null!==n&&n!==a;){var o=n,l=o.alternate,c=o.stateNode;if(o=o.tag,null!==l&&l===a)break;5!==o&&26!==o&&27!==o||null===c||(l=c,r?null!=(c=Lt(n,s))&&i.unshift(Hd(n,c,l)):r||null!=(c=Lt(n,s))&&i.push(Hd(n,c,l))),n=n.return}0!==i.length&&e.push({event:t,listeners:i})}var Gd=/\r\n?/g,Kd=/\u0000|\uFFFD/g;function Xd(e){return("string"===typeof e?e:""+e).replace(Gd,"\n").replace(Kd,"")}function Jd(e,t){return t=Xd(t),Xd(e)===t}function $d(){}function Qd(e,t,n,a,r,s){switch(n){case"children":"string"===typeof a?"body"===t||"textarea"===t&&""===a||kt(e,a):("number"===typeof a||"bigint"===typeof a)&&"body"!==t&&kt(e,""+a);break;case"className":nt(e,"class",a);break;case"tabIndex":nt(e,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":nt(e,n,a);break;case"style":Ct(e,a,s);break;case"data":if("object"!==t){nt(e,"data",a);break}case"src":case"href":if(""===a&&("a"!==t||"href"!==n)){e.removeAttribute(n);break}if(null==a||"function"===typeof a||"symbol"===typeof a||"boolean"===typeof a){e.removeAttribute(n);break}a=Et(""+a),e.setAttribute(n,a);break;case"action":case"formAction":if("function"===typeof a){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("function"===typeof s&&("formAction"===n?("input"!==t&&Qd(e,t,"name",r.name,r,null),Qd(e,t,"formEncType",r.formEncType,r,null),Qd(e,t,"formMethod",r.formMethod,r,null),Qd(e,t,"formTarget",r.formTarget,r,null)):(Qd(e,t,"encType",r.encType,r,null),Qd(e,t,"method",r.method,r,null),Qd(e,t,"target",r.target,r,null))),null==a||"symbol"===typeof a||"boolean"===typeof a){e.removeAttribute(n);break}a=Et(""+a),e.setAttribute(n,a);break;case"onClick":null!=a&&(e.onclick=$d);break;case"onScroll":null!=a&&Ld("scroll",e);break;case"onScrollEnd":null!=a&&Ld("scrollend",e);break;
2case"dangerouslySetInnerHTML":if(null!=a){if("object"!==typeof a||!("__html"in a))throw Error(i(61));if(null!=(n=a.__html)){if(null!=r.children)throw Error(i(60));e.innerHTML=n}}break;case"multiple":e.multiple=a&&"function"!==typeof a&&"symbol"!==typeof a;break;case"muted":e.muted=a&&"function"!==typeof a&&"symbol"!==typeof a;break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":case"autoFocus":break;case"xlinkHref":if(null==a||"function"===typeof a||"boolean"===typeof a||"symbol"===typeof a){e.removeAttribute("xlink:href");break}n=Et(""+a),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":null!=a&&"function"!==typeof a&&"symbol"!==typeof a?e.setAttribute(n,""+a):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":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":a&&"function"!==typeof a&&"symbol"!==typeof a?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":!0===a?e.setAttribute(n,""):!1!==a&&null!=a&&"function"!==typeof a&&"symbol"!==typeof a?e.setAttribute(n,a):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":null!=a&&"function"!==typeof a&&"symbol"!==typeof a&&!isNaN(a)&&1<=a?e.setAttribute(n,a):e.removeAttribute(n);break;case"rowSpan":case"start":null==a||"function"===typeof a||"symbol"===typeof a||isNaN(a)?e.removeAttribute(n):e.setAttribute(n,a);break;case"popover":Ld("beforetoggle",e),Ld("toggle",e),tt(e,"popover",a);break;case"xlinkActuate":at(e,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":at(e,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":at(e,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":at(e,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":at(e,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":at(e,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":at(e,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":at(e,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":at(e,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":tt(e,"is",a);break;case"innerText":case"textContent":break;default:(!(2<n.length)||"o"!==n[0]&&"O"!==n[0]||"n"!==n[1]&&"N"!==n[1])&&tt(e,n=Ft.get(n)||n,a)}}function Zd(e,t,n,a,r,s){switch(n){case"style":Ct(e,a,s);break;case"dangerouslySetInnerHTML":if(null!=a){if("object"!==typeof a||!("__html"in a))throw Error(i(61));if(null!=(n=a.__html)){if(null!=r.children)throw Error(i(60));e.innerHTML=n}}break;case"children":"string"===typeof a?kt(e,a):("number"===typeof a||"bigint"===typeof a)&&kt(e,""+a);break;case"onScroll":null!=a&&Ld("scroll",e);break;case"onScrollEnd":null!=a&&Ld("scrollend",e);break;case"onClick":null!=a&&(e.onclick=$d);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":case"innerText":case"textContent":break;default:Ge.hasOwnProperty(n)||("o"!==n[0]||"n"!==n[1]||(r=n.endsWith("Capture"),t=n.slice(2,r?n.length-7:void 0),"function"===typeof(s=null!=(s=e[_e]||null)?s[n]:null)&&e.removeEventListener(t,s,r),"function"!==typeof a)?n in e?e[n]=a:!0===a?e.setAttribute(n,""):tt(e,n,a):("function"!==typeof s&&null!==s&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,a,r)))}}function eu(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ld("error",e),Ld("load",e);var a,r=!1,s=!1;for(a in n)if(n.hasOwnProperty(a)){var o=n[a];if(null!=o)switch(a){case"src":r=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:Qd(e,t,a,o,n,null)}}return s&&Qd(e,t,"srcSet",n.srcSet,n,null),void(r&&Qd(e,t,"src",n.src,n,null));case"input":Ld("invalid",e);var l=a=o=s=null,c=null,d=null;for(r in n)if(n.hasOwnProperty(r)){var u=n[r];if(null!=u)switch(r){case"name":s=u;break;case"type":o=u;break;case"checked":c=u;break;case"defaultChecked":d=u;break;case"value":a=u;break;case"defaultValue":l=u;break;case"children":case"dangerouslySetInnerHTML":if(null!=u)throw Error(i(137,t));break;default:Qd(e,t,r,u,n,null)}}return ft(e,a,l,c,d,o,s,!1),void ut(e);case"select":for(s in Ld("invalid",e),r=o=a=null,n)if(n.hasOwnProperty(s)&&null!=(l=n[s]))switch(s){case"value":a=l;break;case"defaultValue":o=l;break;case"multiple":r=l;default:Qd(e,t,s,l,n,null)}return t=a,n=o,e.multiple=!!r,void(null!=t?yt(e,!!r,t,!1):null!=n&&yt(e,!!r,n,!0));case"textarea":for(o in Ld("invalid",e),a=s=r=null,n)if(n.hasOwnProperty(o)&&null!=(l=n[o]))switch(o){case"value":r=l;break;case"defaultValue":s=l;break;case"children":a=l;break;case"dangerouslySetInnerHTML":if(null!=l)throw Error(i(91));break;default:Qd(e,t,o,l,n,null)}return wt(e,r,s,a),void ut(e);case"option":for(c in n)if(n.hasOwnProperty(c)&&null!=(r=n[c]))if("selected"===c)e.selected=r&&"function"!==typeof r&&"symbol"!==typeof r;else Qd(e,t,c,r,n,null);return;case"dialog":Ld("beforetoggle",e),Ld("toggle",e),Ld("cancel",e),Ld("close",e);break;case"iframe":case"object":Ld("load",e);break;case"video":case"audio":for(r=0;r<Bd.length;r++)Ld(Bd[r],e);break;case"image":Ld("error",e),Ld("load",e);break;case"details":Ld("toggle",e);break;case"embed":case"source":case"link":Ld("error",e),Ld("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(d in n)if(n.hasOwnProperty(d)&&null!=(r=n[d]))switch(d){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,t));default:Qd(e,t,d,r,n,null)}return;default:if(Nt(t)){for(u in n)n.hasOwnProperty(u)&&(void 0!==(r=n[u])&&Zd(e,t,u,r,n,void 0));return}}for(l in n)n.hasOwnProperty(l)&&(null!=(r=n[l])&&Qd(e,t,l,r,n,null))}var tu=null,nu=null;
vendor: 4,586 bytes, line 2
2function au(e){return 9===e.nodeType?e:e.ownerDocument}function ru(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 su(e,t){if(0===e)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return 1===e&&"foreignObject"===t?0:e}function iu(e,t){return"textarea"===e||"noscript"===e||"string"===typeof t.children||"number"===typeof t.children||"bigint"===typeof t.children||"object"===typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var ou=null;var lu="function"===typeof setTimeout?setTimeout:void 0,cu="function"===typeof clearTimeout?clearTimeout:void 0,du="function"===typeof Promise?Promise:void 0,uu="function"===typeof queueMicrotask?queueMicrotask:"undefined"!==typeof du?function(e){return du.resolve(null).then(e).catch(mu)}:lu;function mu(e){setTimeout(function(){throw e})}function hu(e){return"head"===e}function pu(e,t){var n=t,a=0,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&8===s.nodeType)if("/$"===(n=s.data)){if(0<a&&8>a){n=a;var i=e.ownerDocument;if(1&n&&wu(i.documentElement),2&n&&wu(i.body),4&n)for(wu(n=i.head),i=n.firstChild;i;){var o=i.nextSibling,l=i.nodeName;i[ze]||"SCRIPT"===l||"STYLE"===l||"LINK"===l&&"stylesheet"===i.rel.toLowerCase()||n.removeChild(i),i=o}}if(0===r)return e.removeChild(s),void Fm(t);r--}else"$"===n||"$?"===n||"$!"===n?r++:a=n.charCodeAt(0)-48;else a=0;n=s}while(n);Fm(t)}function gu(e){var t=e.firstChild;for(t&&10===t.nodeType&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":gu(n),Oe(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if("stylesheet"===n.rel.toLowerCase())continue}e.removeChild(n)}}function xu(e){return"$!"===e.data||"$?"===e.data&&"complete"===e.ownerDocument.readyState}function fu(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t||"F!"===t||"F"===t)break;if("/$"===t)return null}}return e}var bu=null;function yu(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}function vu(e,t,n){switch(t=au(n),e){case"html":if(!(e=t.documentElement))throw Error(i(452));return e;case"head":if(!(e=t.head))throw Error(i(453));return e;case"body":if(!(e=t.body))throw Error(i(454));return e;default:throw Error(i(451))}}function wu(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Oe(e)}var ku=new Map,ju=new Set;function Du(e){return"function"===typeof e.getRootNode?e.getRootNode():9===e.nodeType?e:e.ownerDocument}var Cu=I.d;I.d={f:function(){var e=Cu.f(),t=Uc();return e||t},r:function(e){var t=Ve(e);null!==t&&5===t.tag&&"form"===t.type?Mi(t):Cu.r(e)},D:function(e){Cu.D(e),Fu("dns-prefetch",e,null)},C:function(e,t){Cu.C(e,t),Fu("preconnect",e,t)},L:function(e,t,n){Cu.L(e,t,n);var a=Nu;if(a&&e&&t){var r='link[rel="preload"][as="'+gt(t)+'"]';"image"===t&&n&&n.imageSrcSet?(r+='[imagesrcset="'+gt(n.imageSrcSet)+'"]',"string"===typeof n.imageSizes&&(r+='[imagesizes="'+gt(n.imageSizes)+'"]')):r+='[href="'+gt(e)+'"]';var s=r;switch(t){case"style":s=Eu(e);break;case"script":s=Mu(e)}ku.has(s)||(e=m({rel:"preload",href:"image"===t&&n&&n.imageSrcSet?void 0:e,as:t},n),ku.set(s,e),null!==a.querySelector(r)||"style"===t&&a.querySelector(Au(s))||"script"===t&&a.querySelector(_u(s))||(eu(t=a.createElement("link"),"link",e),We(t),a.head.appendChild(t)))}},m:function(e,t){Cu.m(e,t);var n=Nu;if(n&&e){var a=t&&"string"===typeof t.as?t.as:"script",r='link[rel="modulepreload"][as="'+gt(a)+'"][href="'+gt(e)+'"]',s=r;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":s=Mu(e)}if(!ku.has(s)&&(e=m({rel:"modulepreload",href:e},t),ku.set(s,e),null===n.querySelector(r))){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(_u(s)))return}eu(a=n.createElement("link"),"link",e),We(a),n.head.appendChild(a)}}},X:function(e,t){Cu.X(e,t);var n=Nu;if(n&&e){var a=qe(n).hoistableScripts,r=Mu(e),s=a.get(r);s||((s=n.querySelector(_u(r)))||(e=m({src:e,async:!0},t),(t=ku.get(r))&&Lu(e,t),We(s=n.createElement("script")),eu(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},a.set(r,s))}},S:function(e,t,n){Cu.S(e,t,n);var a=Nu;if(a&&e){var r=qe(a).hoistableStyles,s=Eu(e);t=t||"default";var i=r.get(s);if(!i){var o={loading:0,preload:null};
vendor: 4,168 bytes, line 2
2if(i=a.querySelector(Au(s)))o.loading=5;else{e=m({rel:"stylesheet",href:e,"data-precedence":t},n),(n=ku.get(s))&&Pu(e,n);var l=i=a.createElement("link");We(l),eu(l,"link",e),l._p=new Promise(function(e,t){l.onload=e,l.onerror=t}),l.addEventListener("load",function(){o.loading|=1}),l.addEventListener("error",function(){o.loading|=2}),o.loading|=4,Iu(i,t,a)}i={type:"stylesheet",instance:i,count:1,state:o},r.set(s,i)}}},M:function(e,t){Cu.M(e,t);var n=Nu;if(n&&e){var a=qe(n).hoistableScripts,r=Mu(e),s=a.get(r);s||((s=n.querySelector(_u(r)))||(e=m({src:e,async:!0,type:"module"},t),(t=ku.get(r))&&Lu(e,t),We(s=n.createElement("script")),eu(s,"link",e),n.head.appendChild(s)),s={type:"script",instance:s,count:1,state:null},a.set(r,s))}}};var Nu="undefined"===typeof document?null:document;function Fu(e,t,n){var a=Nu;if(a&&"string"===typeof t&&t){var r=gt(t);r='link[rel="'+e+'"][href="'+r+'"]',"string"===typeof n&&(r+='[crossorigin="'+n+'"]'),ju.has(r)||(ju.add(r),e={rel:e,crossOrigin:n,href:t},null===a.querySelector(r)&&(eu(t=a.createElement("link"),"link",e),We(t),a.head.appendChild(t)))}}function Su(e,t,n,a){var r,s,o,l,c=(c=q.current)?Du(c):null;if(!c)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return"string"===typeof n.precedence&&"string"===typeof n.href?(t=Eu(n.href),(a=(n=qe(c).hoistableStyles).get(t))||(a={type:"style",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if("stylesheet"===n.rel&&"string"===typeof n.href&&"string"===typeof n.precedence){e=Eu(n.href);var d=qe(c).hoistableStyles,u=d.get(e);if(u||(c=c.ownerDocument||c,u={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},d.set(e,u),(d=c.querySelector(Au(e)))&&!d._p&&(u.instance=d,u.state.loading=5),ku.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},ku.set(e,n),d||(r=c,s=e,o=n,l=u.state,r.querySelector('link[rel="preload"][as="style"]['+s+"]")?l.loading=1:(s=r.createElement("link"),l.preload=s,s.addEventListener("load",function(){return l.loading|=1}),s.addEventListener("error",function(){return l.loading|=2}),eu(s,"link",o),We(s),r.head.appendChild(s))))),t&&null===a)throw Error(i(528,""));return u}if(t&&null!==a)throw Error(i(529,""));return null;case"script":return t=n.async,"string"===typeof(n=n.src)&&t&&"function"!==typeof t&&"symbol"!==typeof t?(t=Mu(n),(a=(n=qe(c).hoistableScripts).get(t))||(a={type:"script",instance:null,count:0,state:null},n.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Eu(e){return'href="'+gt(e)+'"'}function Au(e){return'link[rel="stylesheet"]['+e+"]"}function Tu(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Mu(e){return'[src="'+gt(e)+'"]'}function _u(e){return"script[async]"+e}function Bu(e,t,n){if(t.count++,null===t.instance)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+gt(n.href)+'"]');if(a)return t.instance=a,We(a),a;var r=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return We(a=(e.ownerDocument||e).createElement("style")),eu(a,"style",r),Iu(a,n.precedence,e),t.instance=a;case"stylesheet":r=Eu(n.href);var s=e.querySelector(Au(r));if(s)return t.state.loading|=4,t.instance=s,We(s),s;a=Tu(n),(r=ku.get(r))&&Pu(a,r),We(s=(e.ownerDocument||e).createElement("link"));var o=s;return o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),eu(s,"link",a),t.state.loading|=4,Iu(s,n.precedence,e),t.instance=s;case"script":return s=Mu(n.src),(r=e.querySelector(_u(s)))?(t.instance=r,We(r),r):(a=n,(r=ku.get(s))&&Lu(a=m({},n),r),We(r=(e=e.ownerDocument||e).createElement("script")),eu(r,"link",a),e.head.appendChild(r),t.instance=r);case"void":return null;default:throw Error(i(443,t.type))}else"stylesheet"===t.type&&0===(4&t.state.loading)&&(a=t.instance,t.state.loading|=4,Iu(a,n.precedence,e));return t.instance}function Iu(e,t,n){for(var a=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=a.length?a[a.length-1]:null,
vendor: 4,327 bytes, line 2
2s=r,i=0;i<a.length;i++){var o=a[i];if(o.dataset.precedence===t)s=o;else if(s!==r)break}s?s.parentNode.insertBefore(e,s.nextSibling):(t=9===n.nodeType?n.head:n).insertBefore(e,t.firstChild)}function Pu(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.title&&(e.title=t.title)}function Lu(e,t){null==e.crossOrigin&&(e.crossOrigin=t.crossOrigin),null==e.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),null==e.integrity&&(e.integrity=t.integrity)}var Ru=null;function zu(e,t,n){if(null===Ru){var a=new Map,r=Ru=new Map;r.set(n,a)}else(a=(r=Ru).get(n))||(a=new Map,r.set(n,a));if(a.has(e))return a;for(a.set(e,null),n=n.getElementsByTagName(e),r=0;r<n.length;r++){var s=n[r];if(!(s[ze]||s[Me]||"link"===e&&"stylesheet"===s.getAttribute("rel"))&&"http://www.w3.org/2000/svg"!==s.namespaceURI){var i=s.getAttribute(t)||"";i=e+i;var o=a.get(i);o?o.push(s):a.set(i,[s])}}return a}function Ou(e,t,n){(e=e.ownerDocument||e).head.insertBefore(n,"title"===t?e.querySelector("head > title"):null)}function Uu(e){return"stylesheet"!==e.type||0!==(3&e.state.loading)}var Vu=null;function Hu(){}function qu(){if(this.count--,0===this.count)if(this.stylesheets)Yu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}var Wu=null;function Yu(e,t){e.stylesheets=null,null!==e.unsuspend&&(e.count++,Wu=new Map,t.forEach(Gu,e),Wu=null,qu.call(e))}function Gu(e,t){if(!(4&t.state.loading)){var n=Wu.get(e);if(n)var a=n.get(null);else{n=new Map,Wu.set(e,n);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),s=0;s<r.length;s++){var i=r[s];"LINK"!==i.nodeName&&"not all"===i.getAttribute("media")||(n.set(i.dataset.precedence,i),a=i)}a&&n.set(null,a)}i=(r=t.instance).getAttribute("data-precedence"),(s=n.get(i)||a)===a&&n.set(null,r),n.set(i,r),this.count++,a=qu.bind(this),r.addEventListener("load",a),r.addEventListener("error",a),s?s.parentNode.insertBefore(r,s.nextSibling):(e=9===e.nodeType?e.head:e).insertBefore(r,e.firstChild),t.state.loading|=4}}var Ku={$$typeof:w,Provider:null,Consumer:null,_currentValue:P,_currentValue2:P,_threadCount:0};function Xu(e,t,n,a,r,s,i,o){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=De(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=De(0),this.hiddenUpdates=De(null),this.identifierPrefix=a,this.onUncaughtError=r,this.onCaughtError=s,this.onRecoverableError=i,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=o,this.incompleteTransitions=new Map}function Ju(e,t,n,a,r,s,i,o,l,c,d,u){return e=new Xu(e,t,n,i,o,l,c,u),t=1,!0===s&&(t|=24),s=Pa(3,null,null,t),e.current=s,s.stateNode=e,(t=_r()).refCount++,e.pooledCache=t,t.refCount++,s.memoizedState={element:a,isDehydrated:n,cache:t},ns(s),e}function $u(e){return e?e=Ba:Ba}function Qu(e,t,n,a,r,s){r=$u(r),null===a.context?a.context=r:a.pendingContext=r,(a=rs(t)).payload={element:n},null!==(s=void 0===s?null:s)&&(a.callback=s),null!==(n=ss(e,a,t))&&(Pc(n,0,t),is(n,e,t))}function Zu(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function em(e,t){Zu(e,t),(e=e.alternate)&&Zu(e,t)}function tm(e){if(13===e.tag){var t=Ta(e,67108864);null!==t&&Pc(t,0,67108864),em(e,67108864)}}var nm=!0;function am(e,t,n,a){var r=B.T;B.T=null;var s=I.p;try{I.p=2,sm(e,t,n,a)}finally{I.p=s,B.T=r}}function rm(e,t,n,a){var r=B.T;B.T=null;var s=I.p;try{I.p=8,sm(e,t,n,a)}finally{I.p=s,B.T=r}}function sm(e,t,n,a){if(nm){var r=im(a);if(null===r)Vd(e,t,a,om,n),bm(e,a);else if(function(e,t,n,a,r){switch(t){case"focusin":return um=ym(um,e,t,n,a,r),!0;case"dragenter":return mm=ym(mm,e,t,n,a,r),!0;case"mouseover":return hm=ym(hm,e,t,n,a,r),!0;case"pointerover":var s=r.pointerId;return pm.set(s,ym(pm.get(s)||null,e,t,n,a,r)),!0;case"gotpointercapture":return s=r.pointerId,gm.set(s,ym(gm.get(s)||null,e,t,n,a,r)),!0}return!1}(r,e,t,n,a))a.stopPropagation();else if(bm(e,a),4&t&&-1<fm.indexOf(e)){for(;null!==r;){var s=Ve(r);
vendor: 3,006 bytes, line 2
2if(null!==s)switch(s.tag){case 3:if((s=s.stateNode).current.memoizedState.isDehydrated){var i=be(s.pendingLanes);if(0!==i){var o=s;for(o.pendingLanes|=2,o.entangledLanes|=2;i;){var l=1<<31-he(i);o.entanglements[1]|=l,i&=~l}kd(s),0===(6&nc)&&(kc=te()+500,jd(0,!1))}}break;case 13:null!==(o=Ta(s,2))&&Pc(o,0,2),Uc(),em(s,2)}if(null===(s=im(a))&&Vd(e,t,a,om,n),s===r)break;r=s}null!==r&&a.stopPropagation()}else Vd(e,t,a,null,n)}}function im(e){return lm(e=Tt(e))}var om=null;function lm(e){if(om=null,null!==(e=Ue(e))){var t=l(e);if(null===t)e=null;else{var n=t.tag;if(13===n){if(null!==(e=c(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return om=e,null}function cm(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"resize":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"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"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ne()){case ae:return 2;case re:return 8;case se:case ie:return 32;case oe:return 268435456;default:return 32}default:return 32}}var dm=!1,um=null,mm=null,hm=null,pm=new Map,gm=new Map,xm=[],fm="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 bm(e,t){switch(e){case"focusin":case"focusout":um=null;break;case"dragenter":case"dragleave":mm=null;break;case"mouseover":case"mouseout":hm=null;break;case"pointerover":case"pointerout":pm.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":gm.delete(t.pointerId)}}function ym(e,t,n,a,r,s){return null===e||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:a,nativeEvent:s,targetContainers:[r]},null!==t&&(null!==(t=Ve(t))&&tm(t)),e):(e.eventSystemFlags|=a,t=e.targetContainers,null!==r&&-1===t.indexOf(r)&&t.push(r),e)}function vm(e){var t=Ue(e.target);if(null!==t){var n=l(t);
vendor: 5,256 bytes, line 2
2if(null!==n)if(13===(t=n.tag)){if(null!==(t=c(n)))return e.blockedOn=t,void function(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}(e.priority,function(){if(13===n.tag){var e=Bc();e=Se(e);var t=Ta(n,e);null!==t&&Pc(t,0,e),em(n,e)}})}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function wm(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=im(e.nativeEvent);if(null!==n)return null!==(t=Ve(n))&&tm(t),e.blockedOn=n,!1;var a=new(n=e.nativeEvent).constructor(n.type,n);At=a,n.target.dispatchEvent(a),At=null,t.shift()}return!0}function km(e,t,n){wm(e)&&n.delete(t)}function jm(){dm=!1,null!==um&&wm(um)&&(um=null),null!==mm&&wm(mm)&&(mm=null),null!==hm&&wm(hm)&&(hm=null),pm.forEach(km),gm.forEach(km)}function Dm(e,t){e.blockedOn===t&&(e.blockedOn=null,dm||(dm=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,jm)))}var Cm=null;function Nm(e){Cm!==e&&(Cm=e,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){Cm===e&&(Cm=null);for(var t=0;t<e.length;t+=3){var n=e[t],a=e[t+1],r=e[t+2];if("function"!==typeof a){if(null===lm(a||n))continue;break}var s=Ve(n);null!==s&&(e.splice(t,3),t-=3,Ai(s,{pending:!0,data:r,method:n.method,action:a},a,r))}}))}function Fm(e){function t(t){return Dm(t,e)}null!==um&&Dm(um,e),null!==mm&&Dm(mm,e),null!==hm&&Dm(hm,e),pm.forEach(t),gm.forEach(t);for(var n=0;n<xm.length;n++){var a=xm[n];a.blockedOn===e&&(a.blockedOn=null)}for(;0<xm.length&&null===(n=xm[0]).blockedOn;)vm(n),null===n.blockedOn&&xm.shift();if(null!=(n=(e.ownerDocument||e).$$reactFormReplay))for(a=0;a<n.length;a+=3){var r=n[a],s=n[a+1],i=r[_e]||null;if("function"===typeof s)i||Nm(n);else if(i){var o=null;if(s&&s.hasAttribute("formAction")){if(r=s,i=s[_e]||null)o=i.formAction;else if(null!==lm(r))continue}else o=i.action;"function"===typeof o?n[a+1]=o:(n.splice(a,3),a-=3),Nm(n)}}}function Sm(e){this._internalRoot=e}function Em(e){this._internalRoot=e}Em.prototype.render=Sm.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(i(409));Qu(t.current,Bc(),e,t,null,null)},Em.prototype.unmount=Sm.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;Qu(e.current,2,null,e,null,null),Uc(),t[Be]=null}},Em.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ae();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xm.length&&0!==t&&t<xm[n].priority;n++);xm.splice(n,0,e),0===n&&vm(e)}};var Am=r.version;if("19.1.0"!==Am)throw Error(i(527,Am,"19.1.0"));I.findDOMNode=function(e){var t=e._reactInternals;if(void 0===t){if("function"===typeof e.render)throw Error(i(188));throw e=Object.keys(e).join(","),Error(i(268,e))}return e=function(e){var t=e.alternate;if(!t){if(null===(t=l(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,a=t;;){var r=n.return;if(null===r)break;var s=r.alternate;if(null===s){if(null!==(a=r.return)){n=a;continue}break}if(r.child===s.child){for(s=r.child;s;){if(s===n)return d(r),e;if(s===a)return d(r),t;s=s.sibling}throw Error(i(188))}if(n.return!==a.return)n=r,a=s;else{for(var o=!1,c=r.child;c;){if(c===n){o=!0,n=r,a=s;break}if(c===a){o=!0,a=r,n=s;break}c=c.sibling}if(!o){for(c=s.child;c;){if(c===n){o=!0,n=s,a=r;break}if(c===a){o=!0,a=s,n=r;break}c=c.sibling}if(!o)throw Error(i(189))}}if(n.alternate!==a)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}(t),e=null===(e=null!==e?u(e):null)?null:e.stateNode};var Tm={bundleType:0,version:"19.1.0",rendererPackageName:"react-dom",currentDispatcherRef:B,reconcilerVersion:"19.1.0"};if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var Mm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mm.isDisabled&&Mm.supportsFiber)try{de=Mm.inject(Tm),ue=Mm}catch(Bm){}}t.createRoot=function(e,t){if(!o(e))throw Error(i(299));var n=!1,a="",r=bo,s=yo,l=vo;return null!==t&&void 0!==t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(a=t.identifierPrefix),void 0!==t.onUncaughtError&&(r=t.onUncaughtError),void 0!==t.onCaughtError&&(s=t.onCaughtError),void 0!==t.onRecoverableError&&(l=t.onRecoverableError),void 0!==t.unstable_transitionCallbacks&&t.unstable_transitionCallbacks),t=Ju(e,1,!1,null,0,n,a,r,s,l,0,null),e[Be]=t.current,Od(e),new Sm(t)},t.hydrateRoot=function(e,t,n){if(!o(e))throw Error(i(299));var a=!1,r="",s=bo,l=yo,c=vo,d=null;return null!==n&&void 0!==n&&(!0===n.unstable_strictMode&&(a=!0),void 0!==n.identifierPrefix&&(r=n.identifierPrefix),void 0!==n.onUncaughtError&&(s=n.onUncaughtError),void 0!==n.onCaughtError&&(l=n.onCaughtError),void 0!==n.onRecoverableError&&(c=n.onRecoverableError),void 0!==n.unstable_transitionCallbacks&&n.unstable_transitionCallbacks,void 0!==n.formState&&(d=n.formState)),(t=Ju(e,1,!0,t,0,a,r,s,l,c,0,d)).context=$u(null),n=t.current,(r=rs(a=Se(a=Bc()))).callback=null,ss(n,r,a),n=a,t.current.lanes=n,Ce(t,n),kd(t),e[Be]=t.current,Od(e),new Em(t)},t.version="19.1.0"},119:(e,t,n)=>{"use strict";!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(863)},189:(e,t)=>
2{"use strict";t.__esModule=!0,t.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(0===n.length)return!0;var a=e.name||"",r=(e.type||"").toLowerCase(),s=r.replace(/\/.*$/,"");return n.some(function(e){var t=e.trim().toLowerCase();return"."===t.charAt(0)?a.toLowerCase().endsWith(t):t.endsWith("/*")?s===t.replace(/\/.*$/,""):r===t})}return!0}},340:(e,t,n)=>{"use strict";e.exports=n(487)},352:(e,t,n)=>{"use strict";!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=n(85)},414:(e,t,n)=>{"use strict";e.exports=n(916)},487:(e,t)=>{"use strict";function n(e,t){var n=e.length;e.push(t);e:for(;0<n;){var a=n-1>>>1,r=e[a];if(!(0<s(r,t)))break e;e[a]=t,e[n]=r,n=a}}function a(e){return 0===e.length?null:e[0]}function r(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var a=0,r=e.length,i=r>>>1;a<i;){var o=2*(a+1)-1,l=e[o],c=o+1,d=e[c];if(0>s(l,n))c<r&&0>s(d,l)?(e[a]=d,e[c]=n,a=c):(e[a]=l,e[o]=n,a=o);else{if(!(c<r&&0>s(d,n)))break e;e[a]=d,e[c]=n,a=c}}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(t.unstable_now=void 0,"object"===typeof performance&&"function"===typeof performance.now){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],d=[],u=1,m=null,h=3,p=!1,g=!1,x=!1,f=!1,b="function"===typeof setTimeout?setTimeout:null,y="function"===typeof clearTimeout?clearTimeout:null,v="undefined"!==typeof setImmediate?setImmediate:null;function w(e){for(var t=a(d);null!==t;){if(null===t.callback)r(d);else{if(!(t.startTime<=e))break;r(d),t.sortIndex=t.expirationTime,n(c,t)}t=a(d)}}function k(e){if(x=!1,w(e),!g)if(null!==a(c))g=!0,D||(D=!0,j());else{var t=a(d);null!==t&&M(k,t.startTime-e)}}var j,D=!1,C=-1,N=5,F=-1;function S(){return!!f||!(t.unstable_now()-F<N)}function E(){if(f=!1,D){var e=t.unstable_now();F=e;var n=!0;try{e:{g=!1,x&&(x=!1,y(C),C=-1),p=!0;var s=h;try{t:{for(w(e),m=a(c);null!==m&&!(m.expirationTime>e&&S());){var i=m.callback;if("function"===typeof i){m.callback=null,h=m.priorityLevel;var o=i(m.expirationTime<=e);if(e=t.unstable_now(),"function"===typeof o){m.callback=o,w(e),n=!0;break t}m===a(c)&&r(c),w(e)}else r(c);m=a(c)}if(null!==m)n=!0;else{var l=a(d);null!==l&&M(k,l.startTime-e),n=!1}}break e}finally{m=null,h=s,p=!1}n=void 0}}finally{n?j():D=!1}}}if("function"===typeof v)j=function(){v(E)};else if("undefined"!==typeof MessageChannel){var A=new MessageChannel,T=A.port2;A.port1.onmessage=E,j=function(){T.postMessage(null)}}else j=function(){b(E,0)};function M(e,n){C=b(function(){e(t.unstable_now())},n)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):N=0<e?Math.floor(1e3/e):5},t.unstable_getCurrentPriorityLevel=function(){return h},t.unstable_next=function(e){switch(h){case 1:case 2:case 3:var t=3;break;default:t=h}var n=h;h=t;try{return e()}finally{h=n}},t.unstable_requestPaint=function(){f=!0},t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=h;h=e;try{return t()}finally{h=n}},t.unstable_scheduleCallback=function(e,r,s){var i=t.unstable_now();switch("object"===typeof s&&null!==s?s="number"===typeof(s=s.delay)&&0<s?i+s:i:s=i,e){case 1:var o=-1;break;case 2:o=250;break;case 5:o=1073741823;break;case 4:o=1e4;break;default:o=5e3}return e={id:u++,callback:r,priorityLevel:e,startTime:s,expirationTime:o=s+o,sortIndex:-1},s>i?(e.sortIndex=s,n(d,e),null===a(c)&&e===a(d)&&(x?(y(C),C=-1):x=!0,M(k,s-i))):(e.sortIndex=o,n(c,e),g||p||(g=!0,D||(D=!0,j()))),e},t.unstable_shouldYield=S,t.unstable_wrapCallback=function(e){var t=h;return function(){var n=h;h=t;try{return e.apply(this,arguments)}finally{h=n}}}}
2,488:(e,t,n)=>{"use strict";var a=n(959);function r(){}function s(){}s.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,s,i){if(i!==a){var o=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:r};return n.PropTypes=n,n}},755:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,r=Object.getOwnPropertyDescriptor,s=function(e){return"function"===typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},i=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var a,r=t.call(e,"constructor"),s=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!s)return!1;for(a in e);return"undefined"===typeof a||t.call(e,a)},o=function(e,t){a&&"__proto__"===t.name?a(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;if(r)return r(e,n).value}return e[n]};e.exports=function e(){var t,n,a,r,c,d,u=arguments[0],m=1,h=arguments.length,p=!1;for("boolean"===typeof u&&(p=u,u=arguments[1]||{},m=2),(null==u||"object"!==typeof u&&"function"!==typeof u)&&(u={});m<h;++m)if(null!=(t=arguments[m]))for(n in t)a=l(u,n),u!==(r=l(t,n))&&(p&&r&&(i(r)||(c=s(r)))?(c?(c=!1,d=a&&s(a)?a:[]):d=a&&i(a)?a:{},o(u,{name:n,newValue:e(p,d,r)})):"undefined"!==typeof r&&o(u,{name:n,newValue:r}));return u}},814:e=>{var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,i=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,l=/^\s+|\s+$/g,c="";function d(e){return e?e.replace(l,c):c}e.exports=function(e,l){if("string"!==typeof e)throw new TypeError("First argument must be a string");if(!e)return[];l=l||{};var u=1,m=1;function h(e){var t=e.match(n);t&&(u+=t.length);var a=e.lastIndexOf("\n");m=~a?e.length-a:m+e.length}function p(){var e={line:u,column:m};return function(t){return t.position=new g(e),y(),t}}function g(e){this.start=e,this.end={line:u,column:m},this.source=l.source}g.prototype.content=e;var x=[];function f(t){var n=new Error(l.source+":"+u+":"+m+": "+t);if(n.reason=t,n.filename=l.source,n.line=u,n.column=m,n.source=e,!l.silent)throw n;x.push(n)}function b(t){var n=t.exec(e);if(n){var a=n[0];return h(a),e=e.slice(a.length),n}}function y(){b(a)}function v(e){var t;for(e=e||[];t=w();)!1!==t&&e.push(t);return e}function w(){var t=p();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;c!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,c===e.charAt(n-1))return f("End of comment missing");var a=e.slice(2,n-2);return m+=2,h(a),e=e.slice(n),m+=2,t({type:"comment",comment:a})}}function k(){var e=p(),n=b(r);if(n){if(w(),!b(s))return f("property missing ':'");var a=b(i),l=e({type:"declaration",property:d(n[0].replace(t,c)),value:a?d(a[0].replace(t,c)):c});return b(o),l}}return y(),function(){var e,t=[];for(v(t);e=k();)!1!==e&&(t.push(e),v(t));return t}()}},863:(e,t,n)=>{"use strict";var a=n(950);function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var i={d:{f:s,r:function(){throw Error(r(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},o=Symbol.for("react.portal");var l=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){return"font"===e?"":"string"===typeof t?"use-credentials"===t?t:"":void 0}t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,t.createPortal=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!t||1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType)throw Error(r(299));return function(e,t,n){var a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:o,key:null==a?null:""+a,children:e,containerInfo:t,implementation:n}}(e,t,null,n)},t.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},t.preconnect=function(e,t){"string"===typeof e&&(t?t="string"===typeof(t=t.crossOrigin)?"use-credentials"===t?t:"":void 0:t=null,i.d.C(e,t))},t.prefetchDNS=function(e){"string"===typeof e&&i.d.D(e)},t.preinit=function(e,t){if("string"===typeof e&&t&&"string"===typeof t.as){var n=t.as,a=c(n,t.crossOrigin),r="string"===typeof t.integrity?t.integrity:void 0,s="string"===typeof t.fetchPriority?t.fetchPriority:void 0;"style"===n?i.d.S(e,"string"===typeof t.precedence?t.precedence:void 0,{crossOrigin:a,integrity:r,fetchPriority:s}):"script"===n&&i.d.X(e,{crossOrigin:a,integrity:r,fetchPriority:s,nonce:"string"===typeof t.nonce?t.nonce:void 0})}},t.preinitModule=function(e,t){if("string"===typeof e)if("object"===typeof t&&null!==t){if(null==t.as||"script"===t.as){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:"string"===typeof t.integrity?t.integrity:void 0,nonce:"string"===typeof t.nonce?t.nonce:void 0})}}else null==t&&i.d.M(e)},t.preload=function(e,t){if("string"===typeof e&&"object"===typeof t&&null!==t&&"string"===typeof t.as){var n=t.as,a=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:a,integrity:"string"===typeof t.integrity?t.integrity:void 0,nonce:"string"===typeof t.nonce?t.nonce:void 0,type:"string"===typeof t.type?t.type:void 0,fetchPriority:"string"===typeof t.fetchPriority?t.fetchPriority:void 0,referrerPolicy:"str
2ing"===typeof t.referrerPolicy?t.referrerPolicy:void 0,imageSrcSet:"string"===typeof t.imageSrcSet?t.imageSrcSet:void 0,imageSizes:"string"===typeof t.imageSizes?t.imageSizes:void 0,media:"string"===typeof t.media?t.media:void 0})}},t.preloadModule=function(e,t){if("string"===typeof e)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:"string"===typeof t.as&&"script"!==t.as?t.as:void 0,crossOrigin:n,integrity:"string"===typeof t.integrity?t.integrity:void 0})}else i.d.m(e)},t.requestFormReset=function(e){i.d.r(e)},t.unstable_batchedUpdates=function(e,t){return e(t)},t.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},t.useFormStatus=function(){return l.H.useHostTransitionStatus()},t.version="19.1.0"},916:(e,t)=>{"use strict";var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(e,t,a){var r=null;if(void 0!==a&&(r=""+a),void 0!==t.key&&(r=""+t.key),"key"in t)for(var s in a={},t)"key"!==s&&(a[s]=t[s]);else a=t;return t=a.ref,{$$typeof:n,type:e,key:r,ref:void 0!==t?t:null,props:a}}t.Fragment=a,t.jsx=r,t.jsxs=r},935:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.camelCase=void 0;var n=/^--[a-zA-Z0-9_-]+$/,a=/-([a-z])/g,r=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(e,t){return t.toUpperCase()},l=function(e,t){return"".concat(t,"-")};t.camelCase=function(e,t){return void 0===t&&(t={}),function(e){return!e||r.test(e)||n.test(e)}(e)?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(i,l):e.replace(s,l)).replace(a,o))}},942:(e,t,n)=>{e.exports=n(488)()},950:(e,t,n)=>{"use strict";e.exports=n(983)},959:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},967:function(e,t,n){"use strict";var a=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(n(999)),r=n(935);function s(e,t){var n={};return e&&"string"===typeof e?((0,a.default)(e,function(e,a){e&&a&&(n[(0,r.camelCase)(e,t)]=a)}),n):n}s.default=s,e.exports=s},983:(e,t)=>{"use strict";var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.iterator;var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,x={};function f(e,t,n){this.props=e,this.context=t,this.refs=x,this.updater=n||p}function b(){}function y(e,t,n){this.props=e,this.context=t,this.refs=x,this.updater=n||p}f.prototype.isReactComponent={},f.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},f.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=f.prototype;var v=y.prototype=new b;v.constructor=y,g(v,f.prototype),v.isPureReactComponent=!0;var w=Array.isArray,k={H:null,A:null,T:null,S:null,V:null},j=Object.prototype.hasOwnProperty;function D(e,t,a,r,s,i){return a=i.ref,{$$typeof:n,type:e,key:t,ref:void 0!==a?a:null,props:i}}function C(e){return"object"===typeof e&&null!==e&&e.$$typeof===n}var N=/\/+/g;function F(e,t){return"object"===typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function S(){}function E(e,t,r,s,i){var o=typeof e;"undefined"!==o&&"boolean"!==o||(e=null);var l,c,d=!1;if(null===e)d=!0;else switch(o){case"bigint":case"string":case"number":d=!0;break;case"object":switch(e.$$typeof){case n:case a:d=!0;break;case m:return E((d=e._init)(e._payload),t,r,s,i)}}if(d)return i=i(e),d=""===s?"."+F(e,0):s,w(i)?(r="",null!=d&&(r=d.replace(N,"$&/")+"/"),E(i,t,r,"",function(e){return e})):null!=i&&(C(i)&&(l=i,c=r+(null==i.key||e&&e.key===i.key?"":(""+i.key).replace(N,"$&/")+"/")+d,i=D(l.type,c,void 0,0,0,l.props)),t.push(i)),1;d=0;var u,p=""===s?".":s+":";if(w(e))for(var g=0;g<e.length;g++)d+=E(s=e[g],t,r,o=p+F(s,g),i);else if("function"===typeof(g=null===(u=e)||"object"!==typeof u?null:"function"===typeof(u=h&&u[h]||u["@@iterator"])?u:null))for(e=g.call(e),g=0;!(s=e.next()).done;)d+=E(s=s.value,t,r,o=p+F(s,g++),i);else if("object"===o){if("function"===typeof e.then)return E(function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch("string"===typeof e.status?e.then(S,S):(e.status="pending",e.then(function(t){"pending"===e.status&&(e.status="fulfilled",e.value=t)},function(t){"pending"===e.status&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}(e),t,r,s,i);throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return d}function A(e,t,n){if(null==e)return e;var a=[],r=0;return E(e,a,"","",function(e){return t.call(n,e,r++)}),a}function T(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var M="function"===typeof reportError?reportError:function(e){if("object"===typeof window&&"function"===typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"===typeof e&&null!==e&&"string"===typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"===typeof process&&"function"===typeof process.emit)return void process.emit("uncaughtException",e);console.error(e)};function _(){}t.Children={map:A,forEach:function(e,t,n){A(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return A(e,function(){t++}),t},toArray:function(e){return A(e,function(e){return e})||[]},only:function(e){if(!C(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=f,t.Fragment=r,t.Profiler=i,t.PureComponent=y,t.StrictMode=s,t.Suspense=
2d,t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,t.__COMPILER_RUNTIME={__proto__:null,c:function(e){return k.H.useMemoCache(e)}},t.cache=function(e){return function(){return e.apply(null,arguments)}},t.cloneElement=function(e,t,n){if(null===e||void 0===e)throw Error("The argument must be a React element, but you passed "+e+".");var a=g({},e.props),r=e.key;if(null!=t)for(s in void 0!==t.ref&&void 0,void 0!==t.key&&(r=""+t.key),t)!j.call(t,s)||"key"===s||"__self"===s||"__source"===s||"ref"===s&&void 0===t.ref||(a[s]=t[s]);var s=arguments.length-2;if(1===s)a.children=n;else if(1<s){for(var i=Array(s),o=0;o<s;o++)i[o]=arguments[o+2];a.children=i}return D(e.type,r,void 0,0,0,a)},t.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider=e,e.Consumer={$$typeof:o,_context:e},e},t.createElement=function(e,t,n){var a,r={},s=null;if(null!=t)for(a in void 0!==t.key&&(s=""+t.key),t)j.call(t,a)&&"key"!==a&&"__self"!==a&&"__source"!==a&&(r[a]=t[a]);var i=arguments.length-2;if(1===i)r.children=n;else if(1<i){for(var o=Array(i),l=0;l<i;l++)o[l]=arguments[l+2];r.children=o}if(e&&e.defaultProps)for(a in i=e.defaultProps)void 0===r[a]&&(r[a]=i[a]);return D(e,s,void 0,0,0,r)},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:c,render:e}},t.isValidElement=C,t.lazy=function(e){return{$$typeof:m,_payload:{_status:-1,_result:e},_init:T}},t.memo=function(e,t){return{$$typeof:u,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=k.T,n={};k.T=n;try{var a=e(),r=k.S;null!==r&&r(n,a),"object"===typeof a&&null!==a&&"function"===typeof a.then&&a.then(_,M)}catch(s){M(s)}finally{k.T=t}},t.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},t.use=function(e){return k.H.use(e)},t.useActionState=function(e,t,n){return k.H.useActionState(e,t,n)},t.useCallback=function(e,t){return k.H.useCallback(e,t)},t.useContext=function(e){return k.H.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e,t){return k.H.useDeferredValue(e,t)},t.useEffect=function(e,t,n){var a=k.H;if("function"===typeof n)throw Error("useEffect CRUD overload is not enabled in this build of React.");return a.useEffect(e,t)},t.useId=function(){return k.H.useId()},t.useImperativeHandle=function(e,t,n){return k.H.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return k.H.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return k.H.useLayoutEffect(e,t)},t.useMemo=function(e,t){return k.H.useMemo(e,t)},t.useOptimistic=function(e,t){return k.H.useOptimistic(e,t)},t.useReducer=function(e,t,n){return k.H.useReducer(e,t,n)},t.useRef=function(e){return k.H.useRef(e)},t.useState=function(e){return k.H.useState(e)},t.useSyncExternalStore=function(e,t,n){return k.H.useSyncExternalStore(e,t,n)},t.useTransition=function(){return k.H.useTransition()},t.version="19.1.0"},999:function(e,t,n){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=null;if(!e||"string"!==typeof e)return n;var a=(0,r.default)(e),s="function"===typeof t;return a.forEach(function(e){if("declaration"===e.type){var a=e.property,r=e.value;s?t(a,r,e):r&&((n=n||{})[a]=r)}}),n};var r=a(n(814))}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var s=t[a]={exports:{}};return e[a].call(s.exports,s,s.exports,n),s.exports}n.m=e,(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;n.t=function(a,r){if(1&r&&(a=this(a)),8&r)return a;
2if("object"===typeof a&&a){if(4&r&&a.__esModule)return a;if(16&r&&"function"===typeof a.then)return a}var s=Object.create(null);n.r(s);var i={};e=e||[null,t({}),t([]),t(t)];for(var o=2&r&&a;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach(e=>i[e]=()=>a[e]);return i.default=()=>a,n.d(s,i),s}})(),n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((t,a)=>(n.f[a](e,t),t),[])),n.u=e=>"static/js/"+e+"."+{206:"ef4aad9d",995:"ddc8e1f7"}[e]+".chunk.js",n.miniCssF=e=>{},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={},t="deepgram-transcriber-react:";n.l=(a,r,s,i)=>{if(e[a])e[a].push(r);else{var o,l;if(void 0!==s)for(var c=document.getElementsByTagName("script"),d=0;d<c.length;d++){var u=c[d];if(u.getAttribute("src")==a||u.getAttribute("data-webpack")==t+s){o=u;break}}o||(l=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,n.nc&&o.setAttribute("nonce",n.nc),o.setAttribute("data-webpack",t+s),o.src=a),e[a]=[r];var m=(t,n)=>{o.onerror=o.onload=null,clearTimeout(h);var r=e[a];if(delete e[a],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(e=>e(n)),t)return t(n)},h=setTimeout(m.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=m.bind(null,o.onerror),o.onload=m.bind(null,o.onload),l&&document.head.appendChild(o)}}})(),n.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.p="https://files.rescript.info/",(()=>{var e={792:0};n.f.j=(t,a)=>{var r=n.o(e,t)?e[t]:void 0;if(0!==r)if(r)a.push(r[2]);else{var s=new Promise((n,a)=>r=e[t]=[n,a]);a.push(r[2]=s);var i=n.p+n.u(t),o=new Error;n.l(i,a=>{if(n.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var s=a&&("load"===a.type?"missing":a.type),i=a&&a.target&&a.target.src;o.message="Loading chunk "+t+" failed.\n("+s+": "+i+")",o.name="ChunkLoadError",o.type=s,o.request=i,r[1](o)}},"chunk-"+t,t)}};var t=(t,a)=>{var r,s,i=a[0],o=a[1],l=a[2],c=0;if(i.some(t=>0!==e[t])){for(r in o)n.o(o,r)&&(n.m[r]=o[r]);if(l)l(n)}for(t&&t(a);c<i.length;c++)s=i[c],n.o(e,s)&&e[s]&&e[s][0](),e[s]=0},a=self.webpackChunkdeepgram_transcriber_react=self.webpackChunkdeepgram_transcriber_react||[];a.forEach(t.bind(null,0)),a.push=t.bind(null,a.push.bind(a))})(),(()=>{"use strict";var e={};n.r(e),n.d(e,{boolean:()=>rg,booleanish:()=>sg,commaOrSpaceSeparated:()=>dg,commaSeparated:()=>cg,number:()=>og,overloadedBoolean:()=>ig,spaceSeparated:()=>lg});var t={};n.r(t),n.d(t,{attentionMarkers:()=>Uf,contentInitial:()=>If,disable:()=>Vf,document:()=>Bf,flow:()=>Lf,flowInitial:()=>Pf,insideSpan:()=>Of,string:()=>Rf,text:()=>zf});var a=n(950),r=n.t(a,2),s=n(352);function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function o(e){var t=function(e,t){if("object"!=i(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,t||"default");if("object"!=i(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==i(t)?t:t+""}function l(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach(function(t){l(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var u=n(414);function m(e){let{toast:t,onDismiss:n}=e;const r=(0,a.useRef)(null),s=(0,a.useRef)(n);return s.current=n,(0,a.useEffect)(()=>{const e=r.current;if(!e)return;const{message:n,tone:a}=t;e.textContent=n;const i=window.AppToast.attach(e,{message:n,tone:a,onDismiss:()=>s.current()});return()=>i.dispose()},[t]),(0,u.jsx)("div",{ref:r})}const h=(0,a.createContext)({});function p(e){const t=(0,a.useRef)(null);return null===t.current&&(t.current=e()),t.current}const g="undefined"!==typeof window,x=g?a.useLayoutEffect:a.useEffect,f=(0,a.createContext)(null);function b(e){return"object"===typeof e&&null!==e}function y(e){return b(e)&&"offsetHeight"in e}const v=(0,a.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class w extends a.Component{getSnapshotBeforeUpdate(e){const t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){const e=t.offsetParent,n=y(e)&&e.offsetWidth||0,a=this.props.sizeRef.current;a.height=t.offsetHeight||0,a.width=t.offsetWidth||0,a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left}return null}componentDidUpdate(){}render(){return this.props.children}}function k(e){let{children:t,isPresent:n,anchorX:r}=e;const s=(0,a.useId)(),i=(0,a.useRef)(null),o=(0,a.useRef)({width:0,height:0,top:0,left:0,right:0}),{nonce:l}=(0,a.useContext)(v);return(0,a.useInsertionEffect)(()=>{const{width:e,height:t,top:a,left:c,right:d}=o.current;if(n||!i.current||!e||!t)return;
2const u="left"===r?"left: ".concat(c):"right: ".concat(d);i.current.dataset.motionPopId=s;const m=document.createElement("style");return l&&(m.nonce=l),document.head.appendChild(m),m.sheet&&m.sheet.insertRule('\n [data-motion-pop-id="'.concat(s,'"] {\n position: absolute !important;\n width: ').concat(e,"px !important;\n height: ").concat(t,"px !important;\n ").concat(u,"px !important;\n top: ").concat(a,"px !important;\n }\n ")),()=>{document.head.contains(m)&&document.head.removeChild(m)}},[n]),(0,u.jsx)(w,{isPresent:n,childRef:i,sizeRef:o,children:a.cloneElement(t,{ref:i})})}const j=e=>{let{children:t,initial:n,isPresent:r,onExitComplete:s,custom:i,presenceAffectsLayout:o,mode:l,anchorX:c}=e;const m=p(D),h=(0,a.useId)();let g=!0,x=(0,a.useMemo)(()=>(g=!1,{id:h,initial:n,isPresent:r,custom:i,onExitComplete:e=>{m.set(e,!0);for(const t of m.values())if(!t)return;s&&s()},register:e=>(m.set(e,!1),()=>m.delete(e))}),[r,m,s]);return o&&g&&(x=d({},x)),(0,a.useMemo)(()=>{m.forEach((e,t)=>m.set(t,!1))},[r]),a.useEffect(()=>{!r&&!m.size&&s&&s()},[r]),"popLayout"===l&&(t=(0,u.jsx)(k,{isPresent:r,anchorX:c,children:t})),(0,u.jsx)(f.Provider,{value:x,children:t})};function D(){return new Map}function C(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=(0,a.useContext)(f);if(null===t)return[!0,null];const{isPresent:n,onExitComplete:r,register:s}=t,i=(0,a.useId)();(0,a.useEffect)(()=>{if(e)return s(i)},[e]);const o=(0,a.useCallback)(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,o]:[!0]}const N=e=>e.key||"";function F(e){const t=[];return a.Children.forEach(e,e=>{(0,a.isValidElement)(e)&&t.push(e)}),t}const S=e=>{let{children:t,custom:n,initial:r=!0,onExitComplete:s,presenceAffectsLayout:i=!0,mode:o="sync",propagate:l=!1,anchorX:c="left"}=e;const[d,m]=C(l),g=(0,a.useMemo)(()=>F(t),[t]),f=l&&!d?[]:g.map(N),b=(0,a.useRef)(!0),y=(0,a.useRef)(g),v=p(()=>new Map),[w,k]=(0,a.useState)(g),[D,S]=(0,a.useState)(g);x(()=>{b.current=!1,y.current=g;for(let e=0;e<D.length;e++){const t=N(D[e]);f.includes(t)?v.delete(t):!0!==v.get(t)&&v.set(t,!1)}},[D,f.length,f.join("-")]);const E=[];if(g!==w){let e=[...g];for(let t=0;t<D.length;t++){const n=D[t],a=N(n);f.includes(a)||(e.splice(t,0,n),E.push(n))}return"wait"===o&&E.length&&(e=E),S(F(e)),k(g),null}const{forceRender:A}=(0,a.useContext)(h);return(0,u.jsx)(u.Fragment,{children:D.map(e=>{const t=N(e),a=!(l&&!d)&&(g===D||f.includes(t));return(0,u.jsx)(j,{isPresent:a,initial:!(b.current&&!r)&&void 0,custom:n,presenceAffectsLayout:i,mode:o,onExitComplete:a?void 0:()=>{if(!v.has(t))return;v.set(t,!0);let e=!0;v.forEach(t=>{t||(e=!1)}),e&&(null===A||void 0===A||A(),S(y.current),l&&(null===m||void 0===m||m()),s&&s())},anchorX:c,children:e},t)})})};function E(e){if("undefined"===typeof Proxy)return e;const t=new Map;return new Proxy(function(){return e(...arguments)},{get:(n,a)=>"create"===a?e:(t.has(a)||t.set(a,e(a)),t.get(a))})}function A(e){return null!==e&&"object"===typeof e&&"function"===typeof e.start}function T(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(-1!==t.indexOf(a))continue;n[a]=e[a]}return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)n=s[a],-1===t.indexOf(n)&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function M(e){const t=[{},{}];return null===e||void 0===e||e.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function _(e,t,n,a){if("function"===typeof t){const[r,s]=M(a);t=t(void 0!==n?n:e.custom,r,s)}if("string"===typeof t&&(t=e.variants&&e.variants[t]),"function"===typeof t){const[r,s]=M(a);t=t(void 0!==n?n:e.custom,r,s)}return t}function B(e,t,n){const a=e.getProps();return _(a,t,void 0!==n?n:a.custom,e)}function I(e,t){var n,a;return null!==(n=null!==(a=null===e||void 0===e?void 0:e[t])&&void 0!==a?a:null===e||void 0===e?void 0:e.default)&&void 0!==n?n:e}const P=e=>e,L={},R=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],z={value:null,addProjectionMetrics:null};function O(e,t){let n=!1,a=!0;const r={delta:0,timestamp:0,isProcessing:!1},s=()=>n=!0,i=R.reduce((e,n)=>(e[n]=function(e,t){let n=new Set,a=new Set,r=!1,s=!1;const i=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1},l=0;
2function c(t){i.has(t)&&(d.schedule(t),e()),l++,t(o)}const d={schedule:function(e){const t=arguments.length>2&&void 0!==arguments[2]&&arguments[2]&&r?n:a;return arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&i.add(e),t.has(e)||t.add(e),e},cancel:e=>{a.delete(e),i.delete(e)},process:e=>{o=e,r?s=!0:(r=!0,[n,a]=[a,n],n.forEach(c),t&&z.value&&z.value.frameloop[t].push(l),l=0,n.clear(),r=!1,s&&(s=!1,d.process(e)))}};return d}(s,t?n:void 0),e),{}),{setup:o,read:l,resolveKeyframes:c,preUpdate:d,update:u,preRender:m,render:h,postRender:p}=i,g=()=>{const s=L.useManualTiming?r.timestamp:performance.now();n=!1,L.useManualTiming||(r.delta=a?1e3/60:Math.max(Math.min(s-r.timestamp,40),1)),r.timestamp=s,r.isProcessing=!0,o.process(r),l.process(r),c.process(r),d.process(r),u.process(r),m.process(r),h.process(r),p.process(r),r.isProcessing=!1,n&&t&&(a=!1,e(g))},x=R.reduce((t,s)=>{const o=i[s];return t[s]=function(t){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return n||(n=!0,a=!0,r.isProcessing||e(g)),o.schedule(t,s,i)},t},{});return{schedule:x,cancel:e=>{for(let t=0;t<R.length;t++)i[R[t]].cancel(e)},state:r,steps:i}}const{schedule:U,cancel:V,state:H,steps:q}=O("undefined"!==typeof requestAnimationFrame?requestAnimationFrame:P,!0),W=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Y=(()=>new Set(W))(),G=new Set(["width","height","top","left","right","bottom",...W]);function K(e,t){-1===e.indexOf(t)&&e.push(t)}function X(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class J{constructor(){this.subscriptions=[]}add(e){return K(this.subscriptions,e),()=>X(this.subscriptions,e)}notify(e,t,n){const a=this.subscriptions.length;if(a)if(1===a)this.subscriptions[0](e,t,n);else for(let r=0;r<a;r++){const a=this.subscriptions[r];a&&a(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function $(e,t){return t?e*(1e3/t):0}let Q;function Z(){Q=void 0}const ee={now:()=>(void 0===Q&&ee.set(H.isProcessing||L.useManualTiming?H.timestamp:performance.now()),Q),set:e=>{Q=e,queueMicrotask(Z)}},te={current:void 0};class ne{constructor(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.canTrackVelocity=null,this.events={},this.updateAndNotify=function(e){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const a=ee.now();var r,s;if((t.updatedAt!==a&&t.setPrevFrameValue(),t.prev=t.current,t.setCurrent(e),t.current!==t.prev)&&(null===(r=t.events.change)||void 0===r||r.notify(t.current),t.dependents))for(const i of t.dependents)i.dirty();n&&(null===(s=t.events.renderRequest)||void 0===s||s.notify(t.current))},this.hasAnimated=!1,this.setCurrent(e),this.owner=n.owner}setCurrent(e){var t;this.current=e,this.updatedAt=ee.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=(t=this.current,!isNaN(parseFloat(t))))}setPrevFrameValue(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.current;this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new J);const n=this.events[e].add(t);return"change"===e?()=>{n(),U.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];t&&this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e,t)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;null===(e=this.events.change)||void 0===e||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return te.current&&te.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){const e=ee.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||e-this.updatedAt>30)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,30);return $(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,t;null===(e=this.dependents)||void 0===e||e.clear(),null===(t=this.events.destroy)||void 0===t||t.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function ae(e,t){return new ne(e,t)}const re=e=>Array.isArray(e),se=["transitionEnd","transition"];function ie(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,ae(n))}function oe(e){return re(e)?e[e.length-1]||0:e}const le=e=>Boolean(e&&e.getVelocity);function ce(e,t){const n=e.getValue("willChange");
2if(a=n,Boolean(le(a)&&a.add))return n.add(t);if(!n&&L.WillChange){const n=new L.WillChange("auto");e.addValue("willChange",n),n.add(t)}var a}const de=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),ue="data-"+de("framerAppearId");function me(e){return e.props[ue]}const he=(e,t)=>n=>t(e(n)),pe=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(he)},ge=(e,t,n)=>n>t?t:n<e?e:n,xe=e=>1e3*e,fe=e=>e/1e3,be={layout:0,mainThread:0,waapi:0};const ye=e=>t=>"string"===typeof t&&t.startsWith(e),ve=ye("--"),we=ye("var(--"),ke=e=>!!we(e)&&je.test(e.split("/*")[0].trim()),je=/var\(--(?:[\x2D0-9A-Z_a-z\u017F\u212A]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*|[\x2D0-9A-Z_a-z\u017F\u212A]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*,(?:[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?:(?![\t-\r \(\)\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uD800-\uDFFF\uFEFF])[^]|[\uD800-\uDBFF][\uDC00-\uDFFF])|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\((?:(?:(?![\(\)\uD800-\uDFFF])[^]|[\uD800-\uDBFF][\uDC00-\uDFFF])|\((?:(?![\(\)\uD800-\uDFFF])[^]|[\uD800-\uDBFF][\uDC00-\uDFFF])*\))*\))+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*)\)$/i,De={test:e=>"number"===typeof e,parse:parseFloat,transform:e=>e},Ce=d(d({},De),{},{transform:e=>ge(0,1,e)}),Ne=d(d({},De),{},{default:1}),Fe=e=>Math.round(1e5*e)/1e5,Se=/-?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)/g;const Ee=/^(?:#[0-9a-f]{3,8}|(?:rgb|h[s\u017F]l)a?\((?:-?[\.0-9]+%?[\t-\r ,\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+){2}-?[\.0-9]+%?[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?:[,\/][\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*)?(?:\b[0-9]+(?:\.[0-9]+)?|\.[0-9]+)?%?\))$/i,Ae=(e,t)=>n=>Boolean("string"===typeof n&&Ee.test(n)&&n.startsWith(e)||t&&!function(e){return null==e}(n)&&Object.prototype.hasOwnProperty.call(n,t)),Te=(e,t,n)=>a=>{if("string"!==typeof a)return a;const[r,s,i,o]=a.match(Se);return{[e]:parseFloat(r),[t]:parseFloat(s),[n]:parseFloat(i),alpha:void 0!==o?parseFloat(o):1}},Me=d(d({},De),{},{transform:e=>Math.round((e=>ge(0,255,e))(e))}),_e={test:Ae("rgb","red"),parse:Te("red","green","blue"),transform:e=>{let{red:t,green:n,blue:a,alpha:r=1}=e;return"rgba("+Me.transform(t)+", "+Me.transform(n)+", "+Me.transform(a)+", "+Fe(Ce.transform(r))+")"}};const Be={test:Ae("#"),parse:function(e){let t="",n="",a="",r="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),a=e.substring(5,7),r=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),a=e.substring(3,4),r=e.substring(4,5),t+=t,n+=n,a+=a,r+=r),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(a,16),alpha:r?parseInt(r,16)/255:1}},transform:_e.transform},Ie=e=>({test:t=>"string"===typeof t&&t.endsWith(e)&&1===t.split(" ").length,parse:parseFloat,transform:t=>"".concat(t).concat(e)}),Pe=Ie("deg"),Le=Ie("%"),Re=Ie("px"),ze=Ie("vh"),Oe=Ie("vw"),Ue=(()=>d(d({},Le),{},{parse:e=>Le.parse(e)/100,transform:e=>Le.transform(100*e)}))(),Ve={test:Ae("hsl","hue"),parse:Te("hue","saturation","lightness"),transform:e=>{let{hue:t,saturation:n,lightness:a,alpha:r=1}=e;return"hsla("+Math.round(t)+", "+Le.transform(Fe(n))+", "+Le.transform(Fe(a))+", "+Fe(Ce.transform(r))+")"}},He={test:e=>_e.test(e)||Be.test(e)||Ve.test(e),parse:e=>_e.test(e)?_e.parse(e):Ve.test(e)?Ve.parse(e):Be.parse(e),transform:e=>"string"===typeof e?e:e.hasOwnProperty("red")?_e.transform(e):Ve.transform(e),getAnimatableNone:e=>{const t=He.parse(e);return t.alpha=0,He.transform(t)}},qe=/(?:#[0-9a-f]{3,8}|(?:rgb|h[s\u017F]l)a?\((?:-?[\.0-9]+%?[\t-\r ,\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+){2}-?[\.0-9]+%?[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?:[,\/][\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*)?(?:\b[0-9]+(?:\.[0-9]+)?|\.[0-9]+)?%?\))/gi;const We="number",Ye="color",Ge=/var[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*--(?:[\x2D0-9A-Z_a-z\u017F\u212A]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*|[\x2D0-9A-Z_a-z\u017F\u212A]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*,(?:[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?:(?![\t-\r \(\)\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uD800-\uDFFF\uFEFF])[^]|[\uD800-\uDBFF][\uDC00-\uDFFF])|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*\((?:(?
2:(?![\(\)\uD800-\uDFFF])[^]|[\uD800-\uDBFF][\uDC00-\uDFFF])|\((?:(?![\(\)\uD800-\uDFFF])[^]|[\uD800-\uDBFF][\uDC00-\uDFFF])*\))*\))+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*)\)|#[0-9a-f]{3,8}|(?:rgb|h[s\u017F]l)a?\((?:-?[\.0-9]+%?[\t-\r ,\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+){2}-?[\.0-9]+%?[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*(?:[,\/][\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*)?(?:\b[0-9]+(?:\.[0-9]+)?|\.[0-9]+)?%?\)|-?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)/gi;function Ke(e){const t=e.toString(),n=[],a={color:[],number:[],var:[]},r=[];let s=0;const i=t.replace(Ge,e=>(He.test(e)?(a.color.push(s),r.push(Ye),n.push(He.parse(e))):e.startsWith("var(")?(a.var.push(s),r.push("var"),n.push(e)):(a.number.push(s),r.push(We),n.push(parseFloat(e))),++s,"${}")).split("${}");return{values:n,split:i,indexes:a,types:r}}function Xe(e){return Ke(e).values}function Je(e){const{split:t,types:n}=Ke(e),a=t.length;return e=>{let r="";for(let s=0;s<a;s++)if(r+=t[s],void 0!==e[s]){const t=n[s];r+=t===We?Fe(e[s]):t===Ye?He.transform(e[s]):e[s]}return r}}const $e=e=>"number"===typeof e?0:He.test(e)?He.getAnimatableNone(e):e;const Qe={test:function(e){var t,n;return isNaN(e)&&"string"===typeof e&&((null===(t=e.match(Se))||void 0===t?void 0:t.length)||0)+((null===(n=e.match(qe))||void 0===n?void 0:n.length)||0)>0},parse:Xe,createTransformer:Je,getAnimatableNone:function(e){const t=Xe(e);return Je(e)(t.map($e))}};function Ze(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function et(e,t){return n=>n>0?t:e}const tt=(e,t,n)=>e+(t-e)*n,nt=(e,t,n)=>{const a=e*e,r=n*(t*t-a)+a;return r<0?0:Math.sqrt(r)},at=[Be,_e,Ve];function rt(e){const t=(n=e,at.find(e=>e.test(n)));var n;if(Boolean(t),"'".concat(e,"' is not an animatable color. Use the equivalent color code instead."),!Boolean(t))return!1;let a=t.parse(e);return t===Ve&&(a=function(e){let{hue:t,saturation:n,lightness:a,alpha:r}=e;t/=360,n/=100,a/=100;let s=0,i=0,o=0;if(n){const e=a<.5?a*(1+n):a+n-a*n,r=2*a-e;s=Ze(r,e,t+1/3),i=Ze(r,e,t),o=Ze(r,e,t-1/3)}else s=i=o=a;return{red:Math.round(255*s),green:Math.round(255*i),blue:Math.round(255*o),alpha:r}}(a)),a}const st=(e,t)=>{const n=rt(e),a=rt(t);if(!n||!a)return et(e,t);const r=d({},n);return e=>(r.red=nt(n.red,a.red,e),r.green=nt(n.green,a.green,e),r.blue=nt(n.blue,a.blue,e),r.alpha=tt(n.alpha,a.alpha,e),_e.transform(r))},it=new Set(["none","hidden"]);function ot(e,t){return n=>tt(e,t,n)}function lt(e){return"number"===typeof e?ot:"string"===typeof e?ke(e)?et:He.test(e)?st:ut:Array.isArray(e)?ct:"object"===typeof e?He.test(e)?st:dt:et}function ct(e,t){const n=[...e],a=n.length,r=e.map((e,n)=>lt(e)(e,t[n]));return e=>{for(let t=0;t<a;t++)n[t]=r[t](e);return n}}function dt(e,t){const n=d(d({},e),t),a={};for(const r in n)void 0!==e[r]&&void 0!==t[r]&&(a[r]=lt(e[r])(e[r],t[r]));return e=>{for(const t in a)n[t]=a[t](e);return n}}const ut=(e,t)=>{const n=Qe.createTransformer(t),a=Ke(e),r=Ke(t);return a.indexes.var.length===r.indexes.var.length&&a.indexes.color.length===r.indexes.color.length&&a.indexes.number.length>=r.indexes.number.length?it.has(e)&&!r.values.length||it.has(t)&&!a.values.length?function(e,t){return it.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}(e,t):pe(ct(function(e,t){const n=[],a={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){var r;const i=t.types[s],o=e.indexes[i][a[i]],l=null!==(r=e.values[o])&&void 0!==r?r:0;n[s]=l,a[i]++}return n}(a,r),r.values),n):("Complex values '".concat(e,"' and '").concat(t,"' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition."),et(e,t))};function mt(e,t,n){if("number"===typeof e&&"number"===typeof t&&"number"===typeof n)return tt(e,t,n);return lt(e)(e,t)}const ht=e=>{const t=t=>{let{timestamp:n}=t;return e(n)};return{start:function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return U.update(t,e)},stop:()=>V(t),now:()=>
2H.isProcessing?H.timestamp:ee.now()}},pt=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,a="";const r=Math.max(Math.round(t/n),2);for(let s=0;s<r;s++)a+=Math.round(1e4*e(s/(r-1)))/1e4+", ";return"linear(".concat(a.substring(0,a.length-2),")")},gt=2e4;function xt(e){let t=0;let n=e.next(t);for(;!n.done&&t<gt;)t+=50,n=e.next(t);return t>=gt?1/0:t}function ft(e,t,n){const a=Math.max(t-5,0);return $(n-e(a),t-a)}const bt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},yt=.001;function vt(e){let t,n,{duration:a=bt.duration,bounce:r=bt.bounce,velocity:s=bt.velocity,mass:i=bt.mass}=e;xe(bt.maxDuration);let o=1-r;o=ge(bt.minDamping,bt.maxDamping,o),a=ge(bt.minDuration,bt.maxDuration,fe(a)),o<1?(t=e=>{const t=e*o,n=t*a,r=t-s,i=kt(e,o),l=Math.exp(-n);return yt-r/i*l},n=e=>{const n=e*o*a,r=n*s+s,i=Math.pow(o,2)*Math.pow(e,2)*a,l=Math.exp(-n),c=kt(Math.pow(e,2),o);return(-t(e)+yt>0?-1:1)*((r-i)*l)/c}):(t=e=>Math.exp(-e*a)*((e-s)*a+1)-.001,n=e=>Math.exp(-e*a)*(a*a*(s-e)));const l=function(e,t,n){let a=n;for(let r=1;r<wt;r++)a-=e(a)/t(a);return a}(t,n,5/a);if(a=xe(a),isNaN(l))return{stiffness:bt.stiffness,damping:bt.damping,duration:a};{const e=Math.pow(l,2)*i;return{stiffness:e,damping:2*o*Math.sqrt(i*e),duration:a}}}const wt=12;function kt(e,t){return e*Math.sqrt(1-t*t)}const jt=["duration","bounce"],Dt=["stiffness","damping","mass"];function Ct(e,t){return t.some(t=>void 0!==e[t])}function Nt(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:bt.visualDuration,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:bt.bounce;const n="object"!==typeof e?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:a,restDelta:r}=n;const s=n.keyframes[0],i=n.keyframes[n.keyframes.length-1],o={done:!1,value:s},{stiffness:l,damping:c,mass:u,duration:m,velocity:h,isResolvedFromDuration:p}=function(e){let t=d({velocity:bt.velocity,stiffness:bt.stiffness,damping:bt.damping,mass:bt.mass,isResolvedFromDuration:!1},e);if(!Ct(e,Dt)&&Ct(e,jt))if(e.visualDuration){const n=e.visualDuration,a=2*Math.PI/(1.2*n),r=a*a,s=2*ge(.05,1,1-(e.bounce||0))*Math.sqrt(r);t=d(d({},t),{},{mass:bt.mass,stiffness:r,damping:s})}else{const n=vt(e);t=d(d(d({},t),n),{},{mass:bt.mass}),t.isResolvedFromDuration=!0}return t}(d(d({},n),{},{velocity:-fe(n.velocity||0)})),g=h||0,x=c/(2*Math.sqrt(l*u)),f=i-s,b=fe(Math.sqrt(l/u)),y=Math.abs(f)<5;let v;if(a||(a=y?bt.restSpeed.granular:bt.restSpeed.default),r||(r=y?bt.restDelta.granular:bt.restDelta.default),x<1){const e=kt(b,x);v=t=>{const n=Math.exp(-x*b*t);return i-n*((g+x*b*f)/e*Math.sin(e*t)+f*Math.cos(e*t))}}else if(1===x)v=e=>i-Math.exp(-b*e)*(f+(g+b*f)*e);else{const e=b*Math.sqrt(x*x-1);v=t=>{const n=Math.exp(-x*b*t),a=Math.min(e*t,300);return i-n*((g+x*b*f)*Math.sinh(a)+e*f*Math.cosh(a))/e}}const w={calculatedDuration:p&&m||null,next:e=>{const t=v(e);if(p)o.done=e>=m;else{let n=0===e?g:0;x<1&&(n=0===e?xe(g):ft(v,e,t));const s=Math.abs(n)<=a,l=Math.abs(i-t)<=r;o.done=s&&l}return o.value=o.done?i:t,o},toString:()=>{const e=Math.min(xt(w),gt),t=pt(t=>w.next(e*t).value,e,30);return e+"ms "+t},toTransition:()=>{}};return w}function Ft(e){let{keyframes:t,velocity:n=0,power:a=.8,timeConstant:r=325,bounceDamping:s=10,bounceStiffness:i=500,modifyTarget:o,min:l,max:c,restDelta:d=.5,restSpeed:u}=e;const m=t[0],h={done:!1,value:m},p=e=>void 0===l?c:void 0===c||Math.abs(l-e)<Math.abs(c-e)?l:c;let g=a*n;const x=m+g,f=void 0===o?x:o(x);f!==x&&(g=f-m);const b=e=>-g*Math.exp(-e/r),y=e=>f+b(e),v=e=>{const t=b(e),n=y(e);h.done=Math.abs(t)<=d,h.value=h.done?f:n};let w,k;const j=e=>{var t;(t=h.value,void 0!==l&&t<l||void 0!==c&&t>c)&&(w=e,k=Nt({keyframes:[h.value,p(h.value)],velocity:ft(y,e,h.value),damping:s,stiffness:i,restDelta:d,restSpeed:u}))};return j(0),{calculatedDuration:null,next:e=>{let t=!1;return k||void 0!==w||(t=!0,v(e),j(e)),void 0!==w&&e>=w?k.next(e-w):(!t&&v(e),h)}}}Nt.applyToOptions=e=>{const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;const n=(arguments.length>2?arguments[2]:void 0)(d(d({},e),{},{keyframes:[0,t]})),a=Math.min(xt(n),gt);return{type:"keyframes",ease:e=>n.next(a*e).value/t,duration:fe(a)}}(e,100,Nt);return e.ease=t.ease,e.duration=xe(t.duration),e.type="keyframes",e};
2const St=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e;function Et(e,t,n,a){if(e===t&&n===a)return P;const r=t=>function(e,t,n,a,r){let s,i,o=0;do{i=t+(n-t)/2,s=St(i,a,r)-e,s>0?n=i:t=i}while(Math.abs(s)>1e-7&&++o<12);return i}(t,0,1,e,n);return e=>0===e||1===e?e:St(r(e),t,a)}const At=Et(.42,0,1,1),Tt=Et(0,0,.58,1),Mt=Et(.42,0,.58,1),_t=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Bt=e=>t=>1-e(1-t),It=Et(.33,1.53,.69,.99),Pt=Bt(It),Lt=_t(Pt),Rt=e=>(e*=2)<1?.5*Pt(e):.5*(2-Math.pow(2,-10*(e-1))),zt=e=>1-Math.sin(Math.acos(e)),Ot=Bt(zt),Ut=_t(zt),Vt=e=>Array.isArray(e)&&"number"===typeof e[0],Ht={linear:P,easeIn:At,easeInOut:Mt,easeOut:Tt,circIn:zt,circInOut:Ut,circOut:Ot,backIn:Pt,backInOut:Lt,backOut:It,anticipate:Rt},qt=e=>{if(Vt(e)){e.length;const[t,n,a,r]=e;return Et(t,n,a,r)}return"string"===typeof e?("Invalid easing type '".concat(e,"'"),Ht[e]):e},Wt=(e,t,n)=>{const a=t-e;return 0===a?1:(n-e)/a};function Yt(e,t){let{clamp:n=!0,ease:a,mixer:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=e.length;if(t.length,1===s)return()=>t[0];if(2===s&&t[0]===t[1])return()=>t[1];const i=e[0]===e[1];e[0]>e[s-1]&&(e=[...e].reverse(),t=[...t].reverse());const o=function(e,t,n){const a=[],r=n||L.mix||mt,s=e.length-1;for(let i=0;i<s;i++){let n=r(e[i],e[i+1]);if(t){const e=Array.isArray(t)?t[i]||P:t;n=pe(e,n)}a.push(n)}return a}(t,a,r),l=o.length,c=n=>{if(i&&n<e[0])return t[0];let a=0;if(l>1)for(;a<e.length-2&&!(n<e[a+1]);a++);const r=Wt(e[a],e[a+1],n);return o[a](r)};return n?t=>c(ge(e[0],e[s-1],t)):c}function Gt(e){const t=[0];return function(e,t){const n=e[e.length-1];for(let a=1;a<=t;a++){const r=Wt(0,t,a);e.push(tt(n,1,r))}}(t,e.length-1),t}function Kt(e){let{duration:t=300,keyframes:n,times:a,ease:r="easeInOut"}=e;const s=(e=>Array.isArray(e)&&"number"!==typeof e[0])(r)?r.map(qt):qt(r),i={done:!1,value:n[0]},o=function(e,t){return e.map(e=>e*t)}(a&&a.length===n.length?a:Gt(n),t),l=Yt(o,n,{ease:Array.isArray(s)?s:(c=n,d=s,c.map(()=>d||Mt).splice(0,c.length-1))});var c,d;return{calculatedDuration:t,next:e=>(i.value=l(e),i.done=e>=t,i)}}const Xt=e=>null!==e;function Jt(e,t,n){let{repeat:a,repeatType:r="loop"}=t,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;const i=e.filter(Xt),o=s<0||a&&"loop"!==r&&a%2===1?0:i.length-1;return o&&void 0!==n?n:i[o]}const $t={decay:Ft,inertia:Ft,tween:Kt,keyframes:Kt,spring:Nt};function Qt(e){"string"===typeof e.type&&(e.type=$t[e.type])}class Zt{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}}const en=e=>e/100;class tn extends Zt{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var e,t;const{motionValue:n}=this.options;n&&n.updatedAt!==ee.now()&&this.tick(ee.now()),this.isStopped=!0,"idle"!==this.state&&(this.teardown(),null===(e=(t=this.options).onStop)||void 0===e||e.call(t))},be.mainThread++,this.options=e,this.initAnimation(),this.play(),!1===e.autoplay&&this.pause()}initAnimation(){const{options:e}=this;Qt(e);const{type:t=Kt,repeat:n=0,repeatDelay:a=0,repeatType:r,velocity:s=0}=e;let{keyframes:i}=e;const o=t||Kt;o!==Kt&&"number"!==typeof i[0]&&(this.mixKeyframes=pe(en,mt(i[0],i[1])),i=[0,100]);const l=o(d(d({},e),{},{keyframes:i}));"mirror"===r&&(this.mirroredGenerator=o(d(d({},e),{},{keyframes:[...i].reverse(),velocity:-s}))),null===l.calculatedDuration&&(l.calculatedDuration=xt(l));const{calculatedDuration:c}=l;this.calculatedDuration=c,this.resolvedDuration=c+a,this.totalDuration=this.resolvedDuration*(n+1)-a,this.generator=l}updateTime(e){const t=Math.round(e-this.startTime)*this.playbackSpeed;null!==this.holdTime?this.currentTime=this.holdTime:this.currentTime=t}tick(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{generator:n,totalDuration:a,mixKeyframes:r,mirroredGenerator:s,resolvedDuration:i,calculatedDuration:o}=this;if(null===this.startTime)return n.next(0);const{delay:l=0,keyframes:c,repeat:d,repeatType:u,repeatDelay:m,type:h,onUpdate:p,finalKeyframe:g}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-a/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);const x=this.currentTime-l*(this.playbackSpeed>=0?1:-1),f=this.playbackSpeed>=0?x<0:x>a;
2this.currentTime=Math.max(x,0),"finished"===this.state&&null===this.holdTime&&(this.currentTime=a);let b=this.currentTime,y=n;if(d){const e=Math.min(this.currentTime,a)/i;let t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),1===n&&t--,t=Math.min(t,d+1);Boolean(t%2)&&("reverse"===u?(n=1-n,m&&(n-=m/i)):"mirror"===u&&(y=s)),b=ge(0,1,n)*i}const v=f?{done:!1,value:c[0]}:y.next(b);r&&(v.value=r(v.value));let{done:w}=v;f||null===o||(w=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const k=null===this.holdTime&&("finished"===this.state||"running"===this.state&&w);return k&&h!==Ft&&(v.value=Jt(c,this.options,g,this.speed)),p&&p(v.value),k&&this.finish(),v}then(e,t){return this.finished.then(e,t)}get duration(){return fe(this.calculatedDuration)}get time(){return fe(this.currentTime)}set time(e){var t;e=xe(e),this.currentTime=e,null===this.startTime||null!==this.holdTime||0===this.playbackSpeed?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),null===(t=this.driver)||void 0===t||t.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(ee.now());const t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=fe(this.currentTime))}play(){var e,t;if(this.isStopped)return;const{driver:n=ht,startTime:a}=this.options;this.driver||(this.driver=n(e=>this.tick(e))),null===(e=(t=this.options).onPlay)||void 0===e||e.call(t);const r=this.driver.now();"finished"===this.state?(this.updateFinished(),this.startTime=r):null!==this.holdTime?this.startTime=r-this.holdTime:this.startTime||(this.startTime=null!==a&&void 0!==a?a:r),"finished"===this.state&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(ee.now()),this.holdTime=this.currentTime}complete(){"running"!==this.state&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,t;this.notifyFinished(),this.teardown(),this.state="finished",null===(e=(t=this.options).onComplete)||void 0===e||e.call(t)}cancel(){var e,t;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),null===(e=(t=this.options).onCancel)||void 0===e||e.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null,be.mainThread--}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var t;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),null===(t=this.driver)||void 0===t||t.stop(),e.observe(this)}}const nn=e=>180*e/Math.PI,an=e=>{const t=nn(Math.atan2(e[1],e[0]));return sn(t)},rn={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:an,rotateZ:an,skewX:e=>nn(Math.atan(e[1])),skewY:e=>nn(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},sn=e=>((e%=360)<0&&(e+=360),e),on=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),ln=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),cn={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:on,scaleY:ln,scale:e=>(on(e)+ln(e))/2,rotateX:e=>sn(nn(Math.atan2(e[6],e[5]))),rotateY:e=>sn(nn(Math.atan2(-e[2],e[0]))),rotateZ:an,rotate:an,skewX:e=>nn(Math.atan(e[4])),skewY:e=>nn(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function dn(e){return e.includes("scale")?1:0}function un(e,t){if(!e||"none"===e)return dn(t);const n=e.match(/^matrix3d\(([\t-\r ,-\.0-9e\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+)\)$/);let a,r;if(n)a=cn,r=n;else{const t=e.match(/^matrix\(([\t-\r ,-\.0-9e\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+)\)$/);a=rn,r=t}if(!r)return dn(t);const s=a[t],i=r[1].split(",").map(mn);return"function"===typeof s?s(i):i[s]}function mn(e){return parseFloat(e.trim())}const hn=e=>e===De||e===Re,pn=new Set(["x","y","z"]),gn=W.filter(e=>!pn.has(e));const xn={width:(e,t)=>{let{x:n}=e,{paddingLeft:a="0",paddingRight:r="0"}=t;return n.max-n.min-parseFloat(a)-parseFloat(r)},height:(e,t)=>{let{y:n}=e,{paddingTop:a="0",paddingBottom:r="0"}=t;return n.max-n.min-parseFloat(a)-parseFloat(r)},top:(e,t)=>{let{top:n}=t;return parseFloat(n)},left:(e,t)=>{let{left:n}=t;return parseFloat(n)},bottom:(e,t)=>{let{y:n}=e,{top:a}=t;return parseFloat(a)+(n.max-n.min)},right:(e,t)=>
2{let{x:n}=e,{left:a}=t;return parseFloat(a)+(n.max-n.min)},x:(e,t)=>{let{transform:n}=t;return un(n,"x")},y:(e,t)=>{let{transform:n}=t;return un(n,"y")}};xn.translateX=xn.x,xn.translateY=xn.y;const fn=new Set;let bn=!1,yn=!1,vn=!1;function wn(){if(yn){const e=Array.from(fn).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{const t=function(e){const t=[];return gn.forEach(n=>{const a=e.getValue(n);void 0!==a&&(t.push([n,a.get()]),a.set(n.startsWith("scale")?1:0))}),t}(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();const t=n.get(e);t&&t.forEach(t=>{var n;let[a,r]=t;null===(n=e.getValue(a))||void 0===n||n.set(r)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{void 0!==e.suspendedScrollY&&window.scrollTo(0,e.suspendedScrollY)})}yn=!1,bn=!1,fn.forEach(e=>e.complete(vn)),fn.clear()}function kn(){fn.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(yn=!0)})}class jn{constructor(e,t,n,a,r){let s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=a,this.element=r,this.isAsync=s}scheduleResolve(){this.state="scheduled",this.isAsync?(fn.add(this),bn||(bn=!0,U.read(kn),U.resolveKeyframes(wn))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:n,motionValue:a}=this;if(null===e[0]){const r=null===a||void 0===a?void 0:a.get(),s=e[e.length-1];if(void 0!==r)e[0]=r;else if(n&&t){const a=n.readValue(t,s);void 0!==a&&null!==a&&(e[0]=a)}void 0===e[0]&&(e[0]=s),a&&void 0===r&&a.set(e[0])}!function(e){for(let n=1;n<e.length;n++){var t;null!==(t=e[n])&&void 0!==t||(e[n]=e[n-1])}}(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),fn.delete(this)}cancel(){"scheduled"===this.state&&(fn.delete(this),this.state="pending")}resume(){"pending"===this.state&&this.scheduleResolve()}}function Dn(e){let t;return()=>(void 0===t&&(t=e()),t)}const Cn=Dn(()=>void 0!==window.ScrollTimeline),Nn={};function Fn(e,t){const n=Dn(e);return()=>{var e;return null!==(e=Nn[t])&&void 0!==e?e:n()}}const Sn=Fn(()=>{try{document.createElement("div").animate({opacity:0}
2,{easing:"linear(0, 1)"})}catch(e){return!1}return!0},"linearEasing"),En=e=>{let[t,n,a,r]=e;return"cubic-bezier(".concat(t,", ").concat(n,", ").concat(a,", ").concat(r,")")},An={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:En([0,.65,.55,1]),circOut:En([.55,0,1,.45]),backIn:En([.31,.01,.66,-.59]),backOut:En([.33,1.53,.69,.99])};function Tn(e,t){return e?"function"===typeof e?Sn()?pt(e,t):"ease-out":Vt(e)?En(e):Array.isArray(e)?e.map(e=>Tn(e,t)||An.easeOut):An[e]:void 0}function Mn(e,t,n){let{delay:a=0,duration:r=300,repeat:s=0,repeatType:i="loop",ease:o="easeOut",times:l}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;const d={[t]:n};l&&(d.offset=l);const u=Tn(o,r);Array.isArray(u)&&(d.easing=u),z.value&&be.waapi++;const m={delay:a,duration:r,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:s+1,direction:"reverse"===i?"alternate":"normal"};c&&(m.pseudoElement=c);const h=e.animate(d,m);return z.value&&h.finished.finally(()=>{be.waapi--}),h}function _n(e){return"function"===typeof e&&"applyToOptions"in e}const Bn=["type"];class In extends Zt{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:t,name:n,keyframes:a,pseudoElement:r,allowFlatten:s=!1,finalKeyframe:i,onComplete:o}=e;this.isPseudoElement=Boolean(r),this.allowFlatten=s,this.options=e,e.type;const l=function(e){let{type:t}=e,n=T(e,Bn);return _n(t)&&Sn()?t.applyToOptions(n):(null!==(a=n.duration)&&void 0!==a||(n.duration=300),null!==(r=n.ease)&&void 0!==r||(n.ease="easeOut"),n);var a,r}(e);this.animation=Mn(t,n,a,l,r),!1===l.autoplay&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const e=Jt(a,this.options,i,this.speed);this.updateMotionValue?this.updateMotionValue(e):function(e,t,n){(e=>e.startsWith("--"))(t)?e.style.setProperty(t,n):e.style[t]=n}(t,n,e),this.animation.cancel()}null===o||void 0===o||o(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),"finished"===this.state&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,t;null===(e=(t=this.animation).finish)||void 0===e||e.call(t)}cancel(){try{this.animation.cancel()}catch(e){}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;"idle"!==e&&"finished"!==e&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,t;this.isPseudoElement||(null===(e=(t=this.animation).commitStyles)||void 0===e||e.call(t))}get duration(){var e,t;const n=(null===(e=this.animation.effect)||void 0===e||null===(t=e.getComputedTiming)||void 0===t?void 0:t.call(e).duration)||0;return fe(Number(n))}get time(){return fe(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=xe(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return null!==this.finishedTime?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline(e){let{timeline:t,observe:n}=e;var a;this.allowFlatten&&(null===(a=this.animation.effect)||void 0===a||a.updateTiming({easing:"linear"}));return this.animation.onfinish=null,t&&Cn()?(this.animation.timeline=t,P):n(this)}}const Pn={anticipate:Rt,backInOut:Lt,circInOut:Ut};function Ln(e){"string"===typeof e.ease&&e.ease in Pn&&(e.ease=Pn[e.ease])}const Rn=["motionValue","onUpdate","onComplete","element"];class zn extends In{constructor(e){Ln(e),Qt(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){var t;const n=this.options,{motionValue:a,onUpdate:r,onComplete:s,element:i}=n,o=T(n,Rn);if(!a)return;if(void 0!==e)return void a.set(e);const l=new tn(d(d({},o),{},{autoplay:!1})),c=xe(null!==(t=this.finishedTime)&&void 0!==t?t:this.time);a.setWithVelocity(l.sample(c-10).value,l.sample(c).value,10),l.stop()}}const On=(e,t)=>"zIndex"!==t&&(!("number"!==typeof e&&!Array.isArray(e))||!("string"!==typeof e||!Qe.test(e)&&"0"!==e||e.startsWith("url(")));const Un=new Set(["opacity","clipPath","filter","transform"]),Vn=Dn(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));const Hn=["autoplay","delay","type","repeat","repeatDelay","repeatType","keyframes","name","motionValue","element"];class qn extends Zt{constructor(e){var t;let{autoplay:n=!0,delay:a=0,type:r="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:
2o="loop",keyframes:l,name:c,motionValue:u,element:m}=e,h=T(e,Hn);super(),this.stop=()=>{var e,t;this._animation&&(this._animation.stop(),null===(t=this.stopTimeline)||void 0===t||t.call(this));null===(e=this.keyframeResolver)||void 0===e||e.cancel()},this.createdAt=ee.now();const p=d({autoplay:n,delay:a,type:r,repeat:s,repeatDelay:i,repeatType:o,name:c,motionValue:u,element:m},h),g=(null===m||void 0===m?void 0:m.KeyframeResolver)||jn;this.keyframeResolver=new g(l,(e,t,n)=>this.onKeyframesResolved(e,t,p,!n),c,u,m),null===(t=this.keyframeResolver)||void 0===t||t.scheduleResolve()}onKeyframesResolved(e,t,n,a){this.keyframeResolver=void 0;const{name:r,type:s,velocity:i,delay:o,isHandoff:l,onUpdate:c}=n;this.resolvedAt=ee.now(),function(e,t,n,a){const r=e[0];if(null===r)return!1;if("display"===t||"visibility"===t)return!0;const s=e[e.length-1],i=On(r,t),o=On(s,t);return"You are trying to animate ".concat(t,' from "').concat(r,'" to "').concat(s,'". ').concat(r," is not an animatable value - to enable this animation set ").concat(r," to a value animatable to ").concat(s," via the `style` property."),!(!i||!o)&&(function(e){const t=e[0];if(1===e.length)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}(e)||("spring"===n||_n(n))&&a)}(e,r,s,i)||(!L.instantAnimations&&o||null===c||void 0===c||c(Jt(e,n,t)),e[0]=e[e.length-1],n.duration=0,n.repeat=0);const u=d(d({startTime:a?this.resolvedAt&&this.resolvedAt-this.createdAt>40?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t},n),{},{keyframes:e}),m=!l&&function(e){var t;const{motionValue:n,name:a,repeatDelay:r,repeatType:s,damping:i,type:o}=e;if(!y(null===n||void 0===n||null===(t=n.owner)||void 0===t?void 0:t.current))return!1;const{onUpdate:l,transformTemplate:c}=n.owner.getProps();return Vn()&&a&&Un.has(a)&&("transform"!==a||!c)&&!l&&!r&&"mirror"!==s&&0!==i&&"inertia"!==o}(u)?new zn(d(d({},u),{},{element:u.motionValue.owner.current})):new tn(u);m.finished.then(()=>this.notifyFinished()).catch(P),this.pendingTimeline&&(this.stopTimeline=m.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){var e;this._animation||(null===(e=this.keyframeResolver)||void 0===e||e.resume(),vn=!0,kn(),wn(),vn=!1);return this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),null===(e=this.keyframeResolver)||void 0===e||e.cancel()}}const Wn=e=>null!==e;const Yn={type:"spring",stiffness:500,damping:25,restSpeed:10},Gn={type:"keyframes",duration:.8},Kn={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Xn=(e,t)=>{let{keyframes:n}=t;return n.length>2?Gn:Y.has(e)?e.startsWith("scale")?{type:"spring",stiffness:550,damping:0===n[1]?2*Math.sqrt(550):30,restSpeed:10}:Yn:Kn},Jn=["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"];const $n=function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0;return i=>{const o=I(a,e)||{},l=o.delay||a.delay||0;let{elapsed:c=0}=a;c-=xe(l);const u=d(d({keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity()},o),{},{delay:-c,onUpdate:e=>{t.set(e),o.onUpdate&&o.onUpdate(e)},onComplete:()=>{i(),o.onComplete&&o.onComplete()},name:e,motionValue:t,element:s?void 0:r});(function(e){let{when:t,delay:n,delayChildren:a,staggerChildren:r,staggerDirection:s,repeat:i,repeatType:o,repeatDelay:l,from:c,elapsed:d}=e,u=T(e,Jn);return!!Object.keys(u).length})(o)||Object.assign(u,Xn(e,u)),u.duration&&(u.duration=xe(u.duration)),u.repeatDelay&&(u.repeatDelay=xe(u.repeatDelay)),void 0!==u.from&&(u.keyframes[0]=u.from);let m=!1;if((!1===u.type||0===u.duration&&!u.repeatDelay)&&(u.duration=0,0===u.delay&&(m=!0)),(L.instantAnimations||L.skipAnimations)&&(m=!0,u.duration=0,u.delay=0),u.allowFlatten=!o.type&&!o.ease,m&&!s&&void 0!==t.get()){const e=function(e,t,n){let{repeat:a,repeatType:r="loop"}=t;const s=e.filter(Wn),i=a&&"loop"!==r&&a%2===1?0:s.length-1;return i&&void 0!==n?n:s[i]}(u.keyframes,o);if(void 0!==e)return void U.update(()=>{u.onUpdate(e),u.onComplete()})}return o.isSync?new tn(u):new qn(u)}},Qn=["transition","transitionEnd"];function Zn(e,t){let{protectedKeys:n,needsAnimating:a}=e;const r=n.hasOwnProperty(t)&&!0!==a[t];return a[t]=!1,r}function ea(e,t){let{delay:n=0,transitionOverride:a,type:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{transition:s=e.getDefaultTransition(),transitionEnd:i}=t,o=T(t,Qn);a&&(s=a);const l=[],c=r&&e.animationState&&e.animationState.getState()[r];for(const m in o){var u;const t=e.getValue(m,null!==(u=e.latestValues[m])&&void 0!==u?u:null),a=o[m];if(void 0===a||c&&Zn(c,m))continue;const r=d({delay:n},I(s||{},m)),i=t.get();if(void 0!==i&&!t.isAnimating&&!Array.isArray(a)&&a===i&&!r.velocity)continue;let h=!1;if(window.MotionHandoffAnimation){const t=me(e);
2if(t){const e=window.MotionHandoffAnimation(t,m,U);null!==e&&(r.startTime=e,h=!0)}}ce(e,m),t.start($n(m,t,a,e.shouldReduceMotion&&G.has(m)?{type:!1}:r,e,h));const p=t.animation;p&&l.push(p)}return i&&Promise.all(l).then(()=>{U.update(()=>{i&&function(e,t){let n=B(e,t)||{},{transitionEnd:a={},transition:r={}}=n,s=T(n,se);s=d(d({},s),a);for(const i in s)ie(e,i,oe(s[i]))}(e,i)})}),l}function ta(e,t){var n;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=B(e,t,"exit"===a.type?null===(n=e.presenceContext)||void 0===n?void 0:n.custom:void 0);let{transition:s=e.getDefaultTransition()||{}}=r||{};a.transitionOverride&&(s=a.transitionOverride);const i=r?()=>Promise.all(ea(e,r,a)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const{delayChildren:r=0,staggerChildren:i,staggerDirection:o}=s;return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5?arguments[5]:void 0;const i=[],o=(e.variantChildren.size-1)*a,l=1===r?function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)*a}:function(){return o-(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)*a};return Array.from(e.variantChildren).sort(na).forEach((e,a)=>{e.notify("AnimationStart",t),i.push(ta(e,t,d(d({},s),{},{delay:n+l(a)})).then(()=>e.notify("AnimationComplete",t)))}),Promise.all(i)}(e,t,r+n,i,o,a)}:()=>Promise.resolve(),{when:l}=s;if(l){const[e,t]="beforeChildren"===l?[i,o]:[o,i];return e().then(()=>t())}return Promise.all([i(),o(a.delay)])}function na(e,t){return e.sortNodePosition(t)}function aa(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let a=0;a<n;a++)if(t[a]!==e[a])return!1;return!0}function ra(e){return"string"===typeof e||Array.isArray(e)}const sa=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],ia=["initial",...sa],oa=ia.length;function la(e){if(!e)return;if(!e.isControllingVariants){const t=e.parent&&la(e.parent)||{};return void 0!==e.props.initial&&(t.initial=e.props.initial),t}const t={};for(let n=0;n<oa;n++){const a=ia[n],r=e.props[a];(ra(r)||!1===r)&&(t[a]=r)}return t}const ca=["transition","transitionEnd"],da=[...sa].reverse(),ua=sa.length;function ma(e){return t=>Promise.all(t.map(t=>{let{animation:n,options:a}=t;return function(e,t){let n,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e.notify("AnimationStart",t),Array.isArray(t)){const r=t.map(t=>ta(e,t,a));n=Promise.all(r)}else if("string"===typeof t)n=ta(e,t,a);else{const r="function"===typeof t?B(e,t,a.custom):t;n=Promise.all(ea(e,r,a))}return n.then(()=>{e.notify("AnimationComplete",t)})}(e,n,a)}))}function ha(e){let t=ma(e),n=xa(),a=!0;const r=t=>(n,a)=>{var r;const s=B(e,a,"exit"===t?null===(r=e.presenceContext)||void 0===r?void 0:r.custom:void 0);if(s){const{transition:e,transitionEnd:t}=s,a=T(s,ca);n=d(d(d({},n),a),t)}return n};function s(s){const{props:i}=e,o=la(e.parent)||{},l=[],c=new Set;let u={},m=1/0;for(let t=0;t<ua;t++){const h=da[t],p=n[h],g=void 0!==i[h]?i[h]:o[h],x=ra(g),f=h===s?p.isActive:null;!1===f&&(m=t);let b=g===o[h]&&g!==i[h]&&x;if(b&&a&&e.manuallyAnimateOnMount&&(b=!1),p.protectedKeys=d({},u),!p.isActive&&null===f||!g&&!p.prevProp||A(g)||"boolean"===typeof g)continue;const y=pa(p.prevProp,g);let v=y||h===s&&p.isActive&&!b&&x||t>m&&x,w=!1;const k=Array.isArray(g)?g:[g];let j=k.reduce(r(h),{});!1===f&&(j={});const{prevResolvedValues:D={}}=p,C=d(d({},D),j),N=t=>{v=!0,c.has(t)&&(w=!0,c.delete(t)),p.needsAnimating[t]=!0;const n=e.getValue(t);n&&(n.liveStyle=!1)};for(const e in C){const t=j[e],n=D[e];if(u.hasOwnProperty(e))continue;let a=!1;a=re(t)&&re(n)?!aa(t,n):t!==n,a?void 0!==t&&null!==t?N(e):c.add(e):void 0!==t&&c.has(e)?N(e):p.protectedKeys[e]=!0}p.prevProp=g,p.prevResolvedValues=j,p.isActive&&(u=d(d({},u),j)),a&&e.blockInitialAnimation&&(v=!1);v&&(!(b&&y)||w)&&l.push(...k.map(e=>({animation:e,options:{type:h}})))}if(c.size){const t={};if("boolean"!==typeof i.initial){const n=B(e,Array.isArray(i.initial)?i.initial[0]:i.initial);n&&n.transition&&(t.transition=n.transition)}c.forEach(n=>{const a=e.getBaseTarget(n),r=e.getValue(n);r&&(r.liveStyle=!0),t[n]=null!==a&&void 0!==a?a:null}),l.push({animation:t})}let h=Boolean(l.length);return!a||!1!==i.initial&&i.initial!==i.animate||e.manuallyAnimateOnMount||(h=!1),a=!1,h?t(l):Promise.resolve()}return{animateChanges:s,setActive:function(t,a){var r;if(n[t].isActive===a)return Promise.resolve();
2null===(r=e.variantChildren)||void 0===r||r.forEach(e=>{var n;return null===(n=e.animationState)||void 0===n?void 0:n.setActive(t,a)}),n[t].isActive=a;const i=s(t);for(const e in n)n[e].protectedKeys={};return i},setAnimateFunction:function(n){t=n(e)},getState:()=>n,reset:()=>{n=xa(),a=!0}}}function pa(e,t){return"string"===typeof t?t!==e:!!Array.isArray(t)&&!aa(t,e)}function ga(){return{isActive:arguments.length>0&&void 0!==arguments[0]&&arguments[0],protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function xa(){return{animate:ga(!0),whileInView:ga(),whileHover:ga(),whileTap:ga(),whileDrag:ga(),whileFocus:ga(),exit:ga()}}class fa{constructor(e){this.isMounted=!1,this.node=e}update(){}}let ba=0;const ya={animation:{Feature:class extends fa{constructor(e){super(e),e.animationState||(e.animationState=ha(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();A(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),null===(e=this.unmountControls)||void 0===e||e.call(this)}}},exit:{Feature:class extends fa{constructor(){super(...arguments),this.id=ba++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;const a=this.node.animationState.setActive("exit",!e);t&&!e&&a.then(()=>{t(this.id)})}mount(){const{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}},va={x:!1,y:!1};function wa(){return va.x||va.y}function ka(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{passive:!0};return e.addEventListener(t,n,a),()=>e.removeEventListener(t,n)}const ja=e=>"mouse"===e.pointerType?"number"!==typeof e.button||e.button<=0:!1!==e.isPrimary;function Da(e){return{point:{x:e.pageX,y:e.pageY}}}function Ca(e,t,n,a){return ka(e,t,(e=>t=>ja(t)&&e(t,Da(t)))(n),a)}function Na(e){let{top:t,left:n,right:a,bottom:r}=e;return{x:{min:n,max:a},y:{min:t,max:r}}}function Fa(e){return e.max-e.min}function Sa(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5;e.origin=a,e.originPoint=tt(t.min,t.max,e.origin),e.scale=Fa(n)/Fa(t),e.translate=tt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=.9999&&e.scale<=1.0001||isNaN(e.scale))&&(e.scale=1),(e.translate>=-.01&&e.translate<=.01||isNaN(e.translate))&&(e.translate=0)}function Ea(e,t,n,a){Sa(e.x,t.x,n.x,a?a.originX:void 0),Sa(e.y,t.y,n.y,a?a.originY:void 0)}function Aa(e,t,n){e.min=n.min+t.min,e.max=e.min+Fa(t)}function Ta(e,t,n){e.min=t.min-n.min,e.max=e.min+Fa(t)}function Ma(e,t,n){Ta(e.x,t.x,n.x),Ta(e.y,t.y,n.y)}const _a=()=>({x:{min:0,max:0},y:{min:0,max:0}});function Ba(e){return[e("x"),e("y")]}function Ia(e){return void 0===e||1===e}function Pa(e){let{scale:t,scaleX:n,scaleY:a}=e;return!Ia(t)||!Ia(n)||!Ia(a)}function La(e){return Pa(e)||Ra(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ra(e){return za(e.x)||za(e.y)}function za(e){return e&&"0%"!==e}function Oa(e,t,n){return n+t*(e-n)}function Ua(e,t,n,a,r){return void 0!==r&&(e=Oa(e,r,a)),Oa(e,n,a)+t}function Va(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;e.min=Ua(e.min,t,n,a,r),e.max=Ua(e.max,t,n,a,r)}function Ha(e,t){let{x:n,y:a}=t;Va(e.x,n.translate,n.scale,n.originPoint),Va(e.y,a.translate,a.scale,a.originPoint)}const qa=.999999999999,Wa=1.0000000000001;function Ya(e,t){e.min=e.min+t,e.max=e.max+t}function Ga(e,t,n,a){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.5;Va(e,t,n,tt(e.min,e.max,r),a)}function Ka(e,t){Ga(e.x,t.x,t.scaleX,t.scale,t.originX),Ga(e.y,t.y,t.scaleY,t.scale,t.originY)}function Xa(e,t){return Na(function(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),a=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:a.y,right:a.x}}(e.getBoundingClientRect(),t))}const Ja=e=>{let{current:t}=e;return t?t.ownerDocument.defaultView:null};function $a(e){return e&&"object"===typeof e&&Object.prototype.hasOwnProperty.call(e,"current")}const Qa=(e,t)=>Math.abs(e-t);class Za{constructor(e,t){let{transformPagePoint:n,contextWindow:a,dragSnapToOrigin:r=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!this.lastMoveEvent||!this.lastMoveEventInfo)return;const e=nr(this.lastMoveEventInfo,this.history),t=null!==this.startEvent,n=function(e,t){const n=Qa(e.x,t.x),a=Qa(e.y,t.y);return Math.sqrt(n**2+a**2)}(e.offset,{x:0,y:0})>=3;if(!t&&!n)return;const{point:a}=e,{timestamp:r}=H;this.history.push(d(d({},a),{},{timestamp:r}));const{onStart:s,onMove:i}=this.handlers;t||(s&&s(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),i&&i(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>
2{this.lastMoveEvent=e,this.lastMoveEventInfo=er(t,this.transformPagePoint),U.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();const{onEnd:n,onSessionEnd:a,resumeAnimation:r}=this.handlers;if(this.dragSnapToOrigin&&r&&r(),!this.lastMoveEvent||!this.lastMoveEventInfo)return;const s=nr("pointercancel"===e.type?this.lastMoveEventInfo:er(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,s),a&&a(e,s)},!ja(e))return;this.dragSnapToOrigin=r,this.handlers=t,this.transformPagePoint=n,this.contextWindow=a||window;const s=er(Da(e),this.transformPagePoint),{point:i}=s,{timestamp:o}=H;this.history=[d(d({},i),{},{timestamp:o})];const{onSessionStart:l}=t;l&&l(e,nr(s,this.history)),this.removeListeners=pe(Ca(this.contextWindow,"pointermove",this.handlePointerMove),Ca(this.contextWindow,"pointerup",this.handlePointerUp),Ca(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),V(this.updatePoint)}}function er(e,t){return t?{point:t(e.point)}:e}function tr(e,t){return{x:e.x-t.x,y:e.y-t.y}}function nr(e,t){let{point:n}=e;return{point:n,delta:tr(n,rr(t)),offset:tr(n,ar(t)),velocity:sr(t,.1)}}function ar(e){return e[0]}function rr(e){return e[e.length-1]}function sr(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,a=null;const r=rr(e);for(;n>=0&&(a=e[n],!(r.timestamp-a.timestamp>xe(t)));)n--;if(!a)return{x:0,y:0};const s=fe(r.timestamp-a.timestamp);if(0===s)return{x:0,y:0};const i={x:(r.x-a.x)/s,y:(r.y-a.y)/s};return i.x===1/0&&(i.x=0),i.y===1/0&&(i.y=0),i}function ir(e,t,n){return{min:void 0!==t?e.min+t:void 0,max:void 0!==n?e.max+n-(e.max-e.min):void 0}}function or(e,t){let n=t.min-e.min,a=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,a]=[a,n]),{min:n,max:a}}const lr=.35;function cr(e,t,n){return{min:dr(e,t),max:dr(e,n)}}function dr(e,t){return"number"===typeof e?e:e[t]||0}const ur=new WeakMap;class mr{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic={x:{min:0,max:0},y:{min:0,max:0}},this.visualElement=e}start(e){let{snapToCursor:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{presenceContext:n}=this.visualElement;if(n&&!1===n.isPresent)return;const{dragSnapToOrigin:a}=this.getProps();this.panSession=new Za(e,{onSessionStart:e=>{const{dragSnapToOrigin:n}=this.getProps();n?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor(Da(e).point)},onStart:(e,t)=>{const{drag:n,dragPropagation:a,onDragStart:r}=this.getProps();if(n&&!a&&(this.openDragLock&&this.openDragLock(),this.openDragLock="x"===(s=n)||"y"===s?va[s]?null:(va[s]=!0,()=>{va[s]=!1}):va.x||va.y?null:(va.x=va.y=!0,()=>{va.x=va.y=!1}),!this.openDragLock))return;var s;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ba(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Le.test(t)){const{projection:n}=this.visualElement;if(n&&n.layout){const a=n.layout.layoutBox[e];if(a){t=Fa(a)*(parseFloat(t)/100)}}}this.originPoint[e]=t}),r&&U.postRender(()=>r(e,t)),ce(this.visualElement,"transform");const{animationState:i}=this.visualElement;i&&i.setActive("whileDrag",!0)},onMove:(e,t)=>{const{dragPropagation:n,dragDirectionLock:a,onDirectionLock:r,onDrag:s}=this.getProps();if(!n&&!this.openDragLock)return;const{offset:i}=t;if(a&&null===this.currentDirection)return this.currentDirection=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=null;Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x");return n}(i),void(null!==this.currentDirection&&r&&r(this.currentDirection));this.updateAxis("x",t.point,i),this.updateAxis("y",t.point,i),this.visualElement.render(),s&&s(e,t)},onSessionEnd:(e,t)=>this.stop(e,t),resumeAnimation:()=>Ba(e=>{var t;return"paused"===this.getAnimationState(e)&&(null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.play())})},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:a,contextWindow:Ja(this.visualElement)})}stop(e,t){const n=this.isDragging;if(this.cancel(),!n)return;const{velocity:a}=t;this.startAnimation(a);const{onDragEnd:r}=this.getProps();r&&U.postRender(()=>r(e,t))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,n){const{drag:a}=this.getProps();if(!n||!hr(e,a,this.currentDirection))return;const r=this.getAxisMotionValue(e);let s=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(s=function(e,t,n){let{min:a,max:r}=t;return void 0!==a&&e<a?e=n?tt(a,e,n.min):Math.max(e,a):void 0!==r&&e>r&&(e=n?tt(r,e,n.max):Math.min(e,r)),e}(s,this.constraints[e],this.elastic[e])),r.set(s)}resolveConstraints(){var e;const{dragConstraints:t,dragElastic:n}=this.getProps(),a=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):null===(e=this.visualElement.projection)||void 0===e?void 0:e.layout,r=this.constraints;t&&$a(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):this.constraints=!(!t||!a)&&function(e,t){let{top:n,left:a,bottom:r,right:s}=t;return{x:ir(e.x,a,s),y:ir(e.y,n,r)}}(a.layoutBox,t),this.elastic=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lr;return!1===e?e=0:!0===e&&(e=lr),{x:cr(e,"left","right"),y:cr(e,"top","bottom")}}(n),r!==this.constraints&&a&&this.constraints&&!this.hasMutatedConstraints&&Ba(e=>{!1!==this.constraints&&this.getAxisMotionValue(e)&&(this.constraints[e]=function(e,t){const n={};return void 0!==t.min&&(n.min=t.min-e.min),void 0!==t.max&&(n.max=t.max-e.min),n}(a.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!$a(e))return!1;const n=e.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const r=function(e,t,n){const a=Xa(e,n),{scroll:r}=t;return r&&(Ya(a.x,r.offset.x),Ya(a.y,r.offset.y)),a}(n,a.root,this.visualElement.getTransformPagePoint());let s=function(e,t){return{x:or(e.x,t.x),y:or(e.y,t.y)}}(a.layout.layoutBox,r);if(t){const e=t(function(e){let{x:t,y:n}=e;return{top:n.min,right:t.max,bottom:n.max,left:t.min}}(s));this.hasMutatedConstraints=!!e,e&&(s=Na(e))}return s}startAnimation(e){const{drag:t,dragMomentum:n,dragElastic:a,dragTransition:r,dragSnapToOrigin:s,onDragTransitionEnd:i}=this.getProps(),o=this.constraints||{},l=Ba(i=>{if(!hr(i,t,this.currentDirection))return;let l=o&&o[i]||{};s&&(l={min:0,max:0});const c=a?200:1e6,u=a?40:1e7,m=d(d({type:"inertia",velocity:n?e[i]:0,bounceStiffness:c,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10},r),l);return this.startAxisValueAnimation(i,m)});return Promise.all(l).then(i)}startAxisValueAnimation(e,t){const n=this.getAxisMotionValue(e);return ce(this.visualElement,e),n.start($n(e,n,0,t,this.visualElement,!1))}stopAnimation(){Ba(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Ba(e=>{var t;return null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.pause()})}getAnimationState(e){var t;return null===(t=this.getAxisMotionValue(e).animation)||void 0===t?void 0:t.state}getAxisMotionValue(e){const t="_drag".concat(e.toUpperCase()),n=this.visualElement.getProps(),a=n[t];return a||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){Ba(t=>{const{drag:n}=this.getProps();if(!hr(t,n,this.currentDirection))return;const{projection:a}=this.visualElement,r=this.getAxisMotionValue(t);if(a&&a.layout){const{min:n,max:s}=a.layout.layoutBox[t];r.set(e[t]-tt(n,s,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!$a(t)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Ba(e=>{const t=this.getAxisMotionValue(e);if(t&&!1!==this.constraints){const n=t.get();a[e]=function(e,t){let n=.5;const a=Fa(e),r=Fa(t);return r>a?n=Wt(t.min,t.max-a,e.min):a>r&&(n=Wt(e.min,e.max-r,t.min)),ge(0,1,n)}({min:n,max:n},this.constraints[e])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),Ba(t=>
2{if(!hr(t,e,null))return;const n=this.getAxisMotionValue(t),{min:r,max:s}=this.constraints[t];n.set(tt(r,s,a[t]))})}addListeners(){if(!this.visualElement.current)return;ur.set(this.visualElement,this);const e=Ca(this.visualElement.current,"pointerdown",e=>{const{drag:t,dragListener:n=!0}=this.getProps();t&&n&&this.start(e)}),t=()=>{const{dragConstraints:e}=this.getProps();$a(e)&&e.current&&(this.constraints=this.resolveRefConstraints())},{projection:n}=this.visualElement,a=n.addEventListener("measure",t);n&&!n.layout&&(n.root&&n.root.updateScroll(),n.updateLayout()),U.read(t);const r=ka(window,"resize",()=>this.scalePositionWithinConstraints()),s=n.addEventListener("didUpdate",e=>{let{delta:t,hasLayoutChanged:n}=e;this.isDragging&&n&&(Ba(e=>{const n=this.getAxisMotionValue(e);n&&(this.originPoint[e]+=t[e].translate,n.set(n.get()+t[e].translate))}),this.visualElement.render())});return()=>{r(),e(),a(),s&&s()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:a=!1,dragConstraints:r=!1,dragElastic:s=lr,dragMomentum:i=!0}=e;return d(d({},e),{},{drag:t,dragDirectionLock:n,dragPropagation:a,dragConstraints:r,dragElastic:s,dragMomentum:i})}}function hr(e,t,n){return(!0===t||t===e)&&(null===n||n===e)}const pr=e=>(t,n)=>{e&&U.postRender(()=>e(t,n))};const{schedule:gr,cancel:xr}=O(queueMicrotask,!1),fr=(0,a.createContext)({}),br={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function yr(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const vr={correct:(e,t)=>{if(!t.target)return e;if("string"===typeof e){if(!Re.test(e))return e;e=parseFloat(e)}const n=yr(e,t.target.x),a=yr(e,t.target.y);return"".concat(n,"% ").concat(a,"%")}},wr={correct:(e,t)=>{let{treeScale:n,projectionDelta:a}=t;const r=e,s=Qe.parse(e);if(s.length>5)return r;const i=Qe.createTransformer(e),o="number"!==typeof s[0]?1:0,l=a.x.scale*n.x,c=a.y.scale*n.y;s[0+o]/=l,s[1+o]/=c;const d=tt(l,c,.5);return"number"===typeof s[2+o]&&(s[2+o]/=d),"number"===typeof s[3+o]&&(s[3+o]/=d),i(s)}},kr={};class jr extends a.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:a}=this.props,{projection:r}=e;!function(e){for(const t in e)kr[t]=e[t],ve(t)&&(kr[t].isCSSVariable=!0)}(Cr),r&&(t.group&&t.group.add(r),n&&n.register&&a&&n.register(r),r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions(d(d({},r.options),{},{onExitComplete:()=>this.safeToRemove()}))),br.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:n,drag:a,isPresent:r}=this.props,{projection:s}=n;return s?(s.isPresent=r,a||e.layoutDependency!==t||void 0===t||e.isPresent!==r?s.willUpdate():this.safeToRemove(),e.isPresent!==r&&(r?s.promote():s.relegate()||U.postRender(()=>{const e=s.getStack();e&&e.members.length||this.safeToRemove()})),null):null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),gr.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:a}=e;a&&(a.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(a),n&&n.deregister&&n.deregister(a))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Dr(e){const[t,n]=C(),r=(0,a.useContext)(h);return(0,u.jsx)(jr,d(d({},e),{},{layoutGroup:r,switchLayoutGroup:(0,a.useContext)(fr),isPresent:t,safeToRemove:n}))}const Cr={borderRadius:d(d({},vr),{},{applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]}),borderTopLeftRadius:vr,borderTopRightRadius:vr,borderBottomLeftRadius:vr,borderBottomRightRadius:vr,boxShadow:wr};function Nr(e){return b(e)&&"ownerSVGElement"in e}const Fr=(e,t)=>e.depth-t.depth;class Sr{constructor(){this.children=[],this.isDirty=!1}add(e){K(this.children,e),this.isDirty=!0}remove(e){X(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Fr),this.isDirty=!1,this.children.forEach(e)}}function Er(e,t){const n=ee.now(),a=r=>{let{timestamp:s}=r;const i=s-n;i>=t&&(V(a),e(i-t))};return U.setup(a,!0),()=>V(a)}function Ar(e){return le(e)?e.get():e}const Tr=["TopLeft","TopRight","BottomLeft","BottomRight"],Mr=Tr.length,_r=e=>"string"===typeof e?parseFloat(e):e,Br=e=>"number"===typeof e||Re.test(e);function Ir(e,t){return void 0!==e[t]?e[t]:e.borderRadius}const Pr=Rr(0,.5,Ot),Lr=Rr(.5,.95,P);function Rr(e,t,n){return a=>a<e?0:a>t?1:n(Wt(e,t,a))}function zr(e,t){e.min=t.min,e.max=t.max}function Or(e,t){zr(e.x,t.x),zr(e.y,t.y)}function Ur(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function Vr(e,t,n,a,r){return e=Oa(e-=t,1/n,a),void 0!==r&&(e=Oa(e,1/r,a)),e}function Hr(e,t,n,a,r){let[s,i,o]=n;!function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5,r=arguments.length>4?arguments[4]:void 0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:e,i=arguments.length>6&&void 0!==arguments[6]?arguments[6]:e;Le.test(t)&&(t=parseFloat(t),t=tt(i.min,i.max,t/100)-i.min);if("number"!==typeof t)return;let o=tt(s.min,s.max,a);e===s&&(o-=t),e.min=Vr(e.min,t,n,o,r),e.max=Vr(e.max,t,n,o,r)}(e,t[s],t[i],t[o],t.scale,a,r)}const qr=["x","scaleX","originX"],Wr=["y","scaleY","originY"];function Yr(e,t,n,a){Hr(e.x,t,qr,n?n.x:void 0,a?a.x:void 0),Hr(e.y,t,Wr,n?n.y:void 0,a?a.y:void 0)}function Gr(e){return 0===e.translate&&1===e.scale}function Kr(e){return Gr(e.x)&&Gr(e.y)}function Xr(e,t){return e.min===t.min&&e.max===t.max}function Jr(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function $r(e,t){return Jr(e.x,t.x)&&Jr(e.y,t.y)}function Qr(e){return Fa(e.x)/Fa(e.y)}function Zr(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class es{constructor(){this.members=[]}add(e){K(this.members,e),e.scheduleRender()}remove(e){if(X(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){const t=this.members.findIndex(t=>e===t);if(0===t)return!1;let n;for(let a=t;a>=0;a--){const e=this.members[a];if(!1!==e.isPresent){n=e;break}}return!!n&&(this.promote(n),!0)}promote(e,t){const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,t&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:a}=e.options;!1===a&&n.hide()}}
2exitAnimationComplete(){this.members.forEach(e=>{const{options:t,resumingFrom:n}=e;t.onExitComplete&&t.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}const ts={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},ns=["","X","Y","Z"],as={visibility:"hidden"};let rs=0;function ss(e,t,n,a){const{latestValues:r}=t;r[e]&&(n[e]=r[e],t.setStaticValue(e,0),a&&(a[e]=0))}function is(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=me(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:t,layoutId:a}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",U,!(t||a))}const{parent:a}=e;a&&!a.hasCheckedOptimisedAppear&&is(a)}function os(e){let{attachResizeListener:t,defaultParent:n,measureScroll:a,checkIsScrollRoot:r,resetTransform:s}=e;return class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null===n||void 0===n?void 0:n();this.id=rs++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,z.value&&(ts.nodes=ts.calculatedTargetDeltas=ts.calculatedProjections=0),this.nodes.forEach(ds),this.nodes.forEach(fs),this.nodes.forEach(bs),this.nodes.forEach(us),z.addProjectionMetrics&&z.addProjectionMetrics(ts)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=t?t.root||t:this,this.path=t?[...t.path,t]:[],this.parent=t,this.depth=t?t.depth+1:0;for(let n=0;n<this.path.length;n++)this.path[n].shouldResetTransform=!0;this.root===this&&(this.nodes=new Sr)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new J),this.eventHandlers.get(e).add(t)}notifyListeners(e){const t=this.eventHandlers.get(e);for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];t&&t.notify(...a)}hasListeners(e){return this.eventHandlers.has(e)}mount(e){if(this.instance)return;var n;this.isSVG=Nr(e)&&!(Nr(n=e)&&"svg"===n.tagName),this.instance=e;const{layoutId:a,layout:r,visualElement:s}=this.options;if(s&&!s.current&&s.mount(e),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||a)&&(this.isLayoutDirty=!0),t){let n;const a=()=>this.root.updateBlockedByResize=!1;t(e,()=>{this.root.updateBlockedByResize=!0,n&&n(),n=Er(a,250),br.hasAnimatedSinceResize&&(br.hasAnimatedSinceResize=!1,this.nodes.forEach(xs))})}a&&this.root.registerSharedNode(a,this),!1!==this.options.animate&&s&&(a||r)&&this.addEventListener("didUpdate",e=>{let{delta:t,hasLayoutChanged:n,hasRelativeLayoutChanged:a,layout:r}=e;if(this.isTreeAnimationBlocked())return this.target=void 0,void(this.relativeTarget=void 0);const i=this.options.transition||s.getDefaultTransition()||Ds,{onLayoutAnimationStart:o,onLayoutAnimationComplete:l}=s.getProps(),c=!this.targetLayout||!$r(this.targetLayout,r),u=!n&&a;if(this.options.layoutRoot||this.resumeFrom||u||n&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const e=d(d({},I(i,"layout")),{},{onPlay:o,onComplete:l});(s.shouldReduceMotion||this.options.layoutRoot)&&(e.delay=0,e.type=!1),this.startAnimation(e),this.setAnimationOrigin(t,u)}else n||xs(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),V(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEac
2h(ys),this.animationId++)}getTransformTemplate(){const{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked())return void(this.options.onExitComplete&&this.options.onExitComplete());if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&is(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let r=0;r<this.path.length;r++){const e=this.path[r];e.shouldResetTransform=!0,e.updateScroll("snapshot"),e.options.layoutRoot&&e.willUpdate(!1)}const{layoutId:t,layout:n}=this.options;if(void 0===t&&!n)return;const a=this.getTransformTemplate();this.prevTransformTemplateValue=a?a(this.latestValues,""):void 0,this.updateSnapshot(),e&&this.notifyListeners("willUpdate")}update(){this.updateScheduled=!1;if(this.isUpdateBlocked())return this.unblockUpdate(),this.clearAllSnapshots(),void this.nodes.forEach(hs);this.isUpdating||this.nodes.forEach(ps),this.isUpdating=!1,this.nodes.forEach(gs),this.nodes.forEach(ls),this.nodes.forEach(cs),this.clearAllSnapshots();const e=ee.now();H.delta=ge(0,1e3/60,e-H.timestamp),H.timestamp=e,H.isProcessing=!0,q.update.process(H),q.preRender.process(H),q.render.process(H),H.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,gr.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ms),this.sharedNodes.forEach(vs)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,U.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){U.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),!this.snapshot||Fa(this.snapshot.measuredBox.x)||Fa(this.snapshot.measuredBox.y)||(this.snapshot=void 0))}updateLayout(){if(!this.instance)return;if(this.updateScroll(),(!this.options.alwaysMeasureLayout||!this.isLead())&&!this.isLayoutDirty)return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let n=0;n<this.path.length;n++){this.path[n].updateScroll()}const e=this.layout;this.layout=this.measure(!1),this.layoutCorrected={x:{min:0,max:0},y:{min:0,max:0}},this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:t}=this.options;t&&t.notify("LayoutMeasure",this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"measure",t=Boolean(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){const t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:a(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!s)return;const e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!Kr(this.projectionDelta),n=this.getTransformTemplate(),a=n?n(this.latestValues,""):void 0,r=a!==this.prevTransformTemplateValue;e&&this.instance&&(t||La(this.latestValues)||r)&&(s(this.instance,a),this.shouldResetTransform=!1,this.scheduleRender())}measure(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const t=this.measurePageBox();let n=this.removeElementScroll(t);var a;return e&&(n=this.removeTransform(n)),Fs((a=n).x),Fs(a.y),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){var e;const{visualElement:t}=this.options;if(!t)return{x:{min:0,max:0},y:{min:0,max:0}};const n=t.measureViewportBox();if(!((null===(e=this.scroll)||void 0===e?void 0:e.wasRoot)||this.path.some(Es))){const{scroll:e}=this.root;e&&(Ya(n.x,e.offset.x),Ya(n.y,e.offset.y))}return n}removeElementScroll(e){var t;const n={x:{min:0,max:0},y:{min:0,max:0}};if(Or(n,e),null!==(t=this.scroll)&&void 0!==t&&t.wasRoot)return n;for(let a=0;a<this.path.length;a++){const t=this.path[a],{scroll:r,options:s}=t;t!==this.root&&r&&s.layoutScroll&&(r.wasRoot&&Or(n,e),Ya(n.x,r.offset.x),Ya(n.y,r.offset.y))}return n}applyTransform(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n={x:{min:0,max:0},y:{min:0,max:0}};Or(n,e);for(let a=0;a<this.path.length;a++){const e=this.path[a];!t&&e.options.layoutScroll&&e.scroll&&e!==e.root&&Ka(n,{x:-e.scroll.offset.x,y:-e.scroll.offset.y}),La(e.latestValues)&&Ka(n,e.latestValues)}return La(this.latestValues)&&Ka(n,this.latestValues),n}removeTransform(e){const t={x:{min:0,max:0},y:{min:0,max:0}};Or(t,e);for(let n=0;n<this.path.length;n++){const e=this.path[n];if(!e.instance)continue;if(!La(e.latestValues))continue;Pa(e.latestValues)&&e.updateSnapshot();const a=_a();Or(a,e.measurePageBox()),Yr(t,e.latestValues,e.snapshot?e.snapshot.layoutBox:void 0,a)}return La(this.latestValues)&&Yr(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options=d(d(d({},this.options),e),{},{crossfade:void 0===e.crossfade||e.crossfade})}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==H.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const n=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=n.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=n.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=n.isS
2haredProjectionDirty);const a=Boolean(this.resumingFrom)||this!==n;if(!(t||a&&this.isSharedProjectionDirty||this.isProjectionDirty||null!==(e=this.parent)&&void 0!==e&&e.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:r,layoutId:s}=this.options;if(this.layout&&(r||s)){if(this.resolvedRelativeTargetAt=H.timestamp,!this.targetDelta&&!this.relativeTarget){const e=this.getClosestProjectingParent();e&&e.layout&&1!==this.animationProgress?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Ma(this.relativeTargetOrigin,this.layout.layoutBox,e.layout.layoutBox),Or(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(this.relativeTarget||this.targetDelta){var i,o,l;if(this.target||(this.target={x:{min:0,max:0},y:{min:0,max:0}},this.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}}),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),i=this.target,o=this.relativeTarget,l=this.relativeParent.target,Aa(i.x,o.x,l.x),Aa(i.y,o.y,l.y)):this.targetDelta?(Boolean(this.resumingFrom)?this.target=this.applyTransform(this.layout.layoutBox):Or(this.target,this.layout.layoutBox),Ha(this.target,this.targetDelta)):Or(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const e=this.getClosestProjectingParent();e&&Boolean(e.resumingFrom)===Boolean(this.resumingFrom)&&!e.options.layoutScroll&&e.target&&1!==this.animationProgress?(this.relativeParent=e,this.forceRelativeParentToResolveTarget(),this.relativeTarget={x:{min:0,max:0},y:{min:0,max:0}},this.relativeTargetOrigin={x:{min:0,max:0},y:{min:0,max:0}},Ma(this.relativeTargetOrigin,this.target,e.target),Or(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}z.value&&ts.calculatedTargetDeltas++}}}getClosestProjectingParent(){if(this.parent&&!Pa(this.parent.latestValues)&&!Ra(this.parent.latestValues))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return Boolean((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var e;const t=this.getLead(),n=Boolean(this.resumingFrom)||this!==t;let a=!0;if((this.isProjectionDirty||null!==(e=this.parent)&&void 0!==e&&e.isProjectionDirty)&&(a=!1),n&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(a=!1),this.resolvedRelativeTargetAt===H.timestamp&&(a=!1),a)return;const{layout:r,layoutId:s}=this.options;if(this.isTreeAnimating=Boolean(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!r&&!s)return;Or(this.layoutCorrected,this.layout.layoutBox);const i=this.treeScale.x,o=this.treeScale.y;!function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const r=n.length;if(!r)return;let s,i;t.x=t.y=1;for(let o=0;o<r;o++){s=n[o],i=s.projectionDelta;const{visualElement:r}=s.options;r&&r.props.style&&"contents"===r.props.style.display||(a&&s.options.layoutScroll&&s.scroll&&s!==s.root&&Ka(e,{x:-s.scroll.offset.x,y:-s.scroll.offset.y}),i&&(t.x*=i.x.scale,t.y*=i.y.scale,Ha(e,i)),a&&La(s.latestValues)&&Ka(e,s.latestValues))}t.x<Wa&&t.x>qa&&(t.x=1),t.y<Wa&&t.y>qa&&(t.y=1)}(this.layoutCorrected,this.treeScale,this.path,n),!t.layout||t.target||1===this.treeScale.x&&1===this.treeScale.y||(t.target=t.layout.layoutBox,t.targetWithTransforms={x:{min:0,max:0},y:{min:0,max:0}});const{target:l}=t;l?(this.projectionDelta&&this.prevProjectionDelta?(Ur(this.prevProjectionDelta.x,this.projectionDelta.x),Ur(this.prevProjectionDelta.y,this.projectionDelta.y)):this.createProjectionDeltas(),Ea(this.projectionDelta,this.layoutCorrected,l,this.latestValues),this.treeScale.x===i&&this.treeScale.y===o&&Zr(this.projectionDelta.x,this.prevProjectionDelta.x)&&Zr(this.projectionDelta.y,this.prevProjectionDelta.y)||(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",l)),z.value&&ts.calculatedProjections++):this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender())}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(){var e;let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(null===(e=this.options.visualElement)||void 0===e||e.scheduleRender(),t){const e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDelta={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}},this.projectionDeltaWithTransform={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}}}setAnimationOrigin(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=this.snapshot,a=n?n.latestValues:{},r=d({},this.latestValues),s={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};this.relativeParent&&this.relativeParent.options.layoutRoot||(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;const i={x:{min:0,max:0},y:{min:0,max:0}},o=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),c=!l||l.members.length<=1,u=Boolean(o&&!c&&!0===this.options.crossfade&&!this.path.some(js));let m;this.animationProgress=0,this.mixTargetDelta=t=>{const n=t/1e3;var l,d;ws(s.x,e.x,n),ws(s.y,e.y,n),this.setTargetDelta(s),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ma(i,this.layout.layoutBox,this.relativeParent.layout.layoutBox),function(e,t,n,a){ks(e.x,t.x,n.x,a),ks(e.y,t.y,n.y,a)}(this.relativeTarget,this.relativeTargetOrigin,i,n),m&&(l=this.relativeTarget,d=m,Xr(l.x,d.x)&&Xr(l.y,d.y))&&(this.isProjectionDirty=!1),m||(m={x:{min:0,max:0},y:{min:0,max:0}}),Or(m,this.relativeTarget)),o&&(this.animationValues=r,function(e,t,n,a,r,s){var i,o;if(r)e.opacity=tt(0,null!==(i=n.opacity)&&void 0!==i?i:1,Pr(a)),e.opacityExit=tt(null!==(o=t.opacity)&&void 0!==o?o:1,0,Lr(a));else if(s){var l,c;e.opacity=tt(null!==(l=t.opacity)&&void 0!==l?l:1,null!==(c=n.opacity)&&void 0!==c?c:1,a)}for(let d=0;d<Mr;d++){const r="border".concat(Tr[d],"Radius");let s=Ir(t,r),i=Ir(n,r);void 0===s&&void 0===i||(s||(s=0),i||(i=0),0===s||0===i||Br(s)===Br(i)?(e[r]=Math.max(tt(_r(s),_r(i),a),0),(Le.test(i)||Le.test(s))&&(e[r]+="%")):e[r]=i)}(t.rotate||n.rotate)&&(e.rotate=tt(t.rotate||0,n.rotate||0,a))}(r,a,this.latestValues,n,u,c)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){var t,n;this.notifyListeners("animationStart"),null===(t=this.currentAnimation)||void 0===t||t.stop(),null===(n=this.resumingFrom)||void 0===n||null===(n=n.currentAnimation)||void 0===n||n.stop(),this.pendingAnimation&&(V(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=U.update(()=>{br.hasAnimatedSinceResize=!0,be.layout++,this.motionValue||(this.motionValue=ae(0)),this.currentAnimation=function(e,t,n){const a=le(e)?e:ae(e);return a.start($n("",a,t,n)),a.animation}(this.motionValue,[0,1e3],d(d({},e),{},{velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{be.layout--},onComplete:()=>{be.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}})),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(1e3),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const e=this.getLead();let{targetWithTransforms:t,target:n,layout:a,latestValues:r}=e;if(t&&n&&a){if(this!==e&&this.layout&&a&&Ss(this.options.animationType,this.layout.layoutBox,a.layoutBox)){n=this.target||{x:{min:0,max:0},y:{min:0,max:0}};const t=Fa(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;const a=Fa(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+a}Or(t,n),Ka(t,r),Ea(this.projectionDeltaWithTransform,this.layoutCorrected,t,r)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new es);this.sharedNodes.get(e).add(t);
2const n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){const e=this.getStack();return!e||e.lead===this}getLead(){var e;const{layoutId:t}=this.options;return t&&(null===(e=this.getStack())||void 0===e?void 0:e.lead)||this}getPrevLead(){var e;const{layoutId:t}=this.options;return t?null===(e=this.getStack())||void 0===e?void 0:e.prevLead:void 0}getStack(){const{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote(){let{needsReset:e,transition:t,preserveFollowOpacity:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const a=this.getStack();a&&a.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){const e=this.getStack();return!!e&&e.relegate(this)}resetSkewAndRotation(){const{visualElement:e}=this.options;if(!e)return;let t=!1;const{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;const a={};n.z&&ss("z",e,a,this.animationValues);for(let r=0;r<ns.length;r++)ss("rotate".concat(ns[r]),e,a,this.animationValues),ss("skew".concat(ns[r]),e,a,this.animationValues);e.render();for(const r in a)e.setStaticValue(r,a[r]),this.animationValues&&(this.animationValues[r]=a[r]);e.scheduleRender()}getProjectionStyles(e){if(!this.instance||this.isSVG)return;if(!this.isVisible)return as;const t={visibility:""},n=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,t.opacity="",t.pointerEvents=Ar(null===e||void 0===e?void 0:e.pointerEvents)||"",t.transform=n?n(this.latestValues,""):"none",t;const a=this.getLead();if(!this.projectionDelta||!this.layout||!a.target){const t={};return this.options.layoutId&&(t.opacity=void 0!==this.latestValues.opacity?this.latestValues.opacity:1,t.pointerEvents=Ar(null===e||void 0===e?void 0:e.pointerEvents)||""),this.hasProjected&&!La(this.latestValues)&&(t.transform=n?n({},""):"none",this.hasProjected=!1),t}const r=a.animationValues||a.latestValues;this.applyTransformsToTarget(),t.transform=function(e,t,n){let a="";const r=e.x.translate/t.x,s=e.y.translate/t.y,i=(null===n||void 0===n?void 0:n.z)||0;if((r||s||i)&&(a="translate3d(".concat(r,"px, ").concat(s,"px, ").concat(i,"px) ")),1===t.x&&1===t.y||(a+="scale(".concat(1/t.x,", ").concat(1/t.y,") ")),n){const{transformPerspective:e,rotate:t,rotateX:r,rotateY:s,skewX:i,skewY:o}=n;e&&(a="perspective(".concat(e,"px) ").concat(a)),t&&(a+="rotate(".concat(t,"deg) ")),r&&(a+="rotateX(".concat(r,"deg) ")),s&&(a+="rotateY(".concat(s,"deg) ")),i&&(a+="skewX(".concat(i,"deg) ")),o&&(a+="skewY(".concat(o,"deg) "))}const o=e.x.scale*t.x,l=e.y.scale*t.y;return 1===o&&1===l||(a+="scale(".concat(o,", ").concat(l,")")),a||"none"}(this.projectionDeltaWithTransform,this.treeScale,r),n&&(t.transform=n(r,t.transform));const{x:s,y:i}=this.projectionDelta;var o,l;(t.transformOrigin="".concat(100*s.origin,"% ").concat(100*i.origin,"% 0"),a.animationValues)?t.opacity=a===this?null!==(o=null!==(l=r.opacity)&&void 0!==l?l:this.latestValues.opacity)&&void 0!==o?o:1:this.preserveOpacity?this.latestValues.opacity:r.opacityExit:t.opacity=a===this?void 0!==r.opacity?r.opacity:"":void 0!==r.opacityExit?r.opacityExit:0;for(const c in kr){if(void 0===r[c])continue;const{correct:e,applyTo:n,isCSSVariable:s}=kr[c],i="none"===t.transform?r[c]:e(r[c],a);if(n){const e=n.length;for(let a=0;a<e;a++)t[n[a]]=i}else s?this.options.visualElement.renderState.vars[c]=i:t[c]=i}return this.options.layoutId&&(t.pointerEvents=a===this?Ar(null===e||void 0===e?void 0:e.pointerEvents)||"":"none"),t}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>{var t;return null===(t=e.currentAnimation)||void 0===t?void 0:t.stop()}),this.root.nodes.forEach(hs),this.root.sharedNodes.clear()}}}function ls(e){e.updateLayout()}function cs(e){var t;const n=(null===(t=e.resumeFrom)||void 0===t?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:t,measuredBox:a}=e.layout,{animationType:r}=e.options,s=n.source!==e.layout.source;"size"===r?Ba(e=>{const a=s?n.measuredBox[e]:n.layoutBox[e],r=Fa(a);a.min=t[e].min,a.max=a.min+r}):Ss(r,n.layoutBox,t)&&Ba(a=>{const r=s?n.measuredBox[a]:n.layoutBox[a],i=Fa(t[a]);r.max=r.min+i,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[a].max=e.relativeTarget[a].min+i)});const i={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};Ea(i,t,n.layoutBox);const o={x:{translate:0,scale:1,origin:0,originPoint:0},y:{translate:0,scale:1,origin:0,originPoint:0}};s?Ea(o,e.applyTransform(a,!0),n.measuredBox):Ea(o,t,n.layoutBox);const l=!Kr(i);let c=!1;if(!e.resumeFrom){const a=e.getClosestProjectingParent();if(a&&!a.resumeFrom){const{snapshot:r,layout:s}=a;if(r&&s){const i={x:{min:0,max:0},y:{min:0,max:0}};Ma(i,n.layoutBox,r.layoutBox);const o={x:{min:0,max:0},y:{min:0,max:0}};Ma(o,t,s.layoutBox),$r(i,o)||(c=!0),a.options.layoutRoot&&(e.relativeTarget=o,e.relativeTargetOrigin=i,e.relativeParent=a)}}}e.notifyListeners("didUpdate",{layout:t,snapshot:n,delta:o,layoutDelta:i,hasLayoutChanged:l,hasRelativeLayoutChanged:c})}else if(e.isLead()){const{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function ds(e){z.value&&ts.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=Boolean(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function us(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function ms(e){e.clearSnapshot()}function hs(e){e.clearMeasurements()}function ps(e){e.isLayoutDirty=!1}function gs(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function xs(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function fs(e){e.resolveTargetDelta()}function bs(e){e.calcProjection()}
2function ys(e){e.resetSkewAndRotation()}function vs(e){e.removeLeadSnapshot()}function ws(e,t,n){e.translate=tt(t.translate,0,n),e.scale=tt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ks(e,t,n,a){e.min=tt(t.min,n.min,a),e.max=tt(t.max,n.max,a)}function js(e){return e.animationValues&&void 0!==e.animationValues.opacityExit}const Ds={duration:.45,ease:[.4,0,.1,1]},Cs=e=>"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Ns=Cs("applewebkit/")&&!Cs("chrome/")?Math.round:P;function Fs(e){e.min=Ns(e.min),e.max=Ns(e.max)}function Ss(e,t,n){return"position"===e||"preserve-aspect"===e&&(a=Qr(t),r=Qr(n),s=.2,!(Math.abs(a-r)<=s));var a,r,s}function Es(e){var t;return e!==e.root&&(null===(t=e.scroll)||void 0===t?void 0:t.wasRoot)}const As=os({attachResizeListener:(e,t)=>ka(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Ts={current:void 0},Ms=os({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Ts.current){const e=new As({});e.mount(window),e.setOptions({layoutScroll:!0}),Ts.current=e}return Ts.current},resetTransform:(e,t)=>{e.style.transform=void 0!==t?t:"none"},checkIsScrollRoot:e=>Boolean("fixed"===window.getComputedStyle(e).position)}),_s={pan:{Feature:class extends fa{constructor(){super(...arguments),this.removePointerDownListener=P}onPointerDown(e){this.session=new Za(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Ja(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:pr(e),onStart:pr(t),onMove:n,onEnd:(e,t)=>{delete this.session,a&&U.postRender(()=>a(e,t))}}}mount(){this.removePointerDownListener=Ca(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}},drag:{Feature:class extends fa{constructor(e){super(e),this.removeGroupControls=P,this.removeListeners=P,this.controls=new mr(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||P}unmount(){this.removeGroupControls(),this.removeListeners()}},ProjectionNode:Ms,MeasureLayout:Dr}};function Bs(e,t){const n=function(e,t,n){if(e instanceof EventTarget)return[e];if("string"===typeof e){var a;let r=document;t&&(r=t.current);const s=null!==(a=null===n||void 0===n?void 0:n[e])&&void 0!==a?a:r.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e)}(e),a=new AbortController;return[n,d(d({passive:!0},t),{},{signal:a.signal}),()=>a.abort()]}function Is(e){return!("touch"===e.pointerType||wa())}function Ps(e,t,n){const{props:a}=e;e.animationState&&a.whileHover&&e.animationState.setActive("whileHover","Start"===n);const r=a["onHover"+n];r&&U.postRender(()=>r(t,Da(t)))}const Ls=(e,t)=>!!t&&(e===t||Ls(e,t.parentElement)),Rs=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);const zs=new WeakSet;function Os(e){return t=>{"Enter"===t.key&&e(t)}}function Us(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}function Vs(e){return ja(e)&&!wa()}function Hs(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const[a,r,s]=Bs(e,n),i=e=>{const a=e.currentTarget;if(!Vs(e))return;zs.add(a);const s=t(a,e),i=(e,t)=>{window.removeEventListener("pointerup",o),window.removeEventListener("pointercancel",l),zs.has(a)&&zs.delete(a),Vs(e)&&"function"===typeof s&&s(e,{success:t})},o=e=>{i(e,a===window||a===document||n.useGlobalTarget||Ls(a,e.target))},l=e=>{i(e,!1)};window.addEventListener("pointerup",o,r),window.addEventListener("pointercancel",l,r)};return a.forEach(e=>{var t;(n.useGlobalTarget?window:e).addEventListener("pointerdown",i,r),y(e)&&(e.addEventListener("focus",e=>((e,t)=>{const n=e.currentTarget;if(!n)return;const a=Os(()=>
2{if(zs.has(n))return;Us(n,"down");const e=Os(()=>{Us(n,"up")});n.addEventListener("keyup",e,t),n.addEventListener("blur",()=>Us(n,"cancel"),t)});n.addEventListener("keydown",a,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",a),t)})(e,r)),t=e,Rs.has(t.tagName)||-1!==t.tabIndex||e.hasAttribute("tabindex")||(e.tabIndex=0))}),s}function qs(e,t,n){const{props:a}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&a.whileTap&&e.animationState.setActive("whileTap","Start"===n);const r=a["onTap"+("End"===n?"":n)];r&&U.postRender(()=>r(t,Da(t)))}const Ws=["root"],Ys=new WeakMap,Gs=new WeakMap,Ks=e=>{const t=Ys.get(e.target);t&&t(e)},Xs=e=>{e.forEach(Ks)};function Js(e,t,n){const a=function(e){let{root:t}=e,n=T(e,Ws);const a=t||document;Gs.has(a)||Gs.set(a,{});const r=Gs.get(a),s=JSON.stringify(n);return r[s]||(r[s]=new IntersectionObserver(Xs,d({root:t},n))),r[s]}(t);return Ys.set(e,n),a.observe(e),()=>{Ys.delete(e),a.unobserve(e)}}const $s={some:0,all:1};const Qs={inView:{Feature:class extends fa{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:a="some",once:r}=e,s={root:t?t.current:void 0,rootMargin:n,threshold:"number"===typeof a?a:$s[a]};return Js(this.node.current,s,e=>{const{isIntersecting:t}=e;if(this.isInView===t)return;if(this.isInView=t,r&&!t&&this.hasEnteredView)return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",t);const{onViewportEnter:n,onViewportLeave:a}=this.node.getProps(),s=t?n:a;s&&s(e)})}mount(){this.startObserver()}update(){if("undefined"===typeof IntersectionObserver)return;const{props:e,prevProps:t}=this.node,n=["amount","margin","root"].some(function(e){let{viewport:t={}}=e,{viewport:n={}}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e=>t[e]!==n[e]}(e,t));n&&this.startObserver()}unmount(){}}},tap:{Feature:class extends fa{mount(){const{current:e}=this.node;e&&(this.unmount=Hs(e,(e,t)=>(qs(this.node,t,"Start"),(e,t)=>{let{success:n}=t;return qs(this.node,e,n?"End":"Cancel")}),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}},focus:{Feature:class extends fa{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch(t){e=!0}e&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=pe(ka(this.node.current,"focus",()=>this.onFocus()),ka(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}},hover:{Feature:class extends fa{mount(){const{current:e}=this.node;e&&(this.unmount=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const[a,r,s]=Bs(e,n),i=e=>{if(!Is(e))return;const{target:n}=e,a=t(n,e);if("function"!==typeof a||!n)return;const s=e=>{Is(e)&&(a(e),n.removeEventListener("pointerleave",s))};n.addEventListener("pointerleave",s,r)};return a.forEach(e=>{e.addEventListener("pointerenter",i,r)}),s}(e,(e,t)=>(Ps(this.node,t,"Start"),e=>Ps(this.node,e,"End"))))}unmount(){}}}},Zs={layout:{ProjectionNode:Ms,MeasureLayout:Dr}},ei=(0,a.createContext)({strict:!1}),ti=(0,a.createContext)({});function ni(e){return A(e.animate)||ia.some(t=>ra(e[t]))}function ai(e){return Boolean(ni(e)||e.variants)}function ri(e){const{initial:t,animate:n}=function(e,t){if(ni(e)){const{initial:t,animate:n}=e;return{initial:!1===t||ra(t)?t:void 0,animate:ra(n)?n:void 0}}return!1!==e.inherit?t:{}}(e,(0,a.useContext)(ti));return(0,a.useMemo)(()=>({initial:t,animate:n}),[si(t),si(n)])}function si(e){return Array.isArray(e)?e.join(" "):e}const ii={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},oi={};for(const n in ii)oi[n]={isEnabled:e=>ii[n].some(t=>!!e[t])};const li=Symbol.for("motionComponentSymbol");function ci(e,t,n){return(0,a.useCallback)(a=>{a&&e.onMount&&e.onMount(a),t&&(a?t.mount(a):t.unmount()),n&&("function"===typeof n?n(a):$a(n)&&(n.current=a))},[t])}
2function di(e,t,n,r,s){var i,o,l,c;const{visualElement:d}=(0,a.useContext)(ti),u=(0,a.useContext)(ei),m=(0,a.useContext)(f),h=(0,a.useContext)(v).reducedMotion,p=(0,a.useRef)(null);r=r||u.renderer,!p.current&&r&&(p.current=r(e,{visualState:t,parent:d,props:n,presenceContext:m,blockInitialAnimation:!!m&&!1===m.initial,reducedMotionConfig:h}));const g=p.current,b=(0,a.useContext)(fr);!g||g.projection||!s||"html"!==g.type&&"svg"!==g.type||function(e,t,n,a){const{layoutId:r,layout:s,drag:i,dragConstraints:o,layoutScroll:l,layoutRoot:c,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:ui(e.parent)),e.projection.setOptions({layoutId:r,layout:s,alwaysMeasureLayout:Boolean(i)||o&&$a(o),visualElement:e,animationType:"string"===typeof s?s:"both",initialPromotionConfig:a,crossfade:d,layoutScroll:l,layoutRoot:c})}(p.current,n,s,b);const y=(0,a.useRef)(!1);(0,a.useInsertionEffect)(()=>{g&&y.current&&g.update(n,m)});const w=n[ue],k=(0,a.useRef)(Boolean(w)&&!(null!==(i=(o=window).MotionHandoffIsComplete)&&void 0!==i&&i.call(o,w))&&(null===(l=(c=window).MotionHasOptimisedAnimation)||void 0===l?void 0:l.call(c,w)));return x(()=>{g&&(y.current=!0,window.MotionIsMounted=!0,g.updateFeatures(),gr.render(g.render),k.current&&g.animationState&&g.animationState.animateChanges())}),(0,a.useEffect)(()=>{g&&(!k.current&&g.animationState&&g.animationState.animateChanges(),k.current&&(queueMicrotask(()=>{var e,t;null===(e=(t=window).MotionHandoffMarkAsComplete)||void 0===e||e.call(t,w)}),k.current=!1))}),g}function ui(e){if(e)return!1!==e.options.allowProjection?e.projection:ui(e.parent)}function mi(e){var t,n;let{preloadedFeatures:r,createVisualElement:s,useRender:i,useVisualState:o,Component:l}=e;function c(e,t){let n;const r=d(d(d({},(0,a.useContext)(v)),e),{},{layoutId:hi(e)}),{isStatic:c}=r,m=ri(e),h=o(e,c);if(!c&&g){!function(){(0,a.useContext)(ei).strict;0}();const e=function(e){const{drag:t,layout:n}=oi;if(!t&&!n)return{};const a=d(d({},t),n);return{MeasureLayout:null!==t&&void 0!==t&&t.isEnabled(e)||null!==n&&void 0!==n&&n.isEnabled(e)?a.MeasureLayout:void 0,ProjectionNode:a.ProjectionNode}}(r);n=e.MeasureLayout,m.visualElement=di(l,h,r,s,e.ProjectionNode)}return(0,u.jsxs)(ti.Provider,{value:m,children:[n&&m.visualElement?(0,u.jsx)(n,d({visualElement:m.visualElement},r)):null,i(l,e,ci(h,m.visualElement,t),h,c,m.visualElement)]})}r&&function(e){for(const t in e)oi[t]=d(d({},oi[t]),e[t])}(r),c.displayName="motion.".concat("string"===typeof l?l:"create(".concat(null!==(t=null!==(n=l.displayName)&&void 0!==n?n:l.name)&&void 0!==t?t:"",")"));const m=(0,a.forwardRef)(c);return m[li]=l,m}function hi(e){let{layoutId:t}=e;const n=(0,a.useContext)(h).id;return n&&void 0!==t?n+"-"+t:t}function pi(e,t){let{layout:n,layoutId:a}=t;return Y.has(e)||e.startsWith("origin")||(n||void 0!==a)&&(!!kr[e]||"opacity"===e)}const gi=(e,t)=>t&&"number"===typeof e?t.transform(e):e,xi=d(d({},De),{},{transform:Math.round}),fi=d(d({borderWidth:Re,borderTopWidth:Re,borderRightWidth:Re,borderBottomWidth:Re,borderLeftWidth:Re,borderRadius:Re,radius:Re,borderTopLeftRadius:Re,borderTopRightRadius:Re,borderBottomRightRadius:Re,borderBottomLeftRadius:Re,width:Re,maxWidth:Re,height:Re,maxHeight:Re,top:Re,right:Re,bottom:Re,left:Re,padding:Re,paddingTop:Re,paddingRight:Re,paddingBottom:Re,paddingLeft:Re,margin:Re,marginTop:Re,marginRight:Re,marginBottom:Re,marginLeft:Re,backgroundPositionX:Re,backgroundPositionY:Re},{rotate:Pe,rotateX:Pe,rotateY:Pe,rotateZ:Pe,scale:Ne,scaleX:Ne,scaleY:Ne,scaleZ:Ne,skew:Pe,skewX:Pe,skewY:Pe,distance:Re,translateX:Re,translateY:Re,translateZ:Re,x:Re,y:Re,z:Re,perspective:Re,transformPerspective:Re,opacity:Ce,originX:Ue,originY:Ue,originZ:Re}),{},{zIndex:xi,fillOpacity:Ce,strokeOpacity:Ce,numOctaves:xi}),bi={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},yi=W.length;function vi(e,t,n){const{style:a,vars:r,transformOrigin:s}=e;let i=!1,o=!1;for(const l in t){const e=t[l];if(Y.has(l))i=!0;else if(ve(l))r[l]=e;else{const t=gi(e,fi[l]);l.startsWith("origin")?(o=!0,s[l]=t):a[l]=t}}if(t.transform||(i||n?a.transform=function(e,t,n){let a="",r=!0;for(let s=0;s<yi;s++){const i=W[s],o=e[i];if(void 0===o)continue;let l=!0;if(l="number"===typeof o?o===(i.startsWith("scale")?1:0):0===parseFloat(o),!l||n){const e=gi(o,fi[i]);l||(r=!1,a+="".concat(bi[i]||i,"(").concat(e,") ")),n&&(t[i]=e)}}return a=a.trim(),n?a=n(t,r?"":a):r&&(a="none"),a}(t,e.transform,n):a.transform&&(a.transform="none")),o){const{originX:e="50%",originY:t="50%",originZ:n=0}=s;a.transformOrigin="".concat(e," ").concat(t," ").concat(n)}}const wi=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ki(e,t,n){for(const a in t)le(t[a])||pi(a,n)||(e[a]=t[a])}function ji(e,t){const n={};return ki(n,e.style||{},e),Object.assign(n,function(e,t){let{transformTemplate:n}=e;return(0,a.useMemo)(()=>{const e={style:{},transform:{},transformOrigin:{},vars:{}};
2return vi(e,t,n),Object.assign({},e.vars,e.style)},[t])}(e,t)),n}function Di(e,t){const n={},a=ji(e,t);return e.drag&&!1!==e.dragListener&&(n.draggable=!1,a.userSelect=a.WebkitUserSelect=a.WebkitTouchCallout="none",a.touchAction=!0===e.drag?"none":"pan-".concat("x"===e.drag?"y":"x")),void 0===e.tabIndex&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=a,n}const Ci={offset:"stroke-dashoffset",array:"stroke-dasharray"},Ni={offset:"strokeDashoffset",array:"strokeDasharray"};const Fi=["attrX","attrY","attrScale","pathLength","pathSpacing","pathOffset"];function Si(e,t,n,a,r){let{attrX:s,attrY:i,attrScale:o,pathLength:l,pathSpacing:c=1,pathOffset:d=0}=t;if(vi(e,T(t,Fi),a),n)return void(e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox));e.attrs=e.style,e.style={};const{attrs:u,style:m}=e;var h,p;(u.transform&&(m.transform=u.transform,delete u.transform),m.transform||u.transformOrigin)&&(m.transformOrigin=null!==(h=u.transformOrigin)&&void 0!==h?h:"50% 50%",delete u.transformOrigin);m.transform&&(m.transformBox=null!==(p=null===r||void 0===r?void 0:r.transformBox)&&void 0!==p?p:"fill-box",delete u.transformBox);void 0!==s&&(u.x=s),void 0!==i&&(u.y=i),void 0!==o&&(u.scale=o),void 0!==l&&function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];e.pathLength=1;const s=r?Ci:Ni;e[s.offset]=Re.transform(-a);const i=Re.transform(t),o=Re.transform(n);e[s.array]="".concat(i," ").concat(o)}(u,l,c,d,!1)}const Ei=()=>d(d({},{style:{},transform:{},transformOrigin:{},vars:{}}),{},{attrs:{}}),Ai=e=>"string"===typeof e&&"svg"===e.toLowerCase();function Ti(e,t,n,r){const s=(0,a.useMemo)(()=>{const n=Ei();return Si(n,t,Ai(r),e.transformTemplate,e.style),d(d({},n.attrs),{},{style:d({},n.style)})},[t]);if(e.style){const t={};ki(t,e.style,e),s.style=d(d({},t),s.style)}return s}const Mi=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function _i(e){return e.startsWith("while")||e.startsWith("drag")&&"draggable"!==e||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||Mi.has(e)}let Bi=e=>!_i(e);try{"function"===typeof(Ii=require("@emotion/is-prop-valid").default)&&(Bi=e=>e.startsWith("on")?!_i(e):Ii(e))}catch(_H){}var Ii;const Pi=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Li(e){return"string"===typeof e&&!e.includes("-")&&!!(Pi.indexOf(e)>-1||/[A-Z]/.test(e))}function Ri(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(t,n,r,s,i)=>{let{latestValues:o}=s;const l=(Li(t)?Ti:Di)(n,o,i,t),c=function(e,t,n){const a={};for(const r in e)"values"===r&&"object"===typeof e.values||(Bi(r)||!0===n&&_i(r)||!t&&!_i(r)||e.draggable&&r.startsWith("onDrag"))&&(a[r]=e[r]);return a}(n,"string"===typeof t,e),u=t!==a.Fragment?d(d(d({},c),l),{},{ref:r}):{},{children:m}=n,h=(0,a.useMemo)(()=>le(m)?m.get():m,[m]);return(0,a.createElement)(t,d(d({},u),{},{children:h}))}}const zi=["transitionEnd","transition"];const Oi=e=>(t,n)=>{const r=(0,a.useContext)(ti),s=(0,a.useContext)(f),i=()=>function(e,t,n,a){let{scrapeMotionValuesFromProps:r,createRenderState:s}=e;return{latestValues:Ui(t,n,a,r),renderState:s()}}(e,t,r,s);return n?i():p(i)};function Ui(e,t,n,a){const r={},s=a(e,{});for(const m in s)r[m]=Ar(s[m]);let{initial:i,animate:o}=e;const l=ni(e),c=ai(e);t&&c&&!l&&!1!==e.inherit&&(void 0===i&&(i=t.initial),void 0===o&&(o=t.animate));let d=!!n&&!1===n.initial;d=d||!1===i;const u=d?o:i;if(u&&"boolean"!==typeof u&&!A(u)){const t=Array.isArray(u)?u:[u];for(let n=0;n<t.length;n++){const a=_(e,t[n]);if(a){const{transitionEnd:e,transition:t}=a,n=T(a,zi);for(const a in n){let e=n[a];if(Array.isArray(e)){e=e[d?e.length-1:0]}
2null!==e&&(r[a]=e)}for(const a in e)r[a]=e[a]}}}return r}function Vi(e,t,n){const{style:a}=e,r={};for(const i in a){var s;(le(a[i])||t.style&&le(t.style[i])||pi(i,e)||void 0!==(null===n||void 0===n||null===(s=n.getValue(i))||void 0===s?void 0:s.liveStyle))&&(r[i]=a[i])}return r}const Hi={useVisualState:Oi({scrapeMotionValuesFromProps:Vi,createRenderState:wi})};function qi(e,t,n){const a=Vi(e,t,n);for(const r in e)if(le(e[r])||le(t[r])){a[-1!==W.indexOf(r)?"attr"+r.charAt(0).toUpperCase()+r.substring(1):r]=e[r]}return a}const Wi={useVisualState:Oi({scrapeMotionValuesFromProps:qi,createRenderState:Ei})};function Yi(e,t){return function(n){let{forwardMotionProps:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{forwardMotionProps:!1};return mi(d(d({},Li(n)?Wi:Hi),{},{preloadedFeatures:e,useRender:Ri(a),createVisualElement:t,Component:n}))}}const Gi=e=>t=>t.test(e),Ki=[De,Re,Le,Pe,Oe,ze,{test:e=>"auto"===e,parse:e=>e}],Xi=e=>Ki.find(Gi(e)),Ji=e=>/^-?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)$/.test(e),$i=/^var\(--(?:([\x2D0-9A-Z_a-z]+)|([\x2D0-9A-Z_a-z]+), ?([ #%\(\),-\.0-9A-Za-z]+))\)/;function Qi(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;'Max CSS variable fallback depth detected in property "'.concat(e,'". This may indicate a circular fallback dependency.');const[a,r]=function(e){const t=$i.exec(e);if(!t)return[,];const[,n,a,r]=t;return["--".concat(null!==n&&void 0!==n?n:a),r]}(e);if(!a)return;const s=window.getComputedStyle(t).getPropertyValue(a);if(s){const e=s.trim();return Ji(e)?parseFloat(e):e}return ke(r)?Qi(r,t,n+1):r}const Zi=e=>/^0(?:[\0-\x08\x0E-\x1F!-\x2D\/-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+$/.test(e);function eo(e){return"number"===typeof e?0===e:null===e||("none"===e||"0"===e||Zi(e))}const to=new Set(["brightness","contrast","saturate","opacity"]);function no(e){const[t,n]=e.slice(0,-1).split("(");if("drop-shadow"===t)return e;const[a]=n.match(Se)||[];if(!a)return e;const r=n.replace(a,"");let s=to.has(t)?1:0;return a!==n&&(s*=100),t+"("+s+r+")"}const ao=/\b([\x2Da-z]*)\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\)/g,ro=d(d({},Qe),{},{getAnimatableNone:e=>{const t=e.match(ao);return t?t.map(no).join(" "):e}}),so=d(d({},fi),{},{color:He,backgroundColor:He,outlineColor:He,fill:He,stroke:He,borderColor:He,borderTopColor:He,borderRightColor:He,borderBottomColor:He,borderLeftColor:He,filter:ro,WebkitFilter:ro}),io=e=>so[e];function oo(e,t){let n=io(e);return n!==ro&&(n=Qe),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const lo=new Set(["auto","none","0"]);class co extends jn{constructor(e,t,n,a,r){super(e,t,n,a,r,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let o=0;o<e.length;o++){let n=e[o];if("string"===typeof n&&(n=n.trim(),ke(n))){const a=Qi(n,t.current);void 0!==a&&(e[o]=a),o===e.length-1&&(this.finalKeyframe=n)}}if(this.resolveNoneKeyframes(),!G.has(n)||2!==e.length)return;const[a,r]=e,s=Xi(a),i=Xi(r);if(s!==i)if(hn(s)&&hn(i))for(let o=0;o<e.length;o++){const t=e[o];"string"===typeof t&&(e[o]=parseFloat(t))}else xn[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:t}=this,n=[];for(let a=0;a<e.length;a++)(null===e[a]||eo(e[a]))&&n.push(a);n.length&&function(e,t,n){let a,r=0;for(;r<e.length&&!a;){const t=e[r];"string"===typeof t&&!lo.has(t)&&Ke(t).values.length&&(a=e[r]),r++}if(a&&n)for(const s of t)e[s]=oo(n,a)}(e,n,t)}measureInitialState(){const{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;"height"===n&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=xn[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;const a=t[t.length-1];void 0!==a&&e.getValue(n,a).jump(a,!1)}measureEndState(){var e;const{element:t,name:n,unresolvedKeyframes:a}=this;if(!t||!t.current)return;const r=t.getValue(n);r&&r.jump(this.measuredOrigin,!1);const s=a.length-1,i=a[s];a[s]=xn[n](t.measureViewportBox(),window.getComputedStyle(t.current)),null!==i&&void 0===this.finalKeyframe&&(this.finalKeyframe=i),null!==(e=this.removedTransforms)&&void 0!==e&&e.length&&this.removedTransforms.forEac
2h(e=>{let[n,a]=e;t.getValue(n).set(a)}),this.resolveNoneKeyframes()}}const uo=[...Ki,He,Qe],mo={current:null},ho={current:!1};const po=new WeakMap;const go=["willChange"],xo=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class fo{scrapeMotionValuesFromProps(e,t,n){return{}}constructor(e){let{parent:t,props:n,presenceContext:a,reducedMotionConfig:r,blockInitialAnimation:s,visualState:i}=e,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=jn,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const e=ee.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,U.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=i;this.latestValues=l,this.baseTarget=d({},l),this.initialValues=n.initial?d({},l):{},this.renderState=c,this.parent=t,this.props=n,this.presenceContext=a,this.depth=t?t.depth+1:0,this.reducedMotionConfig=r,this.options=o,this.blockInitialAnimation=Boolean(s),this.isControllingVariants=ni(n),this.isVariantNode=ai(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=Boolean(t&&t.current);const u=this.scrapeMotionValuesFromProps(n,{},this),{willChange:m}=u,h=T(u,go);for(const d in h){const e=h[d];void 0!==l[d]&&le(e)&&e.set(l[d],!1)}}mount(e){this.current=e,po.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),ho.current||function(){if(ho.current=!0,g)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>mo.current=e.matches;e.addListener(t),t()}else mo.current=!1}(),this.shouldReduceMotion="never"!==this.reducedMotionConfig&&("always"===this.reducedMotionConfig||mo.current),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){this.projection&&this.projection.unmount(),V(this.notifyUpdate),V(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const n=Y.has(e);n&&this.onBindTransform&&this.onBindTransform();const a=t.on("change",t=>{this.latestValues[e]=t,this.props.onUpdate&&U.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),r=t.on("renderRequest",this.scheduleRender);let s;window.MotionCheckAppearSync&&(s=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{a(),r(),s&&s(),t.owner&&t.stop()})}sortNodePosition(e){return this.current&&this.sortInstanceNodePosition&&this.type===e.type?this.sortInstanceNodePosition(this.current,e.current):0}updateFeatures(){let e="animation";for(e in oi){const t=oi[e];if(!t)continue;const{isEnabled:n,Feature:a}=t;if(!this.features[e]&&a&&n(this.props)&&(this.features[e]=new a(this)),this.features[e]){const t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):{x:{min:0,max:0},y:{min:0,max:0}}}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let n=0;n<xo.length;n++){const t=xo[n];this.propEventSubscriptions[t]&&(this.propEventSubscriptions[t](),delete this.propEventSubscriptions[t]);const a=e["on"+t];a&&(this.propEventSubscriptions[t]=this.on(t,a))}this.prevMotionValues=function(e,t,n){for(const a in t){const r=t[a],s=n[a];if(le(r))e.addValue(a,r);else if(le(s))e.addValue(a,ae(r,{owner:e}));else if(s!==r)if(e.hasValue(a)){const t=e.getValue(a);!0===t.liveStyle?t.jump(r):t.hasAnimated||t.set(r)}else{const t=e.getStaticValue(a);e.addValue(a,ae(void 0!==t?t:r,{owner:e}))}}for(const a in n)void 0===t[a]&&e.removeValue(a);return t}(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}
2addVariantChild(e){const t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){const n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return void 0===n&&void 0!==t&&(n=ae(null===t?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){var n;let a=void 0===this.latestValues[e]&&this.current?null!==(n=this.getBaseTargetFromProps(this.props,e))&&void 0!==n?n:this.readValueFromInstance(this.current,e,this.options):this.latestValues[e];var r;return void 0!==a&&null!==a&&("string"===typeof a&&(Ji(a)||Zi(a))?a=parseFloat(a):(r=a,!uo.find(Gi(r))&&Qe.test(t)&&(a=oo(e,t))),this.setBaseTarget(e,le(a)?a.get():a)),le(a)?a.get():a}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){const{initial:t}=this.props;let n;if("string"===typeof t||"object"===typeof t){var a;const r=_(this.props,t,null===(a=this.presenceContext)||void 0===a?void 0:a.custom);r&&(n=r[e])}if(t&&void 0!==n)return n;const r=this.getBaseTargetFromProps(this.props,e);return void 0===r||le(r)?void 0!==this.initialValues[e]&&void 0===n?void 0:this.baseTarget[e]:r}on(e,t){return this.events[e]||(this.events[e]=new J),this.events[e].add(t)}notify(e){if(this.events[e]){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];this.events[e].notify(...n)}}}class bo extends fo{constructor(){super(...arguments),this.KeyframeResolver=co}sortInstanceNodePosition(e,t){return 2&e.compareDocumentPosition(t)?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,t){let{vars:n,style:a}=t;delete n[e],delete a[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;le(e)&&(this.childSubscription=e.on("change",e=>{this.current&&(this.current.textContent="".concat(e))}))}}function yo(e,t,n,a){let{style:r,vars:s}=t;Object.assign(e.style,r,a&&a.getProjectionStyles(n));for(const i in s)e.style.setProperty(i,s[i])}class vo extends bo{constructor(){super(...arguments),this.type="html",this.renderInstance=yo}readValueFromInstance(e,t){var n,a;if(Y.has(t))return null!==(n=this.projection)&&void 0!==n&&n.isProjecting?dn(t):((e,t)=>{const{transform:n="none"}=getComputedStyle(e);return un(n,t)})(e,t);{const n=(a=e,window.getComputedStyle(a)),r=(ve(t)?n.getPropertyValue(t):n[t])||0;return"string"===typeof r?r.trim():r}}measureInstanceViewportBox(e,t){let{transformPagePoint:n}=t;return Xa(e,n)}build(e,t,n){vi(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Vi(e,t,n)}}const wo=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);class ko extends bo{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=_a}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Y.has(t)){const e=io(t);return e&&e.default||0}return t=wo.has(t)?t:de(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return qi(e,t,n)}
2build(e,t,n){Si(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,a){!function(e,t,n,a){yo(e,t,void 0,a);for(const r in t.attrs)e.setAttribute(wo.has(r)?r:de(r),t.attrs[r])}(e,t,0,a)}mount(e){this.isSVGTag=Ai(e.tagName),super.mount(e)}}const jo=(e,t)=>Li(e)?new ko(t):new vo(t,{allowProjection:e!==a.Fragment}),Do=E(Yi(d(d(d(d({},ya),Qs),_s),Zs),jo)),Co=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),No=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},Fo=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim()};var So={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Eo=["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"],Ao=(0,a.forwardRef)((e,t)=>{let{color:n="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:i,className:o="",children:l,iconNode:c}=e,u=T(e,Eo);return(0,a.createElement)("svg",d(d(d({ref:t},So),{},{width:r,height:r,stroke:n,strokeWidth:i?24*Number(s)/Number(r):s,className:Fo("lucide",o)},!l&&!(e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(u)&&{"aria-hidden":"true"}),u),[...c.map(e=>{let[t,n]=e;return(0,a.createElement)(t,n)}),...Array.isArray(l)?l:[l]])}),To=["className"],Mo=(e,t)=>{const n=(0,a.forwardRef)((n,r)=>{let{className:s}=n,i=T(n,To);return(0,a.createElement)(Ao,d({ref:r,iconNode:t,className:Fo("lucide-".concat(Co(No(e))),"lucide-".concat(e),s)},i))});return n.displayName=No(e),n},_o=Mo("mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),Bo=Mo("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),Io=Mo("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),Po=Mo("sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]),Lo=Mo("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),Ro=Mo("pen-line",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]),zo=["sri"],Oo=["page"],Uo=["page","matches"],Vo=["page","matches"],Ho=["onClick","discover","prefetch","relative","reloadDocument","replace","mask","state","target","to","preventScrollReset","viewTransition","defaultShouldRevalidate"],qo=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Wo=["discover","fetcherKey","navigate","reloadDocument","replace","state","method","action","onSubmit","relative","preventScrollReset","viewTransition","defaultShouldRevalidate"];var Yo=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Go=/^[\\/]{2}/;function Ko(e,t){return t+e.replace(/\\/g,"/")}var Xo="popstate";function Jo(e){return"object"===typeof e&&null!=e&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function $o(){return rl(function(e,t){var n;let a=null===(n=t.state)||void 0===n?void 0:n.masked,{pathname:r,search:s,hash:i}=a||e.location;return tl("",{pathname:r,search:s,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||"default",a?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)},function(e,t){return"string"===typeof t?t:nl(t)},null,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}function Qo(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}function Zo(e,t){if(!e){"undefined"!==typeof console&&console.warn(t);try{throw new Error(t)}catch(n){}}}function el(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function tl(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;return d(d({pathname:"string"===typeof e?e:e.pathname,search:"",hash:""},"string"===typeof t?al(t):t),{},{state:n,key:t&&t.key||a||Math.random().toString(36).substring(2,10),mask:r})}function nl(e){let{pathname:t="/",search:n="",hash:a=""}=e;return n&&"?"!==n&&(t+="?"===n.charAt(0)?n:"?"+n),a&&"#"!==a&&(t+="#"===a.charAt(0)?a:"#"+a),t}function al(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function rl(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},{window:r=document.defaultView,v5Compat:s=!1}=a,i=r.history,o="POP",l=null,c=u();function u(){return(i.state||{idx:null}).idx}function m(){o="POP";let e=u(),t=null==e?null:e-c;c=e,l&&l({action:o,location:p.location,delta:t})}function h(e){return sl(r,e)}null==c&&(c=0,i.replaceState(d(d({},i.state),{},{idx:c}),""));let p={get action(){return o},get location(){return e(r,i)},listen(e){if(l)throw new Error("A history only accepts one active listener");return r.addEventListener(Xo,m),l=e,()=>{r.removeEventListener(Xo,m),l=null}},createHref:e=>t(r,e),createURL:h,encodeLocation(e){let t=h(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){o="PUSH";let a=Jo(e)?e:tl(p.location,e,t);n&&n(a,e),c=u()+1;let d=el(a,c),m=p.createHref(a.mask||a);try{i.pushState(d,"",m)}catch(h){if(h instanceof DOMException&&"DataCloneError"===h.name)throw h;r.location.assign(m)}s&&l&&l({action:o,location:p.location,delta:1})},replace:function(e,t){o="REPLACE";let a=Jo(e)?e:tl(p.location,e,t);n&&n(a,e),c=u();let r=el(a,c),d=p.createHref(a.mask||a);i.replaceState(r,"",d),s&&l&&l({action:o,location:p.location,delta:0})},go:e=>i.go(e)};return p}function sl(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a="http://localhost";
2e&&(a="null"!==e.location.origin?e.location.origin:e.location.href),Qo(a,"No window.location.(origin|href) available to create URL");let r="string"===typeof t?t:nl(t);return r=r.replace(/ $/,"%20"),!n&&Go.test(r)&&(r=a+r),new URL(r,a)}new WeakMap;function il(e,t){return ol(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:"/",!1)}function ol(e,t,n,a,r){let s=Dl(("string"===typeof t?al(t):t).pathname||"/",n);if(null==s)return null;let i=null!==r&&void 0!==r?r:ll(e),o=null,l=jl(s);for(let c=0;null==o&&c<i.length;++c)o=yl(i[c],l,a);return o}function ll(e){let t=cl(e);return function(e){e.sort((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let n=e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n]);return n?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)))}(t),t}function cl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=function(e,s){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,o=arguments.length>3?arguments[3]:void 0,l={relativePath:void 0===o?e.path||"":o,caseSensitive:!0===e.caseSensitive,childrenIndex:s,route:e};if(l.relativePath.startsWith("/")){if(!l.relativePath.startsWith(a)&&i)return;Qo(l.relativePath.startsWith(a),'Absolute route path "'.concat(l.relativePath,'" nested under path "').concat(a,'" is not valid. An absolute child route path must start with the combined path of all its parent routes.')),l.relativePath=l.relativePath.slice(a.length)}let c=Tl([a,l.relativePath]),u=n.concat(l);e.children&&e.children.length>0&&(Qo(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'.concat(c,'".')),cl(e.children,t,u,c,i)),(null!=e.path||e.index)&&t.push({path:c,score:bl(c,e.index),routesMeta:u.map((e,t)=>{let[n,a]=kl(e.relativePath,e.caseSensitive,t===u.length-1);return d(d({},e),{},{matcher:n,compiledParams:a})})})};return e.forEach((e,t)=>{var n;if(""!==e.path&&null!==(n=e.path)&&void 0!==n&&n.includes("?"))for(let a of dl(e.path))s(e,t,!0,a);else s(e,t)}),t}function dl(e){let t=e.split("/");if(0===t.length)return[];let[n,...a]=t,r=n.endsWith("?"),s=n.replace(/\?$/,"");if(0===a.length)return r?[s,""]:[s];let i=dl(a.join("/")),o=[];return o.push(...i.map(e=>""===e?s:[s,e].join("/"))),r&&o.push(...i),o.map(t=>e.startsWith("/")&&""===t?"/":t)}var ul=/^:[\w-]+$/,ml=3,hl=2,pl=1,gl=10,xl=-2,fl=e=>"*"===e;function bl(e,t){let n=e.split("/"),a=n.length;return n.some(fl)&&(a+=xl),t&&(a+=hl),n.filter(e=>!fl(e)).reduce((e,t)=>e+(ul.test(t)?ml:""===t?pl:gl),a)}function yl(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],{routesMeta:a}=e,r={},s="/",i=[];for(let o=0;o<a.length;++o){let e=a[o],l=o===a.length-1,c="/"===s?t:t.slice(s.length)||"/",d={path:e.relativePath,caseSensitive:e.caseSensitive,end:l},u=e.matcher&&e.compiledParams?wl(d,c,e.matcher,e.compiledParams):vl(d,c),m=e.route;if(!u&&l&&n&&!a[a.length-1].route.index&&(u=vl({path:e.relativePath,caseSensitive:e.caseSensitive,end:!1},c)),!u)return null;
2Object.assign(r,u.params),i.push({params:r,pathname:Tl([s,u.pathname]),pathnameBase:_l(Tl([s,u.pathnameBase])),route:m}),"/"!==u.pathnameBase&&(s=Tl([s,u.pathnameBase]))}return i}function vl(e,t){"string"===typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=kl(e.path,e.caseSensitive,e.end);return wl(e,t,n,a)}function wl(e,t,n,a){let r=t.match(n);if(!r)return null;let s=r[0],i=s.replace(/(.)\/+$/,"$1"),o=r.slice(1),l=a.reduce((e,t,n)=>{let{paramName:a,isOptional:r}=t;if("*"===a){let e=o[n]||"";i=s.slice(0,s.length-e.length).replace(/(.)\/+$/,"$1")}const l=o[n];return e[a]=r&&!l?void 0:(l||"").replace(/%2F/g,"/"),e},{});return{params:l,pathname:s,pathnameBase:i,pattern:e}}function kl(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];Zo("*"===e||!e.endsWith("*")||e.endsWith("/*"),'Route path "'.concat(e,'" will be treated as if it were "').concat(e.replace(/\*$/,"/*"),'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "').concat(e.replace(/\*$/,"/*"),'".'));let a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,n,r,s)=>{if(a.push({paramName:t,isOptional:null!=n}),n){let t=s.charAt(r+e.length);return t&&"/"!==t?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),r+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":""!==e&&"/"!==e&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),a]}function jl(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return Zo(!1,'The URL path "'.concat(e,'" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (').concat(t,").")),e}}function Dl(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,a=e.charAt(n);return a&&"/"!==a?null:e.slice(n)||"/"}function Cl(e,t){let n=Ml(t).split("/");return e.split("/").forEach(e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)}),n.length>1?n.join("/"):"/"}function Nl(e,t,n,a){return"Cannot include a '".concat(e,"' character in a manually specified `to.").concat(t,"` field [").concat(JSON.stringify(a),"]. Please separate it out to the `to.").concat(n,'` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.')}function Fl(e){return e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0)}function Sl(e){let t=Fl(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function El(e,t,n){let a,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];"string"===typeof e?a=al(e):(a=d({},e),Qo(!a.pathname||!a.pathname.includes("?"),Nl("?","pathname","search",a)),Qo(!a.pathname||!a.pathname.includes("#"),Nl("#","pathname","hash",a)),Qo(!a.search||!a.search.includes("#"),Nl("#","search","hash",a)));let s,i=""===e||""===a.pathname,o=i?"/":a.pathname;if(null==o)s=n;else{let e=t.length-1;if(!r&&o.startsWith("..")){let t=o.split("/");for(;".."===t[0];)t.shift(),e-=1;a.pathname=t.join("/")}s=e>=0?t[e]:"/"}let l=function(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/",{pathname:a,search:r="",hash:s=""}="string"===typeof e?al(e):e;return a?(a=Al(a),t=a.startsWith("/")?Cl(a.substring(1),"/"):Cl(a,n)):t=n,{pathname:t,search:Bl(r),hash:Il(s)}}(a,s),c=o&&"/"!==o&&o.endsWith("/"),u=(i||"."===o)&&n.endsWith("/");return l.pathname.endsWith("/")||!c&&!u||(l.pathname+="/"),l}var Al=e=>e.replace(/[\\/]{2,}/g,"/"),Tl=e=>Al(e.join("/")),Ml=e=>e.replace(/\/+$/,""),_l=e=>Ml(e).replace(/^\/*/,"/"),Bl=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",Il=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";var Pl=class{constructor(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.status=e,this.statusText=t||"",this.internal=a,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ll(e){return null!=e&&"number"===typeof e.status&&"string"===typeof e.statusText&&"boolean"===typeof e.internal&&"data"in e}function Rl(e){let t=e.map(e=>
2e.route.path).filter(Boolean);return Tl(t)||"/"}var zl="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;function Ol(e,t){let n=e;if("string"!==typeof n||!Yo.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let a=n,r=!1;if(zl)try{let e=new URL(window.location.href),a=Go.test(n)?new URL(Ko(n,e.protocol)):new URL(n),s=Dl(a.pathname,t);a.origin===e.origin&&null!=s?n=s+a.search+a.hash:r=!0}catch(s){Zo(!1,'<Link to="'.concat(n,'"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.'))}return{absoluteURL:a,isExternal:r,to:n}}Symbol("Uninstrumented");Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ul=["POST","PUT","PATCH","DELETE"],Vl=(new Set(Ul),["GET",...Ul]);new Set(Vl),Symbol("ResetLoaderData");new WeakMap,new WeakMap,new WeakMap,new WeakMap;var Hl=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];function ql(e){try{return Hl.includes(new URL(e).protocol)}catch(_H){return!1}}var Wl=a.createContext(null);Wl.displayName="DataRouter";var Yl=a.createContext(null);Yl.displayName="DataRouterState";var Gl=a.createContext(!1);function Kl(){return a.useContext(Gl)}var Xl=a.createContext({isTransitioning:!1});Xl.displayName="ViewTransition";var Jl=a.createContext(new Map);Jl.displayName="Fetchers";var $l=a.createContext(null);$l.displayName="Await";var Ql=a.createContext(null);Ql.displayName="Navigation";var Zl=a.createContext(null);Zl.displayName="Location";var ec=a.createContext({outlet:null,matches:[],isDataRoute:!1});ec.displayName="Route";var tc=a.createContext(null);tc.displayName="RouteError";var nc="REACT_ROUTER_ERROR";function ac(){return null!=a.useContext(Zl)}function rc(){return Qo(ac(),"useLocation() may be used only in the context of a <Router> component."),a.useContext(Zl).location}var sc="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ic(e){a.useContext(Ql).static||a.useLayoutEffect(e)}function oc(){let{isDataRoute:e}=a.useContext(ec);return e?function(){let{router:e}=yc("useNavigate"),t=wc("useNavigate"),n=a.useRef(!1);ic(()=>{n.current=!0});let r=a.useCallback(async function(a){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Zo(n.current,sc),n.current&&("number"===typeof a?await e.navigate(a):await e.navigate(a,d({fromRouteId:t},r)))},[e,t]);return r}():function(){Qo(ac(),"useNavigate() may be used only in the context of a <Router> component.");let e=a.useContext(Wl),{basename:t,navigator:n}=a.useContext(Ql),{matches:r}=a.useContext(ec),{pathname:s}=rc(),i=JSON.stringify(Sl(r)),o=a.useRef(!1);ic(()=>{o.current=!0});let l=a.useCallback(function(a){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Zo(o.current,sc),!o.current)return;if("number"===typeof a)return void n.go(a);let l=El(a,JSON.parse(i),s,"path"===r.relative);null==e&&"/"!==t&&(l.pathname="/"===l.pathname?t:Tl([t,l.pathname])),(r.replace?n.replace:n.push)(l,r.state,r)},[t,n,i,s,e]);return l}()}a.createContext(null);function lc(){var e;let{matches:t}=a.useContext(ec),n=t[t.length-1];return null!==(e=null===n||void 0===n?void 0:n.params)&&void 0!==e?e:{}}function cc(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{matches:n}=a.useContext(ec),{pathname:r}=rc(),s=JSON.stringify(Sl(n));return a.useMemo(()=>El(e,JSON.parse(s),r,"path"===t),[e,s,r,t])}function dc(e,t,n){Qo(ac(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=a.useContext(Ql),{matches:s}=a.useContext(ec),i=s[s.length-1],o=i?i.params:{},l=i?i.pathname:"/",c=i?i.pathnameBase:"/",u=i&&i.route;{let e=u&&u.path||"";Dc(l,!u||e.endsWith("*")||e.endsWith("*?"),'You rendered descendant <Routes> (or called `useRoutes()`) at "'.concat(l,'" (under <Route path="').concat(e,'">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won\'t match anymore and therefore the child routes will never render.\n\nPlease change the parent <Route path="').concat(e,'"> to <Route path="').concat("/"===e?"*":"".concat(e,"/*"),'">.'))}let m,h=rc();if(t){var p;let e="string"===typeof t?al(t):t;Qo("/"===c||(null===(p=e.pathname)||void 0===p?void 0:p.startsWith(c)),'When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "'.concat(c,'" but pathname "').concat(e.pathname,'" was given in the `location` prop.')),m=e}else m=h;let g=m.pathname||"/",x=g;if("/"!==c){let e=c.replace(/^\//,"").split("/");x="/"+g.replace(/^\//,"").split("/").slice(e.length).join("/")}let f=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):il(e,{pathname:x});Zo(u||null!=f,'No routes matched location "'.concat(m.pathname).concat(m.search).concat(m.hash,'" ')),Zo(null==f||void 0!==f[f.length-1].route.element||void 0!==f[f.length-1].route.Component||void 0!==f[f.length-1].route.lazy,'Matched leaf route at location "'.concat(m.pathname).concat(m.search).concat(m.hash,'" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.'));let b=fc(f&&f.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:Tl([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?c:Tl([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathnameBase])})),s,n);return t&&b?a.createElement(Zl.Provider,{value:{location:d({pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0},m),navigationType:"POP"}},b):b}function uc(){let e=kc(),t=Ll(e)?"".concat(e.status," ").concat(e.statusText):e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},o=null;return console.error("Error handled by React Router default ErrorBoundary:",e),o=a.createElement(a.Fragment,null,a.createElement("p",null,"\ud83d\udcbf Hey developer \ud83d\udc4b"),a.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",a.createElement("code",{style:i},"ErrorBoundary")," or"," ",a.createElement("code",{style:i},"errorElement")," prop on your route.")),a.createElement(a.Fragment,null,a.createElement("h2",null,"Unexpected Application
2Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},t),n?a.createElement("pre",{style:s},n):null,o)}var mc=a.createElement(uc,null),hc=class extends a.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&"object"===typeof e&&e&&"digest"in e&&"string"===typeof e.digest){const t=function(e){if(e.startsWith("".concat(nc,":").concat("ROUTE_ERROR_RESPONSE",":{")))try{let t=JSON.parse(e.slice(40));if("object"===typeof t&&t&&"number"===typeof t.status&&"string"===typeof t.statusText)return new Pl(t.status,t.statusText,t.data)}catch(t){}}(e.digest);t&&(e=t)}let t=void 0!==e?a.createElement(ec.Provider,{value:this.props.routeContext},a.createElement(tc.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?a.createElement(gc,{error:e},t):t}};hc.contextType=Gl;var pc=new WeakMap;function gc(e){let{children:t,error:n}=e,{basename:r}=a.useContext(Ql);if("object"===typeof n&&n&&"digest"in n&&"string"===typeof n.digest){let e=function(e){if(e.startsWith("".concat(nc,":").concat("REDIRECT",":{")))try{let t=JSON.parse(e.slice(28));if("object"===typeof t&&t&&"number"===typeof t.status&&"string"===typeof t.statusText&&"string"===typeof t.location&&"boolean"===typeof t.reloadDocument&&"boolean"===typeof t.replace)return t}catch(t){}}(n.digest);if(e){let t=pc.get(n);if(t)throw t;let s=Ol(e.location,r),i=s.absoluteURL||s.to;if(ql(i))throw new Error("Invalid redirect location");if(zl&&!pc.get(n)){if(!s.isExternal&&!e.reloadDocument){const t=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:e.replace}));throw pc.set(n,t),t}window.location.href=i}return a.createElement("meta",{httpEquiv:"refresh",content:"0;url=".concat(i)})}}return t}function xc(e){let{routeContext:t,match:n,children:r}=e,s=a.useContext(Wl);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),a.createElement(ec.Provider,{value:t},r)}function fc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2?arguments[2]:void 0,r=null===n||void 0===n?void 0:n.state;if(null==e){if(!r)return null;if(r.errors)e=r.matches;else{if(0!==t.length||r.initialized||!(r.matches.length>0))return null;e=r.matches}}let s=e,i=null===r||void 0===r?void 0:r.errors;if(null!=i){let e=s.findIndex(e=>e.route.id&&void 0!==(null===i||void 0===i?void 0:i[e.route.id]));Qo(e>=0,"Could not find a matching route for errors on route IDs: ".concat(Object.keys(i).join(","))),s=s.slice(0,Math.min(s.length,e+1))}let o=!1,l=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<s.length;e++){let t=s[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(l=e),t.route.id){let{loaderData:e,errors:a}=r,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||void 0===a[t.route.id]);if(t.route.lazy||i){n.isStatic&&(o=!0),s=l>=0?s.slice(0,l+1):[s[0]];break}}}}let c=null===n||void 0===n?void 0:n.onError,d=r&&c?(e,t)=>{var n,a;c(e,{location:r.location,params:null!==(n=null===(a=r.matches)||void 0===a||null===(a=a[0])||void 0===a?void 0:a.params)&&void 0!==n?n:{},pattern:Rl(r.matches),errorInfo:t})}:void 0;return s.reduceRight((e,n,c)=>{let u,m=!1,h=null,p=null;r&&(u=i&&n.route.id?i[n.route.id]:void 0,h=n.route.errorElement||mc,o&&(l<0&&0===c?(Dc("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),m=!0,p=null):l===c&&(m=!0,p=n.route.hydrateFallbackElement||null)));let g=t.concat(s.slice(0,c+1)),x=()=>{let t;return t=u?h:m?p:n.route.Component?a.createElement(n.route.Component,null):n.route.element?n.route.element:e,a.createElement(xc,{match:n,routeContext:{outlet:e,matches:g,isDataRoute:null!=r},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||0===c)?a.createElement(hc,{location:r.location,revalidation:r.revalidation,component:h,error:u,children:x(),routeC
2ontext:{outlet:null,matches:g,isDataRoute:!0},onError:d}):x()},null)}function bc(e){return"".concat(e," must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.")}function yc(e){let t=a.useContext(Wl);return Qo(t,bc(e)),t}function vc(e){let t=a.useContext(Yl);return Qo(t,bc(e)),t}function wc(e){let t=function(e){let t=a.useContext(ec);return Qo(t,bc(e)),t}(e),n=t.matches[t.matches.length-1];return Qo(n.route.id,"".concat(e,' can only be used on routes that contain a unique "id"')),n.route.id}function kc(){var e;let t=a.useContext(tc),n=vc("useRouteError"),r=wc("useRouteError");return void 0!==t?t:null===(e=n.errors)||void 0===e?void 0:e[r]}var jc={};function Dc(e,t,n){t||jc[e]||(jc[e]=!0,Zo(!1,n))}var Cc={};function Nc(e,t){e||Cc[t]||(Cc[t]=!0,console.warn(t))}r.useOptimistic;a.memo(Fc);function Fc(e){let{routes:t,manifest:n,future:a,state:r,isStatic:s,onError:i}=e;return dc(t,void 0,{manifest:n,state:r,isStatic:s,onError:i,future:a})}function Sc(e){Qo(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ec(e){let{basename:t="/",children:n=null,location:r,navigationType:s="POP",navigator:i,static:o=!1,useTransitions:l}=e;Qo(!ac(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=t.replace(/^\/*/,"/"),d=a.useMemo(()=>({basename:c,navigator:i,static:o,useTransitions:l,future:{}}),[c,i,o,l]);"string"===typeof r&&(r=al(r));let{pathname:u="/",search:m="",hash:h="",state:p=null,key:g="default",mask:x}=r,f=a.useMemo(()=>{let e=Dl(u,c);return null==e?null:{location:{pathname:e,search:m,hash:h,state:p,key:g,mask:x},navigationType:s}},[c,u,m,h,p,g,s,x]);return Zo(null!=f,'<Router basename="'.concat(c,'"> is not able to match the URL "').concat(u).concat(m).concat(h,"\" because it does not start with the basename, so the <Router> won't render anything.")),null==f?null:a.createElement(Ql.Provider,{value:d},a.createElement(Zl.Provider,{children:n,value:f}))}function Ac(e){let{children:t,location:n}=e;return dc(Tc(t),n)}a.Component;function Tc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[];return a.Children.forEach(e,(e,r)=>{if(!a.isValidElement(e))return;let s=[...t,r];if(e.type===a.Fragment)return void n.push.apply(n,Tc(e.props.children,s));Qo(e.type===Sc,"[".concat("string"===typeof e.type?e.type:e.type.name,"] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>")),Qo(!e.props.index||!e.props.children,"An index route cannot have child routes.");let i={id:e.props.id||s.join("-"),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:!0===e.props.hasErrorBoundary||null!=e.props.ErrorBoundary||null!=e.props.errorElement,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(i.children=Tc(e.props.children,s)),n.push(i)}),n}var Mc="get",_c="application/x-www-form-urlencoded";function Bc(e){return"undefined"!==typeof HTMLElement&&e instanceof HTMLElement}function Ic(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return new URLSearchParams("string"===typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let a=e[n];return t.concat(Array.isArray(a)?a.map(e=>[n,e]):[[n,a]])},[]))}var Pc=null;var Lc=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Rc(e){return null==e||Lc.has(e)?e:(Zo(!1,'"'.concat(e,'" is not a valid `encType` for `<Form>`/`<fetcher.Form>` and will default to "').concat(_c,'"')),null)}function zc(e,t){let n,a,r,s,i;if(Bc(o=e)&&"form"===o.tagName.toLowerCase()){let i=e.getAttribute("action");a=i?Dl(i,t):null,n=e.getAttribute("method")||Mc,r=Rc(e.getAttribute("enctype"))||_c,s=new FormData(e)}else if(function(e){return Bc(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return Bc(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let o=e.getAttribute("formaction")||i.getAttribute("action");if(a=o?Dl(o,t):null,n=e.getAttribute("formmethod")||i.getAttribute("method")||Mc,r=Rc(e.getAttribute("formenctype"))||Rc(i.getAttribute("enctype"))||_c,s=new FormData(i,e),!function(){if(null===Pc)try{new FormData(document.createElement("form"),0),Pc=!1}catch(e){Pc=!0}return Pc}()){let{name:t,type:n,value:a}=e;if("image"===n){let e=t?"".concat(t,"."):"";s.append("".concat(e,"x"),"0"),s.append("".concat(e,"y"),"0")}else t&&s.append(t,a)}}else{if(Bc(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Mc,a=null,r=_c,i=e}var o;return s&&"text/plain"===r&&(i=s,s=void 0),{action:a,method:n.toLowerCase(),encType:r,formData:s,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");"undefined"!==typeof window?window:"undefined"!==typeof globalThis&&globalThis;function Oc(e,t){if(!1===e||null===e||"undefined"===typeof e)throw new Error(t)}Symbol("SingleFetchRedirect");function Uc(e,t,n,a){let r="string"===typeof e?new URL(e,"undefined"===typeof window?"server://singlefetch/":window.location.origin):e;return n?r.pathname.endsWith("/")?r.pathname="".concat(r.pathname,"_.").concat(a):r.pathname="".concat(r.pathname,".").concat(a):"/"===r.pathname?r.pathname="_root.".concat(a):t&&"/"===Dl(r.pathname,t)?r.pathname="".concat(Ml(t),"/_root.").concat(a):r.pathname="".concat(Ml(r.pathname),".").concat(a),r}async function Vc(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error("Error loading route module `".concat(e.module,"`, reloading page...")),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.
2isSpaMode,window.location.reload(),new Promise(()=>{})}}function Hc(e){return null!=e&&"string"===typeof e.page}function qc(e){return null!=e&&(null==e.href?"preload"===e.rel&&"string"===typeof e.imageSrcSet&&"string"===typeof e.imageSizes:"string"===typeof e.rel&&"string"===typeof e.href)}function Wc(e,t,n,a,r,s){let i=(e,t)=>!n[t]||e.route.id!==n[t].route.id,o=(e,t)=>{var a;return n[t].pathname!==e.pathname||(null===(a=n[t].route.path)||void 0===a?void 0:a.endsWith("*"))&&n[t].params["*"]!==e.params["*"]};return"assets"===s?t.filter((e,t)=>i(e,t)||o(e,t)):"data"===s?t.filter((t,s)=>{let l=a.routes[t.route.id];if(!l||!l.hasLoader)return!1;if(i(t,s)||o(t,s))return!0;if(t.route.shouldRevalidate){var c;let a=t.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:(null===(c=n[0])||void 0===c?void 0:c.params)||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if("boolean"===typeof a)return a}return!0}):[]}function Yc(e,t){let{includeHydrateFallback:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return a=e.map(e=>{let a=t.routes[e.route.id];if(!a)return[];let r=[a.module];return a.clientActionModule&&(r=r.concat(a.clientActionModule)),a.clientLoaderModule&&(r=r.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(r=r.concat(a.hydrateFallbackModule)),a.imports&&(r=r.concat(a.imports)),r}
2).flat(1),[...new Set(a)];var a}function Gc(e,t){let n=new Set,a=new Set(t);return e.reduce((e,r)=>{if(t&&!Hc(r)&&"script"===r.as&&r.href&&a.has(r.href))return e;let s=JSON.stringify(function(e){let t={},n=Object.keys(e).sort();for(let a of n)t[a]=e[a];return t}(r));return n.has(s)||(n.add(s),e.push({key:s,link:r})),e},[])}function Kc(e,t){return"lazy"===e.mode&&!0===t}function Xc(){let e=a.useContext(Wl);return Oc(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Jc(){let e=a.useContext(Yl);return Oc(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var $c=a.createContext(void 0);function Qc(){let e=a.useContext($c);return Oc(e,"You must render this element inside a <HydratedRouter> element"),e}function Zc(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function ed(e,t,n){if(n&&!sd)return[e[0]];if(t){let n=e.findIndex(e=>void 0!==t[e.route.id]);return e.slice(0,n+1)}return e}$c.displayName="FrameworkContext";function td(e){let{page:t}=e,n=T(e,Oo),r=Kl(),{nonce:s}=Qc(),{router:i}=Xc(),o=a.useMemo(()=>il(i.routes,t,i.basename),[i.routes,t,i.basename]);return o?(null==n.nonce&&s&&(n=d(d({},n),{},{nonce:s})),r?a.createElement(ad,d({page:t,matches:o},n)):a.createElement(rd,d({page:t,matches:o},n))):null}function nd(e){let{manifest:t,routeModules:n}=Qc(),[r,s]=a.useState([]);return a.useEffect(()=>{let a=!1;return async function(e,t,n){return Gc((await Promise.all(e.map(async e=>{let a=t.routes[e.route.id];if(a){let e=await Vc(a,n);return e.links?e.links():[]}return[]}))).flat(1).filter(qc).filter(e=>"stylesheet"===e.rel||"preload"===e.rel).map(e=>"stylesheet"===e.rel?d(d({},e),{},{rel:"prefetch",as:"style"}):d(d({},e),{},{rel:"prefetch"})))}(e,t,n).then(e=>{a||s(e)}),()=>{a=!0}},[e,t,n]),r}function ad(e){let{page:t,matches:n}=e,r=T(e,Uo),s=rc(),{future:i}=Qc(),{basename:o}=Xc(),l=a.useMemo(()=>{if(t===s.pathname+s.search+s.hash)return[];let e=Uc(t,o,i.v8_trailingSlashAwareDataRequests,"rsc"),a=!1,r=[];for(let t of n)"function"===typeof t.route.shouldRevalidate?a=!0:r.push(t.route.id);return a&&r.length>0&&e.searchParams.set("_routes",r.join(",")),[e.pathname+e.search]},[o,i.v8_trailingSlashAwareDataRequests,t,s,n]);return a.createElement(a.Fragment,null,l.map(e=>a.createElement("link",d({key:e,rel:"prefetch",as:"fetch",href:e},r))))}function rd(e){let{page:t,matches:n}=e,r=T(e,Vo),s=rc(),{future:i,manifest:o,routeModules:l}=Qc(),{basename:c}=Xc(),{loaderData:u,matches:m}=Jc(),h=a.useMemo(()=>Wc(t,n,m,o,s,"data"),[t,n,m,o,s]),p=a.useMemo(()=>Wc(t,n,m,o,s,"assets"),[t,n,m,o,s]),g=a.useMemo(()=>{if(t===s.pathname+s.search+s.hash)return[];let e=new Set,a=!1;if(n.forEach(t=>{var n;let r=o.routes[t.route.id];r&&r.hasLoader&&(!h.some(e=>e.route.id===t.route.id)&&t.route.id in u&&null!==(n=l[t.route.id])&&void 0!==n&&n.shouldRevalidate||r.hasClientLoader?a=!0:e.add(t.route.id))}),0===e.size)return[];let r=Uc(t,c,i.v8_trailingSlashAwareDataRequests,"data");return a&&e.size>0&&r.searchParams.set("_routes",n.filter(t=>e.has(t.route.id)).map(e=>e.route.id).join(",")),[r.pathname+r.search]},[c,i.v8_trailingSlashAwareDataRequests,u,s,o,h,n,t,l]),x=a.useMemo(()=>Yc(p,o),[p,o]),f=nd(p);return a.createElement(a.Fragment,null,g.map(e=>a.createElement("link",d({key:e,rel:"prefetch",as:"fetch",href:e},r))),x.map(e=>a.createElement("link",d({key:e,rel:"modulepreload",href:e},r))),f.map(e=>{var t;let{key:n,link:s}=e;return a.createElement("link",d(d({key:n,nonce:r.nonce},s),{},{crossOrigin:null!==(t=s.crossOrigin)&&void 0!==t?t:r.crossOrigin}))}))}var sd=!1;function id(e){let{manifest:t,serverHandoffString:n,isSpaMode:r,renderMeta:s,routeDiscovery:i,ssr:o,nonce:l}=Qc(),{router:c,static:u,staticContext:m}=Xc(),{matches:h}=Jc(),p=Kl(),g=Kc(i,o);null==e.nonce&&l&&d(d({},e),{},{nonce:l}),s&&(s.didRenderScripts=!0);let x=ed(h,null,r);a.useEffect(()=>{0},[]);let f=a.useMemo(()=>{var r;if(p)return null;let s=m?"window.__reactRouterContext = ".concat(n,";").concat("window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}
2).pipeThrough(new TextEncoderStream());"):" ",i=u?"".concat(null!==t.hmr&&void 0!==r&&r.runtime?"import ".concat(JSON.stringify(t.hmr.runtime),";"):"").concat(g?"":"import ".concat(JSON.stringify(t.url)),";\n").concat(x.map((e,n)=>{let a="route".concat(n),r=t.routes[e.route.id];Oc(r,"Route ".concat(e.route.id," not found in manifest"));let{clientActionModule:s,clientLoaderModule:i,clientMiddlewareModule:o,hydrateFallbackModule:l,module:c}=r,d=[...s?[{module:s,varName:"".concat(a,"_clientAction")}]:[],...i?[{module:i,varName:"".concat(a,"_clientLoader")}]:[],...o?[{module:o,varName:"".concat(a,"_clientMiddleware")}]:[],...l?[{module:l,varName:"".concat(a,"_HydrateFallback")}]:[],{module:c,varName:"".concat(a,"_main")}];return 1===d.length?"import * as ".concat(a," from ").concat(JSON.stringify(c),";"):[d.map(e=>"import * as ".concat(e.varName,' from "').concat(e.module,'";')).join("\n"),"const ".concat(a," = {").concat(d.map(e=>"...".concat(e.varName)).join(","),"};")].join("\n")}).join("\n"),"\n ").concat(g?"window.__reactRouterManifest = ".concat(JSON.stringify(function(e,t){let{sri:n}=e,a=T(e,zo),r=new Set(t.state.matches.map(e=>e.route.id)),s=t.state.location.pathname.split("/").filter(Boolean),i=["/"];for(s.pop();s.length>0;)i.push("/".concat(s.join("/"))),s.pop();i.forEach(e=>{let n=ol(t.routes,e,t.basename||"/",!1,t.branches);n&&n.forEach(e=>r.add(e.route.id))});let o=[...r].reduce((e,t)=>Object.assign(e,{[t]:a.routes[t]}),{});return d(d({},a),{},{routes:o,sri:!!n||void 0})}(t,c),null,2),";"):"","\n window.__reactRouterRouteModules = {").concat(x.map((e,t)=>"".concat(JSON.stringify(e.route.id),":route").concat(t)).join(","),"};\n\nimport(").concat(JSON.stringify(t.entry.module),");"):" ";return a.createElement(a.Fragment,null,a.createElement("script",d(d({},e),{},{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:s},type:void 0})),a.createElement("script",d(d({},e),{},{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:i},type:"module",async:!0})))},[]),b=sd||p?[]:[...new Set(t.entry.imports.concat(Yc(x,t,{includeHydrateFallback:!0})))],y="object"===typeof t.sri?t.sri:{};return Nc(!p,"The <Scripts /> element is a no-op when using RSC and can be safely removed."),sd||p?null:a.createElement(a.Fragment,null,"object"===typeof t.sri?a.createElement("script",d(d({},e),{},{"rr-importmap":"",type:"importmap",suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:JSON.stringify({integrity:y})}})):null,g?null:a.createElement("link",{rel:"modulepreload",href:t.url,crossOrigin:e.crossOrigin,integrity:y[t.url],nonce:e.nonce,suppressHydrationWarning:!0}),a.createElement("link",{rel:"modulepreload",href:t.entry.module,crossOrigin:e.crossOrigin,integrity:y[t.entry.module],nonce:e.nonce,suppressHydrationWarning:!0}),b.map(t=>a.createElement("link",{key:t,rel:"modulepreload",href:t,crossOrigin:e.crossOrigin,integrity:y[t],nonce:e.nonce,suppressHydrationWarning:!0})),f)}function od(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return e=>{t.forEach(t=>{"function"===typeof t?t(e):null!=t&&(t.current=e)})}}a.Component;function ld(e){let{error:t,isOutsideRemixApp:n}=e,{nonce:r}=Qc();console.error(t);let s,i=a.createElement("script",{nonce:r,dangerouslySetInnerHTML:{__html:'\n console.log(\n "\ud83d\udcbf Hey developer \ud83d\udc4b. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."\n );\n '}});if(Ll(t))return a.createElement(cd,{title:"Unhandled Thrown Response!"},a.createElement("h1",{style:{fontSize:"24px"}},t.status," ",t.statusText),i);if(t instanceof Error)0;else{let e=null==t?"Unknown Error":"object"===typeof t&&"toString"in t?t.toString():JSON.stringify(t);new Error(e)}return a.createElement(cd,{title:"Application Error!",isOutsideRemixApp:n},a.createElement("h1",{style:{fontSize:"24px"}},"Application Error"),a.createElement("pre",{style:{padding:"2rem",background:"hsla(10, 50%, 50%, 0.1)",color:"red",overflow:"auto"}},s.stack),i)}function cd(e){var t;let{title:n,renderScripts:r,isOutsideRemixApp:s,children:i}=e,{routeModules:o}=Qc();return null!==o.root&&void 0!==t&&t.Layout&&!s?i:a.createElement("html",{lang:"en"},a.createElement("head",null,a.createElement("meta",{charSet:"utf-8"}),a.createElement("meta",{name:"viewport",content:"width=device-width,initial-scale=1,viewport-fit=cover"}),a.createElement("title",null,n)),a.createElement("body",null,a.createElement("main",{style:{fontFamily:"system-ui, sans-serif",padding:"2rem"}},i,r?a.createElement(id,null):null)))}var dd="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement;try{dd&&(window.__reactRouterVersion="7.18.1")}catch(BH){}
2function ud(e){let{basename:t,children:n,useTransitions:r,window:s}=e,i=a.useRef();null==i.current&&(i.current=$o({window:s,v5Compat:!0}));let o=i.current,[l,c]=a.useState({action:o.action,location:o.location}),d=a.useCallback(e=>{!1===r?c(e):a.startTransition(()=>c(e))},[r]);return a.useLayoutEffect(()=>o.listen(d),[o,d]),a.createElement(Ec,{basename:t,children:n,location:l.location,navigationType:l.action,navigator:o,useTransitions:r})}var md=a.forwardRef(function(e,t){let{onClick:n,discover:r="render",prefetch:s="none",relative:i,reloadDocument:o,replace:l,mask:c,state:u,target:m,to:h,preventScrollReset:p,viewTransition:g,defaultShouldRevalidate:x}=e,f=T(e,Ho),{basename:b,navigator:y,useTransitions:v}=a.useContext(Ql),w="string"===typeof h&&Yo.test(h),k=Ol(h,b);h=k.to;let j=function(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Qo(ac(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=a.useContext(Ql),{hash:s,pathname:i,search:o}=cc(e,{relative:t}),l=i;return"/"!==n&&(l="/"===i?n:Tl([n,i])),r.createHref({pathname:l,search:o,hash:s})}(h,{relative:i}),D=rc(),C=null;if(c){let e=El(c,[],D.mask?D.mask.pathname:"/",!0);"/"!==b&&(e.pathname="/"===e.pathname?b:Tl([b,e.pathname])),C=y.createHref(e)}let[N,F,S]=function(e,t){let n=a.useContext($c),[r,s]=a.useState(!1),[i,o]=a.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:d,onMouseLeave:u,onTouchStart:m}=t,h=a.useRef(null);a.useEffect(()=>{if("render"===e&&o(!0),"viewport"===e){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return h.current&&e.observe(h.current),()=>{e.disconnect()}}},[e]),a.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{s(!0)},g=()=>{s(!1),o(!1)};return n?"intent"!==e?[i,h,{}]:[i,h,{onFocus:Zc(l,p),onBlur:Zc(c,g),onMouseEnter:Zc(d,p),onMouseLeave:Zc(u,g),onTouchStart:Zc(m,p)}]:[!1,h,{}]}(s,f),E=function(e){let{target:t,replace:n,mask:r,state:s,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c,useTransitions:d}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=oc(),m=rc(),h=cc(e,{relative:o});return a.useCallback(p=>{if(function(e,t){return 0===e.button&&(!t||"_self"===t)&&!function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)}(p,t)){p.preventDefault();let t=void 0!==n?n:nl(m)===nl(h),g=()=>u(e,{replace:t,mask:r,state:s,preventScrollReset:i,relative:o,viewTransition:l,defaultShouldRevalidate:c});d?a.startTransition(()=>g()):g()}},[m,u,h,n,r,s,t,e,i,o,l,c,d])}(h,{replace:l,mask:c,state:u,target:m,preventScrollReset:p,relative:i,viewTransition:g,defaultShouldRevalidate:x,useTransitions:v});let A=!(k.isExternal||o),M=a.createElement("a",d(d(d({},f),S),{},{href:(A?C:void 0)||k.absoluteURL||j,onClick:A?function(e){n&&n(e),e.defaultPrevented||E(e)}:n,ref:od(t,F),target:m,"data-discover":w||"render"!==r?void 0:"true"}));return N&&!w?a.createElement(a.Fragment,null,M,a.createElement(td,{page:j})):M});md.displayName="Link";var hd=a.forwardRef(function(e,t){let{"aria-current":n="page",caseSensitive:r=!1,className:s="",end:i=!1,style:o,to:l,viewTransition:c,children:u}=e,m=T(e,qo),h=cc(l,{relative:m.relative}),p=rc(),g=a.useContext(Yl),{navigator:x,basename:f}=a.useContext(Ql),b=null!=g&&function(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=a.useContext(Xl);Qo(null!=n,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=xd("useViewTransitionState"),s=cc(e,{relative:t});if(!n.isTransitioning)return!1;let i=Dl(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Dl(n.nextLocation.pathname,r)||n.nextLocation.pathname;return null!=vl(s.pathname,o)||null!=vl(s.pathname,i)}(h)&&!0===c,y=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,v=p.pathname,w=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;r||(v=v.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&f&&(w=Dl(w,f)||w);const k="/"!==y&&y.endsWith("/")?y.length-1:y.length;let j,D=v===y||!i&&v.startsWith(y)&&"/"===v.charAt(k),C=null!=w&&(w===y||!i&&w.startsWith(y)&&"/"===w.charAt(y.length)),N={isActive:D,isPending:C,isTransitioning:b},F=D?n:void 0;j="function"===typeof s?s(N):[s,D?"active":null,C?"pending":null,b?"transitioning":null].filter(
2Boolean).join(" ");let S="function"===typeof o?o(N):o;return a.createElement(md,d(d({},m),{},{"aria-current":F,className:j,ref:t,style:S,to:l,viewTransition:c}),"function"===typeof u?u(N):u)});hd.displayName="NavLink";var pd=a.forwardRef((e,t)=>{let{discover:n="render",fetcherKey:r,navigate:s,reloadDocument:i,replace:o,state:l,method:c=Mc,action:u,onSubmit:m,relative:h,preventScrollReset:p,viewTransition:g,defaultShouldRevalidate:x}=e,f=T(e,Wo),{useTransitions:b}=a.useContext(Ql),y=vd(),v=function(e){let{relative:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{basename:n}=a.useContext(Ql),r=a.useContext(ec);Qo(r,"useFormAction must be used inside a RouteContext");let[s]=r.matches.slice(-1),i=d({},cc(e||".",{relative:t})),o=rc();if(null==e){i.search=o.search;let e=new URLSearchParams(i.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let n=e.toString();i.search=n?"?".concat(n):""}}e&&"."!==e||!s.route.index||(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index");"/"!==n&&(i.pathname="/"===i.pathname?n:Tl([n,i.pathname]));return nl(i)}(u,{relative:h}),w="get"===c.toLowerCase()?"get":"post",k="string"===typeof u&&Yo.test(u);return a.createElement("form",d(d({ref:t,method:w,action:v,onSubmit:i?m:e=>{if(m&&m(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,n=(null===t||void 0===t?void 0:t.getAttribute("formmethod"))||c,i=()=>y(t||e.currentTarget,{fetcherKey:r,method:n,navigate:s,replace:o,state:l,relative:h,preventScrollReset:p,viewTransition:g,defaultShouldRevalidate:x});b&&!1!==s?a.startTransition(()=>i()):i()}},f),{},{"data-discover":k||"render"!==n?void 0:"true"}))});function gd(e){return"".concat(e," must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.")}function xd(e){let t=a.useContext(Wl);return Qo(t,gd(e)),t}function fd(e){Zo("undefined"!==typeof URLSearchParams,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=a.useRef(Ic(e)),n=a.useRef(!1),r=rc(),s=a.useMemo(()=>function(e,t){let n=Ic(e);return t&&t.forEach((e,a)=>{n.has(a)||t.getAll(a).forEach(e=>{n.append(a,e)})}),n}(r.search,n.current?null:t.current),[r.search]),i=oc(),o=a.useCallback((e,t)=>{const a=Ic("function"===typeof e?e(new URLSearchParams(s)):e);n.current=!0,i("?"+a,t)},[i,s]);return[s,o]}pd.displayName="Form";var bd=0,yd=()=>"__".concat(String(++bd),"__");function vd(){let{router:e}=xd("useSubmit"),{basename:t}=a.useContext(Ql),n=wc("useRouteId"),r=e.fetch,s=e.navigate;return a.useCallback(async function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{action:i,method:o,encType:l,formData:c,body:d}=zc(e,t);if(!1===a.navigate){let e=a.fetcherKey||yd();await r(e,n,a.action||i,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:c,body:d,formMethod:a.method||o,formEncType:a.encType||l,flushSync:a.flushSync})}else await s(a.action||i,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:c,body:d,formMethod:a.method||o,formEncType:a.encType||l,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,s,t,n])}const wd=Mo("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);function kd(e){let{enabled:t,onChange:n,disabled:a=!1,contextLabel:r}=e;const s=t?"Correction-rule keyterms on: proper nouns from rules for ".concat(r||"inferred context"," are sent to Deepgram. Your own keyterms always apply."):"Correction-rule keyterms off: only your own keyterms are sent. Use for an unrelated recording or an ASR comparison.";return(0,u.jsxs)("button",{type:"button",role:"switch","aria-checked":t,"aria-label":"Correction-rule keyterms",title:s,disabled:a,onClick:()=>null===n||void 0===n?void 0:n(!t),className:"inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 font-headlines text-[11px] font-semibold tracking-normal normal-case transition focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-500/60 disabled:cursor-not-allowed disabled:opacity-50 ".concat(t?"border-accent-500/50 bg-accent-500/15 text-accent-800 dark:border-accent-500/40 dark:bg-accent-500/10 dark:text-accent-300":"border-primary-200 bg-brand-cloud/60 text-primary-400 dark:border-primary-500/60 dark:bg-primary-800/60 dark:text-primary-300"),children:[(0,u.jsx)(Po,{className:"h-3.5 w-3.5","aria-hidden":"true"}),(0,u.jsx)("span",{children:"Rule keyterms"}),(0,u.jsx)("span",{"aria-hidden":"true",className:"relative inline-block h-3.5 w-6 rounded-full transition ".concat(t?"bg-accent-500":"bg-primary-200 dark:bg-primary-500"),children:(0,u.jsx)("span",{className:"absolute top-0.5 h-2.5 w-2.5 rounded-full bg-brand-cloud shadow transition-all ".concat(t?"left-3":"left-0.5")})})]})}const jd={malformed_settings:"settings could not be read",context_unavailable:"context unavailable",rules_unavailable:"rules unavailable",timeout:"lookup timed out"};function Dd(e){var t,n,r,s,i;let{audit:o}=e;const[l,c]=(0,a.useState)(!1);if(!o)return null;const d=o.keyterms||{},m=d.sent||[],h=d.skipped||[],p=null!==(t=d.sentCount)&&void 0!==t?t:m.length,g=null===(n=o.rules)||void 0===n?void 0:n.remainingCorrections,x=null===(r=o.rulesKeyterms)||void 0===r?void 0:r.status,f="skipped"===x?jd[(null===(s=o.rulesKeyterms)||void 0===s?void 0:s.reason)||""]||"skipped":null,b=(o.scopeChain||[]).map(e=>
2e.scopeKey||e.scope).filter(Boolean),y="".concat(p," keyterm").concat(1===p?"":"s"," sent \xb7 ").concat(null!==g&&void 0!==g?g:"?"," remaining correction").concat(1===g?"":"s");return(0,u.jsxs)("section",{"aria-label":"Correction-rule keyterms audit",className:"my-2 rounded-2xl border border-primary-100 bg-white/60 text-xs text-primary-600 backdrop-blur-xl dark:border-white/10 dark:bg-white/5 dark:text-brand-cloud",children:[(0,u.jsxs)("button",{type:"button","aria-expanded":l,onClick:()=>c(e=>!e),title:"Correction-rule keyterms sent with this transcription and the dry-run corrections still to apply",className:"flex w-full items-center gap-2 px-3 py-2 text-left font-headlines font-semibold focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-500/60",children:[(0,u.jsx)(Po,{className:"h-3.5 w-3.5 text-accent-700 dark:text-accent-400","aria-hidden":"true"}),(0,u.jsx)("span",{children:"Rule keyterms"}),(0,u.jsx)("span",{className:"font-normal text-primary-400 dark:text-primary-200",children:y}),f&&(0,u.jsxs)("span",{className:"rounded-full bg-accent-500/15 px-2 py-0.5 font-normal text-accent-800 dark:bg-accent-500/10 dark:text-accent-300",children:["Automatic keyterms skipped: ",f]}),"disabled"===x&&(0,u.jsx)("span",{className:"rounded-full bg-primary-100 px-2 py-0.5 font-normal text-primary-500 dark:bg-primary-700 dark:text-primary-200",children:"Off"}),(0,u.jsx)(wd,{"aria-hidden":"true",className:"ml-auto h-3.5 w-3.5 transition-transform ".concat(l?"rotate-180":"")})]}),l&&(0,u.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 border-t border-primary-100 px-3 py-2 dark:border-white/10",children:[b.length>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("dt",{className:"text-primary-400 dark:text-primary-200",children:"Context"}),(0,u.jsx)("dd",{className:"break-words",children:b.join(" \xb7 ")})]}),(0,u.jsx)("dt",{className:"text-primary-400 dark:text-primary-200",children:"Sent"}),(0,u.jsx)("dd",{className:"break-words",children:m.join(", ")||"none"}),(0,u.jsxs)("dt",{className:"text-primary-400 dark:text-primary-200",children:["Dropped (",null!==(i=d.droppedCount)&&void 0!==i?i:h.length,")"]}),(0,u.jsx)("dd",{className:"break-words",children:h.map(e=>e.term).join(", ")||"none"})]})]})}var Cd=n(942);function Nd(e,t,n,a){return new(n||(n=Promise))(function(r,s){function i(e){try{l(a.next(e))}catch(BH){s(BH)}}function o(e){try{l(a.throw(e))}catch(BH){s(BH)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,o)}l((a=a.apply(e,t||[])).next())})}Object.create;Object.create;"function"===typeof SuppressedError&&SuppressedError;const Fd
vendor: 41,169 bytes, line 2
2=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function S
2d(e,t,n){const a=function(e){const{name:t}=e;if(t&&-1!==t.lastIndexOf(".")&&!e.type){const n=t.split(".").pop().toLowerCase(),a=Fd.get(n);a&&Object.defineProperty(e,"type",{value:a,writable:!1,configurable:!1,enumerable:!0})}return e}(e),{webkitRelativePath:r}=e,s="string"===typeof t?t:"string"===typeof r&&r.length>0?r:"./".concat(e.name);return"string"!==typeof a.path&&Ed(a,"path",s),void 0!==n&&Object.defineProperty(a,"handle",{value:n,writable:!1,configurable:!1,enumerable:!0}),Ed(a,"relativePath",s),a}function Ed(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}const Ad=[".DS_Store","Thumbs.db"];function Td(e){return"object"===typeof e&&null!==e}function Md(e){return e.filter(e=>-1===Ad.indexOf(e.name))}function _d(e){if(null===e)return[];const t=[];for(let n=0;n<e.length;n++){const a=e[n];t.push(a)}return t}function Bd(e){if("function"!==typeof e.webkitGetAsEntry)return Pd(e);const t=e.webkitGetAsEntry();return t&&t.isDirectory?Rd(t):Pd(e,t)}function Id(e){return e.reduce((e,t)=>[...e,...Array.isArray(t)?Id(t):[t]],[])}function Pd(e,t){return Nd(this,void 0,void 0,function*(){var n;if(globalThis.isSecureContext&&"function"===typeof e.getAsFileSystemHandle){const t=yield e.getAsFileSystemHandle();if(null===t)throw new Error("".concat(e," is not a File"));if(void 0!==t){const e=yield t.getFile();return e.handle=t,Sd(e)}}const a=e.getAsFile();if(!a)throw new Error("".concat(e," is not a File"));return Sd(a,null!==(n=null===t||void 0===t?void 0:t.fullPath)&&void 0!==n?n:void 0)})}function Ld(e){return Nd(this,void 0,void 0,function*(){return e.isDirectory?Rd(e):function(e){return Nd(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(n=>{const a=Sd(n,e.fullPath);t(a)},e=>{n(e)})})})}(e)})}function Rd(e){const t=e.createReader();
2return new Promise((e,n)=>{const a=[];!function r(){t.readEntries(t=>Nd(this,void 0,void 0,function*(){if(t.length){const e=Promise.all(t.map(Ld));a.push(e),r()}else try{const t=yield Promise.all(a);e(t)}catch(s){n(s)}}),e=>{n(e)})}()})}var zd=n(189);function Od(e){return function(e){if(Array.isArray(e))return Yd(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Wd(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ud(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function Vd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ud(Object(n),!0).forEach(function(t){Hd(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ud(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Hd(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qd(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var a,r,s=[],i=!0,o=!1;try{for(n=n.call(e);!(i=(a=n.next()).done)&&(s.push(a.value),!t||s.length!==t);i=!0);}catch(l){o=!0,r=l}finally{try{i||null==n.return||n.return()}finally{if(o)throw r}}return s}(e,t)||Wd(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Wd(e,t){if(e){if("string"===typeof e)return Yd(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yd(e,t):void 0}}function Yd(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}var Gd="function"===typeof zd?zd:zd.default,Kd="file-invalid-type",Xd="file-too-large",Jd="file-too-small",$d="too-many-files",Qd=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split(","),t=e.length>1?"one of ".concat(e.join(", ")):e[0];return{code:Kd,message:"File type must be ".concat(t)}},Zd=function(e){return{code:Xd,message:"File is larger than ".concat(e," ").concat(1===e?"byte":"bytes")}},eu=function(e){return{code:Jd,message:"File is smaller than ".concat(e," ").concat(1===e?"byte":"bytes")}},tu={code:$d,message:"Too many files"};function nu(e,t){var n="application/x-moz-file"===e.type||Gd(e,t);return[n,n?null:Qd(t)]}function au(e,t,n){if(ru(e.size))if(ru(t)&&ru(n)){if(e.size>n)return[!1,Zd(n)];if(e.size<t)return[!1,eu(t)]}else{if(ru(t)&&e.size<t)return[!1,eu(t)];if(ru(n)&&e.size>n)return[!1,Zd(n)]}return[!0,null]}function ru(e){return void 0!==e&&null!==e}function su(e){return"function"===typeof e.isPropagationStopped?e.isPropagationStopped():"undefined"!==typeof e.cancelBubble&&e.cancelBubble}function iu(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(e){return"Files"===e||"application/x-moz-file"===e}):!!e.target&&!!e.target.files}function ou(e){e.preventDefault()}function lu(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),r=1;r<n;r++)a[r-1]=arguments[r];return t.some(function(t){return!su(e)&&t&&t.apply(void 0,[e].concat(a)),su(e)})}}function cu(e){return"audio/*"===e||"video/*"===e||"image/*"===e||"text/*"===e||"application/*"===e||/\w+\/[-+.\w]+/g.test(e)}function du(e){return/^.*\.[\w]+$/.test(e)}var uu=["children"],mu=["open"],hu=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],pu=["refKey","onChange","onClick"];function gu(e){return function(e){if(Array.isArray(e))return bu(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||fu(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function xu(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var a,r,s=[],i=!0,o=!1;try{for(n=n.call(e);!(i=(a=n.next()).done)&&(s.push(a.value),!t||s.length!==t);i=!0);}catch(l){o=!0,r=l}finally{try{i||null==n.return||n.return()}finally{if(o)throw r}}return s}(e,t)||fu(e,t)||function(){throw new TypeError("Invalid attempt to de
2structure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function fu(e,t){if(e){if("string"===typeof e)return bu(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bu(e,t):void 0}}function bu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function yu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function vu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?yu(Object(n),!0).forEach(function(t){wu(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wu(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ku(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},s=Object.keys(e);for(a=0;a<s.length;a++)n=s[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)n=s[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var ju=(0,a.forwardRef)(function(e,t){var n=e.children,r=Nu(ku(e,uu)),s=r.open,i=ku(r,mu);return(0,a.useImperativeHandle)(t,function(){return{open:s}},[s]),a.createElement(a.Fragment,null,n(vu(vu({},i),{},{open:s})))});ju.displayName="Dropzone";var Du={disabled:!1,getFilesFromEvent:function(e){return Nd(this,void 0,void 0,function*(){return Td(e)&&Td(e.dataTransfer)?function(e,t){return Nd(this,void 0,void 0,function*(){if(e.items){const n=_d(e.items).filter(e=>"file"===e.kind);if("drop"!==t)return n;return Md(Id(yield Promise.all(n.map(Bd))))}return Md(_d(e.files).map(e=>Sd(e)))})}(e.dataTransfer,e.type):function(e){return Td(e)&&Td(e.target)}(e)?function(e){return _d(e.target.files).map(e=>Sd(e))}(e):Array.isArray(e)&&e.every(e=>"getFile"in e&&"function"===typeof e.getFile)?function(e){return Nd(this,void 0,void 0,function*(){return(yield Promise.all(e.map(e=>e.getFile()))).map(e=>Sd(e))})}(e):[]})},maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};ju.defaultProps=Du,ju.propTypes={children:Cd.func,accept:Cd.objectOf(Cd.arrayOf(Cd.string)),multiple:Cd.bool,preventDropOnDocument:Cd.bool,noClick:Cd.bool,noKeyboard:Cd.bool,noDrag:Cd.bool,noDragEventsBubbling:Cd.bool,minSize:Cd.number,maxSize:Cd.number,maxFiles:Cd.number,disabled:Cd.bool,getFilesFromEvent:Cd.func,onFileDialogCancel:Cd.func,onFileDialogOpen:Cd.func,useFsAccessApi:Cd.bool,autoFocus:Cd.bool,onDragEnter:Cd.func,onDragLeave:Cd.func,onDragOver:Cd.func,onDrop:Cd.func,onDropAccepted:Cd.func,onDropRejected:Cd.func,onError:Cd.func,validator:Cd.func};var Cu={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function Nu(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=vu(vu({},Du),e),n=t.accept,r=t.disabled,s=t.getFilesFromEvent,i=t.maxSize,o=t.minSize,l=t.multiple,c=t.maxFiles,d=t.onDragEnter,u=t.onDragLeave,m=t.onDragOver,h=t.onDrop,p=t.onDropAccepted,g=t.onDropRejected,x=t.onFileDialogCancel,f=t.onFileDialogOpen,b=t.useFsAccessApi,y=t.autoFocus,v=t.preventDropOnDocument,w=t.noClick,k=t.noKeyboard,j=t.noDrag,D=t.noDragEventsBubbling,C=t.onError,N=t.validator,F=(0,a.useMemo)(function(){return function(e){if(ru(e))return Object.entries(e).reduce(function(e,t){var n=qd(t,2),a=n[0],r=n[1];return[].concat(Od(e),[a],Od(r))},[]).filter(function(e){return cu(e)||du(e)}).join(",")}(n)},[n]),S=(0,a.useMemo)(function(){return function(e){if(ru(e)){var t=Object.entries(e).filter(function(e){var t=qd(e,2),n=t[0],a=t[1],r=!0;return cu(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),r=!1),Array.isArray(a)&&a.every(du)||(console.warn('Skipped "'.concat(n,'" because an invali
2d file extension was provided.')),r=!1),r}).reduce(function(e,t){var n=qd(t,2),a=n[0],r=n[1];return Vd(Vd({},e),{},Hd({},a,r))},{});return[{description:"Files",accept:t}]}return e}(n)},[n]),E=(0,a.useMemo)(function(){return"function"===typeof f?f:Su},[f]),A=(0,a.useMemo)(function(){return"function"===typeof x?x:Su},[x]),T=(0,a.useRef)(null),M=(0,a.useRef)(null),_=xu((0,a.useReducer)(Fu,Cu),2),B=_[0],I=_[1],P=B.isFocused,L=B.isFileDialogActive,R=(0,a.useRef)("undefined"!==typeof window&&window.isSecureContext&&b&&"showOpenFilePicker"in window),z=function(){!R.current&&L&&setTimeout(function(){M.current&&(M.current.files.length||(I({type:"closeDialog"}),A()))},300)};(0,a.useEffect)(function(){return window.addEventListener("focus",z,!1),function(){window.removeEventListener("focus",z,!1)}},[M,L,A,R]);var O=(0,a.useRef)([]),U=function(e){T.current&&T.current.contains(e.target)||(e.preventDefault(),O.current=[])};(0,a.useEffect)(function(){return v&&(document.addEventListener("dragover",ou,!1),document.addEventListener("drop",U,!1)),function(){v&&(document.removeEventListener("dragover",ou),document.removeEventListener("drop",U))}},[T,v]),(0,a.useEffect)(function(){return!r&&y&&T.current&&T.current.focus(),function(){}},[T,y,r]);var V=(0,a.useCallback)(function(e){C?C(e):console.error(e)},[C]),H=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),ne(e),O.current=[].concat(gu(O.current),[e.target]),iu(e)&&Promise.resolve(s(e)).then(function(t){if(!su(e)||D){var n=t.length,a=n>0&&function(e){var t=e.files,n=e.accept,a=e.minSize,r=e.maxSize,s=e.multiple,i=e.maxFiles,o=e.validator;return!(!s&&t.length>1||s&&i>=1&&t.length>i)&&t.every(function(e){var t=qd(nu(e,n),1)[0],s=qd(au(e,a,r),1)[0],i=o?o(e):null;return t&&s&&!i})}({files:t,accept:F,minSize:o,maxSize:i,multiple:l,maxFiles:c,validator:N});I({isDragAccept:a,isDragReject:n>0&&!a,isDragActive:!0,type:"setDraggedFiles"}),d&&d(e)}}).catch(function(e){return V(e)})},[s,d,V,D,F,o,i,l,c,N]),q=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),ne(e);var t=iu(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect="copy"}catch(_H){}return t&&m&&m(e),!1},[m,D]),W=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),ne(e);var t=O.current.filter(function(e){return T.current&&T.current.contains(e)}),n=t.indexOf(e.target);-1!==n&&t.splice(n,1),O.current=t,t.length>0||(I({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),iu(e)&&u&&u(e))},[T,u,D]),Y=(0,a.useCallback)(function(e,t){var n=[],a=[];e.forEach(function(e){var t=xu(nu(e,F),2),r=t[0],s=t[1],l=xu(au(e,o,i),2),c=l[0],d=l[1],u=N?N(e):null;if(r&&c&&!u)n.push(e);else{var m=[s,d];u&&(m=m.concat(u)),a.push({file:e,errors:m.filter(function(e){return e})})}}),(!l&&n.length>1||l&&c>=1&&n.length>c)&&(n.forEach(function(e){a.push({file:e,errors:[tu]})}),n.splice(0)),I({acceptedFiles:n,fileRejections:a,isDragReject:a.length>0,type:"setFiles"}),h&&h(n,a,t),a.length>0&&g&&g(a,t),n.length>0&&p&&p(n,t)},[I,l,F,o,i,c,h,p,g,N]),G=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),ne(e),O.current=[],iu(e)&&Promise.resolve(s(e)).then(function(t){su(e)&&!D||Y(t,e)}).catch(function(e){return V(e)}),I({type:"reset"})},[s,Y,V,D]),K=(0,a.useCallback)(function(){if(R.current){I({type:"openDialog"}),E();var e={multiple:l,types:S};window.showOpenFilePicker(e).then(function(e){return s(e)}).then(function(e){Y(e,null),I({type:"closeDialog"})}).catch(function(e){var t;(t=e)instanceof DOMException&&("AbortError"===t.name||t.code===t.ABORT_ERR)?(A(e),I({type:"closeDialog"})):!function(e){return e instanceof DOMException&&("SecurityError"===e.name||e.code===e.SECURITY_ERR)}(e)?V(e):(R.current=!1,M.current?(M.current.value=null,M.current.click()):V(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided.")))})}else M.current&&(I({type:"openDialog"}),E(),M.current.value=null,M.current.click())},[I,E,A,b,Y,V,S,l]),X=(0,a.useCallback)(function(e){T.current&&T.current.isEqualNode(e.target)&&(" "!==e.key&&"Enter"!==e.key&&32!==e.keyCode&&13!==e.keyCode||(e.preventDefault(),K()))},[T,K]),J=(0,a.useCallback)(function(){I({type:"focus"})},[]),$=(0,a.useCallback)(function(){I({type:"blur"})},[]),Q=(0,a.useCallback)(function(){w||(!function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.navigator.userAgent;return function(e){return-1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")}(e)||function(e){return-1!==e.indexOf("Edge/")}(e)}
2()?K():setTimeout(K,0))},[w,K]),Z=function(e){return r?null:e},ee=function(e){return k?null:Z(e)},te=function(e){return j?null:Z(e)},ne=function(e){D&&e.stopPropagation()},ae=(0,a.useMemo)(function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refKey,n=void 0===t?"ref":t,a=e.role,s=e.onKeyDown,i=e.onFocus,o=e.onBlur,l=e.onClick,c=e.onDragEnter,d=e.onDragOver,u=e.onDragLeave,m=e.onDrop,h=ku(e,hu);return vu(vu(wu({onKeyDown:ee(lu(s,X)),onFocus:ee(lu(i,J)),onBlur:ee(lu(o,$)),onClick:Z(lu(l,Q)),onDragEnter:te(lu(c,H)),onDragOver:te(lu(d,q)),onDragLeave:te(lu(u,W)),onDrop:te(lu(m,G)),role:"string"===typeof a&&""!==a?a:"presentation"},n,T),r||k?{}:{tabIndex:0}),h)}},[T,X,J,$,Q,H,q,W,G,k,j,r]),re=(0,a.useCallback)(function(e){e.stopPropagation()},[]),se=(0,a.useMemo)(function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refKey,n=void 0===t?"ref":t,a=e.onChange,r=e.onClick,s=ku(e,pu);return vu(vu({},wu({accept:F,multiple:l,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:Z(lu(a,G)),onClick:Z(lu(r,re)),tabIndex:-1},n,M)),s)}},[M,n,l,G,r]);return vu(vu({},B),{},{isFocused:P&&!r,getRootProps:ae,getInputProps:se,rootRef:T,inputRef:M,open:Z(K)})}function Fu(e,t){switch(t.type){case"focus":return vu(vu({},e),{},{isFocused:!0});case"blur":return vu(vu({},e),{},{isFocused:!1});case"openDialog":return vu(vu({},Cu),{},{isFileDialogActive:!0});case"closeDialog":return vu(vu({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return vu(vu({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return vu(vu({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:t.isDragReject});case"reset":return vu({},Cu);default:return e}}function Su(){}const Eu=Mo("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]),Au=Mo("youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),Tu=Mo("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]),Mu=Mo("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),_u=Mo("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]),Bu=Mo("clapperboard",[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]]),Iu=Mo("file",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]),Pu=Mo("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Lu=Mo("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),Ru=(0,a.createContext)(void 0),zu=()=>{const e=(0,a.useContext)(Ru);if(void 0===e)throw new Error("useDarkMode must be used within a DarkModeProvider");return e},Ou="mlst-dark-mode",Uu=e=>{let{children:t}=e;const[n,r]=(0,a.useState)(!1);(0,a.useEffect)(()=>{const e=Hu(Ou);if("true"===e)r(!0),document.documentElement.classList.add("dark");else if("false"===e)r(!1),document.documentElement.classList.remove("dark");else{const e=window.matchMedia("(prefers-color-scheme: dark)").matches;r(e),e&&document.documentElement.classList.add("dark")}},[]);return(0,u.jsx)(Ru.Provider,{value:{isDarkMode:n,toggleDarkMode:()=>{const e=!n;r(e),e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"),Vu(Ou,e.toString(),365)}},children:t})},Vu=(e,t,n)=>{const a=new Date;a.setTime(a.getTime()+24*n*60*60*1e3),document.cookie="".concat(e,"=").concat(t,";expires=").concat(a.toUTCString(),";path=/;SameSite=Strict")},Hu=e=>{const t=e+"=",n=document.cookie.split(";");for(let a=0;a<n.length;a++){let e=n[a];for(;" "===e.charAt(0);)e=e.substring(1,e.length);if(0===e.indexOf(t))return e.substring(t.length,e.length)}return null};
2class qu extends Error{constructor(e){super(e),this.name="FetchTimeoutError"}}async function Wu(e,t,n,a){let r=null;const s=new Promise((e,t)=>{r=window.setTimeout(()=>{t(new qu(a))},n)});try{return await Promise.race([fetch(e,t),s])}finally{null!==r&&window.clearTimeout(r)}}const Yu=[1500,5e3,12e3],Gu=[300,1e3],Ku="rescript.signedInHint",Xu=e=>new Promise(t=>{window.setTimeout(t,e)});function Ju(e){return 401===e||403===e}function $u(){try{return"1"===window.localStorage.getItem(Ku)}catch(_H){return!1}}function Qu(e){try{e?window.localStorage.setItem(Ku,"1"):window.localStorage.removeItem(Ku)}catch(t){}}const Zu=(0,a.createContext)(void 0),em={NODE_ENV:"production",PUBLIC_URL:"https://files.rescript.info",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_GOOGLE_CLIENT_ID:"650914284514-arrnrmrkrk8r37chamjmk7ta7tfj5nuk.apps.googleusercontent.com"}.REACT_APP_API_URL||"",tm="cookie-session",nm=e=>{let{children:t}=e;const[n,r]=(0,a.useState)(null),[s,i]=(0,a.useState)(null),[o,l]=(0,a.useState)(!0);(0,a.useEffect)(()=>{localStorage.removeItem("authToken");const e=window.fetch.bind(window);return window.fetch=(t,n)=>{const a="string"===typeof t?t:t instanceof URL?t.toString():t.url;if(!(a.startsWith("/api/")||em&&a.startsWith(em)))return e(t,n);const r=new Headers((null===n||void 0===n?void 0:n.headers)||(t instanceof Request?t.headers:void 0));return r.get("Authorization")==="Bearer ".concat(tm)&&r.delete("Authorization"),e(t,d(d({},n),{},{headers:r,credentials:(null===n||void 0===n?void 0:n.credentials)||"include"}))},()=>{window.fetch=e}},[]);const c=async()=>{try{l(!0);const e=await async function(e){const t=e.timeoutsMs||Yu,n=e.retryDelaysMs||Gu,a=e.wait||Xu,r=e.hadSession&&!e.offline?t.length:1;let s=null;for(let l=0;l<r;l+=1){try{const n=await e.fetchProfile(t[l]);if(n.ok){const e=await n.json();return null!==e&&void 0!==e&&e.user?{kind:"signed-in",user:e.user}:{kind:"signed-out",status:n.status}}if(Ju(n.status))return{kind:"signed-out",status:n.status};s=new Error("HTTP ".concat(n.status))}catch(o){s=o}var i;l<r-1&&await a(null!==(i=n[Math.min(l,n.length-1)])&&void 0!==i?i:1e3)}return{kind:"unreachable",error:s,attempts:r}}({fetchProfile:e=>Wu("".concat(em,"/api/auth/me"),{cache:"no-store",credentials:"include"},e,"Timed out while refreshing the signed-in session"),hadSession:$u(),offline:"undefined"!==typeof navigator&&!1===navigator.onLine});if("signed-in"===e.kind)return r(tm),i(e.user),void Qu(!0);"signed-out"===e.kind?Qu(!1):console.error("[AUTH] Session check unreachable after ".concat(e.attempts," attempt(s):"),e.error),r(null),i(null)}catch(e){console.error("[AUTH] Failed to refresh session:",e),r(null),i(null)}finally{l(!1)}};(0,a.useEffect)(()=>{c()},[]);const m=!!n;return(0,u.jsx)(Zu.Provider,{value:{token:n,user:s,login:async e=>{if(null!==e&&void 0!==e&&e.user)return Qu(!0),r(tm),i(e.user),void l(!1);await c()},logout:async()=>{try{await fetch("".concat(em,"/api/auth/logout"),{method:"POST",credentials:"include"})}catch(e){console.error("[AUTH] Logout request failed:",e)}Qu(!1),r(null),i(null),l(!1)},isAuthenticated:m,isLoading:o},children:t})},am=()=>{const e=(0,a.useContext)(Zu);if(void 0===e)throw new Error("useAuth must be used within an AuthProvider");return e},rm="/api/v1";function sm(e){if(void 0===e||null===e)return null;const t=String(e).trim();return t.length>0?t:null}function im(e){if(void 0===e||null===e||""===e)return null;const t=Number(e);return Number.isFinite(t)?t:null}function om(e){var t,n,a,r,s,i,o,l,c,d,u,m,h,p;const g=String(null!==(t=null!==(n=null!==(a=e.text)&&void 0!==a?a:e.questionText)&&void 0!==n?n:e.question_text)&&void 0!==t?t:"").trim(),x=sm(null!==(r=null!==(s=null!==(i=e.context)&&void 0!==i?i:e.contextText)&&void 0!==s?s:e.context_text)&&void 0!==r?r:e.notes);return{id:e.id,episodeId:e.episodeId||e.session_id||"",text:g,questionText:g,askedBy:sm(null!==(o=null!==(l=e.askedBy)&&void 0!==l?l:e.asked_by)&&void 0!==o?o:e.source),questionType:"implicit"===sm(null!==(c=e.questionType)&&void 0!==c?c:e.question_type)?"implicit":"explicit",topic:sm(null!==(d=e.topic)&&void 0!==d?d:e.category),context:x,contextText:x,answerSummary:sm(null!==(u=e.answerSummary)&&void 0!==u?u:e.answer_summary),timestampSeconds:im(null!==(m=e.timestampSeconds)&&void 0!==m?m:e.timestamp_seconds),timecode:sm(e.timeco
2de),sortOrder:null!==(h=im(null!==(p=e.sortOrder)&&void 0!==p?p:e.sort_order))&&void 0!==h?h:0,createdAt:e.createdAt||e.created_at||"",updatedAt:e.updatedAt||e.updated_at||e.createdAt||e.created_at||""}}const lm=new Map,cm=new Map;function dm(e,t,n){return lm.set(e,{value:t,expiresAt:Date.now()+n}),t}async function um(e,t,n){const a=function(e){const t=lm.get(e);if(t){if(!(t.expiresAt<=Date.now()))return t.value;lm.delete(e)}}(e);if(a)return a;const r=cm.get(e);if(r)return r;const s=n().then(n=>dm(e,n,t)).finally(()=>{cm.delete(e)});return cm.set(e,s),s}function mm(e){var t,n,a,r,s,i,o,l,c,u,m;const h=om(e);return d(d({},h),{},{sessionTitle:String(e.sessionTitle||e.session_title||"").trim()||h.episodeId,showSlug:sm(null!==(t=e.showSlug)&&void 0!==t?t:e.show_slug),showTitle:sm(null!==(n=e.showTitle)&&void 0!==n?n:e.show_title),familySlug:sm(null!==(a=e.familySlug)&&void 0!==a?a:e.family_slug),familyTitle:sm(null!==(r=e.familyTitle)&&void 0!==r?r:e.family_title),familyVersionNumber:im(null!==(s=e.familyVersionNumber)&&void 0!==s?s:e.family_version_number),youtubeUrl:sm(null!==(i=e.youtubeUrl)&&void 0!==i?i:e.youtube_url),publishedToHomepage:Boolean(null!==(o=e.publishedToHomepage)&&void 0!==o?o:e.published_to_homepage),sessionUpdatedAt:sm(null!==(l=e.sessionUpdatedAt)&&void 0!==l?l:e.session_updated_at),publishedAt:sm(null!==(c=e.publishedAt)&&void 0!==c?c:e.published_at),shareToken:sm(null!==(u=e.shareToken)&&void 0!==u?u:e.share_token),publicUrl:sm(null!==(m=e.publicUrl)&&void 0!==m?m:e.public_url)})}function hm(e){const t=sm(null===e||void 0===e?void 0:e.slug),n=sm(null===e||void 0===e?void 0:e.title),a=sm(null===e||void 0===e?void 0:e.name),r=Number((null===e||void 0===e?void 0:e.count)||0);return t||a?{slug:t||void 0,title:n||void 0,name:a||void 0,count:r}:null}function pm(e){const t=new URLSearchParams;Object.entries(e).forEach(e=>{let[n,a]=e;void 0!==a&&null!==a&&""!==a&&t.set(n,String(a))});const n=t.toString();return n?"?".concat(n):""}async function gm(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=d({},n.headers||{});t&&(a.Authorization="Bearer ".concat(t)),n.body instanceof FormData||a["Content-Type"]||(a["Content-Type"]="application/json");const r=await fetch(e,d(d({},n),{},{headers:a}));if(!r.ok){const e=await r.json().catch(()=>({error:r.statusText}));throw new Error(e.error||e.message||"Request failed: ".concat(r.status))}return r}async function xm(e,t){return um("auth:".concat(e),5e3,async()=>{const n=await gm("".concat(rm,"/episodes/").concat(e,"/questions"),t),a=await n.json();return d(d({},a),{},{questions:Array.isArray(a.questions)?a.questions.map(om):[]})})}async function fm(e){return um("public:".concat(e),1e4,async()=>{const t=await fetch("".concat("/api","/public/share/").concat(e,"/questions"),{cache:"no-store",credentials:"omit"});if(!t.ok){const e=await t.json().catch(()=>({error:t.statusText}));throw new Error(e.error||e.message||"Request failed: ".concat(t.status))}const n=await t.json();return d(d({},n),{},{questions:Array.isArray(n.questions)?n.questions.map(om):[],pagination:n.pagination||{limit:n.total||0,offset:0,hasMore:!1}})})}const bm=e=>{const t=Number(e);return Number.isFinite(t)?t:null},ym=e=>{if(null==e)return null;return String(e).trim()||null},vm=e=>{if(null==e)return null;if("object"===typeof e&&!Array.isArray(e)){var t;const n=ym(null===e||void 0===e?void 0:e.status);if(n)return n;const a=ym(null!==(t=null===e||void 0===e?void 0:e.layoutMode)&&void 0!==t?t:null===e||void 0===e?void 0:e.layout_mode);if(a)return a;const r=ym(null===e||void 0===e?void 0:e.message);if(r)return r}return ym(e)},wm=e=>String(e||"").trim().toLowerCase().replace(/\s+/g," "),km=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(const a of t){const e=ym(a);if(e)return e}},jm=e=>{const t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0,n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0")):"".concat(a,":").concat(r.toString().padStart(2,"0"))},Dm=e=>{if(!e)return;const t=String(e.mimeType||"").toLowerCase(),n=!t||t.startsWith("image/");return km(e.thumbnailUrl,n?e.url:null,n?e.originalUrl:null)},Cm=e=>{if(!e)return;const t=String(e.mimeType||"").toLowerCase(),n=!t||t.startsWith("image/");return km(n?e.originalUrl:null,n?e.url:null,e.thumbnailUrl)},Nm=e=>km(null===e||void 0===e?void 0:e.url,null===e||void 0===e?void 0:e.playbackUrl,null===e||void 0===e?void 0:e.originalUrl),Fm=e=>{var t,n,a,r,s;return{id:String((null===e||void 0===e?void 0:e.id)||""),filename:ym(null===e||void 0===e?void 0:e.filename),mimeType:ym(null!==(t=null===e||void 0===e?void 0:e.mimeType)&&void 0!==t?t:null===e||void 0===e?void 0:e.mime_type),fileSize:bm(null!==(n=null===e||void 0===e?void 0:e.fileSize)&&void 0!==n?n:null===e||void 0===e?void 0:e.file_size),width:bm(null===e||void 0===e?void 0:e.width),height:bm(null===e||void 0===e?void 0:e.he
2ight),durationSeconds:bm(null!==(a=null===e||void 0===e?void 0:e.durationSeconds)&&void 0!==a?a:null===e||void 0===e?void 0:e.duration_seconds),description:ym(null===e||void 0===e?void 0:e.description),role:ym(null===e||void 0===e?void 0:e.role),label:ym(null===e||void 0===e?void 0:e.label),altText:ym(null!==(r=null===e||void 0===e?void 0:e.altText)&&void 0!==r?r:null===e||void 0===e?void 0:e.alt_text),sourceUrl:ym(null!==(s=null===e||void 0===e?void 0:e.sourceUrl)&&void 0!==s?s:null===e||void 0===e?void 0:e.source_url),notes:ym(null===e||void 0===e?void 0:e.notes),originalUrl:ym(null===e||void 0===e?void 0:e.originalUrl),playbackUrl:ym(null===e||void 0===e?void 0:e.playbackUrl),thumbnailUrl:ym(null===e||void 0===e?void 0:e.thumbnailUrl),url:ym(null===e||void 0===e?void 0:e.url)}},Sm=e=>{var t,n,a,r,s,i,o;const l=Array.isArray(null===e||void 0===e?void 0:e.assets)?e.assets:[],c=Array.isArray(null===e||void 0===e?void 0:e.placements)?e.placements:[],u=Array.isArray(null===e||void 0===e?void 0:e.titles)?e.titles:[],m=l.map(e=>Fm(e)).filter(e=>Boolean(e.id)),h=c.map(e=>(e=>{var t,n,a,r,s,i,o,l,c,u,m,h,p,g,x,f,b;return d(d({},Fm(e)),{},{assetId:String(null!==(t=null!==(n=null===e||void 0===e?void 0:e.assetId)&&void 0!==n?n:null===e||void 0===e?void 0:e.asset_id)&&void 0!==t?t:""),displayStart:null!==(a=bm(null!==(r=null===e||void 0===e?void 0:e.displayStart)&&void 0!==r?r:null===e||void 0===e?void 0:e.display_start))&&void 0!==a?a:0,displayEnd:null!==(s=bm(null!==(i=null===e||void 0===e?void 0:e.displayEnd)&&void 0!==i?i:null===e||void 0===e?void 0:e.display_end))&&void 0!==s?s:0,sourceStart:bm(null!==(o=null===e||void 0===e?void 0:e.sourceStart)&&void 0!==o?o:null===e||void 0===e?void 0:e.source_start),sourceEnd:bm(null!==(l=null===e||void 0===e?void 0:e.sourceEnd)&&void 0!==l?l:null===e||void 0===e?void 0:e.source_end),layoutMode:ym(null!==(c=null===e||void 0===e?void 0:e.layoutMode)&&void 0!==c?c:null===e||void 0===e?void 0:e.layout_mode),layoutX:bm(null!==(u=null===e||void 0===e?void 0:e.layoutX)&&void 0!==u?u:null===e||void 0===e?void 0:e.layout_x),layoutY:bm(null!==(m=null===e||void 0===e?void 0:e.layoutY)&&void 0!==m?m:null===e||void 0===e?void 0:e.layout_y),layoutWidth:bm(null!==(h=null===e||void 0===e?void 0:e.layoutWidth)&&void 0!==h?h:null===e||void 0===e?void 0:e.layout_width),layoutHeight:bm(null!==(p=null===e||void 0===e?void 0:e.layoutHeight)&&void 0!==p?p:null===e||void 0===e?void 0:e.layout_height),displayOrder:bm(null!==(g=null===e||void 0===e?void 0:e.displayOrder)&&void 0!==g?g:null===e||void 0===e?void 0:e.display_order),referenceIndex:bm(null!==(x=null===e||void 0===e?void 0:e.referenceIndex)&&void 0!==x?x:null===e||void 0===e?void 0:e.reference_index),referenceTitle:ym(null!==(f=null===e||void 0===e?void 0:e.referenceTitle)&&void 0!==f?f:null===e||void 0===e?void 0:e.reference_title),renderQuality:vm(null!==(b=null===e||void 0===e?void 0:e.renderQuality)&&void 0!==b?b:null===e||void 0===e?void 0:e.render_quality)})})(e)).filter(e=>Boolean(e.id)),p=u.map(e=>(e=>{var t,n,a,r,s,i,o,l;return{id:String((null===e||void 0===e?void 0:e.id)||""),text:String((null===e||void 0===e?void 0:e.text)||"").trim(),subtitle:ym(null===e||void 0===e?void 0:e.subtitle),variant:ym(null===e||void 0===e?void 0:e.variant),visibility:ym(null===e||void 0===e?void 0:e.visibility),displayStart:null!==(t=bm(null!==(n=null===e||void 0===e?void 0:e.displayStart)&&void 0!==n?n:null===e||void 0===e?void 0:e.display_start))&&void 0!==t?t:0,displayEnd:null!==(a=bm(null!==(r=null===e||void 0===e?void 0:e.displayEnd)&&void 0!==r?r:null===e||void 0===e?void 0:e.display_end))&&void 0!==a?a:0,url:ym(null===e||void 0===e?void 0:e.url),layoutX:bm(null!==(s=null===e||void 0===e?void 0:e.layoutX)&&void 0!==s?s:null===e||void 0===e?void 0:e.layout_x),layoutY:bm(null!==(i=null===e||void 0===e?void 0:e.layoutY)&&void 0!==i?i:null===e||void 0===e?void 0:e.layout_y),layoutWidth:bm(null!==(o=null===e||void 0===e?void 0:e.layoutWidth)&&void 0!==o?o:null===e||void 0===e?void 0:e.layout_width),layoutHeight:bm(null!==(l=null===e||void 0===e?void 0:e.layoutHeight)&&void 0!==l?l:null===e||void 0===e?void 0:e.layout_height)}})(e)).filter(e=>Boolean(e.id));return{selectedTtmlChecksum:ym(null!==(t=null===e||void 0===e?void 0:e.selectedTtmlChecksum)&&void 0!==t?t:null===e||void 0===e?void 0:e.selected_ttml_checksum),assets:m,placements:h,titles:p,counts:{assets:null!==(n=bm(null===e||void 0===e||null===(a=e.counts)||void 0===a?void 0:a.assets))&&void 0!==n?n:m.length,placements:null!==(r=bm(null===e||void 0===e||null===(s=e.counts)||void 0===s?void 0:s.placements))&&void 0!==r?r:h.length,titles:null!==(i=bm(null===e||void 0===e||null===(o=e.counts)||void 0===o?void 0:o.titles))&&void 0!==i?i:p.length}}},Em=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.id?String(e.id):[t,wm(e.title),Math.round(1e3*e.start),Math.round(1e3*e.end)].join(":")},Am=e=>{var t;return km(e.referenceTitle,e.description,e.filename,null!==(t=e.mimeType)&&void 0!==t&&t.startsWith("video/")?"Attached video":"Attached visual")||"Attached visual"},Tm=(e,t)=>
2{var n;const a=new Map;if(null===t||void 0===t||null===(n=t.placements)||void 0===n||!n.length||!e.length)return a;const r=e.map((e,t)=>({reference:e,index:t,key:Em(e,t)}));return t.placements.forEach(e=>{let t=null,n=0;r.forEach(a=>{let{reference:r,index:s,key:i}=a;const o=((e,t,n)=>{let a=0;const r=wm(e.referenceTitle),s=wm(t.title);null!=e.referenceIndex&&(e.referenceIndex===n&&(a+=5),e.referenceIndex===n+1&&(a+=4)),r&&s&&(r===s?a+=5:(r.includes(s)||s.includes(r))&&(a+=2));const i=Math.max(e.displayStart,t.start);Math.min(e.displayEnd,t.end)>i?a+=3:Math.min(Math.abs(e.displayStart-t.start),Math.abs(e.displayEnd-t.end))<=1&&(a+=1);return a})(e,r,s);o<=0||(!t||o>n)&&(t=i,n=o)});const s=t;if(!s)return;const i=a.get(s);if(i)return i.placements.push(e),i.assetCount+=1,void(i.previewImageUrl||(i.previewImageUrl=Dm(e)));a.set(s,{referenceId:s,placements:[e],primaryPlacement:e,assetCount:1,previewImageUrl:Dm(e),attachmentLabel:Am(e)})}),a},Mm=(e,t,n)=>n>=e&&n<=t?0:Math.min(Math.abs(e-n),Math.abs(t-n)),_m=(e,t,n)=>n>=e&&n<=t,Bm="/api",Im="/api/v1",Pm=/^[a-f0-9]{32}$/i,Lm=/^[A-Za-z0-9_-]{43}$/;function Rm(e){return!!e&&("cookie-session"!==e&&(!e.startsWith("rss_")&&(!e.includes(".")&&(Pm.test(e)||Lm.test(e)))))}function zm(e){var t;return e&&"object"===typeof e?d(d({},e),{},{sessionVisuals:e.sessionVisuals?Sm(e.sessionVisuals):null!==(t=e.sessionVisuals)&&void 0!==t?t:null}):e}class Om{static buildSessionCacheKey(e,t){return Rm(t)?"public:".concat(t):"auth:".concat(e)}static buildNarrativeCacheKey(e,t){return Rm(t)?"public:".concat(t):"auth:".concat(e)}static readCachedValue(e,t){const n=e.get(t);if(n){if(!(n.expiresAt<=Date.now()))return n.value;e.delete(t)}}static rememberValue(e,t,n,a){return e.set(t,{value:n,expiresAt:Date.now()+a}),n}static async runCachedRequest(e,t,n,a,r){const s=this.readCachedValue(e,n);if(void 0!==s)return s;const i=t.get(n);if(i)return i;const o=r().then(t=>this.rememberValue(e,n,t,a)).finally(()=>{t.delete(n)});return t.set(n,o),o}static primeNarrativeCache(e,t,n){if(null==n)return;const a=this.buildNarrativeCacheKey(e,t),r=Rm(t)?1e4:5e3;this.rememberValue(this.narrativeCache,a,n,r)}static primePublicShareEmbeddedData(e,t){if(!Rm(e)||null===t||void 0===t||!t.session)return;const n=String(t.session.session_id||t.session.sessionId||"").trim();n&&this.primeNarrativeCache(n,e,t.session._narrativeData),Array.isArray(t.session._questions)&&function(e,t){e&&dm("public:".concat(e),d(d({},t),{},{questions:Array.isArray(t.questions)?t.questions.map(om):[],pagination:t.pagination||{limit:t.total||t.count||0,offset:0,hasMore:!1}}),1e4)}(e,{episodeId:n,total:t.session._questions.length,count:t.session._questions.length,questions:t.session._questions,pagination:{limit:t.session._questions.length,offset:0,hasMore:!1}})}static invalidateSessionCache(e){const t="auth:".concat(e);for(const[n]of this.sessionCache)n.startsWith(t)&&this.sessionCache.delete(n);for(const[n]of this.sessionInflight)n.startsWith(t)&&this.sessionInflight.delete(n)}static invalidateNarrativeCache(e){const t="auth:".concat(e);for(const[n]of this.narrativeCache)n.startsWith(t)&&this.narrativeCache.delete(n);for(const[n]of this.narrativeInflight)n.startsWith(t)&&this.narrativeInflight.delete(n)}static async request(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const a="".concat(Bm).concat(e),r=new Headers(t.headers);r.set("Content-Type","application/json"),n&&r.set("Authorization","Bearer ".concat(n));const s=await fetch(a,d({headers:r},t));if(!s.ok){const e=await s.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(s.status))}return s.json()}static async createSession(e,t){return this.request("/sessions",{method:"POST",body:JSON.stringify(e)},t)}static async getSession(e,t){const n=this.buildSessionCacheKey(e,t),a=(Rm(t),1e4);return this.runCachedRequest(this.sessionCache,this.sessionInflight,n,a,async()=>{if(Rm(t)){const e=await fetch("".concat(Bm,"/public/share/").concat(t),{headers:{"Content-Type":"application/json"}});if(!e.ok){const t=await e.json().catch(()=>({error:"Network error"}));throw new Error(t.error||"HTTP ".concat(e.status))}const n=await e.json(),a=zm(n.session);return this.primePublicShareEmbeddedData(t,d(d({},n),{},{session:a})),a}return zm(await this.request("/sessions/".concat(e),{},t))})}static async updateSession(e,t){var n,a;
2console.log("[SESSION-SERVICE] updateSession called with:",{sessionId:e.sessionId,hasGeneratedTtmlFiles:!!e.generatedTtmlFiles,ttmlFilesCount:null===(n=e.generatedTtmlFiles)||void 0===n?void 0:n.length,ttmlFiles:null===(a=e.generatedTtmlFiles)||void 0===a?void 0:a.map(e=>{var t;return{name:e.name,checksum:e.checksum,hasContent:!!e.content,contentLength:null===(t=e.content)||void 0===t?void 0:t.length}})});const r=await this.request("/sessions/".concat(e.sessionId),{method:"PUT",body:JSON.stringify(e)},t);return this.invalidateSessionCache(e.sessionId),this.invalidateNarrativeCache(e.sessionId),console.log("[SESSION-SERVICE] updateSession result:",r),r}static async listSessions(e,t,n,a,r){const s=new URLSearchParams;null!==r&&void 0!==r&&r.project&&s.append("projectId",r.project),t&&s.append("search",t),n&&s.append("limit",n.toString()),a&&"all"!==a&&s.append("filter",a),null!==r&&void 0!==r&&r.show&&"all"!==r.show&&s.append("show",r.show),null!==r&&void 0!==r&&r.contentSource&&"all"!==r.contentSource&&s.append("contentSource",r.contentSource),null!==r&&void 0!==r&&r.contentVisibility&&"all"!==r.contentVisibility&&s.append("visibility",r.contentVisibility),null!==r&&void 0!==r&&r.includeExternal&&s.append("includeExternal","true");const i=s.toString(),o=i?"/sessions?".concat(i):"/sessions";return this.request(o,{},e)}static async getSessionStorageSummary(e,t,n,a){const r=new URLSearchParams;t&&r.append("search",t),n&&"all"!==n&&r.append("filter",n),null!==a&&void 0!==a&&a.show&&"all"!==a.show&&r.append("show",a.show),null!==a&&void 0!==a&&a.contentSource&&"all"!==a.contentSource&&r.append("contentSource",a.contentSource),null!==a&&void 0!==a&&a.contentVisibility&&"all"!==a.contentVisibility&&r.append("visibility",a.contentVisibility),null!==a&&void 0!==a&&a.includeExternal&&r.append("includeExternal","true");const s=r.toString(),i=s?"/sessions/storage-summary?".concat(s):"/sessions/storage-summary";return this.request(i,{},e)}static async deleteHostedVideoMediaBatch(e,t){return this.request("/sessions/video-source/hosted-media/delete-batch",{method:"POST",body:JSON.stringify({sessionIds:e})},t)}static async deleteSession(e,t){return this.request("/sessions/".concat(e),{method:"DELETE"},t)}static async toggleDeprecation(e,t,n,a){return this.request("/sessions/".concat(e,"/deprecation"),{method:"PATCH",body:JSON.stringify({deprecated:t,reason:null!==n&&void 0!==n?n:null})},a)}static generateSessionUrl(e){return"".concat(window.location.origin,"/session/").concat(e)}static async listEpisodeFamilies(e){const t=await fetch("".concat(Im,"/episodes/families"),{headers:e?{Authorization:"Bearer ".concat(e)}:{}});if(!t.ok){const e=await t.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(t.status))}return(await t.json()).families||[]}static async uploadFile(e,t,n){const a=new FormData;a.append("file",t);const r=new Headers;n&&r.set("Authorization","Bearer ".concat(n));const s=await fetch("".concat(Bm,"/sessions/").concat(e,"/upload"),{method:"POST",body:a,headers:r});if(!s.ok){const e=await s.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(s.status))}return s.json()}static async deleteFile(e,t,n){return this.request("/sessions/".concat(e,"/files/").concat(t),{method:"DELETE"},n)}static async getFile(e,t,n){return this.request("/sessions/".concat(e,"/files/").concat(t),{},n)}static async updateTitle(e,t,n){return this.request("/sessions/".concat(e,"/title"),{method:"PUT",body:JSON.stringify({title:t})},n)}static async updateYoutubeUrl(e,t,n){return this.request("/sessions/".concat(e,"/youtube-url"),{method:"PUT",body:JSON.stringify({youtubeUrl:t})},n)}static async updateVideoUrl(e,t,n){return this.request("/sessions/".concat(e,"/video-url"),{method:"PUT",body:JSON.stringify({videoUrl:t})},n)}static async syncTitleFromYouTube(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const a=await this.request("/sessions/".concat(e,"/youtube-title/sync"),{method:"POST",body:JSON.stringify({applyToSessionTitle:!0===t.applyToSessionTitle})},n);let r=a.syncState;if("boolean"===typeof t.enableAutoSync&&r.enabled!==t.enableAutoSync){r=(await this.updateYoutubeTitleSync(e,t.enableAutoSync,n)).youtubeTitleSync}return d(d({},a),{},{title:a.sessionTitleApplied?a.youtubeTitle:null,youtubeTitleSync:r,youtubeTitleSyncEnabled:r.enabled})}static async updateYoutubeTitleSync(e,t,n){return this.request("/sessions/".concat(e,"/youtube-title-sync"),{method:"PUT",body:JSON.stringify({enabled:t})},n)}static async getSessionInvalidations(e,t,n){const a=new URLSearchParams({sinceVersion:String(t||0)});return this.request("/sessions/".concat(e,"/invalidations?").concat(a.toString()),{},n)}static async toggleHomepagePublish(e,t,n){return this.request("/sessions/".concat(e,"/homepage-publish"),{method:"PATCH",body:JSON.stringify({published:t})},n)}static async updateProductionMetadata(e,t,n){return this.request("/sessions/".concat(e,"/production-metadata"),{method:"PUT",body:JSON.stringify(t)},n)}static async getVideoSourceStatus(e,t){return this.request("/sessions/".concat(e,"/video-source/status"),{},t)}static async getSessionFcpxmlStatus(e,t){const n=await fetch("".concat(Im,"/episodes/").concat(encodeURIComponent(e),"/fcpxml/status"),{headers:t?{Authorization:"Bearer ".concat(t)}:void 0});if(!n.ok){const e=await n.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(n.status))}return n.json()}static async uploadSessionFcpxml(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=new FormData;
2r.append("file",t),a.allowDurationMismatch&&(r.append("allowDurationMismatch","true"),r.append("durationOverrideReason",a.durationOverrideReason||"User confirmed duration mismatch override"));const s=await fetch("".concat(Im,"/episodes/").concat(encodeURIComponent(e),"/fcpxml"),{method:"POST",headers:n?{Authorization:"Bearer ".concat(n)}:void 0,body:r});if(!s.ok){var i,o,l;const e=await s.json().catch(()=>({error:"Network error"})),t=null===(i=e.validation)||void 0===i||null===(o=i.errors)||void 0===o||null===(l=o[0])||void 0===l?void 0:l.message,n=new Error(t||e.error||"HTTP ".concat(s.status));throw n.validation=e.validation,n.status=s.status,n}return s.json()}static async downloadSessionFcpxml(e,t){const n=await fetch("".concat(Im,"/episodes/").concat(encodeURIComponent(e),"/fcpxml/download"),{headers:t?{Authorization:"Bearer ".concat(t)}:void 0});if(!n.ok){const e=await n.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(n.status))}return{blob:await n.blob(),filename:function(e){var t;if(!e)return null;const n=e.match(/filename\*=UTF-8''([^;]+)/i);if(null!==n&&void 0!==n&&n[1])try{return decodeURIComponent(n[1].trim())}catch(s){return n[1].trim()}const a=e.match(/filename="([^"]+)"/i);if(null!==a&&void 0!==a&&a[1])return a[1];const r=e.match(/filename=([^;]+)/i);return(null===r||void 0===r||null===(t=r[1])||void 0===t?void 0:t.trim())||null}(n.headers.get("Content-Disposition"))||"session-".concat(e,".fcpxml")}}static async deleteSessionFcpxml(e,t){const n=await fetch("".concat(Im,"/episodes/").concat(encodeURIComponent(e),"/fcpxml"),{method:"DELETE",headers:t?{Authorization:"Bearer ".concat(t)}:void 0});if(!n.ok){const e=await n.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(n.status))}return n.json()}static async prepareVideoSource(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return this.request("/sessions/".concat(e,"/video-source/prepare"),{method:"POST",body:JSON.stringify(t)},n)}static async deleteVideoSourceProxy(e,t){return this.request("/sessions/".concat(e,"/video-source/proxy"),{method:"DELETE"},t)}static async captureHostedThumbnailFrame(e,t,n){return this.request("/sessions/".concat(e,"/thumbnail/frame"),{method:"POST",body:JSON.stringify({timestampSeconds:t})},n)}static async clearCustomThumbnail(e,t){return this.request("/sessions/".concat(e,"/thumbnail"),{method:"DELETE"},t)}static async addSessionToContext(e,t,n){return this.request("/sessions/".concat(e,"/context"),{method:"POST",body:JSON.stringify({contextSessionId:t})},n)}static async removeSessionFromContext(e,t,n){return this.request("/sessions/".concat(e,"/context/").concat(t),{method:"DELETE"},n)}static async toggleSessionContextInclusion(e,t,n,a){return this.request("/sessions/".concat(e,"/context/").concat(t),{method:"PUT",body:JSON.stringify({includedInContext:n})},a)}static async getSessionForContext(e,t){return this.request("/sessions/".concat(e,"/context-data"),{},t)}static async createConversation(e,t,n){return this.request("/sessions/".concat(e,"/conversations"),{method:"POST",body:JSON.stringify({name:t||"New Conversation"})},n)}static async updateConversation(e,t,n,a){return this.request("/sessions/".concat(e,"/conversations/").concat(t),{method:"PUT",body:JSON.stringify(n)},a)}static async deleteConversation(e,t,n){return this.request("/sessions/".concat(e,"/conversations/").concat(t),{method:"DELETE"},n)}static async setActiveConversation(e,t,n){return this.request("/sessions/".concat(e,"/active-conversation"),{method:"PUT",body:JSON.stringify({conversationId:t})},n)}static async generateConversationName(e,t,n){return this.request("/sessions/".concat(e,"/conversations/").concat(t,"/generate-name"),{method:"POST"},n)}static async addMessageToConversation(e,t,n,a){return this.request("/sessions/".concat(e,"/conversations/").concat(t,"/messages"),{method:"POST",body:JSON.stringify(n)},a)}static async getNarrativeData(e,t){try{const n=this.buildNarrativeCacheKey(e,t),a=Rm(t)?1e4:5e3;return this.runCachedRequest(this.narrativeCache,this.narrativeInflight,n,a,async()=>
2{if(Rm(t)){const e=await fetch("".concat(Bm,"/public/share/").concat(t,"/narrative"));if(!e.ok)throw new Error("Failed to fetch narrative data");return(await e.json()).narrativeData||null}return(await this.request("/sessions/".concat(e,"/narrative"),{},t)).narrativeData||null})}catch(n){return console.error("Error fetching narrative data:",n),null}}static async saveNarrativeData(e,t,n){const a=await this.request("/sessions/".concat(e,"/narrative"),{method:"PUT",body:JSON.stringify({narrativeData:t})},n);return this.invalidateNarrativeCache(e),a}static async getNarrativeGenerationStatus(e,t){if(Rm(t)){const e=await fetch("".concat(Bm,"/public/share/").concat(t,"/narrative-status"));if(!e.ok)throw new Error("Failed to fetch narrative status");return await e.json()}return this.request("/sessions/".concat(e,"/narrative-status"),{},t)}static async getInvalidations(e,t,n){return this.request("/sessions/".concat(e,"/invalidations?sinceVersion=").concat(encodeURIComponent(String(t))),{},n)}static async getNarrativeVersions(e,t){return this.request("/sessions/".concat(e,"/narrative-versions"),{},t)}static async createNarrativeVersion(e,t,n,a,r){return this.request("/sessions/".concat(e,"/narrative-versions"),{method:"POST",body:JSON.stringify({narrativeData:t,generationPrompt:n,generationParams:a})},r)}static async activateNarrativeVersion(e,t,n){return this.request("/sessions/".concat(e,"/narrative-versions/").concat(t,"/activate"),{method:"PUT"},n)}static async getNarrativeVersion(e,t,n){return this.request("/sessions/".concat(e,"/narrative-versions/").concat(t),{},n)}static async createAsyncChatJob(e,t,n,a,r,s,i,o,l){return this.request("/sessions/".concat(e,"/conversations/").concat(t,"/async-message"),{method:"POST",body:JSON.stringify({prompt:n,model:a,settings:r,systemPrompt:i,conversationHistory:o,uploadedFiles:l})},s)}static async getActiveJobsForConversation(e,t,n){return this.request("/sessions/".concat(e,"/conversations/").concat(t,"/active-jobs"),{},n)}static async getAsyncChatJobStatus(e,t,n){return this.request("/sessions/".concat(e,"/jobs/").concat(t,"/status"),{},n)}static async cancelAsyncChatJob(e,t,n){return this.request("/sessions/".concat(e,"/jobs/").concat(t,"/cancel"),{method:"POST"},n)}static async createBatchChatJobs(e,t,n,a,r,s){return this.request("/sessions/".concat(e,"/batch-generate"),{method:"POST",body:JSON.stringify({prompts:t,model:n,settings:a,systemPrompt:s})},r)}static async getBatchStatus(e,t,n){return this.request("/sessions/".concat(e,"/batch/").concat(t,"/status"),{},n)}}Om.sessionCache=new Map,Om.sessionInflight=new Map,Om.narrativeCache=new Map,Om.narrativeInflight=new Map;async function Um(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a={"Content-Type":"application/json"};e&&(a.Authorization="Bearer ".concat(e));const r=new URLSearchParams;Object.entries(t).forEach(e=>{let[t,n]=e;void 0!==n&&""!==n&&r.set(t,String(n))});const s=await fetch("".concat(Im,"/arrangements").concat(r.toString()?"?".concat(r):""),{headers:a,signal:n.signal});if(!s.ok){const e=await s.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(s.status))}return s.json()}const Vm=Om,Hm=e=>{let{size:t=24,className:n=""}=e;return(0,u.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,u.jsx)("path",{d:"M6 2L0 5.75L6 9.5L12 5.75L6 2Z"}),(0,u.jsx)("path",{d:"M18 2L12 5.75L18 9.5L24 5.75L18 2Z"}),(0,u.jsx)("path",{d:"M0 13.25L6 17L12 13.25L6 9.5L0 13.25Z"}),(0,u.jsx)("path",{d:"M18 9.5L12 13.25L18 17L24 13.25L18 9.5Z"}),(0,u.jsx)("path",{d:"M6 18.25L12 22L18 18.25L12 14.5L6 18.25Z"})]})},qm=Mo("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Wm=Mo("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);function Ym(e){var t,n;return null!==(t=e.shootDate)&&void 0!==t?t:"string"===typeof(null===(n=e.metadata)||void 0===n?void 0:n.shootDate)?e.metadata.shootDate:null}function Gm(e){var t,n;return null!==(t=e.workingProjectFolder)&&void 0!==t?t:"string"===typeof(null===(n=e.metadata)||void 0===n?void 0:n.workingProjectFolder)?e.metadata.workingProjectFolder:null}function Km(e){var t,n;return null!==(t=e.notes)&&void 0!==t&&t.length?e.notes:Array.isArray(null===(n=e.metadata)||void 0===n?void 0:n.notes)?e.metadata.notes.filter(e=>"string"===typeof e):[]}const Xm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Jm(e){const t=/^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/.exec(e||"");if(!t)return"";const n=t[2]?Xm[Number(t[2])-1]:"";
2return[t[3]?String(Number(t[3])):"",n,t[1]].filter(Boolean).join(" ")}function $m(e,t){const n=Ym(e)||"",a=Ym(t)||"";return n&&a&&n!==a?a.localeCompare(n):!!n!==!!a?n?-1:1:e.name.localeCompare(t.name)}async function Qm(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"GET",a=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;const s=await fetch("".concat("/api/v1").concat(t),d({method:n,credentials:"include",signal:r,headers:d({"Content-Type":"application/json"},e&&"cookie-session"!==e?{Authorization:"Bearer ".concat(e)}:{})},void 0===a?{}:{body:JSON.stringify(a)})),i=await s.json();if(!s.ok)throw new Error(i.message||i.error||"Request failed (".concat(s.status,")"));return i}async function Zm(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const a=[];let r=0;do{const s=new URLSearchParams(d({status:t.status||"active",limit:"200",offset:String(a.length)},t.search?{search:t.search}:{})),i=await Qm(e,"/projects?".concat(s),"GET",void 0,n);if(a.push(...i.projects),r=i.total,!i.projects.length)break}while(a.length<r);return{projects:a,total:r}}function eh(e,t,n){return Qm(e,"/projects/".concat(encodeURIComponent(t),"/assign"),"POST",n)}function th(){window.dispatchEvent(new Event("rescript-projects-changed"))}const nh=new Map;let ah,rh=0;function sh(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"active";const[n,r]=(0,a.useState)([]),[s,i]=(0,a.useState)(""),[o,l]=(0,a.useState)(!0),[c,d]=(0,a.useState)(0);return(0,a.useEffect)(()=>{rh+=1;const e=()=>{nh.clear(),d(e=>e+1)};return window.addEventListener("rescript-projects-changed",e),()=>{window.removeEventListener("rescript-projects-changed",e),rh-=1,0===rh&&(nh.clear(),ah=void 0)}},[]),(0,a.useEffect)(()=>{e&&ah===e||(nh.clear(),ah=e),r([]),i("")},[e]),(0,a.useEffect)(()=>{if(!e)return void l(!1);let n=!0;const a="".concat(e,":").concat(t);let s=nh.get(a);if(!s||Date.now()-s.at>3e4){s={at:Date.now(),promise:Zm(e,{status:t}).then(e=>e.projects)},nh.set(a,s);const n=s;s.promise.catch(()=>{nh.get(a)===n&&nh.delete(a)})}return l(!0),s.promise.then(e=>{n&&(r(e),i(""))}).catch(e=>{n&&i(e.message)}).finally(()=>{n&&l(!1)}),()=>{n=!1}},[e,t,c]),{projects:n,error:s,loading:o,refresh:th}}function ih(e){let{token:t,value:n,onChange:r,allowAll:s=!1,required:i=!1,label:o="Project"}=e;const{projects:l,error:c,loading:d}=sh(t),[m,h]=(0,a.useState)(!1),[p,g]=(0,a.useState)(""),[x,f]=(0,a.useState)(""),[b,y]=(0,a.useState)(!1),v=async()=>{if(p.trim()&&!b){y(!0),f("");try{const e=await function(e,t){return Qm(e,"/projects","POST",t)}(t,{name:p.trim()});th(),r(e.project.id),h(!1),g("")}catch(BH){f(BH.message)}finally{y(!1)}}};return(0,u.jsxs)("div",{className:"project-picker",children:[(0,u.jsxs)("div",{className:"project-picker-row",children:[(0,u.jsxs)("select",{"aria-label":o,value:n,required:i,onChange:e=>r(e.target.value),className:"project-input",disabled:d&&!l.length,children:[(0,u.jsx)("option",{value:"",children:s?"All projects":d?"Loading projects\u2026":"Choose project"}),s&&(0,u.jsx)("option",{value:"unassigned",children:"Unassigned"}),[...l].sort($m).map(e=>{const t=Jm(Ym(e));return(0,u.jsx)("option",{value:e.id,children:t?"".concat(e.name," \xb7 ").concat(t):e.name},e.id)})]}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Create project","data-tip":"Create project",title:"Create project",onClick:()=>h(e=>!e),children:(0,u.jsx)(qm,{size:18,"aria-hidden":"true"})})]}),m&&(0,u.jsxs)("div",{className:"project-picker-row",children:[(0,u.jsx)("input",{autoFocus:!0,"aria-label":"New project name",className:"project-input",placeholder:"Project name",value:p,onChange:e=>g(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v()),"Escape"===e.key&&h(!1)}}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Save project","data-tip":"Save project",disabled:b||!p.trim(),onClick:()=>{v()},children:(0,u.jsx)(Wm,{size:18})}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Cancel project creation","data-tip":"Cancel",onClick:()=>h(!1),children:(0,u.jsx)(Pu,{size:18})})]}),(x||c)&&(0,u.jsx)("p",{role:"alert",className:"project-error",children:x||c})]})}const oh=e=>{let{values:t,onChange:n,isDarkMode:a,showAutoPrepareToggle:r=!1,compact:s=!1}=e;const i="w-full px-3 py-2 rounded-lg border text-sm ".concat(a?"bg-gray-700 border-gray-600 text-white placeholder-gray-500":"bg-white border-gray-300 text-gray-900 placeholder-gray-400"," focus:ring-2 focus:ring-primary-500 focus:border-primary-500"),o=s?"space-y-3"
2:"space-y-4",l="".concat(i," min-h-[104px] resize-y");return(0,u.jsxs)("div",{className:o,children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(a?"text-gray-300":"text-gray-700"),children:"Dropbox Video URL"}),(0,u.jsx)("input",{type:"url",value:t.dropboxVideoUrl,onChange:e=>n({dropboxVideoUrl:e.target.value}),placeholder:"https://www.dropbox.com/...",className:i})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(a?"text-gray-300":"text-gray-700"),children:"Local Video Path"}),(0,u.jsx)("input",{type:"text",value:t.localVideoPath,onChange:e=>n({localVideoPath:e.target.value}),placeholder:"/Users/.../video.mov",className:i}),(0,u.jsx)("p",{className:"mt-1 text-xs ".concat(a?"text-gray-500":"text-gray-400"),children:"Stored on the session and your user mapping for OTIO/export workflows."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(a?"text-gray-300":"text-gray-700"),children:"Timeline Name"}),(0,u.jsx)("input",{type:"text",value:t.timelineName,onChange:e=>n({timelineName:e.target.value}),placeholder:"e.g., Main Edit v2",className:i})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(a?"text-gray-300":"text-gray-700"),children:"DRP Dropbox URL"}),(0,u.jsx)("input",{type:"url",value:t.dropboxDrpUrl,onChange:e=>n({dropboxDrpUrl:e.target.value}),placeholder:"https://www.dropbox.com/...",className:i})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(a?"text-gray-300":"text-gray-700"),children:"Video Filename"}),(0,u.jsx)("input",{type:"text",value:t.videoFilename,onChange:e=>n({videoFilename:e.target.value}),placeholder:"e.g., Anna Patreon.mov",className:i})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(a?"text-gray-300":"text-gray-700"),children:"Production Notes"}),(0,u.jsx)("textarea",{value:t.productionNotes,onChange:e=>n({productionNotes:e.target.value}),placeholder:"e.g., RX denoise, de-ess, loudness normalized to -16 LUFS",className:l}),(0,u.jsx)("p",{className:"mt-1 text-xs ".concat(a?"text-gray-500":"text-gray-400"),children:"Free-form notes for audio cleanup, mastering, captions, delivery, or other production decisions."})]}),r&&(0,u.jsxs)("label",{className:"flex items-start gap-3 rounded-lg border px-3 py-3 ".concat(a?"border-gray-700 bg-gray-800/70 text-gray-300":"border-gray-200 bg-gray-50 text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:!1!==t.autoPrepareVideoSource,onChange:e=>n({autoPrepareVideoSource:e.target.checked}),className:"mt-0.5 h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500"}),(0,u.jsx)("span",{className:"text-sm",children:"Queue AWS source ingest and proxy generation after the transcript session is created."})]})]})},lh=[{slug:"mlst",title:"Machine Learning Street Talk"},{slug:"mindscape",title:"Mindscape"},{slug:"dwarkesh-patel",title:"Dwarkesh Patel"},{slug:"theories-of-everything",title:"Theories of Everything"}],ch="__custom__",dh=/^(https?:\/\/)?(www\.)?dropbox\.com\/(s|scl\/fi)\/.+/i,uh=e=>{var t,n;let{projectId:r,onProjectChange:s,rulesKeyterms:i=!0,onRulesKeytermsChange:o,onFileSelect:l,onYouTubeSelect:c,onDropboxSelect:m,showAssignment:h,onShowAssignmentChange:p,familyAssignment:g,onFamilyAssignmentChange:x,isProcessing:f=!1,className:b=""}=e;const{isDarkMode:y}=zu(),{token:v}=am(),[w,k]=(0,a.useState)(null),[j,D]=(0,a.useState)(""),[C,N]=(0,a.useState)(""),[F,E]=(0,a.useState)(null),[A,T]=(0,a.useState)(""),[M,_]=(0,a.useState)("file"),[B,I]=(0,a.useState)(!1),[P,L]=(0,a.useState)(""),[R,z]=(0,a.useState)(!1),[O,U]=(0,a.useState)(g.seedSessionId?"new":g.familySlug?"existing":"standalone"),[V,H]=(0,a.useState)(g.familySlug||""),[q,W]=(0,a.useState)(g.seedSessionId||""),[Y,G]=(0,a.useState)([]),[K,X]=(0,a.useState)(!1),[J,$]=(0,a.useState)(""),[Q,Z]=(0,a.useState)(""),[ee,te]=(0,a.useState)([]),[ne,ae]=(0,a.useState)(!1),[re,se]=(0,a.useState)(""),ie=new Set(lh.map(e=>e.slug)),oe=ie.has(h.showSlug)?h.showSlug:ch,[le,ce]=(0,a.useState)({dropboxVideoUrl:"",localVideoPath:"",timelineName:"",dropboxDrpUrl:"",videoFilename:"",productionNotes:"",autoPrepareVideoSource:!0});(0,a.useEffect)(()=>
2{if(!v||!B||"standalone"===O)return;let e=!1;return(async()=>{X(!0),$("");try{const t=await Vm.listEpisodeFamilies(v);e||G(t)}catch(t){e||$(t instanceof Error?t.message:"Failed to load episode families")}finally{e||X(!1)}})(),()=>{e=!0}},[O,B,v]),(0,a.useEffect)(()=>{if(!v||!B||"new"!==O||!h.showSlug.trim())return te([]),se(""),void ae(!1);let e=!1;const t=window.setTimeout(async()=>{ae(!0),se("");try{const t=await Vm.listSessions(v,Q.trim()||void 0,25,"all",{show:h.showSlug,contentSource:"all",contentVisibility:"all",includeExternal:!0});e||te(t.filter(e=>!e.family&&!e.isDeprecated))}catch(t){e||se(t instanceof Error?t.message:"Failed to load seed episodes")}finally{e||ae(!1)}},Q?250:0);return()=>{e=!0,window.clearTimeout(t)}},[v,B,O,Q,h.showSlug]);const de=(0,a.useMemo)(()=>Y.filter(e=>e.showSlug===h.showSlug),[Y,h.showSlug]),ue=(0,a.useCallback)(e=>e.toLowerCase().replace(/&/g," and ").replace(/[^a-z0-9]+/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,""),[]),me=(0,a.useCallback)(e=>e.replace(/^\[[^\]]*deprecated[^\]]*\]\s*/i,"").replace(/\b(?:S|P)\d+(?:\.\d+)?\b/gi,"").replace(/\bv\d+\b/gi,"").replace(/\((?:patreon version|release version|video-synced|synced video repair)\)/gi,"").replace(/\s+-\s+(?:synced video repair|video-synced)\s*$/i,"").replace(/\s{2,}/g," ").trim()||e.trim(),[]),he=(0,a.useCallback)((e,t)=>{const n=ue(me(e))||"family-".concat(t.slice(0,8)),a=new Set(Y.map(e=>e.slug));let r=n,s=2;for(;a.has(r);)r="".concat(n,"-").concat(s),s+=1;return r},[Y,me,ue]),pe=(0,a.useCallback)(e=>e.members.reduce((e,t)=>{const n=Number(t.versionNumber||0);return Number.isFinite(n)?Math.max(e,n):e},0)+1,[]),ge=()=>{k(null),N(""),E(null)},xe=(0,a.useCallback)((e,t)=>{if(T(""),t.length>0){const e=t[0];return void(e.errors.some(e=>"file-too-large"===e.code)?T("File size must be less than 1GB"):e.errors.some(e=>"file-invalid-type"===e.code)?T("Please select an audio file (MP3, WAV, M4A, FLAC, MP4, WEBM)"):T("Invalid file selected"))}if(e.length>0){const t=e[0],n={file:t,name:t.name,size:t.size,url:""};k(n),N(""),E(null),l(n)}},[l]),fe=()=>{(T(""),j.trim())?/^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+/.test(j)?(N(j.trim()),k(null),E(null),c(j.trim(),P.trim()||void 0)):T("Please enter a valid YouTube URL"):T("Please enter a YouTube URL")},be=(e,t)=>{"showSlug"===e&&t!==h.showSlug&&(U("standalone"),H(""),W(""),ye()),p(d(d({},h),{},{[e]:t}))},ye=(0,a.useCallback)(()=>{x({familySlug:"",familyTitle:"",familyVersionNumber:null,seedSessionId:"",seedSessionTitle:""})},[x]),ve=(e,t)=>{if("familyVersionNumber"===e){const e=Number.parseInt(t,10);return void x(d(d({},g),{},{familyVersionNumber:Number.isFinite(e)&&e>0?e:null}))}x(d(d({},g),{},{[e]:t}))};(0,a.useEffect)(()=>{if("existing"!==O||!V)return;const e=de.find(e=>e.slug===V);if(!e)return H(""),void ye();x({familySlug:e.slug,familyTitle:e.title||"",familyVersionNumber:g.familyVersionNumber||pe(e),seedSessionId:"",seedSessionTitle:""})},[ye,pe,g.familyVersionNumber,O,de,x,V,g.seedSessionId,g.seedSessionTitle]),(0,a.useEffect)(()=>{if("new"!==O)return;if(!q)return void((g.familySlug||g.familyTitle||g.familyVersionNumber||g.seedSessionId)&&ye());const e=ee.find(e=>e.sessionId===q);if(e){const t=d(d({},g),{},{familySlug:g.familySlug||he(e.title,e.sessionId),familyTitle:g.familyTitle||me(e.title),familyVersionNumber:g.familyVersionNumber||2,seedSessionId:e.sessionId,seedSessionTitle:e.title});t.familySlug===g.familySlug&&t.familyTitle===g.familyTitle&&t.familyVersionNumber===g.familyVersionNumber&&t.seedSessionId===g.seedSessionId&&t.seedSessionTitle===g.seedSessionTitle||x(t)}},[ye,he,g,O,me,x,ee,q]);const{getRootProps:we,getInputProps:ke,isDragActive:je,isDragReject:De}=Nu({onDrop:xe,accept:{"audio/*":[".mp3",".wav",".m4a",".flac",".mp4",".webm",".ogg"]},maxSize:1073741824,multiple:!1,disabled:f}),Ce=!!(w||C||F);(0,a.useEffect)(()=>{(Ce||f)&&I(!0)},[Ce,f]);const Ne=y?"overflow-hidden rounded-[30px] border border-[#344052] bg-[linear-gradient(180deg,rgba(24,34,49,0.94),rgba(15,23,36,0.86))] text-[#F4F4F4] shadow-[0_32px_70px_-42px_rgba(3,8,18,0.92)] backdrop-blur-2xl":"overflow-hidden rounded-[30px] border border-[#D6DCE4] bg-[linear-gradient(180deg,rgba(255,255,255,0.84),rgba(248,248,247,0.76))] text-[#232E3F] shadow-[0_34px_72px_-40px_rgba(35,46,63,0.3)] backdrop-blur-2xl",Fe=y?"rounded-[24px] border border-white/[0.08] bg-white/[0.05] backdrop-blur-xl":"rounded-[24px] border border-[#D6DCE4] bg-white/[0.62] backdrop-blur-xl",Se=y?"rounded-2xl border border-white/[0.12] bg-white/[0.08] px-3 py-2 text-sm text-[#F4F4F4] shadow-sm outline-none transition focus:border-[#FFB52B]/45":"rounded-2xl border border-[#D6DCE4] bg-white/[0.92] px-3 py-2 text-sm text-[#232E3F] shadow-sm outline-none transition focus:border-[#FFB52B]/50",Ee="".concat(Se," appearance-none bg-[url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20fill%3D%22none%22%20stroke%3D%22%236b7280%22%20stroke-width%3D%222%22%3E%3Cpath%20d%3D%22m2%204%204%204%204-4%22%2F%3
2E%3C%2Fsvg%3E')] bg-[length:12px] bg-[right_12px_center] bg-no-repeat pr-9 ").concat(y?"dark:[color-scheme:dark]":""),Ae=y?"text-[#A9B4C3]":"text-[#5E6B7D]",Te=y?{colorScheme:"dark"}:void 0,Me=y?{backgroundColor:"#182231",color:"#F4F4F4"}:void 0,_e=[{id:"file",label:"Upload File",icon:(0,u.jsx)(Eu,{size:18})},{id:"youtube",label:"YouTube URL",icon:(0,u.jsx)(Au,{size:18})},{id:"dropbox",label:"Dropbox Video",icon:(0,u.jsx)(Hm,{size:18,className:"text-brand-yellow"})}],Be=w?w.name:F?F.videoFilename||"Dropbox video session":C?"YouTube video":"",Ie=w?(e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return"".concat(parseFloat((e/Math.pow(1024,t)).toFixed(2))," ").concat(["Bytes","KB","MB","GB"][t])})(w.size):F?F.dropboxVideoUrl:C;return(0,u.jsxs)("div",{className:"w-full ".concat(b),children:[(0,u.jsx)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},children:(0,u.jsx)("div",{className:Ne,children:(0,u.jsx)("div",{className:"p-5 sm:p-6",children:(0,u.jsxs)("div",{className:"flex flex-col gap-5",children:[(0,u.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("p",{className:"inline-flex items-center gap-2 font-headlines text-[10px] font-semibold uppercase tracking-[0.26em] ".concat(y?"text-[#FFCC66]":"text-[#A36A00]"),children:[(0,u.jsx)(Po,{className:"h-3.5 w-3.5"}),"New Session"]}),(0,u.jsx)("div",{className:"mt-2",children:(0,u.jsx)(kd,{enabled:i,disabled:f,onChange:o,contextLabel:g.familySlug||h.showSlug||void 0})}),(0,u.jsx)("h3",{className:"mt-3 font-headlines text-2xl font-bold tracking-tight",children:"Upload only when you need to"}),(0,u.jsx)("p",{className:"mt-2 max-w-2xl font-body text-sm leading-6 ".concat(Ae),children:"Most of the time this page is for browsing the archive. Pick a source when you want to create a new session, and the full ingest controls will open underneath."})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{f||I(e=>!e)},className:"inline-flex items-center justify-center gap-2 rounded-full border px-4 py-2 font-headlines text-sm font-semibold transition ".concat(y?"border-white/[0.12] bg-white/[0.08] text-[#F4F4F4] hover:bg-white/[0.14]":"border-[#D6DCE4] bg-white/[0.7] text-[#232E3F] hover:bg-white"),children:[B?(0,u.jsx)(Tu,{size:16}):(0,u.jsx)(wd,{size:16}),B?"Hide uploader":"Open uploader"]})]}),(0,u.jsx)("div",{className:"grid gap-2 md:grid-cols-3",children:_e.map(e=>{const t=M===e.id;return(0,u.jsxs)("button",{type:"button",onClick:()=>(e=>{const t=e===M&&B&&!f&&!(w||C||F);_(e),T(""),ge(),D(""),I(!t),"file"===e&&z(!1)})(e.id),disabled:f,className:"flex items-center justify-center gap-2 rounded-[20px] border px-4 py-3 font-headlines text-sm font-semibold transition ".concat(t?"border-[#FFB52B]/40 bg-[#FFB52B] text-[#232E3F] shadow-[0_18px_32px_-24px_rgba(255,181,43,0.9)]":y?"border-white/[0.08] bg-white/[0.05] text-[#D5DEEA] hover:bg-white/[0.1]":"border-[#D6DCE4] bg-white/[0.58] text-[#4E5D72] hover:bg-white/[0.82]"),children:[e.icon,(0,u.jsx)("span",{children:e.label})]},e.id)})}),B||Ce?null:(0,u.jsx)("div",{className:"rounded-[22px] border px-4 py-3 font-body text-sm ".concat(Fe," ").concat(Ae),children:"Choose a source above when you want to ingest a new session. Show assignment and family controls stay tucked away until then."}),(0,u.jsx)(S,{initial:!1,children:B&&(0,u.jsxs)(Do.div,{initial:{opacity:0,height:0,y:-8},animate:{opacity:1,height:"auto",y:0},exit:{opacity:0,height:0,y:-8},transition:{duration:.22},className:"space-y-5 overflow-hidden",children:[(0,u.jsxs)("div",{className:"".concat(Fe," p-4 sm:p-5"),children:[(0,u.jsx)("fieldset",{disabled:f,className:"mb-4",children:(0,u.jsx)(ih,{token:v,value:r,onChange:s,required:!0,label:"Project for new session"})}),(0,u.jsxs)("div",{className:"grid gap-5 xl:grid-cols-[minmax(0,1.1fr)_minmax(0,1.4fr)]",children:[(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-sm font-semibold",children:"Show assignment"}),(0,u.jsx)("p",{className:"mt-1 font-body text-xs leading-5 ".concat(Ae),children:"Required. Every new session must belong to a show."})]}),(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]",children:[(0,u.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"Show"}),(0,u.jsxs)("select",{value:oe,onChange:e=>(e=>{if(e===ch)return ie.has(h.showSlug)&&(U("standalone"),H(""),W(""),ye()),void p({showSlug:ie.has(h.showSlug)?"":h.showSlug,showTitle:ie.has(h.showSlug)?"":h.showTitle});const t=lh.find(t=>t.slug===e);t&&(t.slug!==h.showSlug&&(U("standalone"),H(""),W(""),ye()),p({showSlug:t.slug,showTitle:t.title}))})(e.target.value),disabled:f,className:Ee,style:Te,children:[lh.map(e=>(0,u.jsx)("option",{value:e.slug,style:Me,children:e.title},e.slug)),(0,u.jsx)("option",{value:ch,style:Me,children:"Custom show..."})]})]}),(0,u.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"Show slug"}),(0,u.jsx)("input",{type:"text",value:h.showSlug,onChange:e=>be("showSlug",e.target.value),disabled:f||oe!==ch,placeholder:"mlst",className:"".concat(Se," disabled:cursor-not-allowed disabled:opacity-55")})]})]}),oe===ch&&(0,u.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"Show title"}),(0,u.jsx)("input",{type:"text",value:h.showTitle,onChange:e=>be("showTitle",e.target.value),disabled:f,placeholder:"Custom show title",className:Se})]})]}),(0,u.jsxs)("div",{className:"rounded-[22px] border p-4 ".concat(y?"border-white/[0.08] bg-white/[0.04]":"border-[#D6DCE4] bg-[#F8F8F7]/[0.78]"),children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-sm font-semibold",children:"Episode family"}),(0,u.jsx)("p",{className:"mt-1 font-body text-xs leading-5 ".concat(Ae),children:"Optional. Use this for another version of an existing episode instead of putting `S0` or `v2` into the title."})]}),K?(0,u.jsx)("span",{className:"font-body text-xs ".concat(Ae),children:"Loading families\u2026"}):null]}),(0,u.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:[{id:"standalone",label:"Standalone"},{id:"existing",label:"Existing family"},{id:"new",label:"New family"}].map(e=>(0,u.jsx)("button",{type:"button",onClick:()=>(e=>{if(U(e),"standalone"===e)return H(""),void ye();if("existing"!==e)H(""),W(g.seedSessionId||""),x({familySlug:g.familySlug||"",familyTitle:g.familyTitle||"",familyVersionNumber:g.familyVersionNumber||2,seedSessionId:g.seedSessionId||"",seedSessionTitle:g.seedSessionTitle||""});else{if(W(""),V){const e=Y.find(e=>e.slug===V);if(e)return void x({familySlug:e.slug,familyTitle:e.title||"",familyVersionNumber:pe(e),seedSessionId:"",seedSessionTitle:""})}ye()}})(e.id),disabled:f,className:"rounded-full border px-3 py-1.5 font-headlines text-[11px] font-semibold uppercase tracking-[0.14em] transition ".concat(O===e.id?"border-[#FFB52B]/40 bg-[#FFB52B] text-[#232E3F]":y?"border-white/[0.08] bg-white/[0.06] text-[#D5DEEA] hover:bg-white/[0.1]":"border-[#D6DCE4] bg-white/[0.72] text-[#4E5D72] hover:bg-white"),children:e.label},e.id))}),J?(0,u.jsx)("p",{className:"mt-3 text-xs text-red-500 dark:text-red-300",children:J}):null,"existing"===O&&(0,u.jsxs)("div",{className:"mt-4 grid gap-3 md:grid-cols-[minmax(0,1.5fr)_160px]",children:[(0,u.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"Existing family"}),(0,u.jsxs)("select",{value:V,onChange:e=>(e=>{H(e);const t=Y.find(t=>t.slug===e);t?x({familySlug:t.slug,familyTitle:t.title||"",familyVersionNumber:pe(t),seedSessionId:"",seedSessionTitle:""}):ye()})(e.target.value),disabled:f||0===de.length,className:"".concat(Ee," disabled:cursor-not-allowed disabled:opacity-55"),style:Te,children:[(0,u.jsx)("option",{value:"",style:Me,children:0===de.length?"No families for this show yet":"Choose an existing family"}),de.map(e=>(0,u.jsxs)("option",{value:e.slug,style:Me,children:[e.title||e.slug," \xb7 ",e.versionCount," versions"]},e.slug))]})]}),(0,u.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"Version"}),(0,u.jsx)("input",{type:"number",min:1,value:null!==(t=g.familyVersionNumber)&&void 0!==t?t:"",onChange:e=>ve("familyVersionNumber",e.target.value),disabled:f||!V,className:"".concat(Se," disabled:cursor-not-allowed disabled:opacity-55")})]})]}),"new"===O&&(0,u.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,u.jsxs)("div",{className:"rounded-[20px] border p-4 ".concat(y?"border-white/[0.08] bg-[#101925]/70":"border-[#D6DCE4] bg-white/[0.7]"),children:[(0,u.jsxs)("div",{className:"mb-2 flex items-center gap-2 font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:[(0,u.jsx)(Mu,{size:14}),"Seed from existing episode"]}),(0,u.jsx)("p",{className:"mb-3 font-body text-sm leading-6 ".concat(Ae),children:"Pick the earlier standalone session that this upload is replacing or refining. The seed becomes version 1 and the new upload defaults to version 2."}),(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(Mu,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ".concat(Ae)}),(0,u.jsx)("input",{type:"text",value:Q,onChange:e=>Z(e.target.value),disabled:f,placeholder:"Search ".concat(h.showTitle," episodes"),className:"w-full pl-9 ".concat(Se)})]}),re?(0,u.jsx)("p",{className:"mt-3 text-xs text-red-500 dark:text-red-300",children:re}):null,(0,u.jsx)("div",{className:"mt-3 max-h-56 space-y-2 overflow-y-auto pr-1",children:ne?(0,u.jsx)("p",{className:"font-body text-sm ".concat(Ae),children:"Loading seed episodes\u2026"}):0===ee.length?(0,u.jsx)("p",{className:"font-body text-sm ".concat(Ae),children:"No standalone sessions foun
2d for this show yet."}):ee.map(e=>{const t=e.sessionId===q,n=t?y?"text-[#FFD88A]":"text-[#5E4A16]":Ae;return(0,u.jsxs)("button",{type:"button",onClick:()=>(e=>{const t=me(e.title);W(e.sessionId),x({familySlug:he(e.title,e.sessionId),familyTitle:t,familyVersionNumber:2,seedSessionId:e.sessionId,seedSessionTitle:e.title})})(e),disabled:f,className:"w-full rounded-2xl border px-3 py-3 text-left transition ".concat(t?"border-[#FFB52B]/40 bg-[#FFF4D9] text-[#232E3F] dark:bg-[#FFB52B]/12 dark:text-[#FFE3A1]":y?"border-white/[0.08] bg-white/[0.04] hover:bg-white/[0.08]":"border-[#D6DCE4] bg-white/[0.7] hover:bg-white"),children:[(0,u.jsx)("div",{className:"text-sm font-semibold",children:e.title}),(0,u.jsxs)("div",{className:"mt-1 font-body text-xs ".concat(n),children:[e.sessionId," \xb7 updated ",new Date(e.updatedAt).toLocaleDateString()]})]},e.sessionId)})})]}),q&&(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,u.jsxs)("div",{className:"md:col-span-2 rounded-2xl border border-[#FFB52B]/30 bg-[#FFF4D9]/70 px-3 py-2 text-sm text-[#8A6100] dark:bg-[#FFB52B]/10 dark:text-[#FFE3A1]",children:["Seed episode: ",(0,u.jsx)("span",{className:"font-semibold",children:g.seedSessionTitle||q})]}),(0,u.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"Family slug"}),(0,u.jsx)("input",{type:"text",value:g.familySlug,onChange:e=>ve("familySlug",e.target.value),disabled:f,placeholder:"guest-topic-family",className:Se})]}),(0,u.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"Family title"}),(0,u.jsx)("input",{type:"text",value:g.familyTitle,onChange:e=>ve("familyTitle",e.target.value),disabled:f,placeholder:"Shared display title",className:Se})]}),(0,u.jsxs)("label",{className:"flex max-w-[180px] flex-col gap-1.5",children:[(0,u.jsx)("span",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(Ae),children:"New upload version"}),(0,u.jsx)("input",{type:"number",min:2,value:null!==(n=g.familyVersionNumber)&&void 0!==n?n:2,onChange:e=>ve("familyVersionNumber",e.target.value),disabled:f,className:Se})]})]})]})]})]})]}),Ce?(0,u.jsxs)(Do.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},className:"".concat(Fe," flex items-center justify-between p-4 sm:p-5"),children:[(0,u.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,u.jsx)("div",{className:"rounded-2xl p-2.5 ".concat(y?"bg-white/[0.08]":"bg-[#FFF4D9]"),children:w?(0,u.jsx)(Iu,{size:22,className:"text-brand-yellow"}):F?(0,u.jsx)(Hm,{size:22,className:"text-brand-yellow"}):(0,u.jsx)(Au,{size:22,className:"text-red-500"})}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"truncate font-headlines text-base font-semibold",children:Be}),(0,u.jsx)("p",{className:"truncate font-body text-sm ".concat(Ae),children:Ie}),F?(0,u.jsxs)("p",{className:"mt-1 truncate font-body text-xs ".concat(Ae),children:["Timeline: ",F.timelineName," \xb7 Local path: ",F.localVideoPath]}):null]})]}),!f&&(0,u.jsx)("button",{onClick:()=>{ge(),T("")},className:"rounded-full p-2 transition-colors ".concat(y?"hover:bg-red-500/12":"hover:bg-red-50"),title:"Remove selection",children:(0,u.jsx)(Pu,{size:20,className:"text-red-500"})})]}):(0,u.jsxs)(u.Fragment,{children:["file"===M&&(0,u.jsxs)("div",d(d({},we()),{},{className:"\n relative cursor-pointer rounded-[26px] border-2 border-dashed p-10 text-center transition-all duration-300\n ".concat(je&&!De?"border-[#FFB52B]/70 bg-[#FFF4D9]/55 dark:bg-[#FFB52B]/12":De?"border-red-500/70 bg-red-50 dark:bg-red-900/20":y?"border-white/[0.14] bg-white/[0.05] hover:border-[#FFB52B]/45 hover:bg-white/[0.08]":"border-[#D6DCE4] bg-white/[0.55] hover:border-[#FFB52B]/45 hover:bg-white/[0.82]","\n ").concat(f?"pointer-events-none opacity-50":"","\n "),children:[(0,u.jsx)("input",d({},ke())),(0,u.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4",children:[(0,u.jsx)(Do.div,{animate:je?{scale:1.08}:{scale:1},transition:{duration:.2},children:(0,u.jsx)(Eu,{size:48,className:De?"text-red-500":"text-brand-yellow"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-xl font-semibold",children:je?De?"Invalid file type":"Drop your audio file here":"Upload your audio file"}),(0,u.jsx)("p",{className:"mt-2 font-body text-sm ".concat(Ae),children:"Drag and drop or click to browse."}),(0,u.jsx)("p",{className:"mt-2 font-body text-xs ".concat(Ae),children:"Supports MP3, WAV, M4A, FLAC, MP4, WEBM up to 1GB."})]})]})]})),"youtube"===M&&(0,u.jsx)("div",{className:"".concat(Fe," p-6 sm:p-7"),children:(0,u.jsxs)("div",{className:"mx-auto max-w-3xl",children:[(0,u.jsxs)("div",{className:"mb-5 flex items-start gap-4",children:[(0,u.jsx)("div",{className:"rounded-2xl bg-red-500/10 p-3",children:(0,u.jsx)(Au,{size:28,className:"text-red-500"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-lg font-semibold",children:"Create from YouTube"}),(0,u.jsx)("p",{className:"mt-1 font-body text-sm leading-6 ".concat(Ae),children:"Paste a YouTube URL and ReScript will fetch the audio, preserve the source link, and start the ingest pipeline."})]})]}),(0,u.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row",children:[(0,u.jsxs)("div",{className:"relative flex-1",children:[(0,u.jsx)("input",{type:"text",value:j,onChange:e=>D(e.target.value),placeholder:"https://www.youtube.com/watch?v=...",className:"w-full pr-10 ".concat(Se),disabled:f,onKeyDown:e=>"Enter"===e.key&&fe()}),(0,u.jsx)(_u,{size:18,className:"absolute right-3 top-1/2 -translate-y-1/2 ".concat(Ae)})]}),(0,u.jsx)("button",{onClick:fe,disabled:f||!j.trim(),className:"rounded-full bg-[#FFB52B] px-6 py-3 font-headlines text-sm font-semibold text-[#232E3F] shadow-[0_20px_34px_-24px_rgba(255,181,43,0.92)] transition hover:-translate-y-0.5 hover:bg-[#FFC54D] disabled:cursor-not-allowed disabled:opacity-50",children:"Process"})]}),(0,u.jsxs)("div",{className:"mt-4",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>z(!R),className:"font-body text-sm underline ".concat(y?"text-[#FFE3A1]":"text-[#355E9A]"),children:[R?"Hide":"Show"," YouTube cookies (optional)"]}),R&&(0,u.jsxs)("div",{className:"mt-3",children:[(0,u.jsx)("textarea",{value:P,onChange:e=>
2L(e.target.value),placeholder:"# Netscape HTTP Cookie File\n.youtube.com TRUE / TRUE 1750423095 SOCS CAE...",className:"w-full ".concat(Se," font-mono text-xs"),rows:4,disabled:f}),(0,u.jsxs)("p",{className:"mt-2 font-body text-xs ".concat(Ae),children:["Paste exported cookies here only if the video needs them.",(0,u.jsx)("a",{href:"https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies",target:"_blank",rel:"noopener noreferrer",className:"ml-1 underline",children:"Learn how to export cookies"})]})]})]})]})}),"dropbox"===M&&(0,u.jsxs)("div",{className:"".concat(Fe," p-6 sm:p-7"),children:[(0,u.jsxs)("div",{className:"mb-5 flex items-start gap-4",children:[(0,u.jsx)("div",{className:"rounded-2xl bg-[#FFF4D9] p-3 dark:bg-brand-yellow/12",children:(0,u.jsx)(Bu,{size:28,className:"text-brand-yellow"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-lg font-semibold",children:"Create from Dropbox video"}),(0,u.jsx)("p",{className:"mt-1 max-w-3xl font-body text-sm leading-6 ".concat(Ae),children:"ReScript extracts aligned audio from the source video, creates the transcript from that audio, and queues AWS proxy preparation in the background."})]})]}),(0,u.jsx)(oh,{values:d(d({},le),{},{videoFilename:le.videoFilename||"",productionNotes:le.productionNotes||""}),onChange:e=>ce(t=>d(d({},t),e)),isDarkMode:y,showAutoPrepareToggle:!0,compact:!0}),(0,u.jsx)("div",{className:"mt-5 flex justify-end",children:(0,u.jsx)("button",{onClick:()=>{var e,t;if(T(""),!le.dropboxVideoUrl.trim())return void T("Please enter the Dropbox video URL");if(!dh.test(le.dropboxVideoUrl.trim()))return void T("Please enter a valid Dropbox share URL");if(!le.localVideoPath.trim())return void T("Please provide the local video path");if(!le.timelineName.trim())return void T("Please provide the timeline name");if(!le.dropboxDrpUrl.trim())return void T("Please provide the DRP Dropbox URL");const n=d(d({},le),{},{dropboxVideoUrl:le.dropboxVideoUrl.trim(),localVideoPath:le.localVideoPath.trim(),timelineName:le.timelineName.trim(),dropboxDrpUrl:le.dropboxDrpUrl.trim(),videoFilename:(null===(e=le.videoFilename)||void 0===e?void 0:e.trim())||"",productionNotes:(null===(t=le.productionNotes)||void 0===t?void 0:t.trim())||"",autoPrepareVideoSource:!1!==le.autoPrepareVideoSource});k(null),N(""),E(n),m(n)},disabled:f||!le.dropboxVideoUrl.trim(),className:"rounded-full bg-[#FFB52B] px-6 py-3 font-headlines text-sm font-semibold text-[#232E3F] shadow-[0_20px_34px_-24px_rgba(255,181,43,0.92)] transition hover:-translate-y-0.5 hover:bg-[#FFC54D] disabled:cursor-not-allowed disabled:opacity-50",children:"Process"})})]})]})]})})]})})})}),(0,u.jsx)(S,{children:A&&(0,u.jsxs)(Do.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mt-3 p-3 bg-red-50 dark:bg-red-900 border border-red-200 dark:border-red-700 rounded-lg flex items-center space-x-2",children:[(0,u.jsx)(Lu,{size:16,className:"text-red-500 flex-shrink-0"}),(0,u.jsx)("p",{className:"text-sm text-red-700 dark:text-red-200",children:A})]})})]})},mh=Mo("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),hh=Mo("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ph=Mo("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),gh=Mo("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),xh=e=>{let{status:t}=e;const n=()=>{switch(t.status){case"completed":return t.message.includes("cache")?"text-blue-600":"text-green-600";case"error":return"text-red-600";default:return"text-primary-600"}};return(0,u.jsx)(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"border rounded-xl p-6 ".concat((()=>{switch(t.status){case"completed":return t.message.includes("cache")?"bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700":"bg-green-50 dark:bg-green-900 border-green-200 dark:border-green-700";case"error":return"bg-red-50 dark:bg-red-900 border-red-200 dark:border-red-700";default:return"bg-primary-50 dark:bg-primary-900 border-primary-200 dark:border-primary-700"}})()),children:(0,u.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,u.jsx)("div",{className:n(),children:(()=>{switch(t.status){case"uploading":return(0,u.jsx)(Eu,{className:"animate-pulse",size:24});case"transcribing":return t.message.includes("cache")?(0,u.jsx)(mh,{className:"animate-pulse",size:24}):(0,u.jsx)(_o,{className:"animate-pulse",size:24});case"processing":return(0,u.jsx)(hh,{className:"animate-pulse",size:24});case"completed":return t.message.includes("cache")?(0,u.jsx)(mh,{className:"text-green-600",size:24}):(0,u.jsx)(ph,{className:"text-green-600",size:24});case"error":return(0,u.jsx)(gh,{className:"text-red-600",size:24});default:return(0,u.jsx)(Lo,{className:"animate-spin",size:24})}})()}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsx)("div",{className:"font-medium ".concat(n()),children:t.message}),void 0!==t.progress&&(0,u.jsxs)("div",{className:"mt-3",children:[(0,u.jsxs)("div",{className:"flex justify-between text-sm text-gray-600 dark:text-gray-300 mb-1",children:[(0,u.jsx)("span",{children:"Progress"}),(0,u.jsxs)("span",{children:[t.progress,"%"]})]}),(0,u.jsx)("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2",children:(0,u.jsx)(Do.div,{className:"h-2 rounded-full ".concat("error"===t.status?"bg-red-500":t.message.includes("cache")?"bg-blue-500":"bg-primary-500"),initial:{width:0},animate:{width:"".concat(t.progress,"%")},transition:{duration:.5}})})]}),t.message.includes("cache")&&"completed"===t.status&&(0,u.jsxs)("div",{className:"mt-2 text-sm text-blue-600 dar
2k:text-blue-400 flex items-center space-x-1",children:[(0,u.jsx)(mh,{size:14}),(0,u.jsx)("span",{children:"\u26a1 Instant result from cache - no API call needed!"})]})]})]})})},fh=Mo("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),bh=Mo("brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]),yh=Mo("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),vh=Mo("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),wh=Mo("pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]),kh=Mo("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]),jh=Mo("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),Dh=Mo("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),Ch="/api",Nh="/api/v1/agent",Fh={opus:"opus",sonnet:"sonnet",models:[{id:"opus",name:"Opus",description:"Most intelligent",tier:"opus"},{id:"sonnet",name:"Sonnet",description:"Fast & capable",tier:"sonnet"}]};function Sh(e){const t={};return(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&(t["Content-Type"]="application/json"),e&&(t.Authorization="Bearer ".concat(e)),t}async function Eh(e,t,n,a){const r=await fetch("".concat(Nh,"/sessions"),{method:"POST",credentials:"include",headers:Sh(a),body:JSON.stringify({episodeId:e,model:t,reasoningEffort:n})});if(!r.ok)throw new Error(await r.text());return r.json()}async function Ah(){let e=arguments.length>1?arguments[1]:void 0;const t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=new URLSearchParams;return e.episodeId&&t.set("episodeId",e.episodeId),e.scheduleId&&t.set("scheduleId",e.scheduleId),e.triggerType&&t.set("triggerType",e.triggerType),e.model&&t.set("model",e.model),e.dateFrom&&t.set("dateFrom",e.dateFrom),e.dateTo&&t.set("dateTo",e.dateTo),null!=e.limit&&t.set("limit",String(e.limit)),null!=e.offset&&t.set("offset",String(e.offset)),t}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),n=await fetch("".concat(Nh,"/sessions?").concat(t),{credentials:"include",headers:Sh(e)});if(!n.ok)throw new Error(await n.text());const a=await n.json();return{sessions:a.sessions||[],pagination:a.pagination||void 0}}async function Th(e,t){return(await Ah(e?{episodeId:e}:{},t)).sessions}async function Mh(e,t){const n=await fetch("".concat(Nh,"/sessions/").concat(e),{credentials:"include",headers:Sh(t)});if(!n.ok)throw new Error(await n.text());return n.json()}async function _h(e,t){const n=await fetch("".concat(Nh,"/sessions/").concat(e),{method:"DELETE",credentials:"include",headers:Sh(t)});if(!n.ok)throw new Error(await n.text())}async function Bh(e,t,n){const a=await fetch("".concat(Nh,"/sessions/").concat(e,"/messages"),{method:"POST",credentials:"include",headers:Sh(n),body:JSON.stringify({message:t})});if(!a.ok)throw new Error(await a.text());return a.json()}async function Ih(e,t){const n=await fetch("".concat(Nh,"/sessions/").concat(e,"/messages"),{credentials:"include",headers:Sh(t)});if(!n.ok)throw new Error(await n.text());return(await n.json()).messages||[]}async function Ph(e,t,n,a){const r=await fetch("".concat(Nh,"/sessions/").concat(e,"/respond"),{method:"POST",credentials:"include",headers:Sh(a),body:JSON.stringify({questionId:t,response:n})});if(!r.ok)throw new Error(await r.text())}async function Lh(e,t){const n=await fetch("".concat(Nh,"/sessions/").concat(e,"/stop"),{method:"POST",credentials:"include",headers:Sh(t)});if(!n.ok)throw new Error(await n.text())}async function Rh(e,t,n){const a=await fetch("".concat(Ch,"/agent/sessions/").concat(e,"/cost-limit"),{method:"PUT",credentials:"include",headers:Sh(n),body:JSON.stringify({costLimitUsd:t})});if(!a.ok)throw new Error(await a.text());return a.json()}async function zh(e,t,n){const a=await fetch("".concat(Ch,"/agent/sessions/").concat(e,"/runtime"),{method:"PUT",credentials:"include",headers:Sh(n),body:JSON.stringify(t)});if(!a.ok)throw new Error(await a.text());return a.json()}async function Oh(e,t){const n=await fetch("".concat(Nh,"/sessions/").concat(e,"/files"),{credentials:"include",headers:Sh(t)});if(!n.ok)throw new Error(await n.text());return(await n.json()).files||[]}
2async function Uh(e,t,n){const a=await fetch("".concat(Nh,"/sessions/").concat(encodeURIComponent(e),"/files/").concat(function(e){return String(e).split("/").filter(e=>""!==e).map(encodeURIComponent).join("/")}(t)),{credentials:"include",headers:Sh(n)});if(!a.ok)throw new Error(await a.text());return a.blob()}async function Vh(e,t,n,a){const r=new FormData;for(const o of t)r.append("files",o);const s=n?"?subdir=".concat(encodeURIComponent(n)):"",i=await fetch("".concat(Nh,"/sessions/").concat(e,"/files").concat(s),{method:"POST",credentials:"include",headers:Sh(a,!1),body:r});if(!i.ok)throw new Error(await i.text());return(await i.json()).uploaded}function Hh(e,t,n,a){const r=new URLSearchParams;a&&r.set("authToken",a);const s=r.toString()?"?".concat(r.toString()):"",i="".concat(Nh,"/sessions/").concat(e,"/stream").concat(s),o=new EventSource(i,{withCredentials:!0});return o.onmessage=e=>{try{const n=JSON.parse(e.data);t(n)}catch(_H){}},o.onerror=e=>{n&&n(e)},o}function qh(e){const t=Array.isArray(null===e||void 0===e?void 0:e.models)?e.models.map(e=>{const t="string"===typeof(null===e||void 0===e?void 0:e.id)?e.id.trim():"",n="opus"===(null===e||void 0===e?void 0:e.tier)||"sonnet"===(null===e||void 0===e?void 0:e.tier)?e.tier:null;return t&&n?{id:t,name:"string"===typeof(null===e||void 0===e?void 0:e.name)&&e.name.trim()?e.name.trim():"opus"===n?"Opus":"Sonnet",description:"string"===typeof(null===e||void 0===e?void 0:e.description)?e.description:"",tier:n}:null}).filter(Boolean):[];var n,a;if(t.length>0)return{opus:"string"===typeof(null===e||void 0===e?void 0:e.opus)&&e.opus.trim()?e.opus.trim():(null===(n=t.find(e=>"opus"===e.tier))||void 0===n?void 0:n.id)||Fh.opus,sonnet:"string"===typeof(null===e||void 0===e?void 0:e.sonnet)&&e.sonnet.trim()?e.sonnet.trim():(null===(a=t.find(e=>"sonnet"===e.tier))||void 0===a?void 0:a.id)||Fh.sonnet,models:t};const r="string"===typeof(null===e||void 0===e?void 0:e.opus)&&e.opus.trim()?e.opus.trim():Fh.opus,s="string"===typeof(null===e||void 0===e?void 0:e.sonnet)&&e.sonnet.trim()?e.sonnet.trim():Fh.sonnet;return{opus:r,sonnet:s,models:[{id:r,name:"Opus",description:"Most intelligent",tier:"opus"},{id:s,name:"Sonnet",description:"Fast & capable",tier:"sonnet"}]}}async function Wh(e){const t=["".concat(Ch,"/v1/models"),"".concat(Nh,"/models/latest"),"".concat(Nh,"/models")];let n=null;for(const r of t)try{const t=await fetch(r,{credentials:"include",headers:Sh(e,!1)});if(!t.ok)throw new Error(await t.text());return qh(await t.json())}catch(a){n=a instanceof Error?a:new Error(String(a))}return n&&console.error("[agentService] Failed to load latest models:",n),Fh}async function Yh(e,t){const n=await fetch("".concat(Ch,"/v1/agent/workflows/transcript-refinement"),{method:"POST",credentials:"include",headers:Sh(t),body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()}async function Gh(e,t){const n=await fetch("".concat(Ch,"/v1/agent/workflows/metadata-revision"),{method:"POST",credentials:"include",headers:Sh(t),body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()}async function Kh(e,t){const n=await fetch("".concat(Ch,"/v1/agent/workflows/metadata-generation"),{method:"POST",credentials:"include",headers:Sh(t),body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()}async function Xh(e,t){const n=await fetch("".concat(Ch,"/v1/agent/workflows/topic-map"),{method:"POST",credentials:"include",headers:Sh(t),body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()}async function Jh(e,t){const n=await fetch("".concat(Ch,"/v1/agent/workflows/title-generation"),{method:"POST",credentials:"include",headers:Sh(t),body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()}async function $h(e,t){const n=await fetch("".concat(Ch,"/v1/agent/workflows/speaker-inference"),{method:"POST",credentials:"include",headers:Sh(t),body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()}async function Qh(e){const t=await fetch("".concat(Ch,"/agent/api-key"),{credentials:"include",headers:Sh(e)});if(!t.ok)throw new Error(await t.text());return t.json()}async function Zh(e,t){const n=await fetch("".concat(Ch,"/agent/api-key"),{method:"PUT",credentials:"include",headers:Sh(t),body:JSON.stringify({apiKey:e})});if(!n.ok)throw new Error(await n.text());return n.json()}class ep{static async fetchSpeakerSampleUrl(e,t,n){const a={};n&&(a.Authorization="Bearer ".concat(n));const r=await fetch("".concat("/api","/audio/").concat(encodeURIComponent(e),"/speaker-sample/").concat(t),{headers:a,redirect:"follow"});if(!r.ok)throw new Error("Audio playback failed: HTTP ".concat(r.status));const s=await r.blob();if(!s.size)throw new Error("Speaker sample was empty");return URL.createObjectURL(s)}}const tp=["#81A1C1","#88C0D0","#8FBCBB","#A3BE8C","#EBCB8B","#D08770","#B48EAD"],np=["#5E81AC","#5E97A5","#5E9694","#7E9969","#B08D54","#A96E5C","#8F739D"],ap=[48,54,46,58],rp=[58,64,56,62,68],sp=[58,54,50,62],ip=[54,60,50,56,62],op=(e,t,n)=>Math.min(Math.max(e,t),n),lp=e=>"boolean"===typeof e?e:"undefined"!==typeof document&&document.documentElement.classList.contains("dark"),cp=e=>Number.isFinite(Number(e))?Number(e):0,dp=(e,t)=>{const n=cp(e),a=lp(t),r=(e=>(137.508*cp(e)+18)%360)(n),s=a?sp:ap,i=a?ip:rp;let o=s[n%s.length],l=i[Math.floor(n/s.length)%i.length];return r>=42&&r<=84&&(o+=a?4:6,l+=a?-2:4),((e,t,n)=>{const a=(e%360+360)%360,r=op(t,0,100)/100,s=op(n,0,100)/100,i=(1-Math.abs(2*s-1))*r,o=a/60,l=i*(1-Math.abs(o%2-1));let c=0,d=0,u=0;o>=0&&o<1?(c=i,d=l):o>=1&&o<2?(c=l,d=i):o>=2&&o<3?(d=i,u=l):o>=3&&o<4?(d=l,u=i):o>=4&&o<5?(c=l,u=i):(c=i,u=l);const m=s-i/2,h=e=>Math.round(255*(e+m)).toString(16).padStart(2,"0");return"#".concat(h(c)).concat(h(d)).concat(h(u))})(r,o,l)},up=(e,t)=>{const n=e.replace("#",""),a=3===n.length?n.split("").map(e=>"".concat(e).concat(e)).join(""):n,r=parseInt(a.slice(0,2),16),s=parseInt(a.slice(2,4),16),i=parseInt(a.slice(4,6),16);return"rgba(".concat(r,", ").concat(s,", ").concat(i,", ").concat(t,")")},mp=(e,t)=>(()=>{const n=cp(e),a=lp(t)?np:tp;return n>=0&&n<7?a[n]:dp(n,t)})(),hp=(e,t)=>{const n=mp(e,t);return"linear-gradient(to right, ".concat(up(n,.7),", ").concat(up(n,1),", ").concat(up(n,.7),")")},pp=e=>{let{sessionId:t,speakers:n,speakerSegments:r,audioFile:s,onLabelsComplete:i,initialLabels:o,className:l="",isYouTubeMode:c=!1,transcriptionChecksum:m}=e;const{token:h}=am(),{isDarkMode:p}=zu(),g=oc(),[x,f]=(0,a.useState)(()=>{const e={};
2return n.forEach(t=>{e[t]=(null===o||void 0===o?void 0:o[t])||"Speaker ".concat(t)}),e}),[b,y]=(0,a.useState)(null),[v,w]=(0,a.useState)(""),[k,j]=(0,a.useState)(!1),[D,C]=(0,a.useState)(!1),[N,F]=(0,a.useState)(null),E=(0,a.useRef)(new Map);(0,a.useEffect)(()=>{E.current.forEach(e=>{e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),e.pause()}),E.current.clear(),y(null),w(""),C(!1),F(null)},[m]);const A=async()=>{if(t&&0!==n.length&&!k&&!D)try{j(!0),w("");const e=await $h({sessionId:t,enableWebSearch:!0},h||void 0);F(e.agentSessionId),C(!0)}catch(v){console.error("Speaker name inference failed:",v),w("Failed to start the speaker inference agent. You can still label speakers manually.")}finally{j(!1)}};(0,a.useEffect)(()=>{m&&n.length>0&&(!o||n.every(e=>!o[e]||o[e]==="Speaker ".concat(e)))&&(console.log("[SPEAKER-INFERENCE] Triggering automatic inference on mount"),A())},[m,n.length]);const T=e=>{var t;return(null===(t=r.get(e))||void 0===t?void 0:t.length)||0},M=e=>(r.get(e)||[]).reduce((e,t)=>e+(t.end-t.start),0);return 0===n.length?(0,u.jsx)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"card ".concat(l),children:(0,u.jsxs)("div",{className:"text-center py-8",children:[(0,u.jsx)(Lu,{size:48,className:"text-gray-400 dark:text-gray-500 mx-auto mb-4"}),(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"No Speakers Detected"}),(0,u.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:"The audio file doesn't contain multiple speakers or speaker diarization failed."})]})}):(0,u.jsx)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"card ".concat(l),children:(0,u.jsxs)("div",{className:"space-y-6",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"p-2 bg-purple-100 dark:bg-purple-800 rounded-lg",children:(0,u.jsx)(fh,{size:20,className:"text-purple-600"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"font-semibold text-gray-800 dark:text-gray-200",children:"Label Speakers"}),(0,u.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:s&&!c?"Identify the speakers by listening to audio samples":c?"Identify the speakers by reviewing their segments (audio samples temporarily unavailable for YouTube videos)":"Identify the speakers by reviewing their segments (audio samples not available)"})]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("button",{onClick:()=>g("/"),className:"p-2 text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Return to Home",children:(0,u.jsx)(Io,{size:18})}),m&&(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[k&&(0,u.jsxs)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},className:"flex items-center space-x-2 text-sm text-blue-600 dark:text-blue-400",children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),(0,u.jsx)("span",{children:"AI is analyzing..."})]}),!k&&(0,u.jsx)("button",{onClick:A,className:"flex items-center px-3 py-2 text-sm bg-blue-50 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded-lg hover:bg-blue-100 dark:hover:bg-blue-800 transition-colors",title:n.length>1?"Start the speaker inference agent":"Start the speaker naming agent",children:(0,u.jsx)(bh,{size:16})})]})]})]}),N&&!k&&(0,u.jsxs)(Do.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"bg-blue-50 dark:bg-blue-900 border border-blue-200 dark:border-blue-700 rounded-lg p-4",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)(bh,{size:16,className:"text-blue-600 dark:text-blue-400"}),(0,u.jsx)("span",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:"Speaker inference agent started"})]}),(0,u.jsxs)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("navigate-to-agent",{detail:{agentSessionId:N}})),className:"inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300",children:["Open agent",(0,u.jsx)(yh,{size:12})]})]}),(0,u.jsx)("p",{className:"mt-2 text-xs text-blue-700 dark:text-blue-200",children:"The agent will infer speaker labels through the ReScript CLI and save them back onto this session. Open the agent tab if you want to supervise or interject."})]}),n.length>1&&(0,u.jsxs)(Do.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4",children:[(0,u.jsx)("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Speaker Timeline"}),(()=>{const{segments:e,totalDuration:t}=(()=>{const e=[];n.forEach(t=>{(r.get(t)||[]).forEach(n=>{e.push({start:n.start,end:n.end,speaker:t})})}),e.sort((e,t)=>e.start-t.start);const t=e.length>0?Math.max(...e.map(e=>e.end)):0;return{segments:e,totalDuration:t}})();return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"relative h-8 bg-gray-200 dark:bg-gray-700 rounded overflow-hidden",children:e.map((e,n)=>{const a=e.start/t*100,r=(e.end-e.start)/t*100;return(0,u.jsx)("div",{className:"absolute h-full opacity-80",style:{backgroundColor:mp(e.speaker,p),left:"".concat(a,"%"),width:"".concat(r,"%")},title:"Speaker ".concat(e.speaker,": ").concat(Math.round(e.start),"s - ").concat(Math.round(e.end),"s")},n)})}),(0,u.jsx)("div",{className:"flex flex-wrap gap-3 text-xs",children:n.map(e=>{const n=M(e),a=t>0?(n/t*100).toFixed(1):"0";return(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("div",{className:"w-3 h-3 rounded",style:{backgroundColor:mp(e,p)}}),(0,u.jsxs)("span",{className:"text-gray-600 dark:text-gray-400",children:[x[e]||"Speaker ".concat(e)," (",a,"%)"]})]},e)})}),(0,u.jsx)("div",{className:"relative text-xs text-gray-500 dark:text-gray-400",children:(0,u.jsxs)("div",{className:"flex justify-between",children:[(0,u.jsx)("span",{children:"0:00"}),(0,u.jsxs)("span",{children:[Math.floor(t/60),":",(t%60).toFixed(0).padStart(2,"0")]})]})})]})})()]}),(0,u.jsx)("div",{className:"space-y-4",children:n.map(e=>(0,u.jsxs)(Do.div,{initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*e},className:"flex items-center space-x-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3 flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("div",{className:"w-4 h-4 rounded",style:{backgroundColor:mp(e,p)}}),(0,u.jsx)("div",{className:"p-2 bg-white dark:bg-gray-700 rounded-lg shadow-sm",children:(0,u.jsx)(vh,{size:16,className:"text-gray-600 dark:text-gray-300"})})]}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,u.jsxs)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Speaker ",e]}),(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[T(e)," segments \u2022 ",Math.round(M(e)),"s"]})]}),(0,u.jsx)("input",{type:"text",value:x[e]||"",onChange:t=>((e,t)=>{f(n=>d(d({},n),{},{[e]:t}))})(e,t.target.value),placeholder:"Enter name for Speaker ".concat(e,"..."),className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:border-primary-500 focus:ring-1 focus:ring-primary-200 transition-all duration-200"})]})]}),s&&!c&&(0,u.jsx)("button",{onClick:()=>b===e?(e=>{const t=E.current.get(e);t&&(t.pause(),t.currentTime=0),y(null)})(e):(async e=>{try{if(w(""),null!==b){const e=E.current.get(b);e&&(e.pause(),e.currentTime=0)}if(!m)return void w("Audio not available for Speaker ".concat(e));let n=E.current.get(e);if(!n){try{const t=await ep.fetchSpeakerSampleUrl(m,e,h||void 0);n=new Audio(t),E.current.set(e,n)}catch(t){return console.error("[SPEAKER-LABELING] Failed to fetch speaker sample:",t),void w("Failed to load audio sample for Speaker ".concat(e,". Audio may not be available for this session."))}n.addEventListener("ended",()=>{y(null)}),n.addEventListener("error",()=>{w("Failed to play audio sample for Speaker ".concat(e)),y(null)})}n.currentTime=0,y(e),await n.play()}catch(v){console.error("Audio playback error:",v),w("Failed to play audio sample for Speaker ".concat(e)),y(null)}})(e),disabled:null!==b&&b!==e,className:"\n flex items-center space-x-2 px-3 py-2 rounded-lg font-medium transition-all duration-200\n ".concat(b===e?"bg-red-100 dark:bg-red-800 text-red-700 dark:text-red-200 hover:bg-red-200 dark:hover:bg-red-700":"bg-primary-100 dark:bg-primary-800 text-primary-700 dark:text-primary-200 hover:bg-primary-200 dark:hover:bg-primary-700","\n disabled:opacity-50 disabled:cursor-not-allowed\n "),children:b===e?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(wh,{size:16}),(0,u.jsx)("span",{className:"text-sm",children:"Stop"})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(kh,{size:16}),(0,u.jsx)("span",{className:"text-sm",children:"Play Sample"})]})})]},e))}),(0,u.jsx)(S,{children:v&&(0,u.jsxs)(Do.div,{initial:{opacity:0,height:0}
2,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"p-3 bg-red-50 dark:bg-red-900 border border-red-200 dark:border-red-700 rounded-lg flex items-center space-x-2",children:[(0,u.jsx)(Lu,{size:16,className:"text-red-500 flex-shrink-0"}),(0,u.jsx)("p",{className:"text-sm text-red-700 dark:text-red-200",children:v})]})}),(0,u.jsxs)("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200 dark:border-gray-700",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2 text-sm text-gray-500 dark:text-gray-400",children:[(0,u.jsx)(jh,{size:16}),(0,u.jsx)("span",{children:"Play samples to identify speakers"})]}),(0,u.jsxs)("button",{onClick:()=>{const e={};n.forEach(t=>{e[t]=x[t]||"Speaker ".concat(t)}),i(e)},className:"btn-primary flex items-center space-x-2",children:[(0,u.jsx)(Dh,{size:16}),(0,u.jsx)("span",{children:"Save Labels & Generate Transcript"})]})]})]})})},gp=Mo("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),xp=Mo("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]),fp=Mo("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),bp=Mo("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),yp=Mo("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]),vp=Mo("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),wp=Mo("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]),kp=Mo("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]),jp=Mo("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]),Dp=Mo("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]),Cp=Mo("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),Np=Mo("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Fp=Mo("message-square",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),Sp=Mo("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]),Ep=Mo("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),Ap=Mo("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),Tp="/api",Mp="openrouter_api_key",_p="openrouter_selected_model",Bp="anthropic_refinement_model",Ip="mlst_browser_id",Pp={generateBrowserId(){const e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")},getBrowserId(){try{let e=localStorage.getItem(Ip);return e||(e=this.generateBrowserId(),localStorage.setItem(Ip,e)),e}catch(_H){return this.generateBrowserId()}},clearBrowserId(){try{localStorage.removeItem(Ip)}catch(BH){console.error("[BROWSER-ID] Failed to clear browser ID:",BH)}}},Lp={getApiKey(){try{return localStorage.getItem(Mp)}catch(e){return null}},setApiKey(e){try{localStorage.setItem(Mp,e)}catch(BH){console.error("[BYOK] Failed to save API key:",BH)}},clearApiKey(){try{localStorage.removeItem(Mp)}catch(BH){console.error("[BYOK] Failed to clear API key:",BH)}},hasApiKey(){return!!this.getApiKey()},getMaskedKey(){const e=this.getApiKey();return e?e.length<=16?"****":"".concat(e.substring(0,8),"...").concat(e.substring(e.length-4)):null},isValidKeyFormat:e=>e.startsWith("sk-or-")&&e.length>20},Rp={getSelectedModel(){try{return localStorage.getItem(_p)}catch(e){return null}},setSelectedModel(e){try{localStorage.setItem(_p,e)}catch(BH){console.error("[MODEL] Failed to save selected model:",BH)}},getRefinementModel(){try{return localStorage.getItem(Bp)}catch(e){return null}},setRefinementModel(e){try{localStorage.setItem(Bp,e)}catch(BH){console.error("[MODEL] Failed to save refinement model:",BH)}}};class zp{static async request(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const a="".concat(Tp).concat(e),r=new Headers(t.headers);r.set("Content-Type","application/json"),n&&r.set("Authorization","Bearer ".concat(n));const s=await fetch(a,d({headers:r},t));if(!s.ok){const e=await s.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(s.status))}return s.json()}
2static async getSupportedModels(e){return(await this.request("/supported-models",{},e)).models}static async getOpenRouterModels(e){const t="".concat(Tp,"/openrouter-models"),n=new Headers;n.set("Content-Type","application/json"),e&&n.set("Authorization","Bearer ".concat(e));const a=await fetch(t,{headers:n});if(!a.ok)throw new Error("Failed to fetch models: ".concat(a.status));return a.json()}static async getCachedTTMLVersions(e,t){return this.request("/get-cached-ttml-versions",{method:"POST",body:JSON.stringify(e)},t)}static async downloadCachedTTML(e,t){const n=new Headers;t&&n.set("Authorization","Bearer ".concat(t));const a=await fetch("".concat(Tp,"/download-cached-ttml/").concat(e),{method:"GET",headers:n});if(!a.ok){const e=await a.json().catch(()=>({error:"Failed to download cached TTML"}));throw new Error(e.error||"Failed to download cached TTML")}return a.blob()}static async chatWithTranscript(e,t,n){const a="".concat(Tp,"/chat-transcript"),r=new Headers;r.set("Content-Type","application/json"),t&&r.set("Authorization","Bearer ".concat(t)),n&&r.set("X-OpenRouter-Key",n);const s=await fetch(a,{method:"POST",headers:r,body:JSON.stringify(e)});if(!s.ok){const e=await s.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(s.status))}return s.json()}static async chatWithTranscriptStreaming(e,t,n,a,r,s,i,o,l,c,d,u,m,h,p,g,x,f,b,y){try{var v;const w=new Headers;w.set("Content-Type","application/json"),o&&w.set("Authorization","Bearer ".concat(o)),x&&w.set("X-OpenRouter-Key",x),y&&w.set("X-Share-Token",y);const k=await fetch("".concat(Tp,"/chat-transcript-stream"),{method:"POST",headers:w,body:JSON.stringify({transcript:e,model:t,messages:n,temperature:1,max_tokens:6e4,ttmlContent:l,uploadedFiles:null===c||void 0===c?void 0:c.map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,mimeType:e.mimeType})),sessionId:d,conversationId:g,enableTTMLOutput:m,reasoning:f,disableTimecodeLinks:b,shareToken:y}),signal:null===u||void 0===u?void 0:u.signal});if(!k.ok){const e=await k.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(k.status))}const j=null===(v=k.body)||void 0===v?void 0:v.getReader();if(!j)throw new Error("No response body reader available");const D=new TextDecoder;let C="";try{for(;;){if(null!==u&&void 0!==u&&u.signal.aborted)throw new Error("Stream cancelled by user");const{done:e,value:t}=await j.read();if(e)break;C+=D.decode(t,{stream:!0});const n=C.split("\n");C=n.pop()||"";for(const o of n)if(o.startsWith("data: ")){const e=o.slice(6);if(""===e.trim())continue;try{const t=JSON.parse(e);this.handleStreamEvent(t,a,s,i,r,h,p)}catch(TS){console.warn("[CHAT-STREAM] Primary JSON parse failed, attempting to extract multiple JSON objects"),this.parseMultipleJsonObjects(e,a,s,i,r,h,p)}}}}finally{j.releaseLock()}}catch(w){console.error("[CHAT-STREAM] Streaming error:",w),i(w instanceof Error?w.message:"Streaming failed")}}static async deleteCachedTTML(e,t){return this.request("/delete-cached-ttml/".concat(e),{method:"DELETE"},t)}static async getTtmlJobs(e,t){return this.request("/sessions/".concat(e,"/ttml-jobs"),{},t)}static async deleteTtmlJob(e,t,n){return this.request("/sessions/".concat(e,"/ttml-jobs/").concat(t),{method:"DELETE"},n)}static async getRefinementJobs(e,t){return this.request("/sessions/".concat(e,"/refinement-jobs"),{},t)}static async deleteRefinementJob(e,t,n){return this.request("/sessions/".concat(e,"/refinement-jobs/").concat(t),{method:"DELETE"},n)}static handleStreamEvent(e,t,n,a,r,s,i){var o,l;switch(e.type){case"start":console.log("[CHAT-STREAM] Stream started");break;case"content":console.log("[CHAT-STREAM] Content chunk received:",(null===(o=e.content)||void 0===o?void 0:o.length)||0,"chars"),t(e.content,e.totalTokens);break;case"ttml_block":e.ttml&&e.filename&&r(e.ttml,e.filename);break;case"complete":console.log("[CHAT-STREAM] Stream completed:",e.finish_reason),n(e.usage);break;case"error":console.log("[CHAT-STREAM] Error event received:",e.error),a(e.error);break;case"end":console.log("[CHAT-STREAM] End event received");break;case"tool_call":console.log("[CHAT-STREAM] Tool call received:",e.tool_name,"result length:",(null===(l=e.tool_result)||void 0===l?void 0:l.length)||0),s?s(e.tool_name,e.tool_result):console.warn("[CHAT-STREAM] No onToolCall handler provided!");break;case"tool_error":console.error("[CHAT-STREAM] Tool error:",e.tool_name,e.error),i&&i(e.tool_name,e.error);break;case"ping":break;default:console.log("[CHAT-STREAM] Unknown event type:",e.type)}}static parseMultipleJsonObjects(e,t,n,a,r,s,i){try{console.log("[CHAT-STREAM] Parsing malformed data:",e.substring(0,200));const l=e.split(/\\n\\ndata:\s*/);for(const e of l)if(""!==e.trim())try{const o=JSON.parse(e);console.log("[CHAT-STREAM] Successfully parsed extracted JSON:",o.type),this.handleStreamEvent(o,t,n,a,r,s,i)}catch(o){console.warn("[CHAT-STREAM] Failed to parse JSON part:",e.substring(0,100),o)}}catch(l){console.error("[CHAT-STREAM] Error in parseMultipleJsonObjects:",l)}}static async analyzeGaps(e,t,n){const a=d(d({},t),{},{transcriptSource:t.transcriptSource||t.source});return this.request("/v1/episodes/".concat(e,"/gaps/analyze"),{method:"POST",body:JSON.stringify(a)},n)}static async getStoredGapAnalysis(e,t,n){const a=new URLSearchParams;null!==t&&void 0!==t&&t.source&&a.set("source",t.source);const r=a.toString()?"?".concat(a.toString()):"";return this.request("/v1/episodes/".concat(e,"/gaps").concat(r),{},n)}static async getHesitationTranscriptStatus(e,t){const n=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?"?include=deepgram":"";return this.request("/v1/episodes/".concat(e,"/gaps/hesitation-transcript").concat(n),{},t)}static async ensureHesitationTranscript(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.request("/v1/episodes/".concat(e,"/gaps/hesitation-transcript"),{method:"POST",body:JSON.stringify(n?{force:!0}:{})},t)}static getGapTtmlDownloadUrl(e,t){const n=new URLSearchParams;return void 0!==t.minGapSeconds&&n.set("minGapSeconds",String(t.minGapSeconds)),void 0!==t.relativeThreshold&&n.set("relativeThreshold",String(t.relativeThreshold)),t.transcriptSource&&n.set("source",t.transcriptSource),"".concat(Tp,"/v1/episodes/").concat(e,"/gaps/ttml/download?").concat(n.toString())}
2static async applyGeneratedGapEdits(e,t,n){const a=d(d({},t),{},{transcriptSource:t.transcriptSource||t.source});return this.request("/v1/episodes/".concat(e,"/gaps/edits/apply"),{method:"POST",body:JSON.stringify(a)},n)}static async removeGeneratedGapEdits(e,t,n){return this.request("/v1/episodes/".concat(e,"/gaps/edits/remove"),{method:"POST",body:JSON.stringify(t||{})},n)}}const Op=zp,Up=async e=>{try{var t,n;if(null!==(t=navigator)&&void 0!==t&&null!==(n=t.clipboard)&&void 0!==n&&n.writeText)return await navigator.clipboard.writeText(e),!0;const a=document.createElement("textarea");a.value=e,a.style.position="fixed",a.style.left="-999999px",a.style.top="-999999px",document.body.appendChild(a),a.focus(),a.select();const r=document.execCommand("copy");return document.body.removeChild(a),r}catch(a){return console.error("Failed to copy to clipboard:",a),!1}},Vp=(0,a.createContext)({permissions:null,shareToken:null,metadata:void 0}),Hp=()=>(0,a.useContext)(Vp),qp=e=>{let{children:t,permissions:n=null,shareToken:a=null,metadata:r}=e;return(0,u.jsx)(Vp.Provider,{value:{permissions:n,shareToken:a,metadata:r},children:t})};function Wp(){}function Yp(){}const Gp=/^
vendor: 18,265 bytes, line 2
2(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[\$0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0897-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDD\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF3\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF65-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD6D\uDD6F-\uDD85\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDEC2-\uDEC4\uDEFC-\uDF1C\uDF27\uDF30-\uDF50\uDF70-\uDF85\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC75\uDC7F-\uDCBA\uDCC2\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E-\uDE41\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD3\uDFE1\uDFE2]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDED0-\uDEE3\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0\uDFF0-\uDFF9]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF5A\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD39]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDD70-\uDD79\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDCF0-\uDCF9\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC30-\uDC6D\uDC8F\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAE\uDEC0-\uDEF9]|\uD839[\uDCD0-\uDCF9\uDDD0-\uDDFA\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF]|\uDB40[\uDD00-\uDDEF])*
2$/,Kp=/^(?:[\$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
2D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC4\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[\$\x2D0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u0870-\u0887\u0889-\u088E\u0897-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3C-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C5D\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDD\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1-\u0CF3\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1715\u171F-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B4C\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
2D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF65-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD6D\uDD6F-\uDD85\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDEC2-\uDEC4\uDEFC-\uDF1C\uDF27\uDF30-\uDF50\uDF70-\uDF85\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC75\uDC7F-\uDCBA\uDCC2\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E-\uDE41\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD3\uDFE1\uDFE2]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDED0-\uDEE3\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39\uDF40-\uDF46]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0\uDFF0-\uDFF9]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDF00-\uDF10\uDF12-\uDF3A\uDF3E-\uDF42\uDF50-\uDF5A\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC40-\uDC55\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD39]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDE70-\uDEBE\uDEC0-\uDEC9\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDD70-\uDD79\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD833[\uDCF0-\uDCF9\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC30-\uDC6D\uDC8F\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDE90-\uDEAE\uDEC0-\uDEF9]|\uD839[\uDCD0-\uDCF9\uDDD0-\uDDFA\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF]|\uDB40[\uDD00-\uDDEF])*$/,Xp={};function Jp(e,t){return((t||Xp).jsx?Kp:Gp).test(e)}const $p=/[ \t\n\f\r]/g;function Qp(e){return""===e.replace($p,"")}class Zp{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}function eg(e,t){const n={},a={};for(const r of e)Object.assign(n,r.property),Object.assign(a,r.normal);return new Zp(n,a,t)}function tg(e){return e.toLowerCase()}Zp.prototype.normal={},Zp.prototype.property={},Zp.prototype.space=void 0;
vendor: 4,831 bytes, line 2
2class ng{constructor(e,t){this.attribute=t,this.property=e}}ng.prototype.attribute="",ng.prototype.booleanish=!1,ng.prototype.boolean=!1,ng.prototype.commaOrSpaceSeparated=!1,ng.prototype.commaSeparated=!1,ng.prototype.defined=!1,ng.prototype.mustUseProperty=!1,ng.prototype.number=!1,ng.prototype.overloadedBoolean=!1,ng.prototype.property="",ng.prototype.spaceSeparated=!1,ng.prototype.space=void 0;let ag=0;const rg=ug(),sg=ug(),ig=ug(),og=ug(),lg=ug(),cg=ug(),dg=ug();function ug(){return 2**++ag}const mg=Object.keys(e);class hg extends ng{constructor(t,n,a,r){let s=-1;if(super(t,n),pg(this,"space",r),"number"===typeof a)for(;++s<mg.length;){const t=mg[s];pg(this,mg[s],(a&e[t])===e[t])}}}function pg(e,t,n){n&&(e[t]=n)}function gg(e){const t={},n={};for(const[a,r]of Object.entries(e.properties)){const s=new hg(a,e.transform(e.attributes||{},a),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(a)&&(s.mustUseProperty=!0),t[a]=s,n[tg(a)]=a,n[tg(s.attribute)]=a}return new Zp(t,n,e.space)}hg.prototype.defined=!0;const xg=gg({properties:{ariaActiveDescendant:null,ariaAtomic:sg,ariaAutoComplete:null,ariaBusy:sg,ariaChecked:sg,ariaColCount:og,ariaColIndex:og,ariaColSpan:og,ariaControls:lg,ariaCurrent:null,ariaDescribedBy:lg,ariaDetails:null,ariaDisabled:sg,ariaDropEffect:lg,ariaErrorMessage:null,ariaExpanded:sg,ariaFlowTo:lg,ariaGrabbed:sg,ariaHasPopup:null,ariaHidden:sg,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lg,ariaLevel:og,ariaLive:null,ariaModal:sg,ariaMultiLine:sg,ariaMultiSelectable:sg,ariaOrientation:null,ariaOwns:lg,ariaPlaceholder:null,ariaPosInSet:og,ariaPressed:sg,ariaReadOnly:sg,ariaRelevant:null,ariaRequired:sg,ariaRoleDescription:lg,ariaRowCount:og,ariaRowIndex:og,ariaRowSpan:og,ariaSelected:sg,ariaSetSize:og,ariaSort:null,ariaValueMax:og,ariaValueMin:og,ariaValueNow:og,ariaValueText:null,role:null},transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase()});function fg(e,t){return t in e?e[t]:t}function bg(e,t){return fg(e,t.toLowerCase())}const yg=gg({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:cg,acceptCharset:lg,accessKey:lg,action:null,allow:null,allowFullScreen:rg,allowPaymentRequest:rg,allowUserMedia:rg,alt:null,as:null,async:rg,autoCapitalize:null,autoComplete:lg,autoFocus:rg,autoPlay:rg,blocking:lg,capture:null,charSet:null,checked:rg,cite:null,className:lg,cols:og,colSpan:null,content:null,contentEditable:sg,controls:rg,controlsList:lg,coords:og|cg,crossOrigin:null,data:null,dateTime:null,decoding:null,default:rg,defer:rg,dir:null,dirName:null,disabled:rg,download:ig,draggable:sg,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:rg,formTarget:null,headers:lg,height:og,hidden:ig,high:og,href:null,hrefLang:null,htmlFor:lg,httpEquiv:lg,id:null,imageSizes:null,imageSrcSet:null,inert:rg,inputMode:null,integrity:null,is:null,isMap:rg,itemId:null,itemProp:lg,itemRef:lg,itemScope:rg,itemType:lg,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:rg,low:og,manifest:null,max:null,maxLength:og,media:null,method:null,min:null,minLength:og,multiple:rg,muted:rg,name:null,nonce:null,noModule:rg,noValidate:rg,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:rg,optimum:og,pattern:null,ping:lg,placeholder:null,playsInl
2ine:rg,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:rg,referrerPolicy:null,rel:lg,required:rg,reversed:rg,rows:og,rowSpan:og,sandbox:lg,scope:null,scoped:rg,seamless:rg,selected:rg,shadowRootClonable:rg,shadowRootDelegatesFocus:rg,shadowRootMode:null,shape:null,size:og,sizes:null,slot:null,span:og,spellCheck:sg,src:null,srcDoc:null,srcLang:null,srcSet:null,start:og,step:null,style:null,tabIndex:og,target:null,title:null,translate:null,type:null,typeMustMatch:rg,useMap:null,value:sg,width:og,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lg,axis:null,background:null,bgColor:null,border:og,borderColor:null,bottomMargin:og,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:rg,declare:rg,event:null,face:null,frame:null,frameBorder:null,hSpace:og,leftMargin:og,link:null,longDesc:null,lowSrc:null,marginHeight:og,marginWidth:og,noResize:rg,noHref:rg,noShade:rg,noWrap:rg,object:null,profile:null,prompt:null,rev:null,rightMargin:og,rules:null,scheme:null,scrolling:sg,standby:null,summary:null,text:null,topMargin:og,valueType:null,version:null,vAlign:null,vLink:null,vSpace:og,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:rg,disableRemotePlayback:rg,prefix:null,property:null,results:og,security:null,unselectable:null},space:"html",transform:bg}),vg=gg({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav
2-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:dg,accentHeight:og,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:og,amplitude:og,arabicForm:null,ascent:og,attributeName:null,attributeType:null,azimuth:og,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:og,by:null,calcMode:null,capHeight:og,className:lg,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:og,diffuseConstant:og,direction:null,display:null,dur:null,divisor:og,dominantBaseline:null,download:rg,dx:null,dy:null,edgeMode:null,editable:null,elevation:og,enableBackground:null,end:null,event:null,exponent:og,externalResourcesRequired:null,fill:null,fillOpacity:og,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:cg,g2:cg,glyphName:cg,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:og,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:og,horizOriginX:og,horizOriginY:og,id:null,ideographic:og,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:og,k:og,k1:og,k2:og,k3:og,k4:og,kernelMatrix:dg,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:og,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:og,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,on
2Zoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:og,overlineThickness:og,paintOrder:null,panose1:null,path:null,pathLength:og,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lg,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:og,pointsAtY:og,pointsAtZ:og,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:dg,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:dg,rev:dg,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:dg,requiredFeatures:dg,requiredFonts:dg,requiredFormats:dg,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:og,specularExponent:og,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:og,strikethroughThickness:og,string:null,stroke:null,strokeDashArray:dg,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:og,strokeOpacity:og,strokeWidth:null,style:null,surfaceScale:og,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:dg,tabIndex:og,tableValues:null,target:null,targetX:og,targetY:og,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:dg,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:og,underlineThickness:og,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:og,values:null,vAlphabetic:og,vMathematical:og,vectorEffect:null,vHanging:og,vIdeographic:og,version:null,vertAdvY:og,vertOriginX:og,vertOriginY:og,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:og,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:fg}),wg=gg({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase()}),kg=gg({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:bg}),jg=gg({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase()}
2),Dg=eg([xg,yg,wg,kg,jg],"html"),Cg=eg([xg,vg,wg,kg,jg],"svg"),Ng=/[A-Z]/g,Fg=/-[a-z]/g,Sg=/^data[-\w.:]+$/i;function Eg(e){return"-"+e.toLowerCase()}function Ag(e){return e.charAt(1).toUpperCase()}const Tg={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var Mg=n(967);const _g=Ig("end"),Bg=Ig("start");function Ig(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"===typeof n.line&&n.line>0&&"number"===typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"===typeof n.offset&&n.offset>-1?n.offset:void 0}}}function Pg(e){return e&&"object"===typeof e?"position"in e||"type"in e?Rg(e.position):"start"in e||"end"in e?Rg(e):"line"in e||"column"in e?Lg(e):"":""}function Lg(e){return zg(e&&e.line)+":"+zg(e&&e.column)}function Rg(e){return Lg(e&&e.start)+"-"+Lg(e&&e.end)}function zg(e){return e&&"number"===typeof e?e:1}class Og extends Error{constructor(e,t,n){super(),"string"===typeof t&&(n=t,t=void 0);let a="",r={},s=!1;if(t&&(r="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:d({},t)),"string"===typeof e?a=e:!r.cause&&e&&(s=!0,a=e.message,r.cause=e),!r.ruleId&&!r.source&&"string"===typeof n){const e=n.indexOf(":");-1===e?r.ruleId=n:(r.source=n.slice(0,e),r.ruleId=n.slice(e+1))}if(!r.place&&r.ancestors&&r.ancestors){const e=r.ancestors[r.ancestors.length-1];e&&(r.place=e.position)}const i=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file,this.message=a,this.line=i?i.line:void 0,this.name=Pg(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=s&&r.cause&&"string"===typeof r.cause.stack?r.cause.stack:"",this.actual,this.expected,this.note,this.url}}Og.prototype.file="",Og.prototype.name="",Og.prototype.reason="",Og.prototype.message="",Og.prototype.stack="",Og.prototype.column=void 0,Og.prototype.line=void 0,Og.prototype.ancestors=void 0,Og.prototype.cause=void 0,Og.prototype.fatal=void 0,Og.prototype.place=void 0,Og.prototype.ruleId=void 0,Og.prototype.source=void 0;const Ug={}.hasOwnProperty,Vg=new Map,Hg=/[A-Z]/g,qg=new Set(["table","tbody","thead","tfoot","tr"]),Wg=new Set(["td","th"]),Yg="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Gg(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let a;if(t.development){if("function"!==typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=function(e,t){return n;function n(n,a,r,s){const i=Array.isArray(r.children),o=Bg(n);return t(a,r,s,i,{columnNumber:o?o.column-1:void 0,fileName:e,lineNumber:o?o.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!==typeof t.jsx)throw new TypeError("Expected `jsx` in production options");
vendor: 13,225 bytes, line 2
2if("function"!==typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");a=function(e,t,n){return a;function a(e,a,r,s){const i=Array.isArray(r.children)?n:t;return s?i(a,r,s):i(a,r)}}(0,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?Cg:Dg,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=Kg(r,e,void 0);return s&&"string"!==typeof s?s:r.create(e,r.Fragment,{children:s||void 0},void 0)}function Kg(e,t,n){return"element"===t.type?function(e,t,n){const a=e.schema;let r=a;"svg"===t.tagName.toLowerCase()&&"html"===a.space&&(r=Cg,e.schema=r);e.ancestors.push(t);const s=Zg(e,t.tagName,!1),i=function(e,t){const n={};let a,r;for(r in t.properties)if("children"!==r&&Ug.call(t.properties,r)){const s=Qg(e,r,t.properties[r]);if(s){const[r,i]=s;e.tableCellAlignToStyle&&"align"===r&&"string"===typeof i&&Wg.has(t.tagName)?a=i:n[r]=i}}if(a){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=a}return n}(e,t);let o=$g(e,t);qg.has(t.tagName)&&(o=o.filter(function(e){return"string"!==typeof e||!("object"===typeof(t=e)?"text"===t.type&&Qp(t.value):Qp(t));var t}));return Xg(e,i,s,t),Jg(i,o),e.ancestors.pop(),e.schema=a,e.create(t,s,i,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}ex(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const a=e.schema;let r=a;"svg"===t.name&&"html"===a.space&&(r=Cg,e.schema=r);e.ancestors.push(t);const s=null===t.name?e.Fragment:Zg(e,t.name,!0),i=function(e,t){const n={};for(const a of t.attributes)if("mdxJsxExpressionAttribute"===a.type)if(a.data&&a.data.estree&&e.evaluater){const t=a.data.estree.body[0];Wp(t.type);const r=t.expression;Wp(r.type);const s=r.properties[0];Wp(s.type),Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else ex(e,t.position);else{const r=a.name;let s;if(a.value&&"object"===typeof a.value)if(a.value.data&&a.value.data.estree&&e.evaluater){const t=a.value.data.estree.body[0];Wp(t.type),s=e.evaluater.evaluateExpression(t.expression)}else ex(e,t.position);else s=null===a.value||a.value;n[r]=s}return n}(e,t),o=$g(e,t);return Xg(e,i,s,t),Jg(i,o),e.ancestors.pop(),e.schema=a,e.create(t,s,i,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ex(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const a={};return Jg(a,$g(e,t)),e.create(t,e.Fragment,a,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function Xg(e,t,n,a){"string"!==typeof n&&n!==e.Fragment&&e.passNode&&(t.node=a)}function Jg(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function $g(e,t){const n=[];let a=-1;const r=e.passKeys?new Map:Vg;for(;++a<t.children.length;){const s=t.children[a];let i;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=r.get(e)||0;i=e+"-"+t,r.set(e,t+1)}}const o=Kg(e,s,i);void 0!==o&&n.push(o)}return n}function Qg(e,t,n){const a=function(e,t){const n=tg(t);let a=t,r=ng;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&Sg.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(Fg,Ag);a="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!Fg.test(e)){let n=e.replace(Ng,Eg);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}r=hg}return new r(a,t)}(e.schema,t);if(!(null===n||void 0===n||"number"===typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=a.commaSeparated?function(e,t){const n=t||{};return(""===e[e.length-1]?[...e,""]:e).join((n.padRight?" ":"")+","+(!1===n.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===a.property){let t="object"===typeof n?n:function(e,t){try{return Mg(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const t=n,a=new Og("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=Yg+"#cannot-parse-style-attribute",a}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)Ug.call(e,n)&&(t[tx(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&a.space?Tg[a.property]||a.property:a.attribute,n]}}function Zg(e,t,n){let a;if(n)if(t.includes(".")){const e=t.split(".");let n,r=-1;for(;++r<e.length;){const t=Jp(e[r])?{type:"Identifier",name:e[r]}:{type:"Literal",value:e[r]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(r&&"Literal"===t.type),optional:!1}:t}a=n}else a=Jp(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else a={type:"Literal",value:t};if("Literal"===a.type){const t=a.value;return Ug.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(a);ex(e)}function ex(e,t){const n=new Og("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Yg+"#cannot-handle-mdx-estrees-without-createevaluater",n}function tx(e){let t=e.replace(Hg,nx);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function nx(e){return"-"+e.toLowerCase()}const ax={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},rx={};function sx(e,t){const n=t||rx;return ix(e,"boolean"!==typeof n.includeImageAlt||n.includeImageAlt,"boolean"!==typeof n.includeHtml||n.includeHtml)}function ix(e,t,n){if(function(e){return Boolean(e&&"object"===typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return ox(e.children,t,n)}return Array.isArray(e)?ox(e,t,n):""}function ox(e,t,n){const a=[];let r=-1;for(;++r<e.length;)a[r]=ix(e[r],t,n);return a.join("")}function lx(e,t,n,a){const r=e.length;let s,i=0;if(t=t<0?-t>r?0:r+t:t>r?r:t,n=n>0?n:0,a.length<1e4)s=Array.from(a),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<a.length;)s=a.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function cx(e,t){return e.length>0?(lx(e,e.length,0,t),e):t}class dx{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null===t||void 0===t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const a=t||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return n&&ux(this.left,n),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),ux(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ux(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);ux(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);ux(this.left,t.reverse())}}}function ux(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function mx(e){const t={};let n,a,r,s,i,o,l,c=-1;const u=new dx(e);for(;++c<u.length;){for(;c in t;)c=t[c];if(n=u.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===u.get(c-1)[1].type&&(o=n[1]._tokenizer.events,r=0,r<o.length&&"lineEndingBlank"===o[r][1].type&&(r+=2),r<o.length&&"content"===o[r][1].type))for(;++r<o.length&&"content"!==o[r][1].type;)"chunkText"===o[r][1].type&&(o[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,hx(u,c)),c=t[c],l=!0);else if(n[1]._container){for(r=c,a=void 0;r--;)if(s=u.get(r),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type)"enter"===s[0]&&(a&&(u.get(a)[1].type="lineEndingBlank"),s[1].type="lineEnding",a=r);else if("linePrefix"!==s[1].type&&"listItemIndent"!==s[1].type)break;a&&(n[1].end=d({},u.get(a)[1].start),i=u.slice(a,c),i.unshift(n),u.splice(a,c-a+1,i))}}return lx(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function hx(e,t){const n=e.get(t)[1],a=e.get(t)[2];let r=t-1;const s=[];let i=n._tokenizer;i||(i=a.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const o=i.events,l=[],c={};let d,u,m=-1,h=n,p=0,g=0;const x=[g];for(;h;){for(;e.get(++r)[1]!==h;);s.push(r),h._tokenizer||(d=a.sliceStream(h),h.next||d.push(null),u&&i.defineSkip(h.start),h._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),h._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=h,h=h.next}for(h=n;++m<o.length;)"exit"===o[m][0]&&"enter"===o[m-1][0]&&o[m][1].type===o[m-1][1].type&&o[m][1].start.line!==o[m][1].end.line&&(g=m+1,x.push(g),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(i.events=[],h?(h._tokenizer=void 0,h.previous=void 0):x.pop(),m=x.length;m--;){const t=o.slice(x[m],x[m+1]),n=s.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),m=-1;++m<l.length;)c[p+l[m][0]]=p+l[m][1],p+=l[m][1]-l[m][0]-1;return c}const px={}.hasOwnProperty;function gx(e){const t={};let n=-1;for(;++n<e.length;)xx(t,e[n]);return t}function xx(e,t){let n;for(n in t){const a=(px.call(e,n)?e[n]:void 0)||(e[n]={}),r=t[n];let s;if(r)for(s in r){px.call(a,s)||(a[s]=[]);const e=r[s];fx(a[s],Array.isArray(e)?e:e?[e]:[])}}}function fx(e,t){let n=-1;const a=[];for(;++n<t.length;)("after"===t[n].add?e:a).push(t[n]);lx(e,0,0,a)}const bx=Ax(/[A-Za-z]/),yx=Ax(/[\dA-Za-z]/),vx=Ax(/[#-'*+\--9=?A-Z^-~]/);function wx(e){return null!==e&&(e<32||127===e)}const kx=Ax(/\d/),jx=Ax(/[\dA-Fa-f]/),Dx=Ax(/[!-/:-@[-`{-~]/);function Cx(e){return null!==e&&e<-2}function Nx(e){return null!==e&&(e<0||32===e)}function Fx(e){return-2===e||-1===e||32===e}const Sx=Ax(/(?:[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F])|(?:[\$\+<->
2\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDD00-\uDEB3\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF])/),Ex=Ax(/\s/);function Ax(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function Tx(e,t,n,a){const r=a?a-1:Number.POSITIVE_INFINITY;let s=0;return function(a){if(Fx(a))return e.enter(n),i(a);return t(a)};function i(a){return Fx(a)&&s++<r?(e.consume(a),i):(e.exit(n),t(a))}}const Mx={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Tx(e,t,"linePrefix")},function(t){return e.enter("paragraph"),a(t)});let n;return t;function a(t){const a=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=a),n=a,r(t)}function r(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):Cx(t)?(e.consume(t),e.exit("chunkText"),a):(e.consume(t),r)}}};const _x={tokenize:function(e){const t=this,n=[];let a,r,s,i=0;return o;function o(a){if(i<n.length){const r=n[i];return t.containerState=r[1],e.attempt(r[0].continuation,l,c)(a)}return c(a)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&y();const n=t.events.length;let r,s=n;for(;s--;)if("exit"===t.events[s][0]&&"chunkFlow"===t.events[s][1].type){r=t.events[s][1].end;break}b(i);let o=n;for(;o<t.events.length;)t.events[o][1].end=d({},r),o++;return lx(t.events,s+1,0,t.events.slice(n)),t.events.length=o,c(e)}return o(e)}function c(r){if(i===n.length){if(!a)return h(r);if(a.currentConstruct&&a.currentConstruct.concrete)return g(r);t.interrupt=Boolean(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Bx,u,m)(r)}
vendor: 5,404 bytes, line 2
2function u(e){return a&&y(),b(i),h(e)}function m(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,g(e)}function h(n){return t.containerState={},e.attempt(Bx,p,g)(n)}function p(e){return i++,n.push([t.currentConstruct,t.containerState]),h(e)}function g(n){return null===n?(a&&y(),b(0),void e.consume(n)):(a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:r}),x(n))}function x(n){return null===n?(f(e.exit("chunkFlow"),!0),b(0),void e.consume(n)):Cx(n)?(e.consume(n),f(e.exit("chunkFlow")),i=0,t.interrupt=void 0,o):(e.consume(n),x)}function f(e,n){const o=t.sliceStream(e);if(n&&o.push(null),e.previous=r,r&&(r.next=e),r=e,a.defineSkip(e.start),a.write(o),t.parser.lazy[e.start.line]){let e=a.events.length;for(;e--;)if(a.events[e][1].start.offset<s&&(!a.events[e][1].end||a.events[e][1].end.offset>s))return;const n=t.events.length;let r,o,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(r){o=t.events[l][1].end;break}r=!0}for(b(i),e=n;e<t.events.length;)t.events[e][1].end=d({},o),e++;lx(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function b(a){let r=n.length;for(;r-- >a;){const a=n[r];t.containerState=a[1],a[0].exit.call(t,e)}n.length=a}function y(){a.write([null]),r=void 0,a=void 0,t.containerState._closeFlow=void 0}}},Bx={tokenize:function(e,t,n){return Tx(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};const Ix={partial:!0,tokenize:function(e,t,n){return function(t){return Fx(t)?Tx(e,a,"linePrefix")(t):a(t)};function a(e){return null===e||Cx(e)?t(e):n(e)}}};const Px={resolve:function(e){return mx(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(t)};function a(t){return null===t?r(t):Cx(t)?e.check(Lx,s,r)(t):(e.consume(t),a)}function r(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}},Lx={partial:!0,tokenize:function(e,t,n){const a=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Tx(e,r,"linePrefix")};function r(r){if(null===r||Cx(r))return n(r);const s=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(r):e.interrupt(a.parser.constructs.flow,n,t)(r)}}};const Rx={tokenize:function(e){const t=this,n=e.attempt(Ix,function(a){if(null===a)return void e.consume(a);return e.enter("lineEndingBlank"),e.consume(a),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n},e.attempt(this.parser.constructs.flowInitial,a,Tx(e,e.attempt(this.parser.constructs.flow,a,e.attempt(Px,a)),"linePrefix")));return n;function a(a){if(null!==a)return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(a)}}};const zx={resolveAll:Hx()},Ox=Vx("string"),Ux=Vx("text");function Vx(e){return{resolveAll:Hx("text"===e?qx:void 0),tokenize:function(t){const n=this,a=this.parser.constructs[e],r=t.attempt(a,s,i);return s;function s(e){return l(e)?r(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),o;t.consume(e)}function o(e){return l(e)?(t.exit("data"),r(e)):(t.consume(e),o)}function l(e){if(null===e)return!0;const t=a[e];let r=-1;if(t)for(;++r<t.length;){const e=t[r];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function Hx(e){return function(t,n){let a,r=-1;for(;++r<=t.length;)void 0===a?t[r]&&"data"===t[r][1].type&&(a=r,r++):t[r]&&"data"===t[r][1].type||(r!==a+2&&(t[a][1].end=t[r-1][1].end,t.splice(a+2,r-a-2),r=a+2),a=void 0);return e?e(t,n):t}}function qx(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const a=e[n-1][1],r=t.sliceStream(a);let s,i=r.length,o=-1,l=0;for(;i--;){const e=r[i];if("string"===typeof e){for(o=e.length;32===e.charCodeAt(o-1);)l++,o--;if(o)break;o=-1}else if(-2===e)s=!0,l++;else if(-1!==e){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const r={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:a.start._bufferIndex+o,_index:a.start._index+i,line:a.end.line,column:a.end.column-l,offset:a.end.offset-l},end:d({},a.end)};a.end=d({},r.start),a.start.offset===a.end.offset?Object.assign(a,r):(e.splice(n,0,["enter",r,t],["exit",r,t]),n+=2)}n++}return e}const Wx={name:"thematicBreak",tokenize:function(e,t,n){let a,r=0;return function(t){return e.enter("thematicBreak"),function(e){return a=e,s(e)}(t)};function s(s){return s===a?(e.enter("thematicBreakSequence"),i(s)):r>=3&&(null===s||Cx(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===a?(e.consume(t),r++,i):(e.exit("thematicBreakSequence"),Fx(t)?Tx(e,s,"whitespace")(t):s(t))}}};const Yx={continuation:{tokenize:function(e,t,n){const a=this;return a.containerState._closeFlow=void 0,e.check(Ix,r,s);function r(n){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,Tx(e,t,"listItemIndent",a.containerState.size+1)(n)}function s(n){return a.containerState.furtherBlankLines||!Fx(n)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine
vendor: 1,328 bytes, line 2
2=void 0,i(n)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,e.attempt(Kx,t,i)(n))}function i(r){return a.containerState._closeFlow=!0,a.interrupt=void 0,Tx(e,e.attempt(Yx,t,n),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(r)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const a=this,r=a.events[a.events.length-1];let s=r&&"linePrefix"===r[1].type?r[2].sliceSerialize(r[1],!0).length:0,i=0;return function(t){const r=a.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===r?!a.containerState.marker||t===a.containerState.marker:kx(t)){if(a.containerState.type||(a.containerState.type=r,e.enter(r,{_container:!0})),"listUnordered"===r)return e.enter("listItemPrefix"),42===t||45===t?e.check(Wx,n,l)(t):l(t);if(!a.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),o(t)}return n(t)};function o(t){return kx(t)&&++i<10?(e.consume(t),o):(!a.interrupt||i<2)&&(a.containerState.marker?t===a.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||t,e.check(Ix,a.interrupt?n:c,e.attempt(Gx,u,d))}
vendor: 9,760 bytes, line 2
2function c(e){return a.containerState.initialBlankLine=!0,s++,u(e)}function d(t){return Fx(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return a.containerState.size=s+a.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},Gx={partial:!0,tokenize:function(e,t,n){const a=this;return Tx(e,function(e){const r=a.events[a.events.length-1];return!Fx(e)&&r&&"listItemPrefixWhitespace"===r[1].type?t(e):n(e)},"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},Kx={partial:!0,tokenize:function(e,t,n){const a=this;return Tx(e,function(e){const r=a.events[a.events.length-1];return r&&"listItemIndent"===r[1].type&&r[2].sliceSerialize(r[1],!0).length===a.containerState.size?t(e):n(e)},"listItemIndent",a.containerState.size+1)}};const Xx={continuation:{tokenize:function(e,t,n){const a=this;return function(t){if(Fx(t))return Tx(e,r,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return r(t)};function r(a){return e.attempt(Xx,t,n)(a)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const a=this;return function(t){if(62===t){const n=a.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),r}return n(t)};function r(n){return Fx(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};function Jx(e,t,n,a,r,s,i,o,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(a),e.enter(r),e.enter(s),e.consume(t),e.exit(s),u;if(null===t||32===t||41===t||wx(t))return n(t);return e.enter(a),e.enter(i),e.enter(o),e.enter("chunkString",{contentType:"string"}),p(t)};function u(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(r),e.exit(a),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),m(n))}function m(t){return 62===t?(e.exit("chunkString"),e.exit(o),u(t)):null===t||60===t||Cx(t)?n(t):(e.consume(t),92===t?h:m)}function h(t){return 60===t||62===t||92===t?(e.consume(t),m):m(t)}function p(r){return d||null!==r&&41!==r&&!Nx(r)?d<c&&40===r?(e.consume(r),d++,p):41===r?(e.consume(r),d--,p):null===r||32===r||40===r||wx(r)?n(r):(e.consume(r),92===r?g:p):(e.exit("chunkString"),e.exit(o),e.exit(i),e.exit(a),t(r))}function g(t){return 40===t||41===t||92===t?(e.consume(t),p):p(t)}}function $x(e,t,n,a,r,s){const i=this;let o,l=0;return function(t){return e.enter(a),e.enter(r),e.consume(t),e.exit(r),e.enter(s),c};function c(u){return l>999||null===u||91===u||93===u&&!o||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(s),e.enter(r),e.consume(u),e.exit(r),e.exit(a),t):Cx(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||Cx(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),o||(o=!Fx(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function Qx(e,t,n,a,r,s){let i;return function(t){if(34===t||39===t||40===t)return e.enter(a),e.enter(r),e.consume(t),e.exit(r),i=40===t?41:t,o;return n(t)};function o(n){return n===i?(e.enter(r),e.consume(n),e.exit(r),e.exit(a),t):(e.enter(s),l(n))}function l(t){return t===i?(e.exit(s),o(i)):null===t?n(t):Cx(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),Tx(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||Cx(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===i||92===t?(e.consume(t),c):c(t)}}function Zx(e,t){let n;return function a(r){if(Cx(r))return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,a;if(Fx(r))return Tx(e,a,n?"linePrefix":"lineSuffix")(r);return t(r)}}function ef(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const tf={name:"definition",tokenize:function(e,t,n){const a=this;let r;return function(t){return e.enter("definition"),function(t){return $x.call(a,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return r=ef(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return Nx(t)?Zx(e,o)(t):o(t)}function o(t){return Jx(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(nf,c,c)(t)}function c(t){return Fx(t)?Tx(e,d,"whitespace")(t):d(t)}function d(s){return null===s||Cx(s)?(e.exit("definition"),a.parser.defined.push(r),t(s)):n(s)}}},nf={partial:!0,tokenize:function(e,t,n){return function(t){return Nx(t)?Zx(e,a)(t):n(t)};function a(t){return Qx(e,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function r(t){return Fx(t)?Tx(e,s,"whitespace")(t):s(t)}function s(e){return null===e||Cx(e)?t(e):n(e)}}};const af={name:"codeIndented",tokenize:function(e,t,n){const a=this;return function(t){return e.enter("codeIndented"),Tx(e,r,"linePrefix",5)(t)};function r(e){const t=a.events[a.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?s(e):n(e)}function s(t){return null===t?o(t):Cx(t)?e.attempt(rf,s,o)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||Cx(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function o(n){return e.exit("codeIndented"),t(n)}}},rf={partial:!0,tokenize:function(e,t,n){const a=this;return r;function r(t){return a.parser.lazy[a.now().line]?n(t):Cx(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r):Tx(e,s,"linePrefix",5)(t)}function s(e){const s=a.events[a.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):Cx(e)?r(e):n(e)}}};const sf={name:"headingAtx",resolve:function(e,t){let n,a,r=e.length-2,s=3;"whitespace"===e[s][1].type&&(s+=2);r-2>s&&"whitespace"===e[r][1].type&&(r-=2);"atxHeadingSequence"===e[r][1].type&&(s===r-1||r-4>s&&"whitespace"===e[r-2][1].type)&&(r-=s+1===r?2:4);r>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[r][1].end},a={type:"chunkText",start:e[s][1].start,end:e[r][1].end,contentType:"text"},lx(e,s,r-s+1,[["enter",n,t],["enter",a,t],["exit",a,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let a=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),r(t)}(t)};function r(t){return 35===t&&a++<6?(e.consume(t),r):null===t||Nx(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||Cx(n)?(e.exit("atxHeading"),t(n)):Fx(n)?Tx(e,s,"whitespace")(n):(e.enter("atxHeadingText"),o(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),s(t))}function o(t){return null===t||35===t||Nx(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),o)}}};const of={name:"setextUnderline",resolveTo:function(e,t){let n,a,r,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(a=s)}else"content"===e[s][1].type&&e.splice(s,1),r||"definition"!==e[s][1].type||(r=s);const i={type:"setextHeading",start:d({},e[n][1].start),end:d({},e[e.length-1][1].end)};e[a][1].type="setextHeadingText",r?(e.splice(a,0,["enter",i,t]),e.splice(r+1,0,["exit",e[n][1],t]),e[n][1].end=d({},e[r][1].end)):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const a=this;let r;return function(t){let i,o=a.events.length;for(;o--;)if("lineEnding"!==a.events[o][1].type&&"linePrefix"!==a.events[o][1].type&&"content"!==a.events[o][1].type){i="paragraph"===a.events[o][1].type;break}if(!a.parser.lazy[a.now().line]&&(a.interrupt||i))return e.enter("setextHeadingLine"),r=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t);return n(t)};function s(t){return t===r?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),Fx(t)?Tx(e,i,"lineSuffix")(t):i(t))}function i(a){return null===a||Cx(a)?(e.exit("setextHeadingLine"),t(a)):n(a)}}};const lf=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],cf=["pre","script","style","textarea"],df={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const a=this;let r,s,i,o,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(o){return 33===o?(e.consume(o),d):47===o?(e.consume(o),s=!0,h):63===o?(e.consume(o),r=3,a.interrupt?t:B):bx(o)?(e.consume(o),i=String.fromCharCode(o),p):n(o)}function d(s){return 45===s?(e.consume(s),r=2,u):91===s?(e.consume(s),r=5,o=0,m):bx(s)?(e.consume(s),r=4,a.interrupt?t:B):n(s)}function u(r){return 45===r?(e.consume(r),a.interrupt?t:B):n(r)}function m(r){const s="CDATA[";return r===s.charCodeAt(o++)?(e.consume(r),6===o?a.interrupt?t:N:m):n(r)}function h(t){return bx(t)?(e.consume(t),i=String.fromCharCode(t),p):n(t)}
vendor: 4,267 bytes, line 2
2function p(o){if(null===o||47===o||62===o||Nx(o)){const l=47===o,c=i.toLowerCase();return l||s||!cf.includes(c)?lf.includes(i.toLowerCase())?(r=6,l?(e.consume(o),g):a.interrupt?t(o):N(o)):(r=7,a.interrupt&&!a.parser.lazy[a.now().line]?n(o):s?x(o):f(o)):(r=1,a.interrupt?t(o):N(o))}return 45===o||yx(o)?(e.consume(o),i+=String.fromCharCode(o),p):n(o)}function g(r){return 62===r?(e.consume(r),a.interrupt?t:N):n(r)}function x(t){return Fx(t)?(e.consume(t),x):D(t)}function f(t){return 47===t?(e.consume(t),D):58===t||95===t||bx(t)?(e.consume(t),b):Fx(t)?(e.consume(t),f):D(t)}function b(t){return 45===t||46===t||58===t||95===t||yx(t)?(e.consume(t),b):y(t)}function y(t){return 61===t?(e.consume(t),v):Fx(t)?(e.consume(t),y):f(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):Fx(t)?(e.consume(t),v):k(t)}function w(t){return t===l?(e.consume(t),l=null,j):null===t||Cx(t)?n(t):(e.consume(t),w)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||Nx(t)?y(t):(e.consume(t),k)}function j(e){return 47===e||62===e||Fx(e)?f(e):n(e)}function D(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||Cx(t)?N(t):Fx(t)?(e.consume(t),C):n(t)}function N(t){return 45===t&&2===r?(e.consume(t),A):60===t&&1===r?(e.consume(t),T):62===t&&4===r?(e.consume(t),I):63===t&&3===r?(e.consume(t),B):93===t&&5===r?(e.consume(t),_):!Cx(t)||6!==r&&7!==r?null===t||Cx(t)?(e.exit("htmlFlowData"),F(t)):(e.consume(t),N):(e.exit("htmlFlowData"),e.check(uf,P,F)(t))}function F(t){return e.check(mf,S,P)(t)}function S(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),E}function E(t){return null===t||Cx(t)?F(t):(e.enter("htmlFlowData"),N(t))}function A(t){return 45===t?(e.consume(t),B):N(t)}function T(t){return 47===t?(e.consume(t),i="",M):N(t)}function M(t){if(62===t){const n=i.toLowerCase();return cf.includes(n)?(e.consume(t),I):N(t)}return bx(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),M):N(t)}function _(t){return 93===t?(e.consume(t),B):N(t)}function B(t){return 62===t?(e.consume(t),I):45===t&&2===r?(e.consume(t),B):N(t)}function I(t){return null===t||Cx(t)?(e.exit("htmlFlowData"),P(t)):(e.consume(t),I)}function P(n){return e.exit("htmlFlow"),t(n)}}},uf={partial:!0,tokenize:function(e,t,n){return function(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Ix,t,n)}}},mf={partial:!0,tokenize:function(e,t,n){const a=this;return function(t){if(Cx(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r;return n(t)};function r(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}};const hf={partial:!0,tokenize:function(e,t,n){const a=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(e){return a.parser.lazy[a.now().line]?n(e):t(e)}}},pf={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const a=this,r={partial:!0,tokenize:function(e,t,n){let r=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),Fx(t)?Tx(e,c,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===s?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===s?(r++,e.consume(t),d):r>=o?(e.exit("codeFencedFenceSequence"),Fx(t)?Tx(e,u,"whitespace")(t):u(t)):n(t)}function u(a){return null===a||Cx(a)?(e.exit("codeFencedFence"),t(a)):n(a)}}};let s,i=0,o=0;return function(t){return function(t){const n=a.events[a.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(o++,e.consume(t),l):o<3?n(t):(e.exit("codeFencedFenceSequence"),Fx(t)?Tx(e,c,"whitespace")(t):c(t))}function c(n){return null===n||Cx(n)?(e.exit("codeFencedFence"),a.interrupt?t(n):e.check(hf,h,b)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||Cx(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):Fx(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Tx(e,u,"whitespace")(t)):96===t&&t===s?
vendor: 6,271 bytes, line 2
2n(t):(e.consume(t),d)}function u(t){return null===t||Cx(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(t))}function m(t){return null===t||Cx(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(r,b,p)(t)}function p(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),g}function g(t){return i>0&&Fx(t)?Tx(e,x,"linePrefix",i+1)(t):x(t)}function x(t){return null===t||Cx(t)?e.check(hf,h,b)(t):(e.enter("codeFlowValue"),f(t))}function f(t){return null===t||Cx(t)?(e.exit("codeFlowValue"),x(t)):(e.consume(t),f)}function b(n){return e.exit("codeFenced"),t(n)}}};const gf=document.createElement("i");function xf(e){const t="&"+e+";";gf.innerHTML=t;const n=gf.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}const ff={name:"characterReference",tokenize:function(e,t,n){const a=this;let r,s,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),o};function o(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,s=yx,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,s=jx,c):(e.enter("characterReferenceValue"),r=7,s=kx,c(t))}function c(o){if(59===o&&i){const r=e.exit("characterReferenceValue");return s!==yx||xf(a.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(o),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(o)}return s(o)&&i++<r?(e.consume(o),c):n(o)}}};const bf={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),a};function a(a){return Dx(a)?(e.enter("characterEscapeValue"),e.consume(a),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(a)}}};const yf={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),Tx(e,t,"linePrefix")}}};function vf(e,t,n){const a=[];let r=-1;for(;++r<e.length;){const s=e[r].resolveAll;s&&!a.includes(s)&&(t=s(t,n),a.push(s))}return t}const wf={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const a=e[t][1];if(n.push(e[t]),"labelImage"===a.type||"labelLink"===a.type||"labelEnd"===a.type){const e="labelImage"===a.type?4:2;a.type="data",t+=e}}e.length!==n.length&&lx(e,0,e.length,n);return e},resolveTo:function(e,t){let n,a,r,s,i=e.length,o=0;for(;i--;)if(n=e[i][1],a){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(r){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(a=i,"labelLink"!==n.type)){o=2;break}}else"labelEnd"===n.type&&(r=i);const l={type:"labelLink"===e[a][1].type?"link":"image",start:d({},e[a][1].start),end:d({},e[e.length-1][1].end)},c={type:"label",start:d({},e[a][1].start),end:d({},e[r][1].end)},u={type:"labelText",start:d({},e[a+o+2][1].end),end:d({},e[r-2][1].start)};return s=[["enter",l,t],["enter",c,t]],s=cx(s,e.slice(a+1,a+o+3)),s=cx(s,[["enter",u,t]]),s=cx(s,vf(t.parser.constructs.insideSpan.null,e.slice(a+o+4,r-3),t)),s=cx(s,[["exit",u,t],e[r-2],e[r-1],["exit",c,t]]),s=cx(s,e.slice(r+1)),s=cx(s,[["exit",l,t]]),lx(e,a,e.length,s),e},tokenize:function(e,t,n){const a=this;let r,s,i=a.events.length;for(;i--;)if(("labelImage"===a.events[i][1].type||"labelLink"===a.events[i][1].type)&&!a.events[i][1]._balanced){r=a.events[i][1];break}return function(t){if(!r)return n(t);if(r._inactive)return d(t);return s=a.parser.defined.includes(ef(a.sliceSerialize({start:r.end,end:a.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),o};function o(t){return 40===t?e.attempt(kf,c,s?c:d)(t):91===t?e.attempt(jf,c,s?l:d)(t):s?c(t):d(t)}function l(t){return e.attempt(Df,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}},kf={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),a};function a(t){return Nx(t)?Zx(e,r)(t):r(t)}function r(t){return 41===t?c(t):Jx(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return Nx(t)?Zx(e,o)(t):c(t)}function i(e){return n(e)}function o(t){return 34===t||39===t||40===t?Qx(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return Nx(t)?Zx(e,c)(t):c(t)}function c(a){return 41===a?(e.enter("resourceMarker"),e.consume(a),e.exit("resourceMarker"),e.exit("resource"),t):n(a)}}},jf={tokenize:function(e,t,n){const a=this;return function(t){return $x.call(a,e,r,s,"reference","referenceMarker","referenceString")(t)};function r(e){return a.parser.defined.includes(ef(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},Df={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),a};function a(a){return 93===a?(e.enter("referenceMarker"),e.consume(a),e.exit("referenceMarker"),e.exit("reference"),t):n(a)}}};const Cf={name:"labelStartImage",resolveAll:wf.resolveAll,tokenize:function(e,t,n){const a=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),r};function r(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}};function Nf(e){return null===e||Nx(e)||Ex(e)?1:Sx(e)?2:void 0}const Ff={name:"attention",resolveAll:function(e,t){let n,a,r,s,i,o,l,c,u=-1;for(;++u<e.length;)if("enter"===e[u][0]&&"attentionSequence"===e[u][1].type&&e[u][1]._close)for(n=u;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[
vendor: 6,476 bytes, line 2
2n][1]).charCodeAt(0)===t.sliceSerialize(e[u][1]).charCodeAt(0)){if((e[n][1]._close||e[u][1]._open)&&(e[u][1].end.offset-e[u][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[u][1].end.offset-e[u][1].start.offset)%3))continue;o=e[n][1].end.offset-e[n][1].start.offset>1&&e[u][1].end.offset-e[u][1].start.offset>1?2:1;const m=d({},e[n][1].end),h=d({},e[u][1].start);Sf(m,-o),Sf(h,o),s={type:o>1?"strongSequence":"emphasisSequence",start:m,end:d({},e[n][1].end)},i={type:o>1?"strongSequence":"emphasisSequence",start:d({},e[u][1].start),end:h},r={type:o>1?"strongText":"emphasisText",start:d({},e[n][1].end),end:d({},e[u][1].start)},a={type:o>1?"strong":"emphasis",start:d({},s.start),end:d({},i.end)},e[n][1].end=d({},s.start),e[u][1].start=d({},i.end),l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=cx(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=cx(l,[["enter",a,t],["enter",s,t],["exit",s,t],["enter",r,t]]),l=cx(l,vf(t.parser.constructs.insideSpan.null,e.slice(n+1,u),t)),l=cx(l,[["exit",r,t],["enter",i,t],["exit",i,t],["exit",a,t]]),e[u][1].end.offset-e[u][1].start.offset?(c=2,l=cx(l,[["enter",e[u][1],t],["exit",e[u][1],t]])):c=0,lx(e,n-1,u-n+3,l),u=n+l.length-c-2;break}u=-1;for(;++u<e.length;)"attentionSequence"===e[u][1].type&&(e[u][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,a=this.previous,r=Nf(a);let s;return function(t){return s=t,e.enter("attentionSequence"),i(t)};function i(o){if(o===s)return e.consume(o),i;const l=e.exit("attentionSequence"),c=Nf(o),d=!c||2===c&&r||n.includes(o),u=!r||2===r&&c||n.includes(a);return l._open=Boolean(42===s?d:d&&(r||!u)),l._close=Boolean(42===s?u:u&&(c||!d)),t(o)}}};function Sf(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Ef={name:"autolink",tokenize:function(e,t,n){let a=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),r};function r(t){return bx(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||yx(e)?(a=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),a=0,o):(43===t||45===t||46===t||yx(t))&&a++<32?(e.consume(t),i):(a=0,l(t))}function o(a){return 62===a?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(a),e.exit("autolinkMarker"),e.exit("autolink"),t):null===a||32===a||60===a||wx(a)?n(a):(e.consume(a),o)}function l(t){return 64===t?(e.consume(t),c):vx(t)?(e.consume(t),l):n(t)}function c(e){return yx(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),a=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):u(n)}function u(t){if((45===t||yx(t))&&a++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const Af={name:"htmlText",tokenize:function(e,t,n){const a=this;let r,s,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),o};function o(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),v):63===t?(e.consume(t),b):bx(t)?(e.consume(t),j):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,h):bx(t)?(e.consume(t),f):n(t)}function c(t){return 45===t?(e.consume(t),m):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):Cx(t)?(i=d,M(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),m):d(t)}function m(e){return 62===e?T(e):45===e?u(e):d(e)}function h(t){const a="CDATA[";return t===a.charCodeAt(s++)?(e.consume(t),6===s?p:h):n(t)}function p(t){return null===t?n(t):93===t?(e.consume(t),g):Cx(t)?(i=p,M(t)):(e.consume(t),p)}function g(t){return 93===t?(e.consume(t),x):p(t)}function x(t){return 62===t?T(t):93===t?(e.consume(t),x):p(t)}function f(t){return null===t||62===t?T(t):Cx(t)?(i=f,M(t)):(e.consume(t),f)}function b(t){return null===t?n(t):63===t?(e.consume(t),y):Cx(t)?(i=b,M(t)):(e.consume(t),b)}function y(e){return 62===e?T(e):b(e)}function v(t){return bx(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||yx(t)?(e.consume(t),w):k(t)}function k(t){return Cx(t)?(i=k,M(t)):Fx(t)?(e.consume(t),k):T(t)}function j(t){return 45===t||yx(t)?(e.consume(t),j):47===t||62===t||Nx(t)?D(t):n(t)}function D(t){return 47===t?(e.consume(t),T):58===t||95===t||bx(t)?(e.consume(t),C):Cx(t)?(i=D,M(t)):Fx(t)?(e.consume(t),D):T(t)}function C(t){return 45===t||46===t||58===t||95===t||yx(t)?(e.consume(t),C):N(t)}function N(t){return 61===t?(e.consume(t),F):Cx(t)?(i=N,M(t)):Fx(t)?(e.consume(t),N):D(t)}function F(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,S):Cx(t)?(i=F,M(t)):Fx(t)?(e.consume(t),F):(e.consume(t),E)}function S(t){return t===r?(e.consume(t),r=void 0,A):null===t?n(t):Cx(t)?(i=S,M(t)):(e.consume(t),S)}function E(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||Nx(t)?D(t):(e.consume(t),E)}function A(e){return 47===e||62===e||Nx(e)?D(e):n(e)}function T(a){return 62===a?(e.consume(a),e.exit("htmlTextData"),e.exit("htmlText"),t):n(a)}function M(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),_}function _(t){return Fx(t)?Tx(e,B,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):B(t)}function B(t){return e.enter("htmlTextData"),i(t)}}};const Tf={name:"labelStartLink",resolveAll:wf.resolveAll,tokenize:function(e,t,n){const a=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),r};function r(e){return 94===e&&"_hiddenFootnoteSupport"in a.parser.constructs?n(e):t(e)}}};const Mf={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),a};function a(a){return Cx(a)?(e.exit("hardBreakEscape"),t(a)):n(a)}}};const _f={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,a=e.length-4,r=3;if(("lineEnding"===e[r][1].type||"space"===e[r][1].type)&&("lineEnding"===e[a][1].type||"space"===e[a][1].type))for(t=r;++t<a;)if("codeTextData"===e[t][1].type){e[r][1].type="codeTextPadding",e[a][1].type="codeTextPadding",r+=2,a-=2;break}t=r-1,a++;for(;++t<=a;)void 0===n?t!==a&&"lineEnding"!==e[t][1].type&&(n=t):t!==a&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),a-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let a,r,s=0;
vendor: 10,944 bytes, line 2
2return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),s++,i):(e.exit("codeTextSequence"),o(t))}function o(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),o):96===t?(r=e.enter("codeTextSequence"),a=0,c(t)):Cx(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||Cx(t)?(e.exit("codeTextData"),o(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),a++,c):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(r.type="codeTextData",l(n))}}};const Bf={42:Yx,43:Yx,45:Yx,48:Yx,49:Yx,50:Yx,51:Yx,52:Yx,53:Yx,54:Yx,55:Yx,56:Yx,57:Yx,62:Xx},If={91:tf},Pf={[-2]:af,[-1]:af,32:af},Lf={35:sf,42:Wx,45:[of,Wx],60:df,61:of,95:Wx,96:pf,126:pf},Rf={38:ff,92:bf},zf={[-5]:yf,[-4]:yf,[-3]:yf,33:Cf,38:ff,42:Ff,60:[Ef,Af],91:Tf,92:[Mf,bf],93:wf,95:Ff,96:_f},Of={null:[Ff,zx]},Uf={null:[42,95]},Vf={null:[]};function Hf(e,t,n){let a={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},s=[];let i=[],o=[],l=!0;const c={attempt:b(function(e,t){y(e,t.from)}),check:b(f),consume:function(e){Cx(e)?(a.line++,a.column=1,a.offset+=-3===e?2:1,v()):-1!==e&&(a.column++,a.offset++);a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===i[a._index].length&&(a._bufferIndex=-1,a._index++));d.previous=e,l=!0},enter:function(e,t){const n=t||{};return n.type=e,n.start=p(),d.events.push(["enter",n,d]),o.push(n),n},exit:function(e){const t=o.pop();return t.end=p(),d.events.push(["exit",t,d]),t},interrupt:b(f,{interrupt:!0})},d={code:null,containerState:{},defineSkip:function(e){r[e.line]=e.column,v()},events:[],now:p,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const a=[];let r;for(;++n<e.length;){const s=e[n];let i;if("string"===typeof s)i=s;else switch(s){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&r)continue;i=" ";break;default:i=String.fromCharCode(s)}r=-2===s,a.push(i)}return a.join("")}(h(e),t)},sliceStream:h,write:function(e){if(i=cx(i,e),g(),null!==i[i.length-1])return[];return y(t,0),d.events=vf(s,d.events,d),d.events}};let u,m=t.tokenize.call(d,c);return t.resolveAll&&s.push(t),d;function h(e){return function(e,t){const n=t.start._index,a=t.start._bufferIndex,r=t.end._index,s=t.end._bufferIndex;let i;if(n===r)i=[e[n].slice(a,s)];else{if(i=e.slice(n,r),a>-1){const e=i[0];"string"===typeof e?i[0]=e.slice(a):i.shift()}s>0&&i.push(e[r].slice(0,s))}return i}(i,e)}function p(){const{_bufferIndex:e,_index:t,line:n,column:r,offset:s}=a;return{_bufferIndex:e,_index:t,line:n,column:r,offset:s}}function g(){let e;for(;a._index<i.length;){const t=i[a._index];if("string"===typeof t)for(e=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===e&&a._bufferIndex<t.length;)x(t.charCodeAt(a._bufferIndex));else x(t)}}function x(e){l=void 0,u=e,m=m(e)}function f(e,t){t.restore()}function b(e,t){return function(n,r,s){let i,u,m,h;return Array.isArray(n)?g(n):"tokenize"in n?g([n]):function(e){return t;function t(t){const n=null!==t&&e[t],a=null!==t&&e.null;return g([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(a)?a:a?[a]:[]])(t)}}(n);function g(e){return i=e,u=0,0===e.length?s:x(e[u])}function x(e){return function(n){h=function(){const e=p(),t=d.previous,n=d.currentConstruct,r=d.events.length,s=Array.from(o);return{from:r,restore:i};function i(){a=e,d.previous=t,d.currentConstruct=n,d.events.length=r,o=s,v()}}(),m=e,e.partial||(d.currentConstruct=e);if(e.name&&d.parser.constructs.disable.null.includes(e.name))return b(n);return e.tokenize.call(t?Object.assign(Object.create(d),t):d,c,f,b)(n)}}function f(t){return l=!0,e(m,h),r}function b(e){return l=!0,h.restore(),++u<i.length?x(i[u]):s}}}function y(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&lx(d.events,t,d.events.length-t,e.resolve(d.events.slice(t),d)),e.resolveTo&&(d.events=e.resolveTo(d.events,d))}function v(){a.line in r&&a.column<2&&(a.column=r[a.line],a.offset+=r[a.line]-1)}}const qf=/[\0\t\n\r]/g;function Wf(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||65535===(65535&n)||65534===(65535&n)||n>1114111?"\ufffd":String.fromCodePoint(n)}const Yf=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Gf(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return Wf(n.slice(t?2:1),t?16:10)}return xf(n)||e}const Kf={}.hasOwnProperty;function Xf(e,n,a){return"string"!==typeof n&&(a=n,n=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(te),autolinkProtocol:C,autolinkEmail:C,atxHeading:s($),blockQuote:s(Y),characterEscape:C,characterReference:C,codeFenced:s(G),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(G,i),codeText:s(K,i),codeTextData:C,data:C,codeFlowValue:C,definition:s(X),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(J),hardBreakEscape:s(Q),hardBreakTrailing:s(Q),htmlFlow:s(Z,i),htmlFlowData:C,htmlText:s(Z,i),htmlTextData:C,image:s(ee),label:i,link:s(te),listItem:s(ae),listItemValue:m,listOrdered:s(ne,u),listUnordered:s(ne),paragraph:s(re),reference:z,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s($),strong:s(se),thematicBreak:s(oe)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:W,autolinkProtocol:q,blockQuote:l(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:V,characterReference:H,codeFenced:l(x),codeFencedFence:g,codeFencedFenceInfo:h,codeFencedFenceMeta:p,codeFlowValue:N,codeIndented:l(f),codeText:l(T),codeTextData:N,data:N,definition:l(),definitionDestinationString:v,definitionLabelString:b,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(S),hardBreakTrailing:l(S),htmlFlow:l(E),htmlFlowData:N,htmlText:l(A),htmlTextData:N,image:l(_),label:I,labelText:B,lineEnding:F,link:l(M),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:O,resourceDestinationString:P,resourceTitleString:L,resource:R,setextHeading:l(D),setextHeadingLineSequence:j,setextHeadingText:k,strong:l(),thematicBreak:l()}};$f(t,(e||{}).mdastExtensions||[]);const n={};return a;function a(e){let a={type:"root",children:[]};const s={stack:[a],tokenStack:[],config:t,enter:o,exit:c,buffer:i,resume:d,data:n},l=[];let u=-1;for(;++u<e.length;)if("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)if("enter"===e[u][0])l.push(u);else{u=r(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];Kf.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},s),e[u][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||Zf).call(s,void 0,e[0])}for(a.position={start:Jf(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Jf(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)a=t.transforms[u](a)||a;return a}function r(e,t,n){let a,r,s,i,o=t-1,l=-1,c=!1;for(;++o<=n;){const t=e[o];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!a||i||l||s||(s=o),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(a){let i=o;for(r=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;r&&(e[r][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",r=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}s&&(!r||s<r)&&(a._spread=!0),a.end=Object.assign({},r?e[r][1].start:t[1].end),e.splice(r||o,0,["exit",a,t[2]]),o++,n++}if("listItemPrefix"===t[1].type){const r={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};a=r,e.splice(o,0,["enter",r,t[2]]),o++,n++,s=void 0,i=!0}}}return e[t][1]._spread=c,n}function s(e,t){return n;function n(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Jf(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),a=this.tokenStack.pop();if(!a)throw new Error("Cannot close `"+e.type+"` ("+Pg({start:e.start,end:e.end})+"): it\u2019s not open");if(a[0].type!==e.type)if(t)t.call(this,e,a[0]);else{(a[1]||Zf).call(this,e,a[0])}n.position.end=Jf(e.end)}function d(){return sx(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function m(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function h(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function p(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function f(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function b(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=ef(this.sliceSerialize(e)).toLowerCase()}function y(){const e=this.resume();this.stack[this.stack.length-1].title=e}function v(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function j(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function D(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ie(),n.position={start:Jf(e.start),end:void 0},t.push(n)),this.stack.push(n)}function N(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Jf(e.end)}function F(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=Jf(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.t
vendor: 4,539 bytes, line 2
2ype)&&(C.call(this,e),N.call(this,e))}function S(){this.data.atHardBreak=!0}function E(){const e=this.resume();this.stack[this.stack.length-1].value=e}function A(){const e=this.resume();this.stack[this.stack.length-1].value=e}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function M(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function _(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function B(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(Yf,Gf)}(t),n.identifier=ef(t).toLowerCase()}function I(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function P(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function R(){this.data.inReference=void 0}function z(){this.data.referenceType="collapsed"}function O(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=ef(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function V(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let a;if(n)a=Wf(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{a=xf(t)}this.stack[this.stack.length-1].value+=a}function H(e){this.stack.pop().position.end=Jf(e.end)}function q(e){N.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function W(e){N.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function Y(){return{type:"blockquote",children:[]}}function G(){return{type:"code",lang:null,meta:null,value:""}}function K(){return{type:"inlineCode",value:""}}function X(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function J(){return{type:"emphasis",children:[]}}function $(){return{type:"heading",depth:0,children:[]}}function Q(){return{type:"break"}}function Z(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function ae(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function se(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function oe(){return{type:"thematicBreak"}}}(a)(function(e){for(;!mx(e););return e}(function(e){const n={constructs:gx([t,...(e||{}).extensions||[]]),content:a(Mx),defined:[],document:a(_x),flow:a(Rx),lazy:{},string:a(Ox),text:a(Ux)};return n;function a(e){return function(t){return Hf(n,e,t)}}}(a).document().write(function(){let e,t=1,n="",a=!0;return function(r,s,i){const o=[];let l,c,d,u,m;for(r=n+("string"===typeof r?r.toString():new TextDecoder(s||void 0).decode(r)),d=0,n="",a&&(65279===r.charCodeAt(0)&&d++,a=void 0);d<r.length;){if(qf.lastIndex=d,l=qf.exec(r),u=l&&void 0!==l.index?l.index:r.length,m=r.charCodeAt(u),!l){n=r.slice(d);break}if(10===m&&d===u&&e)o.push(-3),e=void 0;else switch(e&&(o.push(-5),e=void 0),d<u&&(o.push(r.slice(d,u)),t+=u-d),m){case 0:o.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),o.push(-2);t++<c;)o.push(-1);break;case 10:o.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&o.push(-5),n&&o.push(n),o.push(null)),o}}()(e,n,!0))))}function Jf(e){return{line:e.line,column:e.column,offset:e.offset}}function $f(e,t){let n=-1;for(;++n<t.length;){const a=t[n];Array.isArray(a)?$f(e,a):Qf(e,a)}}function Qf(e,t){let n;for(n in t)if(Kf.call(t,n))switch(n){case"canContainEols":{const a=t[n];a&&e[n].push(...a);break}case"transforms":{const a=t[n];a&&e[n].push(...a);break}case"enter":case"exit":{const a=t[n];a&&Object.assign(e[n],a);break}}}function Zf(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Pg({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Pg({start:t.start,end:t.end}
2)+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Pg({start:t.start,end:t.end})+") is still open")}function eb(e){const t=this;t.parser=function(n){return Xf(n,d(d(d({},t.data("settings")),e),{},{extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]}))}}const tb="object"===typeof self?self:globalThis,nb=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),a=r=>{if(e.has(r))return e.get(r);const[s,i]=t[r];switch(s){case 0:case-1:return n(i,r);case 1:{const e=n([],r);for(const t of i)e.push(a(t));return e}case 2:{const e=n({},r);for(const[t,n]of i)e[a(t)]=a(n);return e}case 3:return n(new Date(i),r);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),r)}case 5:{const e=n(new Map,r);for(const[t,n]of i)e.set(a(t),a(n));return e}case 6:{const e=n(new Set,r);for(const t of i)e.add(a(t));return e}case 7:{const{name:e,message:t}=i;return n(new tb[e](t),r)}case 8:return n(BigInt(i),r);case"BigInt":return n(Object(BigInt(i)),r);case"ArrayBuffer":return n(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:e}=new Uint8Array(i);return n(new DataView(e),i)}}return n(new tb[s](i),r)};return a})(new Map,e)(0),ab="",{toString:rb}={},{keys:sb}=Object,ib=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=rb.call(e).slice(8,-1);switch(n){case"Array":return[1,ab];case"Object":return[2,ab];case"Date":return[3,ab];case"RegExp":return[4,ab];case"Map":return[5,ab];case"Set":return[6,ab];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},ob=e=>{let[t,n]=e;return 0===t&&("function"===n||"symbol"===n)},lb=function(e){let{json:t,lossy:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=[];return((e,t,n,a)=>{const r=(e,t)=>{const r=a.push(e)-1;return n.set(t,r),r},s=a=>{if(n.has(a))return n.get(a);let[i,o]=ib(a);switch(i){case 0:{let t=a;switch(o){case"bigint":i=8,t=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+o);t=null;break;case"undefined":return r([-1],a)}return r([i,t],a)}case 1:{if(o){let e=a;return"DataView"===o?e=new Uint8Array(a.buffer):"ArrayBuffer"===o&&(e=new Uint8Array(a)),r([o,[...e]],a)}const e=[],t=r([i,e],a);for(const n of a)e.push(s(n));return t}case 2:{if(o)switch(o){case"BigInt":return r([o,a.toString()],a);case"Boolean":case"Number":case"String":return r([o,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const n=[],l=r([i,n],a);for(const t of sb(a))!e&&ob(ib(a[t]))||n.push([s(t),s(a[t])]);return l}case 3:return r([i,a.toISOString()],a);case 4:{const{source:e,flags:t}=a;return r([i,{source:e,flags:t}],a)}case 5:{const t=[],n=r([i,t],a);for(const[r,i]of a)(e||!ob(ib(r))&&!ob(ib(i)))&&t.push([s(r),s(i)]);return n}case 6:{const t=[],n=r([i,t],a);for(const r of a)!e&&ob(ib(r))||t.push(s(r));return n}}const{message:l}=a;return r([i,{name:o,message:l}],a)};return s})(!(t||n),!!t,new Map,a)(e),a},cb="function"===typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?nb(lb(e,t)):structuredClone(e):(e,t)=>nb(lb(e,t));function db(e){const t=[];let n=-1,a=0,r=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&yx(e.charCodeAt(n+1))&&yx(e.charCodeAt(n+2)))r=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(i=String.fromCharCode(s,t),r=1):i="\ufffd"}else i=String.fromCharCode(s);i&&(t.push(e.slice(a,n),encodeURIComponent(i)),a=n+r+1,i=""),r&&(n+=r,r=0)}return t.join("")+e.slice(a)}function ub(e,t){const n=[{type:"text",value:"\u21a9"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function mb(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const hb=function(e){if(null===e||void 0===e)return gb;if("function"===typeof e)return pb(e);if("object"===typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=hb(e[n]);return pb(a);function a(){let e=-1;for(var n=arguments.length,a=new Array(n),r=0;r<n;r++)a[r]=arguments[r];for(;++e<t.length;)if(t[e].apply(this,a))return!0;return!1}}(e):function(e){const t=e;return pb(n);function n(n){const a=n;let r;for(r in e)if(a[r]!==t[r])return!1;return!0}}(e);if("string"===typeof e)return function(e){return pb(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function pb(e){return function(t,n,a){return Boolean(xb(t)&&e.call(this,t,"number"===typeof n?n:void 0,a||void 0))}}function gb(){return!0}function xb(e){return null!==e&&"object"===typeof e&&"type"in e}const fb=[],bb=!0,yb=!1;function vb(e,t,n,a){let r;"function"===typeof t&&"function"!==typeof n?(a=n,n=t):r=t;
vendor: 4,542 bytes, line 2
2const s=hb(r),i=a?-1:1;!function e(r,o,l){const c=r&&"object"===typeof r?r:{};if("string"===typeof c.type){const e="string"===typeof c.tagName?c.tagName:"string"===typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+r.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,m=fb;if((!t||s(r,o,l[l.length-1]||void 0))&&(m=function(e){if(Array.isArray(e))return e;if("number"===typeof e)return[bb,e];return null===e||void 0===e?fb:[e]}(n(r,l)),m[0]===yb))return m;if("children"in r&&r.children){const t=r;if(t.children&&"skip"!==m[0])for(d=(a?t.children.length:-1)+i,u=l.concat(t);d>-1&&d<t.children.length;){const n=t.children[d];if(c=e(n,d,u)(),c[0]===yb)return c;d="number"===typeof c[1]?c[1]:d+i}}return m}}(e,void 0,[])()}function wb(e,t,n,a){let r,s,i;"function"===typeof t&&"function"!==typeof n?(s=void 0,i=t,r=n):(s=t,i=n,r=a),vb(e,s,function(e,t){const n=t[t.length-1],a=n?n.children.indexOf(e):void 0;return i(e,a,n)},r)}function kb(e,t){const n=t.referenceType;let a="]";if("collapsed"===n?a+="[]":"full"===n&&(a+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+a}];const r=e.all(t),s=r[0];s&&"text"===s.type?s.value="["+s.value:r.unshift({type:"text",value:"["});const i=r[r.length-1];return i&&"text"===i.type?i.value+=a:r.push({type:"text",value:a}),r}function jb(e){const t=e.spread;return null===t||void 0===t?e.children.length>1:t}function Db(e){const t=String(e),n=/\r?\n|\r/g;let a=n.exec(t),r=0;const s=[];for(;a;)s.push(Cb(t.slice(r,a.index),r>0,!0),a[0]),r=a.index+a[0].length,a=n.exec(t);return s.push(Cb(t.slice(r),r>0,!1)),s.join("")}function Cb(e,t,n){let a=0,r=e.length;if(t){let t=e.codePointAt(a);for(;9===t||32===t;)a++,t=e.codePointAt(a)}if(n){let t=e.codePointAt(r-1);for(;9===t||32===t;)r--,t=e.codePointAt(r-1)}return r>a?e.slice(a,r):""}const Nb={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",a={};t.lang&&(a.className=["language-"+t.lang]);let r={type:"element",tagName:"code",properties:a,children:[{type:"text",value:n}]};return t.meta&&(r.data={meta:t.meta}),e.patch(t,r),r=e.applyData(t,r),r={type:"element",tagName:"pre",properties:{},children:[r]},e.patch(t,r),r},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"===typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",a=String(t.identifier).toUpperCase(),r=db(a.toLowerCase()),s=e.footnoteOrder.indexOf(a);let i,o=e.footnoteCounts.get(a);void 0===o?(o=0,e.footnoteOrder.push(a),i=e.footnoteOrder.length):i=s+1,o+=1,e.footnoteCounts.set(a,o);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return kb(e,t);const r={src:db(a.url||""),alt:t.alt};null!==a.title&&void 0!==a.title&&(r.title=a.title);const s={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const n={src:db(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const a={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,a),e.applyData(t,a)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const a={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,a),e.applyData(t,a)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),a=e.definitionById.get(n);if(!a)return kb(e,t);
vendor: 4,959 bytes, line 2
2const r={href:db(a.url||"")};null!==a.title&&void 0!==a.title&&(r.title=a.title);const s={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const n={href:db(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const a={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},listItem:function(e,t,n){const a=e.all(t),r=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let a=-1;for(;!t&&++a<n.length;)t=jb(n[a])}return t}(n):jb(t),s={},i=[];if("boolean"===typeof t.checked){const e=a[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},a.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<a.length;){const e=a[o];(r||0!==o||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||r?i.push(e):i.push(...e.children)}const l=a[a.length-1];l&&(r||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:s,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},a=e.all(t);let r=-1;for("number"===typeof t.start&&1!==t.start&&(n.start=t.start);++r<a.length;){const e=a[r];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(a,!0)};return e.patch(t,s),e.applyData(t,s)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),a=n.shift(),r=[];if(a){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([a],!0)};e.patch(t.children[0],n),r.push(n)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=Bg(t.children[1]),i=_g(t.children[t.children.length-1]);s&&i&&(a.position={start:s,end:i}),r.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const a=n?n.children:void 0,r=0===(a?a.indexOf(t):1)?"th":"td",s=n&&"table"===n.type?n.align:void 0,i=s?s.length:t.children.length;let o=-1;const l=[];for(;++o<i;){const n=t.children[o],a={},i=s?s[o]:void 0;i&&(a.align=i);let c={type:"element",tagName:r,properties:a,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:Db(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:Fb,yaml:Fb,definition:Fb,footnoteDefinition:Fb};function Fb(){}const Sb=["children"],Eb={}.hasOwnProperty,Ab={};function Tb(e,t){e.position&&(t.position=function(e){const t=Bg(e),n=_g(e);if(t&&n)return{start:t,end:n}}(e))}function Mb(e,t){let n=t;if(e&&e.data){const t=e.data.hName,a=e.data.hChildren,r=e.data.hProperties;if("string"===typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&r&&Object.assign(n.properties,cb(r)),"children"in n&&n.children&&null!==a&&void 0!==a&&(n.children=a)}return n}function _b(e,t){const n=t.data||{},a=!("value"in t)||Eb.call(n,"hProperties")||Eb.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,a),e.applyData(t,a)}function Bb(e,t){const n=[];let a=-1;for(t&&n.push({type:"text",value:"\n"});++a<e.length;)a&&n.push({type:"text",value:"\n"}),n.push(e[a]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function Ib(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function Pb(e,t){const n=function(e,t){const n=t||Ab,a=new Map,r=new Map,s=new Map,i=d(d({},Nb),n.handlers),o={all:function(e){const t=[];if("children"in e){const n=e.children;let a=-1;for(;++a<n.length;){const r=o.one(n[a],e);if(r){if(a&&"break"===n[a-1].type&&(Array.isArray(r)||"text"!==r.type||(r.value=
2Ib(r.value)),!Array.isArray(r)&&"element"===r.type)){const e=r.children[0];e&&"text"===e.type&&(e.value=Ib(e.value))}Array.isArray(r)?t.push(...r):t.push(r)}}}return t},applyData:Mb,definitionById:a,footnoteById:r,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,a=o.handlers[n];if(Eb.call(o.handlers,n)&&a)return a(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){const{children:t}=e,n=T(e,Sb),a=cb(n);return a.children=o.all(e),a}return cb(e)}return(o.options.unknownHandler||_b)(o,e,t)},options:n,patch:Tb,wrap:Bb};return wb(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?a:r,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o}(e,t),a=n.one(e,void 0),r=function(e){const t="string"===typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||ub,a=e.options.footnoteBackLabel||mb,r=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const r=e.footnoteById.get(e.footnoteOrder[l]);if(!r)continue;const s=e.all(r),i=String(r.identifier).toUpperCase(),c=db(i.toLowerCase());let d=0;const u=[],m=e.footnoteCounts.get(i);for(;void 0!==m&&++d<=m;){u.length>0&&u.push({type:"text",value:" "});let e="string"===typeof n?n:n(l,d);"string"===typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"===typeof a?a:a(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const h=s[s.length-1];if(h&&"element"===h.type&&"p"===h.tagName){const e=h.children[h.children.length-1];e&&"text"===e.type?e.value+=" ":h.children.push({type:"text",value:" "}),h.children.push(...u)}else s.push(...u);const p={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(r,p),o.push(p)}if(0!==o.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:d(d({},cb(i)),{},{id:"footnote-label"}),children:[{type:"text",value:r}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)}
2,{type:"text",value:"\n"}]}}(n),s=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return r&&s.children.push({type:"text",value:"\n"},r),s}function Lb(e,t){return e&&"run"in e?async function(n,a){const r=Pb(n,d({file:a},t));await e.run(r,a)}:function(n,a){return Pb(n,d({file:a},e||t))}}function Rb(e){if(e)throw e}var zb=n(755);function Ob(e){if("object"!==typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Ub(){const e=[],t={run:function(){for(var t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];let r=-1;const s=n.pop();if("function"!==typeof s)throw new TypeError("Expected function as last argument, not "+s);!function t(a){const i=e[++r];let o=-1;if(a)s(a);else{for(var l=arguments.length,c=new Array(l>1?l-1:0),d=1;d<l;d++)c[d-1]=arguments[d];for(;++o<n.length;)null!==c[o]&&void 0!==c[o]||(c[o]=n[o]);n=c,i?function(e,t){let n;return r;function r(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];const l=e.length>r.length;let c;l&&r.push(s);try{c=e.apply(this,r)}catch(a){if(l&&n)throw a;return s(a)}l||(c&&c.then&&"function"===typeof c.then?c.then(i,s):c instanceof Error?s(c):i(c))}function s(e){if(!n){n=!0;for(var a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];t(e,...r)}}function i(e){s(null,e)}}(i,t)(...c):s(null,...c)}}(null,...n)},use:function(n){if("function"!==typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const Vb={basename:function(e,t){if(void 0!==t&&"string"!==typeof t)throw new TypeError('"ext" argument must be a string');Hb(e);let n,a=0,r=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){a=s+1;break}}else r<0&&(n=!0,r=s+1);return r<0?"":e.slice(a,r)}if(t===e)return"";let i=-1,o=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){a=s+1;break}}else i<0&&(n=!0,i=s+1),o>-1&&(e.codePointAt(s)===t.codePointAt(o--)?o<0&&(r=s):(o=-1,r=i));a===r?r=i:r<0&&(r=e.length);return e.slice(a,r)},dirname:function(e){if(Hb(e),0===e.length)return".";let t,n=-1,a=e.length;for(;--a;)if(47===e.codePointAt(a)){if(t){n=a;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){Hb(e);let t,n=e.length,a=-1,r=0,s=-1,i=0;for(;n--;){const o=e.codePointAt(n);if(47!==o)a<0&&(t=!0,a=n+1),46===o?s<0?s=n:1!==i&&(i=1):s>-1&&(i=-1);else if(t){r=n+1;break}}if(s<0||a<0||0===i||1===i&&s===a-1&&s===r+1)return"";return e.slice(s,a)},join:function(){let e,t=-1;for(var n=arguments.length,a=new Array(n),r=0;r<n;r++)a[r]=arguments[r];for(;++t<a.length;)Hb(a[t]),a[t]&&(e=void 0===e?a[t]:e+"/"+a[t]);return void 0===e?".":function(e){Hb(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,a,r="",s=0,i=-1,o=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(i===l-1||1===o);else if(i!==l-1&&2===o){if(r.length<2||2!==s||46!==r.codePointAt(r.length-1)||46!==r.codePointAt(r.length-2))if(r.length>2){if(a=r.lastIndexOf("/"),a!==r.length-1){a<0?(r="",s=0):(r=r.slice(0,a),s=r.length-1-r.lastIndexOf("/")),i=l,o=0;continue}}else if(r.length>0){r="",s=0,i=l,o=0;continue}t&&(r=r.length>0?r+"/..":"..",s=2)}else r.length>0?r+="/"+e.slice(i+1,l):r=e.slice(i+1,l),s=l-i-1;i=l,o=0}else 46===n&&o>-1?o++:o=-1}return r}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(e)},sep:"/"};function Hb(e){if("string"!==typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const qb={cwd:function(){return"/"}};function Wb(e){return Boolean(null!==e&&"object"===typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function Yb(e){if("string"===typeof e)e=new URL(e);else if(!Wb(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const Gb=["history","path","basename","stem","extname","dirname"];class Kb{constructor(e){let t;t=e?Wb(e)?{path:e}:"string"===typeof e||function(e){return Boolean(e&&"object"===typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":qb.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,a=-1;for(;++a<Gb.length;){const e=Gb[a];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Gb.includes(n)||(this[n]=t[n])}get basename(){return"string"===typeof this.path?Vb.basename(this.path):void 0}
2set basename(e){Jb(e,"basename"),Xb(e,"basename"),this.path=Vb.join(this.dirname||"",e)}get dirname(){return"string"===typeof this.path?Vb.dirname(this.path):void 0}set dirname(e){$b(this.basename,"dirname"),this.path=Vb.join(e||"",this.basename)}get extname(){return"string"===typeof this.path?Vb.extname(this.path):void 0}set extname(e){if(Xb(e,"extname"),$b(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Vb.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){Wb(e)&&(e=Yb(e)),Jb(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"===typeof this.path?Vb.basename(this.path,this.extname):void 0}set stem(e){Jb(e,"stem"),Xb(e,"stem"),this.path=Vb.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const a=this.message(e,t,n);throw a.fatal=!0,a}info(e,t,n){const a=this.message(e,t,n);return a.fatal=void 0,a}message(e,t,n){const a=new Og(e,t,n);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(e){if(void 0===this.value)return"";if("string"===typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function Xb(e,t){if(e&&e.includes(Vb.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Vb.sep+"`")}function Jb(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function $b(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const Qb=function(e){const t=this.constructor.prototype,n=t[e],a=function(){return n.apply(a,arguments)};return Object.setPrototypeOf(a,t),a},Zb={}.hasOwnProperty;class ey extends Qb{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Ub()}copy(){const e=new ey;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(zb(!0,{},this.namespace)),e}data(e,t){return"string"===typeof e?2===arguments.length?(ry("data",this.frozen),this.namespace[e]=t,this):Zb.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ry("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const a=t.call(e,...n);"function"===typeof a&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=oy(e),n=this.parser||this.Parser;return ny("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),ny("process",this.parser||this.Parser),ay("process",this.compiler||this.Compiler),t?a(void 0,t):new Promise(a);function a(a,r){const s=oy(e),i=n.parse(s);function o(e,n){e||!n?r(e):a?a(n):t(void 0,n)}n.run(i,s,function(e,t,a){if(e||!t||!a)return o(e);const r=t,s=n.stringify(r,a);var i;"string"===typeof(i=s)||function(e){return Boolean(e&&"object"===typeof e&&"byteLength"in e&&"byteOffset"in e)}(i)?a.value=s:a.result=s,o(e,a)})}}processSync(e){let t,n=!1;return this.freeze(),ny("processSync",this.parser||this.Parser),ay("processSync",this.compiler||this.Compiler),this.process(e,function(e,a){n=!0,Rb(e),t=a}),iy("processSync","process",n),t}run(e,t,n){sy(e),this.freeze();const a=this.transformers;return n||"function"!==typeof t||(n=t,t=void 0),n?r(void 0,n):new Promise(r);function r(r,s){const i=oy(t);a.run(e,i,function(t,a,i){const o=a||e;t?s(t):r?r(o):n(void 0,o,i)})}}runSync(e,t){let n,a=!1;return this.run(e,t,function(e,t){Rb(e),n=t,a=!0}),iy("runSync","run",a),n}stringify(e,t){this.freeze();const n=oy(t),a=this.compiler||this.Compiler;return ay("stringify",a),sy(e),a(e,n)}use(e){const t=this.attachers,n=this.namespace;if(ry("use",this.frozen),null===e||void 0===e);else if("function"===typeof e){for(var a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];c(e,r)}else{if("object"!==typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?l(e):o(e)}return this;function i(e){if("function"===typeof e)c(e,[]);else{if("object"!==typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;c(t,n)}else o(e)}}function o(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(e.plugins),e.settings&&(n.settings=zb(!0,n.settings,e.settings))}function l(e){let t=-1;if(null===e||void 0===e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){i(e[t])}}}function c(e,n){let a=-1,r=-1;for(;++a<t.length;)if(t[a][0]===e){r=a;break}if(-1===r)t.push([e,...n]);else if(n.length>0){let[a,...s]=n;const i=t[r][1];Ob(i)&&Ob(a)&&(a=zb(!0,i,a)),t[r]=[e,a,...s]}}}}const ty=(new ey).freeze();function ny(e,t){if("function"!==typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function ay(e,t){if("function"!==typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function ry(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function sy(e){if(!Ob(e)||"string"!==typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function iy(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function oy(e){return function(e){return Boolean(e&&"object"===typeof e&&"message"in e&&"messages"in e)}(e)?e:new Kb(e)}const ly=[],cy={allowDangerousHtml:!0},dy=/^(https?|ircs?|mailto|xmpp)$/i,uy=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function my(e){const t=hy(e),n=py(e);return gy(t.runSync(t.parse(n),n),e)}function hy(e){const t=e.rehypePlugins||ly,n=e.remarkPlugins||ly,a=e.remarkRehypeOptions?d(d({},e.remarkRehypeOptions),cy):cy;return ty().use(eb).use(n).use(Lb,a).use(t)}function py(e){const t=e.children||"",n=new Kb;return"string"===typeof t&&(n.value=t),n}function gy(e,t){const n=t.allowedElements,a=t.allowElement,r=t.components,s=t.disallowedElements,i=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||xy;for(const c of uy)Object.hasOwn(t,c.from)&&Yp((c.from,c.to&&c.to,c.id));return wb(e,function(e,t,r){if("raw"===e.type&&r&&"number"===typeof t)return i?r.children.splice(t,1):r.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in ax)if(Object.hasOwn(ax,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],a=ax[t];(null===a||a.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let i=n?!n.includes(e.tagName):!!s&&s.includes(e.tagName);if(!i&&a&&"number"===typeof t&&(i=!a(e,t,r)),i&&r&&"number"===typeof t)return o&&e.children?r.children.splice(t,1,...e.children):r.children.splice(t,1),t}}),Gg(e,{Fragment:u.Fragment,components:r,ignoreInvalidStyle:!0,jsx:u.jsx,jsxs:u.jsxs,passKeys:!0,passNode:!0})}function xy(e){const t=e.indexOf(":"),n=e.indexOf("?"),a=e.indexOf("#"),r=e.indexOf("/");return-1===t||-1!==r&&t>r||-1!==n&&t>n||-1!==a&&t>a||dy.test(e.slice(0,t))?e:""}const fy=Mo("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]),by='{\n "mcpServers": {\n "MLST ReScript": {\n "url": "https://app.rescript.info/api/v1/mcp"\n }\n }\n}',yy=e=>{let{isOpen:t,onClose:n,isDarkMode:a=!1,title:r="MLST ReScript MCP"}=e;return t?(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:n,children:(0,u.jsxs)("div",{className:"w-full max-w-2xl rounded-2xl border p-6 shadow-2xl ".concat(a?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-200 bg-white text-gray-900"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center justify-between gap-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("div",{className:"rounded-2xl p-2 ".concat(a?"bg-gray-700":"bg-gray-100"),children:(0,u.jsx)(fy,{className:"h-5 w-5 text-primary-600"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-lg font-semibold",children:r}),(0,u.jsx)("p",{className:"text-sm ".concat(a?"text-gray-400":"text-gray-500"),children:"Connect your client to the MLST ReScript MCP endpoint."})]})]}),(0,u.jsx)("button",{type:"button",onClick:n,className:"rounded-lg p-2 ".concat(a?"hover:bg-gray-700":"hover:bg-gray-100"),children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]}),(0,u.jsxs)("div",{className:"space-y-4 text-sm",children:[(0,u.jsxs)("div",{className:"rounded-xl border p-4 ".concat(a?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsx)("div",{className:"mb-2 font-medium",children:"Basic setup"}),(0,u.jsxs)("ol",{className:"list-decimal space-y-1 pl-5",children:[(0,u.jsx)("li",{children:"Open your MCP-capable client settings."}),(0,u.jsxs)("li",{children:["Add a new server named ",(0,u.jsx)("strong",{children:"MLST ReScript"}),"."]}),(0,u.jsxs)("li",{children:["Use ",(0,u.jsx)("code",{children:"https://app.rescript.info/api/v1/mcp"})," as the server URL."]}),(0,u.jsx)("li",{children:"Authenticate in the app if your client prompts for normal browser login."})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,u.jsx)("div",{className:"font-medium",children:"JSON snippet"}),(0,u.jsxs)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(by)},className:"inline-flex items-center gap-2 rounded-lg px-3 py-2 text-sm ".concat(a?"bg-gray-700 hover:bg-gray-600":"bg-gray-100 hover:bg-gray-200"),children:[(0,u.jsx)(Np,{className:"h-4 w-4"}),(0,u.jsx)("span",{children:"Copy JSON"})]})]}),(0,u.jsx)("pre",{className:"overflow-x-auto rounded-xl border p-4 text-xs ".concat(a?"border-gray-700 bg-gray-900/70 text-gray-200":"border-gray-200 bg-gray-50 text-gray-800"),children:by})]})]})]})}):null},vy=e=>{var t;let{transcript:r,filename:s,transcriptionData:i,speakerLabels:o,audioFile:l,transcriptionChecksum:c,sessionId:m,currentSessionData:h,onTtmlGenerated:p,onTtmlPreview:g,onTtmlSelected:x,isActiveTab:f=!0}=e;const{token:b}=am(),{permissions:y}=Hp(),{isDarkMode:v}=zu(),w=(0,a.useMemo)(()=>{const e=Boolean((null===h||void 0===h?void 0:h.published)||(null===h||void 0===h?void 0:h.publishedToHomepage)||(null===h||void 0===h?void 0:h.published_to_homepage)),t=(null===h||void 0===h?void 0:h.youtubeUrl)||(null===h||void 0===h?void 0:h.youtube_url)||(null===h||void 0===h?void 0:h.videoUrl)||"",n="string"===typeof t&&t.trim().length>0,a=Boolean((null===h||void 0===h?void 0:h.isYoutubeMode)||(null===h||void 0===h?void 0:h.is_youtube_mode));return e||n||a},[h]),[k,j]=(0,a.useState)([]),[D,C]=(0,a.useState)(""),[N,F]=(0,a.useState)(""),[E,A]=(0,a.useState)(""),[T,M]=(0,a.useState)(!0),[_,B]=(0,a.useState)(null),[I,P]=(0,a.useState)([]),[L,R]=(0,a.useState)(!1),[z,O]=(0,a.useState)(!1),[U,V]=(0,a.useState)(null),H=a.useRef(null),q=a.useRef(!1),[W,Y]=(0,a.useState)([]),[G,K]=(0,a.useState)([]),[X,J]=(0,a.useState)(!1),$=a.useRef(null),Q=a.useRef(!1),Z=a.useRef(new Set),ee=a.useRef(new Set),[te,ne]=(0,a.useState)(!1),[ae,re]=(0,a.useState)(null),[se,ie]=(0,a.useState)({isOpen:!1,file:null,content:""}),[oe,le]=(0,a.useState)("raw"),[ce,de]=(0,a.useState)(""),[ue,me]=(0,a.useState)(!1),[he,pe]=(0,a.useState)(!1),[ge,xe]=(0,a.useState)(null),[fe,be]=(0,a.useState)({topics:[],edits:[],clips:[],references:[]}),[ye,ve]=(0,a.useState)({isOpen:!1,file:null}),[we,ke]=(0,a.useState)(!1),[je,De]=(0,a.useState)(new Set),[Ce,Ne]=(0,a.useState)({isOpen:!1,file:null,instructions:"",iterationCount:1,blankSlate:!1,maxIssuesToFix:0,topicDensity:18}),[Fe,Se]=(0,a.useState)({isOpen:!1,topicDensity:18,enableWebSearch:!1,includeEdits:!1,additionalInstructions:""}),[Ee,Ae]=(0,a.useState)(!1),[Te,Me]=(0,a.useState)(null),_e=a.useRef(null),[Be,Ie]=(0,a.useState)({}),[Pe,Le]=(0,a.useState)({}),[Re,ze]=(0,a.useState)([]),[Oe,Ue]=(0,a.useState)(()=>Rp.getRefinementModel()||"");(0,a.useEffect)(()=>{y?M(!1):Wh().then(e=>{if(e.models&&e.models.length>0){const t=e.models.map(e=>({id:e.id,name:"".concat(e.name," (").concat(e.description,")")})),n=e.models.map(e=>e.id);ze(t),j(n);const a=Rp.getSelectedModel();if(a&&n.includes(a))C(a);else{const t=e.models.find(e=>"opus"===e.tier);C((null===t||void 0===t?void 0:t.id)||n[0])}const r=e.models.find(e=>"opus"===e.tier),s=Rp.getRefinementModel();s&&e.models.some(e=>e.id===s)?Ue(s):Ue((null===r||void 0===r?void 0:r.id)||e.models[0].id)}}).catch(()=>{}).finally(()=>M(!1))},[y]);const[Ve,He]=(0,a.useState)([]),[qe,We]=(0,a.useState)(!1),[Ye,Ge]=(0,a.useState)([]),[Ke,Xe]=(0,a.useState)(!1),[Je,$e]=(0,a.useState)(!1),Qe=a.useRef([]),Ze=a.useRef({}),et=(0,a.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"generation";if(Ze.current[e]=t,Qe.current.includes(e))return;const n=[...Qe.current,e];Qe.current=n,Ge(n)},[]),tt=(0,a.useCallback)(e=>{const t=Ze.current[e.id];if(t)return t;const n=(e.title||"").toLowerCase();return n.includes("refine")||n.includes("follow-up")||n.includes("timeline edit")?"follow-up":n.includes("ttml")||n.includes("caption")||n.includes("timeline")?"generation":"other"},[]),nt=(0,a.useCallback)(e=>{if(Qe.current.includes(e.id))return!0;const t=(e.title||"").toLowerCase();return t.includes("ttml")||t.includes("caption")||t.includes("timeline")},[]),at=(0,a.useCallback)(async()=>
2{if(m&&!y){We(!0);try{const e=(await Th(m,b||void 0)).filter(nt).sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,12);He(e)}catch(e){console.error("[TTML Agent] Failed to load agent workflows:",e)}finally{We(!1)}}else He([])},[nt,m,y]),rt=(0,a.useMemo)(()=>Ve.filter(e=>"active"===e.status).length,[Ve]),st=(0,a.useMemo)(()=>Ve.filter(e=>"generation"===tt(e)).slice(0,4),[Ve,tt]),it=(0,a.useMemo)(()=>st.filter(e=>"active"===e.status).length,[st]),ot=(0,a.useMemo)(()=>I.filter(e=>e.isDraft).length,[I]),lt=(0,a.useMemo)(()=>Je?I:I.filter(e=>!e.isDraft),[I,Je]);(0,a.useEffect)(()=>{it>0&&Xe(!0)},[it]),(0,a.useEffect)(()=>{Xe(!1),$e(!1)},[m]),(0,a.useEffect)(()=>{if(!f)return;if(at(),!m||y)return;const e=setInterval(()=>{at()},1e4);return()=>clearInterval(e)},[f,at,m,y,Ye]),(0,a.useEffect)(()=>{D&&Rp.setSelectedModel(D)},[D]),(0,a.useEffect)(()=>{Oe&&Rp.setRefinementModel(Oe)},[Oe]),(0,a.useEffect)(()=>{if(!f||!m||!b||y)return;const e=async()=>{try{const e=await Op.getTtmlJobs(m,b);e.success&&Y(e.jobs)}catch(e){console.error("[TTML Jobs] Failed to load server jobs:",e)}},t=async()=>{try{const e=await Op.getRefinementJobs(m,b);if(e.success){K(e.jobs);for(const n of e.jobs)if(("completed"===n.status||"no_changes"===n.status||"failed"===n.status)&&!ee.current.has(n.job_id))if(ee.current.add(n.job_id),console.log("[REFINE-JOB] Job ".concat(n.job_id," finished (").concat(n.status,") - refreshing files")),De(e=>{const t=new Set(e);return t.delete(n.source_checksum),t}),"completed"===n.status||"no_changes"===n.status){const e=n.result_checksums?JSON.parse(n.result_checksums):[],t=n.no_change_iterations?JSON.parse(n.no_change_iterations):[],a=n.total_cost_usd?" ($".concat(n.total_cost_usd.toFixed(2),")"):"";e.length>0?A("Refinement complete! ".concat(e.length," new version(s) created").concat(t.length>0?", ".concat(t.length," no-op(s)"):"").concat(a)):t.length>0&&A("Refinement complete - no changes detected in ".concat(t.length," iteration(s)").concat(a)),console.log("[REFINE-JOB] Triggering TTML refresh after job ".concat(n.job_id," completed")),ht(),setTimeout(()=>A(""),5e3)}else"failed"===n.status&&F("Refinement failed: ".concat(n.error_message||"Unknown error"));const t=e.jobs.filter(e=>"pending"===e.status||"refining"===e.status).map(e=>e.source_checksum);De(new Set(t))}}catch(e){console.error("[Refinement Jobs] Failed to load refinement jobs:",e)}};e(),t();let n=Date.now();const a=setInterval(()=>{const a=Date.now(),r=Q.current?2e3:1e4;a-n>=r&&(n=a,e(),t())},2e3);return $.current=a,()=>{$.current&&(clearInterval($.current),$.current=null)}},[f,m,b,y]),(0,a.useEffect)(()=>{if(!m||!b)return;const e=W.filter(e=>"completed"===e.status).filter(e=>!Z.current.has(e.job_id));e.length>0&&(console.log("[TTML Jobs] New completed jobs detected:",e.map(e=>e.job_id)),console.log("[TTML Jobs] Current allTtmlFiles count BEFORE refresh:",I.length),e.forEach(e=>Z.current.add(e.job_id)),console.log("[TTML Jobs] Calling loadAllTtmlFiles() to refresh..."),ht().then(()=>{console.log("[TTML Jobs] loadAllTtmlFiles() completed")}))},[W,m,b]),(0,a.useEffect)(()=>{const e=W.filter(e=>"pending"===e.status||"generating"===e.status||"refining"===e.status),t=G.filter(e=>"pending"===e.status||"refining"===e.status);Q.current=e.length>0||t.length>0},[W,G]),(0,a.useEffect)(()=>{H.current=U},[U]),(0,a.useEffect)(()=>{if(null!==h&&void 0!==h&&h.generatedTtmlFiles&&Array.isArray(h.generatedTtmlFiles)&&h.generatedTtmlFiles.length>0&&0===I.length){console.log("[TTMLRanking] Initializing from parent session data:",h.generatedTtmlFiles.length,"files");const e=h.generatedTtmlFiles.map(e=>({id:e.checksum||"".concat(e.name||e.description||"unknown","-").concat(Date.now()),name:e.name||e.description||e.filename||"Version ".concat(e.version||"?"),content:e.content,type:"cached",source:"standard",model:e.model||"unknown",generatedAt:e.generatedAt,version:e.version||1,parentChecksum:e.parentChecksum,rootChecksum:e.rootChecksum||e.checksum,childChecksums:e.childChecksums||[],tokenUsage:null,checksum:e.checksum,isValid:e.isValid,validationErrors:e.validationErrors,validationWarnings:e.validationWarnings,validationStats:e.validationStats,lastV
2alidated:e.lastValidated,generatedBy:e.generatedBy,costUsd:e.costUsd,cumulativeCostUsd:e.cumulativeCostUsd,refinementLog:e.refinementLog,revisionNotes:e.revisionNotes,editType:e.editType,editedBy:e.editedBy,noOpRefinements:e.noOpRefinements,isDraft:Boolean(e.isDraft),isSelected:h.selectedTtmlId===e.checksum}));P(e),h.selectedTtmlId&&!q.current?(console.log("[TTML-SELECT] Setting selectedTtmlId from currentSessionData (initial load):",h.selectedTtmlId),V(h.selectedTtmlId),H.current=h.selectedTtmlId):q.current&&console.log("[TTML-SELECT] Skipping currentSessionData selection - user has already made a selection")}},[h]);const ct=a.useRef(new Set);(0,a.useEffect)(()=>{if(null===h||void 0===h||!h.generatedTtmlFiles||0===I.length)return;const e=new Set(I.map(e=>e.checksum)),t=h.generatedTtmlFiles.filter(t=>t.checksum&&!e.has(t.checksum));if(t.length>0){console.log("[TTMLRanking] Found",t.length,"new files from parent, adding them");const e=t.map(e=>({id:e.checksum||"".concat(e.name||e.description||"unknown","-").concat(Date.now()),name:e.name||e.description||e.filename||"Version ".concat(e.version||"?"),content:e.content,type:"cached",source:"standard",model:e.model||"unknown",generatedAt:e.generatedAt,version:e.version||1,parentChecksum:e.parentChecksum,rootChecksum:e.rootChecksum||e.checksum,childChecksums:e.childChecksums||[],tokenUsage:null,checksum:e.checksum,isValid:e.isValid,validationErrors:e.validationErrors,validationWarnings:e.validationWarnings,validationStats:e.validationStats,lastValidated:e.lastValidated,generatedBy:e.generatedBy,costUsd:e.costUsd,cumulativeCostUsd:e.cumulativeCostUsd,refinementLog:e.refinementLog,revisionNotes:e.revisionNotes,editType:e.editType,editedBy:e.editedBy,noOpRefinements:e.noOpRefinements,isDraft:Boolean(e.isDraft),isSelected:e.isSelected||h.selectedTtmlId===e.checksum}));if(P(t=>[...t.map(e=>d(d({},e),{},{isSelected:h.selectedTtmlId===e.checksum})),...e]),h.selectedTtmlId){const t=e.find(e=>e.isSelected);var n;if(t)console.log("[TTML-SELECT] New file is selected, updating selectedTtmlId:",null===(n=t.checksum)||void 0===n?void 0:n.substring(0,8)),V(h.selectedTtmlId),H.current=h.selectedTtmlId}setTimeout(()=>{e.forEach(e=>{e.content&&e.checksum&&!ct.current.has(e.checksum)&&(ct.current.add(e.checksum),console.log("[TTMLRanking] Auto-validating new file:",e.name),xt(e))})},500)}},[null===h||void 0===h?void 0:h.generatedTtmlFiles,null===h||void 0===h?void 0:h.selectedTtmlId,I.length]);const dt=a.useRef(!1),ut=a.useRef(!1);(0,a.useEffect)(()=>{f&&r&&m&&b&&!dt.current&&(dt.current=!0,console.log("[TTMLRanking] Loading cached TTML files from backend"),ht().then(()=>{setTimeout(()=>{ft()},1e3)}),mt())},[f,r,b,m]),(0,a.useEffect)(()=>{const e=e=>{if(!f)return;const t=e.detail||{};m&&t.sessionId===m&&(t.selectedTtmlId&&(V(t.selectedTtmlId),H.current=t.selectedTtmlId),De(new Set),ht(),at())};return window.addEventListener("agent-ttml-updated",e),()=>window.removeEventListener("agent-ttml-updated",e)},[f,at,m,r,b,D]),(0,a.useEffect)(()=>{const e=()=>{f&&at()};return window.addEventListener("navigate-to-agent",e),()=>window.removeEventListener("navigate-to-agent",e)},[f,at]);const mt=async()=>{if(m&&b)if(q.current)console.log("[TTML-SELECT] Skipping loadSessionSelectedTtml - user has already made a selection");else try{const e=await Vm.getSession(m,b);e.selectedTtmlId&&(console.log("[TTML-SELECT] Setting selectedTtmlId from server session fetch:",e.selectedTtmlId),V(e.selectedTtmlId),H.current=e.selectedTtmlId)}catch(e){console.error("Failed to load session selected TTML:",e)}},ht=async()=>{if(r&&b){R(!0);try{const n=await Op.getCachedTTMLVersions({transcript:r,model:D||"all",sessionId:m},b);if(n.success){console.log("[TTMLRanking] Loaded cached TTML versions:",n.cachedVersions.length),console.log("[TTMLRanking] Cached versions details:",n.cachedVersions.map(e=>{var t,n,a;return{filename:e.filename,checksum:null===(t=e.checksum)||void 0===t?void 0:t.substring(0,8),version:e.version,rootChecksum:null===(n=e.rootChecksum)||void 0===n?void 0:n.substring(0,8),parentChecksum:null===(a=e.parentChecksum)||void 0===a?void 0:a.substring(0,8),isValid:e.isValid,hasStats:!!e.validationStats}}));const a=n.cachedVersions.map((e,t)=>{const n="best-of-3"===e.type?"best-of-3":"standard";return{id:"cached_".concat(e.checksum,"_").concat(t,"_").concat(Date.now()),name:e.filename,type:"cached",source:n,model:e.model,generatedAt:new Date(e.generatedAt),version:e.version||
21,parentChecksum:e.parentChecksum,rootChecksum:e.rootChecksum||e.checksum,childChecksums:e.childChecksums||[],cumulativeCostUsd:e.cumulativeCostUsd||e.costUsd,tokenUsage:e.tokenUsage,checksum:e.checksum,isSelected:H.current===e.checksum,isValid:e.isValid,validationErrors:e.validationErrors,validationWarnings:e.validationWarnings,validationStats:e.validationStats,lastValidated:e.lastValidated,generatedBy:e.generatedBy,costUsd:e.costUsd,refinementLog:e.refinementLog,revisionNotes:e.revisionNotes,editType:e.editType,editedBy:e.editedBy,hasTimelineEdits:e.hasTimelineEdits||!1,editCuts:e.editCuts||null,isDraft:Boolean(e.isDraft)}});console.log("[TTMLRanking] Files with validation stats:",a.filter(e=>e.validationStats).length,"out of",a.length,"total files");const r=new Map;for(const t of a){var e;const n=t.rootChecksum||t.checksum;r.has(n)||r.set(n,[]),r.get(n).push((null===(e=t.checksum)||void 0===e?void 0:e.substring(0,8))+"(v"+t.version+")")}console.log("[TTMLRanking] Version chains from cache:",Object.fromEntries(r)),console.log("[TTMLRanking] About to merge. Server returned",a.length,"files with checksums:",a.map(e=>{var t;return null===(t=e.checksum)||void 0===t?void 0:t.substring(0,8)})),P(e=>{if(console.log("[TTMLRanking] Inside setState - prevFiles count:",e.length,"checksums:",e.map(e=>{var t;return null===(t=e.checksum)||void 0===t?void 0:t.substring(0,8)})),0===e.length)return console.log("[TTMLRanking] Setting cached files (initial load):",a.length),a.length>0&&setTimeout(()=>pt(a),0),a;{const t=new Map(a.map(e=>[e.checksum||e.id,e])),n=new Set(e.map(e=>e.checksum||e.id)),r=e.map(e=>{const n=t.get(e.checksum||e.id);return n?d(d({},e),{},{refinementLog:n.refinementLog||e.refinementLog,revisionNotes:n.revisionNotes||e.revisionNotes,editType:n.editType||e.editType,editedBy:n.editedBy||e.editedBy,version:n.version||e.version,parentChecksum:n.parentChecksum||e.parentChecksum,rootChecksum:n.rootChecksum||e.rootChecksum,childChecksums:n.childChecksums||e.childChecksums,cumulativeCostUsd:n.cumulativeCostUsd||e.cumulativeCostUsd,generatedBy:n.generatedBy||e.generatedBy,isValid:void 0!==n.isValid?n.isValid:e.isValid,validationStats:n.validationStats||e.validationStats,validationErrors:n.validationErrors||e.validationErrors,validationWarnings:n.validationWarnings||e.validationWarnings,hasTimelineEdits:n.hasTimelineEdits||e.hasTimelineEdits||!1,editCuts:n.editCuts||e.editCuts||null}):e}),s=a.filter(e=>!n.has(e.checksum||e.id));console.log("[TTMLRanking] Merge result: existingChecksums:",Array.from(n).map(e=>null===e||void 0===e?void 0:e.substring(0,8)),"newCachedFiles count:",s.length,"new checksums:",s.map(e=>{var t;return null===(t=e.checksum)||void 0===t?void 0:t.substring(0,8)}));const i=s.length>0?[...r,...s]:r;return s.length>0?(console.log("[TTMLRanking] Found",s.length,"new cached files to add, existing:",e.length),setTimeout(()=>pt(s),0)):console.log("[TTMLRanking] Updated existing files with cache data"),i}});const s=H.current;var t;if(!s&&!q.current&&a.length>0&&m)console.log("[TTML-SELECT] Auto-selecting first TTML (no prior selection):",null===(t=a[0].checksum)||void 0===t?void 0:t.substring(0,8)),await gt(a[0].checksum,!1);else console.log("[TTML-SELECT] Skipping auto-select - currentSelection:",null===s||void 0===s?void 0:s.substring(0,8),"userHasSelected:",q.current,"cachedFiles:",a.length)}}catch(n){console.error("Failed to load cached versions:",n)}finally{R(!1)}}},pt=async e=>{if(console.log("[TTML-PARENT-UPDATE] Starting update with",e.length,"files"),p)try{const a=[];for(const r of e){var t;let e;if(console.log("[TTML-PARENT-UPDATE] Processing file:",{name:r.name,type:r.type,hasContent:!!r.content,checksum:r.checksum,isValid:r.isValid,hasStats:!!r.validationStats}),"cached"!==r.type||r.content)e=r.content;else try{const t=await Op.downloadCachedTTML(r.checksum,b);e=await t.text(),console.log("[TTML-PARENT-UPDATE] Downloaded cached content for",r.name,"length:",e.length)}catch(n){console.warn("Failed to fetch cached content for ".concat(r.name,":"),n);continue}const s={name:r.name,content:e,filename:r.name,generatedAt:r.generatedAt,checksum:r.checksum,isValid:r.isValid,validationErrors:r.validationErrors,validationWarnings:r.validationWarnings,validationStats:r.validationStats,version:r.version,parentChecksum:r.parentChecksum,rootChecksum:r.rootChecksum,childChecksums:r.childChecksums,model:r.model,costUsd:r.costUsd,cumulativeCostUsd:r.cumulativeCostUsd,generatedBy:r.generatedBy,refinementLog:r.refinementLog,noOpRefinements:r.noOpRefinements};console.log("[TTML-PARENT-UPDATE] Prepared TTML file:",{name:s.name,checksum:s.checksum,contentLength:null===(t=s.content)||void 0===t?void 0:t.length,stats:s.validationStats}),a.push(s)}
2console.log("[TTML-PARENT-UPDATE] Calling onTtmlGenerated with",a.length,"files"),a.length>0&&p(a)}catch(n){console.error("Failed to update parent with all TTML files:",n)}else console.warn("[TTML-PARENT-UPDATE] No onTtmlGenerated callback provided")},gt=async function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(m&&b){console.log("[TTML-SELECT] selectTtml called with:",null===e||void 0===e?void 0:e.substring(0,8),"userInitiated:",t),t&&(q.current=!0,console.log("[TTML-SELECT] User has manually selected, disabling auto-selection override"));try{V(e),console.log("[TTML-SELECT] Local state updated to:",null===e||void 0===e?void 0:e.substring(0,8)),await Vm.updateSession({sessionId:m,selectedTtmlId:e},b),P(t=>t.map(t=>d(d({},t),{},{isSelected:t.checksum===e||t.id===e}))),x&&x(e),A("Metadata revision selection saved"),setTimeout(()=>A(""),3e3)}catch(n){console.error("Failed to save TTML selection:",n),F("Failed to save TTML selection")}}},xt=async e=>{if(e.content&&e.checksum)try{var t,a;console.log("[TTML-VALIDATE] Validating single TTML:",e.name);const{comprehensiveTTMLValidation:s}=await n.e(995).then(n.bind(n,995)),i=(null===h||void 0===h||null===(t=h.transcriptionData)||void 0===t||null===(a=t.metadata)||void 0===a?void 0:a.duration)||(null===h||void 0===h?void 0:h.duration)||0,o=s(e.content,{expectedDuration:i>0?i:null});if(console.log("[TTML-VALIDATE] Validation result for",e.name,":",{isValid:o.isValid,errors:o.errors.length,warnings:o.warnings.length,stats:o.stats}),P(t=>t.map(t=>t.id===e.id||t.checksum===e.checksum?d(d({},t),{},{isValid:o.isValid,validationErrors:o.errors,validationWarnings:o.warnings,validationStats:o.stats,lastV
2alidated:(new Date).toISOString()}):t)),P(t=>{const n=t.map(t=>t.id===e.id||t.checksum===e.checksum?d(d({},t),{},{isValid:o.isValid,validationErrors:o.errors,validationWarnings:o.warnings,validationStats:o.stats,lastValidated:(new Date).toISOString()}):t);return pt(n),n}),m&&b&&e.checksum)try{(await fetch("".concat("/api","/sessions/").concat(m,"/validate-ttml"),{method:"POST",headers:{Authorization:"Bearer ".concat(b),"Content-Type":"application/json"},body:JSON.stringify({checksums:[e.checksum]})})).ok&&console.log("[TTML-VALIDATE] Backend validation completed for",e.name)}catch(r){console.warn("[TTML-VALIDATE] Backend validation failed, but client-side validation succeeded")}}catch(r){console.error("[TTML-VALIDATE] Failed to validate TTML:",r)}},ft=async()=>{if(m&&b){O(!0),F("");try{const e=await fetch("".concat("/api","/sessions/").concat(m,"/validate-ttml"),{method:"POST",headers:{Authorization:"Bearer ".concat(b)}});if(!e.ok)throw new Error("Failed to validate metadata revisions");const t=await e.json();t.success&&(console.log("[TTMLRanking] Validation result:",t.summary),A("Validation complete: ".concat(t.summary.validFiles,"/").concat(t.summary.totalFiles," files are valid")),t.results&&t.results.length>0&&P(e=>{const n=e.map(e=>{const n=t.results.find(t=>t.checksum&&(t.checksum===e.checksum||t.checksum===e.id));return n?d(d({},e),{},{isValid:n.isValid,validationErrors:n.errors||[],validationWarnings:n.warnings||[],validationStats:n.stats||null,lastValidated:(new Date).toISOString()}):e});return pt(n),n}))}catch(e){console.error("Failed to validate TTML files:",e),F("Failed to validate metadata revisions")}finally{O(!1)}}},bt=async e=>{try{var t;let n;n="cached"===e.type?await Op.downloadCachedTTML(e.checksum,b):new Blob([e.content],{type:"application/ttml+xml"});const a=(null===(t=e.model)||void 0===t?void 0:t.split("/").pop())||"unknown";let r=e.name||"ttml-v".concat(e.version||"unknown");(r.endsWith(".xml")||r.endsWith(".ttml"))&&(r=r.replace(/\.(xml|ttml)$/i,"")),r.includes(a)||(r="".concat(r,"-").concat(a));const s=URL.createObjectURL(n),i=document.createElement("a");i.href=s,i.download="".concat(r,".ttml"),i.click(),URL.revokeObjectURL(s)}catch(n){console.error("Failed to download TTML file:",n),F("Failed to download metadata revision")}},yt=e=>e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),vt=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),wt=e=>{let t=yt(e).replace(/\[CLIP\]\s*/gi,"").replace(/<br\s*\/?>/gi,"\n").trim();if(t.includes("|")&&!t.includes("\n")){const e=t.split("|").map(e=>e.trim());return{clipTitle:e[0]||"",clipType:e[1]||"",clipDescription:e[2]||"",clipVisual:e[3]||""}}const n=t.split("\n").map(e=>e.trim()).filter(e=>e.length>0);let a="",r="",s="",i="";for(const o of n){const e=o.toLowerCase();if(e.startsWith("visual:"))i=o.substring(7).trim();else if(e.includes("viral hook")){r="Viral Hook";const e=o.indexOf(":");e>-1&&(s=o.substring(e+1).trim())}else if(e.includes("educational nugget")||e.startsWith("educational:")){r="Educational Nugget";const e=o.indexOf(":");e>-1&&(s=o.substring(e+1).trim())}else if(e.includes("humorous aside")||e.startsWith("humorous:")){r="Humorous Aside";const e=o.indexOf(":");e>-1&&(s=o.substring(e+1).trim())}else a?s||(s=o):a=o}return{clipTitle:a,clipType:r,clipDescription:s,clipVisual:i}},kt=e=>{let t=yt(e).replace(/\[EDIT\]\s*/gi,"").replace(/<br\s*\/?>/gi,"\n").trim();if(t.includes("|")&&!t.includes("\n")){const e=t.split("|").map(e=>e.trim());return{editTitle:e[0]||"",editSuggestion:e[1]||"",editImprovement:e[2]||"",editPriority:e[3]||""}}const n=t.split("\n").map(e=>e.trim()).filter(e=>e.length>0);let a="",r="",s="",i="";for(const o of n)o.toLowerCase().startsWith("suggestion:")?r=o.substring(11).trim():o.toLowerCase().startsWith("improvement:")?s=o.substring(12).trim():o.toLowerCase().startsWith("priority:")?i=o.substring(9).trim():a||(a=o);return{editTitle:a,editSuggestion:r,editImprovement:s,editPriority:i}},jt=e=>{const t=yt(e).replace(/\[REF\]\s*/gi,"").replace(/<br\s*\/?>/gi,"\n").trim().split("\n").map(e=>e.trim()).filter(e=>e.length>0);let n="",a="",r="",s="",i="",o="";if(t.length>0){const e=t[0];if(e.includes("|")){const t=e.split("|").map(e=>e.trim());n=t[0]||"",a=t[1]||"",r=t[2]||""}else n=e;t.length>1&&(s=t[1]),t.length>2&&(i=t[2]),t.length>3&&(o=t[3])}return{refName:n,refLinkText:a,refUrl:r,refCategory:s,refContext:i,refVisual:o}},Dt=e=>{const t=yt(e).replace(/<br\s*\/?>/gi,"\n").trim().split("\n").map(e=>e.trim()).filter(e=>e.length>0);let n="",a="",r="",s="",i="",o="",l="";if(t.length>0){const e=t[0].match(/^\[(\d+):\s*([\d?]+\/?\d*)\]\s*>>\s*\[?([^\]]+)\]?/);e&&(n=e[1],a=e[2],r=e[3].trim())}for(let c=1;c<t.length;c++){const e=t[c];e.toLowerCase().startsWith("score:")?s=e.replace(/^score:\s*/i,"").trim():e.toLowerCase().startsWith("justification:")?i=e.replace(/^justification:\s*/i,"").trim():e.toLowerCase().startsWith("optimal placement:")?o=e.replace(/^optimal placement:\s*/i,"").replace(/[\[\]]/g,"").trim():e.toLowerCase().startsWith("continuity:")&&(l=e.replace(/^continuity:\s*/i,"").trim())}return{topicRank:n,topicPlacement:a,topicTitle:r,topicScore:s,topicJustification:i,topicOptimalPlacement:o,topicContinuity:l}},Ct=e=>{const t=(t,n)=>{const a=[],r=new RegExp('<div[^>]*xml:id="'.concat(t,'"[^>]*>([\\s\\S]*?)<\\/div>')),s=e.match(r);if(s){const e=/<p[^>]*begin="([^"]+)"[^>]*end="([^"]+)"[^>]*>([\s\S]*?)<\/p>/g;let r,i=0;for(;null!==(r=e.exec(s[1]));){const e=r[3],s=e.replace(/<br\s*\/?>/gi,"\n").replace(/<[^>]+>/g,"").trim();let o={};"topic"===n?o=Dt(e):"clip"===n?o=wt(e):"edit"===n?o=kt(e):"reference"===n&&(o=jt(e)),a.push(d({id:"".concat(t,"_").concat(i),begin:r[1],end:r[2],text:s,originalXml:r[0]},o)),i++}}return a};be({topics:t("d_summary","topic"),edits:t("d_edit","edit"),clips:t("d_clip","clip"),references:t("d_references","reference")})},Nt=(e,t,n,a)=>{be(r=>d(d({},r),{},{[e]:r[e].map(e=>e.id===t?d(d({},e),{},{[n]:a}):e)})),me(!0)},Ft=(e,t,n,a)=>{be(r=>d(d({},r),{},{[e]:r[e].map(e=>e.id===t?d(d({},e),{},{[n]:a}):e)})),me(!0)},St=(e,t)=>
2{be(n=>d(d({},n),{},{[e]:n[e].filter(e=>e.id!==t)})),me(!0)},Et=(e,t,n)=>{be(a=>{const r=[...a.topics],s=r.findIndex(t=>t.id===e);return-1===s?a:(r[s]=d(d({},r[s]),{},{[t]:n}),"end"===t&&s<r.length-1&&(r[s+1]=d(d({},r[s+1]),{},{begin:n})),"begin"===t&&s>0&&(r[s-1]=d(d({},r[s-1]),{},{end:n})),d(d({},a),{},{topics:r}))}),me(!0)},At=()=>{let e=ce;return(t=>{const n=t.map(e=>{const t=void 0!==e.topicTitle?(e=>{const t=[],n="[".concat(e.topicRank||"?",": ").concat(e.topicPlacement||"?","] >> [").concat(vt(e.topicTitle||""),"]");return t.push(n),e.topicScore&&t.push("Score: ".concat(vt(e.topicScore))),e.topicJustification&&t.push("Justification: ".concat(vt(e.topicJustification))),e.topicOptimalPlacement&&t.push("Optimal Placement: [".concat(vt(e.topicOptimalPlacement),"]")),e.topicContinuity&&t.push("Continuity: ".concat(vt(e.topicContinuity))),t.join("<br/>")})(e):e.text.replace(/\n/g,"<br/>");return' <p begin="'.concat(e.begin,'" end="').concat(e.end,'">').concat(t,"</p>")}).join("\n"),a=' <div xml:id="d_summary" region="r_summary" style="s0">\n'.concat(n,"\n </div>");e=e.replace(/<div[^>]*xml:id="d_summary"[^>]*>[\s\S]*?<\/div>/,a)})(fe.topics),(t=>{const n=t.map(e=>{const t=void 0!==e.clipTitle?(e=>["[CLIP] ".concat(vt(e.clipTitle||"")),vt(e.clipType||""),vt(e.clipDescription||""),vt(e.clipVisual||"")].join(" | "))(e):e.text.replace(/\n/g,"<br/>");return' <p begin="'.concat(e.begin,'" end="').concat(e.end,'">').concat(t,"</p>")}).join("\n"),a=' <div xml:id="d_clip" region="r_clip" style="s1">\n'.concat(n,"\n </div>");e=e.replace(/<div[^>]*xml:id="d_clip"[^>]*>[\s\S]*?<\/div>/,a)})(fe.clips),(t=>{const n=t.map(e=>{const t=void 0!==e.editTitle?(e=>["[EDIT] ".concat(vt(e.editTitle||"")),vt(e.editSuggestion||""),vt(e.editImprovement||""),vt(e.editPriority||"")].join(" | "))(e):e.text.replace(/\n/g,"<br/>");return' <p begin="'.concat(e.begin,'" end="').concat(e.end,'">').concat(t,"</p>")}).join("\n"),a=' <div xml:id="d_edit" region="r_edit" style="s2">\n'.concat(n,"\n </div>");e=e.replace(/<div[^>]*xml:id="d_edit"[^>]*>[\s\S]*?<\/div>/,a)})(fe.edits),(t=>{const n=t.map(e=>{const t=void 0!==e.refName?(e=>{let t="[REF] ".concat(vt(e.refName||""));e.refLinkText&&e.refUrl&&(t+=" | ".concat(vt(e.refLinkText)," | ").concat(vt(e.refUrl)));const n=[t];return e.refCategory&&n.push(vt(e.refCategory)),e.refContext&&n.push(vt(e.refContext)),e.refVisual&&n.push(vt(e.refVisual)),n.join("<br/>")})(e):e.text.replace(/\n/g,"<br/>");return' <p begin="'.concat(e.begin,'" end="').concat(e.end,'">').concat(t,"</p>")}).join("\n"),a=' <div xml:id="d_references" region="r_references" style="s3">\n'.concat(n,"\n </div>");e=e.replace(/<div[^>]*xml:id="d_references"[^>]*>[\s\S]*?<\/div>/,a)})(fe.references),e},Tt=(0,a.useMemo)(()=>{const e={},t={};return I.forEach(e=>{e.checksum&&(t[e.checksum]=e)}),I.forEach(n=>{var a;const r=(null===(a=n.validationStats)||void 0===a?void 0:a.segmentsByType)||{},s=r.topic||0,i=r.clip||0,o=r.edit||0,l=r.reference||0;let c={topic:0,clip:0,edit:0,reference:0},d=!1;if(n.parentChecksum){var u;const e=t[n.parentChecksum];null!==e&&void 0!==e&&null!==(u=e.validationStats)&&void 0!==u&&u.segmentsByType&&(c=e.validationStats.segmentsByType,d=!0)}e[n.id]={topics:s-(c.topic||0),clips:i-(c.clip||0),edits:o-(c.edit||0),refs:l-(c.reference||0),hasParent:d}}),e},[I]),Mt=(0,a.useMemo)(()=>{console.log("[TTMLGrouping] Grouping",lt.length,"visible files by rootChecksum");const e=new Map;for(const s of lt){var t,n;const a=s.rootChecksum||s.checksum||s.id;console.log("[TTMLGrouping] File",null===(t=s.checksum)||void 0===t?void 0:t.substring(0,8),"version:",s.version,"rootChecksum:",null===(n=s.rootChecksum)||void 0===n?void 0:n.substring(0,8),"-> rootKey:",null===a||void 0===a?void 0:a.substring(0,8)),e.has(a)||e.set(a,[]),e.get(a).push(s)}console.log("[TTMLGrouping] Chains found:",e.size,"chains with versions:",[...e.entries()].map(e=>{let[t,n]=e;return"".concat(null===t||void 0===t?void 0:t.substring(0,8),":").concat(n.length,"v")}).join(", "));const a=[];for(const[s,i]of e){var r;i.sort((e,t)=>
2(e.version||1)-(t.version||1));const e=Pe[s],t=e?i.find(t=>t.checksum===e):null,n=i.find(e=>e.isSelected);let o;o=t||(n||i[i.length-1]),o._chainVersions=i,o._chainRootKey=s,o._rootCreatedAt=(null===(r=i[0])||void 0===r?void 0:r.generatedAt)||o.generatedAt,a.push(o)}return a.sort((e,t)=>{const n=new Date(e._rootCreatedAt||e.generatedAt||0).getTime();return new Date(t._rootCreatedAt||t.generatedAt||0).getTime()-n}),a},[lt,Pe]),_t=e=>{const t=e&&!e.endsWith("Z")?"".concat(e,"Z"):e,n=new Date(t);return Number.isNaN(n.getTime())?e:n.toLocaleString()};if(T)return(0,u.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,u.jsx)(Lo,{className:"h-8 w-8 animate-spin text-[#FFB52B]"})});const Bt=v?"flex-shrink-0 rounded-[24px] border border-[#344052] bg-[#202A3A]/92 p-6 text-[#F4F4F4] shadow-[0_26px_48px_-32px_rgba(10,14,20,0.78)]":"flex-shrink-0 rounded-[24px] border border-[#D6DCE4] bg-white/[0.94] p-6 text-[#232E3F] shadow-[0_24px_44px_-30px_rgba(35,46,63,0.28)]",It=v?"mb-4 hidden text-sm text-gray-300 md:block":"mb-4 hidden text-sm text-gray-600 md:block",Pt=v?"flex items-center rounded-md border border-[#445066] bg-[#253247] px-4 py-2 text-[#F4F4F4] transition-colors hover:bg-[#2E3D55] disabled:cursor-not-allowed disabled:opacity-50":"flex items-center rounded-md border border-[#CBD4E1] bg-[#F7F9FC] px-4 py-2 text-[#232E3F] transition-colors hover:bg-[#EBF0F6] disabled:cursor-not-allowed disabled:opacity-50";return(0,u.jsxs)("div",{className:"flex flex-col h-full max-h-[calc(100vh-200px)]",children:[(0,u.jsxs)("div",{className:Bt,children:[(0,u.jsxs)("h2",{className:"text-xl font-semibold mb-4 flex items-center",children:[(0,u.jsx)(gp,{className:"mr-2 h-5 w-5 ".concat(v?"text-[#FFCF74]":"text-[#B57700]")}),"Metadata Generation and Management"]}),!y&&(0,u.jsx)("p",{className:It,children:"Validator-gated agent generation is the default path. Use follow-up agent sessions only for targeted edits or timeline-cut passes on an existing metadata revision."}),!y&&(0,u.jsx)(u.Fragment,{children:(0,u.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,u.jsxs)("button",{onClick:()=>Se({isOpen:!0,topicDensity:18,enableWebSearch:!1,includeEdits:!w,additionalInstructions:""}),disabled:W.filter(e=>"pending"===e.status||"generating"===e.status||"refining"===e.status).length+rt>=4||!Oe||!r||!m,className:"flex items-center rounded-md border border-[#E5A117] bg-[#FFB52B] px-4 py-2 text-[#232E3F] shadow-[0_18px_32px_-24px_rgba(255,181,43,0.9)] transition-colors hover:bg-[#FFC54D] dark:border-[#FFCF74] dark:bg-[#FFCF74] dark:text-[#1C2432] dark:hover:bg-[#FFD987] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,u.jsx)(hh,{className:"h-4 w-4 mr-2"}),"Generate With Agent"]}),(0,u.jsxs)("button",{onClick:()=>ke(!0),className:Pt,title:"MLST ReScript MCP setup",children:[(0,u.jsx)(xp,{className:"h-4 w-4 mr-2"}),"MCP Setup"]}),(0,u.jsx)("button",{onClick:()=>{var e;return null===(e=_e.current)||void 0===e?void 0:e.click()},disabled:Ee||!m,className:Pt,title:"Import TTML exported from DaVinci Resolve or other editors",children:Ee?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Eu,{className:"h-4 w-4 mr-2"}),"Import TTML"]})}),(0,u.jsx)("input",{ref:_e,type:"file",accept:".ttml,.xml",onChange:async e=>{var t;const n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(n&&m&&b){Me(null),Ae(!0),F("");try{var a,r,s,o,l,c,d,u;const e=await n.text();if(!e.includes("<tt")||!e.includes("</tt>"))return void Me({success:!1,message:"Invalid file: Not a valid TTML/XML document"});console.log("[TTML-UPLOAD] Uploading file:",n.name,"size:",e.length);const t=(null===i||void 0===i||null===(a=i.results)||void 0===a||null===(r=a.channels)||void 0===r||null===(s=r[0])||void 0===s||null===(o=s.alternatives)||void 0===o||null===(l=o[0])||void 0===l||null===(c=l.words)||void 0===c||null===(d=c.slice(-1))||void 0===d||null===(u=d[0])||void 0===u?void 0:u.end)||null,g="/api",x=await fetch("".concat(g,"/sessions/").concat(m,"/upload-ttml"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(b)},body:JSON.stringify({ttmlContent:e,filename:n.name,totalDuration:t})}),f=await x.json();if(f.success){Me({success:!0,message:f.message,checksum:f.checksum,isValid:f.isValid,validationErrors:f.validationErrors,validationWarnings:f.validationWarnings});const t=f.ttmlContent||e,a={id:f.checksum,name:n.name,content:t,type:"cached",source:"standard",model:"external-upload",generatedAt:new Date,version:1,
2checksum:f.checksum,isValid:f.isValid,validationErrors:f.validationErrors,validationWarnings:f.validationWarnings,validationStats:f.validationStats,isDraft:Boolean(f.isDraft)};var h;if(P(e=>e.some(e=>e.checksum===f.checksum)?e:[...e,a]),f.isValid)A("TTML imported successfully: ".concat(n.name));else A("TTML imported with ".concat((null===(h=f.validationErrors)||void 0===h?void 0:h.length)||0," validation error(s). Use follow-up fixes to resolve them."));if(p){const e=[...I.filter(e=>e.checksum!==f.checksum),a];p(e.map(e=>({name:e.name,content:e.content||"",filename:e.name,generatedAt:e.generatedAt,checksum:e.checksum,isValid:e.isValid,validationErrors:e.validationErrors,validationWarnings:e.validationWarnings,validationStats:e.validationStats})))}}else Me({success:!1,message:f.error||"Upload failed"}),F(f.error||"Failed to upload TTML")}catch(g){console.error("[TTML-UPLOAD] Error:",g),Me({success:!1,message:g instanceof Error?g.message:"Upload failed"}),F("Failed to upload metadata revision")}finally{Ae(!1),_e.current&&(_e.current.value="")}}},className:"hidden"})]})}),Te&&(0,u.jsxs)("div",{className:"mt-4 p-4 rounded-lg flex items-start gap-3 ".concat(Te.success?Te.isValid?"border border-[#E7B14C]/45 bg-[#FFF4D8] dark:border-[#8E6E33] dark:bg-[#332A17]":"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800":"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800"),children:[Te.success?Te.isValid?(0,u.jsx)(ph,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-[#B57700] dark:text-[#FFCF74]"}):(0,u.jsx)(fp,{className:"h-5 w-5 text-yellow-600 dark:text-yellow-400 flex-shrink-0 mt-0.5"}):(0,u.jsx)(gh,{className:"h-5 w-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsx)("p",{className:"font-medium ".concat(Te.success?Te.isValid?"text-[#8B5B00] dark:text-[#FFE3A1]":"text-yellow-800 dark:text-yellow-200":"text-red-800 dark:text-red-200"),children:Te.message}),Te.validationErrors&&Te.validationErrors.length>0&&(0,u.jsxs)("div",{className:"mt-2",children:[(0,u.jsxs)("p",{className:"text-sm text-yellow-700 dark:text-yellow-300 font-medium mb-1",children:["Validation errors (",Te.validationErrors.length,"):"]}),(0,u.jsxs)("ul",{className:"text-sm text-yellow-600 dark:text-yellow-400 list-disc list-inside space-y-0.5",children:[Te.validationErrors.slice(0,5).map((e,t)=>(0,u.jsx)("li",{children:e.message||String(e)},t)),Te.validationErrors.length>5&&(0,u.jsxs)("li",{className:"italic",children:["...and ",Te.validationErrors.length-5," more"]})]}),(0,u.jsx)("p",{className:"text-sm text-yellow-600 dark:text-yellow-400 mt-2 italic",children:"Use an agent follow-up session on the uploaded TTML to fix these issues and re-validate."})]})]}),(0,u.jsx)("button",{onClick:()=>Me(null),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:(0,u.jsx)(Pu,{className:"h-4 w-4"})})]}),y&&(0,u.jsx)("div",{className:"bg-gray-50 dark:bg-gray-700 p-4 rounded-lg mb-4",children:(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Metadata generation is not available for public shares. You are viewing the existing metadata revisions for this session."})}),!y&&(st.length>0||qe)&&(0,u.jsxs)("div",{className:"mt-4 rounded-2xl border border-[#D6DCE4] bg-[#FFF8EA]/80 dark:border-[#445166] dark:bg-[#202A3A]/88",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>Xe(e=>!e),className:"w-full flex items-start justify-between gap-3 px-3 py-2.5 text-left",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-sm font-medium text-gray-700 dark:text-gray-200",children:[(0,u.jsx)(hh,{className:"h-4 w-4 text-[#B57700] dark:text-[#FFCF74]"}),(0,u.jsx)("span",{children:"Recent Agent Generations"}),(0,u.jsx)("span",{className:"inline-flex items-center rounded-full border border-[#FFB52B]/35 bg-[#FFF4D8] px-2 py-0.5 text-[11px] font-medium text-[#8B5B00] dark:border-[#FFB52B]/30 dark:bg-[#FFB52B]/[0.16] dark:text-[#FFE3A1]",children:it>0?"".concat(it," active"):"".concat(st.length," recent")}
2)]}),(0,u.jsx)("p",{className:"mt-1 text-[11px] text-gray-500 dark:text-gray-400",children:"Validator-gated metadata generation runs for this episode. Follow-up edits stay in the Agent tab."})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2 text-gray-400 dark:text-gray-500",children:[qe&&(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 animate-spin"}),Ke?(0,u.jsx)(wd,{className:"h-4 w-4"}):(0,u.jsx)(bp,{className:"h-4 w-4"})]})]}),(0,u.jsx)(S,{initial:!1,children:Ke&&(0,u.jsx)(Do.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden border-t border-gray-200 dark:border-gray-700",children:(0,u.jsxs)("div",{className:"p-2 space-y-1.5",children:[st.map(e=>{const t="active"===e.status,n="completed"===e.status?"bg-[#FFF4D8] border-[#E7B14C] text-[#8B5B00] dark:bg-[#332A17] dark:border-[#8E6E33] dark:text-[#FFE3A1]":"failed"===e.status?"bg-red-50 dark:bg-red-900/20 border-red-300 dark:border-red-700 text-red-700 dark:text-red-300":"stopped"===e.status?"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-300 dark:border-yellow-700 text-yellow-700 dark:text-yellow-300":"bg-[#EEF1F3] border-[#C7D0DB] text-[#3F4E62] dark:bg-[#273244] dark:border-[#4F5C72] dark:text-[#D5DCE5]";return(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900/40 px-2.5 py-2",children:[(0,u.jsx)("div",{className:"h-2 w-2 rounded-full flex-shrink-0 ".concat("completed"===e.status?"bg-[#FFB52B]":"failed"===e.status?"bg-red-500":"stopped"===e.status?"bg-yellow-500":"bg-[#232E3F] animate-pulse dark:bg-[#FFCF74]")}),(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,u.jsx)("span",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.title||"TTML agent workflow"}),(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full border ".concat(n),children:e.status})]}),(0,u.jsxs)("div",{className:"mt-0.5 text-[11px] text-gray-500 dark:text-gray-400 truncate",children:[[(e.model||"").split("/").pop()||e.model,"Updated ".concat(_t(e.updated_at))].filter(Boolean).join(" \u2022 "),t?" \u2022 Live progress in Agent tab":" \u2022 $".concat((e.total_cost_usd||0).toFixed(2))]})]}),(0,u.jsx)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("navigate-to-agent",{detail:{agentSessionId:e.id}})),className:"shrink-0 rounded-md border border-[#445166] bg-[#232E3F] px-2 py-1 text-xs text-[#F4F4F4] transition-colors hover:bg-[#2F3B4E]",children:"Open"})]},e.id)}),qe&&(0,u.jsxs)("div",{className:"px-1 text-[11px] text-gray-500 dark:text-gray-400 flex items-center",children:[(0,u.jsx)(Lo,{className:"h-3 w-3 animate-spin mr-2"}),"Refreshing generation status..."]})]})})})]}),W.filter(e=>"pending"===e.status||"generating"===e.status||"refining"===e.status||"failed"===e.status||"completed"===e.status&&Date.now()-new Date(e.completed_at||"").getTime()<5e3).length>0&&(0,u.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,u.jsxs)("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 flex items-center",children:[(0,u.jsx)(yp,{className:"h-4 w-4 mr-2"}),"Legacy Server Jobs (",W.filter(e=>"pending"===e.status||"generating"===e.status).length," generating",W.filter(e=>"refining"===e.status).length>0?", ".concat(W.filter(e=>"refining"===e.status).length," refining"):"",W.filter(e=>"failed"===e.status).length>0?", ".concat(W.filter(e=>"failed"===e.status).length," failed"):"",")"]}),(0,u.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Compatibility path only. New TTML creation should start with the validator-gated agent flow above."}),(0,u.jsx)("div",{className:"space-y-2",children:W.filter(e=>"pending"===e.status||"generating"===e.status||"refining"===e.status||"failed"===e.status||"completed"===e.status&&Date.now()-new Date(e.completed_at||"").getTime()<5e3).map(e=>(0,u.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg border transition-all ".concat("generating"===e.status?"bg-[#EEF1F3] border-[#C7D0DB] dark:bg-[#273244] dark:border-[#4F5C72]":"refining"===e.status?"bg-[#232E3F] border-[#445166] dark:bg-[#232E3F] dark:border-[#556176]":"completed"===e.status?"bg-[#FFF4D8] border-[#
2E7B14C] dark:bg-[#332A17] dark:border-[#8E6E33]":"failed"===e.status?"bg-red-50 dark:bg-red-900/20 border-red-300 dark:border-red-700":"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-300 dark:border-yellow-700"),children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:["generating"===e.status&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin text-[#3F4E62] dark:text-[#D5DCE5]"}),"refining"===e.status&&(0,u.jsx)(vp,{className:"h-4 w-4 animate-spin text-[#FFCF74]"}),"completed"===e.status&&(0,u.jsx)(ph,{className:"h-4 w-4 text-[#B57700] dark:text-[#FFCF74]"}),"failed"===e.status&&(0,u.jsx)(gh,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),"pending"===e.status&&(0,u.jsx)(wp,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400"}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["best-of-3"===e.type?"3x Composite":"Standard"," Metadata Generation",(0,u.jsx)("span",{className:"ml-2 text-xs font-normal text-gray-500",children:"(Server-side)"})]}),(0,u.jsxs)("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.model.split("/").pop()," \u2022 ",e.progress||("pending"===e.status?"Queued...":"Processing...")]}),"refining"===e.status&&e.current_refinement>0&&(0,u.jsxs)("div",{className:"mt-1 text-xs text-[#FFCF74]",children:["Refinement ",e.current_refinement," of ",e.max_refinements]}),1===e.enable_web_access&&(0,u.jsx)("div",{className:"mt-1 text-xs text-[#B57700] dark:text-[#FFCF74]",children:"Web access enabled"}),e.error_message&&(0,u.jsx)("div",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:e.error_message}),"completed"===e.status&&e.cost_usd&&(0,u.jsxs)("div",{className:"mt-1 text-xs text-[#B57700] dark:text-[#FFCF74]",children:["Cost: $",e.cost_usd.toFixed(2)]})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.started_at?e.completed_at?"".concat(Math.round((new Date(e.completed_at).getTime()-new Date(e.started_at).getTime())/1e3),"s"):"".concat(Math.round((Date.now()-new Date(e.started_at).getTime())/1e3),"s"):"Waiting..."}),(0,u.jsx)("button",{onClick:t=>{t.stopPropagation(),(async e=>{if(m&&b)try{if(!(await Op.deleteTtmlJob(m,e,b)).success)throw new Error("Failed to delete job");{A("Job deleted successfully");const e=await Op.getTtmlJobs(m,b);e.success&&Y(e.jobs)}}catch(t){console.error("[TTML Jobs] Failed to delete job:",t),F(t.message||"Failed to delete job")}})(e.job_id)},className:"p-1 transition-colors ".concat("pending"===e.status||"generating"===e.status||"refining"===e.status?"text-gray-400 hover:text-orange-500 dark:hover:text-orange-400":"text-gray-400 hover:text-red-500 dark:hover:text-red-400"),title:"pending"===e.status||"generating"===e.status||"refining"===e.status?"Cancel job":"Delete job",children:"pending"===e.status||"generating"===e.status||"refining"===e.status?(0,u.jsx)(gh,{className:"h-4 w-4"}):(0,u.jsx)(kp,{className:"h-3 w-3"})})]})]},e.job_id))})]}),G.filter(e=>"pending"===e.status||"refining"===e.status||"failed"===e.status||("completed"===e.status||"no_changes"===e.status)&&Date.now()-new Date(e.completed_at||"").getTime()<1e4).length>0&&(0,u.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,u.jsxs)("h3",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 flex items-center",children:[(0,u.jsx)(vp,{className:"h-4 w-4 mr-2"}),"Legacy Metadata Follow-Up Jobs (",G.filter(e=>"refining"===e.status).length," active",G.filter(e=>"pending"===e.status).length>0?", ".concat(G.filter(e=>"pending"===e.status).length," pending"):"",G.filter(e=>"failed"===e.status).length>0?", ".concat(G.filter(e=>"failed"===e.status).length," failed"):"",")"]}),(0,u.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Keep these for older runs. For new work, generate with the agent and use targeted follow-up sessions only when you need specific fixes."}),(0,u.jsx)("div",{className:"space-y-2",children:G.filter(e=>"pending"===e.status||"refining"===e.status||"failed"===e.status||("completed"===e.status||"no_changes"===e.status)&&Date.now()-new Date(e.completed_at||"").getTime()<1e4).map(e=>{var t;const n=e.result_checksums?JSON.parse(e.result_checksums):[],a=e.no_change_iterations?JSON.parse(e.no_change_iterations):[];return(0,u.jsxs)("div",{className:"flex items-center justify-between p-3 rounded-lg border transition-all ".concat("refining"===e.status?"bg-[#232E3F] border-[#445166] dark:bg-[#232E3F] dark:border-[#556176]":"completed"===e.status?"bg-[#FFF4D8] border-[#
2E7B14C] dark:bg-[#332A17] dark:border-[#8E6E33]":"no_changes"===e.status?"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-300 dark:border-yellow-700":"failed"===e.status?"bg-red-50 dark:bg-red-900/20 border-red-300 dark:border-red-700":"bg-gray-50 dark:bg-gray-900/20 border-gray-300 dark:border-gray-700"),children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:["refining"===e.status&&(0,u.jsx)(vp,{className:"h-4 w-4 animate-spin text-[#FFCF74]"}),"completed"===e.status&&(0,u.jsx)(ph,{className:"h-4 w-4 text-[#B57700] dark:text-[#FFCF74]"}),"no_changes"===e.status&&(0,u.jsx)(fp,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400"}),"failed"===e.status&&(0,u.jsx)(gh,{className:"h-4 w-4 text-red-600 dark:text-red-400"}),"pending"===e.status&&(0,u.jsx)(wp,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["Follow-Up Pass (",e.max_iterations," iteration",e.max_iterations>1?"s":"",")",(0,u.jsxs)("span",{className:"ml-2 text-xs font-normal text-gray-500",children:[null===(t=e.source_checksum)||void 0===t?void 0:t.substring(0,8),"..."]})]}),(0,u.jsxs)("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.model.split("-").slice(-2).join("-")," \u2022 ",e.progress||("pending"===e.status?"Queued...":"Processing...")]}),"refining"===e.status&&e.current_iteration>0&&(0,u.jsxs)("div",{className:"mt-1 text-xs text-[#FFCF74]",children:["Iteration ",e.current_iteration," of ",e.max_iterations]}),1===e.enable_web_access&&(0,u.jsx)("div",{className:"mt-1 text-xs text-[#B57700] dark:text-[#FFCF74]",children:"Web access enabled"}),1===e.blank_slate&&(0,u.jsx)("div",{className:"mt-1 text-xs text-[#3F4E62] dark:text-[#D5DCE5]",children:"Blank slate mode"}),"completed"===e.status&&(0,u.jsxs)("div",{className:"mt-1 text-xs text-[#B57700] dark:text-[#FFCF74]",children:["Created ",n.length," version(s)",a.length>0?", ".concat(a.length," no-op"):""," \u2022 $",(e.total_cost_usd||0).toFixed(2)]}),"no_changes"===e.status&&(0,u.jsxs)("div",{className:"text-xs text-yellow-600 dark:text-yellow-400 mt-1",children:["No changes detected in ",a.length," iteration(s) \u2022 $",(e.total_cost_usd||0).toFixed(2)]}),e.error_message&&(0,u.jsx)("div",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:e.error_message})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.started_at?e.completed_at?"".concat(Math.round((new Date(e.completed_at).getTime()-new Date(e.started_at).getTime())/1e3),"s"):"".concat(Math.round((Date.now()-new Date(e.started_at).getTime())/1e3),"s"):"Waiting..."}),("failed"===e.status||"completed"===e.status||"no_changes"===e.status)&&(0,u.jsx)("button",{onClick:async t=>{t.stopPropagation();try{await Op.deleteRefinementJob(m,e.job_id,b),K(t=>t.filter(t=>t.job_id!==e.job_id))}catch(n){console.error("Failed to delete refinement job:",n)}},className:"p-1 text-gray-400 hover:text-red-500 dark:hover:text-red-400 transition-colors",title:"Delete job",children:(0,u.jsx)(kp,{className:"h-3 w-3"})})]})]},e.job_id)})})]}),_&&(0,u.jsx)("div",{className:"mt-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-md",children:(0,u.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,u.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Token Usage:"}),(0,u.jsxs)("div",{className:"flex gap-4",children:[(0,u.jsxs)("span",{children:["Prompt: ",_.prompt_tokens.toLocaleString()]}),(0,u.jsxs)("span",{children:["Completion: ",_.completion_tokens.toLocaleString()]}),(0,u.jsxs)("span",{className:"font-semibold",children:["Total: ",_.total_tokens.toLocaleString()]})]})]})})]}),(0,u.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-6 mt-6 pr-2",children:[(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow",children:[(0,u.jsx)("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:(0,u.jsxs)("h3",{className:"text-lg font-semibold flex items-center justify-between",children:[(0,u.jsxs)("span",{className:"flex items-center",children:[(0,u.jsx)(gp,{className:"h-5 w-5 mr-2"}),"Metadata Revisions (",Mt.length,lt.length>Mt.length?" \u2022 ".concat(lt.length," visible versions"):"",")"]}),L&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin text-gray-500"})]})}),(0,u.jsx)("div",{className:"px-6 py-3 border-b border-gray-200 dark:border-gray-700 bg-gray-50/80 dark:bg-gray-900/20",children:(0,u.jsxs)("div",{className:"flex flex-col gap-2 md:flex-row md:items-start md:justify-between",children:[(0,u.jsxs)("div",{className:"flex items-start gap-2 text-xs text-gray-600 dark:text-gray-400",children:[(0,u.jsx)(jp,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0 text-gray-400 dark:text-gray-500"}),(0,u.jsx)("div",{children:"Visible cards show finalized revisions in each metadata lineage. Agent generation may create intermediate draft mutations that stay hidden here until a revision is finalized."})]}),ot>0?(0,u.jsx)("button",{type:"button",onClick:()=>$e(e=>!e),className:"self-start text-[11px] px-2 py-1 rounded-md border border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-300 hover:bg-white dark:hover:bg-gray-800 transition-colors",children:Je?"Hide ".concat(ot," draft mutation").concat(1===ot?"":"s"):"Show ".concat(ot," draft mutation").concat(1===ot?"":"s")}):(0,u.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-gray-500",children:"Draft intermediates are hidden unless the backend returns them."})]})}),(0,u.jsxs)("div",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:[Mt.map(e=>{var t,n,r,s,i,o,l,c,h;return(0,u.jsxs)("div",{className:"p-4 transition-colors cursor-pointer relative ".concat(e.isSelected?"border-l-4 border-[#FFB52B] bg-[#FFF8EA] dark:bg-[#2B3241]":"hover:bg-gray-50 dark:hover:bg-gray-700"),onClick:t=>{var n;"INPUT"===t.target.tagName||"BUTTON"===t.target.tagName||t.target.closest("button")||e.checksum&&!1!==e.isValid&&
2(console.log("[TTML-SELECT] Row clicked, selecting:",null===(n=e.checksum)||void 0===n?void 0:n.substring(0,8)),gt(e.checksum))},onMouseEnter:()=>{var t;g&&!1!==e.isValid&&(console.log("[TTML-HOVER] Row hover enter:",null===(t=e.checksum)||void 0===t?void 0:t.substring(0,8)),g(e.checksum||e.id))},onMouseLeave:()=>{g&&(console.log("[TTML-HOVER] Row hover leave"),g(null))},children:[(0,u.jsxs)("div",{className:"flex items-start justify-between",children:[(0,u.jsx)("div",{className:"flex items-start gap-3",children:(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,u.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:e.name}),e.isDraft&&(0,u.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-200",children:"Draft"}),e.isSelected&&(0,u.jsxs)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium border border-[#FFB52B]/40 bg-[#FFF4D8] text-[#8B5B00] dark:border-[#FFB52B]/30 dark:bg-[#FFB52B]/[0.16] dark:text-[#FFE3A1]",children:[(0,u.jsx)(Dp,{className:"h-3 w-3 mr-1"}),"Selected"]}),je.has(e.checksum||"")&&(0,u.jsxs)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium border border-[#445166] bg-[#232E3F] text-[#F4F4F4] animate-pulse",children:[(0,u.jsx)(Lo,{className:"h-3 w-3 mr-1 animate-spin"}),"Refining..."]}),!0===e.isValid&&(e.validationWarnings&&e.validationWarnings.length>0?(0,u.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-yellow-100 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-100 cursor-help",title:"".concat(e.validationWarnings.length," warnings: ").concat(e.validationWarnings.slice(0,3).map(e=>e.message).join("; ")).concat(e.validationWarnings.length>3?"...":""),children:[(0,u.jsx)(fp,{className:"h-3 w-3 mr-1"}),e.validationWarnings.length," warnings"]}):(0,u.jsxs)("span",{className:"inline-flex items-center rounded px-2 py-0.5 text-xs font-medium border border-[#E7B14C]/45 bg-[#FFF4D8] text-[#8B5B00] dark:border-[#8E6E33] dark:bg-[#332A17] dark:text-[#FFE3A1]",children:[(0,u.jsx)(ph,{className:"h-3 w-3 mr-1"}),"Valid"]})),!1===e.isValid&&(0,u.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-red-100 text-red-800 dark:bg-red-800 dark:text-red-100 cursor-help",title:(null===(t=e.validationErrors)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.message)||(null===(r=e.validationErrors)||void 0===r||null===(s=r[0])||void 0===s?void 0:s.type)||"Validation failed",children:[(0,u.jsx)(gh,{className:"h-3 w-3 mr-1"}),(null===(i=e.validationErrors)||void 0===i||null===(o=i[0])||void 0===o||null===(l=o.type)||void 0===l?void 0:l.replace(/_/g," "))||"Invalid"]}),void 0===e.isValid&&!e.validationStats&&(0,u.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-100",children:[(0,u.jsx)(wp,{className:"h-3 w-3 mr-1 animate-pulse"}),"Validating..."]})]}),(0,u.jsxs)("div",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400 space-y-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-4",children:[(0,u.jsxs)("span",{className:"flex items-center",children:[(0,u.jsx)(wp,{className:"h-3 w-3 mr-1"}),new Date(e.generatedAt).toLocaleString()]}),(0,u.jsxs)("span",{children:["Model: ",e.model]})]}),((null===(c=e.tokenUsage)||void 0===c?void 0:c.total_tokens)||null!==e.costUsd&&void 0!==e.costUsd)&&(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(yp,{className:"h-3 w-3"}),(null===(h=e.tokenUsage)||void 0===h?void 0:h.total_tokens)&&(0,u.jsxs)("span",{children:["Tokens: ",e.tokenUsage.total_tokens.toLocaleString()]}),(()=>{const t=e._chainVersions||[e],n=t.reduce((e,t)=>e+(t.costUsd||0),0);return n>0&&t.length>1?(0,u.jsxs)("span",{className:"text-[#B57700] dark:text-[#FFCF74]",title:"This version: $".concat((e.costUsd||0).toFixed(2)," | Total across ").concat(t.length," versions"),children:["(\u03a3 $",n.toFixed(2),")"]}):n>0?(0,u.jsxs)("span",{className:"text-[#B57700] dark:text-[#FFCF74]",children:["($",n.toFixed(2),")"]}):null})()]}),(()=>{let t=e.generatedBy;if(!t){const n=(e._chainVersions||[]).find(e=>1===e.version||!e.parentChecksum);t=null===n||void 0===n?void 0:n.generatedBy}return t?(0,u.jsx)("div",{className:"flex items-center gap-2 text-gray-400 dark:text-gray-500",children:(0,u.jsxs)("span",{children:["By: ",t]})}):null})(),e.validationStats&&(0,u.jsx)("div",{className:"flex items-center gap-3 text-xs mt-1",children:((t,n,a,r)=>{const s=Tt[e.id],i=e=>{if(null===s||void 0===s||!s.hasParent||0===e)return null;const t=e>0;return(0,u.jsxs)("span",{className:"ml-1 font-medium ".concat(t?"text-[#B57700] dark:text-[#FFCF74]":"text-red-600 dark:text-red-400"),children:[t?"+":"",e]})};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:["Topics: ",(null===(t=e.validationStats.segmentsByType)||void 0===t?void 0:t.topic)||0,i((null===s||void 0===s?void 0:s.topics)||0)]}),(0,u.jsxs)("span",{className:"inline-flex items-center rounded border border-[#445166] bg-[#232E3F] px-2 py-0.5 text-[#F4F4F4]",children:["Clips: ",(null===(n=e.validationStats.segmentsByType)||void 0===n?void 0:n.clip)||0,i((null===s||void 0===s?void 0:s.clips)||0)]}),(0,u.jsxs)("span",{className:"inline-flex items-center px-2 py-0.5 rounded bg-yellow-100 text-yellow-700 dark:bg-yellow-700 dark:text-yellow-300",children:["Edits: ",(null===(a=e.validationStats.segmentsByType)||void 0===a?void 0:a.edit)||0,i((null===s||void 0===s?void 0:s.edits)||0)]}),(0,u.jsxs)("span",{className:"inline-flex items-center rounded border border-[#C7D0DB] bg-[#EEF1F3] px-2 py-0.5 text-[#3F4E62] dark:border-[#4F5C72] dark:bg-[#273244] dark:text-[#D5DCE5]",children:["Refs: ",(null===(r=e.validationStats.segmentsByType)||void 0===r?void 0:r.reference)||0,i((null===s||void 0===s?void 0:s.refs)||0)]})]})})()}),!1===e.isValid&&e.validationErrors&&e.validationErrors.length>0&&(0,u.jsxs)("div",{className:"mt-2 p-2 bg-red-50 dark:bg-red-900/20 rounded text-xs",children:[(0,u.jsx)("div",{className:"font-medium text-red-800 dark:text-red-200 mb-1",children:"Validation Errors:"}),e.validationErrors.slice(0,3).map((e,t)=>(0,u.jsxs)("div",{className:"text-red-700 dark:text-red-300",children:["\u2022 ",e.message]},t)),e.validationErrors.length>3&&(0,u.jsxs)("div",{className:"text-red-700 dark:text-red-300",children:["... and ",e.validationErrors.length-3," more errors"]})]})]})]})}),(0,u.jsxs)("div",{className:"flex items-center gap-1 ml-4",children:[(0,u.jsx)("button",{onClick:()=>(async e=>{try{let t;if("cached"!==e.type||e.content)t=e.content||"";else{const n=await Op.downloadCachedTTML(e.checksum,b);t=await n.text()}ie({isOpen:!0,file:e,content:t}),de(t),me(!1),xe(null),le("raw"),Ct(t)}catch(t){console.error("Failed to load TTML content:",t),F("Failed to load TTML content")}})(e),className:"p-2 text-gray-600 hover:text-[#232E3F] dark:text-gray-400 dark:hover:text-[#FFCF74]",title:"View metadata revision",children:(0,u.jsx)(Cp,{className:"h-4 w-4"})}),(e.refinementLog&&e.refinementLog.length>0||e.revisionNotes)&&(0,u.jsx)("button",{onClick:()=>ve({isOpen:!0,file:e}
2),className:"p-2 text-gray-600 hover:text-amber-600 dark:text-gray-400 dark:hover:text-amber-400",title:e.revisionNotes?"View revision notes":"View refinement log",children:(0,u.jsx)(gp,{className:"h-4 w-4"})}),(0,u.jsx)("button",{onClick:()=>(async e=>{try{let t;if("cached"!==e.type||e.content)t=e.content||"";else{const n=await Op.downloadCachedTTML(e.checksum,b);t=await n.text()}await Up(t),A("Raw TTML copied to clipboard"),setTimeout(()=>A(""),3e3)}catch(t){console.error("Failed to copy TTML:",t),F("Failed to copy TTML to clipboard")}})(e),className:"p-2 text-gray-600 hover:text-[#B57700] dark:text-gray-400 dark:hover:text-[#FFCF74]",title:"Copy TTML to clipboard",children:(0,u.jsx)(Np,{className:"h-4 w-4"})}),!y&&(0,u.jsx)("button",{onClick:()=>(e=>{Ne({isOpen:!0,file:e,instructions:"",iterationCount:1,blankSlate:!1,maxIssuesToFix:0,topicDensity:18})})(e),disabled:je.has(e.checksum||"")||!e.checksum,className:"p-2 disabled:opacity-50 ".concat(je.has(e.checksum||"")?"text-[#FFCF74]":"text-gray-600 hover:text-[#232E3F] dark:text-gray-400 dark:hover:text-[#FFCF74]"),title:je.has(e.checksum||"")?"Agent follow-up in progress...":"Start targeted metadata follow-up in agent".concat(te?" (with web access)":""),children:je.has(e.checksum||"")?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Fp,{className:"h-4 w-4"})}),(0,u.jsx)("button",{onClick:()=>bt(e),className:"p-2 text-gray-600 hover:text-[#B57700] dark:text-gray-400 dark:hover:text-[#FFCF74]",title:"Download TTML",children:(0,u.jsx)(Sp,{className:"h-4 w-4"})}),!y&&(0,u.jsx)("button",{onClick:()=>(async e=>{try{"cached"===e.type&&e.checksum&&await Op.deleteCachedTTML(e.checksum,b);const t=I.filter(t=>t.id!==e.id);if(P(t),A("Metadata revision deleted"),e.isSelected&&m){const e=t.filter(e=>!1!==e.isValid);if(e.length>0){const t=e[0],n=t.checksum||t.id;await Vm.updateSession({sessionId:m,selectedTtmlId:n},b),V(n),P(e=>e.map(e=>d(d({},e),{},{isSelected:(e.checksum||e.id)===n}))),x&&x(n),A("Metadata revision deleted. Auto-selected: ".concat(t.name))}else await Vm.updateSession({sessionId:m,selectedTtmlId:null},b),V(null),g&&g(null)}}catch(t){console.error("Failed to delete TTML file:",t),F("Failed to delete metadata revision")}})(e),className:"p-2 text-gray-600 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400",title:"Delete metadata revision",children:(0,u.jsx)(kp,{className:"h-4 w-4"})})]})]}),(()=>{const t=e._chainVersions||[e],n=e._chainRootKey||e.rootChecksum||e.checksum,r=t.some(e=>e.isSelected);return(0,u.jsx)("div",{className:"absolute bottom-2 right-2 flex items-center gap-0.5",title:"Version history - click to select",children:t.map((e,t)=>(0,u.jsxs)(a.Fragment,{children:[(0,u.jsx)("button",{onClick:t=>{var a;t.stopPropagation(),console.log("[TTML-ORB] Version orb clicked:",null===(a=e.checksum)||void 0===a?void 0:a.substring(0,8),"version:",e.version),e.checksum&&!1!==e.isValid&>(e.checksum),e.checksum&&n&&Le(t=>d(d({},t),{},{[n]:e.checksum}))},onMouseEnter:t=>{var n;t.stopPropagation(),console.log("[TTML-ORB] Version orb hover:",null===(n=e.checksum)||void 0===n?void 0:n.substring(0,8),"version:",e.version),g&&!1!==e.isValid&&e.checksum&&g(e.checksum)},onMouseLeave:e=>{e.stopPropagation()},className:"w-4 h-4 rounded-full text-[10px] font-medium transition-all border ".concat(e.isSelected?"border-[#FFB52B] bg-[#FFB52B] text-[#232E3F]":e.isDraft?"bg-transparent text-amber-600 border-amber-400 hover:bg-amber-50 dark:text-amber-300 dark:border-amber-600 dark:hover:bg-amber-900/20":!1===e.isValid?"bg-transparent text-red-600 border-red-400 hover:bg-red-50 dark:text-red-400 dark:border-red-500 dark:hover:bg-red-900/30":e.validationWarnings&&e.validationWarnings.length>0?"bg-transparent text-yellow-600 border-yellow-400 hover:bg-yellow-50 dark:text-yellow-400 dark:border-yellow-500 dark:hover:bg-yellow-900/30":r?"bg-transparent text-[#232E3F] border-[#445166] hover:bg-[#EEF1F3] dark:text-[#D5DCE5] dark:border-[#4F5C72] dark:hover:bg-[#273244]":"bg-transparent text-gray-400 border-gray-300 hover:bg-gray-50 dark:text-gray-500 dark:border-gray-600 dark:hover:bg-gray-800"),title:"Version ".concat(e.version||
21).concat(e.isDraft?" (draft)":!1===e.isValid?" (invalid)":e.validationWarnings&&e.validationWarnings.length>0?" (".concat(e.validationWarnings.length," warnings)"):e.isSelected?" (selected)":""," - click to select"),children:e.version||1}),e.noOpRefinements&&e.noOpRefinements.length>0&&(0,u.jsx)("span",{className:"w-4 h-4 rounded-full text-[10px] font-bold flex items-center justify-center bg-amber-100 dark:bg-amber-900/40 text-amber-600 dark:text-amber-400 border border-amber-300 dark:border-amber-700 cursor-help",title:"".concat(e.noOpRefinements.length," refinement(s) produced no changes - cost: $").concat(e.noOpRefinements.reduce((e,t)=>e+(t.costUsd||0),0).toFixed(2),"\nClick Log button to see details"),children:"!"})]},e.checksum||t))})})()]},e.id)}),0===Mt.length&&!L&&(0,u.jsxs)("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400",children:[(0,u.jsx)(gp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,u.jsx)("p",{children:ot>0&&!Je?"No finalized metadata revisions are visible yet":"No metadata revisions generated yet"}),(0,u.jsx)("p",{className:"text-sm mt-2",children:ot>0&&!Je?"Draft mutation revisions exist, but they are hidden by default. Use the toggle above to inspect them.":'Click "Generate With Agent" to create your first metadata draft'})]})]})]}),(0,u.jsxs)(S,{children:[N&&(0,u.jsx)(Do.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,u.jsxs)("div",{className:"flex items-center",children:[(0,u.jsx)(Lu,{className:"h-5 w-5 text-red-600 dark:text-red-400 mr-3"}),(0,u.jsx)("p",{className:"text-red-800 dark:text-red-200",children:N})]})}),E&&(0,u.jsx)(Do.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"rounded-lg border border-[#E7B14C]/45 bg-[#FFF4D8] p-4 dark:border-[#8E6E33] dark:bg-[#332A17]",children:(0,u.jsxs)("div",{className:"flex items-center",children:[(0,u.jsx)(ph,{className:"mr-3 h-5 w-5 text-[#B57700] dark:text-[#FFCF74]"}),(0,u.jsx)("p",{className:"text-[#8B5B00] dark:text-[#FFE3A1]",children:E})]})})]})]}),(0,u.jsx)(S,{children:se.isOpen&&se.file&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>{ue&&!window.confirm("You have unsaved changes. Close anyway?")||(ie({isOpen:!1,file:null,content:""}),me(!1))},children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-5xl max-h-[85vh] flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsxs)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[(0,u.jsx)(gp,{className:"h-5 w-5 mr-2"}),se.file.name,se.file.version&&(0,u.jsxs)("span",{className:"ml-2 rounded border border-[#445166] bg-[#232E3F] px-2 py-0.5 text-xs text-[#F4F4F4]",children:["v",se.file.version]}),ue&&(0,u.jsx)("span",{className:"ml-2 px-2 py-0.5 text-xs rounded bg-amber-100 text-amber-700 dark:bg-amber-700 dark:text-amber-300",children:"Edited"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[ue&&(0,u.jsxs)("button",{onClick:async()=>{if(se.file&&m&&b)if(ut.current)console.log("[TTML-SAVE] Ignoring duplicate save request - already saving");else{ut.current=!0,pe(!0),xe(null);try{const e="raw"===oe?ce:At(),t=await fetch("".concat("/api","/save-edited-ttml"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(b)},body:JSON.stringify({sessionId:m,parentChecksum:se.file.checksum,editedTtml:e,model:se.file.model})}),n=await t.json();if(!n.success)return void xe(n.error||"Validation failed");A("Saved as new version (v".concat(n.version,")")),ie({isOpen:!1,file:null,content:""}),me(!1),ht()}catch(e){console.error("Failed to save edited TTML:",e),xe(e.message||"Failed to save")}finally{pe(!1),ut.current=!1}}},disabled:he,className:"flex items-center gap-1 rounded bg-[#FFB52B] px-3 py-1.5 text-sm font-medium text-[#232E3F] transition-colors hover:bg-[#FFC54D] disabled:opacity-50",children:[he?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Dh,{className:"h-4 w-4"}),"Save as New Version"]}),(0,u.jsx)("button",{onClick:()=>Up("raw"===oe?ce:At()),className:"p-2 text-gray-600 hover:text-[#B57700] dark:text-gray-400 dark:hover:text-[#FFCF74]",title:"Copy to clipboard",children:(0,u.jsx)(Np,{className:"h-4 w-4"})}),(0,u.jsx)("button",{onClick:()=>bt(se.file),className:"p-2 text-gray-600 hover:text-[#B57700] dark:text-gray-400 dark:hover:text-[#FFCF74]",title:"Download",children:(0,u.jsx)(Sp,{className:"h-4 w-4"})}),(0,u.jsx)("button",{onClick:()=>{ue&&!window.confirm("You have unsaved changes. Close anyway?")||(ie({isOpen:!1,file:null,content:""}),me(!1))},className:"p-2 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]})]}),(0,u.jsx)("div",{className:"flex border-b border-gray-200 dark:border-gray-700",children:[{id:"raw",label:"Raw TTML"},{id:"topics",label:"Topics (".concat(fe.topics.length,")")},{id:"clips",label:"Clips (".concat(fe.clips.filter(e=>{var t;return!(null!==(t=e.clipTitle)&&void 0!==t&&t.includes("PLACEHOLDER"))}).length,")")},{id:"edits",label:"Edits (".concat(fe.edits.length,")")},{id:"references",label:"References (".concat(fe.references.length,")")}].map(e=>(0,u.jsx)("button",{onClick:()=>le(e.id),className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors ".concat(oe===e.id?"border-[#FFB52B] text-[#8B5B00] dark:text-[#FFCF74]":"border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"),children:e.label},e.id))}),ge&&(0,u.jsxs)("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg text-red-700 dark:text-red-300 text-sm",children:[(0,u.jsx)("strong",{children:"Validation Error:"})," ",ge]}),(0,u.jsx)("div",{className:"flex-1 overflow-auto p-4",children:"raw"===oe?(0,u.jsx)("textarea",{value:ce,onChange:e=>{de(e.target.value),me(!0)},className:"w-full h-full min-h-[400px] resize-none rounded-lg border border-gray-200 bg-gray-50 p-4 text-xs font-mono focus:border-transparent focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-700 dark:bg-gray-900",spellCheck:!1}):"topics"===oe?(0,u.jsx)("div",{className:"space-y-4",children:0===fe.topics.length?(0,u.jsx)("div",{className:"text-center text-gray-500 dark:text-gray-400 py-8",children:"No topic segments found in this TTML."}):fe.topics.map((e,t)=>
2(0,u.jsxs)("div",{className:"rounded-lg border border-[#E7B14C]/45 bg-gray-50 p-4 dark:border-[#8E6E33] dark:bg-gray-900",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1 rounded border border-[#E7B14C]/40 bg-[#FFF4D8] px-2 py-1 dark:border-[#8E6E33] dark:bg-[#332A17]",children:[(0,u.jsxs)("span",{className:"text-sm font-bold text-[#8B5B00] dark:text-[#FFE3A1]",children:["#",e.topicRank||t+1]}),e.topicPlacement&&(0,u.jsxs)("span",{className:"text-xs text-[#B57700] dark:text-[#FFCF74]",children:["/",e.topicPlacement.split("/")[1]||"?"]})]}),e.topicScore&&(0,u.jsx)("span",{className:"text-xs bg-gray-200 dark:bg-gray-700 px-2 py-1 rounded text-gray-600 dark:text-gray-300",children:e.topicScore.split("(")[0].trim()}),(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsx)("input",{type:"text",value:e.begin,onChange:t=>Et(e.id,"begin",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000",title:0===t?"First topic start time":"Changing this also updates the previous topic's end time"}),(0,u.jsx)("span",{className:"text-gray-400",children:"\u2192"}),(0,u.jsx)("input",{type:"text",value:e.end,onChange:t=>Et(e.id,"end",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000",title:t===fe.topics.length-1?"Last topic end time":"Changing this also updates the next topic's start time"})]})]}),(0,u.jsx)("button",{onClick:()=>St("topics",e.id),className:"p-1 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",title:"Delete topic",children:(0,u.jsx)(kp,{className:"h-4 w-4"})})]}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Title"}),(0,u.jsx)("input",{type:"text",value:e.topicTitle||"",onChange:t=>Nt("topics",e.id,"topicTitle",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-600 dark:bg-gray-800",placeholder:"Topic title..."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Justification"}),(0,u.jsx)("textarea",{value:e.topicJustification||"",onChange:t=>Nt("topics",e.id,"topicJustification",t.target.value),className:"w-full resize-y rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-600 dark:bg-gray-800",rows:2,placeholder:"Why this segment has this ranking..."})]}),e.topicContinuity&&(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Continuity Note"}),(0,u.jsx)("input",{type:"text",value:e.topicContinuity||"",onChange:t=>Nt("topics",e.id,"topicContinuity",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-600 dark:bg-gray-800",placeholder:"Continuity with previous/next topics..."})]})]})]},e.id))}):"clips"===oe?(0,u.jsx)("div",{className:"space-y-4",children:0===fe.clips.filter(e=>{var t;return!(null!==(t=e.clipTitle)&&void 0!==t&&t.includes("PLACEHOLDER"))}).length?(0,u.jsx)("div",{className:"text-center text-gray-500 dark:text-gray-400 py-8",children:"No clip segments found in this TTML."}):fe.clips.filter(e=>{var t;return!(null!==(t=e.clipTitle)&&void 0!==t&&t.includes("PLACEHOLDER"))}).map(e=>(0,u.jsxs)("div",{className:"rounded-lg border border-[#445166] bg-gray-50 p-4 dark:border-[#556176] dark:bg-gray-900",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("span",{className:"text-sm font-medium text-[#232E3F] dark:text-[#FFCF74]",children:"CLIP"}),(0,u.jsx)("input",{type:"text",value:e.begin,onChange:t=>
2Ft("clips",e.id,"begin",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000"}),(0,u.jsx)("span",{className:"text-gray-400",children:"\u2192"}),(0,u.jsx)("input",{type:"text",value:e.end,onChange:t=>Ft("clips",e.id,"end",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000"})]}),(0,u.jsx)("button",{onClick:()=>St("clips",e.id),className:"p-1 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",title:"Delete clip",children:(0,u.jsx)(kp,{className:"h-4 w-4"})})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Title"}),(0,u.jsx)("input",{type:"text",value:e.clipTitle||"",onChange:t=>Nt("clips",e.id,"clipTitle",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#232E3F]/20 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#FFB52B]/25",placeholder:"Clip title..."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Type"}),(0,u.jsxs)("select",{value:e.clipType||"",onChange:t=>Nt("clips",e.id,"clipType",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#232E3F]/20 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#FFB52B]/25",children:[(0,u.jsx)("option",{value:"",children:"Select type..."}),(0,u.jsx)("option",{value:"Viral Hook",children:"Viral Hook"}),(0,u.jsx)("option",{value:"Educational Nugget",children:"Educational Nugget"}),(0,u.jsx)("option",{value:"Humorous Aside",children:"Humorous Aside"})]})]}),(0,u.jsxs)("div",{className:"col-span-2",children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Description"}),(0,u.jsx)("textarea",{value:e.clipDescription||"",onChange:t=>Nt("clips",e.id,"clipDescription",t.target.value),className:"w-full resize-y rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#232E3F]/20 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#FFB52B]/25",rows:2,placeholder:"Why this works as a clip..."})]}),(0,u.jsxs)("div",{className:"col-span-2",children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Visual Suggestion"}),(0,u.jsx)("input",{type:"text",value:e.clipVisual||"",onChange:t=>Nt("clips",e.id,"clipVisual",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#232E3F]/20 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#FFB52B]/25",placeholder:"Suggested visuals or b-roll..."})]})]})]},e.id))}):"edits"===oe?(0,u.jsx)("div",{className:"space-y-4",children:0===fe.edits.length?(0,u.jsx)("div",{className:"text-center text-gray-500 dark:text-gray-400 py-8",children:"No edit segments found in this TTML."}):fe.edits.map(e=>(0,u.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-red-200 dark:border-red-800",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("span",{className:"text-red-600 dark:text-red-400 font-medium text-sm",children:"EDIT"}),(0,u.jsx)("input",{type:"text",value:e.begin,onChange:t=>Ft("edits",e.id,"begin",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000"}),(0,u.jsx)("span",{className:"text-gray-400",children:"\u2192"}),(0,u.jsx)("input",{type:"text",value:e.end,onChange:t=>Ft("edits",e.id,"end",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000"})]}),(0,u.jsx)("button",{onClick:()=>St("edits",e.id),className:"p-1 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",title:"Delete edit",children:(0,u.jsx)(kp,{className:"h-4 w-4"})})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Title"}),(0,u.jsx)("input",{type:"text",value:e.editTitle||"",onChange:t=>Nt("edits",e.id,"editTitle",t.target.value),className:"w-full text-sm bg-white dark:bg-gray-800 px-3 py-2 rounded border border-gray-300 dark:border-gray-600 focus:ring-2 focus:ring-red-500",placeholder:"Edit title..."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Priority"}),(0,u.jsxs)("select",{value:e.editPriority||"",onChange:t=>Nt("edits",e.id,"editPriority",t.target.value),className:"w-full text-sm bg-white dark:bg-gray-800 px-3 py-2 rounded border border-gray-300 dark:border-gray-600 focus:ring-2 focus:ring-red-500",children:[(0,u.jsx)("option",{value:"",children:"Select priority..."}),(0,u.jsx)("option",{value:"High",children:"High"}),(0,u.jsx)("option",{value:"Medium",children:"Medium"}),(0,u.jsx)("option",{value:"Low",children:"Low"})]})]}),(0,u.jsxs)("div",{className:"col-span-2",children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Suggestion"}),(0,u.jsx)("textarea",{value:e.editSuggestion||"",onChange:t=>Nt("edits",e.id,"editSuggestion",t.target.value),className:"w-full text-sm bg-white dark:bg-gray-800 px-3 py-2 rounded border border-gray-300 dark:border-gray-600 focus:ring-2 focus:ring-red-500 resize-y",rows:2,placeholder:"What to do (cut, trim, add context, etc.)..."})]}),(0,u.jsxs)("div",{className:"col-span-2",children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Improvement"}),(0,u.jsx)("textarea",{value:e.editImprovement||"",onChange:t=>Nt("edits",e.id,"editImprovement",t.target.value),className:"w-full text-sm bg-white dark:bg-gray-800 px-3 py-2 rounded border border-gray-300 dark:border-gray-600 focus:ring-2 focus:ring-red-500 resize-y",rows:2,placeholder:"Why this edit helps..."})]})]})]},e.id))}):(0,u.jsx)("div",{className:"space-y-4",children:0===fe.references.length?(0,u.jsx)("div",{className:"text-center text-gray-500 dark:text-gray-400 py-8",children:"No reference segments found in this TTML."}):fe.references.map(e=>(0,u.jsxs)("div",{className:"rounded-lg border border-[#D7C3A0] bg-gray-50 p-4 dark:border-[#6A5A44] dark:bg-gray-900",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("span",{className:"text-sm font-medium text-[#7A6346] dark:text-[#E4D7BD]",children:"REF"}),(0,u.jsx)("input",{type:"text",value:e.begin,onChange:t=>Ft("references",e.id,"begin",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000"}),(0,u.jsx)("span",{className:"text-gray-400",children:"\u2192"}),(0,u.jsx)("input",{type:"text",value:e.end,onChange:t=>Ft("references",e.id,"end",t.target.value),className:"w-28 text-xs font-mono bg-white dark:bg-gray-800 px-2 py-1 rounded border border-gray-300 dark:border-gray-600",placeholder:"00:00:00.000"})]}),(0,u.jsx)("button",{onClick:()=>St("references",e.id),className:"p-1 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",title:"Delete reference",children:(0,u.jsx)(kp,{className:"h-4 w-4"})})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Name"}),(0,u.jsx)("input",{type:"text",value:e.refName||"",onChange:t=>
2Nt("references",e.id,"refName",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#D7C3A0]/45 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#6A5A44]/40",placeholder:"Reference name..."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Category"}),(0,u.jsx)("input",{type:"text",value:e.refCategory||"",onChange:t=>Nt("references",e.id,"refCategory",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#D7C3A0]/45 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#6A5A44]/40",placeholder:"Person, Paper, Book, etc."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Link Text"}),(0,u.jsx)("input",{type:"text",value:e.refLinkText||"",onChange:t=>Nt("references",e.id,"refLinkText",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#D7C3A0]/45 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#6A5A44]/40",placeholder:"arXiv Paper, Official Site, etc."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"URL"}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("input",{type:"url",value:e.refUrl||"",onChange:t=>Nt("references",e.id,"refUrl",t.target.value),className:"flex-1 rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#D7C3A0]/45 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#6A5A44]/40",placeholder:"https://..."}),e.refUrl&&e.refUrl.startsWith("http")&&(0,u.jsx)("a",{href:e.refUrl,target:"_blank",rel:"noopener noreferrer",className:"rounded p-2 text-[#232E3F] transition-colors hover:bg-[#EEF1F3] hover:text-[#1B2433] dark:text-[#D5DCE5] dark:hover:bg-[#273244] dark:hover:text-[#FFCF74]",title:"Open URL in new tab",children:(0,u.jsx)(Ep,{className:"h-4 w-4"})})]})]}),(0,u.jsxs)("div",{className:"col-span-2",children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Context"}),(0,u.jsx)("textarea",{value:e.refContext||"",onChange:t=>Nt("references",e.id,"refContext",t.target.value),className:"w-full resize-y rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#D7C3A0]/45 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#6A5A44]/40",rows:2,placeholder:"Why this reference is relevant..."})]}),(0,u.jsxs)("div",{className:"col-span-2",children:[(0,u.jsx)("label",{className:"block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Visual Suggestion"}),(0,u.jsx)("input",{type:"text",value:e.refVisual||"",onChange:t=>Nt("references",e.id,"refVisual",t.target.value),className:"w-full rounded border border-gray-300 bg-white px-3 py-2 text-sm focus:ring-2 focus:ring-[#D7C3A0]/45 dark:border-gray-600 dark:bg-gray-800 dark:focus:ring-[#6A5A44]/40",placeholder:"Photo, diagram, book cover, etc."})]})]})]},e.id))})})]})})}),(0,u.jsx)(S,{children:ye.isOpen&&ye.file&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>ve({isOpen:!1,file:null}),children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white dark:bg-gray-800 rounded-lg w-full max-w-4xl max-h-[80vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[(0,u.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,u.jsx)(gp,{className:"h-5 w-5 text-amber-500"}),ye.file.refinementLog&&ye.file.refinementLog.length>0?"Refinement Log - ".concat(ye.file.name):"Revision Notes - ".concat(ye.file.name),ye.file.version&&ye.file.version>1&&(0,u.jsxs)("span",{className:"ml-2 rounded border border-[#445166] bg-[#232E3F] px-2 py-0.5 text-xs text-[#F4F4F4]",children:["v",ye.file.version]})]}),(0,u.jsx)("button",{onClick:()=>ve({isOpen:!1,file:null}),className:"p-2 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]}),(0,u.jsxs)("div",{className:"flex-1 overflow-auto p-4 space-y-3",children:[ye.file.revisionNotes&&(0,u.jsxs)("div",{className:"mb-4 rounded-lg border border-[#E7B14C]/45 bg-gradient-to-r from-[#FFF8EA] to-[#F7E2AF] p-4 dark:border-[#8E6E33] dark:from-[#2C2A22] dark:to-[#3B3425]",children:[(0,u.jsxs)("h4",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-[#8B5B00] dark:text-[#FFE3A1]",children:[(0,u.jsx)(Ap,{className:"h-4 w-4"}),"manual"===ye.file.editType?"Revision Notes":"Agent Revision Notes"]}),(0,u.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none text-gray-700 dark:text-gray-300",children:(0,u.jsx)(my,{children:ye.file.revisionNotes})})]}),null===(t=ye.file.refinementLog)||void 0===t?void 0:t.map((e,t)=>{var n,a,r,s;const i=(()=>{switch(e.event){case"generation_start":return{icon:"\u25b6\ufe0f",label:"Generation Started",color:"text-[#3F4E62] dark:text-[#D5DCE5]",bg:"bg-[#EEF1F3] dark:bg-[#273244]"};case"generation_complete":return{icon:"\u2705",label:"Generation Complete",color:"text-[#B57700] dark:text-[#FFCF74]",bg:"bg-[#FFF4D8] dark:bg-[#332A17]"};case"agent_init":return{icon:"\ud83e\udd16",label:"Agent Initialized",color:"text-[#232E3F] dark:text-[#F4F4F4]",bg:"bg-[#EEF1F3] dark:bg-[#232E3F]"};case"assistant_message":return{icon:"\ud83d\udcac",label:"Assistant",color:"text-[#232E3F] dark:text-[#D5DCE5]",bg:"bg-[#EEF1F3] dark:bg-[#273244]"};case"tool_use":return{icon:"\ud83d\udd27",label:"Tool: ".concat(e.tool),color:"text-orange-600 dark:text-orange-400",bg:"bg-orange-50 dark:bg-orange-900/20"};case"tool_result":return{icon:e.isError?"\u274c":"\ud83d\udccb",label:"Tool Result",color:e.isError?"text-red-600 dark:text-red-400":"text-gray-600 dark:text-gray-400",bg:e.isError?"bg-red-50 dark:bg-red-900/20":"bg-gray-50 dark:bg-gray-800"};case"agent_result":return{icon:"\ud83c\udfc1",label:"Agent Complete",color:"text-[#B57700] dark:text-[#FFCF74]",bg:"bg-[#FFF4D8] dark:bg-[#332A17]"};case"manual_refinement":return{icon:"\ud83d\udd27",label:"Manual Refinement",color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-900/20"};case"completed":return{icon:"\u2705",label:"Completed",color:"text-[#B57700] dark:text-[#FFCF74]",bg:"bg-[#FFF4D8] dark:bg-[#332A17]"};default:return{icon:"\ud83d\udcdd",label:e.event,color:"text-gray-600 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"}}})();return(0,u.jsxs)("div",{className:"".concat(i.bg," rounded-lg p-3 border-l-4 ").concat(i.color.replace("text-","border-")),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsxs)("span",{className:"text-sm font-medium ".concat(i.color),children:[i.icon," ",i.label]}),(0,u.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.time?new Date(e.time).toLocaleTimeString():""})]}),"assistant_message"===e.event&&e.text&&(0,u.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-900 rounded p-2 mt-2 whitespace-pre-wrap max-h-48 overflow-y-auto",children:e.text}),"tool_use"===e.event&&e.input&&(0,u.jsx)("div",{className:"text-xs text-gray-600 dark:text-gray-400 bg-white dark:bg-gray-900 rounded p-2 mt-2 font-mono overflow-x-auto",children:(0,u.jsx)("pre",{children:JSON.stringify(e.input,null,2)})}),"tool_result"===e.event&&e.content&&(0,u.jsx)("div",{className:"text-xs ".concat(e.isError?"text-red-600 dark:text-red-400":"text-gray-600 dark:text-gray-400"," bg-white dark:bg-gray-900 rounded p-2 mt-2 font-mono overflow-x-auto max-h-32 overflow-y-auto"),children:e.content}),"agent_init"===e.event&&(0,u.jsxs)("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:["Model: ",(0,u.jsx)("span",{className:"font-medium",children:e.model}),e.tools&&(0,u.jsxs)("span",{className:"ml-2",children:["Tools: ",e.tools.length]})]}),"agent_result"===e.event&&(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-xs mt-2",children:[e.durationMs&&(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-900 p-2 rounded",children:["Duration: ",(0,u.jsxs)("span",{className:"font-medium",children:[(e.durationMs/1e3).toFixed(1),"s"]})]}),e.numTurns&&(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-900 p-2 rounded",children:["Turns: ",(0,u.jsx)("span",{className:"font-medium",children:e.numTurns})]})]}),"generation_complete"===e.event&&(0,u.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 text-xs mt-2",children:[void 0!==e.isValid&&
2(0,u.jsxs)("div",{className:"p-2 rounded ".concat(e.isValid?"bg-[#FFF4D8] dark:bg-[#332A17]":"bg-red-100 dark:bg-red-900/30"),children:["Valid: ",(0,u.jsx)("span",{className:"font-medium ".concat(e.isValid?"text-[#B57700]":"text-red-600"),children:e.isValid?"Yes":"No"})]}),void 0!==e.errors&&(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-900 p-2 rounded",children:["Errors: ",(0,u.jsx)("span",{className:"font-medium",children:e.errors})]}),void 0!==e.warnings&&(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-900 p-2 rounded",children:["Warnings: ",(0,u.jsx)("span",{className:"font-medium",children:e.warnings})]})]}),e.stats&&(0,u.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:["Topics: ",(null===(n=e.stats.segmentsByType)||void 0===n?void 0:n.topic)||0," | Clips: ",(null===(a=e.stats.segmentsByType)||void 0===a?void 0:a.clip)||0," | Edits: ",(null===(r=e.stats.segmentsByType)||void 0===r?void 0:r.edit)||0," | Refs: ",(null===(s=e.stats.segmentsByType)||void 0===s?void 0:s.reference)||0]})]},t)}),(!ye.file.refinementLog||0===ye.file.refinementLog.length)&&(!ye.file.noOpRefinements||0===ye.file.noOpRefinements.length)&&(0,u.jsx)("div",{className:"text-center text-gray-500 dark:text-gray-400 py-8",children:"No activity log available for this version."}),ye.file.noOpRefinements&&ye.file.noOpRefinements.length>0&&(0,u.jsxs)("div",{className:"mt-4 border-t border-amber-200 dark:border-amber-800 pt-4",children:[(0,u.jsxs)("h4",{className:"text-sm font-medium text-amber-700 dark:text-amber-300 mb-2 flex items-center",children:[(0,u.jsx)(fp,{className:"h-4 w-4 mr-2"}),"No-Change Refinements (",ye.file.noOpRefinements.length,")"]}),(0,u.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-400 mb-3",children:"These refinement attempts produced no changes to the metadata revision content."}),(0,u.jsx)("div",{className:"space-y-2",children:ye.file.noOpRefinements.map((e,t)=>{var n,a;return(0,u.jsxs)("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:["Iteration ",e.iteration]}),(0,u.jsxs)("span",{className:"text-xs text-amber-600 dark:text-amber-400",children:["$",(null===(n=e.costUsd)||void 0===n?void 0:n.toFixed(2))||"0.00"]})]}),(0,u.jsxs)("div",{className:"text-xs text-amber-700 dark:text-amber-300 mt-1",children:["Model: ",(null===(a=e.model)||void 0===a?void 0:a.split("-").slice(-2).join("-"))||"unknown"]}),(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:e.timestamp?new Date(e.timestamp).toLocaleString():""}),e.message&&(0,u.jsx)("div",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2",children:e.message})]},t)})}),(0,u.jsxs)("div",{className:"mt-3 text-xs text-amber-600 dark:text-amber-400",children:["Total cost for no-op refinements: $",ye.file.noOpRefinements.reduce((e,t)=>e+(t.costUsd||0),0).toFixed(2)]})]})]})]})})}),(0,u.jsx)(S,{children:Ce.isOpen&&Ce.file&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Ne(e=>d(d({},e),{},{isOpen:!1})),children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-lg",onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsxs)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[(0,u.jsx)(Fp,{className:"mr-2 h-5 w-5 text-[#232E3F] dark:text-[#FFCF74]"}),"Metadata Follow-Up"]}),(0,u.jsx)("button",{onClick:()=>Ne(e=>d(d({},e),{},{isOpen:!1})),className:"p-2 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]}),(0,u.jsxs)("div",{className:"p-4 space-y-4",children:[(0,u.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["Selected Revision: ",(0,u.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:Ce.file.name})]}),(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-700 rounded-md p-3",children:"Use this for targeted fixes, edits, or timeline-cut analysis after the main validator-gated generation pass. First-pass metadata creation now starts from the Generate With Agent button."}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Agent Model (Anthropic)"}),(0,u.jsx)("select",{value:Oe,onChange:e=>Ue(e.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:Re.map(e=>(0,u.jsx)("option",{value:e.id,children:e.name},e.id))})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Additional Instructions (optional)"}),(0,u.jsx)("textarea",{value:Ce.instructions,onChange:e=>{const t=e.target.value;Ne(e=>d(d({},e),{},{instructions:t,blankSlate:t.trim().length>0||e.blankSlate}))},placeholder:"e.g., Focus on improving topic boundaries, add more detailed clip descriptions, fix the intro timestamp...",className:"min-h-[100px] w-full resize-y rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-600 dark:bg-gray-700 dark:text-white"})]}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Number of Refinement Iterations"}),(0,u.jsx)("div",{className:"flex items-center gap-3",children:[1,2,3,5].map(e=>(0,u.jsx)("button",{onClick:()=>Ne(t=>d(d({},t),{},{iterationCount:e})),className:"px-4 py-2 rounded-md font-medium transition-colors ".concat(Ce.iterationCount===e?"bg-[#232E3F] text-[#F4F4F4]":"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"),children:e},e))}),(0,u.jsx)("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Each iteration will try to improve the TTML further based on validation and quality criteria."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Issues to Fix per Pass"}),(0,u.jsx)("div",{className:"flex items-center gap-3",children:[{value:0,label:"All"},{value:2,label:"2"},{value:5,label:"5"},{value:10,label:"10"}].map(e=>(0,u.jsx)("button",{onClick:()=>Ne(t=>d(d({},t),{},{maxIssuesToFix:e.value})),className:"px-4 py-2 rounded-md font-medium transition-colors ".concat(Ce.maxIssuesToFix===e.value?"bg-[#232E3F] text-[#F4F4F4]":"bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600"),children:e.label},e.value))}),(0,u.jsx)("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:0===Ce.maxIssuesToFix?"Fix all validation errors and warnings in one comprehensive pass.":"Fix up to ".concat(Ce.maxIssuesToFix," issues per iteration. Use lower values for more controlled, incremental fixes.")})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[(0,u.jsx)("input",{type:"checkbox",id:"refine-web-access",checked:te,onChange:e=>
2ne(e.target.checked),className:"h-4 w-4 rounded border-gray-300 text-[#FFB52B] focus:ring-[#FFB52B]"}),(0,u.jsx)("label",{htmlFor:"refine-web-access",className:"text-sm text-gray-700 dark:text-gray-300",children:"Enable web access for reference URL lookup"})]}),(0,u.jsxs)("div",{className:"flex items-start gap-2 p-3 rounded-lg border ".concat(Ce.blankSlate?"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800":"bg-gray-50 dark:bg-gray-700 border-gray-200 dark:border-gray-600"),children:[(0,u.jsx)("input",{type:"checkbox",id:"refine-blank-slate",checked:Ce.blankSlate,onChange:e=>Ne(t=>d(d({},t),{},{blankSlate:e.target.checked})),className:"w-4 h-4 mt-0.5 text-amber-600 border-gray-300 rounded focus:ring-amber-500"}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{htmlFor:"refine-blank-slate",className:"text-sm font-medium ".concat(Ce.blankSlate?"text-amber-800 dark:text-amber-200":"text-gray-700 dark:text-gray-300"),children:["Blank Slate Mode ",Ce.instructions.trim()&&Ce.blankSlate&&(0,u.jsx)("span",{className:"text-xs font-normal",children:"(auto-enabled)"})]}),(0,u.jsx)("p",{className:"text-xs mt-0.5 ".concat(Ce.blankSlate?"text-amber-700 dark:text-amber-300":"text-gray-500 dark:text-gray-400"),children:Ce.blankSlate?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("strong",{children:"Recommended when using custom instructions."})," The agent will follow only your instructions above instead of the generic refinement prompt. Without blank slate, the TTML may be returned unchanged if there are no validation errors."]}):"Skip the standard refinement prompt. Only your instructions will guide the refinement."})]})]}),Ce.blankSlate&&(0,u.jsxs)("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800",children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-amber-800 dark:text-amber-200 mb-2",children:"Topic Density (per hour)"}),(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("input",{type:"range",min:"5",max:"30",value:Ce.topicDensity,onChange:e=>Ne(t=>d(d({},t),{},{topicDensity:parseInt(e.target.value)})),className:"flex-1 h-2 bg-amber-200 dark:bg-amber-700 rounded-lg appearance-none cursor-pointer accent-amber-600"}),(0,u.jsx)("span",{className:"text-sm font-medium text-amber-800 dark:text-amber-200 w-8 text-center",children:Ce.topicDensity})]}),(0,u.jsxs)("div",{className:"flex justify-between text-xs text-amber-600 dark:text-amber-400 mt-1",children:[(0,u.jsx)("span",{children:"Sparse (5)"}),(0,u.jsx)("span",{children:"Medium (12)"}),(0,u.jsx)("span",{children:"Dense (18)"}),(0,u.jsx)("span",{children:"Very Dense (30)"})]}),(0,u.jsx)("p",{className:"mt-2 text-xs text-amber-600 dark:text-amber-400",children:Ce.topicDensity<=8?"Fewer, broader topic segments for high-level overviews.":Ce.topicDensity<=14?"Balanced topic segmentation for most content.":Ce.topicDensity<=22?"More detailed topic segments (default).":"Maximum granularity with many specific topic segments."})]})]}),(0,u.jsxs)("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-700",children:[(0,u.jsx)("button",{onClick:()=>Ne(e=>d(d({},e),{},{isOpen:!1})),className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Cancel"}),(0,u.jsxs)("button",{onClick:async()=>{if(!Ce.file||!m||!Ce.file.checksum)return;const{file:e,instructions:t,iterationCount:n,blankSlate:a,maxIssuesToFix:r,topicDensity:s}=Ce;Ne(e=>d(d({},e),{},{isOpen:!1})),F("");const i="Starting metadata follow-up agent".concat(a?" (blank slate)":"").concat(0===r?" (fix all issues)":" (fix up to ".concat(r," issues)")," (").concat(n," iteration").concat(n>1?"s":"",")...");A(i),De(t=>new Set(t).add(e.checksum));try{const i=await Gh({sessionId:m,sourceChecksum:e.checksum,model:Oe,additionalInstructions:t,enableWebAccess:te,iterationCount:n,blankSlate:a,maxIssuesToFix:r,topicDensity:s},b||void 0);if(!i.success)throw new Error("Agent session returned failure");{console.log("[REFINE-AGENT] Started refinement agent session: ".concat(i.agentSessionId)),et(i.agentSessionId,"follow-up"),at();const e="Metadata follow-up started via agent (".concat(n," iteration").concat(n>1?"s":"",")");A(e)}}catch(o){console.error("Failed to start TTML follow-up agent session:",o),F(o instanceof Error?o.message:"Failed to start TTML follow-up agent session"),De(t=>{const n=new Set(t);return n.delete(e.checksum),n})}},className:"flex items-center rounded-md bg-[#232E3F] px-4 py-2 text-[#F4F4F4] transition-colors hover:bg-[#2F3B4E]",children:[(0,u.jsx)(Fp,{className:"h-4 w-4 mr-2"}),"Start Follow-Up Session"]})]})]})]})})}),(0,u.jsx)(S,{children:Fe.isOpen&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>Se(e=>d(d({},e),{},{isOpen:!1})),children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md",onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsxs)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[(0,u.jsx)(hh,{className:"mr-2 h-5 w-5 text-[#B57700] dark:text-[#FFCF74]"}),"Generate Metadata With Agent"]}),(0,u.jsx)("button",{onClick:()=>Se(e=>d(d({},e),{},{isOpen:!1})),className:"p-2 text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]}),(0,u.jsxs)("div",{className:"p-4 space-y-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Agent Model"}),(0,u.jsx)("select",{value:Oe,onChange:e=>Ue(e.target.value),className:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-600 dark:bg-gray-700 dark:text-white",children:Re.map(e=>(0,u.jsx)("option",{value:e.id,children:e.name},e.id))}),(0,u.jsx)("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Uses the agent system directly and only finishes once the generated metadata revision validates cleanly."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Topic Density (per hour)"}),(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("input",{type:"range",min:"5",max:"30",value:Fe.topicDensity,onChange:e=>Se(t=>d(d({},t),{},{topicDensity:parseInt(e.target.value)})),className:"flex-1 h-2 cursor-pointer appearance-none rounded-lg bg-gray-200 accent-[#FFB52B] dark:bg-gray-600"}),(0,u.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 w-8 text-center",children:Fe.topicDensity})]}),(0,u.jsxs)("div",{className:"flex justify-between text-xs text-gray-500 dark:text-gray-400 mt-1",children:[(0,u.jsx)("span",{children:"Sparse (5)"}),(0,u.jsx)("span",{children:"Medium (12)"}),(0,u.jsx)("span",{children:"Dense (18)"}),(0,u.jsx)("span",{children:"Very Dense (30)"})]}),(0,u.jsx)("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:Fe.topicDensity<=8?"Fewer, broader topic segments for high-level overviews.":Fe.topicDensity<=14?"Balanced topic segmentation for most content.":Fe.topicDensity<=22?"More detailed topic segments (default).":"Maximum granularity with many specific topic segments."})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("input",{type:"checkbox",id:"generate-web-search",checked:Fe.enableWebSearch,onChange:e=>Se(t=>d(d({},t),{},{enableWebSearch:e.target.checked})),className:"h-4 w-4 rounded border-gray-300 text-[#FFB52B] focus:ring-[#FFB52B]"}),(0,u.jsx)("label",{htmlFor:"generate-web-search",className:"text-sm text-gray-700 dark:text-gray-300",children:"Verify references online during generation"})]}),(0,u.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 -mt-2 ml-6",children:"Enables the agent's `web_search` and `web_fetch` tools for reference sanity checking before final validation."}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("input",{type:"checkbox",id:"generate-include-edits",checked:Fe.includeEdits,onChange:e=>Se(t=>d(d({},t),{},{includeEdits:e.target.checked})),className:"h-4 w-4 rounded border-gray-300 text-[#FFB52B] focus:ring-[#FFB52B]"}),(0,u.jsx)("label",{htmlFor:"generate-include-edits",className:"text-sm text-gray-700 dark:text-gray-300",children:"Create edit suggestions track"})]}),(0,u.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 -mt-2 ml-6",children:w?"Disabled by default for published or YouTube-linked sessions. Keep public metadata to topics, clips, and references unless a human explicitly needs an edits pass.":"Turn this off for distribution-ready metadata where edit recommendations are no longer useful."}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Additional Instructions (Optional)"}),(0,u.jsx)("textarea",{value:Fe.additionalInstructions,onChange:e=>Se(t=>d(d({},t),{},{additionalInstructions:e.target.value})),placeholder:"Add context about the content, guest names, specific focus areas, or instructions like 'reuse the verified references from episode XYZ but keep current timings'...",className:"w-full resize-none rounded-md border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/30 dark:border-gray-600 dark:bg-gray-700 dark:text-white",rows:3}),(0,u.jsx)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"These instructions will be added to the generation prompt. The current agent is still write-scoped to this session, so cross-session reuse works best through explicit read-only lookup tools rather than direct mutation."})]}
2),(0,u.jsx)("div",{className:"rounded-lg border border-[#E7B14C]/45 bg-[#FFF8EA] p-3 text-xs text-[#8B5B00] dark:border-[#8E6E33] dark:bg-[#332A17] dark:text-[#FFE3A1]",children:"The agent will create a blank metadata revision, build it incrementally with structured mutation tools, validate after each major stage, and only finish once the final revision passes validation."}),(0,u.jsxs)("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-gray-200 dark:border-gray-700",children:[(0,u.jsx)("button",{onClick:()=>Se(e=>d(d({},e),{},{isOpen:!1})),className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Cancel"}),(0,u.jsxs)("button",{onClick:async()=>{Se(e=>d(d({},e),{},{isOpen:!1})),await(async e=>{const{topicDensity:t=18,enableWebSearch:n=!1,includeEdits:a=!w,additionalInstructions:r=""}=e||{};if(y&&!y.rankingTtmlAllowed)return void F("Metadata generation is not allowed for this share link");if(!m)return void F("Session ID is required for TTML generation");if(W.filter(e=>"pending"===e.status||"generating"===e.status||"refining"===e.status).length+rt>=4)F("Maximum ".concat(4," concurrent generations allowed"));else try{console.log("[TTML Agent] Starting validator-gated TTML generation...","Model:",Oe,"Topic density:",t,"Web verification:",n,"Include edits:",a,"Additional instructions:",r?"yes":"no");const e=await Kh({sessionId:m,model:Oe,topicDensity:t,enableWebAccess:n,includeEdits:a,additionalInstructions:r},b||void 0);if(!e.success)throw new Error("Failed to start metadata generation session");console.log("[TTML Agent] Generation session started:",e.agentSessionId),et(e.agentSessionId,"generation"),at(),A("Validator-gated metadata generation started via agent")}catch(s){console.error("[TTML Agent] Failed to start generation session:",s),F(s.message||"Failed to start metadata generation session")}})({topicDensity:Fe.topicDensity,enableWebSearch:Fe.enableWebSearch,includeEdits:Fe.includeEdits,additionalInstructions:Fe.additionalInstructions})},className:"flex items-center rounded-md bg-[#FFB52B] px-4 py-2 text-[#232E3F] transition-colors hover:bg-[#FFC54D]",children:[(0,u.jsx)(hh,{className:"h-4 w-4 mr-2"}),"Generate With Agent"]})]})]})]})})}),(0,u.jsx)(yy,{isDarkMode:"undefined"!==typeof document&&document.documentElement.classList.contains("dark"),isOpen:we,onClose:()=>ke(!1),title:"MLST ReScript MCP"})]})},wy=Mo("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]),ky=Mo("message-circle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]),jy=Mo("minimize",[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]),Dy=Mo("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]),Cy=Mo("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),Ny=Mo("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),Fy=Mo("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Sy=Mo("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),Ey=Mo("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7
2a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),Ay=Mo("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),Ty=Mo("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),My=Mo("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);function _y(e,t){const n=String(e);if("string"!==typeof t)throw new TypeError("Expected character");let a=0,r=n.indexOf(t);for(;-1!==r;)a++,r=n.indexOf(t,r+t.length);return a}function By(e,t,n){const a=hb((n||{}).ignore||[]),r=function(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let a=-1;for(;++a<n.length;){const e=n[a];t.push([Iy(e[0]),Py(e[1])])}return t}(t);let s=-1;for(;++s<r.length;)vb(e,"text",i);function i(e,t){let n,i=-1;for(;++i<t.length;){const e=t[i],r=n?n.children:void 0;if(a(e,r?r.indexOf(e):void 0,n))return;n=e}if(n)return function(e,t){const n=t[t.length-1],a=r[s][0],i=r[s][1];let o=0;const l=n.children.indexOf(e);let c=!1,d=[];a.lastIndex=0;let u=a.exec(e.value);for(;u;){const n=u.index,r={index:u.index,input:u.input,stack:[...t,e]};let s=i(...u,r);if("string"===typeof s&&(s=s.length>0?{type:"text",value:s}:void 0),!1===s?a.lastIndex=n+1:(o!==n&&d.push({type:"text",value:e.value.slice(o,n)}),Array.isArray(s)?d.push(...s):s&&d.push(s),o=n+u[0].length,c=!0),!a.global)break;u=a.exec(e.value)}c?(o<e.value.length&&d.push({type:"text",value:e.value.slice(o)}),n.children.splice(l,1,...d)):d=[e];return l+d.length}(e,t)}}function Iy(e){return"string"===typeof e?new RegExp(function(e){if("string"!==typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e),"g"):e}function Py(e){return"function"===typeof e?e:function(){return e}}const Ly="phrasing",Ry=["autolink","link","image","label"];function zy(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Oy(e){this.config.enter.autolinkProtocol.call(this,e)}function Uy(e){this.config.exit.autolinkProtocol.call(this,e)}function Vy(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function Hy(e){this.config.exit.autolinkEmail.call(this,e)}function qy(e){this.exit(e)}function Wy(e){By(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Yy],[/(?<=^|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]|(?:[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F])|(?:[\$\+<->
2\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDD00-\uDEB3\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF]))([\+\x2D\.0-9A-Z_a-z]+)@([\x2D0-9A-Z_a-z]+(?:\.[\x2D0-9A-Z_a-z]+)+)/g,Gy]],{ignore:["link","linkReference"]})}function Yy(e,t,n,a,r){let s="";if(!Ky(r))return!1;if(/^w/i.test(t)&&(n=t+n,t="",s="http://"),!function(e){const t=e.split(".");if(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))return!1;return!0}(n))return!1;const i=function(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],a=n.indexOf(")");const r=_y(e,"(");let s=_y(e,")");for(;-1!==a&&r>s;)e+=n.slice(0,a+1),n=n.slice(a+1),a=n.indexOf(")"),s++;return[e,n]}(n+a);if(!i[0])return!1;const o={type:"link",title:null,url:s+t+i[0],children:[{type:"text",value:t+i[0]}]};return i[1]?[o,{type:"text",value:i[1]}]:o}function Gy(e,t,n,a){return!(!Ky(a,!0)||/[-\d_]$/.test(n))&&{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function Ky(e,t){const n=e.input.charCodeAt(e.index-1);return(0===e.index||Ex(n)||Sx(n))&&(!t||47!==n)}function Xy(){this.buffer()}function Jy(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function $y(){this.buffer()}function Qy(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Zy(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ef(this.sliceSerialize(e)).toLowerCase(),n.label=t}function ev(e){this.exit(e)}function tv(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=ef(this.sliceSerialize(e)).toLowerCase(),n.label=t}function nv(e){this.exit(e)}function av(e,t,n,a){const r=n.createTracker(a);let s=r.move("[^");const i=n.enter("footnoteReference"),o=n.enter("reference");return s+=r.move(n.safe(n.associationId(e),{after:"]",before:s})),o(),i(),s+=r.move("]"),s}function rv(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:function(e,n,a,r){const s=a.createTracker(r);let i=s.move("[^");const o=a.enter("footnoteDefinition"),l=a.enter("label");i+=s.move(a.safe(a.associationId(e),{before:i,after:"]"})),l(),i+=s.move("]:"),e.children&&e.children.length>0&&(s.shift(4),i+=s.move((t?"\n":" ")+a.indentLines(a.containerFlow(e,s.current()),t?iv:sv)));return o(),i},footnoteReference:av},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]}}function sv(e,t,n){return 0===t?e:iv(e,t,n)}function iv(e,t,n){return(n?"":" ")+e}av.peek=function(){return"["};const ov=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];function lv(e){this.enter({type:"delete",children:[]},e)}function cv(e){this.exit(e)}function dv(e,t,n,a){const r=n.createTracker(a),s=n.enter("strikethrough");let i=r.move("~~");return i+=n.containerPhrasing(e,d(d({},r.current()),{},{before:i,after:"~"})),i+=r.move("~~"),s(),i}function uv(e){return e.length}function mv(e){return null===e||void 0===e?"":String(e)}function hv(e){const t="string"===typeof e?e.codePointAt(0):0;return 67===t||99===t?99:76===t||108===t?108:82===t||114===t?114:0}function pv(e,t,n){return">"+(n?"":" ")+e}
vendor: 6,971 bytes, line 2
2function gv(e,t){return xv(e,t.inConstruct,!0)&&!xv(e,t.notInConstruct,!1)}function xv(e,t,n){if("string"===typeof t&&(t=[t]),!t||0===t.length)return n;let a=-1;for(;++a<t.length;)if(e.includes(t[a]))return!0;return!1}function fv(e,t,n,a){let r=-1;for(;++r<n.unsafe.length;)if("\n"===n.unsafe[r].character&&gv(n.stack,n.unsafe[r]))return/[ \t]/.test(a.before)?"":" ";return"\\\n"}function bv(e,t,n){return(n?"":" ")+e}function yv(e){const t=e.options.quote||'"';if('"'!==t&&"'"!==t)throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function vv(e){return"&#x"+e.toString(16).toUpperCase()+";"}function wv(e,t,n){const a=Nf(e),r=Nf(t);return void 0===a?void 0===r?"_"===n?{inside:!0,outside:!0}:{inside:!1,outside:!1}:1===r?{inside:!0,outside:!0}:{inside:!1,outside:!0}:1===a?void 0===r?{inside:!1,outside:!1}:1===r?{inside:!0,outside:!0}:{inside:!1,outside:!1}:void 0===r?{inside:!1,outside:!1}:1===r?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function kv(e,t,n,a){const r=function(e){const t=e.options.emphasis||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}(n),s=n.enter("emphasis"),i=n.createTracker(a),o=i.move(r);let l=i.move(n.containerPhrasing(e,d({after:r,before:o},i.current())));const c=l.charCodeAt(0),u=wv(a.before.charCodeAt(a.before.length-1),c,r);u.inside&&(l=vv(c)+l.slice(1));const m=l.charCodeAt(l.length-1),h=wv(a.after.charCodeAt(0),m,r);h.inside&&(l=l.slice(0,-1)+vv(m));const p=i.move(r);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},o+l+p}function jv(e){return e.value||""}function Dv(e,t,n,a){const r=yv(n),s='"'===r?"Quote":"Apostrophe",i=n.enter("image");let o=n.enter("label");const l=n.createTracker(a);let c=l.move("![");return c+=l.move(n.safe(e.alt,d({before:c,after:"]"},l.current()))),c+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,d({before:c,after:">"},l.current()))),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,d({before:c,after:e.title?" ":")"},l.current())))),o(),e.title&&(o=n.enter("title".concat(s)),c+=l.move(" "+r),c+=l.move(n.safe(e.title,d({before:c,after:r},l.current()))),c+=l.move(r),o()),c+=l.move(")"),i(),c}function Cv(e,t,n,a){const r=e.referenceType,s=n.enter("imageReference");let i=n.enter("label");const o=n.createTracker(a);let l=o.move("![");const c=n.safe(e.alt,d({before:l,after:"]"},o.current()));l+=o.move(c+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(e),d({before:l,after:"]"},o.current()));return i(),n.stack=u,s(),"full"!==r&&c&&c===m?"shortcut"===r?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(m+"]"),l}function Nv(e,t,n){let a=e.value||"",r="`",s=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(a);)r+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++s<n.unsafe.length;){const e=n.unsafe[s],t=n.compilePattern(e);let r;if(e.atBreak)for(;r=t.exec(a);){let e=r.index;10===a.charCodeAt(e)&&13===a.charCodeAt(e-1)&&e--,a=a.slice(0,e)+" "+a.slice(r.index+1)}}return r+a+r}function Fv(e,t){const n=sx(e);return Boolean(!t.options.resourceLink&&e.url&&!e.title&&e.children&&1===e.children.length&&"text"===e.children[0].type&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}function Sv(e,t,n,a){const r=yv(n),s='"'===r?"Quote":"Apostrophe",i=n.createTracker(a);let o,l;if(Fv(e,n)){const t=n.stack;n.stack=[],o=n.enter("autolink");let a=i.move("<");return a+=i.move(n.containerPhrasing(e,d({before:a,after:">"},i.current()))),a+=i.move(">"),o(),n.stack=t,a}o=n.enter("link"),l=n.enter("label");let c=i.move("[");return c+=i.move(n.containerPhrasing(e,d({before:c,after:"]("},i.current()))),c+=i.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),c+=i.move("<"),c+=i.move(n.safe(e.url,d({before:c,after:">"},i.current()))),c+=i.move(">")):(l=n.enter("destinationRaw"),c+=i.move(n.safe(e.url,d({before:c,after:e.title?" ":")"},i.current())))),l(),e.title&&(l=n.enter("title".concat(s)),c+=i.move(" "+r),c+=i.move(n.safe(e.title,d({before:c,after:r},i.current()))),c+=i.move(r),l()),c+=i.move(")"),o(),c}function Ev(e,t,n,a){const r=e.referenceType,s=n.enter("linkReference");let i=n.enter("label");const o=n.createTracker(a);let l=o.move("[");const c=n.containerPhrasing(e,d({before:l,after:"]"},o.current()));l+=o.move(c+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const m=n.safe(n.associationId(e),d({before:l,after:"]"},o.current()));return i(),n.stack=u,s(),"full"!==r&&c&&c===m?"shortcut"===r?l=l.slice(0,-1):l+=o.move("]"):l+=o.move(m+"]"),l}function Av(e){const t=e.options.bullet||"*";if("*"!==t&&"+"!==t&&"-"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Tv(e){const t=e.options.rule||"*";if("*"!==t&&"-"!==t&&"_"!==t)throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}dv.peek=function(){return"~"},kv.peek=function(e,t,n){return n.options.emphasis||"*"},jv.peek=function(){return"<"},Dv.peek=function(){return"!"},Cv.peek=function(){return"!"},Nv.peek=function(){return"`"},Sv.peek=function(e,t,n){return Fv(e,n)?"<":"["},Ev.peek=function(){return"["};const Mv=hb(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function _v(e,t,n,a){const r=function(e){const t=e.options.strong||"*";if("*"!==t&&"_"!==t)throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}(n),s=n.enter("strong"),i=n.createTracker(a),o=i.move(r+r);let l=i.move(n.containerPhrasing(e,d({after:r,before:o},i.current())));const c=l.charCodeAt(0),u=wv(a.before.charCodeAt(a.before.length-1),c,r);u.inside&&(l=vv(c)+l.slice(1));const m=l.charCodeAt(l.length-1),h=wv(a.after.charCodeAt(0),m,r);h.inside&&(l=l.slice(0,-1)+vv(m));const p=i.move(r+r);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},o+l+p}_v.peek=function(e,t,n){return n.options.strong||"*"};const Bv={blockquote:function(e,t,n,a){const r=n.enter("blockquote"),s=n.createTracker(a);s.move("> "),s.shift(2);const i=n.indentLines(n.containerFlow(e,s.current()),pv);return r(),i},break:fv,code:function(e,t,n,a){const r=function(e){const t=e.options.fence||"`";if("`"!==t&&"~"!==t)throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}(n),s=e.value||"",i="`"===r?"GraveAccent":"Tilde";if(function(e,t){return Boolean(!1===t.options.fences&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}
vendor: 6,746 bytes, line 2
2(e,n)){const e=n.enter("codeIndented"),t=n.indentLines(s,bv);return e(),t}const o=n.createTracker(a),l=r.repeat(Math.max(function(e,t){const n=String(e);let a=n.indexOf(t),r=a,s=0,i=0;if("string"!==typeof t)throw new TypeError("Expected substring");for(;-1!==a;)a===r?++s>i&&(i=s):s=1,r=a+t.length,a=n.indexOf(t,r);return i}(s,r)+1,3)),c=n.enter("codeFenced");let u=o.move(l);if(e.lang){const t=n.enter("codeFencedLang".concat(i));u+=o.move(n.safe(e.lang,d({before:u,after:" ",encode:["`"]},o.current()))),t()}if(e.lang&&e.meta){const t=n.enter("codeFencedMeta".concat(i));u+=o.move(" "),u+=o.move(n.safe(e.meta,d({before:u,after:"\n",encode:["`"]},o.current()))),t()}return u+=o.move("\n"),s&&(u+=o.move(s+"\n")),u+=o.move(l),c(),u},definition:function(e,t,n,a){const r=yv(n),s='"'===r?"Quote":"Apostrophe",i=n.enter("definition");let o=n.enter("label");const l=n.createTracker(a);let c=l.move("[");return c+=l.move(n.safe(n.associationId(e),d({before:c,after:"]"},l.current()))),c+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(e.url,d({before:c,after:">"},l.current()))),c+=l.move(">")):(o=n.enter("destinationRaw"),c+=l.move(n.safe(e.url,d({before:c,after:e.title?" ":"\n"},l.current())))),o(),e.title&&(o=n.enter("title".concat(s)),c+=l.move(" "+r),c+=l.move(n.safe(e.title,d({before:c,after:r},l.current()))),c+=l.move(r),o()),i(),c},emphasis:kv,hardBreak:fv,heading:function(e,t,n,a){const r=Math.max(Math.min(6,e.depth||1),1),s=n.createTracker(a);if(function(e,t){let n=!1;return wb(e,function(e){if("value"in e&&/\r?\n|\r/.test(e.value)||"break"===e.type)return n=!0,yb}),Boolean((!e.depth||e.depth<3)&&sx(e)&&(t.options.setext||n))}(e,n)){const t=n.enter("headingSetext"),a=n.enter("phrasing"),i=n.containerPhrasing(e,d(d({},s.current()),{},{before:"\n",after:"\n"}));return a(),t(),i+"\n"+(1===r?"=":"-").repeat(i.length-(Math.max(i.lastIndexOf("\r"),i.lastIndexOf("\n"))+1))}const i="#".repeat(r),o=n.enter("headingAtx"),l=n.enter("phrasing");s.move(i+" ");let c=n.containerPhrasing(e,d({before:"# ",after:"\n"},s.current()));return/^[\t ]/.test(c)&&(c=vv(c.charCodeAt(0))+c.slice(1)),c=c?i+" "+c:i,n.options.closeAtx&&(c+=" "+i),l(),o(),c},html:jv,image:Dv,imageReference:Cv,inlineCode:Nv,link:Sv,linkReference:Ev,list:function(e,t,n,a){const r=n.enter("list"),s=n.bulletCurrent;let i=e.ordered?function(e){const t=e.options.bulletOrdered||".";if("."!==t&&")"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}(n):Av(n);const o=e.ordered?"."===i?")":".":function(e){const t=Av(e),n=e.options.bulletOther;if(!n)return"*"===t?"-":"*";if("*"!==n&&"+"!==n&&"-"!==n)throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}(n);let l=!(!t||!n.bulletLastUsed)&&i===n.bulletLastUsed;if(!e.ordered){const t=e.children?e.children[0]:void 0;if("*"!==i&&"-"!==i||!t||t.children&&t.children[0]||"list"!==n.stack[n.stack.length-1]||"listItem"!==n.stack[n.stack.length-2]||"list"!==n.stack[n.stack.length-3]||"listItem"!==n.stack[n.stack.length-4]||0!==n.indexStack[n.indexStack.length-1]||0!==n.indexStack[n.indexStack.length-2]||0!==n.indexStack[n.indexStack.length-3]||(l=!0),Tv(n)===i&&t){let t=-1;for(;++t<e.children.length;){const n=e.children[t];if(n&&"listItem"===n.type&&n.children&&n.children[0]&&"thematicBreak"===n.children[0].type){l=!0;break}}}}l&&(i=o),n.bulletCurrent=i;const c=n.containerFlow(e,a);return n.bulletLastUsed=i,n.bulletCurrent=s,r(),c},listItem:function(e,t,n,a){const r=function(e){const t=e.options.listItemIndent||"one";if("tab"!==t&&"one"!==t&&"mixed"!==t)throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}(n);let s=n.bulletCurrent||Av(n);t&&"list"===t.type&&t.ordered&&(s=("number"===typeof t.start&&t.start>-1?t.start:1)+(!1===n.options.incrementListMarker?0:t.children.indexOf(e))+s);let i=s.length+1;("tab"===r||"mixed"===r&&(t&&"list"===t.type&&t.spread||e.spread))&&(i=4*Math.ceil(i/4));const o=n.createTracker(a);o.move(s+" ".repeat(i-s.length)),o.shift(i);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(e,o.current()),function(e,t,n){if(t)return(n?"":" ".repeat(i))+e;return(n?s:s+" ".repeat(i-s.length))+e});return l(),c},paragraph:function(e,t,n,a){const r=n.enter("paragraph"),s=n.enter("phrasing"),i=n.containerPhrasing(e,a);return s(),r(),i},root:function(e,t,n,a){return(e.children.some(function(e){return Mv(e)})?n.containerPhrasing:n.containerFlow).call(n,e,a)},strong:_v,text:function(e,t,n,a){return n.safe(e.value,a)},thematicBreak:function(e,t,n){const a=(Tv(n)+(n.options.ruleSpaces?" ":"")).repeat(function(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}(n));return n.options.ruleSpaces?a.slice(0,-1):a}};function Iv(e){const t=e._align;this.enter({type:"table",align:t.map(function(e){return"none"===e?null:e}),children:[]},e),this.data.inTable=!0}function Pv(e){this.exit(e),this.data.inTable=void 0}function Lv(e){this.enter({type:"tableRow",children:[]},e)}function Rv(e){this.exit(e)}function zv(e){this.enter({type:"tableCell",children:[]},e)}function Ov(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Uv));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Uv(e,t){return"|"===t?t:e}function Vv(e){const t=e||{},n=t.tableCellPadding,a=t.tablePipeAlign,r=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:"\n",inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[\t :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:function(e,t,n){let a=Bv.inlineCode(e,t,n);n.stack.includes("tableCell")&&(a=a.replace(/\|/g,"\\$&"));return a},table:function(e,t,n,a){return o(function(e,t,n){const a=e.children;let r=-1;const s=[],i=t.enter("table");for(;++r<a.length;)s[r]=l(a[r],t,n);return i(),s}(e,n,a),e.align)},tableCell:i,tableRow:function(e,t,n,a){const r=l(e,n,a),s=o([r]);return s.slice(0,s.indexOf("\n"))}}};function i(e,t,n,a){const r=n.enter("tableCell"),i=n.enter("phrasing"),o=n.containerPhrasing(e,d(d({},a),{},{before:s,after:s}));return i(),r(),o}function o(e,t){return function(e,t){const n=t||{},a=(n.align||[]).concat(),r=n.stringLength||uv,s=[],i=[],o=[],l=[];let c=0,d=-1;for(;++d<e.length;){const t=[],a=[];let s=-1;for(e[d].length>c&&(c=e[d].length);++s<e[d].length;
vendor: 8,653 bytes, line 2
2){const i=mv(e[d][s]);if(!1!==n.alignDelimiters){const e=r(i);a[s]=e,(void 0===l[s]||e>l[s])&&(l[s]=e)}t.push(i)}i[d]=t,o[d]=a}let u=-1;if("object"===typeof a&&"length"in a)for(;++u<c;)s[u]=hv(a[u]);else{const e=hv(a);for(;++u<c;)s[u]=e}u=-1;const m=[],h=[];for(;++u<c;){const e=s[u];let t="",a="";99===e?(t=":",a=":"):108===e?t=":":114===e&&(a=":");let r=!1===n.alignDelimiters?1:Math.max(1,l[u]-t.length-a.length);const i=t+"-".repeat(r)+a;!1!==n.alignDelimiters&&(r=t.length+r+a.length,r>l[u]&&(l[u]=r),h[u]=r),m[u]=i}i.splice(1,0,m),o.splice(1,0,h),d=-1;const p=[];for(;++d<i.length;){const e=i[d],t=o[d];u=-1;const a=[];for(;++u<c;){const r=e[u]||"";let i="",o="";if(!1!==n.alignDelimiters){const e=l[u]-(t[u]||0),n=s[u];114===n?i=" ".repeat(e):99===n?e%2?(i=" ".repeat(e/2+.5),o=" ".repeat(e/2-.5)):(i=" ".repeat(e/2),o=i):o=" ".repeat(e)}!1===n.delimiterStart||u||a.push("|"),!1===n.padding||!1===n.alignDelimiters&&""===r||!1===n.delimiterStart&&!u||a.push(" "),!1!==n.alignDelimiters&&a.push(i),a.push(r),!1!==n.alignDelimiters&&a.push(o),!1!==n.padding&&a.push(" "),!1===n.delimiterEnd&&u===c-1||a.push("|")}p.push(!1===n.delimiterEnd?a.join("").replace(/ +$/,""):a.join(""))}return p.join("\n")}(e,{align:t,alignDelimiters:a,padding:n,stringLength:r})}function l(e,t,n){const a=e.children;let r=-1;const s=[],o=t.enter("tableRow");for(;++r<a.length;)s[r]=i(a[r],0,t,n);return o(),s}}function Hv(e){const t=this.stack[this.stack.length-2];t.type,t.checked="taskListCheckValueChecked"===e.type}function qv(e){const t=this.stack[this.stack.length-2];if(t&&"listItem"===t.type&&"boolean"===typeof t.checked){const e=this.stack[this.stack.length-1];e.type;const n=e.children[0];if(n&&"text"===n.type){const a=t.children;let r,s=-1;for(;++s<a.length;){const e=a[s];if("paragraph"===e.type){r=e;break}}r===e&&(n.value=n.value.slice(1),0===n.value.length?e.children.shift():e.position&&n.position&&"number"===typeof n.position.start.offset&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Wv(e,t,n,a){const r=e.children[0],s="boolean"===typeof e.checked&&r&&"paragraph"===r.type,i="["+(e.checked?"x":" ")+"] ",o=n.createTracker(a);s&&o.move(i);let l=Bv.listItem(e,t,n,d(d({},a),o.current()));return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,function(e){return e+i})),l}const Yv={tokenize:function(e,t,n){let a=0;return function t(s){if((87===s||119===s)&&a<3)return a++,e.consume(s),t;if(46===s&&3===a)return e.consume(s),r;return n(s)};function r(e){return null===e?n(e):t(e)}},partial:!0},Gv={tokenize:function(e,t,n){let a,r,s;return i;function i(t){return 46===t||95===t?e.check(Xv,l,o)(t):null===t||Nx(t)||Ex(t)||45!==t&&Sx(t)?l(t):(s=!0,e.consume(t),i)}function o(t){return 95===t?a=!0:(r=a,a=void 0),e.consume(t),i}function l(e){return r||a||!s?n(e):t(e)}},partial:!0},Kv={tokenize:function(e,t){let n=0,a=0;return r;function r(i){return 40===i?(n++,e.consume(i),r):41===i&&a<n?s(i):33===i||34===i||38===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||60===i||63===i||93===i||95===i||126===i?e.check(Xv,t,s)(i):null===i||Nx(i)||Ex(i)?t(i):(e.consume(i),r)}function s(t){return 41===t&&a++,e.consume(t),r}},partial:!0},Xv={tokenize:function(e,t,n){return a;function a(i){return 33===i||34===i||39===i||41===i||42===i||44===i||46===i||58===i||59===i||63===i||95===i||126===i?(e.consume(i),a):38===i?(e.consume(i),s):93===i?(e.consume(i),r):60===i||null===i||Nx(i)||Ex(i)?t(i):n(i)}function r(e){return null===e||40===e||91===e||Nx(e)||Ex(e)?t(e):a(e)}function s(e){return bx(e)?i(e):n(e)}function i(t){return 59===t?(e.consume(t),a):bx(t)?(e.consume(t),i):n(t)}},partial:!0},Jv={tokenize:function(e,t,n){return function(t){return e.consume(t),a};function a(e){return yx(e)?n(e):t(e)}},partial:!0},$v={name:"wwwAutolink",tokenize:function(e,t,n){const a=this;return function(t){if(87!==t&&119!==t||!nw.call(a,a.previous)||iw(a.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Yv,e.attempt(Gv,e.attempt(Kv,r),n),n)(t)};function r(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(n)}},previous:nw},Qv={name:"protocolAutolink",tokenize:function(e,t,n){const a=this;let r="",s=!1;return function(t){if((72===t||104===t)&&aw.call(a,a.previous)&&!iw(a.events))return e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(t),e.consume(t),i;return n(t)};function i(t){if(bx(t)&&r.length<5)return r+=String.fromCodePoint(t),e.consume(t),i;if(58===t){const n=r.toLowerCase();if("http"===n||"https"===n)return e.consume(t),o}return n(t)}function o(t){return 47===t?(e.consume(t),s?l:(s=!0,o)):n(t)}function l(t){return null===t||wx(t)||Nx(t)||Ex(t)||Sx(t)?n(t):e.attempt(Gv,e.attempt(Kv,c),n)(t)}function c(n){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(n)}},previous:aw},Zv={name:"emailAutolink",tokenize:function(e,t,n){const a=this;let r,s;return function(t){if(!sw(t)||!rw.call(a,a.previous)||iw(a.events))return n(t);return e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(t)};function i(t){return sw(t)?(e.consume(t),i):64===t?(e.consume(t),o):n(t)}function o(t){return 46===t?e.check(Jv,c,l)(t):45===t||95===t||yx(t)?(s=!0,e.consume(t),o):c(t)}function l(t){return e.consume(t),r=!0,o}function c(i){return s&&r&&bx(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(i)):n(i)}},previous:rw},ew={};let tw=48;for(;tw<123;)ew[tw]=Zv,tw++,58===tw?tw=65:91===tw&&(tw=97);function nw(e){return null===e||40===e||42===e||95===e||91===e||93===e||126===e||Nx(e)}function aw(e){return!bx(e)}function rw(e){return!(47===e||sw(e))}function sw(e){return 43===e||45===e||46===e||95===e||yx(e)}function iw(e){let t=e.length,n=!1;for(;t--;){const a=e[t][1];if(("labelLink"===a.type||"labelImage"===a.type)&&!a._balanced){n=!0;break}if(a._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}ew[43]=Zv,ew[45]=Zv,ew[46]=Zv,ew[95]=Zv,ew[72]=[Zv,Qv],ew[104]=[Zv,Qv],ew[87]=[Zv,$v],ew[119]=[Zv,$v];const ow={tokenize:function(e,t,n){const a=this;return Tx(e,function(e){const r=a.events[a.events.length-1];return r&&"gfmFootnoteDefinitionIndent"===r[1].type&&4===r[2].sliceSerialize(r[1],!0).length?t(e):n(e)},"gfmFootnoteDefinitionIndent",5)},partial:!0};function lw(e,t,n){const a=this;let r=a.events.length;const s=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let i;for(;r--;){const e=a.events[r][1];if("labelImage"===e.type){i=e;break}if("gfmFootnoteCall"===e.type||"labelLink"===e.type||"label"===e.type||"image"===e.type||"link"===e.type)break}return function(r){if(!i||!i._balanced)return n(r);const o=ef(a.sliceSerialize({start:i.end,end:a.now()}));if(94!==o.codePointAt(0)||!s.includes(o.slice(1)))return n(r);return e.enter("gfmFootnoteCallLabelMarker"),e.consume(r),e.exit("gfmFootnoteCallLabelMarker"),t(r)}}function cw(e,t){let n,a=e.length;for(;a--;)if("labelImage"===e[a][1].type&&"enter"===e[a][0]){n=e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},l=[e[a+1],e[a+2],["enter",r,t],e[a+3],e[a+4],["enter",s,t],["exit",s,t],["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(a,e.length-a+1,...l),e}function dw(e,t,n){const a=this,r=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let s,i=0;return function(t){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(t),e.exit("gfmFootnoteCallLabelMarker"),o};function o(t){return 94!==t?n(t):(e.enter("gfmFootnoteCallMarker"),e.consume(t),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(o){if(i>999||93===o&&!s||null===o||91===o||Nx(o))return n(o);if(93===o){e.exit("chunkString");const s=e.exit("gfmFootnoteCallString");return r.includes(ef(a.sliceSerialize(s)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(o),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(o)}return Nx(o)||(s=!0),i++,e.consume(o),92===o?c:l}function c(t){return 91===t||92===t||93===t?(e.consume(t),i++,l):l(t)}}
vendor: 1,169 bytes, line 2
2function uw(e,t,n){const a=this,r=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let s,i,o=0;return function(t){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),l};function l(t){return 94===t?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(t)}function c(t){if(o>999||93===t&&!i||null===t||91===t||Nx(t))return n(t);if(93===t){e.exit("chunkString");const n=e.exit("gfmFootnoteDefinitionLabelString");return s=ef(a.sliceSerialize(n)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(t),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),u}return Nx(t)||(i=!0),o++,e.consume(t),92===t?d:c}function d(t){return 91===t||92===t||93===t?(e.consume(t),o++,c):c(t)}function u(t){return 58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),r.includes(s)||r.push(s),Tx(e,m,"gfmFootnoteDefinitionWhitespace")):n(t)}function m(e){return t(e)}}
vendor: 4,496 bytes, line 2
2function mw(e,t,n){return e.check(Ix,t,e.attempt(ow,t,n))}function hw(e){e.exit("gfmFootnoteDefinition")}function pw(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:function(e,n,a){const r=this.previous,s=this.events;let i=0;return function(t){if(126===r&&"characterEscape"!==s[s.length-1][1].type)return a(t);return e.enter("strikethroughSequenceTemporary"),o(t)};function o(s){const l=Nf(r);if(126===s)return i>1?a(s):(e.consume(s),i++,o);if(i<2&&!t)return a(s);const c=e.exit("strikethroughSequenceTemporary"),d=Nf(s);return c._open=!d||2===d&&Boolean(l),c._close=!l||2===l&&Boolean(d),n(s)}},resolveAll:function(e,t){let n=-1;for(;++n<e.length;)if("enter"===e[n][0]&&"strikethroughSequenceTemporary"===e[n][1].type&&e[n][1]._close){let a=n;for(;a--;)if("exit"===e[a][0]&&"strikethroughSequenceTemporary"===e[a][1].type&&e[a][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[a][1].end.offset-e[a][1].start.offset){e[n][1].type="strikethroughSequence",e[a][1].type="strikethroughSequence";const r={type:"strikethrough",start:Object.assign({},e[a][1].start),end:Object.assign({},e[n][1].end)},s={type:"strikethroughText",start:Object.assign({},e[a][1].end),end:Object.assign({},e[n][1].start)},i=[["enter",r,t],["enter",e[a][1],t],["exit",e[a][1],t],["enter",s,t]],o=t.parser.constructs.insideSpan.null;o&&lx(i,i.length,0,vf(o,e.slice(a+1,n),t)),lx(i,i.length,0,[["exit",s,t],["enter",e[n][1],t],["exit",e[n][1],t],["exit",r,t]]),lx(e,a-1,n-a+3,i),n=a+i.length-2;break}}n=-1;for(;++n<e.length;)"strikethroughSequenceTemporary"===e[n][1].type&&(e[n][1].type="data");return e}};return null!==t&&void 0!==t||(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}}}class gw{constructor(){this.map=[]}add(e,t,n){!function(e,t,n,a){let r=0;if(0===n&&0===a.length)return;for(;r<e.map.length;){if(e.map[r][0]===t)return e.map[r][1]+=n,void e.map[r][2].push(...a);r+=1}e.map.push([t,n,a])}(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),0===this.map.length)return;let t=this.map.length;const n=[];for(;t>0;)t-=1,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let a=n.pop();for(;a;){for(const t of a)e.push(t);a=n.pop()}this.map.length=0}}function xw(e,t){let n=!1;const a=[];for(;t<e.length;){const r=e[t];if(n){if("enter"===r[0])"tableContent"===r[1].type&&a.push("tableDelimiterMarker"===e[t+1][1].type?"left":"none");else if("tableContent"===r[1].type){if("tableDelimiterMarker"===e[t-1][1].type){const e=a.length-1;a[e]="left"===a[e]?"center":"right"}}else if("tableDelimiterRow"===r[1].type)break}else"enter"===r[0]&&"tableDelimiterRow"===r[1].type&&(n=!0);t+=1}return a}function fw(e,t,n){const a=this;let r,s=0,i=0;return function(e){let t=a.events.length-1;for(;t>-1;){const e=a.events[t][1].type;if("lineEnding"!==e&&"linePrefix"!==e)break;t--}const r=t>-1?a.events[t][1].type:null,s="tableHead"===r||"tableRow"===r?v:o;if(s===v&&a.parser.lazy[a.now().line])return n(e);return s(e)};function o(t){return e.enter("tableHead"),e.enter("tableRow"),function(e){if(124===e)return l(e);return r=!0,i+=1,l(e)}(t)}function l(t){return null===t?n(t):Cx(t)?i>1?(i=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),u):n(t):Fx(t)?Tx(e,l,"whitespace")(t):(i+=1,r&&(r=!1,s+=1),124===t?(e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),r=!0,l):(e.enter("data"),c(t)))}function c(t){return null===t||124===t||Nx(t)?(e.exit("data"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return 92===t||124===t?(e.consume(t),c):c(t)}function u(t){return a.interrupt=!1,a.parser.lazy[a.now().line]?n(t):(e.enter("tableDelimiterRow"),r=!1,Fx(t)?Tx(e,m,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):m(t))}function m(t){return 45===t||58===t?p(t):124===t?(r=!0,e.enter("tableCellDivider"),e.consume(t),e.exit("tableCellDivider"),h):y(t)}function h(t){return Fx(t)?Tx(e,p,"whitespace")(t):p(t)}function p(t){return 58===t?(i+=1,r=!0,e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),g):45===t?(i+=1,g(t)):null===t||Cx(t)?b(t):y(t)}function g(t){return 45===t?(e.enter("tableDelimiterFiller"),x(t)):y(t)}function x(t){return 45===t?(e.consume(t),x):58===t?(r=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(t),e.exit("tableDelimiterMarker"),f):(e.exit("tableDelimiterFiller"),f(t))}function f(t){return Fx(t)?Tx(e,b,"whitespace")(t):b(t)}
vendor: 4,383 bytes, line 2
2function b(n){return 124===n?m(n):(null===n||Cx(n))&&r&&s===i?(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(n)):y(n)}function y(e){return n(e)}function v(t){return e.enter("tableRow"),w(t)}function w(n){return 124===n?(e.enter("tableCellDivider"),e.consume(n),e.exit("tableCellDivider"),w):null===n||Cx(n)?(e.exit("tableRow"),t(n)):Fx(n)?Tx(e,w,"whitespace")(n):(e.enter("data"),k(n))}function k(t){return null===t||124===t||Nx(t)?(e.exit("data"),w(t)):(e.consume(t),92===t?j:k)}function j(t){return 92===t||124===t?(e.consume(t),k):k(t)}}function bw(e,t){let n,a,r,s=-1,i=!0,o=0,l=[0,0,0,0],c=[0,0,0,0],d=!1,u=0;const m=new gw;for(;++s<e.length;){const h=e[s],p=h[1];"enter"===h[0]?"tableHead"===p.type?(d=!1,0!==u&&(vw(m,t,u,n,a),a=void 0,u=0),n={type:"table",start:Object.assign({},p.start),end:Object.assign({},p.end)},m.add(s,0,[["enter",n,t]])):"tableRow"===p.type||"tableDelimiterRow"===p.type?(i=!0,r=void 0,l=[0,0,0,0],c=[0,s+1,0,0],d&&(d=!1,a={type:"tableBody",start:Object.assign({},p.start),end:Object.assign({},p.end)},m.add(s,0,[["enter",a,t]])),o="tableDelimiterRow"===p.type?2:a?3:1):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type?"tableCellDivider"===p.type&&(i?i=!1:(0!==l[1]&&(c[0]=c[1],r=yw(m,t,l,o,void 0,r)),l=c,c=[l[1],s,0,0])):(i=!1,0===c[2]&&(0!==l[1]&&(c[0]=c[1],r=yw(m,t,l,o,void 0,r),l=[0,0,0,0]),c[2]=s)):"tableHead"===p.type?(d=!0,u=s):"tableRow"===p.type||"tableDelimiterRow"===p.type?(u=s,0!==l[1]?(c[0]=c[1],r=yw(m,t,l,o,s,r)):0!==c[1]&&(r=yw(m,t,c,o,s,r)),o=0):!o||"data"!==p.type&&"tableDelimiterMarker"!==p.type&&"tableDelimiterFiller"!==p.type||(c[3]=s)}for(0!==u&&vw(m,t,u,n,a),m.consume(t.events),s=-1;++s<t.events.length;){const e=t.events[s];"enter"===e[0]&&"table"===e[1].type&&(e[1]._align=xw(t.events,s))}return e}function yw(e,t,n,a,r,s){const i=1===a?"tableHeader":2===a?"tableDelimiter":"tableData";0!==n[0]&&(s.end=Object.assign({},ww(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const o=ww(t.events,n[1]);if(s={type:i,start:Object.assign({},o),end:Object.assign({},o)},e.add(n[1],0,[["enter",s,t]]),0!==n[2]){const r=ww(t.events,n[2]),s=ww(t.events,n[3]),i={type:"tableContent",start:Object.assign({},r),end:Object.assign({},s)};if(e.add(n[2],0,[["enter",i,t]]),2!==a){const a=t.events[n[2]],r=t.events[n[3]];if(a[1].end=Object.assign({},r[1].end),a[1].type="chunkText",a[1].contentType="text",n[3]>n[2]+1){const t=n[2]+1,a=n[3]-n[2]-1;e.add(t,a,[])}}e.add(n[3]+1,0,[["exit",i,t]])}return void 0!==r&&(s.end=Object.assign({},ww(t.events,r)),e.add(r,0,[["exit",s,t]]),s=void 0),s}function vw(e,t,n,a,r){const s=[],i=ww(t.events,n);r&&(r.end=Object.assign({},i),s.push(["exit",r,t])),a.end=Object.assign({},i),s.push(["exit",a,t]),e.add(n+1,0,s)}function ww(e,t){const n=e[t],a="enter"===n[0]?"start":"end";return n[1][a]}const kw={name:"tasklistCheck",tokenize:function(e,t,n){const a=this;return function(t){if(null!==a.previous||!a._gfmTasklistFirstContentOfListItem)return n(t);return e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),r};function r(t){return Nx(t)?(e.enter("taskListCheckValueUnchecked"),e.consume(t),e.exit("taskListCheckValueUnchecked"),s):88===t||120===t?(e.enter("taskListCheckValueChecked"),e.consume(t),e.exit("taskListCheckValueChecked"),s):n(t)}function s(t){return 93===t?(e.enter("taskListCheckMarker"),e.consume(t),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),i):n(t)}function i(a){return Cx(a)?t(a):Fx(a)?e.check({tokenize:jw},t,n)(a):n(a)}}};function jw(e,t,n){return Tx(e,function(e){return null===e?n(e):t(e)},"whitespace")}const Dw={};function Cw(e){const t=e||Dw,n=this.data(),a=n.micromarkExtensions||(n.micromarkExtensions=[]),r=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),s=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);a.push(function(e){return gx([{text:ew},{document:{91:{name:"gfmFootnoteDefinition",tokenize:uw,continuation:{tokenize:mw},exit:hw}},text:{91:{name:"gfmFootnoteCall",tokenize:dw},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:lw,resolveTo:cw}}},pw(e),{flow:{null:{name:"table",tokenize:fw,resolveAll:bw}}},{text:{91:kw}}])}(t)),r.push([{transforms:[Wy],enter:{literalAutolink:zy,literalAutolinkEmail:Oy,literalAutolinkHttp:Oy,literalAutolinkWww:Oy},exit:{literalAutolink:qy,literalAutolinkEmail:Hy,literalAutolinkHttp:Uy,literalAutolinkWww:Vy}}
2,{enter:{gfmFootnoteCallString:Xy,gfmFootnoteCall:Jy,gfmFootnoteDefinitionLabelString:$y,gfmFootnoteDefinition:Qy},exit:{gfmFootnoteCallString:Zy,gfmFootnoteCall:ev,gfmFootnoteDefinitionLabelString:tv,gfmFootnoteDefinition:nv}},{canContainEols:["delete"],enter:{strikethrough:lv},exit:{strikethrough:cv}},{enter:{table:Iv,tableData:zv,tableHeader:zv,tableRow:Lv},exit:{codeText:Ov,table:Pv,tableData:Rv,tableHeader:Rv,tableRow:Rv}},{exit:{taskListCheckValueChecked:Hv,taskListCheckValueUnchecked:Hv,paragraph:qv}}]),s.push(function(e){return{extensions:[{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ly,notInConstruct:Ry},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ly,notInConstruct:Ry},{character:":",before:"[ps]",after:"\\/",inConstruct:Ly,notInConstruct:Ry}]},rv(e),{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:ov}],handlers:{delete:dv}},Vv(e),{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Wv}}]}}(t))}const Nw=Mo("reply",[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]),Fw=Mo("thumbs-up",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]),Sw=Mo("heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]),Ew=Mo("smile",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]),Aw=Mo("bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]),Tw=Mo("italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]),Mw=Mo("quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]),_w=Mo("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]),Bw=e=>{const t=/\b(\d{1,2}):(\d{2})(?::(\d{2}))?\b/g.exec(e);if(!t)return null;const n=t[0];let a=0,r=0,s=0;if(t[3]?(a=parseInt(t[1],10),r=parseInt(t[2],10),s=parseInt(t[3],10)):(r=parseInt(t[1],10),s=parseInt(t[2],10)),r>=60||s>=60)return null;return{originalText:n,seconds:3600*a+60*r+s,formattedTime:a>0?"".concat(a,":").concat(r.toString().padStart(2,"0"),":").concat(s.toString().padStart(2,"0")):"".concat(r,":").concat(s.toString().padStart(2,"0"))}},Iw=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return t>0?"".concat(t,":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")):"".concat(n,":").concat(a.toString().padStart(2,"0"))},Pw="undefined"!==typeof window;let Lw=Pw&&"true"===new URLSearchParams(window.location.search).get("debug");Pw&&(window.__RESCRIPT_DEBUG__=Lw),Pw&&Object.defineProperty(window,"__RESCRIPT_DEBUG__",{get:()=>Lw,set:e=>{Lw=Boolean(e),console.info("[DEBUG] Debug logging ".concat(Lw?"ENABLED":"DISABLED"))}}),Pw&&window.addEventListener("keydown",e=>{e.ctrlKey&&e.shiftKey&&"D"===e.key&&(e.preventDefault(),window.__RESCRIPT_DEBUG__=!Lw)});const Rw=(e,t)=>0===t.length||e.startsWith("[")?[e,...t]:["[".concat(e,"]"),...t],zw=function(e){if(Lw){for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];console.log(...Rw(e,n))}},Ow=(0,a.createContext)({isTabVisible:!0,isMediaPlaying:!1,isIdle:!1,setMediaPlaying:()=>{}}),Uw=()=>(0,a.useContext)(Ow),Vw=e=>{let{children:t}=e;const[n,r]=(0,a.useState)(!document.hidden),[s,i]=(0,a.useState)(!1),o=(0,a.useRef)(new Set),l=(0,a.useRef)(new Set),c=!n&&!s;(0,a.useEffect)(()=>{const e=()=>{const e=!document.hidden;
2r(e),e?l.current.forEach(e=>e()):s||o.current.forEach(e=>e())};return document.addEventListener("visibilitychange",e),()=>{document.removeEventListener("visibilitychange",e)}},[s]),(0,a.useEffect)(()=>{c?zw("[IDLE] App entering idle mode - tab hidden, no media playing"):zw("[IDLE] App active - visible:",n,"media:",s)},[c,n,s]);const d=(0,a.useCallback)(e=>{i(e)},[]);return(0,u.jsx)(Ow.Provider,{value:{isTabVisible:n,isMediaPlaying:s,isIdle:c,setMediaPlaying:d},children:t})},Hw=()=>{var e,t,n;return"undefined"!==typeof navigator&&"undefined"!==typeof window&&(navigator.maxTouchPoints>=1||(null===(e=(t=window).matchMedia)||void 0===e||null===(n=e.call(t,"(pointer: coarse)"))||void 0===n?void 0:n.matches)||/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))},qw=()=>{var e,t;if("undefined"===typeof window)return{width:0,height:0};const n=window.visualViewport;return{width:null!==(e=null===n||void 0===n?void 0:n.width)&&void 0!==e?e:window.innerWidth,height:null!==(t=null===n||void 0===n?void 0:n.height)&&void 0!==t?t:window.innerHeight}};function Ww(){const[e,t]=(0,a.useState)(()=>"undefined"!==typeof window&&(window.innerWidth<=768||Hw())),[n,r]=(0,a.useState)(()=>{if("undefined"===typeof window)return!1;const{width:e,height:t}=qw();return Hw()&&(Math.min(e,t)<=600||t<=720)}),s=(0,a.useRef)(()=>{if("undefined"===typeof navigator)return!1;const e=navigator.hardwareConcurrency||4,t=navigator.deviceMemory||4;return e<=2||t<=2}).current();(0,a.useEffect)(()=>{var e;const n=()=>{const e=Hw(),{width:n,height:a}=qw(),s=window.innerWidth<=768||e;t(s),r(e&&(Math.min(n,a)<=600||a<=720))},a=()=>{setTimeout(n,100)};return window.addEventListener("resize",n,{passive:!0}),window.addEventListener("orientationchange",a,{passive:!0}),null===(e=window.visualViewport)||void 0===e||e.addEventListener("resize",n),()=>{var e;window.removeEventListener("resize",n),window.removeEventListener("orientationchange",a),null===(e=window.visualViewport)||void 0===e||e.removeEventListener("resize",n)}},[]);return(0,a.useMemo)(()=>e||s?{isMobile:e,isCompactTouchLayout:n,isLowPerformance:s,timeUpdateThrottleMs:500,youtubePollingMs:500,useSmoothScroll:!1,enableWordHighlighting:!1,searchDebounceMs:500,jobPollingMs:5e3,slowJobPollingMs:3e4}:{isMobile:!1,isCompactTouchLayout:n,isLowPerformance:!1,timeUpdateThrottleMs:150,youtubePollingMs:250,useSmoothScroll:!0,enableWordHighlighting:!0,searchDebounceMs:200,jobPollingMs:2e3,slowJobPollingMs:1e4},[n,s,e])}const Yw=(0,a.createContext)(void 0),Gw=(0,a.createContext)(void 0),Kw=()=>{const e=(0,a.useContext)(Yw);if(!e)throw new Error("useAudioControls must be used within an AudioProvider");return e},Xw=()=>{const e=(0,a.useContext)(Gw);if(void 0===e)throw new Error("useAudioCurrentTime must be used within an AudioProvider");return e},Jw=()=>{const e=Kw(),t=Xw();return d(d({},e),{},{currentTime:t})},$w=()=>{const{seekTo:e}=Kw();return{seekTo:e}},Qw=e=>{let{children:t}=e;const{setMediaPlaying:n}=Uw(),{timeUpdateThrottleMs:r}=Ww(),s=(0,a.useRef)(null),[i,o]=(0,a.useState)(0),[l,c]=(0,a.useState)(0),[d,m]=(0,a.useState)(!1),[h,p]=(0,a.useState)(!1),[g,x]=(0,a.useState)(null),[f,b]=(0,a.useState)(1),[y,v]=(0,a.useState)(1),[w,k]=(0,a.useState)("audio"),[j,D]=(0,a.useState)(0),[C,N]=(0,a.useState)(null),F=(0,a.useRef)("audio"),S=(0,a.useRef)(0),E=(0,a.useRef)(0),A=(0,a.useRef)(!1),T=(0,a.useRef)(null),M=((0,a.useRef)(null),(0,a.useRef)(0)),_=(0,a.useRef)(null),B=(0,a.useRef)(!1),I=(0,a.useRef)(null),P=(0,a.useRef)(0),L=(0,a.useCallback)(e=>e.startsWith("http")?e:window.location.origin+e,[]),R=(0,a.useCallback)(e=>{N(e),D(e=>e+1)},[]);(0,a.useEffect)(()=>{n(d)},[d,n]),(0,a.useEffect)(()=>{S.current=i},[i]),(0,a.useEffect)(()=>{E.current=l},[l]),(0,a.useEffect)(()=>{A.current=d},[d]),(0,a.useEffect)(()=>{"youtube"===w&&s.current?(s.current.pause(),s.current.muted=!0):"audio"===w&&s.current&&(s.current.muted=!1)},[w]);const z=(0,a.useCallback)(e=>{"youtube"===w&&o(e)},[w]),O=(0,a.useCallback)(e=>{"youtube"===w&&c(e)},[w]),U=(0,a.useCallback)(e=>{"youtube"===w&&m(e)},[w]),V=(0,a.useCallback)(e=>{zw("[AudioContext] Setting player mode:",e),F.current=e,k(e),"youtube"===e&&s.current&&(s.current.pause(),s.current.muted=!0),"audio"===e&&s.current&&(s.current.muted=!1)},[]),H=(0,a.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("youtube"===F.current)return void zw("[AudioContext] Skipping audio load - in YouTube mode");_.current=Number.isFinite(t.startTime)?Math.max(0,t.startTime):null,B.current=!!t.shouldPlay;const n=L(e);
2if(zw("[AudioContext] Loading audio from URL:",e),zw("[AudioContext] Full URL:",n),zw("[AudioContext] Audio element exists:",!!s.current),x(n),s.current){const a=s.current,r=a.currentSrc||"",i=a.getAttribute("src")||a.src||"";if(I.current===n||r===n||i===n){if(zw("[AudioContext] Reusing already-loaded audio element for URL:",e),null!==_.current){const e=Number.isFinite(a.duration)&&a.duration>0?Math.min(_.current,a.duration):_.current;Math.abs(a.currentTime-e)>.05&&(a.currentTime=e),o(e),M.current=Date.now(),_.current=null}const n=a.readyState>=HTMLMediaElement.HAVE_FUTURE_DATA;return p(!n),void(t.shouldPlay?a.paused?a.play().then(()=>m(!0)).catch(e=>console.error("[AudioContext] Error playing reused audio:",e)):m(!0):!1!==t.shouldPlay||a.paused||(a.pause(),m(!1)))}p(!0),m(!1);const l=()=>{zw("[AudioContext] Audio load started for URL:",e)},c=()=>{zw("[AudioContext] Audio loading progress")},d=()=>{zw("[AudioContext] Audio can start playing")},u=()=>{zw("[AudioContext] Audio can play through without buffering")},h=()=>{zw("[AudioContext] Audio loaded data event fired")};a.addEventListener("loadstart",l,{once:!0}),a.addEventListener("progress",c,{once:!0}),a.addEventListener("canplay",d,{once:!0}),a.addEventListener("canplaythrough",u,{once:!0}),a.addEventListener("loadeddata",h,{once:!0}),zw("[AudioContext] Setting audio src to:",n),I.current=n,a.src=n,a.load(),zw("[AudioContext] Called load() on audio element")}else console.error("[AudioContext] Audio ref is not available")},[L]),q=(0,a.useCallback)(async()=>{if("youtube"===F.current)return zw("[AudioContext] YouTube mode - setting isPlaying true for YouTube player"),void m(!0);if(s.current)try{zw("[AudioContext] Playing audio"),zw("[AudioContext] Audio element state:",{src:s.current.src,readyState:s.current.readyState,networkState:s.current.networkState,error:s.current.error,duration:s.current.duration,paused:s.current.paused}),await s.current.play(),m(!0)}catch(e){console.error("[AudioContext] Error playing audio:",e),e instanceof Error&&console.error("[AudioContext] Error details:",{name:e.name,message:e.message,stack:e.stack})}},[]),W=(0,a.useCallback)(()=>{if("youtube"===F.current)return zw("[AudioContext] YouTube mode - setting isPlaying false for YouTube player"),void m(!1);s.current&&(s.current.pause(),m(!1),T.current=null)},[]),Y=(0,a.useCallback)(e=>{zw("[AudioContext] Seeking to time:",e,"playerMode:",F.current),o(e),M.current=Date.now(),R(e),"youtube"!==F.current&&s.current&&(s.current.currentTime=e)},[R]),G=(0,a.useCallback)(async(e,t)=>{if(zw("[AudioContext] Playing segment:",{startTime:e,endTime:t,playerMode:F.current}),R(e),"youtube"===F.current)return o(e),m(!0),void(M.current=Date.now());s.current&&(s.current.currentTime=e,o(e),M.current=Date.now(),T.current=t||null,await q())},[q,R]),K=(0,a.useCallback)(e=>{if(!s.current)return;const t=Math.max(0,Math.min(1,e));zw("[AudioContext] Setting volume:",t),s.current.volume=t,b(t)},[]),X=(0,a.useCallback)(e=>{s.current&&(zw("[AudioContext] Setting playback rate:",e),s.current.playbackRate=e,v(e))},[]);(0,a.useEffect)(()=>{const e=s.current;if(!e)return;const t=()=>{if("youtube"===F.current)return;const t=e.currentTime,n=Date.now();n-M.current>=r&&(o(t),M.current=n),T.current&&t>=T.current&&(zw("[AudioContext] Reached segment end time"),W())},n=()=>
2{if(zw("[AudioContext] Audio metadata loaded, duration:",e.duration),c(e.duration),null!==_.current){const t=Number.isFinite(e.duration)&&e.duration>0?Math.min(_.current,e.duration):_.current;e.currentTime=t,o(t),M.current=Date.now(),_.current=null}p(!1),B.current&&(B.current=!1,e.play().then(()=>{m(!0)}).catch(e=>{console.error("[AudioContext] Error resuming audio after reload:",e)}))},a=()=>{zw("[AudioContext] Audio ended"),m(!1),T.current=null},i=e=>{const t=e.target,n=t.error,a=I.current||"";if(!!n&&(n.code===MediaError.MEDIA_ERR_NETWORK||n.code===MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED)&&/\/api\/(public\/share\/[^/]+\/audio|audio\/)/.test(a)&&Date.now()-P.current>6e4){P.current=Date.now();const e=t.currentTime||0,n=!t.paused||B.current;return _.current=e,B.current=n,t.src=a,void t.load()}if(_.current=null,B.current=!1,console.error("[AudioContext] Audio error:",{event:e,error:n,code:null===n||void 0===n?void 0:n.code,message:null===n||void 0===n?void 0:n.message,src:t.src,networkState:t.networkState,readyState:t.readyState,NETWORK_STATES:{NETWORK_EMPTY:0,NETWORK_IDLE:1,NETWORK_LOADING:2,NETWORK_NO_SOURCE:3,currentState:t.networkState},READY_STATES:{HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4,currentState:t.readyState}}),n)switch(n.code){case MediaError.MEDIA_ERR_ABORTED:console.error("[AudioContext] The fetching of the audio was aborted by the user");break;case MediaError.MEDIA_ERR_NETWORK:console.error("[AudioContext] A network error occurred while fetching the audio");break;case MediaError.MEDIA_ERR_DECODE:console.error("[AudioContext] An error occurred while decoding the audio");break;case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:console.error("[AudioContext] The audio format is not supported");break;default:console.error("[AudioContext] An unknown error occurred")}p(!1),m(!1)},l=()=>{m(!0)},d=()=>{m(!1)};return e.addEventListener("timeupdate",t),e.addEventListener("loadedmetadata",n),e.addEventListener("ended",a),e.addEventListener("error",i),e.addEventListener("play",l),e.addEventListener("pause",d),()=>{e.removeEventListener("timeupdate",t),e.removeEventListener("loadedmetadata",n),e.removeEventListener("ended",a),e.removeEventListener("error",i),e.removeEventListener("play",l),e.removeEventListener("pause",d)}},[W,r]),(0,a.useEffect)(()=>()=>{s.current&&(s.current.pause(),s.current.src="")},[]);const J=(0,a.useCallback)(()=>({currentTime:S.current,duration:E.current,isPlaying:A.current}),[]),$=(0,a.useMemo)(()=>({audioRef:s,duration:l,isPlaying:d,isLoading:h,audioUrl:g,volume:f,playbackRate:y,playerMode:w,mediaSeekRequestId:j,mediaSeekRequestTime:C,loadAudio:H,play:q,pause:W,seekTo:Y,playSegment:G,setVolume:K,setPlaybackRate:X,setPlayerMode:V,setYouTubeTime:z,setYouTubeDuration:O,setYouTubePlaying:U,getPlaybackSnapshot:J}),[l,d,h,g,f,y,w,j,C,H,q,W,Y,G,K,X,V,z,O,U,J]);return(0,u.jsx)(Yw.Provider,{value:$,children:(0,u.jsxs)(Gw.Provider,{value:i,children:[(0,u.jsx)("audio",{ref:s,preload:"auto",style:{display:"none"}}),t]})})},Zw=["className","children"],ek=["className","children"],tk="",nk=480,ak=e=>{let{sessionId:t,token:n,isPublicView:r=!1,isInline:s=!1,onCommentsChange:i,pendingTimestamp:o,selectedCommentId:l,onClose:c,initialComments:m,disablePolling:h=!1}=e;const{user:p}=am(),{isDarkMode:g}=zu(),{seekTo:x}=$w(),{currentTime:f}=Jw(),b=(0,a.useRef)(x),{permissions:y}=Hp(),{isCompactTouchLayout:v}=Ww();(0,a.useEffect)(()=>{b.current=x},[x]);const[w,k]=(0,a.useState)(!1),j=v,[D,C]=(0,a.useState)(m||[]),[N,F]=(0,a.useState)(()=>"undefined"!==typeof window?window.innerHeight-200:500),[E,A]=(0,a.useState)(!1),[M,_]=(0,a.useState)(0),[B,I]=(0,a.useState)(0),[P,L]=(0,a.useState)(!1),R=(0,a.useCallback)(()=>{if("undefined"===typeof window)return{originX:0,originY:0,width:nk,height:500,pixelsPerClientPixelX:1,pixelsPerClientPixelY:1};const e=document.querySelector(".app-shell");if(!e)return{originX:0,originY:0,width:window.innerWidth,height:window.innerHeight,pixelsPerClientPixelX:1,pixelsPerClientPixelY:1};const t=e.getBoundingClientRect(),n=e.clientWidth||t.width||window.innerWidth,a=e.clientHeight||t.height||window.innerHeight;return{originX:t.left,originY:t.top,width:n,height:a,pixelsPerClientPixelX:t.width>0?n/t.width:1,pixelsPerClientPixelY:t.height>0?a/t.height:1}},[]),[z,O]=(0,a.useState)(()=>{const e="undefined"===typeof window?{width:nk,height:500}:(()=>{const e=document.querySelector(".app-shell");if(!e)return{width:window.innerWidth,height:window.innerHeight};const t=e.getBoundingClientRect();return{width:e.clientWidth||t.width||window.innerWidth,height:e.clientHeight||t.height||window.innerHeight}})();return{x:Math.max(0,e.width-nk),y:Math.min(100,Math.max(0,e.height-320))}}),[U,V]=(0,a.useState)(!1),[H,q]=(0,a.useState)({x:0,y:0});(0,a.useEffect)(()=>{console.log("[Comments] Component rendered at",(new Date).toISOString(),{sessionId:t,isInline:s,pendingTimestamp:o,selectedCommentId:l,hasOnCommentsChange:!!i,hasOnClose:!!c,timestamp:Date.now()})},[t,s,o,l]);const[W,Y]=(0,a.useState)(""),[G,K]=(0,a.useState)(!1),[X,J]=(0,a.useState)(""),[$,Q]=(0,a.useState)(!1),[Z,ee]=(0,a.useState)(!1),[te,ne]=(0,a.useState)(()=>"undefined"!==typeof window&&localStorage.getItem("anonymousName")||""),[ae,re]=(0,a.useState)(null),[se,ie]=(0,a.useState)(null),[oe,le]=(0,a.useState)(null),[ce,de]=(0,a.useState)({}),[ue,me]=(0,a.useState)(new Set),he=(0,a.useRef)(null),pe=(0,a.useRef)(null),ge=(0,a.useRef)(!1),xe=()=>{if("undefined"===typeof window)return null;let e=localStorage.getItem("anonymousSessionId");return e||(e="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),localStorage.setItem("anonymousSessionId",e)),e};(0,a.useEffect)(()=>{"undefined"!==typeof window&&te&&localStorage.setItem("anonymousName",te)},[te]);const fe=(0,a.useRef)(null),be=(0,a.useRef)(null),ye=(0,a.useRef)(null),ve=(0,a.useRef)(null),we=(0,a.useRef)(null),ke=(0,a.useRef)(0),je=(0,a.useRef)(!1),De=(0,a.useRef)(3e4),Ce=(0,a.useRef)(null);(0,a.useEffect)(()=>
2{if(j)return void O({x:0,y:0});const e=()=>{const e=R();F(t=>{const n=Math.max(200,e.height-100);return Math.max(200,Math.min(n,t))}),O(t=>{const n=Math.max(0,e.width-nk),a=Math.max(0,e.height-N);return{x:Math.max(0,Math.min(n,t.x)),y:Math.max(0,Math.min(a,t.y))}})};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[R,j,N]),(0,a.useEffect)(()=>{je.current=$},[$]);const Ne=(0,a.useCallback)(()=>{null!==he.current&&(window.clearTimeout(he.current),he.current=null)},[]),Fe=(0,a.useCallback)((e,t)=>{Ne(),he.current=window.setTimeout(()=>{const n=ve.current;if(n){try{n.focus({preventScroll:j})}catch(_H){n.focus()}void 0!==e&&n.setSelectionRange(e,null!==t&&void 0!==t?t:e),he.current=null}},j?180:120)},[Ne,j]);(0,a.useEffect)(()=>()=>{Ne(),null!==pe.current&&window.clearTimeout(pe.current)},[Ne]),(0,a.useEffect)(()=>{D.forEach(e=>{var t,n,a,r,s;"pinned_message"===e.type&&console.log("[COMMENTS-PINNED] Comment ".concat(e.id," pinned content:"),{hasOriginalMessage:!(null===(t=e.pinnedContent)||void 0===t||!t.originalMessage),originalMessageLength:(null===(n=e.pinnedContent)||void 0===n||null===(a=n.originalMessage)||void 0===a?void 0:a.length)||0,originalMessagePreview:(null===(r=e.pinnedContent)||void 0===r||null===(s=r.originalMessage)||void 0===s?void 0:s.substring(0,200))||"No content"})})},[D]),(0,a.useEffect)(()=>{if(null!==o&&void 0!==o){const e=Iw(o);Y("".concat(e," "));const t="".concat(e," ").length;Fe(t,t)}},[Fe,o]),(0,a.useEffect)(()=>{if(j||ge.current)return;if(""===W||/^(\d{1,2}:\d{2}(:\d{2})?\s?)$/.test(W)){const e=Iw(f),t="".concat(e," ");W!==t&&Y(t)}},[j,f,W]),(0,a.useEffect)(()=>{l&&D.length>0&&(null!==pe.current&&window.clearTimeout(pe.current),pe.current=window.setTimeout(()=>{const e=document.getElementById("comment-".concat(l));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),pe.current=null},100))},[l,D.length]);const Se=(0,a.useMemo)(()=>{const e=new Map,t=[];return D.forEach(t=>{e.set(t.id,d(d({},t),{},{replies:[]}))}),D.forEach(n=>{const a=e.get(n.id);if(a)if(n.parentCommentId&&e.has(n.parentCommentId)){const t=e.get(n.parentCommentId);t&&(t.replies=t.replies||[],t.replies.push(a))}else t.push(a)}),t.sort((e,t)=>{const n=null!==e.timestampSeconds&&void 0!==e.timestampSeconds,a=null!==t.timestampSeconds&&void 0!==t.timestampSeconds;if(n&&a)return e.timestampSeconds-t.timestampSeconds;if(n&&!a)return-1;if(!n&&a)return 1;{const n=e.created_at||e.timestamp,a=t.created_at||t.timestamp;return n&&a?new Date(n).getTime()-new Date(a).getTime():0}}),t.forEach(e=>{e.replies&&e.replies.length>0&&e.replies.sort((e,t)=>{const n=e.created_at||e.timestamp,a=t.created_at||t.timestamp;return n&&a?new Date(n).getTime()-new Date(a).getTime():0})}),t},[D]),Ee=(0,a.useCallback)((e,t)=>{console.log("[COMMENTS] extractTTMLBlocks called for comment ".concat(t,":"),{contentLength:e.length,contentPreview:e.substring(0,200)});const n=[],a=/```ttml\n([\s\S]*?)\n```/g;let r;for(;null!==(r=a.exec(e));){console.log("[COMMENTS] Found traditional TTML block in comment ".concat(t,":"),r[1].substring(0,100));const e=r[1].trim();if(e){const a=e=>e.includes("r_overview")||e.includes("d_overview")?"overview":e.includes("r_clips")||e.includes("d_clips")?"clips":e.includes("r_best")||e.includes("d_best")?"best-parts":e.includes("r_weak")||e.includes("d_weak")?"weak-parts":e.includes("r_summary")||e.includes("d_summary")?"summary":e.includes("r_clip")||e.includes("d_clip")?"clip":e.includes("r_edit")||e.includes("d_edit")?"edit":"ttml",r=a(e),s={id:"".concat(r,"-").concat(t,"-").concat(n.length),content:e,commentId:t,createdAt:new Date};n.push(s)}}const s=/<tt[^>]*>[\s\S]*?<\/tt>/g;let i;for(console.log("[COMMENTS] Looking for <tt>...</tt> XML blocks in content..."),console.log('[COMMENTS] Content includes "<tt"? '.concat(e.includes("<tt")));null!==(i=s.exec(e));){const e=i[0].trim();console.log("[COMMENTS] Found TTML XML block in comment ".concat(t,":"),e.substring(0,100));const a=(e,t)=>e.includes("r_overview")||e.includes("d_overview")?"overview.ttml":e.includes("r_clips")||e.includes("d_clips")?"clips.ttml":e.includes("r_best")||e.includes("d_best")?"best-parts.ttml":e.includes("r_weak")||e.includes("d_weak")?"weak-parts.ttml":e.includes("r_summary")||e.includes("d_summary")?"summary.ttml":e.includes("script_clips")?"script-clips-".concat(t+1,".ttml"):e.includes("doom_debate")?"doom-debate.ttml":e.includes("main_interview")?"main-interview.ttml":e.includes("patreon_warmup")?"patreon-warmup.ttml":"ttml-file-".concat(t+1,".ttml"),r=a(e,n.length),s=r.replace(".ttml",""),o={id:"".concat(s,"-").concat(t,"-").concat(n.length),content:e,commentId:t,createdAt:new Date,filename:r};
2n.push(o),console.log("[COMMENTS] Created TTML block with filename: ".concat(r))}return console.log("[COMMENTS] Total TTML blocks found for comment ".concat(t,": ").concat(n.length)),n},[]),Ae=(0,a.useCallback)(e=>{const t=new Blob([e.content],{type:"application/ttml+xml"}),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n;let r=e.filename||"".concat(e.id,".ttml");a.download=r.endsWith(".ttml")?r:"".concat(r,".ttml"),document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)},[]),Te=(0,a.useCallback)(e=>e.replace(/```ttml\n[\s\S]*?\n```/g,"").trim(),[]),Me=(0,a.useCallback)(async(e,t)=>{try{await navigator.clipboard.writeText(e),re(t),setTimeout(()=>re(null),2e3)}catch(n){console.error("Failed to copy comment:",n);const r=document.createElement("textarea");r.value=e,document.body.appendChild(r),r.select();try{document.execCommand("copy"),re(t),setTimeout(()=>re(null),2e3)}catch(a){console.error("Fallback copy failed:",a)}document.body.removeChild(r)}},[]),_e=e=>{let{content:t,commentId:n}=e;const a=Ee(t,n);return console.log("[COMMENTS] TTMLDownloadButtons for comment ".concat(n,":"),{content:t.substring(0,100)+"...",ttmlFilesFound:a.length,ttmlFiles:a}),0===a.length?null:(0,u.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-600",children:[(0,u.jsx)("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2",children:"TTML Files Found:"}),(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>(0,u.jsxs)("button",{onClick:()=>Ae(e),className:"flex items-center space-x-1 text-xs ".concat(g?"border border-[#445166] bg-[#232E3F] text-[#F4F4F4] hover:bg-[#2F3B4E]":"border border-[#E7B14C]/45 bg-[#FFF4D8] text-[#8B5B00] hover:bg-[#FFE7AD]"," px-2 py-1 rounded transition-colors"),children:[(0,u.jsx)(gp,{size:12}),(0,u.jsxs)("span",{children:["Download ",e.filename?e.filename.replace(".ttml","").toUpperCase():e.id.split("-")[0].toUpperCase()]}),(0,u.jsx)(Sp,{size:10})]},e.id))})]})};(0,a.useEffect)(()=>{const e=()=>{De.current=3e4,Q(e=>!1),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{Q(!0)},6e4)},t=["mousedown","keypress","scroll","touchstart"];return t.forEach(t=>{document.addEventListener(t,e,!0)}),e(),()=>{t.forEach(t=>{document.removeEventListener(t,e,!0)}),ye.current&&clearTimeout(ye.current)}},[]);const Be=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(t&&(r||n)){e||K(!0),J("");try{if(r&&!n)return console.error("[COMMENTS] Public view requires a share token"),void J("Comments unavailable - share token required");const e=r?"".concat(tk,"/api/public/share/").concat(n,"/comments"):"".concat(tk,"/api/sessions/").concat(t,"/comments");console.log("[COMMENTS] Making request to:",e),console.log("[COMMENTS] With token:",n?"present":"missing"),console.log("[COMMENTS] Public view:",r);const a={"Content-Type":"application/json"};!r&&n&&(a.Authorization="Bearer ".concat(n));const s=await fetch(e,{headers:a});console.log("[COMMENTS] Response status:",s.status),console.log("[COMMENTS] Response headers:",Object.fromEntries(s.headers.entries()));const o=await s.text();if(console.log("[COMMENTS] Raw response:",o.substring(0,200)+"..."),!s.ok)throw new Error("Failed to load comments");let l;try{l=JSON.parse(o)}catch(TS){throw console.error("[COMMENTS] JSON parse error:",TS),new Error("Server returned invalid JSON")}const c=l.comments||[];console.log("[COMMENTS] Loaded comments:",c),console.log("[COMMENTS] First comment structure:",c[0]),c.length>0&&(console.log("[COMMENTS] Sample comment keys:",Object.keys(c[0])),console.log("[COMMENTS] Comments with timestampSeconds:",c.filter(e=>null!==e.timestampSeconds&&void 0!==e.timestampSeconds).length),console.log("[COMMENTS] Comments with timestamp_seconds:",c.filter(e=>null!==e.timestamp_seconds&&void 0!==e.timestamp_seconds).length)),C(c),i?(console.log("[COMMENTS] Calling onCommentsChange with",c.length,"comments"),i(c)):console.log("[COMMENTS] No onCommentsChange callback provided")}catch(a){console.error("Failed to load comments:",a),e||J("Failed to load comments")}finally{e||K(!1)}}},[t,n,r,i]),Ie=(0,a.useRef)(Be);(0,a.useEffect)(()=>{Ie.current=Be},[Be]);const Pe=(0,a.useCallback)(async()=>
2{if(t&&n&&!r)try{const e=await fetch("".concat(tk,"/api/sessions/").concat(t,"/reactions"),{headers:{Authorization:"Bearer ".concat(n)}});if(e.ok){const t=await e.json();de(t.reactions||{})}}catch(X){console.error("Failed to load reactions:",X)}},[t,n,r]),Le=(0,a.useRef)(Pe);(0,a.useEffect)(()=>{Le.current=Pe},[Pe]),(0,a.useEffect)(()=>{t&&(r||n)&&(h&&m&&m.length>0?console.log("[COMMENTS] Using pre-loaded comments from CDN bundle, skipping API fetch"):(Ie.current(),Le.current()))},[t,n,h]),(0,a.useEffect)(()=>{if(h)return void console.log("[COMMENTS] Polling disabled for static/CDN content");if(!t||!r&&!n)return;const e=()=>{Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{je.current&&(Ie.current(!0),Le.current(),De.current=Math.min(2*De.current,3e5),console.log("[COMMENTS] Next poll in ".concat(De.current/1e3,"s (exponential backoff)"))),e()},De.current)};return e(),()=>{Ce.current&&(clearTimeout(Ce.current),Ce.current=null),be.current&&(clearInterval(be.current),be.current=null)}},[t,n,r,h]);const Re=()=>{var e;null===(e=fe.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})};(0,a.useEffect)(()=>{const e=D.length>ke.current;!s&&e&&(()=>{if(!we.current)return!0;const e=we.current;return e.scrollTop+e.clientHeight>=e.scrollHeight-100})()&&Re(),ke.current=D.length},[D,s]),(0,a.useEffect)(()=>{!s&&D.length>0&&Re()},[s]);const ze=(0,a.useCallback)(e=>{b.current&&b.current(e)},[]),Oe=async()=>{if(console.log("[COMMENTS] addComment called",{newComment:W.trim(),sessionId:t,isPublicView:r,token:n?"present":"missing",user:p?"present":"missing",sharePermissions:y}),W.trim()&&t)if(r||n&&p){if(y&&!y.commentsWrite)return console.log("[COMMENTS] addComment blocked by share permissions",y),void J("Comments are read-only for this share link");K(!0),J("");try{const e=Bw(W.trim()),a=null===e||void 0===e?void 0:e.seconds;if(r&&!n)return console.error("[COMMENTS] Public view requires a share token"),void J("Cannot post comment - share token required");const s=r?"".concat(tk,"/api/public/share/").concat(n,"/comments"):"".concat(tk,"/api/sessions/").concat(t,"/comments");console.log("[COMMENTS] Posting comment to:",s);const o={"Content-Type":"application/json"};if(!r&&n)o.Authorization="Bearer ".concat(n);else if(r){const e=xe();e&&(o["X-Anonymous-Session-ID"]=e)}const l=r?{content:W.trim(),type:"comment",anonName:te.trim(),timestampSeconds:a,parentCommentId:se}:{content:W.trim(),type:"comment",timestampSeconds:a,parentCommentId:se};console.log("[COMMENTS] Request body:",l),console.log("[COMMENTS] Request headers:",o);const c=await fetch(s,{method:"POST",headers:o,body:JSON.stringify(l)});console.log("[COMMENTS] Response status:",c.status);const d=await c.text();if(console.log("[COMMENTS] Response text:",d),!c.ok)throw new Error("Failed to add comment: ".concat(c.status," - ").concat(d));let u;try{u=JSON.parse(d)}catch(TS){throw console.error("[COMMENTS] Failed to parse response as JSON:",TS),new Error("Server returned invalid JSON response")}console.log("[COMMENTS] Comment added successfully:",u),Y(""),ie(null),console.log("[COMMENTS] Reloading comments after add..."),await Ie.current(),console.log("[COMMENTS] Comments reloaded after add"),i&&D&&setTimeout(()=>{console.log("[COMMENTS] Force updating parent with current comments"),Ie.current()},100)}catch(e){console.error("[COMMENTS] Failed to add comment:",e),J(e instanceof Error?e.message:"Failed to add comment")}finally{K(!1)}}else console.log("[COMMENTS] addComment early return - not public view and missing token/user",{isPublicView:r,hasToken:!!n,hasUser:!!p});else console.log("[COMMENTS] addComment early return - no comment or sessionId",{hasComment:!!W.trim(),hasSessionId:!!t})},Ue=e=>{if(!r&&p){const t=e.userEmail===p.email||"[email protected]"===p.email;return console.log("[DELETE] Checking delete permission for authenticated user:",{commentEmail:e.userEmail,userEmail:p.email,canDelete:t}),t}if(r&&null!==y&&void 0!==y&&y.commentsWrite&&e.isAnonymous){const t=xe(),n=e.anonymousSessionId===t;return console.log("[DELETE] Checking delete permission for anonymous user:",{commentSessionId:e.anonymousSessionId,currentSessionId:t,canDelete:n}),n}return!1},Ve=()=>{ie(null),le(null),Y("")},He=(0,a.useCallback)(async(e,a)=>{if(t&&n&&p)try{(await fetch("".concat(tk,"/api/sessions/").concat(t,"/comments/").concat(e,"/reactions"),{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify({emoji:a})})).ok&&await Pe()}catch(X){console.error("Failed to handle reaction:",X)}},[t,n,p,Pe]),qe=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),Oe())},We=e=>{if(!e)return"Unknown time";const t="string"===typeof e?new Date(e):e;if(isNaN(t.getTime()))return"Invalid time";const n=(new Date).getTime()-t.getTime(),a=Math.floor(n/6e4),r=Math.floor(a/60),s=Math.floor(r/24);return s>0?"".concat(s,"d ago"):r>0?"".concat(r,"h ago"):a>0?"".concat(a,"m ago"):"Just now"},Ye=e=>{if(!e)return"GU";if(e.includes("@"))return e.split("@")[0].substring(0,2).toUpperCase();const t=e.trim().split(" ");return t.length>1?(t[0][0]+t[t.length-1][0]).toUpperCase():e.substring(0,2).toUpperCase()},Ge=e=>{const t=["bg-[#232E3F]","bg-[#435065]","bg-[#8B5B00]","bg-[#B56A5D]","bg-[#FFB52B]","bg-[#5C6675]","bg-[#6B5130]","bg-[#A48757]"];if(!e)return t[0];
2return t[e.split("").reduce((e,t)=>e+t.charCodeAt(0),0)%t.length]},Ke=g?"border-white/10 bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.12),transparent_22%),radial-gradient(circle_at_86%_14%,rgba(111,137,182,0.10),transparent_20%),radial-gradient(circle_at_24%_84%,rgba(80,112,166,0.10),transparent_22%),radial-gradient(circle_at_92%_82%,rgba(248,113,113,0.07),transparent_18%),linear-gradient(180deg,rgba(17,27,42,0.54),rgba(17,27,42,0.5))] text-gray-100 shadow-[0_28px_72px_-36px_rgba(0,0,0,0.72)] backdrop-blur-[44px]":"border-[rgba(215,222,233,0.82)] bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.13),transparent_22%),radial-gradient(circle_at_86%_14%,rgba(111,137,182,0.09),transparent_20%),radial-gradient(circle_at_24%_84%,rgba(80,112,166,0.08),transparent_22%),radial-gradient(circle_at_92%_82%,rgba(248,113,113,0.05),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.5),rgba(255,255,255,0.46))] text-gray-900 shadow-[0_24px_60px_-34px_rgba(15,23,42,0.18)] backdrop-blur-[40px]",Xe=g?"border-white/10 bg-[radial-gradient(circle_at_16%_14%,rgba(255,181,43,0.06),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.34),rgba(17,27,42,0.3))] backdrop-blur-[34px]":"border-[rgba(215,222,233,0.76)] bg-[radial-gradient(circle_at_16%_14%,rgba(255,181,43,0.06),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.42),rgba(255,255,255,0.38))] backdrop-blur-[32px]",Je=g?"border-white/10 bg-[rgba(10,17,27,0.34)] text-gray-100 placeholder-gray-400 backdrop-blur-[30px]":"border-[rgba(215,222,233,0.8)] bg-[rgba(255,255,255,0.4)] text-gray-900 placeholder-gray-500 backdrop-blur-[26px]",$e=g?"text-gray-400":"text-gray-600",Qe=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const n=ve.current;if(!n)return;const a=n.selectionStart,r=n.selectionEnd,s=W.substring(a,r),i=W.substring(0,a),o=W.substring(r),l="".concat(i).concat(e).concat(s).concat(t).concat(o);Y(l);const c=a+e.length+s.length;Fe(c,c)},Ze=()=>Qe("**","**"),et=()=>Qe("*","*"),tt=()=>{var e;const t=(null===(e=ve.current)||void 0===e?void 0:e.selectionStart)||0,n=W.substring(0,t).lastIndexOf("\n")+1,a=W.substring(0,n),r=W.substring(n);Y("".concat(a,"> ").concat(r))},nt=(0,a.useCallback)(()=>{const e=D.filter(e=>!e.parentCommentId&&void 0!==e.timestampSeconds&&null!==e.timestampSeconds),t=D.filter(e=>!e.parentCommentId&&(void 0===e.timestampSeconds||null===e.timestampSeconds)),n=[...e].sort((e,t)=>e.timestampSeconds-t.timestampSeconds),a=[...t].sort((e,t)=>{const n=new Date(e.createdAt||e.created_at||e.timestamp||0),a=new Date(t.createdAt||t.created_at||t.timestamp||0);return n.getTime()-a.getTime()}),r=[...n],s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:42;const n=e.split(" "),a=[];let r="";return n.forEach(e=>{(r+" "+e).trim().length<=t?r=r?r+" "+e:e:(r&&a.push(r),r=e)}),r&&a.push(r),a.join("<br/>")},i=e=>{let t=e;return t=t.replace(/&/g,"&"),t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),t=t.replace(/"/g,"""),t=t.replace(/'/g,"'"),t=t.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),t=t.replace(/(?<!\*)\*([^*]+?)\*(?!\*)/g,"<em>$1</em>"),t=t.replace(/`(.+?)`/g,"<code>$1</code>"),t=t.replace(/\n/g,"<br/>"),t};let o='<?xml version="1.0" encoding="UTF-8"?>\n<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns:tts="http://www.w3.org/ns/ttml#styling" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" xmlns:ittp="http://www.w3.org/ns/ttml/profile/imsc1#parameter" xmlns:itts="http://www.w3.org/ns/ttml/profile/imsc1#styling" ttp:profile="http://www.w3.org/ns/ttml/profile/imsc1/text" ttp:frameRate="24" ttp:frameRateMultiplier="1000 1001" ttp:dropMode="nonDrop" ttp:timeBase="media">\n <head>\n <styling>\n <style xml:id="r_comments_style" tts:color="#ffffff" tts:opacity="1" tts:fontSize="75%" tts:fontFamily="proportionalSansSerif" tts:fontWeight="normal" tts:textOutline="#000000 2px" tts:textAlign="start"/>\n </styling>\n <layout>\n <region xml:id="r_comments" tts:origin="2.970% 49.977%" tts:extent="94.060% 46.667%" tts:displayAlign="before" tts:backgroundColor="#000000" tts:opacity="0.50" tts:showBackgroun
2d="whenActive"/>\n </layout>\n </head>\n <body>\n <div xml:id="d_comments" region="r_comments" style="r_comments_style">';const l=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60),r=Math.floor(e%1*1e3);return"".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"),".").concat(r.toString().padStart(3,"0"))};if(a.length>0){const e=[];a.forEach(t=>{let n=t.content;n=i(n),n=s(n);const a=t.displayName||t.userName||t.userEmail;e.push("[".concat(a,"] ").concat(n)),t.replies&&t.replies.length>0&&t.replies.forEach(t=>{let n=i(t.content);n=s(n);const a=t.displayName||t.userName||t.userEmail;e.push(" \u21b3 [".concat(a,"] ").concat(n))})});const t=e.join("<br/><br/>");let n=30;r.length>0&&void 0!==r[0].timestampSeconds&&(n=Math.min(30,r[0].timestampSeconds)),o+='\n <p begin="00:00:00.000" end="'.concat(l(n),'">[General Notes]<br/>').concat(t,"</p>")}return r.forEach((e,t)=>{if(e.parentCommentId)return;const n=e.timestampSeconds;let a=n+20;const c=r.find((e,a)=>a>t&&!e.parentCommentId&&void 0!==e.timestampSeconds&&e.timestampSeconds>n);c&&c.timestampSeconds<a&&(a=c.timestampSeconds);const d=l(n),u=l(a);let m=e.content;m=i(m),m=s(m);const h=e.displayName||e.userName||e.userEmail,p="[".concat(h,"] ").concat(m);o+='\n <p begin="'.concat(d,'" end="').concat(u,'">').concat(p,"</p>"),e.replies&&e.replies.length>0&&e.replies.forEach(e=>{let t=i(e.content);t=s(t);const n=e.displayName||e.userName||e.userEmail,a=" \u21b3 [".concat(n,"] ").concat(t);o+='\n <p begin="'.concat(d,'" end="').concat(u,'">').concat(a,"</p>")})}),o+="\n </div>\n </body>\n</tt>",o},[D]),at=(0,a.useCallback)(()=>{const e=nt(),n=new Blob([e],{type:"application/xml"}),a=URL.createObjectURL(n),r=document.createElement("a");r.href=a;const s=(new Date).toISOString().replace(/[:.]/g,"-").slice(0,-5);r.download="comments_".concat(t,"_").concat(s,".ttml"),r.click(),URL.revokeObjectURL(a)},[nt,t]),rt=e=>{let{content:t}=e;const n=[];let a=0;const r=/\b(\d{1,2}):(\d{2})(?::(\d{2}))?\b/g;let s,i=0;for(;null!==(s=r.exec(t));){s.index>a&&n.push((0,u.jsx)("span",{children:t.substring(a,s.index)},"text-".concat(i++)));const e=Bw(s[0]);e?n.push((0,u.jsx)("button",{onClick:()=>ze(e.seconds),className:"mx-1 font-mono text-sm text-[#B57700] hover:text-[#8B5B00] underline",title:"Jump to ".concat(e.formattedTime),children:e.originalText},"timestamp-".concat(i++))):n.push((0,u.jsx)("span",{children:s[0]},"text-".concat(i++))),a=s.index+s[0].length}return a<t.length&&n.push((0,u.jsx)("span",{children:t.substring(a)},"text-".concat(i++))),(0,u.jsx)(u.Fragment,{children:n.length>0?n:t})},st=()=>{s||j||k(!w)},it=e=>{e.preventDefault();
2const t=R(),n=(e.clientX-t.originX)*t.pixelsPerClientPixelX,a=(e.clientY-t.originY)*t.pixelsPerClientPixelY;V(!0),q({x:n-z.x,y:a-z.y})};(0,a.useEffect)(()=>{const e=e=>{if(!E)return;const t=R(),n=(e.clientY-t.originY)*t.pixelsPerClientPixelY,a=M-n,r=Math.max(200,Math.min(t.height-100,B+a));F(r)},t=()=>{A(!1)};if(E)return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),document.body.style.cursor="ns-resize",()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t),document.body.style.cursor=""}},[B,M,R,E]),(0,a.useEffect)(()=>{const e=e=>{if(!U)return;const t=R(),n=(e.clientX-t.originX)*t.pixelsPerClientPixelX,a=(e.clientY-t.originY)*t.pixelsPerClientPixelY,r=n-H.x,s=a-H.y,i=Math.max(0,t.width-nk),o=Math.max(0,t.height-N);O({x:Math.max(0,Math.min(i,r)),y:Math.max(0,Math.min(o,s))})},t=()=>{V(!1)};if(U)return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),document.body.style.cursor="move",()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t),document.body.style.cursor=""}},[H,R,U,N]);const ot=e=>{var a,s,o,c;let{comment:m,depth:h}=e;const x=m.replies&&m.replies.length>0,f=ue.has(m.id);return(0,u.jsxs)("div",{className:"".concat(h>0?"ml-8 mt-2":""),id:"comment-".concat(m.id),children:[(0,u.jsx)("div",{className:"".concat(Xe," rounded-xl p-3 ").concat(l===m.id?"ring-2 ring-[#FFB52B]":""),children:(0,u.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,u.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-xs font-medium text-white ".concat(m.avatarColor?"":Ge(m.displayName||m.userName||m.userEmail)),style:m.avatarColor?{backgroundColor:m.avatarColor}:{},children:Ye(m.displayName||m.userName||m.userEmail)}),(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("span",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100 font-headlines",children:m.displayName||m.userName||m.userEmail}),null!==m.timestampSeconds&&void 0!==m.timestampSeconds&&(0,u.jsx)("button",{onClick:()=>ze(m.timestampSeconds),className:"font-mono text-xs text-[#B57700] hover:text-[#8B5B00]",children:Iw(m.timestampSeconds)}),(0,u.jsxs)("span",{className:"flex items-center text-xs ".concat($e),children:[(0,u.jsx)(wp,{size:12,className:"mr-1"}),We(m.createdAt||m.created_at||m.timestamp)]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(!r||r&&(null===y||void 0===y?void 0:y.commentsWrite))&&(0,u.jsx)("button",{onClick:()=>(e=>{ie(e.id),le(e),Y(""),Fe()})(m),className:"p-1 rounded transition-colors ".concat(g?"text-gray-400 hover:text-gray-200 hover:bg-white/8":"text-gray-400 hover:text-gray-600 hover:bg-[rgba(255,255,255,0.42)]"),title:"Reply",children:(0,u.jsx)(Nw,{size:14})}),(0,u.jsx)("button",{onClick:()=>{var e;return Me("pinned_message"===m.type&&(null===(e=m.pinnedContent)||void 0===e?void 0:e.originalMessage)||m.content,m.id)},className:"p-1 rounded transition-colors ".concat(ae===m.id?"".concat(g?"text-[#FFCF74] bg-[#332A17]":"text-[#B57700] bg-[#FFF4D8]"):"".concat(g?"text-gray-400 hover:text-gray-200 hover:bg-white/8":"text-gray-400 hover:text-gray-600 hover:bg-[rgba(255,255,255,0.42)]")),title:"Copy comment to clipboard",children:ae===m.id?(0,u.jsx)(Wm,{size:14}):(0,u.jsx)(Np,{size:14})}),Ue(m)&&(0,u.jsx)("button",{onClick:()=>(async e=>{if(t){J("");try{let a;if(r){if(!n)return void J("Cannot delete comment - share token required");const t=xe();a=await fetch("".concat(tk,"/api/public/share/").concat(n,"/comments/").concat(e),{method:"DELETE",headers:{"X-Anonymous-Session-ID":t||""}})}else{if(!n||!p)throw new Error("Not authorized to delete comment");a=await fetch("".concat(tk,"/api/sessions/").concat(t,"/comments/").concat(e),{method:"DELETE",headers:{Authorization:"Bearer ".concat(n)}})}if(!a.ok)throw new Error("Failed to delete comment");const s=D.filter(t=>t.id!==e);C(s),i&&i(s)}catch(a){console.error("Failed to delete comment:",a),J("Failed to delete comment")}}})(m.id),className:"text-gray-400 hover:text-red-500 transition-colors p-1 rounded ".concat(g?"hover:bg-white/8":"hover:bg-[rgba(255,255,255,0.42)]"),title:"Delete comment",children:(0,u.jsx)(kp,{size:14})})]})]}),"pinned_message"===m.type?(0,u.jsxs)("div",{className:"".concat(g?"bg-[rgba(86,61,14,0.34)] border-yellow-700/70 backdrop-blur-[24px]":"bg-[rgba(255,245,220,0.54)] border-yellow-200/90 backdrop-blur-[22px]"," border rounded-xl p-3"),children:[(0,u.jsxs)("div",{className:"text-xs ".concat(g?"text-yellow-300":"text-yellow-700"," font-medium mb-2 flex items-center"),children:["\ud83d\udccc Pinned from ",null===(a=m.pinnedContent)||void 0===a?void 0:a.model]}),(0,u.jsx)("div",{className:"text-sm ".concat(g?"text-gray-200":"text-gray-700"," ").concat(Xe," rounded-xl p-3 prose prose-sm max-w-none ").concat(g?"prose-invert":""),children:(0,u.jsx)(my,{remarkPlugins:[Cw],components:{p:e=>{let{children:t}=e;return"string"===typeof t?(0,u.jsx)("div",{className:"mb-2 last:mb-0 ".concat(g?"text-gray-200":"text-gray-700"),children:(0,u.jsx)(rt,{content:t})}):(0,u.jsx)("div",{className:"mb-2 last:mb-0 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},ul:e=>{let{children:t}=e;return(0,u.jsx)("ul",{className:"list-disc list-inside mb-2 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},ol:e=>{let{children:t}=e;return(0,u.jsx)("ol",{className:"list-decimal list-inside mb-2 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},li:e=>{let{children:t}=e;return(0,u.jsx)("li",{className:"mb-1 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},h1:e=>{let{children:t}=e;return(0,u.jsx)("h1",{className:"text-base font-bold mb-2 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},h2:e=>{let{children:t}=e;return(0,u.jsx)("h2",{className:"text-sm font-bold mb-2 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},h3:e=>{let{children:t}=e;return(0,u.jsx)("h3",{className:"text-sm font-semibold mb-1 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},strong:e=>{let{children:t}=e;return(0,u.jsx)("strong",{className:"font-semibold ".concat(g?"text-gray-100":"text-gray-800"),children:t})},em:e=>{let{children:t}=e;return(0,u.jsx)("em",{className:"italic ".concat(g?"text-gray-200":"text-gray-700"),children:t})},blockquote:e=>{let{children:t}=e;return(0,u.jsx)("blockquote",{className:"border-l-4 ".concat(g?"border-gray-500 text-gray-300":"border-gray-300 text-gray-700"," pl-4 italic mb-2"),children:t})},code:e=>{let{className:t,children:n}=e,a=T(e,Zw);const r=/language-(\w+)/.exec(t||""),s=!a.node||"pre"!==a.node.tagName;if(!s&&r&&"ttml"===r[1])return null;const i=s?"".concat(g?"bg-white/10 text-gray-200":"bg-[rgba(255,255,255,0.46)] text-gray-800"," px-1 py-0.5 rounded text-xs backdrop-blur-xl"):"block ".concat(g?"bg-white/10 text-gray-200":"bg-[rgba(255,255,255,0.46)] text-gray-800"," p-2 rounded text-xs overflow-x-auto backdrop-blur-xl");return(0,u.jsx)("code",d(d({className:"".concat(t," ").concat(i)},a),{},{children:n}))}},children:Te((null===(s=m.pinnedContent)||void 0===s?void 0:s.originalMessage)||"")})}),(0,u.jsx)(_e,{content:(null===(o=m.pinnedContent)||void 0===o?void 0:o.originalMessage)||"",commentId:m.id})]}):(0,u.jsx)("div",{className:"text-sm ".concat(g?"text-gray-200":"text-gray-700"," prose prose-sm max-w-none ").concat(g?"prose-invert":""),children:(0,u.jsx)(my,{remarkPlugins:[Cw],components:{p:e=>{let{children:t}=e;return"string"===typeof t?(0,u.jsx)("p",{className:"mb-2 last:mb-0 ".concat(g?"text-gray-200":"text-gray-700"),children:(0,u.jsx)(rt,{content:t})}):(0,u.jsx)("p",{className:"mb-2 last:mb-0 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},ul:e=>{let{children:t}=e;return(0,u.jsx)("ul",{className:"list-disc list-inside mb-2 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},ol:e=>{let{children:t}=e;return(0,u.jsx)("ol",{className:"list-decimal list-inside mb-2 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},li:e=>{let{children:t}=e;return(0,u.jsx)("li",{className:"mb-1 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},h1:e=>{let{children:t}=e;return(0,u.jsx)("h1",{className:"text-lg font-bold mb-2 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},h2:e=>{let{children:t}=e;return(0,u.jsx)("h2",{className:"text-base font-bold mb-2 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},h3:e=>{let{children:t}=e;return(0,u.jsx)("h3",{className:"text-sm font-semibold mb-1 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},strong:e=>{let{children:t}=e;return(0,u.jsx)("strong",{className:"font-semibold ".concat(g?"text-gray-100":"text-gray-800"),children:t})},em:e=>{let{children:t}=e;return(0,u.jsx)("em",{className:"italic ".concat(g?"text-gray-200":"text-gray-700"),children:t})},blockquote:e=>{let{children:t}=e;return(0,u.jsx)("blockquote",{className:"border-l-4 ".concat(g?"border-gray-500 text-gray-300":"border-gray-300 text-gray-700"," pl-4 italic mb-2"),children:t})},code:e=>{let{className:t,children:n}=e,a=T(e,ek);const r=!t?"".concat(g?"bg-white/10 text-gray-200":"bg-[rgba(255,255,255,0.46)] text-gray-800"," px-1 py-0.5 rounded text-xs backdrop-blur-xl"):"block ".concat(g?"bg-white/10 text-gray-200":"bg-[rgba(255,255,255,0.46)] text-gray-800"," p-2 rounded text-xs overflow-x-auto backdrop-blur-xl");return(0,u.jsx)("code",d(d({className:r},a),{},{children:n}))},a:e=>{let{children:t,href:n}=e;return(0,u.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-[#B57700] hover:text-[#8B5B00] underline",children:t})}},children:m.content})}),!r&&(0,u.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[null===(c=ce[m.id])||void 0===c?void 0:c.map((e,t)=>{var n;const a=null===(n=e.users)||void 0===n?void 0:n.split(",").map(e=>{const t=e.split("@")[0];return t.charAt(0).toUpperCase()+t.slice(1)}).join(", ");return(0,u.jsxs)("button",{onClick:()=>He(m.id,e.emoji),className:"relative group flex items-center gap-1 px-2 py-1 rounded-full text-xs transition-colors ".concat(e.userReacted?g?"border border-[#445166] bg-[rgba(35,46,63,0.62)] text-[#F4F4F4] hover:bg-[rgba(47,59,78,0.74)] backdrop-blur-xl":"border border-[#
2E7B14C]/45 bg-[#FFF4D8] text-[#8B5B00] hover:bg-[#FFE7AD]":g?"bg-white/8 text-gray-300 hover:bg-white/12 backdrop-blur-xl":"bg-[rgba(255,255,255,0.42)] text-gray-700 hover:bg-[rgba(255,255,255,0.58)] backdrop-blur-[22px]"),title:a||"No users",children:[(0,u.jsx)("span",{children:e.emoji}),(0,u.jsx)("span",{children:e.count}),a&&(0,u.jsxs)("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 text-xs rounded shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 whitespace-nowrap z-50 ".concat(g?"border border-white/10 bg-[rgba(17,27,42,0.58)] text-gray-200 backdrop-blur-[24px]":"border border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.54)] text-[#172033] backdrop-blur-[22px]"),children:[a,(0,u.jsx)("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-l-transparent border-r-4 border-r-transparent border-t-4 ".concat(g?"border-t-gray-900":"border-t-gray-800")})]})]},t)}),(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsx)("button",{onClick:()=>He(m.id,"\ud83d\udc4d"),className:"p-1.5 rounded-full transition-colors ".concat(g?"hover:bg-white/8 text-gray-400 hover:text-gray-200":"hover:bg-[rgba(255,255,255,0.42)] text-gray-500 hover:text-gray-700"),title:"Thumbs up",children:(0,u.jsx)(Fw,{size:14})}),(0,u.jsx)("button",{onClick:()=>He(m.id,"\u2764\ufe0f"),className:"p-1.5 rounded-full transition-colors ".concat(g?"hover:bg-white/8 text-gray-400 hover:text-gray-200":"hover:bg-[rgba(255,255,255,0.42)] text-gray-500 hover:text-gray-700"),title:"Heart",children:(0,u.jsx)(Sw,{size:14})}),(0,u.jsx)("button",{onClick:()=>He(m.id,"\ud83d\ude0a"),className:"p-1.5 rounded-full transition-colors ".concat(g?"hover:bg-white/8 text-gray-400 hover:text-gray-200":"hover:bg-[rgba(255,255,255,0.42)] text-gray-500 hover:text-gray-700"),title:"Smile",children:(0,u.jsx)(Ew,{size:14})})]})]}),x&&(0,u.jsxs)("button",{onClick:()=>{return e=m.id,void me(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e},className:"flex items-center gap-1 mt-2 text-xs ".concat(g?"text-gray-400 hover:text-gray-200":"text-gray-600 hover:text-gray-800"),children:[f?(0,u.jsx)(wd,{size:14}):(0,u.jsx)(bp,{size:14}),(0,u.jsxs)("span",{children:[m.replies.length," ",1===m.replies.length?"reply":"replies"]})]})]})]})}),x&&f&&(0,u.jsx)("div",{className:"mt-2",children:m.replies.map(e=>(0,u.jsx)(ot,{comment:e,depth:h+1},e.id))})]})};if(!t)return null;const lt=!s&&(w||j),ct=s?{height:"576px"}:lt?j?{left:"0.75rem",right:"0.75rem",top:"calc(var(--app-mobile-top-offset) + 0.75rem)",bottom:"calc(var(--app-mobile-bottom-offset) + 0.75rem)"}:void 0:{height:"".concat(N,"px"),left:"".concat(z.x,"px"),top:"".concat(z.y,"px")},dt=e=>{const t=!e&&!s&&!lt,n=e?g?"border-white/10 bg-[radial-gradient(circle_at_12%_18%,rgba(255,181,43,0.08),transparent_22%),linear-gradient(180deg,rgba(17,27,42,0.34),rgba(17,27,42,0.3))] backdrop-blur-[34px]":"border-[#e5ebf2] bg-[radial-gradient(circle_at_12%_18%,rgba(255,181,43,0.08),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.42),rgba(255,255,255,0.38))] backdrop-blur-[32px]":g?"border-white/10 bg-[radial-gradient(circle_at_12%_18%,rgba(255,181,43,0.08),transparent_22%),linear-gradient(180deg,rgba(17,27,42,0.32),rgba(17,27,42,0.28))] backdrop-blur-[34px]":"border-[#e5ebf2] bg-[radial-gradient(circle_at_12%_18%,rgba(255,181,43,0.08),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.4),rgba(255,255,255,0.36))] backdrop-blur-[32px]",a=e?g?"rounded-full border border-white/10 bg-white/[0.05] p-2 text-gray-300 backdrop-blur-[24px]":"rounded-full border border-[#dfe6ef] bg-[rgba(255,255,255,0.34)] p-2 text-[#5b687c] backdrop-blur-[24px]":g?"rounded-xl border border-transparent bg-white/[0.02] p-2 text-gray-400 transition-colors hover:border-white/10 hover:bg-white/[0.07]":"rounded-xl border border-transparent bg-[rgba(255,255,255,0.12)] p-2 text-gray-600 transition-colors hover:border-[#dfe6ef] hover:bg-[rgba(255,255,255,0.34)]";return(0,u.jsxs)("div",{className:"flex shrink-0 items-center justify-between border-b px-4 ".concat(e?"py-3":"py-4"," ").concat(n),onMouseDown:t?it:void 0,style:{cursor:t?"move":"default"},children:[(0,u.jsxs)("div",{className:"flex min-w-0 items-center space-x-3",children:[(0,u.jsx)(ky,{size:20,className:"shrink-0 text-[#B57700] dark:text-[#FFCF74]"}),e?(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(g?"text-[#ffcf74]":"text-[#8a6115]"),children:"Comments"}),(0,u.jsx)("div",{className:"truncate text-sm font-semibold font-headlines ".concat(g?"text-white":"text-[#232E3F]"),children:r?"Public view":"Session comments"}),(0,u.jsxs)("p",{className:"mt-0.5 text-xs ".concat(g?"text-gray-400":"text-gray-600"),children:[D.length," comment",1!==D.length?"s":""," \u2022 Markdown supp
2orted",r&&" \u2022 No account required"]})]}):(0,u.jsxs)("div",{children:[(0,u.jsxs)("h3",{className:"font-semibold font-headlines text-gray-900 dark:text-gray-100",children:["Comments ",w&&"(Fullscreen)"," ",r&&"\u2022 Public View"]}),(0,u.jsxs)("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[D.length," comment",1!==D.length?"s":""," \u2022 Markdown supported",r&&" \u2022 No account required"]})]})]}),(0,u.jsxs)("div",{className:"flex shrink-0 items-center space-x-2",children:[!(null!==y&&void 0!==y&&y.isPublicShare)&&D.length>0&&(0,u.jsx)("button",{onClick:at,className:a,title:"Download comments as TTML",children:(0,u.jsx)(Sp,{size:18})}),!s&&!e&&(0,u.jsx)("button",{onClick:st,className:a,title:w?"Exit fullscreen":"Enter fullscreen",children:w?(0,u.jsx)(jy,{size:18}):(0,u.jsx)(Dy,{size:18})}),(0,u.jsx)("button",{onClick:()=>{null===c||void 0===c||c()},className:a,title:"Close comments",children:(0,u.jsx)(Pu,{size:18})})]})]})},ut=e=>(0,u.jsxs)("div",{ref:we,className:"min-h-0 flex-1 overflow-y-auto p-4 space-y-4 ".concat(g?"bg-[radial-gradient(circle_at_10%_12%,rgba(255,181,43,0.04),transparent_20%),radial-gradient(circle_at_88%_18%,rgba(111,137,182,0.05),transparent_22%)]":"bg-[radial-gradient(circle_at_10%_12%,rgba(255,181,43,0.05),transparent_20%),radial-gradient(circle_at_88%_18%,rgba(111,137,182,0.05),transparent_22%)]"),"data-allow-touch-scroll":"true",style:e?{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain"}:void 0,children:[G&&0===D.length?(0,u.jsxs)("div",{className:"py-8 text-center text-gray-500",children:[(0,u.jsx)(ky,{size:48,className:"mx-auto mb-4 text-gray-300"}),(0,u.jsx)("p",{children:"Loading comments..."})]}):0===D.length?(0,u.jsxs)("div",{className:"py-8 text-center text-gray-500",children:[(0,u.jsx)(ky,{size:48,className:"mx-auto mb-4 text-gray-300"}),(0,u.jsx)("p",{children:"No comments yet"}),(0,u.jsx)("p",{className:"text-sm",children:"Start the conversation!"})]}):Se.map(e=>(0,u.jsx)(ot,{comment:e,depth:0},e.id)),(0,u.jsx)("div",{ref:fe})]}),mt=e=>(0,u.jsx)(S,{children:X&&(0,u.jsx)(Do.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"shrink-0 rounded-lg border p-3 ".concat(g?"border-red-500/35 bg-[rgba(127,29,29,0.32)] backdrop-blur-[20px]":"border-red-200 bg-[rgba(254,242,242,0.56)] backdrop-blur-[18px]"," ").concat(e?"mx-4 mb-3":"mx-4 mb-2"),children:(0,u.jsx)("p",{className:"text-sm text-red-700",children:X})})}),ht=e=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mb-3 flex border-b pb-2 ".concat(e?"flex-wrap items-center gap-2 border-gray-200 dark:border-gray-700":"items-center justify-between border-gray-100 dark:border-gray-700"),children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("button",{onClick:Ze,className:"rounded p-1.5 transition-colors ".concat(g?"text-gray-400 hover:bg-white/8":"text-gray-600 hover:bg-[rgba(255,255,255,0.42)]"),title:"Bold (**text**)",children:(0,u.jsx)(Aw,{size:14})}),(0,u.jsx)("button",{onClick:et,className:"rounded p-1.5 transition-colors ".concat(g?"text-gray-400 hover:bg-white/8":"text-gray-600 hover:bg-[rgba(255,255,255,0.42)]"),title:"Italic (*text*)",children:(0,u.jsx)(Tw,{size:14})}),(0,u.jsx)("button",{onClick:tt,className:"rounded p-1.5 transition-colors ".concat(g?"text-gray-400 hover:bg-white/8":"text-gray-600 hover:bg-[rgba(255,255,255,0.42)]"),title:"Quote (> text)",children:(0,u.jsx)(Mw,{size:14})}),(0,u.jsx)("div",{className:"h-4 w-px ".concat(g?"bg-gray-600":"bg-gray-300")}),(0,u.jsx)("button",{onClick:()=>ee(!Z),className:"rounded p-1.5 transition-colors ".concat(g?"text-gray-400 hover:bg-white/8":"text-gray-600 hover:bg-[rgba(255,255,255,0.42)]"),title:"Markdown help",children:(0,u.jsx)(_w,{size:14})})]}),(0,u.jsx)("span",{className:"text-xs ".concat(e?"ml-auto":""," text-gray-500"),children:"Markdown supported"})]}),(0,u.jsx)(S,{children:Z&&(0,u.jsx)(Do.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"mb-3 rounded-lg p-3 text-xs ".concat(g?"border border-white/10 bg-[rgba(17,27,42,0.34)] text-gray-300 backdrop-blur-[22px]":"border border-[rgba(215,222,233,0.8)] bg-[rgba(255,255,255,0.38)] text-gray-600 backdrop-blur-[20px]"),children:(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("code",{children:"**bold**"})," \u2192 ",(0,u.jsx)("strong",{children:"bold"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("code",{children:"*italic*"})," \u2192 ",(0,u.jsx)("em",{children:"italic"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("code",{children:"`code`"})," \u2192 ",(0,u.jsx)("code",{className:"rounded px-1 ".concat(g?"bg-white/10 backdrop-blur-xl":"bg-[rgba(255,255,255,0.5)] backdrop-blur-[20px]"),children:"code"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("code",{children:"> quote"})," \u2192 blockquote"]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("code",{children:"# Heading"})," \u2192 heading"]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("code",{children:"- list"})," \u2192 bullet list"]})]})})}),se&&oe&&(0,u.jsxs)("div",{className:"mb-3 flex items-center justify-between rounded-xl p-2.5 ".concat(g?"border border-white/10 bg-[rgba(17,27,42,0.34)] backdrop-blur-[22px]":"border border-[rgba(215,222,233,0.8)] bg-[rgba(255,255,255,0.4)] backdrop-blur-[20px]"),children:[(0,u.jsxs)("div",{className:"flex min-w-0 items-center gap-2 text-sm",children:[(0,u.jsx)(Nw,{size:14,className:"shrink-0"}),(0,u.jsxs)("span",{className:"truncate ".concat(g?"text-gray-300":"text-gray-600"),children:["Replying to ",oe.userName||oe.userEmail]})]}),(0,u.jsx)("button",{onClick:Ve,className:"shrink-0 text-xs ".concat(g?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-700"),children:"Cancel"})]}),r&&!p&&(0,u.jsxs)("div",{className:"mb-3",children:[(0,u.jsx)("input",{type:"text",value:te,onChange:e=>ne(e.target.value),onFocus:()=>{ge.current=!0},onBlur:()=>{ge.current=!1},placeholder:"Enter your name here",className:"w-full border text-base focus:border-transparent focus:ring-2 focus:ring-[#FFB52B]/35 ".concat(e?"rounded-2xl px-4 py-3":"rounded-lg p-2"," ").concat(Je),style:e?{fontSize:"16px"}:void 0,"data-allow-touch-scroll":"true",maxLength:50,disabled:G}),(0,u.jsx)("p",{className:"mt-1 text-xs ".concat($e),children:"Leave empty for a random guest name"})]})]}),pt=(0,u.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[dt(!0),ut(!0),mt(!0),(0,u.jsx)("div",{className:"shrink-0 border-t ".concat(g?"border-white/10 bg-[rgba(17,27,42,0.28)] backdrop-blur-[26px]":"border-[#e5ebf2] bg-[rgba(255,255,255,0.34)] backdrop-blur-[24px]"),children:(0,u.jsxs)("div",{className:"px-4 pb-4 pt-3",style:{paddingBottom:"max(1rem, env(safe-area-inset-bottom))"},children:[ht(!0),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsx)("textarea",{ref:ve,value:W,onChange:e=>Y(e.target.value),onFocus:()=>{ge.current=!0},onBlur:()=>{ge.current=!1}
2,onKeyPress:qe,placeholder:se?"Write your reply... (Markdown supported)":r?"Add a public comment... (Markdown supported)":"Add a comment... (Markdown supported)",className:"min-h-[120px] w-full resize-none rounded-2xl border px-4 py-3 text-base shadow-sm focus:border-transparent focus:ring-2 focus:ring-[#FFB52B]/35 ".concat(Je),style:{fontSize:"16px"},"data-allow-touch-scroll":"true",rows:4,disabled:G,enterKeyHint:"send"}),(0,u.jsxs)("button",{onClick:()=>{console.log("[COMMENTS] Send button clicked",{newComment:W.trim(),isLoading:G,disabled:!W.trim()||G}),Oe()},disabled:!W.trim()||G,className:"flex w-full items-center justify-center gap-2 rounded-xl bg-[#FFB52B] px-4 py-3.5 text-sm font-semibold text-[#232E3F] transition-colors hover:bg-[#FFC54D] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,u.jsx)(My,{size:16}),(0,u.jsx)("span",{children:se?"Send reply":"Send comment"})]}),(0,u.jsxs)("div",{className:"flex flex-col gap-1 text-xs ".concat($e),children:[(0,u.jsxs)("span",{children:["Auto-refresh: ",$?"Paused (idle)":"Active"]}),(0,u.jsx)("span",{children:"Press Enter + Shift for new line, Enter to send"})]})]})]})})]}),gt=(0,u.jsxs)(u.Fragment,{children:[dt(!1),ut(!1),mt(!1),(0,u.jsxs)("div",{className:"shrink-0 border-t ".concat(g?"border-white/10 bg-[radial-gradient(circle_at_16%_14%,rgba(255,181,43,0.05),transparent_22%),linear-gradient(180deg,rgba(17,27,42,0.22),rgba(17,27,42,0.2))] backdrop-blur-[30px]":"border-[#e5ebf2] bg-[radial-gradient(circle_at_16%_14%,rgba(255,181,43,0.05),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.28),rgba(255,255,255,0.26))] backdrop-blur-[26px]"),children:[(0,u.jsxs)("button",{onClick:()=>L(!P),className:"flex w-full items-center justify-center gap-2 p-2 transition-colors ".concat(g?"text-gray-400 hover:bg-white/8":"text-gray-600 hover:bg-[rgba(255,255,255,0.42)]"),title:P?"Expand input area":"Collapse input area",children:[P?(0,u.jsx)(bp,{size:16}):(0,u.jsx)(wd,{size:16}),(0,u.jsx)("span",{className:"text-xs",children:P?"Show input":"Hide input"})]}),!P&&(0,u.jsxs)("div",{className:"p-4",children:[ht(!1),(0,u.jsxs)("div",{className:"flex space-x-2",children:[(0,u.jsx)("textarea",{ref:ve,value:W,onChange:e=>Y(e.target.value),onFocus:()=>{ge.current=!0},onBlur:()=>{ge.current=!1}
2,onKeyPress:qe,placeholder:se?"Write your reply... (Markdown supported)":r?"Add a public comment... (Markdown supported)":"Add a comment... (Markdown supported)",className:"flex-1 resize-none rounded-lg border p-3 text-base focus:border-transparent focus:ring-2 focus:ring-[#FFB52B]/35 ".concat(Je," ").concat(lt?"min-h-[120px]":"min-h-[80px]"),"data-allow-touch-scroll":"true",rows:lt?4:3,disabled:G}),(0,u.jsx)("button",{onClick:()=>{console.log("[COMMENTS] Send button clicked",{newComment:W.trim(),isLoading:G,disabled:!W.trim()||G}),Oe()},disabled:!W.trim()||G,className:"flex items-center rounded-lg bg-[#FFB52B] px-4 py-3 text-[#232E3F] transition-colors hover:bg-[#FFC54D] disabled:cursor-not-allowed disabled:opacity-50",children:(0,u.jsx)(My,{size:16})})]}),(0,u.jsxs)("div",{className:"mt-2 flex justify-between text-xs ".concat($e),children:[(0,u.jsxs)("span",{children:["Auto-refresh: ",$?"Paused (idle)":"Active"]}),(0,u.jsx)("span",{children:"Press Enter + Shift for new line, Enter to send"})]})]})]})]});return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(S,{children:j?(0,u.jsx)("div",{className:"fixed inset-x-0 z-[90] flex min-h-0 flex-col ".concat(g?"bg-[rgba(17,27,42,0.54)] backdrop-blur-[32px]":"bg-[rgba(255,255,255,0.52)] backdrop-blur-[30px]"),"data-allow-touch-scroll":"true",style:{top:"var(--app-mobile-top-offset)",bottom:"var(--app-mobile-bottom-offset)",overscrollBehavior:"contain"},children:pt}):(0,u.jsxs)(Do.div,{initial:{opacity:0,x:s||lt?0:400,scale:lt?.95:1},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:s||lt?0:400,scale:lt?.95:1},className:"".concat(s?"relative w-full":"fixed z-50"," ").concat(Ke," flex min-h-0 flex-col ").concat(s?"rounded-lg":lt?"inset-4 rounded-xl":"w-[480px] rounded-lg shadow-2xl"),style:ct,"data-allow-touch-scroll":"true",children:[!s&&!lt&&(0,u.jsx)("div",{className:"absolute top-0 left-0 right-0 h-1 cursor-ns-resize z-40 ".concat(g?"hover:bg-[#FFCF74]/70":"hover:bg-[#FFB52B]"," ").concat(E?"bg-[#FFB52B]":""," transition-colors"),onMouseDown:e=>{e.preventDefault();const t=R(),n=(e.clientY-t.originY)*t.pixelsPerClientPixelY;A(!0),_(n),I(N)},title:"Drag to resize panel height"}),gt]})}),(0,u.jsx)("script",{dangerouslySetInnerHTML:{__html:"\n window.addPinnedMessage = function(originalMessage, model) {\n if (window.commentsRef && window.commentsRef.addPinnedMessage) {\n window.commentsRef.addPinnedMessage(originalMessage, model);\n }\n };\n "}})]})},rk=a.memo(ak,(e,t)=>e.sessionId===t.sessionId&&e.token===t.token&&e.isPublicView===t.isPublicView&&e.isInline===t.isInline&&e.pendingTimestamp===t.pendingTimestamp&&e.selectedCommentId===t.selectedCommentId&&e.disablePolling===t.disablePolling&&e.initialComments===t.initialComments),sk=Mo("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),ik=Mo("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),ok=e=>{let{sessionId:t,sessionContext:n,onSessionContextUpdate:r,className:s=""}=e;const{token:i}=am(),[o,l]=(0,a.useState)(!1),[c,m]=(0,a.useState)(""),[h,p]=(0,a.useState)([]),[g,x]=(0,a.useState)(!1),[f,b]=(0,a.useState)(!1),[y,v]=(0,a.useState)(null),w=(0,a.useCallback)(async e=>{if(i)try{x(!!e);const a=(await Vm.listSessions(i,e,10)).filter(e=>e.sessionId!==t&&!n.some(t=>t.sessionId===e.sessionId));p(a),v(null)}catch(a){console.error("Failed to load sessions:",a),v("Failed to load sessions")}finally{x(!1)}},[i,t,n]);(0,a.useEffect)(()=>{if(o){const e=setTimeout(()=>{c?w(c):w()},300);return()=>clearTimeout(e)}},[c,w,o]);const k=e=>e<1e3?"".concat(e," words"):e<1e6?"".concat((e/1e3).toFixed(1),"k words"):"".concat((e/1e6).toFixed(1),"M words"),j=e=>"".concat(e.substring(0,8),"..."),D=n.filter(e=>e.includedInContext).length;return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-700 ".concat(s),children:[(0,u.jsxs)("button",{onClick:()=>l(!o),className:"w-full flex items-center justify-between p-3 text-left hover:bg-gray-100 dark:hover:bg-gray-600 rounded-lg transition-colors",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Session Context"}),n.length>0&&(0,u.jsx)("div",{className:"flex items-center space-x-1 text-xs text-gray-500",children:(0,u.jsxs)("span",{children:[D,"/",n.length," sessions in context"]})})]}),(0,u.jsx)("div",{className:"flex items-center space-x-2",children:o?(0,u.jsx)(Tu,{size:16}):(0,u.jsx)(wd,{size:16})})]}),(0,u.jsx)(S,{children:o&&(0,u.jsx)(Do.div,{initial:{height:0,opacity:0}
2,animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:(0,u.jsxs)("div",{className:"p-3 pt-0 space-y-4",children:[(0,u.jsx)("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:"Include other sessions in your chat context. Their transcripts and TTML files will be available to the AI for analysis and comparison."}),n.length>0&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Sessions in Context (",n.length,")"]}),(0,u.jsxs)("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[D," enabled"]})]}),(0,u.jsx)("div",{className:"space-y-2 max-h-48 overflow-y-auto",children:n.map(e=>(0,u.jsx)(Do.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"p-3 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 transition-all ".concat(e.includedInContext?"border-primary-300 dark:border-primary-600 bg-primary-50 dark:bg-primary-900/20":"opacity-60"),children:(0,u.jsxs)("div",{className:"flex items-start justify-between",children:[(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[e.isYouTubeMode?(0,u.jsx)(Au,{className:"h-3 w-3 text-red-500 flex-shrink-0"}):(0,u.jsx)(_o,{className:"h-3 w-3 text-primary-600 flex-shrink-0"}),(0,u.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title})]}),e.filename!==e.title&&(0,u.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2 truncate",children:e.filename}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500 dark:text-gray-400",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(sk,{className:"h-2 w-2"}),(0,u.jsx)("span",{children:j(e.sessionId)})]}),e.speakerCount>0&&(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(fh,{className:"h-2 w-2"}),(0,u.jsxs)("span",{children:[e.speakerCount," speaker",1!==e.speakerCount?"s":""]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(gp,{className:"h-2 w-2"}),(0,u.jsx)("span",{children:k(e.wordCount)})]})]}),e.speakerNames.length>0&&(0,u.jsx)("div",{className:"mt-2",children:(0,u.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.speakerNames.slice(0,2).map((e,t)=>(0,u.jsx)("span",{className:"inline-block px-1.5 py-0.5 text-xs bg-primary-100 dark:bg-primary-900 text-primary-800 dark:text-primary-200 rounded-full",children:e},t)),e.speakerNames.length>2&&(0,u.jsxs)("span",{className:"inline-block px-1.5 py-0.5 text-xs bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 rounded-full",children:["+",e.speakerNames.length-2]})]})})]}),(0,u.jsxs)("div",{className:"ml-3 flex items-center space-x-1",children:[(0,u.jsx)("button",{onClick:()=>(async(e,a)=>{if(i)try{if((await Vm.toggleSessionContextInclusion(t,e,a,i)).success){const t=n.map(t=>t.sessionId===e?d(d({},t),{},{includedInContext:a}):t);r(t),v(null)}}catch(s){console.error("Failed to toggle session context inclusion:",s),v("Failed to update context: ".concat(s instanceof Error?s.message:"Unknown error"))}})(e.sessionId,!e.includedInContext),className:"p-1 rounded transition-colors ".concat(e.includedInContext?"text-brand-yellow hover:bg-[#fff3d6] dark:hover:bg-brand-yellow/15":"text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"),title:e.includedInContext?"Exclude from context":"Include in context",children:e.includedInContext?(0,u.jsx)(Cp,{size:14}):(0,u.jsx)(Fy,{size:14})}),(0,u.jsx)("button",{onClick:()=>(async e=>{if(i)try{if((await Vm.removeSessionFromContext(t,e,i)).success){const t=n.filter(t=>t.sessionId!==e);r(t),o&&w(c||void 0),v(null)}}catch(a){console.error("Failed to remove session from context:",a),v("Failed to remove session: ".concat(a instanceof Error?a.message:"Unknown error"))}})(e.sessionId),className:"p-1 text-red-400 hover:bg-red-100 dark:hover:bg-red-900/20 rounded transition-colors",title:"Remove from context list",children:(0,u.jsx)(kp,{size:14})})]})]})},e.sessionId))})]}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Add Sessions to Context"}),(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(Mu,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-3 w-3 text-gray-400"}),(0,u.jsx)("input",{type:"text",placeholder:"Search by filename, title, session ID, or speaker name...",value:c,onChange:e=>m(e.target.value),className:"w-full pl-8 pr-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400 focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition-all duration-200"}),g&&(0,u.jsx)("div",{className:"absolute right-3 top-1/2 transform -translate-y-1/2",children:(0,u.jsx)(Lo,{className:"animate-spin h-3 w-3 text-gray-400"})})]}),h.length>0&&(0,u.jsx)("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:h.map(e=>(0,u.jsx)(Do.div,{initial:{opacity:0,y:10}
2,animate:{opacity:1,y:0},className:"group cursor-pointer",children:(0,u.jsx)("div",{className:"p-3 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 hover:border-primary-300 dark:hover:border-primary-600 hover:bg-primary-50 dark:hover:bg-primary-900/20 transition-all duration-200",children:(0,u.jsxs)("div",{className:"flex items-start justify-between",children:[(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[e.isYouTubeMode?(0,u.jsx)(Au,{className:"h-3 w-3 text-red-500 flex-shrink-0"}):(0,u.jsx)(_o,{className:"h-3 w-3 text-primary-600 flex-shrink-0"}),(0,u.jsx)("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:e.title})]}),e.filename!==e.title&&(0,u.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1 truncate",children:e.filename}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500 dark:text-gray-400",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(sk,{className:"h-2 w-2"}),(0,u.jsx)("span",{children:j(e.sessionId)})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(wp,{className:"h-2 w-2"}),(0,u.jsx)("span",{children:e.timeAgo})]}),e.speakerCount>0&&(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(fh,{className:"h-2 w-2"}),(0,u.jsxs)("span",{children:[e.speakerCount," speaker",1!==e.speakerCount?"s":""]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(gp,{className:"h-2 w-2"}),(0,u.jsx)("span",{children:k(e.wordCount)})]})]}),e.speakerNames.length>0&&(0,u.jsx)("div",{className:"mt-1",children:(0,u.jsxs)("div",{className:"flex flex-wrap gap-1",children:[e.speakerNames.slice(0,2).map((e,t)=>(0,u.jsx)("span",{className:"inline-block px-1.5 py-0.5 text-xs bg-primary-100 dark:bg-primary-900 text-primary-800 dark:text-primary-200 rounded-full",children:e},t)),e.speakerNames.length>2&&(0,u.jsxs)("span",{className:"inline-block px-1.5 py-0.5 text-xs bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 rounded-full",children:["+",e.speakerNames.length-2]})]})})]}),(0,u.jsx)("div",{className:"ml-3 flex-shrink-0",children:(0,u.jsxs)("button",{onClick:()=>(async e=>{if(i){b(!0);try{const a=await Vm.addSessionToContext(t,e.sessionId,i);if(a.success){const t=[...n,a.contextItem];r(t),p(t=>t.filter(t=>t.sessionId!==e.sessionId)),v(null)}}catch(a){console.error("Failed to add session to context:",a),v("Failed to add session: ".concat(a instanceof Error?a.message:"Unknown error"))}finally{b(!1)}}})(e),disabled:f,className:"flex items-center space-x-1 px-2 py-1 bg-primary-600 text-white rounded text-xs hover:bg-primary-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",title:"Add to context",children:[f?(0,u.jsx)(Lo,{className:"animate-spin h-3 w-3"}):(0,u.jsx)(ik,{size:12}),(0,u.jsx)("span",{children:"Add"})]})})]})})},e.sessionId))}),0===h.length&&!g&&c&&(0,u.jsx)("div",{className:"text-center py-4 text-gray-500 dark:text-gray-400",children:(0,u.jsxs)("p",{className:"text-sm",children:['No sessions found matching "',c,'"']})}),0===h.length&&!g&&!c&&(0,u.jsx)("div",{className:"text-center py-4 text-gray-500 dark:text-gray-400",children:(0,u.jsx)("p",{className:"text-sm",children:"Search for sessions to add to context"})})]}),y&&(0,u.jsx)("div",{className:"text-red-600 dark:text-red-400 text-sm bg-red-50 dark:bg-red-900/20 p-2 rounded",children:y})]})})})]})},lk=Mo("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}
2],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]),ck=Mo("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),dk=Mo("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]),uk=e=>{let{conversations:t,activeConversationId:n,isCollapsed:r,onToggleCollapse:s,onSelectConversation:i,onCreateConversation:o,onDeleteConversation:l,onRenameConversation:c,onGenerateConversationName:d,onDuplicateConversation:m,onTogglePinConversation:h,onBatchGenerate:p,isGeneratingName:g,isReadOnly:x=!1,activeJobs:f=new Map}=e;const[b,y]=(0,a.useState)(null),[v,w]=(0,a.useState)(""),k=()=>{b&&v.trim()&&c(b,v.trim()),y(null),w("")},j=e=>{const t=(new Date).getTime()-new Date(e).getTime(),n=Math.floor(t/6e4),a=Math.floor(t/36e5),r=Math.floor(t/864e5);return n<1?"Just now":n<60?"".concat(n,"m ago"):a<24?"".concat(a,"h ago"):r<7?"".concat(r,"d ago"):new Date(e).toLocaleDateString()},D=e=>{const t=e.messages[e.messages.length-1];if(!t)return"No messages yet";const n=t.content;return n.length>50?n.substring(0,50)+"...":n},C=e=>{const t=e.chatSettings;if(!t)return null;const n=[];return t.enableWebSearch&&n.push((0,u.jsx)("div",{title:"Web Search Enabled",children:(0,u.jsx)(Mu,{className:"w-3 h-3 text-[#B57700]"})},"search")),t.uploadedFiles&&t.uploadedFiles.length>0&&n.push((0,u.jsx)("div",{title:"".concat(t.uploadedFiles.length," Files Uploaded"),children:(0,u.jsx)(gp,{className:"w-3 h-3 text-[#232E3F] dark:text-[#FFCF74]"})},"files")),t.selectedModel&&"gpt-4o"!==t.selectedModel&&n.push((0,u.jsx)("div",{title:"Model: ".concat(t.selectedModel),children:(0,u.jsx)(lk,{className:"w-3 h-3 text-red-500"})},"model")),n.length>0?(0,u.jsx)("div",{className:"flex items-center space-x-1",children:n}):null};return r?(0,u.jsxs)("div",{className:"w-12 bg-gray-50 dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700 flex flex-col",children:[(0,u.jsx)("button",{onClick:s,className:"p-3 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border-b border-gray-200 dark:border-gray-700",title:"Expand conversations",children:(0,u.jsx)(bp,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),!x&&(0,u.jsx)("button",{onClick:o,className:"p-3 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors text-primary-600 dark:text-primary-400",title:"New conversation",children:(0,u.jsx)(ik,{className:"w-4 h-4"})}),(0,u.jsx)("div",{className:"flex-1 flex flex-col space-y-1 px-1 py-2",children:t.map(e=>(0,u.jsxs)("button",{onClick:()=>i(e.id),className:"p-2 rounded transition-colors relative ".concat(n===e.id?"bg-primary-100 dark:bg-primary-900":"hover:bg-gray-100 dark:hover:bg-gray-700"),title:e.name,children:[(0,u.jsx)(ky,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}),e.messages.length>0&&(0,u.jsx)("div",{className:"absolute -top-1 -right-1 h-3 w-3 rounded-full bg-[#FFB52B] text-xs"})]},e.id))})]}):(0,u.jsxs)("div",{className:"w-80 bg-gray-50 dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700 flex flex-col",children:[(0,u.jsx)("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Conversations"}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[!x&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:o,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors text-primary-600 dark:text-primary-400",title:"New conversation",children:(0,u.jsx)(ik,{className:"w-4 h-4"})}),p&&(0,u.jsx)("button",{onClick:p,className:"rounded p-2 text-[#232E3F] transition-colors hover:bg-gray-100 dark:text-[#FFCF74] dark:hover:bg-gray-700",title:"Batch generate conversations",children:(0,u.jsx)(ck,{className:"w-4 h-4"})})]}),(0,u.jsx)("button",{onClick:s,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",title:"Collapse sidebar",children:(0,u.jsx)(dk,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})})]})]})}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===t.length?(0,u.jsxs)("div",{className:"p-4 text-center text-gray-500 dark:text-gray-400",children:[(0,u.jsx)(ky,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),(0,u.jsx)("p",{className:"text-sm",children:"No conversations yet"}),!x&&(0,u.jsx)("button",{onClick:o,className:"mt-2 text-sm text-primary-600 dark:text-primary-400 hover:underline",children:"Start your first conversation"})]}):(0,u.jsx)("div",{className:"p-2 space-y-3",children:(e=>{const t=e.sort((e,t)=>
2new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()),n={};t.forEach(e=>{const t=(e=>{const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=new Date(n.getTime()-864e5),r=new Date(n.getTime()-6048e5),s=new Date(new Date(e).getFullYear(),new Date(e).getMonth(),new Date(e).getDate());if(s.getTime()===n.getTime())return"Today";if(s.getTime()===a.getTime())return"Yesterday";if(s>=r)return s.toLocaleDateString("en-US",{weekday:"long"});return s.getFullYear()===t.getFullYear()?s.toLocaleDateString("en-US",{month:"long",day:"numeric"}):s.toLocaleDateString("en-US",{year:"numeric",month:"short"})})(e.createdAt);n[t]||(n[t]=[]),n[t].push(e)});const a=["Today","Yesterday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];return Object.entries(n).sort((e,t)=>{let[n]=e,[r]=t;const s=a.indexOf(n),i=a.indexOf(r);return-1!==s&&-1!==i?s-i:-1!==s?-1:-1!==i?1:r.localeCompare(n)})})(t).map(e=>{let[a,r]=e;return(0,u.jsxs)("div",{className:"space-y-1",children:[(0,u.jsx)("div",{className:"px-2 py-1 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:a}),r.map(e=>{var a;return(0,u.jsxs)("div",{className:"group relative rounded-lg border transition-colors ".concat(n===e.id?"bg-primary-50 dark:bg-primary-800/30 border-primary-200 dark:border-primary-600":"bg-white dark:bg-gray-700 border-gray-200 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"),children:[b===e.id?(0,u.jsx)("div",{className:"p-3",children:(0,u.jsx)("input",{type:"text",value:v,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&k(),"Escape"===e.key&&(y(null),w(""))},onBlur:k,className:"w-full p-1 text-sm border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded focus:ring-2 focus:ring-primary-500 focus:border-transparent",autoFocus:!0})}):(0,u.jsx)("button",{onClick:()=>i(e.id),className:"w-full p-3 text-left bg-transparent border-none focus:outline-none focus:ring-0",children:(0,u.jsx)("div",{className:"flex items-start justify-between",children:(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("h3",{className:"text-sm font-medium truncate ".concat(n===e.id?"text-gray-900 dark:text-white":"text-gray-900 dark:text-gray-100"),children:e.name}),f.has(e.id)&&(0,u.jsx)("div",{className:"flex-shrink-0",title:"Processing".concat("pending"===(null===(a=f.get(e.id))||void 0===a?void 0:a.status)?" (queued)":"","..."),children:(0,u.jsx)(Lo,{className:"h-3 w-3 animate-spin text-[#FFB52B]"})}),(0,u.jsx)("div",{className:"flex-shrink-0",children:C(e)})]}),(0,u.jsx)("p",{className:"text-xs mt-1 truncate ".concat(n===e.id?"text-gray-600 dark:text-gray-100":"text-gray-500 dark:text-gray-400"),children:D(e)}),(0,u.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,u.jsx)("span",{className:"text-xs ".concat(n===e.id?"text-gray-500 dark:text-gray-200":"text-gray-400 dark:text-gray-500"),children:j(e.updatedAt)}),(0,u.jsxs)("span",{className:"text-xs ".concat(n===e.id?"text-gray-500 dark:text-gray-200":"text-gray-400 dark:text-gray-500"),children:[e.messages.length," messages"]})]})]})})}),b!==e.id&&!x&&(0,u.jsxs)("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity flex space-x-1",children:[(0,u.jsx)("button",{onClick:t=>{t.stopPropagation(),d(e.id)},disabled:g===e.id,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors",title:"Generate AI name",children:g===e.id?(0,u.jsx)("div",{className:"w-3 h-3 border border-gray-400 border-t-transparent rounded-full animate-spin"}):(0,u.jsx)(Po,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"})}),(0,u.jsx)("button",{onClick:t=>{t.stopPropagation(),(e=>{y(e.id),w(e.name)})(e)},className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors",title:"Rename conversation",children:(0,u.jsx)(Ro,{className:"w-3 h-3 text-gray-500 dark:text-gray-400"})}),(0,u.jsx)("button",{onClick:n=>{n.stopPropagation();const a=1===t.length?"Delete this conversation? A new empty conversation will be created.":"Delete this conversation? This action cannot be undone.";window.confirm(a)&&l(e.id)},className:"p-1 hover:bg-red-200 dark:hover:bg-red-900 rounded transition-colors",title:"Delete conversation",children:(0,u.jsx)(kp,{className:"w-3 h-3 text-red-500 dark:text-red-400"})})]})]},e.id)})]},a)})})})]})};var mk=n(119);const hk=[{id:"main-topics",label:"What are the main topics?",prompt:"What are the main topics discu
2ssed?",category:"analysis",color:"gray"},{id:"summarize",label:"Summarize this content",prompt:"Summarize this content in bullet points",category:"analysis",color:"gray"},{id:"external-references",label:"External references for visuals",prompt:"List external references made which we should show visuals for",category:"analysis",color:"gray"},{id:"table-of-contents",label:"Table of contents",prompt:"Can you create a table of contents using only HH:MM:SS (not using timecode links), dont be too verbose, about 6-7 items per hour, less is more, be concise with the title names",category:"analysis",color:"gray"},{id:"custom-vocab",label:"Custom Vocabulary",prompt:"Give me a custom vocab in comma delimited format for words in this show likely to be mistranscribed, note that our show is MLST, our Sponsor is Tufa AI Labs (lab director Benjamin Crouzier)",category:"analysis",color:"gray"},{id:"top-5-improvements",label:"Top 5 improvements",prompt:"Suggest the top 5 actions to improve the show",category:"improvements",color:"green"},{id:"lessons-clips",label:"Lessons & clip ideas",prompt:"Analyze this published video's YouTube performance to extract lessons learned. Focus on: 1) What worked well and why (high retention segments, engagement spikes), 2) What didn't work and why (drop-off points, low engagement), 3) Identify the strongest moments that could be repurposed as YouTube Shorts or Twitter mid-forms - use the topic map to find thematic clips from different parts of the show. For each clip suggestion, explain how to frame/present it for maximum impact. The goal is learning from this video's performance to improve future content.",category:"improvements",color:"green"},{id:"top-5-trimming",label:"Top 5 trimming recommendations",prompt:"Provide top 5 recommendations for trimming content - identify specific segments to cut to improve pacing and viewer engagement",category:"improvements",color:"green"},{id:"top-5-rearranging",label:"Top 5 re-arranging recommendations",prompt:"Provide top 5 recommendations for re-arranging content - suggest better sequencing and flow to maximize impact and viewer retention",category:"improvements",color:"green"},{id:"youtube-shorts",label:"5 YouTube Shorts candidates",prompt:"Give me 5 suggested YouTube short candidates, comprised of subclips, hook, title and visuals to display",category:"improvements",color:"green"},{id:"youtube-retention",label:"YouTube retention/stats analysis",prompt:"Perform a detailed analysis of the YouTube retention and stats on this video. Analyze the retention curve, identify where viewers drop off, correlate with the transcript content at those timestamps, and provide insights on what's working and what's not.",category:"youtube",color:"red"},{id:"narrative-analysis",label:"Perform narrative analysis with improvements",prompt:"Perform a narrative analysis on the content with suggestions on improvements",category:"narrative",color:"purple"},{id:"captivating-story",label:"How to edit into a captivating story",prompt:"How could I edit this into a captivating story, give suggestions",category:"narrative",color:"purple"},{id:"viral-titles",label:"20 viral titles and thumbnail concepts",prompt:"Please come up with 20 viral titles and thumbnail concepts for YouTube",category:"narrative",color:"purple"},{id:"synopsis",label:"Synopsis with guest names",prompt:"Can you generate a synopsis of the show in simple relatable language, starting with the guests names",category:"narrative",color:"purple"},{id:"weakest-parts",label:"Weakest parts for YouTube tech audience",prompt:"What are the weakest parts of this content for YouTube technical audience?",category:"critical",color:"red"},{id:"factual-accuracy",label:"Critically appraise for factual accuracy",prompt:"Can you critically appraise the content for factual accuracy",category:"critical",color:"red"},{id:"weak-questions",label:"Critique weak questions & errors",prompt:"Can you critically appraise weak questions and point out anything the hosts said which is wrong or embarrassing",category:"critical",color:"red"},{id:"host-critique",label:"Critique host contributions & suggest trims",prompt:"Critically appraise all of the host's questions and contributions for factual correctness. Identify any errors, misunderstandings, or weak points. Also provide specific suggestions on how to trim down the host's contributions to improve pacing and keep focus on the guest's expertise. Be direct and constructive.",category:"critical",color:"red"},{id:"editing-markers",label:"Find editing markers (stumbles, interruptions)",prompt:'Search through the transcript and find all instances where: 1) Someone says "let\'s edit that out" or similar phrases indicating content should be removed, 2) There are obvious stumbles, false starts, or someone asking to restart, 3) There are interruptions or talking over each other, 4) Someone says "the guest" when referring to themselves (third person mistakes), 5) Any "um", "uh", long pauses, or filler words that indicate potential edit points. For each instance, provide the timecode and a brief description of what was said.',category:"editing",color:"orange"},{id:"visual-opportunities",label:"Find visual/B-roll opportunities",prompt:'Search through the transcript and identify all moments where adding a visual, image, diagram, or B-roll would significantly enhance viewer understanding. Look for:\n\n1. **Papers & Publications**: When a specific research paper, study, or publication is mentioned by name or author\n2. **Books**: Any book titles, authors, or specific chapters referenced\n3. **Diagrams & Figures**: When someone describes a figure, chart, graph, or visual concept from their work\n4. **Algorithms & Code**: When specific algorithms, equations, code snippets, or technical implementations are explained\n5. **Products & Tools**: Specific software, hardware, websites, or tools mentioned\n6. **People**: When notable researchers, scientists, or public figures are discussed\n7. **Concepts**: Complex technical concepts that would benefit from a visual explanation\n8. **Historical Events**: References to historical moments, experiments, or breakthroughs\n9. **Organizations**: Companies, labs, universities, or institutions mentioned\n\nFor each opportunity, provide as a list:\n- HH:M
2M:SS - [Brief context of what\'s being discussed] \u2192 Suggested visual: [Specific description of what to show]\n\nBe specific about what visual would help - don\'t just say "add an image", describe exactly what should be shown (e.g., "Screenshot of the GPT-4 paper abstract", "Photo of Geoffrey Hinton", "Diagram of transformer attention mechanism").',category:"visuals",color:"blue"},{id:"sensitivity-analysis",label:"Corporate/PR sensitivity analysis",prompt:"Run corporate/PR/comms sensitivity analysis: identify confidential information, legal risks, ethical concerns, or anything likely to get blocked in review",category:"sensitivity",color:"yellow"}],pk={analysis:"Analysis & Questions",improvements:"Improvements & Recommendations",youtube:"YouTube Analysis",narrative:"Narrative Analysis",critical:"Critical Issues",editing:"Editing Markers",visuals:"Visual Opportunities",sensitivity:"Sensitivity Analysis"},gk={gray:{bg:"bg-gray-100 dark:bg-gray-700",hover:"hover:bg-gray-200 dark:hover:bg-gray-600",border:"border-gray-300 dark:border-gray-600",text:"text-gray-700 dark:text-gray-300"},green:{bg:"bg-[#FFF4D8] dark:bg-[#332A17]",hover:"hover:bg-[#FFE7AD] dark:hover:bg-[#43331B]",border:"border-[#
2E7B14C] dark:border-[#8E6E33]",text:"text-[#8B5B00] dark:text-[#FFE3A1]"},red:{bg:"bg-red-100 dark:bg-red-800",hover:"hover:bg-red-200 dark:hover:bg-red-700",border:"border-red-300 dark:border-red-600",text:"text-red-700 dark:text-red-200"},purple:{bg:"bg-[#EEF1F3] dark:bg-[#232E3F]",hover:"hover:bg-[#E1E7EE] dark:hover:bg-[#2F3B4E]",border:"border-[#445166] dark:border-[#556274]",text:"text-[#232E3F] dark:text-[#F4F4F4]"},yellow:{bg:"bg-yellow-100 dark:bg-yellow-800",hover:"hover:bg-yellow-200 dark:hover:bg-yellow-700",border:"border-yellow-300 dark:border-yellow-600",text:"text-yellow-700 dark:text-yellow-200"},orange:{bg:"bg-orange-100 dark:bg-orange-800",hover:"hover:bg-orange-200 dark:hover:bg-orange-700",border:"border-orange-300 dark:border-orange-600",text:"text-orange-700 dark:text-orange-200"},blue:{bg:"bg-[#EEF1F3] dark:bg-[#232E3F]",hover:"hover:bg-[#E1E7EE] dark:hover:bg-[#2F3B4E]",border:"border-[#445166] dark:border-[#556274]",text:"text-[#232E3F] dark:text-[#F4F4F4]"}},xk=e=>{let{isOpen:t,onClose:n,onGenerate:r,selectedModel:s,isStarting:i=!1}=e;const[o,l]=(0,a.useState)(new Set),c=hk.reduce((e,t)=>(e[t.category]||(e[t.category]=[]),e[t.category].push(t),e),{});return t?mk.createPortal((0,u.jsx)(S,{children:t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:.5},exit:{opacity:0},className:"fixed inset-0 bg-black z-[9998]",onClick:n}),(0,u.jsx)(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"fixed inset-0 flex items-center justify-center z-[9999] p-4",children:(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-3xl w-full max-h-[90vh] overflow-hidden flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Batch Generate Conversations"}),(0,u.jsx)("button",{onClick:n,disabled:i,className:"p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",children:(0,u.jsx)(Pu,{className:"w-5 h-5"})})]}),(0,u.jsxs)("div",{className:"flex-1 overflow-y-auto p-4",children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Select conversation starters to generate. Each will create a separate conversation."}),(0,u.jsxs)("div",{className:"flex gap-2",children:[(0,u.jsx)("button",{onClick:()=>{l(new Set(hk.map(e=>e.id)))},className:"rounded px-2 py-1 text-xs bg-[#FFF4D8] text-[#8B5B00] hover:bg-[#FFE7AD] dark:bg-[#332A17] dark:text-[#FFE3A1] dark:hover:bg-[#43331B]",children:"Select All"}),(0,u.jsx)("button",{onClick:()=>{l(new Set)},className:"text-xs px-2 py-1 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-600",children:"Deselect All"})]})]}),Object.entries(c).map(e=>{let[t,n]=e;return(0,u.jsxs)("div",{className:"mb-4",children:[(0,u.jsx)("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:pk[t]||t}),(0,u.jsx)("div",{className:"space-y-2",children:n.map(e=>{const t=o.has(e.id),n=gk[e.color];return(0,u.jsx)("button",{onClick:()=>(e=>{const t=new Set(o);t.has(e)?t.delete(e):t.add(e),l(t)})(e.id),className:"w-full text-left px-3 py-2 rounded-lg border transition-all ".concat(t?"".concat(n.bg," ").concat(n.border," ring-2 ring-offset-1 ring-[#FFB52B]"):"bg-white dark:bg-gray-700 ".concat(n.border," ").concat(n.hover)),children:(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("div",{className:"w-5 h-5 rounded border flex items-center justify-center ".concat(t?"bg-[#FFB52B] border-[#FFB52B]":"border-gray-300 dark:border-gray-600"),children:t&&(0,u.jsx)(Wm,{className:"w-3 h-3 text-white"})}),(0,u.jsx)("span",{className:"text-sm ".concat(n.text),children:e.label})]})},e.id)})})]},t)})]}),(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-t border-gray-200 dark:border-gray-700",children:[(0,u.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[o.size," starter",1!==o.size?"s":""," selected",o.size>0&&(0,u.jsxs)("span",{className:"ml-2 text-xs text-gray-500",children:["(Model: ",s.split("/").pop(),")"]})]}),(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("button",{onClick:n,disabled:i,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 rounded-md hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors disabled:opacity-50",children:"Cancel"}),(0,u.jsxs)("button",{onClick:()=>{if(0===o.size)return;const e=hk.filter(e=>o.has(e.id)).map(e=>({prompt:e.prompt}));r(e)},disabled:0===o.size||i,className:"flex items-center gap-2 rounded-md bg-[#FFB52B] px-4 py-2 text-[#232E3F] transition-colors hover:bg-[#FFC54D] disabled:cursor-not-allowed disabled:opacity-50",children:[(0,u.jsx)(kh,{className:"w-4 h-4"}),i?"Starting...":"Generate ".concat(o.size," Conversation").concat(1!==o.size?"s":"")]})]})]})]})})]})}),document.body):null};class fk extends a.Component{constructor(e){super(e),this.handleRetry=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})},this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){const n=t.componentStack||"";console.error("[ERROR-BOUNDARY] Component error caught:",{error:e.message,stack:e.stack,componentStack:n,timestamp:(new Date).toISOString()}),this.setState({errorInfo:n}),this.props.onError&&this.props.onError(e,n)}
2render(){if(this.state.hasError){if(this.props.fallback){const e=this.props.fallback;return(0,u.jsx)(e,{error:this.state.error,retry:this.handleRetry})}return(0,u.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-64 p-8 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3 mb-4",children:[(0,u.jsx)(fp,{className:"w-8 h-8 text-red-500"}),(0,u.jsx)("h2",{className:"text-xl font-semibold text-red-700 dark:text-red-300",children:"Something went wrong"})]}),(0,u.jsx)("p",{className:"text-red-600 dark:text-red-400 text-center mb-6 max-w-md",children:"An unexpected error occurred. The application encountered a problem and couldn't continue."}),this.state.error&&(0,u.jsxs)("details",{className:"mb-6 w-full max-w-2xl",children:[(0,u.jsx)("summary",{className:"cursor-pointer text-sm text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300",children:"Error Details"}),(0,u.jsxs)("div",{className:"mt-2 p-4 bg-red-100 dark:bg-red-900/30 rounded border text-sm text-red-800 dark:text-red-200 font-mono overflow-auto",children:[(0,u.jsxs)("div",{className:"mb-2",children:[(0,u.jsx)("strong",{children:"Error:"})," ",this.state.error.message]}),this.state.error.stack&&(0,u.jsxs)("div",{className:"mb-2",children:[(0,u.jsx)("strong",{children:"Stack:"}),(0,u.jsx)("pre",{className:"whitespace-pre-wrap text-xs mt-1",children:this.state.error.stack})]}),this.state.errorInfo&&(0,u.jsxs)("div",{children:[(0,u.jsx)("strong",{children:"Component Stack:"}),(0,u.jsx)("pre",{className:"whitespace-pre-wrap text-xs mt-1",children:this.state.errorInfo})]})]})]}),(0,u.jsxs)("div",{className:"flex space-x-4",children:[(0,u.jsxs)("button",{onClick:this.handleRetry,className:"flex items-center space-x-2 px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors",children:[(0,u.jsx)(Cy,{className:"w-4 h-4"}),(0,u.jsx)("span",{children:"Try Again"})]}),(0,u.jsx)("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors",children:"Reload Page"})]})]})}return this.props.children}}const bk=fk,yk=(0,a.createContext)(void 0);function vk(e){let{children:t}=e;const[n,r]=(0,a.useState)(null),[s,i]=(0,a.useState)(null),[o,l]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(null),[p,g]=(0,a.useState)(null),[x,f]=(0,a.useState)(!0),[b,y]=(0,a.useState)(0),[v,w]=(0,a.useState)(null);return(0,u.jsx)(yk.Provider,{value:{hoveredTimeRange:n,setHoveredTimeRange:r,timelineHoverTime:s,setTimelineHoverTime:i,timelineViewportRange:o,setTimelineViewportRange:l,transcriptSelectionRange:c,setTranscriptSelectionRange:d,playingWidgetId:m,setPlayingWidgetId:h,dragHighlightTime:p,setDragHighlightTime:g,cursorSyncEnabled:x,setCursorSyncEnabled:f,syncRequestId:b,syncRequestTargetTime:v,requestCursorSync:e=>{f(!0),w(Number.isFinite(e)?Number(e):null),y(e=>e+1)}},children:t})}function wk(){const e=(0,a.useContext)(yk);if(!e)throw new Error("useAudioUI must be used within AudioUIProvider");return e}const kk=new Map,jk=e=>{try{return decodeURIComponent(e)}catch(BH){return console.error("[AudioClipCard] Failed to decode URI:",e,BH),e}},Dk=e=>{let{clipData:t,onLoadSession:n,currentSessionId:r,isPlaying:s=!1,isCurrentAudio:i=!1,onPlay:o,onStop:l,onHoverTimeRange:c,onHoverEnd:d}=e;const{isDarkMode:m}=zu(),{token:h}=am(),{shareToken:p}=Hp(),[g,x]=(0,a.useState)(!1),[f,b]=(0,a.useState)(""),{pause:y,playSegment:v}=Kw(),{playingWidgetId:w,setPlayingWidgetId:k}=wk(),[j,D]=(0,a.useState)(!1),[C,N]=(0,a.useState)(!1),[F,S]=(0,a.useState)(!1),{sessionId:E,startTime:A,endTime:T,name:M,snippetName:_,narrativeContext:B}=t,I=e=>{const[t,n,a]=e.split(":").map(Number);return 3600*t+60*n+a},P=I(A),L=T?I(T):void 0,R=L?L-P:0,z=!!T,O=E===(r||""),U="widget_".concat(E,"_").concat(P,"_").concat(L||"single"),V=w===U,{isExpanded:H,setExpanded:q}=(e=>{const t="widget_expanded_".concat(e),[n,r]=(0,a.useState)(()=>"undefined"!==typeof window&&"true"===sessionStorage.getItem(t));(0,a.useEffect)(()=>{"undefined"!==typeof window&&sessionStorage.setItem(t,String(n))},[n,t]);const s=(0,a.useCallback)(()=>{r(e=>!e)},[]),i=(0,a.useCallback)(e=>{r(e)},[]);return{isExpanded:n,toggleExpanded:s,setExpanded:i}})(U),{transcriptSegments:W,speakerLabels:Y,cacheTranscript:G,hasCache:K}=(e=>{const[t,n]=(0,a.useState)(()=>{const t=kk.get(e);return(null===t||void 0===t?void 0:t.segments)||[]}),[r,s]=(0,a.useState)(()=>{const t=kk.get(e);return(null===t||void 0===t?void 0:t.speakerLabels)||{}});return{transcriptSegments:t,speakerLabels:r,cacheTranscript:(0,a.useCallback)((t,a)=>{kk.set(e,{segments:t,speakerLabels:a,loadedAt:Date.now()}),n(t),s(a)},[e]),hasCache:(0,a.useCallback)(()=>kk.has(e),[e]),clearCache:(0,a.useCallback)(()=>{kk.delete(e),n([]),s({})},[e])}})(U),X=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return"".concat(String(t).padStart(2,"0"),":").concat(String(n).padStart(2,"0"),":").concat(String(a).padStart(2,"0"))},J=(0,a.useCallback)(async()=>
2{if(!K()&&!g){x(!0),b("");try{var e,t;const n=await Vm.getSession(E,h||p||void 0);if(null!==(e=n.transcriptionData)&&void 0!==e&&null!==(t=e.results)&&void 0!==t&&t.utterances){const e=n.transcriptionData.results.utterances.filter(e=>{const t=e.start;return e.end>=P&&(L?t<=L:t<=P+10)}).map(e=>{var t;const a=e.speaker,r=(null===(t=n.speakerLabels)||void 0===t?void 0:t[a])||"Speaker ".concat(a);return{start:e.start,end:e.end,text:e.transcript,speaker:void 0!==a?"Speaker ".concat(a):void 0,speakerLabel:void 0!==a?r:void 0}});G(e,n.speakerLabels||{})}else b("No transcript data available")}catch(n){console.error("Failed to load transcript:",n),b("Failed to load transcript")}finally{x(!1)}}},[E,h,P,L,g,K,G]),$=(0,a.useCallback)(async()=>{const e=!H;q(e),e&&0===W.length&&!g&&await J()},[H,W.length,g,J,q]),Q=(0,a.useCallback)(async()=>{if(0===W.length)return S(!0),void(g||await J());const e=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=(e%60).toFixed(3);return"".concat(String(t).padStart(2,"0"),":").concat(String(n).padStart(2,"0"),":").concat(String(a).padStart(6,"0"))},t=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),n='<?xml version="1.0" encoding="UTF-8"?>\n<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns:tts="http://www.w3.org/ns/ttml#styling" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" xmlns:ittp="http://www.w3.org/ns/ttml/profile/imsc1#parameter" xmlns:itts="http://www.w3.org/ns/ttml/profile/imsc1#styling" ttp:profile="http://www.w3.org/ns/ttml/profile/imsc1/text" ttp:frameRate="24" ttp:frameRateMultiplier="1000 1001" ttp:dropMode="nonDrop" ttp:timeBase="media">\n <head>\n <styling>\n <style xml:id="clip_style" tts:color="#ffffff" tts:fontSize="100%" tts:fontFamily="proportionalSansSerif" tts:fontWeight="bold" tts:textAlign="center"/>\n <style xml:id="transcript_style" tts:color="#ffffff" tts:fontSize="90%" tts:fontFamily="proportionalSansSerif" tts:textAlign="left"/>\n <style xml:id="description_style" tts:color="#ffff00" tts:fontSize="85%" tts:fontFamily="proportionalSansSerif" tts:textAlign="center"/>\n </styling>\n <layout>\n <region xml:id="r_clip" tts:origin="10% 10%" tts:extent="80% 20%" tts:displayAlign="before"/>\n <region xml:id="r_transcript" tts:origin="10% 75%" tts:extent="80% 20%" tts:displayAlign="after"/>\n <region xml:id="r_description" tts:origin="10% 45%" tts:extent="80% 15%" tts:displayAlign="center"/>\n </layout>\n <metadata>\n <ttm:title>'.concat(t(_),'</ttm:title>\n <ttm:agent xml:id="ai">AI Assistant</ttm:agent>\n </metadata>\n </head>\n <body>\n <div xml:id="d_clip" region="r_clip" style="clip_style">\n <p begin="').concat(e(P),'" end="').concat(e(L||P+10),'">').concat(t(_),'</p>\n </div>\n <div xml:id="d_transcript" region="r_transcript" style="transcript_style">\n ').concat(W.map((n,a)=>'<p begin="'.concat(e(n.start),'" end="').concat(e(n.end),'">').concat(t(n.speakerLabel||n.speaker||"Unknown"),": ").concat(t(n.text),"</p>")).join("\n "),"\n </div>\n ").concat(M?'<div xml:id="d_description" region="r_description" style="description_style">\n <p begin="'.concat(e(P),'" end="').concat(e(L||P+10),'">').concat(t(jk(M)),"</p>\n </div>"):"","\n </body>\n</tt>"),a=new Blob([n],{type:"application/ttml+xml"}),r=URL.createObjectURL(a),s=document.createElement("a");s.href=r,s.download="".concat(_.replace(/[^a-z0-9]/gi,"_").toLowerCase(),".ttml"),document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)},[W,_,P,L,M,g,J]),Z=(0,a.useCallback)(async()=>{if(0===W.length)return N(!0),void(g||await J());const e=W.map(e=>"[".concat(X(e.start)," - ").concat(X(e.end),"] ").concat(e.speakerLabel||e.speaker||"Unknown",": ").concat(e.text)).join("\n"),t="".concat(_,"\n").concat(A," \u2192 ").concat(T||A,"\n").concat(M?jk(M)+"\n":"","\n").concat(e);try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),document.body.removeChild(e)}D(!0),setTimeout(()=>D(!1),2e3)}catch(n){console.error("Failed to copy transcript:",n)}},[W,_,A,T,M,X,g,J]);return(0,a.useEffect)(()=>{0===W.length&&H&&!g&&J()},[H]),(0,a.useEffect)(()=>{C&&W.length>0&&!g&&(N(!1),Z())},[C,W.length,g,Z]),(0,a.useEffect)(()=>{F&&W.length>0&&!g&&(S(!1),Q())},[F,W.length,g,Q]),(0,u.jsxs)("div",{className:"\n w-full my-4 roun
2ded-xl overflow-hidden transition-all duration-300\n ".concat(m?"bg-gradient-to-br from-gray-800 to-gray-900 border border-gray-700 shadow-xl":"bg-gradient-to-br from-[#f6f1e5] to-[#eef2f6] border border-[#d8c9a3] shadow-lg","\n ").concat(V?"ring-2 ring-brand-yellow ring-offset-2":"","\n "),children:[(0,u.jsx)("div",{className:"\n p-4 cursor-pointer transition-colors duration-200\n ".concat(m?"hover:bg-gray-700/50":"hover:bg-white/50","\n "),onClick:$,onMouseEnter:()=>{O&&c&&c(P,L)},onMouseLeave:()=>{O&&d&&d()},children:(0,u.jsxs)("div",{className:"flex items-start gap-4",children:[(0,u.jsx)("button",{onClick:async e=>{e.stopPropagation(),O?V?(l&&l(),y()):o?(k(U),o(E,P,L)):await v(P,L):n(E)},className:"\n flex-shrink-0 w-12 h-12 rounded-full flex items-center justify-center transition-all duration-200\n ".concat(V?"bg-gradient-to-br from-brand-yellow to-[#d9980e] hover:from-[#ffc54d] hover:to-brand-yellow shadow-lg text-brand-navy":"bg-gradient-to-br from-brand-navy to-[#41526a] hover:from-[#1a2230] hover:to-brand-navy shadow-lg","\n ").concat(V?"":"text-white"," transform hover:scale-105\n "),title:V?"Pause":"Play",children:V?(0,u.jsx)(wh,{size:20}):(0,u.jsx)(kh,{size:20,className:"ml-1"})}),(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsx)("h3",{className:"\n text-lg font-semibold mb-1\n ".concat(m?"text-white":"text-gray-900","\n "),children:_}),(0,u.jsxs)("div",{className:"flex items-center gap-4 mb-2",children:[(0,u.jsxs)("div",{className:"\n flex items-center gap-1.5 text-sm\n ".concat(m?"text-gray-400":"text-gray-600","\n "),children:[(0,u.jsx)(wp,{size:14}),z?(0,u.jsxs)("span",{children:[A," \u2192 ",T," ",(0,u.jsxs)("span",{className:"opacity-75",children:["(",Math.floor(R),"s)"]})]}):(0,u.jsx)("span",{children:A})]}),!O&&(0,u.jsxs)("div",{className:"flex items-center gap-1.5 text-sm text-brand-yellow",children:[(0,u.jsx)(Ep,{size:14}),(0,u.jsxs)("span",{children:["Session ",E.length>8?"".concat(E.substring(0,8),"..."):E]})]})]}),M&&(0,u.jsx)("p",{className:"\n text-sm mb-2\n ".concat(m?"text-gray-300":"text-gray-700","\n "),children:jk(M)}),B&&(0,u.jsxs)("div",{className:"\n text-sm italic p-3 rounded-lg mt-2\n ".concat(m?"bg-gray-700/50 text-gray-300":"bg-white/50 text-gray-700","\n "),children:[(0,u.jsx)(_o,{size:14,className:"inline mr-2 opacity-70"}),B]})]}),(0,u.jsxs)("div",{className:"flex items-start gap-2",children:[(0,u.jsx)("button",{className:"\n p-2 rounded-lg transition-colors duration-200\n ".concat(m?"hover:bg-gray-700 text-gray-400 hover:text-gray-200":"hover:bg-white/70 text-gray-600 hover:text-gray-800","\n "),onClick:e=>{e.stopPropagation(),$()},title:H?"Collapse transcript":"Expand transcript",children:H?(0,u.jsx)(Tu,{size:20}):(0,u.jsx)(wd,{size:20})}),(0,u.jsx)("button",{onClick:e=>{e.stopPropagation(),Z()},className:"\n p-2 rounded-lg transition-all duration-200 relative\n ".concat(m?"hover:bg-gray-700 text-gray-400 hover:text-gray-200":"hover:bg-white/70 text-gray-600 hover:text-gray-800","\n ").concat(j?"text-brand-yellow":"","\n "),title:j?"Copied!":"Copy transcript with timestamps",children:j?(0,u.jsx)(Wm,{size:18,className:"animate-bounce"}):(0,u.jsx)(Np,{size:18})}),(0,u.jsx)("button",{onClick:async e=>{e.stopPropagation(),await Q()},className:"\n p-2 rounded-lg transition-colors duration-200\n ".concat(m?"hover:bg-gray-700 text-gray-400 hover:text-gray-200":"hover:bg-white/70 text-gray-600 hover:text-gray-800","\n "),title:"Download TTML",disabled:0===W.length&&!H,children:(0,u.jsx)(Sp,{size:18})}),!O&&(0,u.jsx)("button",{onClick:e=>{e.stopPropagation(),window.open("/session/".concat(E),"_blank")},className:"\n p-2 rounded-lg transition-colors duration-200\n ".concat(m?"hover:bg-gray-700 text-gray-400 hover:text-gray-200":"hover:bg-white/70 text-gray-600 hover:text-gray-800","\n "),title:"Open Session in New Tab",children:(0,u.jsx)(Ep,{size:18})})]})]})}),H&&(0,u.jsx)("div",{className:"\n border-t transition-all duration-300\n ".concat(m?"border-gray-700":"border-[#d8c9a3]","\n "),children:(0,u.jsx)("div",{className:"\n p-4\n ".concat(m?"bg-gray-800/50":"bg-white/30","\n "),children:g?(0,u.jsx)("div",{className:"text-center py-8",children:(0,u.jsx)("div",{className:"animate-pulse text-sm opacity-70",children:"Loading transcript..."})}):f?(0,u.jsx)("div",{className:"text-center py-8 text-red-500 text-sm",children:f}):0===W.length?(0,u.jsx)("div",{className:"text-center py-8 opacity-70 text-sm",children:"No transcript available for this segment"}):(0,u.jsx)("div",{className:"space-y-4 max-h-96 overflow-y-auto",children:W.map((e,t)=>{const n=["from-brand-navy to-[#41526a]","from-[#5b6778] to-[#2f394a]","from-brand-yellow to-[#d9980e]","from-[#c7b07a] to-[#8c6b2f]","from-[#d8d1c2] to-[#a2acb8]","from-[#41526a] to-[#232E3F]"],a=n[(e.speaker?parseInt(e.speaker.replace("Speaker ","")):-1)%n.length];return(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("div",{className:"flex-shrink-0",children:(0,u.jsx)("div",{className:"\n w-10 h-10 rounded-full bg-gradient-to-br ".concat(e.speaker?a:"from-gray-400 to-gray-600"," \n flex items-center justify-center text-white text-sm font-bold shadow-md\n "),children:e.speakerLabel?e.speakerLabel.charAt(0).toUpperCase():"?"})}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"flex items-baseline gap-2 mb-1",children:[(0,u.jsx)("span",{className:"\n text-sm font-medium\n ".concat(m?"text-gray-300":"text-gray-700","\n "),children:e.speakerLabel||e.speaker||"Unknown Speaker"}),(0,u.jsx)("span",{className:"\n text-xs opacity-60\n ".concat(m?"text-gray-400":"text-gray-500","\n "),children:X(e.start)})]}),(0,u.jsx)("div",{className:"\n text-sm leading-relaxed\n ".concat(m?"text-gray-200":"text-gray-800","\n "),children:e.text})]}),(0,u.jsx)("button",{onClick:t=>{if(t.stopPropagation(),O)if(o){const t="widget_".concat(E,"_").concat(e.start,"_").concat(e.end);k(t),o(E,e.start,e.end)}else v(e.start,e.end);else{const t="".concat(Math.floor(e.start/60),"m").concat(Math.floor(e.start%60),"s");window.open("/session/".concat(E,"?t=").concat(t),"_blank")}},className:"\n flex-shrink-0 p-1.5 rounded-lg opacity-0 hover:opacity-100 transition-opacity duration-200\n ".concat(m?"hover:bg-gray-700 text-gray-400 hover:text-gray-200":"hover:bg-gray-200 text-gray-600 hover:text-gray-800","\n "),title:"Play this segment",children:(0,u.jsx)(jh,{size:16})})]},t)})})})})]})},Ck=(0,a.memo)(Dk,(e,t)=>{const n={sessionId:e.clipData.sessionId,startTime:e.clipData.startTime,endTime:e.clipData.endTime,name:e.clipData.name,snippetName:e.clipData.snippetName,currentSessionId:e.currentSessionId,isPlaying:e.isPlaying,isCurrentAudio:e.isCurrentAudio},a={sessionId:t.clipData.sessionId,startTime:t.clipData.startTime,endTime:t.clipData.endTime,name:t.clipData.name,snippetName:t.clipData.snippetName,currentSessionId:t.currentSessionId,isPlaying:t.isPlaying,isCurrentAudio:t.isCurrentAudio};return JSON.stringify(n)===JSON.stringify(a)});const Nk=Mo("skip-back",[["polygon",{points:"19 20 9 12 19 4 19 20",key:"o2sva"}],["line",{x1:"5",x2:"5",y1:"19",y2:"5",key:"1ocqjk"}]]),Fk=Mo("skip-forward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]),Sk=e=>{let{isOpen:t,onClose:n,sessionId:r,startSeconds:s,endSeconds:i,sessionTitle:o}=e;const{isDarkMode:l}=zu(),{token:c}=am(),{loadAudio:d,playSegment:m,play:h,pause:p,seekTo:g,currentTime:x,duration:f,isPlaying:b,isLoading:y}=Jw(),[v,w]=(0,a.useState)(!0),[k,j]=(0,a.useState)(""),[D,C]=(0,a.useState)([]),[N,F]=(0,a.useState)(null),[S,E]=(0,a.useState)({});(0,a.useRef)(new Map);(0,a.useEffect)(()=>
2{if(!t||!r||!c)return;(async()=>{w(!0),j("");try{var e,t;console.log("[TimelineViewerModal] Loading session:",r);const n=await Vm.getSession(r,c);if(console.log("[TimelineViewerModal] Session data loaded:",n),F(n),null!==(e=n.transcriptionData)&&void 0!==e&&null!==(t=e.results)&&void 0!==t&&t.utterances){const e=n.transcriptionData.results.utterances.map(e=>({start:e.start,end:e.end,text:e.transcript,speaker:void 0!==e.speaker&&null!==e.speaker?"Speaker ".concat(e.speaker):"Unknown Speaker"}));console.log("[TimelineViewerModal] Extracted segments:",e.length),C(e)}else console.warn("[TimelineViewerModal] No utterances found in transcription data"),C([]);n.speakerLabels&&E(n.speakerLabels),n.audioUrl?(console.log("[TimelineViewerModal] Loading audio from session"),d(n.audioUrl),setTimeout(()=>{m(s,i)},500)):console.warn("[TimelineViewerModal] No audio URL available for session")}catch(n){console.error("Failed to load session data:",n),j("Failed to load session data")}finally{w(!1)}})()},[t,r,c,d,m,s,i]),(0,a.useEffect)(()=>{!t&&b&&p()},[t,b,p]);const A=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return"".concat(String(t).padStart(2,"0"),":").concat(String(n).padStart(2,"0"),":").concat(String(a).padStart(2,"0"))},T=e=>{g(e)};if(!t)return null;D.find(e=>x>=e.start&&x<=e.end);const M=(()=>{if(console.log("[TimelineViewerModal] Getting segments in range:",{startSeconds:s,endSeconds:i,totalSegments:D.length}),0===D.length)return console.warn("[TimelineViewerModal] No transcript segments available"),[];if(!i){const e=D.filter(e=>Math.abs(e.start-s)<5);if(e.length>0)return e;return[D.reduce((e,t)=>{const n=Math.abs(e.start-s);return Math.abs(t.start-s)<n?t:e})]}const e=D.filter(e=>e.start>=s&&e.start<=i||e.end>=s&&e.end<=i||e.start<=s&&e.end>=i);if(console.log("[TimelineViewerModal] Found overlapping segments:",e.length),0===e.length){const e=5,t=D.filter(t=>t.end>=s-e&&t.start<=i+e);return console.log("[TimelineViewerModal] Found nearby segments with tolerance:",t.length),t.length>0?t:[]}return e})(),_=i?"".concat(A(s)," - ").concat(A(i)):A(s);return console.log("[TimelineViewerModal] Render state:",{rangeSegments:M,isArray:Array.isArray(M),segmentCount:Array.isArray(M)?M.length:"not array"}),(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",children:(0,u.jsxs)("div",{className:"\n w-full max-w-4xl mx-4 rounded-lg shadow-xl\n ".concat(l?"bg-gray-800":"bg-white","\n "),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-b ".concat(l?"border-gray-700":"border-gray-200"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-lg font-semibold ".concat(l?"text-white":"text-gray-900"),children:"Timeline Viewer"}),(0,u.jsxs)("p",{className:"text-sm ".concat(l?"text-gray-400":"text-gray-600"),children:[o||"Session ".concat(r.substring(0,8),"...")," \u2022 ",_]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("button",{onClick:()=>{window.open("/session/".concat(r),"_blank")},className:"p-2 rounded-lg transition-colors ".concat(l?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-500 hover:text-gray-700"),title:"Open full session in new tab",children:(0,u.jsx)(Ep,{size:18})}),(0,u.jsx)("button",{onClick:n,className:"p-2 rounded-lg transition-colors ".concat(l?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-500 hover:text-gray-700"),children:(0,u.jsx)(Pu,{size:20})})]})]}),(0,u.jsx)("div",{className:"p-6",children:v?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):k?(0,u.jsx)("div",{className:"text-center py-12",children:(0,u.jsx)("p",{className:"text-red-500",children:k})}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"p-4 rounded-lg mb-6 ".concat(l?"bg-gray-700":"bg-gray-50"),children:[(0,u.jsxs)("div",{className:"mb-4",children:[(0,u.jsx)("div",{className:"w-full h-2 rounded-full ".concat(l?"bg-gray-600":"bg-gray-300"),children:(0,u.jsx)("div",{className:"h-full bg-blue-600 rounded-full transition-all duration-150",style:{width:"".concat(f?x/f*100:0,"%")}})}),(0,u.jsxs)("div",{className:"flex justify-between mt-1 text-xs text-gray-500",children:[(0,u.jsx)("span",{children:A(x)}),(0,u.jsx)("span",{children:A(f)})]})]}),(0,u.jsxs)("div",{className:"flex items-center justify-center gap-4",children:[(0,u.jsx)("button",{onClick:()=>{const e=Math.max(0,x-10);T(e)},className:"p-2 rounded-full transition-colors ".concat(l?"hover:bg-gray-600 text-gray-300":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(Nk,{size:20})}),(0,u.jsx)("button",{onClick:()=>{b?p():h()},className:"p-3 bg-blue-600 hover:bg-blue-700 text-white rounded-full transition-colors",children:b?(0,u.jsx)(wh,{size:24}):(0,u.jsx)(kh,{size:24})}),(0,u.jsx)("button",{onClick:()=>{const e=Math.min(f,x+10);T(e)},className:"p-2 rounded-full transition-colors ".concat(l?"hover:bg-gray-600 text-gray-300":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(Fk,{size:20})}),(0,u.jsxs)("div",{className:"flex items-center gap-2 ml-4",children:[(0,u.jsx)(jh,{size:16,className:"text-gray-500"}),(0,u.jsx)("input",{type:"range",min:"0",max:"1",step:"0.1",value:1,onChange:e=>{console.log("Volume control not yet implemented:",e.target.value)},className:"w-20"})]})]})]}),(0,u.jsxs)("div",{className:"rounded-lg p-4 ".concat(l?"bg-gray-750":"bg-gray-50"),children:[(0,u.jsx)("h3",{className:"text-sm font-medium mb-3 ".concat(l?"text-gray-300":"text-gray-700"),children:"Segment Information"}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsxs)("div",{className:"text-sm ".concat(l?"text-gray-300":"text-gray-600"),children:[(0,u.jsxs)("p",{className:"mb-2",children:[(0,u.jsx)("strong",{children:"Time Range:"})," ",_]}),i&&(0,u.jsxs)("p",{children:[(0,u.jsx)("strong",{children:"Duration:"})," ",A(i-s)]})]}),(0,u.jsx)("div",{className:"text-sm ".concat(l?"text-blue-400":"text-blue-600"),children:(0,u.jsx)("p",{className:"italic",children:"Audio player will seek to this time range. Visit the Transcript page to view the full transcript."})})]})]})]})})]})})},Ek=(e,t)=>{try{if(!e.startsWith("timecode://"))return null;const n=e.replace("timecode://",""),[a,r]=n.split("?"),s=a.split("/");
2if(s.length<2)return console.warn("Invalid timecode format: missing session_id or time"),null;const i=s[0],o=s[1],l=s.length>2?s[2]:void 0,c=/^\d{2}:\d{2}:\d{2}$/;if(!c.test(o))return console.warn("Invalid start time format:",o),null;if(l&&!c.test(l))return console.warn("Invalid end time format:",l),null;let d;if(r){d=new URLSearchParams(r).get("name")||void 0}return{sessionId:i,startTime:o,endTime:l,name:d,snippetName:t}}catch(n){return console.error("Error parsing timecode:",n),null}},Ak=e=>{const[t,n,a]=e.split(":").map(Number);return 3600*t+60*n+a},Tk=["href","children","node"],Mk=["className","children"],_k="\n## Comprehensive Storytelling Guide for Video Editing and Content Analysis\n\n### Cold Opens and Hooks \u2013 Grabbing Attention from the First Second\n\n**What it is:** A cold open is an opening scene that plunges the viewer directly into an interesting or dramatic moment before any intro or context. On YouTube, this is often the first 5-15 seconds of the video \u2013 and it's critical. A cold open serves as a hook: something so intriguing or unexpected that the viewer must keep watching. It could be a question, a bold statement, a mini-story, a surprising fact, or an emotional moment. The key is that it's presented upfront with no preamble \u2013 you drop the viewer in media res (\"in the middle of things\").\n\n**Why it works:** Online, attention is a scarce commodity. Viewers decide within seconds whether to stay or click away. A strong hook promises value or intrigue, giving them a reason to watch on. A cold open dunks the audience right into the action or mystery, provoking immediate questions: \"Whoa, what's happening here? How did we get here? I need to know more.\" It leverages curiosity and sets the tone and theme quickly.\n\n### Emotional Stakes \u2013 Making Viewers Care\n\n**What it is:** \"Emotional stakes\" means the human element that's at risk in your story \u2013 the feelings, relationships, or personal consequences riding on the outcome. It's basically answering the questions: \"Why does this story matter, and to whom?\" If your narrative is purely factual with no sense of personal impact, the stakes feel low. Emotional stakes introduce things like a protagonist's dream on the line, a community in peril, or a family legacy at risk.\n\n**Why it works:** Simply put, if the audience doesn't care, nothing else matters. Emotional stakes are what make viewers care. They trigger empathy and investment. When we experience a story with relatable characters and emotions, our brains release oxytocin \u2013 the bonding hormone \u2013 which increases trust and empathy. High stakes, especially those involving urgency or risk, also trigger norepinephrine (our alertness chemical). This means viewers pay more attention and are more likely to remember what they see.\n\n### Foreshadowing \u2013 Hinting at Future Twists\n\n**What it is:** Foreshadowing is when you drop subtle clues about what's going to happen later in the story. In a script, this might be an early hint or symbolic detail that seems minor at first but pays off down the line. It sets up viewer expectations \u2013 sometimes fulfilling them, sometimes subverting them.\n\n**Why it works:** Foreshadowing builds anticipation and dramatic tension. Psychologically, viewers love to predict outcomes. A hint gets the audience's mental gears turning as they try to figure out future events.\n\n### Suspenseful Reveals \u2013 Building Tension then Unveiling\n\n**What it is:** A suspenseful reveal means deliberately withholding a key piece of information and then revealing it at the perfect moment for maximum impact. It's the \"big twist\" or the answer to a burning question that you've teased throughout the narrative.\n\n**Why it works:** Suspense is all about keeping the audience guessing. By raising questions and delaying the answers, you create mystery and engagement. Our brains actually reward us for this \u2013 suspense and unresolved situations keep the brain's dopamine-based reward system activated in anticipation.\n\n### Tension and Release Cycles \u2013 Keeping the Audience on the Edge\n\n**What it is:** Tension and release is the rhythmic cycle of building suspense or intensity (tension), then giving the audience a moment of resolution or calm (release). It's like tightening a spring and then letting it uncoil for a beat, only to tighten it again.\n\n**Why it works:** If a story is all at one level (all tension or all calm), viewers eventually become desensitized or bored. Our brains start tuning out a constant stimulus. By alternating the intensity, you \"wake up\" the audience's attention repeatedly.\n\n### Chapters and Escalation Pacing \u2013 Structuring for Progress\n\n**What it is:** Think of your script like a book with chapters or a series of escalating segments. Chaptering means dividing your video into clear sections or phases \u2013 each with its own mini-story or focus \u2013 that together build the full narrative. Escalation pacing means that with each chapter or section, the stakes, tension, or complexity increases.\n\n**Why it works:** Structured chapters help both you and the viewer. For you (the creator), it's easier to organize the script and ensure a logical flow. For the viewer, it makes the content scannable and digestible. Escalation is important because if every part stayed at the same level, interest could plateau.\n\n### Contrast \u2013 Highlighting Differences to Drive Points Home\n\n**What it is:** Contrast in storytelling means juxtaposing opposites or extremes to emphasize a point. This could be contrasting characters (hero vs. villain), outcomes (success vs. failure), scenarios (boom vs. bust), or even tones (serious vs. humorous).\n\n**Why it works:** Our brains notice change and difference. If everything is on one note, it becomes background noise. The moment something changes, our attention snaps back. In narrative, contrast makes your message clearer.\n\n### Relatable Analogies and Meta
2phors \u2013 Explaining Complex Ideas Simply\n\n**What it is:** An analogy or metaphor compares a complex concept to something simple and familiar, making the concept easier to grasp. It's when you say \"X is like Y\" to leverage what the audience already understands.\n\n**Why it works:** Analogies bridge new information to existing knowledge. They help viewers latch onto unfamiliar ideas by connecting them to frameworks they already know. Psychologically, this reduces mental friction \u2013 people learn and remember better when they can relate new ideas to everyday life.\n\n### Callbacks and Circular Structure \u2013 Coming Full Circle\n\n**What it is:** A callback is a reference to something earlier in your script \u2013 an earlier event, line, or theme \u2013 later on in the story. It creates a connective thread that runs through your narrative. A circular structure means your story ends where it began, creating a satisfying sense of closure.\n\n**Why it works:** Callbacks give the audience that rewarding \"I see what you did there!\" moment. By tying back to an earlier moment, you create unity and coherence in the story. Circular storytelling in particular highlights how far the story or characters have come.\n\n### Red Herrings and Controlled Misdirection \u2013 Leading and Surprising Your Audience\n\n**What it is:** A red herring is a false clue \u2013 a narrative redirection that leads the audience to a wrong assumption. Misdirection in storytelling is the broader technique of purposefully guiding your viewers' attention away from the truth, only to reveal the real truth later.\n\n**Why it works:** When used well, red herrings and misdirection create intrigue and surprise. They enhance suspense by encouraging viewers to theorize and guess, often leading them down a wrong path so that the real outcome is more impactful.\n\n### Framing Stories (Embedded Narratives) \u2013 Stories Within Stories\n\n**What it is:** A frame narrative (or framing story) is when your main story contains another story inside of it. Essentially, one narrative frames another. Often you have an outer narrator or context that introduces an inner narrative.\n\n**Why it works:** Framing can make abstract or dry content more relatable by embedding it in a narrative context. It also adds a layer of intrigue \u2013 viewers realize there's a story being told and want to see how it ties back to the main narrative.\n\n### Key Principles for Video Editing and Content Analysis\n\n**For Identifying Story Structure:**\n- Look for chapter breaks and escalation patterns\n- Identify tension and release cycles\n- Notice how emotional stakes are established and maintained\n- Spot foreshadowing elements that pay off later\n- Recognize circular structure and callbacks\n\n**For Content Enhancement:**\n- Identify opportunities for stronger hooks in the opening\n- Look for places where analogies could clarify complex concepts\n- Find moments where contrast could emphasize key points\n- Spot potential for suspenseful reveals\n- Recognize where framing stories could add engagement\n\n**For Pacing Analysis:**\n- Map out the tension and release rhythm\n- Identify if chapters escalate properly\n- Check if there are appropriate breathers between intense moments\n- Ensure emotional stakes are maintained throughout\n- Verify that reveals are properly set up and paid off\n\nThis comprehensive storytelling framework provides the foundation for analyzing and enhancing video content through narrative techniques that have proven effective across literature, film, and successful YouTube channels. Each technique can be applied individually or combined for maximum impact, always serving the ultimate goal of keeping the audience engaged and emotionally invested in the content.\n",Bk=e=>{var t,n,r,s,i;let{transcript:o,model:l,onModelChange:c,supportedModels:m,currentTtmlFiles:h=[],sessionId:p,transcriptionData:g,transcriptionChecksum:x,speakerLabels:f={},shareToken:b,isPublicView:y,narrativeData:v,youtubeRetentionData:w,isActiveTab:k=!0}=e;const{token:j}=am(),{permissions:D}=Hp(),{addPinnedMessage:C}=((e,t)=>{const{user:n}=am();return{addPinnedMessage:async(a,r)=>
2{if(e&&t&&n)try{if(!(await fetch("".concat(tk,"/api/sessions/").concat(e,"/comments"),{method:"POST",headers:{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"},body:JSON.stringify({content:"Pinned message from ".concat(r),type:"pinned_message",pinnedContent:{originalMessage:a,model:r,timestamp:(new Date).toISOString()}})})).ok)throw new Error("Failed to pin message");return!0}catch(s){return console.error("Failed to pin message:",s),!1}}}})(null!==p&&void 0!==p?p:null,y?null!==b&&void 0!==b?b:null:j),[N,F]=(0,a.useState)([]),{loadAudio:E,playSegment:A,pause:M,isPlaying:_}=Kw(),{playingWidgetId:B,setPlayingWidgetId:I,setHoveredTimeRange:P}=wk(),L="text-[#B57700] dark:text-[#FFCF74] hover:text-[#8F5E00] dark:hover:text-[#FFE3A1] underline decoration-[#FFB52B]/55 underline-offset-2",R="border border-[#FFB52B]/40 bg-[#FFF4D8] text-[#8B5B00] hover:bg-[#FFE7AD] dark:border-[#FFB52B]/30 dark:bg-[#FFB52B]/[0.16] dark:text-[#FFE3A1] dark:hover:bg-[#FFB52B]/[0.24]",z="border border-[#D6DCE4] bg-[#EEF1F3] text-[#566377] hover:bg-[#E1E7EE] dark:border-[#445166] dark:bg-[#273244] dark:text-[#CAD1DB] dark:hover:bg-[#2F3B4E]",O="border border-[#445166] bg-[#232E3F] text-[#F4F4F4] hover:bg-[#2F3B4E]",U="rounded border-[#C9BEAA] text-[#FFB52B] focus:ring-[#FFB52B] focus:ring-offset-0";zw("[CHAT] ChatInterface received currentTtmlFiles prop:",h),zw("[CHAT] ChatInterface received youtubeRetentionData prop:",w?{videoId:w.videoId,hasStats:!!w.videoStats}:null);const V=(0,a.useMemo)(()=>(0,a.memo)(e=>{let{clipData:t,onLoadSession:n,currentSessionId:r,widgetId:s}=e;const{playSegment:i,pause:o}=Kw(),{playingWidgetId:l,setPlayingWidgetId:c,setHoveredTimeRange:d}=wk(),m=l==="widget_".concat(s),h=(0,a.useCallback)((e,t,n)=>{const a="widget_".concat(e,"_").concat(t,"_").concat(n||"single");c(a),i(t,n)},[i,c]),p=(0,a.useCallback)(()=>{c(null),o()},[o,c]),g=(0,a.useCallback)((e,t)=>{d({start:e,end:t})},[d]),x=(0,a.useCallback)(()=>{d(null)},[d]);return(0,u.jsx)(Ck,{clipData:t,onLoadSession:n,currentSessionId:r,isPlaying:m,isCurrentAudio:m,onPlay:h,onStop:p,onHoverTimeRange:g,onHoverEnd:x})},(e,t)=>e.clipData===t.clipData&&e.currentSessionId===t.currentSessionId&&e.widgetId===t.widgetId),[]);(0,a.useEffect)(()=>{(async()=>{if(k)if(p&&j)try{const e=await Vm.getSession(p,j);if(e.audioUrl&&(console.log("[ChatInterface] Loading audio from session:",e.audioUrl),E(e.audioUrl)),e.uploadedFiles&&e.uploadedFiles.length>0){console.log("[CHAT] Loading ".concat(e.uploadedFiles.length," files from session"));const t=e.uploadedFiles.map(e=>d(d({},e),{},{uploadedAt:"string"===typeof e.uploadedAt?e.uploadedAt:new Date(e.uploadedAt).toISOString(),includedInContext:void 0===e.includedInContext||e.includedInContext}));qt(t);const n={};t.forEach(e=>{n[e.id]=e.includedInContext}),Yt(n)}let t=[];e.sessionContext&&e.sessionContext.length>0&&(console.log("[CHAT] Loading ".concat(e.sessionContext.length," sessions from context")),t=e.sessionContext),Kt(t),e.chatSettings&&(console.log("[CHAT] Loading chat settings from session:",e.chatSettings),e.chatSettings.selectedModel&&c(e.chatSettings.selectedModel),void 0!==e.chatSettings.useStorytellingContext&&oe(e.chatSettings.useStorytellingContext),void 0!==e.chatSettings.enableWebSearch&&ce(e.chatSettings.enableWebSearch),void 0!==e.chatSettings.textOnlyTimeReferences&&ge(e.chatSettings.textOnlyTimeReferences),void 0!==e.chatSettings.includeTTMLInContext&&st(e.chatSettings.includeTTMLInContext),void 0!==e.chatSettings.includeTopicMapInContext&&ot(e.chatSettings.includeTopicMapInContext),void 0!==e.chatSettings.includeYouTubeStatsInContext&&ct(e.chatSettings.includeYouTubeStatsInContext),void 0!==e.chatSettings.includeCommentsInContext&&ut(e.chatSettings.includeCommentsInContext))}catch(J){console.error("Failed to load session data:",J)}else p||(qt([]),Yt({}),Kt([]),oe(!1),ce(!1))})()},[k,p,j,c]);const[H,q]=(0,a.useState)(""),[W]=(0,a.useState)(!1),[Y,G]=(0,a.useState)(!1),[K,X]=(0,a.useState)(""),[J,$]=(0,a.useState)(""),[Q,Z]=(0,a.useState)([]),[ee,te]=(0,a.useState)(""),[ne,ae]=(0,a.useState)(!1),[re,se]=(0,a.useState)(!1),[ie,oe]=(0,a.useState)(!1),[le,ce]=(0,a.useState)(!1),[de,ue]=(0,a.useState)(!1),[me,he]=(0,a.useState)("none"),[pe,ge]=(0,a.useState)(!1),[xe,fe]=(0,a.useState)(null),[be,ye]=(0,a.useState)(!1),[ve,we]=(0,a.useState)(null),[ke,je]=(0,a.useState)(null),De=(0,a.useRef)(null),[Ce,Ne]=(0,a.useState)([]),[Fe,Se]=(0,a.useState)(null),[Ee,Ae]=(0,a.useState)(()=>window.innerWidth<768),[Te,Me]=(0,a.useState)(null),[_e,Be]=(0,a.useState)(!1),[Ie,Pe]=(0,a.useState)(!1),[Le,Re]=(0,a.useState)(null),[ze,Oe]=(0,a.useState)(new Map),[Ue,Ve]=(0,a.useState)(0),[He]=(0,a.useState)(3),[qe,We]=(0,a.useState)(null),[Ye,Ge]=(0,a.useState)(null),[Ke,Xe]=(0,a.useState)(!1),Je=(0,a.useCallback)(()=>{try{const e=localStorage.getItem("mlst_chat_defaults");if(e)return JSON.parse(e)}catch(BH){console.error("[CHAT] Failed to load chat defaults:",BH)}return null},[]),$e=(0,a.useCallback)(e=>{try{localStorage.setItem("mlst_chat_defaults",JSON.stringify(e))}catch(BH){console.error("[CHAT] Failed to save chat defaults:",BH)}},[]),Qe=(0,a.useCallback)(()=>"mlst_public_conversations_".concat(p),[p]),Ze=(0,a.useCallback)(()=>
2{if(!p)return[];try{const e=localStorage.getItem(Qe());if(e){return JSON.parse(e).map(e=>{var t;return d(d({},e),{},{createdAt:new Date(e.createdAt),updatedAt:new Date(e.updatedAt),messages:(null===(t=e.messages)||void 0===t?void 0:t.map(e=>d(d({},e),{},{timestamp:e.timestamp?new Date(e.timestamp):new Date})))||[]})})}}catch(BH){console.error("[CHAT] Failed to load public share conversations from localStorage:",BH)}return[]},[p,Qe]),et=(0,a.useCallback)(e=>{if(p)try{localStorage.setItem(Qe(),JSON.stringify(e)),console.log("[CHAT] Saved public share conversations to localStorage:",e.length)}catch(BH){console.error("[CHAT] Failed to save public share conversations to localStorage:",BH)}},[p,Qe]),tt=(0,a.useCallback)(()=>{if(!p)return null;try{return localStorage.getItem("mlst_public_active_conv_".concat(p))}catch(BH){return null}},[p]),nt=(0,a.useCallback)(e=>{if(p)try{e?localStorage.setItem("mlst_public_active_conv_".concat(p),e):localStorage.removeItem("mlst_public_active_conv_".concat(p))}catch(BH){console.error("[CHAT] Failed to save public share active conversation ID:",BH)}},[p]),at=Je(),[rt,st]=(0,a.useState)(null===(t=null===at||void 0===at?void 0:at.includeTTMLInContext)||void 0===t||t),[it,ot]=(0,a.useState)(null===(n=null===at||void 0===at?void 0:at.includeTopicMapInContext)||void 0===n||n),[lt,ct]=(0,a.useState)(null===(r=null===at||void 0===at?void 0:at.includeYouTubeStatsInContext)||void 0===r||r),[dt,ut]=(0,a.useState)(null!==(s=null===at||void 0===at?void 0:at.includeCommentsInContext)&&void 0!==s&&s),[mt,ht]=(0,a.useState)([]),[pt,gt]=(0,a.useState)(""),[xt,ft]=(0,a.useState)(!1),[bt,yt]=(0,a.useState)(!1),[vt,wt]=(0,a.useState)("");(0,a.useEffect)(()=>{if(y){const e=Lp.getApiKey();e&>(e)}},[y]),(0,a.useEffect)(()=>{(async()=>{if(dt&&p&&j)try{const t="",n=await fetch("".concat(t,"/api/sessions/").concat(p,"/comments"),{headers:{Authorization:"Bearer ".concat(j)}});if(n.ok){var e;const t=await n.json();ht(t.comments||[]),console.log("[CHAT] Loaded ".concat((null===(e=t.comments)||void 0===e?void 0:e.length)||0," comments for context"))}}catch(J){console.error("[CHAT] Failed to load comments:",J)}else dt||ht([])})()},[dt,p,j]),(0,a.useEffect)(()=>{const e=setTimeout(()=>{$e({includeTTMLInContext:rt,includeTopicMapInContext:it,includeCommentsInContext:dt,includeYouTubeStatsInContext:lt,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe})},500);return()=>clearTimeout(e)},[rt,it,dt,lt,ie,le,pe,$e]),(0,a.useEffect)(()=>{if(!Le||!p||!j)return;const e=setInterval(async()=>{try{const e=await Om.getBatchStatus(p,Le.batchId,j);if(Re(t=>t?d(d({},t),{},{completed:e.completed,failed:e.failed}):null),e.isComplete){const e=await Vm.getSession(p,j);null!==e&&void 0!==e&&e.conversations&&Ne(e.conversations),Re(null)}}catch(J){console.error("Failed to poll batch status:",J)}},3e3);return()=>clearInterval(e)},[Le,p,j]),(0,a.useEffect)(()=>{if(0===ze.size||!p||!j)return;const e=setInterval(async()=>{for(const[e,t]of ze.entries())try{const n=(await Om.getAsyncChatJobStatus(p,t.jobId,j)).job;if(e===Fe&&n.context&&fe(n.context),"completed"===n.status){if(e===Fe&&n.context&&fe(n.context),e===Fe&&n.result){G(!1),X(""),rn.current="";const e=N[N.length-1];if(!(e&&"assistant"===e.role&&e.content===n.result)){const e=[...N,{role:"assistant",content:n.result}];F(e),await It(!0,e),Pt(e)}}Oe(t=>{const n=new Map(t);return n.delete(e),n})}else"failed"===n.status||"cancelled"===n.status?(e===Fe&&("failed"===n.status&&$(n.error||"Chat request failed"),X(""),rn.current="",G(!1)),Oe(t=>{const n=new Map(t);return n.delete(e),n})):"pending"!==n.status&&"running"!==n.status||(Oe(t=>{const a=new Map(t),r=a.get(e);return r&&a.set(e,d(d({},r),{},{status:n.status,startedAt:n.startedAt})),a}),e===Fe&&n.streamedContent&&(X(n.streamedContent),rn.current=n.streamedContent))}catch(J){console.error("[ASYNC-CHAT] Failed to poll job status for conversation",e,":",J)}},1e3);return()=>clearInterval(e)},[ze,p,j,N,Fe]),(0,a.useEffect)(()=>{(async()=>{if(p&&Fe&&j&&!ze.has(Fe))try{const e=await Om.getActiveJobsForConversation(p,Fe,j);if(e.jobs&&e.jobs.length>0){const t=e.jobs[0];console.log("[ASYNC-CHAT] Found active job to resume:",t.jobId);N.some(e=>"user"===e.role&&e.content===t.prompt)||F(e=>[...e,{role:"user",content:t.prompt}]);try{const e=await Om.getAsyncChatJobStatus(p,t.jobId,j);e.job.streamedContent&&(X(e.job.streamedContent),rn.current=e.job.streamedContent)}catch(BH){console.warn("[ASYNC-CHAT] Could not fetch streamed content:",BH)}Oe(e=>{const n=new Map(e);return n.set(Fe,{jobId:t.jobId,prompt:t.prompt,status:t.status,startedAt:t.startedAt}),n}),G(!0)}}catch(J){console.error("[ASYNC-CHAT] Failed to check active jobs:",J)}})()},[p,Fe,j,ze]),(0,a.useEffect)(()=>{Fe&&ze.has(Fe)?G(!0):(G(!1),X(""),rn.current="")},[Fe,ze]);const kt=(0,a.useCallback)((e,t,n,a,r,s)=>{let i="You are a helpful AI assistant. You are having a conversation with a user about the following transcript.\n---\n".concat(e,"\n---\n**IMPORTANT:** Your task is to answer the user's questions and discuss the transcript.\n- Do NOT generate NEW TTML, XML, or any other code format output.\n- Focus on providing helpful, conversational answers about the transcript content in plain text and markdown.\n- Use Markdown for formatting if it helps with readability.");if(i+=s?'\n\n**TIME REFERENCES:**\nWhen referencing specific moments, use plain text format like "at 12:34:56" or "from 12:34 to 15:45".\nDo NOT use any special timecode links or markdown links for time references.':'\n\n**CRITICAL: Time Code Citation Format**\nWhen referencing specific moments in transcripts, you MUST use this interactive time code markup:\n\nFor single time points:\n[snippet_name](timecode://host/HH:MM:SS?name=description)\n\nFor time ranges:\n[snippet_name](timecode://host/HH:MM:SS/HH:MM:SS?name=description)\n\nFormat requirements:\n- Always use HH:MM:SS format (e.g., 00:15:30, 01:02:45)\n- Include a descriptive name parameter\n- Make links descriptive, not just "click here"\n\nExamples:\n- [Guest discusses AI ethics](timecode://host/00:15:30?name=AI%20Ethics%20Discussion)\n- [Key point about neural networks](time
2code://host/00:25:00/00:27:30?name=Neural%20Networks)',t.length>0){i+="\n\n**ADDITIONAL CONTEXT:**\n";for(const e of t)i+="\n### ".concat(e.name,"\n```\n").concat(e.content,"\n```\n")}return n&&(i+="\n\n".concat(n)),a&&(i+="\n\n".concat(a)),r&&(i+="\n\n**STORYTELLING FRAMEWORK:**\n```\n".concat(_k,"\n```\n\nWhen analyzing content or providing editing recommendations, please apply these storytelling principles to help identify:\n- Opportunities for stronger narrative structure\n- Ways to enhance emotional engagement\n- Techniques to improve pacing and tension\n- Methods to create more compelling hooks and reveals\n- Approaches to better connect with the audience")),i},[]),jt=!y||Lp.hasApiKey();(0,a.useEffect)(()=>{_||(I(null),De.current=null)},[_]);const Dt=(0,a.useCallback)(async(e,t,n)=>{const a="widget_".concat(e,"_").concat(t,"_").concat(n||"single");if(B===a)return M(),I(null),void(De.current=null);I(a),De.current=n||null;const r="".concat(e,"_").concat(t,"_").concat(n||"single");je(r),console.log("Playing time code: ".concat(e," from ").concat(t,"s").concat(n?" to ".concat(n,"s"):""));try{if(e===p)await A(t,n);else if(console.log("[ChatInterface] Loading audio from different session: ".concat(e)),j){const a=await Vm.getSession(e,j);a.audioUrl?(E(a.audioUrl),setTimeout(()=>{A(t,n)},500)):(console.error("[ChatInterface] No audio URL available for session:",e),je(null),I(null))}}catch(J){console.error("[ChatInterface] Error playing time code:",J),je(null),I(null)}},[p,j,ke,M,E,A,I]),Ct=(0,a.useCallback)(()=>{M(),I(null),je(null),De.current=null},[M,I]),Nt=(0,a.useCallback)((e,t)=>{P({start:e,end:t})},[P]),Ft=(0,a.useCallback)(()=>{P(null)},[P]),St=(0,a.useCallback)(e=>{window.open("/session/".concat(e),"_blank")},[]),Et=(0,a.useRef)(Dt),At=(0,a.useRef)(Ct),Tt=(0,a.useRef)(Nt),Mt=(0,a.useRef)(Ft);(0,a.useEffect)(()=>{Et.current=Dt,At.current=Ct,Tt.current=Nt,Mt.current=Ft},[Dt,Ct,Nt,Ft]);const _t=(0,a.useCallback)(e=>{let{href:t,children:n,node:a}=e,r=T(e,Tk);if(t&&(t.startsWith("timecode://")||t.includes("timecode://")||t.includes("timecode%3A%2F%2F"))){const e=t=>{var n;if("string"===typeof t)return t;if("number"===typeof t)return String(t);if(Array.isArray(t))return t.map(e).join("");if(null!==t&&void 0!==t&&null!==(n=t.props)&&void 0!==n&&n.children)return e(t.props.children);if(null!==t&&void 0!==t&&t.toString&&"function"===typeof t.toString){const e=t.toString();return"[object Object]"===e?"":e}return""},a=e(n)||"Audio Clip";let r=t;try{r=decodeURIComponent(t)}catch(BH){console.error("[TimeCodeComponent] Failed to decode URI:",t,BH)}const s=Ek(r,a);if(s){"host"===s.sessionId&&p?s.sessionId=p:s.sessionId;"".concat(s.sessionId,"_").concat(s.startTime,"_").concat(s.endTime||"single");const e=s.sessionId===(p||"");if(pe){const t=s.endTime?"".concat(s.startTime," \u2192 ").concat(s.endTime):s.startTime,n=e?"":" (Session ".concat(s.sessionId.substring(0,8),"...)"),r="".concat(t," [").concat(a,"]").concat(n);return(0,u.jsx)("span",{className:"".concat(L," font-mono text-sm cursor-pointer"),onClick:()=>{e?Et.current(s.sessionId,Ak(s.startTime),s.endTime?Ak(s.endTime):void 0):St(s.sessionId)},title:s.name?(()=>{try{return decodeURIComponent(s.name)}catch(BH){return console.error("[TimeCodeComponent] Failed to decode name:",s.name,BH),s.name}})():"Click to play",children:r})}const t="".concat(s.sessionId,"_").concat(s.startTime,"_").concat(s.endTime||"single");return(0,u.jsx)("div",{className:"block my-2",children:(0,u.jsx)(V,{clipData:s,onLoadSession:St,currentSessionId:p,widgetId:t},t)})}}return(0,u.jsx)("a",d(d({href:t},r),{},{className:L,children:n}))},[L,p,ke,St,pe]),Bt=async e=>{if(p&&(j||b))try{if(y){const t=Ze(),n=t.findIndex(t=>t.id===e.id);return n>=0?t[n]=e:t.push(e),et(t),void nt(e.id)}const t=(await Vm.getSession(p,j||b)).conversations||[],n=t.findIndex(t=>t.id===e.id);n>=0?t[n]=e:t.push(e),await Vm.updateSession({sessionId:p,conversations:t,activeConversationId:e.id},j||b)}catch(J){console.error("Error saving conversation to session:",J)}},It=async function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0;if(!Fe||!p||!j&&!b)return void console.warn("[CHAT] Cannot save conversation state - missing activeConversationId, sessionId, or token/shareToken");const n=Ce.find(e=>e.id===Fe);if(!n)return void console.warn("[CHAT] Cannot save conversation state - current conversation not found");const a=t||N;console.log("[CHAT] Saving conversation state for:",Fe,"updateTimestamp:",e,"messageCount:",a.length);const r=d(d({},n),{},{messages:a.map(e=>d(d({},e),{},{timestamp:new Date})),chatSettings:Rt()},e&&{updatedAt:new Date});Ne(e=>e.map(e=>e.id===Fe?r:e));try{await Bt(r),console.log("[CHAT] Successfully saved conversation state with",a.length,"messages")}catch(J){console.error("[CHAT] Failed to save conversation state:",J)}},Pt=async e=>{if(!Fe||!p)return;
2if(y){if(!Lp.getApiKey())return}else if(!j)return;const t=Ce.find(e=>e.id===Fe);if(!t||"New Conversation"!==t.name)return;const n=e.filter(e=>"user"===e.role).length,a=e.filter(e=>"assistant"===e.role).length;n>=1&&a>=1&&await Ut(Fe)},Lt=async()=>{if(p&&(j||b))try{const e=y?Pp.getBrowserId():j?j.substring(0,32):void 0,t={id:"conv_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9)),name:"New Conversation",messages:[],ownerId:e,isPublicShare:y,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,uploadedFiles:[],fileContextToggles:{},sessionContext:Gt,includeTTMLInContext:rt,includeTopicMapInContext:it,includeCommentsInContext:dt,includeYouTubeStatsInContext:lt},createdAt:new Date,updatedAt:new Date};Ne(e=>[...e,t]),Se(t.id),F([]),qt([]),Yt({}),await Bt(t)}catch(J){console.error("Error creating conversation:",J)}},Rt=()=>({selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,uploadedFiles:Ht,fileContextToggles:Wt,sessionContext:Gt,includeTTMLInContext:rt,includeTopicMapInContext:it,includeCommentsInContext:dt,includeYouTubeStatsInContext:lt}),zt=e=>{const t=e.chatSettings,n=y?Pp.getBrowserId():j?j.substring(0,32):void 0,a=!e.ownerId||e.ownerId===n;if(t){var r,s,i,o,d;if(t.selectedModel&&t.selectedModel!==l&&c(t.selectedModel),oe(null!==(r=t.useStorytellingContext)&&void 0!==r&&r),ce(null!==(s=t.enableWebSearch)&&void 0!==s&&s),ge(null!==(i=t.textOnlyTimeReferences)&&void 0!==i&&i),void 0!==t.includeTTMLInContext&&st(t.includeTTMLInContext),void 0!==t.includeTopicMapInContext&&ot(t.includeTopicMapInContext),void 0!==t.includeCommentsInContext&&ut(t.includeCommentsInContext),void 0!==t.includeYouTubeStatsInContext&&ct(t.includeYouTubeStatsInContext),a)qt(null!==(o=t.uploadedFiles)&&void 0!==o?o:[]),Yt(null!==(d=t.fileContextToggles)&&void 0!==d?d:{});else qt([]),Yt({});void 0!==t.sessionContext&&Kt(t.sessionContext)}else oe(!1),ce(!1),ge(!1),qt([]),Yt({})},Ot=async e=>{if(!p||!j&&!b||e===Fe)return;await It(!1);const t=Ce.find(t=>t.id===e);t&&(Se(e),F(t.messages.map(e=>({role:e.role,content:e.content}))),zt(t),y?nt(e):j&&await Vm.setActiveConversation(p,e,j))},Ut=async e=>{if(!p)return;const t=y?Lp.getApiKey():null;if(!y||t){Me(e);try{const n=Ce.find(t=>t.id===e);if(!n||0===n.messages.length)return;const a=n.messages.filter(e=>"user"===e.role).map(e=>e.content).join(" ").substring(0,500);if(!a.trim()){const t=d(d({},n),{},{name:"Chat Conversation",updatedAt:new Date});return Ne(n=>n.map(n=>n.id===e?t:n)),void await Bt(t)}const r=(await Op.chatWithTranscript({model:"anthropic/claude-sonnet-4",message:"Generate a concise 4-5 word title for this conversation based ONLY on what the human has asked or discussed. Be descriptive and instructive. Focus on the main topic or action the human is asking about.\n\nHuman messages:\n".concat(a,"\n\nRespond with ONLY the title, nothing else."),transcript:a||"Conversation",conversationHistory:[]},j||void 0,t)).response.trim().replace(/['"]/g,""),s=d(d({},n),{},{name:r,updatedAt:new Date});Ne(t=>t.map(t=>t.id===e?s:t)),await Bt(s)}catch(J){console.error("Error generating conversation name:",J)}finally{Me(null)}}else console.log("Cannot generate name: No API key available for public share")},Vt=(e,t)=>{if(!e)return e;const n=t/150;if(n<=2)return e;const a=e.split("\n"),r=a.length,s=Math.max(10,Math.floor(.2*r)),i=a.slice(0,Math.floor(s/2)),o=a.slice(-Math.floor(s/2)),l=["[ABBREVIATED TRANSCRIPT - Estimated ".concat(n.toFixed(1)," minutes]"),"","[BEGINNING EXCERPT]",...i,"","[... MIDDLE CONTENT ABBREVIATED (".concat(r-s," lines omitted) ...]"),"","[ENDING EXCERPT]",...o,"","[Note: This transcript has been abbreviated. Original length: ".concat(t," words, ~").concat(n.toFixed(1)," minutes. LLM should summarize key points rather than quote verbatim.]")].join("\n");return console.log("[CHAT] Abbreviated transcript from ".concat(t," words (").concat(n.toFixed(1),"min) to ").concat(l.split(" ").length," words")),l},[Ht,qt]=(0,a.useState)([]),[Wt,Yt]=(0,a.useState)({}),[Gt,Kt]=(0,a.useState)([]),[Xt,Jt]=(0,a.useState)(!1),[$t,Qt]=(0,a.useState)(null),[Zt,en]=(0,a.useState)(null),[tn,nn]=(0,a.useState)(""),an=(0,a.useRef)(null),rn=(0,a.useRef)(""),sn=(0,a.useRef)(null),on=(0,a.useRef)(null);(0,a.useEffect)(()=>{var e;if(B)return;an.current&&N.length>0&&"assistant"===(null===(e=N[N.length-1])||void 0===e?void 0:e.role)&&(()=>{var e;null===(e=an.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})})()},[N.length]),(0,a.useEffect)(()=>{(async()=>
2{if(p&&(j||b))try{if(y){const e=Ze(),t=tt();if(e.length>0){Ne(e);const n=t&&e.find(e=>e.id===t)?t:e[0].id;Se(n);const a=e.find(e=>e.id===n);a&&(F(a.messages.map(e=>({role:e.role,content:e.content}))),zt(a)),console.log("[CHAT] Loaded public share conversations from localStorage:",e.length)}else await Lt();return}const n=await Vm.getSession(p,j||b),a=e=>e?e.filter(e=>!e.isPublicShare):[];if(n.conversations&&0!==n.conversations.length){const r=a(n.conversations);if(0===r.length)await Lt();else{var e,t;Ne(r);const a=(null===(e=r.find(e=>e.id===n.activeConversationId))||void 0===e?void 0:e.id)||(null===(t=r[0])||void 0===t?void 0:t.id);Se(a||null);const s=r.find(e=>e.id===a);s&&(F(s.messages.map(e=>({role:e.role,content:e.content}))),zt(s))}}else if(n.chatMessages&&n.chatMessages.length>0){const e={id:"default",name:"Main Conversation",messages:n.chatMessages.map(e=>d(d({},e),{},{timestamp:new Date})),chatSettings:n.chatSettings,createdAt:new Date,updatedAt:new Date};Ne([e]),Se("default"),F(n.chatMessages.map(e=>({role:e.role,content:e.content}))),zt(e)}else await Lt()}catch(J){console.error("Error loading conversations:",J),await Lt()}})()},[p,j]),(0,a.useEffect)(()=>{if(Fe&&N.length>0){const e=setTimeout(()=>{It()},1e3);return()=>clearTimeout(e)}},[N]);const ln=e=>{const t=new Blob([e.content],{type:"application/ttml+xml"}),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n;let r=e.filename||"".concat(e.id,".ttml");a.download=r.endsWith(".ttml")?r:"".concat(r,".ttml"),document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(n)},cn=e=>e.replace(/```ttml\n[\s\S]*?\n```/g,"").trim();(0,a.useEffect)(()=>{const e=e=>{ne&&"Escape"===e.key&&ae(!1)};if(ne){document.addEventListener("keydown",e);const t=document.querySelector('[role="dialog"]');t&&t.focus()}return()=>{document.removeEventListener("keydown",e)}},[ne]);const dn=()=>{en(null),nn("")},un=async e=>{"user"===N[e].role&&await mn(e)},mn=async e=>{if(W||Y||!o)return;const t=N.slice(0,e+1);$(""),X(""),G(!0),rn.current="";const n=new AbortController;on.current=n;try{const e=t.map(e=>({role:e.role,content:e.content}));console.log("[CHAT] Current TTML files:",h),console.log("[CHAT] Include TTML in context:",rt);let a=h.length>0&&rt?JSON.stringify(h.map(e=>({name:e.name,content:e.content}))):void 0;console.log("[CHAT] TTML content being sent:",a?"Present":"Not present"),console.log("[CHAT] Narrative data available:",!!v),console.log("[CHAT] Include topic map in context:",it);let r=[];if(h.length>0&&rt&&r.push(...h.map(e=>({type:"ttml",name:e.name,content:e.content}))),v&&it?(console.log("[CHAT] Adding narrative/topic map to context, data keys:",Object.keys(v)),r.push({type:"topicMap",name:"Narrative Structure / Topic Map",content:JSON.stringify(v,null,2)})):it&&!v&&console.warn("[CHAT] Topic map toggle is ON but narrativeData is not available yet"),w&<){const e=w.videoStats,t=w.retentionData,n={videoId:w.videoId,videoDurationSeconds:w.videoDurationSeconds,fetchedAt:w.fetchedAt,stats:e?{views:e.views,likes:e.likes,comments:e.comments,shares:e.shares,subscribersGained:e.subscribersGained,subscribersLost:e.subscribersLost,estimatedMinutesWatched:e.estimatedMinutesWatched,averageViewDuration:e.averageViewDuration,averageViewPercentage:e.averageViewPercentage,videoTitle:e.videoTitle,videoPublishedAt:e.videoPublishedAt}:null,retentionCurve:t?t.map(e=>({percent:e.percent,absoluteRetention:e.absoluteRetention,relativeRetention:e.relativeRetention,timestampSeconds:e.timestampSeconds})):[]};r.push({type:"youtubeStats",name:"YouTube Analytics Data (All-Time)",content:JSON.stringify(n,null,2)}),console.log("[CHAT] YouTube stats included in context:",n)}if(mt.length>0&&dt){const e=mt.map(e=>({timestamp:e.timestamp_seconds,formattedTime:e.timestamp_seconds?"".concat(Math.floor(e.timestamp_seconds/3600).toString().padStart(2,"0"),":").concat(Math.floor(e.timestamp_seconds%3600/60).toString().padStart(2,"0"),":").concat(Math.floor(e.timestamp_seconds%60).toString().padStart(2,"0")):"no timestamp",content:e.content,author:e.user_name||"Anonymous",type:e.type||"comment",createdAt:e.created_at}));r.push({type:"comments",name:"Session Comments & Annotations",content:JSON.stringify(e,null,2)}),console.log("[CHAT] Comments included in context:",e.length)}let s=r.length>0?JSON.stringify(r):a;console.log("[CHAT] Context content array:",r.map(e=>({type:e.type,name:e.name}))),console.log("[CHAT] combinedContextContent first 500 chars:",null===s||void 0===s?void 0:s.substring(0,500)),console.log("[CHAT] Combined context content being sent:",s?"".concat(r.length," items"):"None");const i=Gt.filter(e=>e.includedInContext),c=await Promise.all(i.map(async e=>{if(!e.transcript||!e.ttmlFiles){console.log("[CHAT] Loading full data for session ".concat(e.sessionId));try{const t=await Vm.getSessionForContext(e.sessionId,j||void 0);return d(d({},e),{},{transcript:t.transcript,ttmlFiles:t.ttmlFiles})}catch(J){return console.error("[CHAT] Failed to load session data for ".concat(e.sessionId,":"),J),e}}return e}));let u="";if(c.length>0){const e="\n**SESSION CONTEXT:**\n\nThe following are transcripts and TTML files from other sessions that are relevant to this conversation. Use this context to provide more comprehensive analysis and insights:\n\n".concat(c.map(e=>{const t=e.speakerCount>0?" (".concat(e.speakerCount," speakers: ").concat(e.speakerNames.join(", "),")"):"",n=e.isYouTubeMode?"\ud83c\udfa5 YouTube Video":"\ud83c\udf99\ufe0f Audio File";let a="### ".concat(n,": ").concat(e.title).concat(t,"\n**Session ID:** ").concat(e.sessionId,"\n**Filename:** ").concat(e.filename,"\n**Word Count:** ").concat(e.wordCount," words\n\n**TRANSCRIPT:**\n```\n").concat(e.transcript?Vt(e.transcript,e.wordCount):"[Transcript will be loaded when needed]","\n```");return e.ttmlFiles&&e.ttmlFiles.length>0&&(a+="\n\n**TTML FILES:**\n".concat(e.ttmlFiles.map(e=>"\n#### ".concat(e.name,"\n```xml\n").concat(e.content,"\n```")).join("\n"))),a}).join("\n\n---\n\n"));u=e}let m="";const g=Ht.filter(e=>!1!==Wt[e.id]);g.length>0&&(m="\n\n**UPLOADED FILES CONTEXT:**\n\n".concat(g.map(e=>"### File: ".concat(e.name,"\n**Type:** ").concat(e.type,"\n**Size:** ").concat(e.size," bytes\n\n```\n").concat(e.content||"[Content not loaded]","\n```")).join("\n\n---\n\n")));let x=o;u&&(x+="\n\n"+u),m&&(x+="\n\n"+m),ie&&(x+="\n\n"+_k),await Op.chatWithTranscriptStreaming(x,l,e,e=>{var t;null!==(t=on.current)&&void 0!==t&&t.signal.aborted||(rn.current+=e,X(rn.current))},(e,n)=>{const a={id:n,content:e,messageIndex:t.length,createdAt:new Date,filename:n};Z(e=>[...e,a]),te('TTML file "'.concat(n,'" ready for download!')),setTimeout(()=>te(""),5e3)},()=>{},e=>{console.error("[CHAT] Streaming error:",e),$(e)},j||void 0,s||a,g,p,n,!1,void 0,void 0,Fe,y?Lp.getApiKey():null,"none"!==me?{effort:me}:null,pe,y?b:null),G(!1),X("");const f=rn.current;rn.current="",on.current=null;
2const k=[...t,{role:"assistant",content:f}];F(k),Pt(k),await It(!0,k)}catch(a){const e=a instanceof Error?a.message:"Failed to send message";console.error("[CHAT] Error in sendMessageFromIndex:",a),$(e),G(!1),X(""),rn.current="",on.current=null}},hn=async()=>{if(!H.trim()||W||Y||!o)return;if(D&&"DISABLED"===D.chatMode)return void $("Chat is disabled for this share link");if(D&&"READ_ONLY"===D.chatMode)return void $("Chat is read-only for this share link");if(y&&!Lp.hasApiKey())return void $("Please enter your OpenRouter API key to use chat. Click the settings button above to add your key.");console.log("[CHAT] sendMessage called, sessionContext state:",Gt);const e=H.trim();q(""),$(""),X(""),Ke?(console.log("[CHAT] Automated retry in progress, preserving retry state"),Xe(!1)):(Ve(0),We(null),Ge(null),console.log("[CHAT] Reset retry state for new user message"));const t=[...N,{role:"user",content:e}];F(t),G(!0),rn.current="",Pt(t);const n=new AbortController;on.current=n;try{var a;const u=t.map(e=>({role:e.role,content:e.content}));console.log("[CHAT] Current TTML files:",h),console.log("[CHAT] Include TTML in context:",rt);let m=h.length>0&&rt?JSON.stringify(h.map(e=>({name:e.name,content:e.content}))):void 0;console.log("[CHAT] TTML content being sent:",m?"Present":"Not present"),console.log("[CHAT-REGEN] Narrative data available:",!!v),console.log("[CHAT-REGEN] Include topic map in context:",it);let g=[];if(h.length>0&&rt&&g.push(...h.map(e=>({type:"ttml",name:e.name,content:e.content}))),v&&it?(console.log("[CHAT-REGEN] Adding narrative/topic map to context, data keys:",Object.keys(v)),g.push({type:"topicMap",name:"Narrative Structure / Topic Map",content:JSON.stringify(v,null,2)})):it&&!v&&console.warn("[CHAT-REGEN] Topic map toggle is ON but narrativeData is not available yet"),w&<){const e=w.videoStats,t=w.retentionData,n={videoId:w.videoId,videoDurationSeconds:w.videoDurationSeconds,fetchedAt:w.fetchedAt,stats:e?{views:e.views,likes:e.likes,comments:e.comments,shares:e.shares,subscribersGained:e.subscribersGained,subscribersLost:e.subscribersLost,estimatedMinutesWatched:e.estimatedMinutesWatched,averageViewDuration:e.averageViewDuration,averageViewPercentage:e.averageViewPercentage,videoTitle:e.videoTitle,videoPublishedAt:e.videoPublishedAt}:null,retentionCurve:t?t.map(e=>({percent:e.percent,absoluteRetention:e.absoluteRetention,relativeRetention:e.relativeRetention,timestampSeconds:e.timestampSeconds})):[]};g.push({type:"youtubeStats",name:"YouTube Analytics Data (All-Time)",content:JSON.stringify(n,null,2)}),console.log("[CHAT-REGEN] YouTube stats included in context:",n)}if(mt.length>0&&dt){const e=mt.map(e=>({timestamp:e.timestamp_seconds,formattedTime:e.timestamp_seconds?"".concat(Math.floor(e.timestamp_seconds/3600).toString().padStart(2,"0"),":").concat(Math.floor(e.timestamp_seconds%3600/60).toString().padStart(2,"0"),":").concat(Math.floor(e.timestamp_seconds%60).toString().padStart(2,"0")):"no timestamp",content:e.content,author:e.user_name||"Anonymous",type:e.type||"comment",createdAt:e.created_at}));g.push({type:"comments",name:"Session Comments & Annotations",content:JSON.stringify(e,null,2)}),console.log("[CHAT-REGEN] Comments included in context:",e.length)}let x=g.length>0?JSON.stringify(g):m;console.log("[CHAT-REGEN] Context content array:",g.map(e=>({type:e.type,name:e.name}))),console.log("[CHAT-REGEN] combinedContextContent first 500 chars:",null===(a=x)||void 0===a?void 0:a.substring(0,500)),console.log("[CHAT-REGEN] Combined context content being sent:",x?"".concat(g.length," items"):"None");const f=Gt.filter(e=>e.includedInContext);console.log("[CHAT] Session context data:",Gt),console.log("[CHAT] Enabled sessions:",f);const k=await Promise.all(f.map(async e=>{if(!e.transcript||!e.ttmlFiles){console.log("[CHAT] Loading full data for session ".concat(e.sessionId));try{const t=await Vm.getSessionForContext(e.sessionId,j||void 0);return d(d({},e),{},{transcript:t.transcript,ttmlFiles:t.ttmlFiles})}catch(J){return console.error("[CHAT] Failed to load session data for ".concat(e.sessionId,":"),J),e}}return e}));if(console.log("[CHAT] Enabled sessions with loaded data:",k),console.log("[CHAT] Session context detailed data:"),k.forEac
2h(e=>{var t,n;console.log("[CHAT] Session ".concat(e.sessionId,":"),{title:e.title,hasTranscript:!!e.transcript,transcriptLength:(null===(t=e.transcript)||void 0===t?void 0:t.length)||0,hasTtml:!!e.ttmlFiles,ttmlCount:(null===(n=e.ttmlFiles)||void 0===n?void 0:n.length)||0})}),k.length>0){var r,s,i,c;const e="\n**SESSION CONTEXT:**\n\nThe following are transcripts and TTML files from other sessions that are relevant to this conversation. Use this context to provide more comprehensive analysis and insights:\n\n".concat(k.map(e=>{const t=e.speakerCount>0?" (".concat(e.speakerCount," speakers: ").concat(e.speakerNames.join(", "),")"):"",n=e.isYouTubeMode?"\ud83c\udfa5 YouTube Video":"\ud83c\udf99\ufe0f Audio File";let a="### ".concat(n,": ").concat(e.title).concat(t,"\n**Session ID:** ").concat(e.sessionId,"\n**Filename:** ").concat(e.filename,"\n**Word Count:** ").concat(e.wordCount," words\n\n**TRANSCRIPT:**\n```\n").concat(e.transcript?Vt(e.transcript,e.wordCount):"[Transcript will be loaded when needed]","\n```");return e.ttmlFiles&&e.ttmlFiles.length>0&&(a+="\n\n**TTML FILES:**\n".concat(e.ttmlFiles.map(e=>"\n**".concat(e.name,":**\n```ttml\n").concat(e.content,"\n```\n")).join(""))),a}).join("\n\n---\n\n"),"\n\nWhen referencing information from these sessions in your response, always specify which session you're referencing (e.g., \"In the session '").concat((null===(r=k[0])||void 0===r?void 0:r.title)||"Session Title","' (").concat((null===(s=k[0])||void 0===s||null===(i=s.sessionId)||void 0===i?void 0:i.substring(0,8))||"ID",'...)").\n');x=x?"".concat(e,"\n\n").concat(x):e,console.log("[CHAT] Session context prompt added to combinedContextContent:",e.substring(0,200)+"..."),console.log("[CHAT] Full session context prompt length:",e.length),console.log("[CHAT] Final combinedContextContent length after adding session context:",(null===(c=x)||void 0===c?void 0:c.length)||0)}const D=Ht.filter(e=>!1!==Wt[e.id]);if(D.length>0){const e="\n**UPLOADED FILES CONTEXT:**\n\n".concat(D.map(e=>"text"===e.type?"**".concat(e.name," (Text File):**\n```\n").concat(e.content,"\n```"):"pdf"===e.type?"**".concat(e.name," (PDF File):**\n[PDF content included as base64 - ").concat(kn(e.size),"]"):"image"===e.type?"**".concat(e.name," (Image File):**\n[Image included as base64 - ").concat(kn(e.size),"]"):"").join("\n\n"),"\n\nPlease analyze these files in conjunction with the transcript content.\n");x=x?"".concat(e,"\n\nCONTEXT DATA:\n").concat(x):e}if(ie){const e="\n**STORYTELLING CONTEXT FOR VIDEO EDITING ANALYSIS:**\n\nThe following is comprehensive storytelling knowledge that will help you provide better analysis and recommendations for video editing. This knowledge covers narrative techniques that are crucial for engagement and should inform your analysis:\n\n```\n".concat(_k,"\n```\n\nWhen analyzing content or providing editing recommendations, please apply these storytelling principles to help identify:\n- Opportunities for stronger narrative structure\n- Ways to enhance emotional engagement\n- Techniques to improve pacing and tension\n- Methods to create more compelling hooks and reveals\n- Approaches to better connect with the audience\n\nUse this storytelling framework to enhance your analysis and provide more valuable, engagement-focused recommendations.\n");x=x?"".concat(e,"\n\n").concat(x):e}const C=D;let S="";k.length>0&&(S="\n**SESSION CONTEXT:**\n\nThe following are transcripts and TTML files from other sessions that are relevant to this conversation. Use this context to provide more comprehensive analysis and insights:\n\n".concat(k.map(e=>{const t=e.speakerCount>0?" (".concat(e.speakerCount," speakers: ").concat(e.speakerNames.join(", "),")"):"",n=e.isYouTubeMode?"\ud83c\udfa5 YouTube Video":"\ud83c\udf99\ufe0f Audio File";let a="### ".concat(n,": ").concat(e.title).concat(t,"\n**Session ID:** ").concat(e.sessionId,"\n**Filename:** ").concat(e.filename,"\n**Word Count:** ").concat(e.wordCount," words\n\n**TRANSCRIPT:**\n```\n").concat(e.transcript?Vt(e.transcript,e.wordCount):"[Transcript will be loaded when needed]","\n```");return e.ttmlFiles&&e.ttmlFiles.length>0&&(a+="\n\n**TTML FILES:**\n".concat(e.ttmlFiles.map(e=>"\n**".concat(e.name,":**\n```ttml\n").concat(e.content,"\n```\n")).join(""))),a}).join("\n\n---\n\n"),"\n"));let E="";D.length>0&&(E="\n**UPLOADED FILES CONTEXT:**\n\n".concat(D.map(e=>"text"===e.type?"**".concat(e.name," (Text File):**\n```\n").concat(e.content,"\n```"):"pdf"===e.type?"**".concat(e.name," (PDF File):**\n[PDF content included as base64 - ").concat(kn(e.size),"]"):"image"===e.type?"**".concat(e.name," (Image File):**\n[Image included as base64 - ").concat(kn(e.size),"]"):"").join("\n\n"),"\n"));if(!y&&p&&Fe&&j){const t=kt(o,g,S,E,ie,pe),n=N.map(e=>({role:e.role,content:e.content}));console.log("[ASYNC-CHAT] Submitting job with system prompt length:",t.length),console.log("[ASYNC-CHAT] Previous messages count:",n.length);const a=Ht.filter(e=>!1!==Wt[e.id]);console.log("[ASYNC-CHAT] Enabled files for multimodal:",a.map(e=>({id:e.id,name:e.name,type:e.type,mimeType:e.mimeType})));const r=await Om.createAsyncChatJob(p,Fe,e,le?"".concat(l,":online"):l,{disableTimecodeLinks:pe,autoName:!0},j,t,n,a.map(e=>({id:e.id,name:e.name,type:e.type,size:e.size,mimeType:e.mimeType})));return console.log("[ASYNC-CHAT] Job created:",r.jobId),void Oe(t=>{const n=new Map(t);return n.set(Fe,{jobId:r.jobId,prompt:e,status:"pending"}),n})}await Op.chatWithTranscriptStreaming(o,le?"".concat(l,":online"):l,u,(e,t)=>{console.log("[CHAT] onChunk called with content:",(null===e||void 0===e?void 0:e.length)||0,"chars, total:",rn.current.length),rn.current+=e,X(rn.current)},(e,t)=>{const n={id:t,content:e,messageIndex:N.length,createdAt:new Date};Z(e=>[...e,n]),te('TTML file "'.concat(t,'" ready for download!')),setTimeout(()=>te(""),5e3)},e=>{let t=rn.current;console.log("[CHAT] Final content preview:",t.substring(0,200)),c
2onsole.log("[CHAT] Current messages length:",N.length),G(!1),X(""),rn.current="",on.current=null;const n=((e,t)=>{console.log("[CHAT] extractTTMLBlocks called with messageIndex: ".concat(t)),console.log("[CHAT] Content to search:",e);const n=[],a=/```ttml\n([\s\S]*?)\n```/g;let r;for(;null!==(r=a.exec(e));){console.log("[CHAT] Found traditional TTML block:",r[1].substring(0,100));const e=r[1].trim();if(e){const a=e=>e.includes("r_overview")||e.includes("d_overview")?"overview":e.includes("r_clips")||e.includes("d_clips")?"clips":e.includes("r_best")||e.includes("d_best")?"best-parts":e.includes("r_weak")||e.includes("d_weak")?"weak-parts":e.includes("r_summary")||e.includes("d_summary")?"summary":e.includes("r_clip")||e.includes("d_clip")?"clip":e.includes("r_edit")||e.includes("d_edit")?"edit":"ttml",r=a(e),s={id:"".concat(r,"-").concat(t,"-").concat(n.length),content:e,messageIndex:t,createdAt:new Date};console.log("[CHAT] Created TTML block:",s.id,"for messageIndex:",t),n.push(s)}}const s=/<tt[^>]*>[\s\S]*?<\/tt>/g;let i;for(;null!==(i=s.exec(e));){const e=i[0].trim();console.log("[CHAT] Found TTML XML block:",e.substring(0,100));const a=(e,t)=>e.includes("r_overview")||e.includes("d_overview")?"overview.ttml":e.includes("r_clips")||e.includes("d_clips")?"clips.ttml":e.includes("r_best")||e.includes("d_best")?"best-parts.ttml":e.includes("r_weak")||e.includes("d_weak")?"weak-parts.ttml":e.includes("r_summary")||e.includes("d_summary")?"summary.ttml":e.includes("script_clips")?"script-clips-".concat(t+1,".ttml"):e.includes("doom_debate")?"doom-debate.ttml":e.includes("main_interview")?"main-interview.ttml":e.includes("patreon_warmup")?"patreon-warmup.ttml":"ttml-file-".concat(t+1,".ttml"),r=a(e,n.length),s=r.replace(".ttml",""),o={id:"".concat(s,"-").concat(t,"-").concat(n.length),content:e,messageIndex:t,createdAt:new Date,filename:r};console.log("[CHAT] Created TTML block with filename: ".concat(r)),n.push(o)}return console.log("[CHAT] Total TTML blocks found: ".concat(n.length)),n})(t,N.length);console.log("[CHAT] Extracted TTML files:",n),n.length>0&&(Z(e=>{const t=[...e,...n];return console.log("[CHAT] Updated TTML files array:",t),t}),te("".concat(n.length," TTML file").concat(n.length>1?"s":""," ready for download!")),setTimeout(()=>te(""),5e3)),F(e=>{const n=e[e.length-1];if(n&&"assistant"===n.role&&n.content===t)return console.log("[CHAT] Skipping duplicate message"),e;const a=[...e,{role:"assistant",content:t}];return console.log("[CHAT] Updated messages array length:",a.length),setTimeout(async()=>{await It(!0,a),await Pt(a)},100),a}),console.log("Streaming completed with usage:",e)},e=>{if(console.error("Streaming error:",e),!e.includes("cancelled")&&!e.includes("aborted")&&($(e),e.includes("Provider returned error")||e.includes("tool_call")||e.includes("streaming"))){var n;console.log("[CHAT] Attempting self-healing for provider error...");const a=(null===(n=t[t.length-1])||void 0===n?void 0:n.content)||"",r=Ye===a&&e.includes("Provider returned error");if(r&&Ue>=He)return console.error("[CHAT] Provider error retry limit exceeded. Manual intervention required."),$("Provider connection failed after ".concat(He," attempts. Please try again later or check your connection.")),Ve(0),void Ge(null);r?Ve(e=>e+1):(Ve(1),Ge(a));let s="";const i=r?Ue+1:1;s=e.includes("tool_call")||e.includes("during continuation")?"I encountered a tool execution error during processing. Let me try a simpler approach to ".concat(a,".\n\n**Attempt ").concat(i,"/").concat(He,"** - Using alternative method without complex tool calls."):e.includes("streaming")||e.includes("continuation stream")?'I encountered a streaming error during processing. Let me retry your request: "'.concat(a,'"\n\n**Attempt ').concat(i,"/").concat(He,"** - Retrying with improved error handling."):e.includes("recursive")?'I encountered an error during follow-up processing. Let me restart your request: "'.concat(a,'"\n\n**Attempt ').concat(i,"/").concat(He,"** - Using simplified processing approach."):'I encountered a provider error. Let me try a different approach to: "'.concat(a,'"\n\n**Attempt ').concat(i,"/").concat(He,"** - Using alternative processing method.");const o=2e3*Math.pow(1.5,i-1);return void setTimeout(()=>{Xe(!0),F(e=>[...e,{role:"user",content:s}]),$(""),X("\n\n*Retrying with enhanced error handling (attempt ".concat(i,"/").concat(He,")...*")),setTimeout(()=>{if(!Y){pn({key:"Enter",shiftKey:!1,preventDefault:()=>{},currentTarget:{value:""}})}},1e3)},o)}F(t),X(""),rn.current="",G(!1),on.current=null},j,x,C,p,n,!1,(e,t)=>{},(e,t)=>{},Fe,y?Lp.getApiKey():null,"none"!==me?{effort:me}:null,pe,y?b:null)}catch(u){console.error("Chat failed:",u);const e=u instanceof Error?u.message:"Failed to send message";e.includes("cancelled")||e.includes("aborted")||$(e),F(t),X(""),G(!1),on.current=null}};(0,a.useEffect)(()=>{h.length>0&&!re&&(se(!0),te("".concat(h.length," TTML file").concat(h.length>
21?"s":""," automatically added to chat context for video editing assistance")),setTimeout(()=>te(""),3e3))},[h,re]);const pn=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),hn())},gn=e=>e.split("/").map(e=>e.replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())).join(" / "),xn=async e=>{for(const t of Array.from(e))if(t.size>52428800)$("File ".concat(t.name," is too large. Maximum size is 50MB."));else if(p)try{const e=await Vm.uploadFile(p,t,j||void 0),n={id:e.file.id,name:e.file.name,type:e.file.type,size:e.file.size,mimeType:e.file.mimeType,uploadedAt:e.file.uploadedAt,content:void 0,s3Key:void 0,isLoading:!1,includedInContext:!0};qt(e=>[...e,n]),Yt(e=>d(d({},e),{},{[n.id]:!0}))}catch(J){console.error("Failed to upload file to session:",J),$("Failed to upload ".concat(t.name,": ").concat(J instanceof Error?J.message:"Unknown error"))}else{const e="file_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9));let n,a;if(t.type.startsWith("image/"))n="image",a=await fn(t);else if("application/pdf"===t.type)n="pdf",a=await fn(t);else{if(!(t.type.startsWith("text/")||t.name.endsWith(".txt")||t.name.endsWith(".md"))){$("Unsupported file type: ".concat(t.type));continue}n="text",a=await t.text()}const r={id:e,name:t.name,type:n,content:a,size:t.size,mimeType:t.type,uploadedAt:(new Date).toISOString(),isLoading:!1,includedInContext:!0};qt(e=>[...e,r]),Yt(t=>d(d({},t),{},{[e]:!0}))}},fn=e=>new Promise((t,n)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>{const e=a.result;t(e.split(",")[1])},a.onerror=e=>n(e)}),bn=e=>{e.preventDefault(),Jt(!0)},yn=e=>{e.preventDefault(),Jt(!1)},vn=e=>{e.preventDefault(),Jt(!1),e.dataTransfer.files&&xn(e.dataTransfer.files)},wn=async e=>{if(p)try{await Vm.deleteFile(p,e,j||void 0)}catch(J){return console.error("Failed to delete file from session:",J),void $("Failed to delete file: ".concat(J instanceof Error?J.message:"Unknown error"))}qt(t=>t.filter(t=>t.id!==e)),Yt(t=>{const n=d({},t);return delete n[e],n})},kn=e=>{if(0===e)return"0 Bytes";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},jn=!ne&&"undefined"!==typeof window&&window.location.pathname.includes("/session/"),Dn=ne?"fixed inset-0 z-50 bg-white dark:bg-gray-900 flex flex-col":jn?"h-full flex flex-col bg-white dark:bg-gray-800":"bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700",Cn=ne||jn?"flex-1 flex flex-col p-4 space-y-4 overflow-hidden":"p-6 space-y-6",Nn=ne||jn?"flex-1 overflow-y-auto space-y-4 p-4 bg-gray-50 dark:bg-gray-700 rounded-lg min-h-0":"h-96 overflow-y-auto space-y-4 p-4 bg-gray-50 dark:bg-gray-700 rounded-lg overflow-x-hidden",Fn=(0,a.useMemo)(()=>({code:e=>{let{className:t,children:n}=e,a=T(e,Mk);const r=/language-(\w+)/.exec(t||""),s=!a.node||"pre"!==a.node.tagName;return!s&&r&&"ttml"===r[1]?null:(0,u.jsx)("code",d(d({className:"".concat(t," ").concat(s?"bg-gray-200 dark:bg-gray-600 text-gray-800 dark:text-gray-100 px-1 py-0.5 rounded text-xs":"block bg-gray-200 dark:bg-gray-600 text-gray-800 dark:text-gray-100 p-2 rounded text-xs overflow-x-auto")},a),{},{children:n}))},pre:e=>{let{children:t}=e;return(0,u.jsx)("pre",{className:"bg-gray-200 dark:bg-gray-600 rounded p-2 overflow-x-auto my-2",children:t})},p:e=>{let{children:t}=e;return(0,u.jsx)("div",{className:"mb-2 last:mb-0 text-gray-900 dark:text-gray-100",children:t})},ul:e=>{let{children:t}=e;return(0,u.jsx)("ul",{className:"list-disc list-inside mb-2 text-gray-900 dark:text-gray-100",children:t})},ol:e=>{let{children:t}=e;return(0,u.jsx)("ol",{className:"list-decimal list-inside mb-2 text-gray-900 dark:text-gray-100",children:t})},li:e=>{let{children:t}=e;return(0,u.jsx)("li",{className:"mb-1 text-gray-900 dark:text-gray-100",children:t})},h1:e=>{let{children:t}=e;return(0,u.jsx)("h1",{className:"text-lg font-bold mb-2 text-gray-900 dark:text-gray-100",children:t})},h2:e=>{let{children:t}=e;return(0,u.jsx)("h2",{className:"text-base font-bold mb-2 text-gray-900 dark:text-gray-100",children:t})},h3:e=>{let{children:t}=e;return(0,u.jsx)("h3",{className:"text-sm font-bold mb-1 text-gray-900 dark:text-gray-100",children:t})},strong:e=>{let{children:t}=e;return(0,u.jsx)("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",children:t})},em:e=>{let{children:t}=e;return(0,u.jsx)("em",{className:"italic text-gray-900 dark:text-gray-100",children:t})},blockquote:e=>{let{children:t}=e;return(0,u.jsx)("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-700 dark:text-gray-300",children:t})},table:e=>{let{children:t}=e;return(0,u.jsx)("div",{className:"overflow-x-auto my-2",children:(0,u.jsx)("table",{className:"min-w-full border-collapse border border-gray-300 dark:border-gray-600 text-sm",children:t})})},thead:e=>{let{children:t}=e;return(0,u.jsx)("thead",{className:"bg-gray-100 dark:bg-gray-700",children:t})},tbody:e=>{let{children:t}=e;return(0,u.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-600",children:t})},tr:e=>{let{children:t}=e;return(0,u.jsx)("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-700/50",children:t})},th:e=>{let{children:t}=e;return(0,u.jsx)("th",{className:"px-3 py-2 text-left font-semibold text-gray-900 dark:text-gray-100 border border-gray-300 dark:border-gray-600",children:t})},td:e=>{let{children:t}=e;return(0,u.jsx)("td",{className:"px-3 py-2 text-gray-900 dark:text-gray-100 border border-gray-300 dark:border-gray-600",children:t})},a:_t}),[_t]);return(0,u.jsxs)(bk,{children:[(0,u.jsx)(Do.div,{initial:{opacity:0,y:20}
2,animate:{opacity:1,y:0},className:Dn,role:ne?"dialog":void 0,"aria-modal":ne?"true":void 0,"aria-labelledby":ne?"chat-modal-title":void 0,"aria-describedby":ne?"chat-modal-description":void 0,tabIndex:ne?-1:void 0,children:(0,u.jsxs)("div",{className:jn?"flex h-full min-h-0":"flex h-full",children:[(0,u.jsx)(uk,{conversations:Ce,activeConversationId:Fe,isCollapsed:!ne&&!jn||Ee,onToggleCollapse:()=>Ae(!Ee),onSelectConversation:Ot,onCreateConversation:Lt,onDeleteConversation:async e=>{if(p&&(j||b))try{if(1===Ce.length){qt([]),Yt({});const e={id:"conv_".concat(Date.now(),"_").concat(Math.random().toString(36).substring(2,15)),name:"New Conversation",messages:[],createdAt:new Date,updatedAt:new Date,isPinned:!1,isPublicShare:y,ownerId:y?Pp.getBrowserId():void 0,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,uploadedFiles:[],fileContextToggles:{},sessionContext:Gt,includeTTMLInContext:rt,includeTopicMapInContext:it,includeCommentsInContext:dt,includeYouTubeStatsInContext:lt}};Ne([e]),Se(e.id),F([]),y?(et([e]),nt(e.id)):j&&await Vm.updateSession({sessionId:p,conversations:[e],activeConversationId:e.id},j),console.log("[CHAT] Deleted last conversation and created new one:",e.id)}else{const a=Ce.filter(t=>t.id!==e);if(Ne(a),y){if(et(a),e===Fe){var t;const e=null===(t=a[0])||void 0===t?void 0:t.id;e&&(nt(e),await Ot(e))}}else if(j&&(await Vm.deleteConversation(p,e,j),e===Fe)){var n;const e=null===(n=a[0])||void 0===n?void 0:n.id;e&&await Ot(e)}}}catch(J){console.error("Error deleting conversation:",J)}},onRenameConversation:async(e,t)=>{if(p&&(j||b))try{const n=Ce.map(n=>n.id===e?d(d({},n),{},{name:t,updatedAt:new Date}):n);Ne(n),y?et(n):j&&await Vm.updateConversation(p,e,{name:t},j)}catch(J){console.error("Error renaming conversation:",J)}},onGenerateConversationName:Ut,onDuplicateConversation:async e=>{if(p&&j)try{const t=Ce.find(t=>t.id===e);if(!t)return;const n={id:"conv_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9)),name:"".concat(t.name," (Copy)"),messages:[...t.messages],chatSettings:t.chatSettings?d({},t.chatSettings):void 0,createdAt:new Date,updatedAt:new Date,isPinned:!1};Ne(e=>[...e,n]),Se(n.id),zt(n),F(n.messages.map(e=>({role:e.role,content:e.content}))),await Bt(n)}catch(J){console.error("Error duplicating conversation:",J)}},onTogglePinConversation:async e=>{if(p&&j)try{const t=Ce.find(t=>t.id===e);if(!t)return;const n=d(d({},t),{},{isPinned:!t.isPinned,updatedAt:new Date});Ne(t=>t.map(t=>t.id===e?n:t)),await Bt(n)}catch(J){console.error("Error toggling pin status:",J)}},onBatchGenerate:()=>Be(!0),isGeneratingName:Te,isReadOnly:!!D&&"READ_ONLY"===D.chatMode,activeJobs:ze}),(0,u.jsxs)("div",{className:Cn+(jn?" min-h-0":""),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"rounded-2xl border border-[#FFB52B]/25 bg-[#FFB52B]/[0.14] p-2 shadow-[0_18px_30px_-24px_rgba(255,181,43,0.92)]",children:(0,u.jsx)(ky,{size:24,className:"text-[#232E3F] dark:text-[#FFCF74]"})}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("h3",{id:"chat-modal-title",className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:["Chat with Transcript ",ne&&"(Fullscreen)"]}),(0,u.jsxs)("p",{id:"chat-modal-description",className:"text-gray-600 dark:text-gray-400 text-sm",children:["Ask questions or discuss the transcript content",(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 ml-2",children:[h.length>0&&(0,u.jsxs)("button",{onClick:()=>{const e=!rt;st(e),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,includeTTMLInContext:e,includeTopicMapInContext:it,includeCommentsInContext:dt,includeYouTubeStatsInContext:lt}},j).catch(e=>{console.error("Failed to save TTML context preference:",e)})},className:"inline-flex items-center px-2 py-1 rounded-full text-xs transition-colors cursor-pointer ".concat(rt?R:z),children:[h.length," TTML File",h.length>
21?"s":""," in Context"]}),v&&(0,u.jsx)("button",{onClick:()=>{const e=!it;ot(e),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,includeTTMLInContext:rt,includeTopicMapInContext:e,includeCommentsInContext:dt,includeYouTubeStatsInContext:lt}},j).catch(e=>{console.error("Failed to save topic map context preference:",e)})},className:"inline-flex items-center px-2 py-1 rounded-full text-xs transition-colors cursor-pointer ".concat(it?O:z),children:"Topic Map in Context"}),w&&w.videoStats&&(0,u.jsx)("button",{onClick:()=>{const e=!lt;ct(e),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,includeTTMLInContext:rt,includeTopicMapInContext:it,includeYouTubeStatsInContext:e}},j).catch(e=>{console.error("Failed to save YouTube stats context preference:",e)})},className:"inline-flex items-center px-2 py-1 rounded-full text-xs transition-colors cursor-pointer ".concat(lt?R:z),children:"YouTube Stats in Context"}),mt.length>0&&(0,u.jsxs)("button",{onClick:()=>{const e=!dt;ut(e),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,includeTTMLInContext:rt,includeTopicMapInContext:it,includeCommentsInContext:e,includeYouTubeStatsInContext:lt}},j).catch(e=>{console.error("Failed to save comments context preference:",e)})},className:"inline-flex items-center px-2 py-1 rounded-full text-xs transition-colors cursor-pointer ".concat(dt?O:z),title:"".concat(mt.length," comments ").concat(dt?"included in":"excluded from"," context"),children:["Comments in Context (",mt.length,")"]})]})]})]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("button",{onClick:()=>{ae(!ne)},className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:ne?"Exit fullscreen":"Enter fullscreen",children:ne?(0,u.jsx)(jy,{size:18}):(0,u.jsx)(Dy,{size:18})}),ne&&(0,u.jsx)("button",{onClick:()=>ae(!1),className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Close fullscreen",children:(0,u.jsx)(Pu,{size:18})}),N.length>0&&(0,u.jsx)("button",{onClick:()=>{on.current&&(on.current.abort(),on.current=null),F([]),$(""),X(""),Z([]),te(""),se(!1),qt([]),Yt({}),Kt([]),rn.current="",Y&&G(!1),p&&j&&Vm.updateSession({sessionId:p,uploadedFiles:[],sessionContext:[]},j).catch(e=>{console.error("Failed to update session with cleared context:",e)})},className:"p-2 text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",title:"Clear conversation",children:(0,u.jsx)(Cy,{size:16})})]})]}),(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-50 dark:bg-gray-700",children:[(0,u.jsxs)("div",{onClick:()=>ue(!de),className:"w-full flex items-center justify-between p-3 text-left hover:bg-gray-100 dark:hover:bg-gray-600 rounded-lg transition-colors cursor-pointer",role:"button",tabIndex:0,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||ue(!de)},children:[(0,u.jsx)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Chat Settings"}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-1 text-xs text-gray-500",children:[(0,u.jsx)("span",{children:gn(l).split(" ")[0]}),ie&&(0,u.jsx)("span",{children:"\u2022 Story"}),le&&(0,u.jsx)("span",{children:"\u2022 Web"}),Ht.length>0&&(0,u.jsxs)("span",{children:["\u2022 ",Ht.filter(e=>!1!==Wt[e.id]).length,"/",Ht.length," files"]}),Gt.length>0&&(0,u.jsxs)("span",{children:["\u2022 ",Gt.filter(e=>e.includedInContext).length,"/",Gt.length," sessions"]})]}),(0,u.jsx)("button",{onClick:e=>{e.stopPropagation();const t=!pe;ge(t),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:t,includeTTMLInContext:rt,includeTopicMapInContext:it}},j).catch(e=>{console.error("Failed to save text-only preference:",e)})},className:"\n px-2 py-1 text-xs rounded-md transition-colors\n ".concat(pe?"bg-gray-700 text-gray-200 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300 dark:bg-gray-600 dark:text-gray-300 dark:hover:bg-gray-500","\n "),title:pe?"Switch to widget view":"Switch to text-only view",children:pe?"Text":"Widget"}),de?(0,u.jsx)(Tu,{size:16}):(0,u.jsx)(wd,{size:16})]})]}),(0,u.jsx)(S,{children:de&&(0,u.jsx)(Do.div,{initial:{height:0,opacity:0}
2,animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},className:"overflow-hidden",children:(0,u.jsxs)("div",{className:"p-3 pt-0 space-y-4",children:[(0,u.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:"Chat Model"}),(0,u.jsx)("select",{value:l,onChange:e=>{const t=e.target.value;c(t),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:t,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:pe,includeTTMLInContext:rt,includeTopicMapInContext:it}},j).catch(e=>{console.error("Failed to save model selection:",e)})},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent",disabled:W,children:m.map(e=>(0,u.jsx)("option",{value:e,children:gn(e)},e))})]}),y&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[(0,u.jsx)(Ny,{className:"inline w-4 h-4 mr-1"}),"OpenRouter API Key"]}),jt&&(0,u.jsx)("span",{className:"text-xs text-[#B57700] dark:text-[#FFCF74]",children:"Connected"})]}),jt?(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("div",{className:"flex-1 px-3 py-2 bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 rounded-lg text-sm font-mono",children:Lp.getMaskedKey()}),(0,u.jsx)("button",{onClick:()=>{Lp.clearApiKey(),gt(""),ft(!0)},className:"px-3 py-2 text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg text-sm transition-colors",children:"Clear"})]}):(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)("input",{type:bt?"text":"password",value:pt,onChange:e=>{gt(e.target.value),wt("")},placeholder:"sk-or-v1-...",className:"w-full px-3 py-2 pr-20 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent font-mono text-sm"}),(0,u.jsx)("button",{type:"button",onClick:()=>yt(!bt),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 text-gray-500 hover:text-gray-700 dark:hover:text-gray-300",children:bt?(0,u.jsx)(Fy,{className:"w-4 h-4"}):(0,u.jsx)(Cp,{className:"w-4 h-4"})})]}),vt&&(0,u.jsx)("p",{className:"text-xs text-red-600 dark:text-red-400",children:vt}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("button",{onClick:()=>{pt.trim()?Lp.isValidKeyFormat(pt)?(Lp.setApiKey(pt),wt("")):wt("Invalid key format. OpenRouter keys start with sk-or-"):wt("Please enter your API key")},className:"px-3 py-1.5 rounded-lg text-sm transition-colors ".concat("bg-[#FFB52B] text-[#232E3F] shadow-[0_18px_32px_-24px_rgba(255,181,43,0.9)] hover:bg-[#FFC54D]"),children:"Save Key"}),(0,u.jsx)("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-xs ".concat(L),children:"Get API Key"})]}),(0,u.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Your key is stored locally in your browser and never saved on our servers."})]}),(0,u.jsx)("div",{className:"mt-3 rounded-lg p-3 ".concat("border border-[#E7B14C]/45 bg-[#FFF8EA] text-[#6F5934] dark:border-[#79613A] dark:bg-[#2B3241] dark:text-[#E4D7BD]"),children:(0,u.jsxs)("p",{className:"text-xs",children:[(0,u.jsx)("strong",{children:"\ud83d\udd12 Your chats are private."})," Conversations you create here are only visible to you and won't be seen by other visitors or the session owner."]})})]}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Additional Context Files"}),(0,u.jsx)("button",{onClick:()=>{var e;
2return null===(e=sn.current)||void 0===e?void 0:e.click()},className:"rounded px-3 py-1 text-xs transition-colors ".concat("bg-[#232E3F] text-[#F4F4F4] hover:bg-[#2F3B4E]"),children:"Upload Files"})]}),(0,u.jsx)("input",{ref:sn,type:"file",multiple:!0,accept:".txt,.md,.pdf,image/*",onChange:e=>e.target.files&&xn(e.target.files),className:"hidden"}),(0,u.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-3 text-center transition-colors ".concat(Xt?"border-[#FFB52B] bg-[#FFF8EA] dark:bg-[#263245]":"border-[#D6DCE4] bg-white dark:border-[#41506A] dark:bg-[#202A3A]"),onDragOver:bn,onDragLeave:yn,onDrop:vn,children:[(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:'Drag & drop files or click "Upload Files"'}),(0,u.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Supports: Text, PDFs, Images"})]}),Ht.length>0&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Files (",Ht.length,"):"]}),(0,u.jsxs)("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[Ht.filter(e=>!1!==Wt[e.id]).length," in context"]})]}),(0,u.jsx)("div",{className:"space-y-2 max-h-32 overflow-y-auto",children:Ht.map(e=>(0,u.jsxs)("div",{className:"flex items-center justify-between rounded p-2 border transition-all ".concat(!1!==Wt[e.id]?"bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-600":"bg-gray-50 dark:bg-gray-700 border-gray-300 dark:border-gray-600 opacity-60"),children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[(0,u.jsx)("span",{className:"px-1.5 py-0.5 text-xs rounded font-medium ".concat("text"===e.type?"border border-[#FFB52B]/40 bg-[#FFF4D8] text-[#8B5B00] dark:border-[#FFB52B]/30 dark:bg-[#FFB52B]/[0.16] dark:text-[#FFE3A1]":"pdf"===e.type?"bg-red-100 dark:bg-red-800 text-red-700 dark:text-red-200":"border border-[#445166] bg-[#232E3F] text-[#F4F4F4]"),children:e.type.toUpperCase()}),(0,u.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",title:e.name,children:e.name})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)("input",{type:"checkbox",id:"file-toggle-".concat(e.id),checked:!1!==Wt[e.id],onChange:()=>(async e=>{const t=!Wt[e];Yt(n=>d(d({},n),{},{[e]:t}));const n=Ht.map(n=>n.id===e?d(d({},n),{},{includedInContext:t}):n);if(qt(n),p&&j)try{await Vm.updateSession({sessionId:p,uploadedFiles:n},j)}catch(J){console.error("Failed to update file context toggle in session:",J),Yt(n=>d(d({},n),{},{[e]:!t})),qt(Ht),$("Failed to update file context setting")}})(e.id),className:"w-3 h-3 ".concat(U),title:"Include in chat context"}),(0,u.jsx)("label",{htmlFor:"file-toggle-".concat(e.id),className:"text-xs text-gray-600 dark:text-gray-400 cursor-pointer",title:"Include in chat context",children:"Context"})]}),(0,u.jsx)("button",{onClick:()=>wn(e.id),className:"p-1 text-gray-400 dark:text-gray-500 hover:text-red-600 dark:hover:text-red-400 transition-colors",title:"Remove file",children:(0,u.jsx)(Pu,{size:14})})]})]},e.id))})]})]})]}),(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("input",{type:"checkbox",id:"web-search",checked:le,onChange:e=>{const t=e.target.checked;ce(t),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:t,textOnlyTimeReferences:pe,includeTTMLInContext:rt,includeTopicMapInContext:it}},j).catch(e=>{console.error("Failed to save web search setting:",e)})},className:"w-4 h-4 ".concat(U)}),(0,u.jsx)("label",{htmlFor:"web-search",className:"text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer",children:"Enable Web Search"})]}),(0,u.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 ml-7",children:"When enabled, the AI can search the web for current information and external references. Uses OpenRouter's web search feature to provide up-to-date context and fact-checking."}),le?(0,u.jsx)("div",{className:"ml-7 rounded px-2 py-1 text-xs border border-[#
2E7B14C]/45 bg-[#FFF4D8] text-[#8B5B00] dark:border-[#8E6E33] dark:bg-[#332A17] dark:text-[#FFE3A1]",children:"\u2713 Web search enabled - AI can access current web information"}):(0,u.jsx)("div",{className:"ml-7 text-xs text-gray-700 bg-gray-50 px-2 py-1 rounded",children:"\u2717 Web search disabled - AI limited to training data"})]}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("input",{type:"checkbox",id:"storytelling-context",checked:ie,onChange:e=>{const t=e.target.checked;oe(t),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:t,enableWebSearch:le,textOnlyTimeReferences:pe,includeTTMLInContext:rt,includeTopicMapInContext:it}},j).catch(e=>{console.error("Failed to save storytelling setting:",e)})},className:"w-4 h-4 ".concat(U)}),(0,u.jsx)("label",{htmlFor:"storytelling-context",className:"text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer",children:"Include Storytelling Context"})]}),(0,u.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 ml-7",children:"Adds comprehensive storytelling knowledge for better video editing recommendations and narrative analysis."}),ie&&(0,u.jsx)("div",{className:"ml-7 rounded px-2 py-1 text-xs border border-[#E7B14C]/45 bg-[#FFF4D8] text-[#8B5B00] dark:border-[#8E6E33] dark:bg-[#332A17] dark:text-[#FFE3A1]",children:"\u2713 Storytelling context active"})]}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("input",{type:"checkbox",id:"disable-timecode-links",checked:pe,onChange:e=>{const t=e.target.checked;ge(t),p&&j&&Vm.updateSession({sessionId:p,chatSettings:{selectedModel:l,useStorytellingContext:ie,enableWebSearch:le,textOnlyTimeReferences:t,includeTTMLInContext:rt,includeTopicMapInContext:it}},j).catch(e=>{console.error("Failed to save timecode links setting:",e)})},className:"w-4 h-4 ".concat(U)}),(0,u.jsx)("label",{htmlFor:"disable-timecode-links",className:"text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer",children:"Disable Timecode Links"})]}),(0,u.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 ml-7",children:'When enabled, the AI will output plain text timestamps (e.g., "at 01:23:45") instead of clickable timecode links. Useful for exporting conversations or when timecode widgets are not needed.'}),pe?(0,u.jsx)("div",{className:"ml-7 text-xs text-orange-700 dark:text-orange-300 bg-orange-50 dark:bg-orange-900/30 px-2 py-1 rounded",children:"\u2713 Timecode links disabled - AI outputs plain text timestamps"}):(0,u.jsx)("div",{className:"ml-7 text-xs text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-gray-700 px-2 py-1 rounded",children:"\u2717 Timecode links enabled - AI outputs clickable timestamp widgets"})]}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("label",{htmlFor:"reasoning-strength",className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Reasoning Strength"}),(0,u.jsxs)("select",{id:"reasoning-strength",value:me,onChange:e=>he(e.target.value),className:"rounded-md border border-[#CDD4DD] bg-white px-2 py-1 text-sm text-[#232E3F] focus:border-[#FFB52B] focus:ring-[#FFB52B]/25 dark:border-[#445166] dark:bg-[#202A3A] dark:text-[#F4F4F4]",children:[(0,u.jsx)("option",{value:"none",children:"None (Disabled)"}),(0,u.jsx)("option",{value:"minimal",children:"Minimal"}),(0,u.jsx)("option",{value:"low",children:"Low"}),(0,u.jsx)("option",{value:"medium",children:"Medium"}),(0,u.jsx)("option",{value:"high",children:"High"}),(0,u.jsx)("option",{value:"xhigh",children:"Extra High"})]})]}),(0,u.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400 ml-0",children:"Enable extended thinking/reasoning for deeper analysis. Higher levels use more tokens but produce more thorough responses."}),"none"!==me&&(0,u.jsxs)("div",{className:"rounded px-2 py-1 text-xs border border-[#445166] bg-[#EEF1F3] text-[#3F4E62] dark:border-[#4F5C72] dark:bg-[#273244] dark:text-[#D5DCE5]",children:["\u2713 Extended thinking active (",me,")"]})]})]})]}),p&&!D&&(0,u.jsx)(ok,{sessionId:p,sessionContext:Gt,onSessionContextUpdate:async e=>{if(Kt(e),p&&j)try{await Vm.updateSession({sessionId:p,sessionContext:e},j)}catch(J){console.error("Failed to update session context:",J),$("Failed to update session context")}}})]})})})]}),Le&&(0,u.jsxs)("div",{className:"mx-4 mb-2 rounded-lg border border-[#445166] bg-[#232E3F] p-3 text-[#F4F4F4]",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(Lo,{className:"w-4 h-4 animate-spin text-[#FFCF74]"}),(0,u.jsx)("span",{className:"text-sm font-medium text-[#F4F4F4]",children:"Generating conversations in background"})]}),(0,u.jsxs)("span",{className:"text-xs text-[#FFCF74]",children:[Le.completed+Le.failed," / ",Le.totalJobs," complete"]})]}),(0,u.jsx)("div",{className:"h-1.5 w-full rounded-full bg-white/10",children:(0,u.jsx)("div",{className:"h-1.5 rounded-full bg-[#FFB52B] transition-all duration-300",style:{width:"".concat((Le.completed+Le.failed)/Le.totalJobs*100,"%")}})}),Le.failed>0&&(0,u.jsxs)("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:[Le.failed," failed"]})]}),(0,u.jsx)("div",{className:ne||jn?"flex-1 flex flex-col space-y-4 min-h-0 overflow-auto":"space-y-4",children:0!==N.length||W?(0,u.jsxs)("div",{className:Nn,children:[0===N.length&&Fe&&(0,u.jsxs)("div",{className:"flex flex-col items-center justify-center py-8",children:[(0,u.jsx)(ky,{className:"w-12 h-12 text-gray-300 dark:text-gray-600 mb-4"}),(0,u.jsx)("h3",{className:"text-lg font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Start a new conversation"}),(0,u.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-6 text-center max-w-md",children:"Use the agent system for richer transcript workflows. This chat stays available for direct ad hoc questions."})]}),(0,u.jsx)(S,{children:N.map((e,t)=>(0,u.jsxs)(Do.div,{initial:{opacity:0,y:10}
2,animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex items-start space-x-3 ".concat("user"===e.role?"justify-end":"justify-start"),children:["assistant"===e.role&&(0,u.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center",children:(0,u.jsx)(wy,{size:16,className:"text-primary-600"})}),(0,u.jsxs)("div",{className:"max-w-[70%] p-3 rounded-lg ".concat("user"===e.role?"bg-primary-600 text-white ml-auto":"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 dark:text-gray-100"),children:[(0,u.jsx)("div",{className:"text-sm",children:"user"===e.role?Zt===t?(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("textarea",{value:tn,onChange:e=>nn(e.target.value),className:"w-full p-2 text-gray-900 bg-white border border-gray-300 rounded-md resize-none focus:outline-none focus:ring-2 focus:ring-primary-500",rows:4,autoFocus:!0}),(0,u.jsxs)("div",{className:"flex gap-2",children:[(0,u.jsx)("button",{onClick:()=>(async e=>{if(tn.trim()&&null!==e){const t=N.slice(0,e);if(t.push({role:"user",content:tn.trim()}),F(t),en(null),nn(""),Fe){const e=Ce.find(e=>e.id===Fe);if(e){const n=d(d({},e),{},{messages:t.map(e=>d(d({},e),{},{timestamp:new Date})),updatedAt:new Date});Ne(e=>e.map(e=>e.id===Fe?n:e)),await Bt(n)}}await un(e)}})(t),className:"px-3 py-1 text-xs text-white bg-primary-600 hover:bg-primary-700 rounded transition-colors",children:"Save & Execute"}),(0,u.jsx)("button",{onClick:dn,className:"px-3 py-1 text-xs text-gray-700 bg-gray-200 hover:bg-gray-300 rounded transition-colors",children:"Cancel"})]})]}):(0,u.jsx)("div",{className:"whitespace-pre-wrap",children:e.content}):(0,u.jsx)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:(0,u.jsx)(my,{remarkPlugins:[Cw],urlTransform:e=>(e.startsWith("timecode://"),e),components:Fn,children:(()=>{const t=cn(e.content);return t})()})})}),"assistant"===e.role&&Q.filter(e=>e.messageIndex===t).length>0&&(0,u.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-200",children:[(0,u.jsx)("div",{className:"text-xs text-gray-600 mb-2",children:"TTML Files Generated:"}),(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:Q.filter(e=>e.messageIndex===t).map(e=>(0,u.jsxs)("button",{onClick:()=>ln(e),className:"flex items-center space-x-1 rounded border border-[#FFB52B]/40 bg-[#FFF4D8] px-2 py-1 text-xs text-[#8B5B00] transition-colors hover:bg-[#FFE7AD] dark:border-[#FFB52B]/30 dark:bg-[#FFB52B]/[0.16] dark:text-[#FFE3A1] dark:hover:bg-[#FFB52B]/[0.24]",children:[(0,u.jsx)(gp,{size:12}),(0,u.jsxs)("span",{children:["Download ",e.filename?e.filename.replace(".ttml","").toUpperCase():e.id.split("-")[0].toUpperCase()]}),(0,u.jsx)(Sp,{size:10})]},e.id))})]}),(0,u.jsxs)("div",{className:"mt-3 pt-3 border-t ".concat("user"===e.role?"border-primary-500/30":"border-gray-200"," flex flex-wrap gap-2"),children:["user"===e.role&&Zt!==t&&(0,u.jsx)("button",{onClick:()=>(e=>{const t=N[e];"user"===t.role&&(en(e),nn(t.content))})(t),className:"flex items-center space-x-1 text-xs bg-gray-100 hover:bg-gray-200 text-gray-700 px-2 py-1 rounded transition-colors",title:"Edit this message",children:(0,u.jsx)(Sy,{size:12})}),Zt!==t&&(!D||"FULL"===D.chatMode||y)&&(0,u.jsx)("button",{onClick:()=>(async e=>{if("user"===N[e].role){const t=N.slice(0,e+1);if(F(t),Fe){const e=Ce.find(e=>e.id===Fe);if(e){const n=d(d({},e),{},{messages:t.map(e=>d(d({},e),{},{timestamp:new Date})),updatedAt:new Date});Ne(e=>e.map(e=>e.id===Fe?n:e)),await Bt(n)}}await un(e)}else{const t=N.slice(0,e);let n=-1;for(let e=t.length-1;e>=0;e--)if("user"===t[e].role){n=e;break}if(n>=0){const e=N.slice(0,n+1);if(F(e),Fe){const t=Ce.find(e=>e.id===Fe);if(t){const n=d(d({},t),{},{messages:e.map(e=>d(d({},e),{},{timestamp:new Date})),updatedAt:new Date});Ne(e=>e.map(e=>e.id===Fe?n:e)),await Bt(n)}}await un(n)}}})(t),className:"flex items-center space-x-1 rounded border border-[#445166] bg-[#232E3F] px-2 py-1 text-xs text-[#F4F4F4] transition-colors hover:bg-[#2F3B4E]",title:"user"===e.role?"Re-execute from this message":"Re-execute from previous user message",children:(0,u.jsx)(vp,{size:12})}),Zt!==t&&(!D||"FULL"===D.chatMode||y)&&(0,u.jsx)("button",{onClick:()=>{window.confirm("Delete this message?")&&(async e=>
2{const t=N.filter((t,n)=>n!==e);if(F(t),Fe){const e=Ce.find(e=>e.id===Fe);if(e){const n=d(d({},e),{},{messages:t.map(e=>d(d({},e),{},{timestamp:new Date})),updatedAt:new Date});Ne(e=>e.map(e=>e.id===Fe?n:e)),await Bt(n)}}})(t)},className:"flex items-center space-x-1 text-xs bg-red-100 hover:bg-red-200 text-red-700 px-2 py-1 rounded transition-colors",title:"Delete this message",children:(0,u.jsx)(kp,{size:12})}),"assistant"===e.role&&e.content.length>100&&(0,u.jsx)("button",{onClick:()=>(async(e,t)=>{try{await navigator.clipboard.writeText(e),Qt(t),setTimeout(()=>Qt(null),2e3)}catch(J){console.error("Failed to copy to clipboard:",J);const a=document.createElement("textarea");a.value=e,document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),Qt(t),setTimeout(()=>Qt(null),2e3)}})(e.content,t),className:"flex items-center space-x-1 text-xs px-2 py-1 rounded transition-colors ".concat($t===t?"border border-[#FFB52B]/40 bg-[#FFF4D8] text-[#8B5B00] hover:bg-[#FFE7AD] dark:border-[#FFB52B]/30 dark:bg-[#FFB52B]/[0.16] dark:text-[#FFE3A1] dark:hover:bg-[#FFB52B]/[0.24]":"bg-gray-100 hover:bg-gray-200 text-gray-700"),title:"Copy message to clipboard",children:$t===t?(0,u.jsx)(u.Fragment,{children:(0,u.jsx)(Wm,{size:12})}):(0,u.jsx)(u.Fragment,{children:(0,u.jsx)(Np,{size:12})})}),"assistant"===e.role&&p&&e.content.length>100&&!y&&(!D||"FULL"===D.chatMode)&&(0,u.jsx)("button",{onClick:()=>(async(e,t)=>{if(p)try{const n=await C(e,t);$(n?"":"Failed to pin message to comments")}catch(n){console.error("Error pinning message:",n),$("Failed to pin message to comments")}else $("No session available to pin message")})(e.content,l),className:"flex items-center space-x-1 text-xs bg-yellow-100 dark:bg-yellow-800 hover:bg-yellow-200 dark:hover:bg-yellow-700 text-yellow-700 dark:text-yellow-200 px-2 py-1 rounded transition-colors",title:"Pin this message to comments for collaboration",children:(0,u.jsx)(Ey,{size:12})})]})]}),"user"===e.role&&(0,u.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center",children:(0,u.jsx)(vh,{size:16,className:"text-gray-600"})})]},"".concat(e.role,"-").concat(t,"-").concat(e.content.slice(0,20))))}),(W||Y)&&(0,u.jsxs)(Do.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex items-start space-x-3",children:[(0,u.jsx)("div",{className:"flex-shrink-0 w-8 h-8 bg-primary-100 rounded-full flex items-center justify-center",children:(0,u.jsx)(wy,{size:16,className:"text-primary-600"})}),(0,u.jsx)("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-600 p-3 rounded-lg max-w-[70%]",children:Y&&K?(0,u.jsx)("div",{className:"text-sm text-gray-900 dark:text-gray-100",children:(0,u.jsxs)("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:[(0,u.jsx)(my,{remarkPlugins:[Cw],urlTransform:e=>(e.startsWith("timecode://"),e),components:Fn,children:K}),(0,u.jsx)("span",{className:"inline-block w-2 h-4 bg-primary-600 ml-1 animate-pulse"})]})}):(0,u.jsxs)("div",{className:"flex items-center space-x-2 text-gray-600 dark:text-gray-400",children:[(0,u.jsx)(Lo,{className:"animate-spin",size:16}),(0,u.jsx)("span",{className:"text-sm",children:Fe&&ze.has(Fe)?(0,u.jsxs)(u.Fragment,{children:["Processing","running"===(null===(i=ze.get(Fe))||void 0===i?void 0:i.status)?"":" (queued)","... You can navigate away and return later."]}):"Thinking..."}),Fe&&ze.has(Fe)&&(0,u.jsxs)("button",{onClick:async()=>{if(!p||!j||!Fe)return;const e=ze.get(Fe);if(e)try{console.log("[ASYNC-CHAT] Cancelling job:",e.jobId);const t=await Om.cancelAsyncChatJob(p,e.jobId,j);t.success?(Oe(e=>{const t=new Map(e);return t.delete(Fe),t}),G(!1),F(e=>e.length>0&&"user"===e[e.length-1].role?e.slice(0,-1):e),console.log("[ASYNC-CHAT] Job cancelled successfully")):(console.error("[ASYNC-CHAT] Failed to cancel job:",t.error),$(t.error||"Failed to cancel job"))}catch(J){console.error("[ASYNC-CHAT] Error cancelling job:",J),$("Failed to cancel job")}},className:"ml-2 px-2 py-1 text-xs bg-red-100 hover:bg-red-200 dark:bg-red-900/30 dark:hover:bg-red-800/50 text-red-600 dark:text-red-400 rounded transition-colors flex items-center gap-1",title:"Cancel generation",children:[(0,u.jsx)(Ay,{size:10,
2className:"fill-current"}),"Cancel"]})]})})]}),(0,u.jsx)("div",{ref:an})]}):(0,u.jsxs)("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:[(0,u.jsx)(ky,{size:48,className:"mx-auto text-gray-300 dark:text-gray-600 mb-4"}),(0,u.jsx)("p",{children:"Start a conversation about your transcript!"})]})}),(0,u.jsx)(S,{children:J&&(0,u.jsx)(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"bg-red-50 dark:bg-red-900 border border-red-200 dark:border-red-700 rounded-lg p-3",children:(0,u.jsx)("p",{className:"text-red-700 dark:text-red-300 text-sm",children:J})})}),(0,u.jsx)(S,{children:ee&&(0,u.jsx)(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"rounded-lg border border-[#E7B14C]/45 bg-[#FFF8EA] p-3 dark:border-[#79613A] dark:bg-[#2B3241]",children:(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)(gp,{size:16,className:"text-[#B57700] dark:text-[#FFCF74]"}),(0,u.jsx)("p",{className:"text-sm font-medium text-[#6F5934] dark:text-[#E4D7BD]",children:ee})]})})}),Q.length>0&&(0,u.jsxs)("div",{className:"p-4 border-t border-b border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700",children:[(0,u.jsx)("h4",{className:"text-sm font-semibold mb-2 text-gray-700 dark:text-gray-300",children:"Downloadable TTML Files:"}),(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:Q.map(e=>(0,u.jsxs)(Do.button,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},onClick:()=>ln(e),className:"flex items-center space-x-2 bg-secondary-100 dark:bg-secondary-900 text-secondary-800 dark:text-secondary-200 px-3 py-1.5 rounded-lg hover:bg-secondary-200 dark:hover:bg-secondary-800 transition-colors text-sm font-medium",children:[(0,u.jsx)(Sp,{size:16}),(0,u.jsx)("span",{children:e.filename?e.filename.replace(".ttml",""):e.id})]},e.id))})]}),(0,u.jsxs)("div",{className:jn?"flex-shrink-0 space-y-3 mt-4":"space-y-3",children:[Ht.length>0&&(0,u.jsxs)("div",{className:"flex flex-wrap gap-2 p-2 bg-gray-50 dark:bg-gray-700/50 rounded-lg border border-gray-200 dark:border-gray-600",children:[Ht.filter(e=>!1!==Wt[e.id]).map(e=>(0,u.jsxs)("div",{className:"relative group flex items-center gap-2 bg-white dark:bg-gray-800 rounded-lg p-2 pr-6 border border-gray-200 dark:border-gray-600 shadow-sm",children:["image"===e.type&&e.content?(0,u.jsx)("img",{src:"data:".concat(e.mimeType,";base64,").concat(e.content),alt:e.name,className:"h-10 w-10 object-cover rounded"}):"image"===e.type?(0,u.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded border border-[#445166] bg-[#232E3F]",children:(0,u.jsx)(Ty,{size:20,className:"text-[#FFCF74]"})}):"pdf"===e.type?(0,u.jsx)("div",{className:"h-10 w-10 bg-red-100 dark:bg-red-800 rounded flex items-center justify-center",children:(0,u.jsx)(gp,{size:20,className:"text-red-600 dark:text-red-300"})}):(0,u.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded border border-[#FFB52B]/40 bg-[#FFF4D8] dark:border-[#FFB52B]/30 dark:bg-[#FFB52B]/[0.16]",children:(0,u.jsx)(gp,{size:20,className:"text-[#B57700] dark:text-[#FFE3A1]"})}),(0,u.jsxs)("div",{className:"flex flex-col",children:[(0,u.jsx)("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 max-w-[100px] truncate",title:e.name,children:e.name}),(0,u.jsx)("span",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:kn(e.size)})]}),(0,u.jsx)("button",{onClick:()=>wn(e.id),className:"absolute -top-1 -right-1 p-0.5 bg-gray-200 dark:bg-gray-600 hover:bg-red-200 dark:hover:bg-red-700 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove file",children:(0,u.jsx)(Pu,{size:12,className:"text-gray-600 dark:text-gray-300"})})]},e.id)),Ht.filter(e=>!1===Wt[e.id]).length>0&&(0,u.jsxs)("span",{className:"flex items-center text-xs text-gray-500 dark:text-gray-400",children:["+",Ht.filter(e=>!1===Wt[e.id]).length," hidden"]})]}),xe&&xe.totalTokens>0&&(0,u.jsxs)("div",{className:"group relative mb-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("div",{className:"flex-1 h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:(0,u.jsx)("div",{className:"h-full rounded-full transition-all duration-500 ".concat("green"===xe.status?"bg-[#FFB52B]":"yellow"===xe.status?"bg-[#E7B14C]":"orange"===xe.status?"bg-[#C98A00]":"bg-[#B56A5D]"),style:{width:"".concat(Math.min(xe.percentUsed,100),"%")}})}),(0,u.jsxs)("span",{className:"text-[10px] font-mono tabular-nums whitespace-nowrap ".concat("green"===xe.status?"text-[#B57700] dark:text-[#FFCF74]":"yellow"===xe.status?"text-[#A36A00] dark:text-[#FFD67D]":"orange"===xe.status?"text-[#8B5B00] dark:text-[#EABF6C]":"text-[#A25D55] dark:text-[#E6B6AE]"),children:[xe.percentUsed,"%"]})]}),(0,u.jsxs)("div",{className:"absolute bottom-full left-0 mb-1 px-2 py-1 bg-gray-900 dark:bg-gray-700 text-white text-xs rounded shadow-lg op
2acity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 whitespace-nowrap",children:["Context: ",xe.totalTokens.toLocaleString()," / ",xe.maxTokens.toLocaleString()," tokens",xe.compactionCount>0&&" (compacted ".concat(xe.compactionCount,"x)")]})]}),(0,u.jsxs)("div",{className:"flex space-x-3 relative ".concat(Xt?"rounded-lg ring-2 ring-[#FFB52B]":""),onDragOver:bn,onDragLeave:yn,onDrop:vn,children:[Xt&&(0,u.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-lg bg-[#FFF4D8]/90 dark:bg-[#232E3F]/90 pointer-events-none",children:(0,u.jsx)("span",{className:"font-medium text-[#8B5B00] dark:text-[#FFE3A1]",children:"Drop files here"})}),(0,u.jsx)("textarea",{value:H,onChange:e=>q(e.target.value),onKeyPress:pn,onPaste:async e=>{const t=e.clipboardData.items,n=[];for(const a of Array.from(t))if(a.type.startsWith("image/")){const e=a.getAsFile();e&&n.push(e)}if(n.length>0){const e=new DataTransfer;n.forEach(t=>e.items.add(t)),await xn(e.files)}},placeholder:D&&"READ_ONLY"===D.chatMode?"Read-only access - chat is disabled":"Ask a question about the transcript... (paste or drop files)",className:"flex-1 p-3 border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-transparent resize-none",rows:2,disabled:W||Y||!o||D&&"READ_ONLY"===D.chatMode||!1}),Y?(0,u.jsxs)("button",{onClick:()=>{on.current&&(on.current.abort(),on.current=null,G(!1),X(""),rn.current="")},className:"px-4 py-3 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors flex items-center space-x-2",title:"Stop generating response",children:[(0,u.jsx)(Ay,{size:16}),(0,u.jsx)("span",{children:"Stop"})]}):(0,u.jsx)("button",{onClick:hn,disabled:!H.trim()||W||!o||D&&"READ_ONLY"===D.chatMode||!1,className:"px-4 py-3 bg-primary-600 text-white rounded-lg hover:bg-primary-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center",children:W?(0,u.jsx)(Lo,{className:"animate-spin",size:20}):(0,u.jsx)(My,{size:20})})]}),!o&&(0,u.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Complete a transcription first to start chatting with the transcript."})]})]})]})}),ve&&(0,u.jsx)(Sk,{isOpen:be,onClose:()=>{ye(!1),we(null)},sessionId:ve.sessionId,startSeconds:ve.startSeconds,endSeconds:ve.endSeconds,sessionTitle:ve.sessionTitle}),(0,u.jsx)(xk,{isOpen:_e,onClose:()=>Be(!1),selectedModel:l,isStarting:Ie,onGenerate:async e=>{if(p&&j&&o){Pe(!0);try{const t=[];if(rt&&h&&h.length>0){const e=h[h.length-1];null!==e&&void 0!==e&&e.content&&t.push({name:"Current TTML Captions",content:e.content.substring(0,5e4)})}if(it&&v&&t.push({name:"Narrative Structure / Topic Map",content:JSON.stringify(v,null,2).substring(0,3e4)}),w&<){const e=w.videoStats,n=w.retentionData,a={videoId:w.videoId,videoDurationSeconds:w.videoDurationSeconds,fetchedAt:w.fetchedAt,stats:e?{views:e.views,likes:e.likes,comments:e.comments,shares:e.shares,subscribersGained:e.subscribersGained,subscribersLost:e.subscribersLost,estimatedMinutesWatched:e.estimatedMinutesWatched,averageViewDuration:e.averageViewDuration,averageViewPercentage:e.averageViewPercentage,videoTitle:e.videoTitle,videoPublishedAt:e.videoPublishedAt}:null,retentionCurve:n?n.map(e=>({percent:e.percent,absoluteRetention:e.absoluteRetention,relativeRetention:e.relativeRetention,timestampSeconds:e.timestampSeconds})):[]};t.push({name:"YouTube Analytics Data (All-Time)",content:JSON.stringify(a,null,2)})}if(mt.length>0&&dt){const e=mt.map(e=>({timestamp:e.timestamp_seconds,formattedTime:e.timestamp_seconds?"".concat(Math.floor(e.timestamp_seconds/3600).toString().padStart(2,"0"),":").concat(Math.floor(e.timestamp_seconds%3600/60).toString().padStart(2,"0"),":").concat(Math.floor(e.timestamp_seconds%60).toString().padStart(2,"0")):"no timestamp",content:e.content,author:e.user_name||"Anonymous",type:e.type||"comment",createdAt:e.created_at}));t.push({name:"Session Comments",content:JSON.stringify(e,null,2)})}const n=kt(o,t,"","",ie,!0);console.log("[BATCH] Built system prompt with length:",n.length,"context items:",t.length);const a=await Om.createBatchChatJobs(p,e,l,{disableTimecodeLinks:!0,autoName:!0},j,n);Be(!1),Re({batchId:a.batchId,totalJobs:a.totalJobs,completed:0,failed:0});const r=await Vm.getSession(p,j);null!==r&&void 0!==r&&r.conversations&&Ne(r.conversations)}catch(J){console.error("Failed to start batch generation:",J)}
2finally{Pe(!1)}}}})]})},Ik=(e,t)=>{var n,a,r,s,i,o;return e.transcript===t.transcript&&e.model===t.model&&e.supportedModels.length===t.supportedModels.length&&e.supportedModels.every((e,n)=>e===t.supportedModels[n])&&e.sessionId===t.sessionId&&e.transcriptionChecksum===t.transcriptionChecksum&&(null===(n=e.currentTtmlFiles)||void 0===n?void 0:n.length)===(null===(a=t.currentTtmlFiles)||void 0===a?void 0:a.length)&&(e.currentTtmlFiles||[]).every((e,n)=>{var a;const r=null===(a=t.currentTtmlFiles)||void 0===a?void 0:a[n];return r&&e.name===r.name&&e.content===r.content})&&JSON.stringify(e.speakerLabels)===JSON.stringify(t.speakerLabels)&&JSON.stringify(e.transcriptionData)===JSON.stringify(t.transcriptionData)&&e.narrativeData===t.narrativeData&&(null===(r=e.youtubeRetentionData)||void 0===r?void 0:r.videoId)===(null===(s=t.youtubeRetentionData)||void 0===s?void 0:s.videoId)&&(null===(i=e.youtubeRetentionData)||void 0===i?void 0:i.fetchedAt)===(null===(o=t.youtubeRetentionData)||void 0===o?void 0:o.fetchedAt)},Pk=(0,a.memo)(Bk,Ik),Lk={api_call:"\ud83c\udf10",bash:"\ud83d\udcbb",read_file:"\ud83d\udcc4",write_file:"\u270f\ufe0f",edit_file:"\ud83d\udd27",list_files:"\ud83d\udcc2",web_search:"\ud83d\udd0d",web_fetch:"\ud83d\udd17",validate_ttml:"\u2705",ask_supervisor:"\ud83d\udcac"},Rk={api_call:"API Call",bash:"Shell Command",read_file:"Read File",write_file:"Write File",edit_file:"Edit File",list_files:"List Files",web_search:"Web Search",web_fetch:"Web Fetch",validate_ttml:"Validate TTML",ask_supervisor:"Ask Supervisor"};const zk=e=>{let{toolName:t,toolCallId:n,toolInput:r,success:s,duration_ms:i,outputPreview:o,isRunning:l=!1}=e;const[c,d]=(0,a.useState)(!1),m=Lk[t]||"\ud83d\udee0\ufe0f",h=Rk[t]||t,p=function(e,t){if(!t)return"";switch(e){case"api_call":return"".concat(t.method||"GET"," ").concat(t.path||"");case"bash":return t.command||"";case"read_file":case"write_file":case"edit_file":return t.path||"";case"validate_ttml":return"".concat((t.ttml_content||"").length," chars");case"web_fetch":return t.url||"";case"web_search":return t.query||"";case"ask_supervisor":return t.question||"";default:return JSON.stringify(t).substring(0,100)}}(t,r||{}),g=l?"border-blue-400 dark:border-blue-500":s?"border-green-400 dark:border-green-500":"border-red-400 dark:border-red-500",x=l?"bg-blue-50 dark:bg-blue-900/20":s?"bg-green-50 dark:bg-green-900/20":"bg-red-50 dark:bg-red-900/20";return(0,u.jsxs)("div",{className:"my-2 border-l-3 ".concat(g," ").concat(x," rounded-r-lg overflow-hidden"),children:[(0,u.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/5 transition-colors",onClick:()=>d(!c),children:[(0,u.jsx)("span",{className:"text-sm",children:m}),(0,u.jsx)("span",{className:"text-xs font-semibold text-gray-700 dark:text-gray-300",children:h}),p&&(0,u.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate flex-1 font-mono",children:p}),l&&(0,u.jsx)("span",{className:"animate-spin text-xs",children:"\u23f3"}),void 0!==i&&!l&&(0,u.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 whitespace-nowrap",children:i<1e3?"".concat(i,"ms"):"".concat((i/1e3).toFixed(1),"s")}),(0,u.jsx)("span",{className:"text-xs transition-transform ".concat(c?"rotate-90":""),children:"\u25b6"})]}),c&&(0,u.jsxs)("div",{className:"px-3 pb-2 border-t border-gray-200/50 dark:border-gray-700/50",children:[r&&(0,u.jsxs)("div",{className:"mt-2",children:[(0,u.jsx)("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 mb-1",children:"Input"}),(0,u.jsx)("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-2 rounded overflow-x-auto max-h-40 overflow-y-auto font-mono",children:JSON.stringify(r,null,2)})]}),o&&(0,u.jsxs)("div",{className:"mt-2",children:[(0,u.jsx)("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 mb-1",children:"Output"}),(0,u.jsx)("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-2 rounded overflow-x-auto max-h-60 overflow-y-auto font-mono whitespace-pre-wrap",children:o})]})]})]})},Ok=["none","minimal","low","medium","high","xhigh"],Uk=[{id:"opus",name:"Opus",description:"Most intelligent",tier:"opus"},{id:"sonnet",name:"Sonnet",description:"Fast & capable",tier:"sonnet"}];function Vk(e){return e.includes("opus")?"Opus":e.includes("sonnet")?"Sonnet":e.split("/").pop()||e}function Hk(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const a=new Map,r=null!==(t=null===e||void 0===e?void 0:e.models)&&void 0!==t?t:[],s=r.length>0?r:Uk;for(const i of s)null!==i&&void 0!==i&&i.id&&a.set(i.id,i);for(const i of n){const e=String(i||"").trim();if(!e||a.has(e))continue;const t=e.toLowerCase();a.set(e,{id:e,name:Vk(e),description:"",tier:t.includes("opus")?"opus":"sonnet"})}return[...a.values()]}const qk=e=>{var t,n;let{sessionId:r,isPublicView:s=!1,shareToken:i,token:o,isActiveTab:l=!0,preferredSessionId:c,onPreferredSessionHandled:m,sessionListOptions:h,sessionListLabel:p}=e;const{isDarkMode:g}=zu(),[x,f]=(0,a.useState)([]),[b,y]=(0,a.useState)(null),[v,w]=(0,a.useState)([]),[k,j]=(0,a.useState)(""),[D,C]=(0,a.useState)(!1),[N,F]=(0,a.useState)(!1),[S,E]=(0,a.useState)({inputTokens:0,outputTokens:0,costUsd:0}),[A,T]=(0,a.useState)(null),[M,_]=(0,a.useState)(""),[B,I]=(0,a.useState)(""),[P,L]=(0,a.useState)("high"),[R,z]=(0,a.useState)("high"),[O,U]=(0,a.useState)(null),[V,H]=(0,a.useState)(""),[q,W]=(0,a.useState)(null),[Y,G]=(0,a.useState)(!0),[
2K,X]=(0,a.useState)([]),[J,$]=(0,a.useState)(!1),[Q,Z]=(0,a.useState)(!1),[ee,te]=(0,a.useState)(null),[ne,ae]=(0,a.useState)(!1),[re,se]=(0,a.useState)(""),[ie,oe]=(0,a.useState)(!1),[le,ce]=(0,a.useState)(!1),[de,ue]=(0,a.useState)(""),[me,he]=(0,a.useState)(null),[pe,ge]=(0,a.useState)(null),[xe,fe]=(0,a.useState)(""),[be,ye]=(0,a.useState)(!0),[ve,we]=(0,a.useState)(!1),ke=(0,a.useRef)(null),je=(0,a.useRef)(null),De=(0,a.useRef)(null),Ce=(0,a.useRef)(""),Ne=(0,a.useRef)(null),Fe=(0,a.useRef)(!1);(0,a.useEffect)(()=>{Wh(o||void 0).then(T).catch(console.error),Qh(o||void 0).then(te).catch(console.error)},[o]),(0,a.useEffect)(()=>{var e,t;!B&&A&&I(A.opus||(null===(e=A.models)||void 0===e||null===(t=e[0])||void 0===t?void 0:t.id)||"")},[A,B]);const Se=(0,a.useMemo)(()=>Hk(A,[B]),[A,B]),Ee=(0,a.useMemo)(()=>Hk(A,[M]),[M,A]),Ae=Se.some(e=>e.id===B)?B:(null===(t=Se[0])||void 0===t?void 0:t.id)||"",Te=Ee.some(e=>e.id===M)?M:(null===(n=Ee[0])||void 0===n?void 0:n.id)||"",Me=(0,a.useCallback)(()=>{if(!ke.current)return!0;const e=ke.current;return e.scrollTop+e.clientHeight>=e.scrollHeight-100},[]),_e=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"auto";var t;ke.current?ke.current.scrollTo({top:ke.current.scrollHeight,behavior:e}):null===(t=je.current)||void 0===t||t.scrollIntoView({behavior:e})},[]),Be=(0,a.useCallback)(()=>{if(Me())return Fe.current=!1,void ye(!0);Fe.current||ye(!1)},[Me]),Ie=(0,a.useCallback)(()=>{Fe.current=!0,ye(!0),_e("smooth")},[_e]);(0,a.useEffect)(()=>{be&&_e()},[be,v,_e]),(0,a.useEffect)(()=>()=>{De.current&&De.current.close()},[]),(0,a.useEffect)(()=>{if(!N)return;const e=window.setInterval(()=>{pe&&(Date.now()-pe<=45e3||ue(e=>e&&e.includes("reconnect")?e:"Still connected; waiting for agent activity..."))},15e3);return()=>window.clearInterval(e)},[N,pe]);const Pe=(0,a.useCallback)(async()=>{try{const e=h?await Ah(h,o||void 0):await Th(r,o||void 0);f(Array.isArray(e)?e:e.sessions),W(e=>"Failed to load agent sessions"===e?null:e)}catch(e){console.error("Failed to load sessions:",e),W("Failed to load agent sessions")}},[r,h,o]),Le=(0,a.useCallback)(async()=>{if(b)try{const e=await Mh(b,o||void 0);f(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?d(d({},t),e):t):[e,...t]),_(e.model),z(e.reasoning_effort||"high"),E({inputTokens:e.total_input_tokens||0,outputTokens:e.total_output_tokens||0,costUsd:e.total_cost_usd||0})}catch(e){console.error("Failed to refresh selected session:",e)}},[b,o]);(0,a.useEffect)(()=>{l&&Pe()},[l,Pe]),(0,a.useEffect)(()=>{if(!l)return;const e=setInterval(()=>{b?Le():Pe()},1e4);return()=>clearInterval(e)},[b,l,Pe,Le]),(0,a.useEffect)(()=>{if(!l)return;const e=()=>{b?Le():Pe()};return window.addEventListener("focus",e),document.addEventListener("visibilitychange",e),()=>{window.removeEventListener("focus",e),document.removeEventListener("visibilitychange",e)}},[b,l,Pe,Le]);const Re=()=>{De.current&&(De.current.close(),De.current=null),ye(!0)},ze=(0,a.useCallback)(e=>{const t=[];if(!e.messages)return t;for(const n of e.messages){const e=new Date(n.created_at.endsWith("Z")?n.created_at:"".concat(n.created_at,"Z"));if("user"!==n.role){if("assistant"===n.role)try{const a=JSON.parse(n.content);let r="";const s=[];for(const e of a)"text"===e.type?r+=e.text:"tool_use"===e.type&&s.push({id:e.id,toolName:e.name,toolInput:e.input,isRunning:!1,success:!0});t.push({id:"msg-".concat(n.id),role:"assistant",content:r,toolCalls:s.length>0?s:void 0,timestamp:e})}catch(_H){t.push({id:"msg-".concat(n.id),role:"assistant",content:n.content,timestamp:e})}}else t.push({id:"msg-".concat(n.id),role:"user",content:n.content,timestamp:e})}return t},[]),Oe=(0,a.useCallback)(async e=>{const t="string"===typeof e?await Mh(e,o||void 0):e;return f(e=>e.some(e=>e.id===t.id)?e.map(e=>e.id===t.id?d(d({},e),t):e):[t,...e]),((e,t)=>{Re(),y(e),_(t),ye(!0),Ce.current="";const n=Hh(e,Ve,e=>{console.error("SSE error:",e),fe("Stream interrupted; waiting for reconnect..."),N&&ue("Stream interrupted; waiting for reconnect...")},o||void 0);De.current=n})(t.id,t.model),z(t.reasoning_effort||"high"),w(ze(t)),E({inputTokens:t.total_input_tokens||0,outputTokens:t.total_output_tokens||0,costUsd:t.total_cost_usd||0}),t},[ze,o]);(0,a.useEffect)(()=>{const e=async e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.agentSessionId;if(n)try{return await Oe(n),void await Pe()}catch(a){console.error("Failed to auto-open agent session:",a)}await Pe()};return window.addEventListener("navigate-to-agent",e),()=>window.removeEventListener("navigate-to-agent",e)},[Pe,Oe]),(0,a.useEffect)(()=>
2{if(!c)return;let e=!1;return(async()=>{try{const t=await Mh(c,o||void 0);if(e)return;await Oe(t)}catch(t){console.error("Failed to open preferred agent session:",t)}finally{e||(null===m||void 0===m||m(),Pe())}})(),()=>{e=!0}},[c,o,Pe,m,Oe]);const Ue=(0,a.useCallback)(async()=>{if(b)try{const e=await Oh(b,o||void 0);X(e)}catch(e){}},[b,o]);(0,a.useEffect)(()=>{Ue()},[Ue]);const Ve=(0,a.useCallback)(e=>{switch(ge(Date.now()),"ping"!==e.type&&fe(""),e.type){case"connected":_(e.model||""),e.reasoningEffort&&z(e.reasoningEffort);break;case"status":F(!0),me||he(new Date),e.message&&ue(e.message);break;case"session_update":e.title&&f(t=>t.map(t=>t.id===b?d(d({},t),{},{title:e.title}):t)),e.model&&_(e.model),e.reasoningEffort&&z(e.reasoningEffort);break;case"text":Ce.current+=e.content,F(!0),ue("Responding..."),w(e=>{const t=e[e.length-1];return t&&"assistant"===t.role&&"streaming"===t.id?[...e.slice(0,-1),d(d({},t),{},{content:Ce.current})]:[...e,{id:"streaming",role:"assistant",content:Ce.current,timestamp:new Date}]});break;case"tool_start":{ue("Running ".concat(e.toolName,"..."));const t={id:e.toolCallId||"tc-".concat(Date.now()),toolName:e.toolName,toolInput:e.toolInput,isRunning:!0};w(e=>{const n=e[e.length-1];if(n&&"assistant"===n.role&&"streaming"===n.id){const a=n.toolCalls||[];return[...e.slice(0,-1),d(d({},n),{},{toolCalls:[...a,t]})]}return[...e,{id:"streaming",role:"assistant",content:Ce.current,toolCalls:[t],timestamp:new Date}]});break}case"tool_end":w(t=>{const n=t[t.length-1];if(n&&"assistant"===n.role&&n.toolCalls){const a=n.toolCalls.map(t=>t.id===e.toolCallId||t.toolName===e.toolName&&t.isRunning?d(d({},t),{},{isRunning:!1,success:e.success,duration_ms:e.duration_ms,outputPreview:e.outputPreview}):t);return[...t.slice(0,-1),d(d({},n),{},{toolCalls:a})]}return t});break;case"ask_supervisor":F(!1),U({id:e.id,question:e.question,options:e.options||[],context:e.context||""});break;case"cost_update":{const t=e.costUsd||0;E({inputTokens:e.inputTokens||0,outputTokens:e.outputTokens||0,costUsd:t}),f(e=>e.map(e=>e.id===b?d(d({},e),{},{total_cost_usd:t}):e));break}case"done":{const t=me?Math.floor((Date.now()-me.getTime())/1e3):0;F(!1),C(!1),ue(""),he(null),ge(null),fe(""),Ce.current="",w(e=>{const n=[...e],a=n.length-1;if(a>=0&&"streaming"===n[a].id){const e=t>0?"\n\n*Thought for ".concat(Math.floor(t/60),"m ").concat(t%60,"s*"):"";n[a]=d(d({},n[a]),{},{id:"msg-".concat(Date.now()),content:n[a].content+e})}return n}),void 0!==e.totalCost&&E(t=>d(d({},t),{},{costUsd:e.totalCost})),Ue(),Pe(),r&&window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:r,scopes:["agent_done"]}}));break}case"error":F(!1),C(!1),ue(""),he(null),ge(null),fe(""),W(e.message||"Unknown error"),Ce.current="";break;case"ping":default:break;case"workspace_updated":Ue();break;case"comments_updated":r&&window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:r,scopes:["comments"]}})),window.dispatchEvent(new CustomEvent("agent-comments-updated",{detail:d({sessionId:r},e)}));break;case"ttml_updated":r&&window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:r,scopes:["metadata","description","narrative"]}})),window.dispatchEvent(new CustomEvent("agent-ttml-updated",{detail:d({sessionId:r},e)}))}},[Ue]),He=async()=>{if(!k.trim()||!b)return;const e=k.trim();j(""),W(null),C(!0),F(!0),he(new Date),ge(Date.now()),fe(""),ye(!0),Ce.current="",w(t=>[...t,{id:"msg-".concat(Date.now()),role:"user",content:e,timestamp:new Date}]);try{const t=await Bh(b,e,o||void 0);t.queued&&(ue("Queued message (".concat(t.queueLength||1," waiting)...")),C(!1))}catch(t){W(t.message||"Failed to send message"),C(!1),F(!1)}},qe=async()=>{if(O&&b&&V.trim())try{await Ph(b,O.id,V.trim(),o||void 0),U(null),H(""),F(!0)}catch(e){W(e.message||"Failed to send response")}},We=(0,a.useCallback)(async()=>{if(!b)return;await Up(b)?ue("Copied agent session ID: ".concat(b)):W("Failed to copy agent session ID")},[b]),Ye=async e=>{if(b&&0!==e.length){$(!0),W(null);try{const t=Array.from(e),n=await Vh(b,t,"context",o||void 0);w(e=>[...e,{id:"upload-".concat(Date.now()),role:"user",content:"Uploaded ".concat(n.length," file").concat(n.length>
21?"s":""," to workspace: ").concat(n.map(e=>e.originalName).join(", ")),timestamp:new Date}]),Ue()}catch(t){W(t.message||"Failed to upload files")}finally{$(!1),Z(!1)}}},Ge=async e=>{if(b)try{W(null),we(!0);const t=await zh(b,e,o||void 0);e.model&&_(t.model),e.reasoningEffort&&z(t.reasoningEffort)}catch(t){W(t.message||"Failed to update agent runtime")}finally{we(!1)}},Ke=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),O?qe():He())},Xe=e=>e<.01?"$".concat((100*e).toFixed(2),"c"):"$".concat(e.toFixed(2)),Je=e=>{const t=Math.floor((Date.now()-e.getTime())/1e3);if(t<5)return"just now";if(t<60)return"".concat(t,"s ago");const n=Math.floor(t/60);if(n<60)return"".concat(n,"m ago");const a=Math.floor(n/60);if(a<24)return"".concat(a,"h ago");const r=Math.floor(a/24);return r<7?"".concat(r,"d ago"):e.toLocaleDateString()},$e=e=>{const t=Math.floor((Date.now()-e.getTime())/1e3),n=Math.floor(t/60),a=t%60;return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0")):"".concat(a,"s")},Qe=e=>{const t=[];return e.schedule_id&&t.push("sched ".concat(e.schedule_id.slice(0,8))),e.trigger_type&&t.push(e.trigger_event?"".concat(e.trigger_type,":").concat(e.trigger_event):e.trigger_type),e.session_id&&t.push("episode ".concat(e.session_id.slice(0,8))),t.join(" \u2022 ")},[,Ze]=(0,a.useState)(0);(0,a.useEffect)(()=>{const e=setInterval(()=>Ze(e=>e+1),1e3);return()=>clearInterval(e)},[]);const et=b&&x.find(e=>e.id===b)||null;return(0,u.jsxs)("div",{className:"relative flex h-full max-h-full min-h-0 w-full min-w-0 overflow-hidden overscroll-none bg-[#F8F6F1] dark:bg-[#101722] ".concat(Q?"ring-2 ring-inset ring-[#FFB52B]":""),onDragOver:e=>{e.preventDefault(),b&&Z(!0)},onDragLeave:e=>{e.preventDefault(),Z(!1)},onDrop:e=>{e.preventDefault(),Z(!1),b&&e.dataTransfer.files.length>0&&Ye(e.dataTransfer.files)},children:[Y&&(0,u.jsxs)("div",{className:"flex min-h-0 w-64 max-w-full shrink-0 flex-col overflow-hidden border-r border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-800/50",children:[(0,u.jsxs)("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsxs)("div",{className:"mb-2 space-y-2",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:"New Session Model"}),(0,u.jsx)("select",{value:Ae,onChange:e=>I(e.target.value),disabled:0===Se.length,className:"w-full rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-xs text-gray-700 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",children:0===Se.length?(0,u.jsx)("option",{value:"",children:"Loading models..."}):Se.map(e=>(0,u.jsx)("option",{value:e.id,children:"opus"===e.tier?"Opus":"sonnet"===e.tier?"Sonnet":e.name},e.id))})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:"Reasoning"}),(0,u.jsx)("select",{value:P,onChange:e=>L(e.target.value),className:"w-full rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-xs text-gray-700 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",children:Ok.map(e=>(0,u.jsx)("option",{value:e,children:e},e))})]})]}),(0,u.jsx)("button",{onClick:async()=>{try{W(null);const e=await Eh(r,B||void 0,P,o||void 0);f(t=>[e,...t]),await Oe(e)}catch(e){W(e.message||"Failed to create session")}},className:"w-full rounded-lg bg-[#FFB52B] px-3 py-2 text-sm font-medium text-[#232E3F] transition-colors hover:bg-[#FFC54D]",children:"+ New Agent Session"}),(0,u.jsx)("div",{className:"mt-2",children:ne?(0,u.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,u.jsx)("input",{type:"password",value:re,onChange:e=>se(e.target.value),placeholder:"sk-ant-api03-...",className:"w-full px-2 py-1 text-xs bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded"}),(0,u.jsxs)("div",{className:"flex gap-1",children:[(0,u.jsx)("button",{onClick:async()=>{oe(!0);try{const e=await Zh(re,o||void 0);te({hasKey:e.hasKey,keyPreview:e.hasKey?"...".concat(re.slice(-6)):null}),ae(!1),se("")}catch(BH){W(BH.message||"Invalid API key")}finally{oe(!1)}},disabled:ie,className:"flex-1 rounded bg-[#FFB52B] px-2 py-1 text-[10px] text-[#232E3F] hover:bg-[#FFC54D] disabled:opacity-50",children:ie?"Validating...":"Save"}),(0,u.jsx)("button",{onClick:()=>{ae(!1),se("")},className:"px-2 py-1 text-[10px] bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 rounded",children:"Cancel"})]})]}):(0,u.jsx)("button",{onClick:()=>ae(!0),className:"w-full text-left px-2 py-1 text-[10px] text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",children:null!==ee&&void 0!==ee&&ee.hasKey?"API Key: ".concat(ee.keyPreview," (change)"):"Add your Anthropic API key (BYO
2K)"})})]}),(0,u.jsxs)("div",{className:"px-3 py-1.5 border-b border-gray-200/50 dark:border-gray-700/50",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("span",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Sessions"}),(0,u.jsx)("button",{onClick:()=>Pe(),className:"p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",title:"Refresh sessions",children:(0,u.jsx)(vp,{size:12})})]}),p&&(0,u.jsx)("div",{className:"mt-1 text-[10px] text-gray-500 dark:text-gray-400 truncate",children:p})]}),(0,u.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-y-contain",children:0===x.length?(0,u.jsx)("div",{className:"p-4 text-center text-gray-400 dark:text-gray-500 text-sm",children:"No sessions yet"}):x.map(e=>(()=>{const t=(e=>{switch(e.runner_status){case"queued":return{label:"Queued",className:"bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-300"};case"claimed":case"starting":return{label:"Starting",className:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300"};case"running":return{label:"Running",className:"bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-300"};case"sticky":return{label:"Waiting",className:"bg-sky-100 dark:bg-sky-900/30 text-sky-700 dark:text-sky-300"};case"failed":return{label:"Failed",className:"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300"};default:return null}})(e);return(0,u.jsxs)("div",{className:"p-3 border-b border-gray-200/50 dark:border-gray-700/50 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700/50 transition-colors ".concat(b===e.id?"bg-[#FFF8EA] dark:bg-[#232E3F]/70 border-l-4 border-l-[#FFB52B]":""),onClick:()=>(async e=>{try{W(null),await Oe(e)}catch(t){W(t.message||"Failed to load session")}})(e.id),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300 truncate flex-1",children:e.title||"Untitled"}),(0,u.jsx)("button",{onClick:t=>{t.stopPropagation(),(async e=>{try{await _h(e,o||void 0),f(t=>t.filter(t=>t.id!==e)),b===e&&(Re(),y(null),w([]),E({inputTokens:0,outputTokens:0,costUsd:0}))}catch(t){W(t.message||"Failed to delete session")}})(e.id)},className:"text-gray-400 hover:text-red-500 text-xs ml-1",title:"Delete session",children:"\u2715"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat("active"===e.status?"bg-[#FFF4D8] dark:bg-[#332A17] text-[#8B5B00] dark:text-[#FFE3A1]":"stopped"===e.status?"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-400":"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400"),children:Vk(e.model)}),t&&(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat(t.className),children:t.label}),e.total_cost_usd>0&&(0,u.jsx)("span",{className:"text-[10px] text-gray-400",children:Xe(e.total_cost_usd)}),N&&e.id===b&&(0,u.jsxs)("span",{className:"relative flex h-1.5 w-1.5",children:[(0,u.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-[#FFCF74] opacity-75"}),(0,u.jsx)("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-[#FFB52B]"})]})]}),Qe(e)&&(0,u.jsx)("div",{className:"mt-1 text-[10px] text-gray-400 dark:text-gray-500 truncate",children:Qe(e)})]},e.id)})())}),b&&K.length>0&&(0,u.jsxs)("div",{className:"max-h-40 shrink-0 overflow-y-auto overscroll-y-contain border-t border-gray-200 dark:border-gray-700",children:[(0,u.jsx)("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Workspace Files"}),K.map(e=>(0,u.jsxs)("div",{className:"px-3 py-1 text-[10px] text-gray-500 dark:text-gray-400 truncate hover:bg-gray-100 dark:hover:bg-gray-700/50 cursor-pointer flex items-center gap-1",title:"Click to download: ".concat(e.path),onClick:()=>(async e=>{if(b)try{const t=await Uh(b,e),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n,a.download=e.split("/").pop()||e,a.click(),URL.revokeObjectURL(n)}catch(t){W(t.message||"Failed to download file")}})(e.path),children:[(0,u.jsx)("svg",{className:"w-3 h-3 flex-shrink-0 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,u.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),(0,u.jsx)("span",{className:"truncate",children:e.path}),(0,u.jsxs)("span",{className:"text-gray-400 flex-shrink-0",children:["(",(e.size/1024).toFixed(1),"KB)"]}
2)]},e.path))]}),(0,u.jsxs)("div",{className:"shrink-0 border-t border-gray-200 p-3 text-[10px] text-gray-400 dark:border-gray-700 dark:text-gray-500",children:[N&&(de||xe)&&(0,u.jsxs)("div",{className:"mb-1 flex items-center gap-1.5 font-medium text-[#B57700] dark:text-[#FFCF74]",children:[(0,u.jsxs)("span",{className:"relative flex h-1.5 w-1.5 flex-shrink-0",children:[(0,u.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-[#FFCF74] opacity-75"}),(0,u.jsx)("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-[#FFB52B]"})]}),(0,u.jsx)("span",{className:"truncate",children:de||xe})]}),M&&(0,u.jsxs)("div",{children:["Session: ",Vk(M)]})]})]}),Q&&b&&(0,u.jsx)("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-lg border-2 border-dashed border-[#FFB52B] bg-[#FFF4D8]/60 dark:bg-[#232E3F]/70",children:(0,u.jsxs)("div",{className:"rounded-[1.25rem] border border-[#E7B14C]/45 bg-white/95 px-6 py-4 text-center shadow-lg dark:border-[#79613A] dark:bg-[#1E2634]",children:[(0,u.jsx)("div",{className:"text-2xl mb-1",children:"\ud83d\udcc1"}),(0,u.jsx)("div",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Drop files to upload to workspace"})]})}),(0,u.jsx)(yy,{isDarkMode:g,isOpen:le,onClose:()=>ce(!1),title:"MLST ReScript MCP"}),(0,u.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden",children:[(0,u.jsx)("div",{className:"shrink-0 overflow-hidden border-b border-gray-200 bg-gray-50/50 px-4 py-2 dark:border-gray-700 dark:bg-gray-800/30",children:(0,u.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-3",children:[(0,u.jsx)("button",{onClick:()=>G(!Y),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Toggle sidebar",children:Y?"\u25c0":"\u25b6"}),M&&(0,u.jsx)("span",{className:"rounded-full bg-[#232E3F] px-2 py-0.5 text-xs font-medium text-[#F4F4F4] dark:bg-[#1B2534] dark:text-[#FFE3A1]",children:Vk(M)}),S.costUsd>0&&(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Xe(S.costUsd)," (",S.inputTokens.toLocaleString()," in / ",S.outputTokens.toLocaleString()," out)"]}),N&&(0,u.jsxs)("span",{className:"flex items-center gap-1.5 text-xs text-[#B57700] dark:text-[#FFCF74]",children:[(0,u.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,u.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-[#FFCF74] opacity-75"}),(0,u.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-[#FFB52B]"})]}),de||xe||"Working...",me&&(0,u.jsx)("span",{className:"text-gray-400 dark:text-gray-500 tabular-nums",children:$e(me)})]}),(0,u.jsx)("div",{className:"min-w-0 flex-1"}),b&&v.length>0&&!be&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"text-xs px-2 py-0.5 bg-amber-100 dark:bg-amber-900/30 text-amber-700 dark:text-amber-400 rounded font-medium",children:"Unsynced"}),(0,u.jsx)("button",{onClick:Ie,className:"text-xs px-2 py-1 bg-amber-100 hover:bg-amber-200 dark:bg-amber-900/30 dark:hover:bg-amber-900/50 text-amber-700 dark:text-amber-400 rounded transition-colors",children:"Sync"})]}),b&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{onClick:()=>{We()},className:"text-xs px-2 py-1 bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-600 dark:text-gray-300 rounded transition-colors inline-flex items-center gap-1",title:"Copy agent session ID",children:[(0,u.jsx)(Np,{size:12}),(0,u.jsx)("span",{children:"Copy ID"})]}),(0,u.jsx)("select",{value:Te,onChange:e=>{Ge({model:e.target.value})},disabled:ve||0===Ee.length,className:"rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-700 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",title:"Model for the next turn",children:0===Ee.length?(0,u.jsx)("option",{value:"",children:"Loading models..."}):Ee.map(e=>(0,u.jsx)("option",{value:e.id,children:"opus"===e.tier?"Opus":"sonnet"===e.tier?"Sonnet":e.name},e.id))}),(0,u.jsx)("select",{value:R,onChange:e=>{Ge({reasoningEffort:e.target.value})},disabled:ve,className:"rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-700 dark:border-gray-600 dark:bg-gray-700 dark:text-gray-200",title:"Reasoning level for the next turn",children:Ok.map(e=>(0,u.jsx)("option",{value:e,children:e},e))}),(0,u.jsx)("button",{onClick:()=>ce(!0),className:"text-xs px-2 py-1 bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-600 dark:text-gray-300 rounded transition-colors",title:"Open MLST ReScript MCP setup",children:"MCP Setup"})]}),N&&(0,u.jsx)("button",{onClick:async()=>
2{if(b)try{await Lh(b,o||void 0),F(!1),C(!1)}catch(e){W(e.message||"Failed to stop agent")}},className:"text-xs px-2 py-1 bg-red-100 hover:bg-red-200 dark:bg-red-900/30 dark:hover:bg-red-900/50 text-red-700 dark:text-red-400 rounded transition-colors",children:"Stop Agent"}),!N&&et&&"completed"!==et.status&&(0,u.jsx)("button",{onClick:async()=>{if(b)try{await async function(e,t){const n=await fetch("".concat(Nh,"/sessions/").concat(e,"/finish"),{method:"POST",credentials:"include",headers:Sh(t)});if(!n.ok)throw new Error(await n.text())}(b,o||void 0),F(!1),C(!1),ue(""),await Pe()}catch(e){W(e.message||"Failed to finish agent session")}},className:"text-xs px-2 py-1 bg-emerald-100 hover:bg-emerald-200 dark:bg-emerald-900/30 dark:hover:bg-emerald-900/50 text-emerald-700 dark:text-emerald-400 rounded transition-colors",children:"Finish Session"})]})}),(0,u.jsxs)("div",{ref:ke,onScroll:Be,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-y-contain px-4 py-4 space-y-4",children:[b?0!==v.length||D?(0,u.jsxs)(u.Fragment,{children:[v.map(e=>(0,u.jsx)("div",{className:"flex ".concat("user"===e.role?"justify-end":"justify-start"),children:(0,u.jsxs)("div",{className:"max-w-[85%] ".concat("user"===e.role?"rounded-2xl rounded-br-md bg-[#232E3F] px-4 py-2 text-[#F4F4F4]":"bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-2xl rounded-bl-md px-4 py-3"),children:[e.toolCalls&&e.toolCalls.length>0&&(0,u.jsx)("div",{className:e.content?"mb-2":"",children:e.toolCalls.map(e=>(0,u.jsx)(zk,{toolName:e.toolName,toolCallId:e.id,toolInput:e.toolInput,success:e.success,duration_ms:e.duration_ms,outputPreview:e.outputPreview,isRunning:e.isRunning},e.id))}),e.content&&("assistant"===e.role?(0,u.jsx)("div",{className:"text-sm prose prose-sm dark:prose-invert max-w-none break-words prose-p:my-1 prose-ul:my-1 prose-ol:my-1 prose-li:my-0.5 prose-headings:my-2 prose-headings:text-base prose-code:text-xs prose-code:bg-gray-200 prose-code:dark:bg-gray-700 prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-pre:bg-gray-200 prose-pre:dark:bg-gray-700 prose-pre:text-xs prose-pre:p-2 prose-pre:rounded-lg prose-a:text-[#B57700] prose-a:dark:text-[#FFCF74]",children:(0,u.jsx)(my,{remarkPlugins:[Cw],children:e.content})}):(0,u.jsx)("div",{className:"text-sm whitespace-pre-wrap break-words",children:e.content})),(0,u.jsx)("div",{className:"text-[10px] mt-1 ".concat("user"===e.role?"text-[#FFE3A1]":"text-gray-400 dark:text-gray-500"),children:Je(e.timestamp)})]})},e.id)),O&&(0,u.jsx)("div",{className:"flex justify-start",children:(0,u.jsxs)("div",{className:"max-w-[85%] bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-300 dark:border-yellow-700 rounded-2xl px-4 py-3",children:[(0,u.jsx)("div",{className:"text-xs font-semibold text-yellow-700 dark:text-yellow-400 mb-1",children:"Agent is asking you:"}),(0,u.jsx)("div",{className:"text-sm text-gray-900 dark:text-gray-100 mb-2",children:O.question}),O.context&&(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2 italic",children:O.context}),O.options.length>0&&(0,u.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:O.options.map((e,t)=>(0,u.jsx)("button",{onClick:()=>H(e),className:"text-xs px-2 py-1 rounded border transition-colors ".concat(V===e?"bg-[#FFF4D8] dark:bg-[#332A17] border-[#FFB52B] text-[#8B5B00] dark:text-[#FFE3A1]":"border-gray-300 dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300"),children:e},t))}),(0,u.jsxs)("div",{className:"flex gap-2",children:[(0,u.jsx)("input",{type:"text",value:V,onChange:e=>H(e.target.value),onKeyDown:Ke,placeholder:"Type your response...",className:"flex-1 rounded border border-gray-300 bg-white px-3 py-1.5 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/35 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-100"}),(0,u.jsx)("button",{onClick:qe,disabled:!V.trim(),className:"rounded bg-[#FFB52B] px-3 py-1.5 text-sm text-[#232E3F] transition-colors hover:bg-[#FFC54D] disabled:bg-gray-400",children:"Send"})]})]})}),N&&!O&&(0,u.jsx)("div",{className:"flex justify-start",children:(0,u.jsx)("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-2xl px-3 py-1.5",children:(0,u.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[(0,u.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,u.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-[#FFCF74] opacity-75"}),(0,u.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-[#FFB52B]"})]}),(0,u.jsx)("span",{children:de||xe||"Working..."}),me&&(0,u.jsx)("span",{className:"text-gray-400 dark:text-gray-500 tabular-nums",children:$e(me)})]})})})]}):(0,u.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,u.jsxs)("div",{className:"text-center text-gray-400 dark:text-gray-500 max-w-md",children:[(0,u.jsx)("div",{className:"text-sm mb-2",children:"What would you like to do?"}),(0,u.jsxs)("div",{className:"text-xs space-y-1",children:[(0,u.jsx)("div",{children:'"Generate metadata for this episode"'}),(0,u.jsx)("div",{children:'"Analyze the transcript quality"'}),(0,u.jsx)("div",{children:'"Improve the current metadata"'}),(0,u.jsx)("div",{children:'"Tell me about this episode"'})]})]})}):(0,u.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,u.jsxs)("div",{className:"text-center text-gray-400 dark:text-gray-500",children:[(0,u.jsx)("div",{className:"text-2xl mb-2",children:"\ud83e\udd16"}),(0,u.jsx)("div",{className:"text-sm font-medium mb-1",children:"MLST Agent"}),(0,u.jsx)("div",{className:"text-xs",children:"Create a new session to start chatting"})]})}),q&&(0,u.jsxs)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg px-3 py-2 text-sm text-red-700 dark:text-red-400",children:[q,q.toLowerCase().includes("cost limit")&&b&&(0,u.jsx)("button",{onClick:async()=>{const e=prompt("Set new cost limit (USD):","50");if(e)try{await Rh(b,parseFloat(e),o||void 0),W(null)}catch(BH){W(BH.message||"Failed to set cost limit")}},className:"ml-2 px-2 py-0.5 bg-red-100 dark:bg-red-800 hover:bg-red-200 dark:hover:bg-red-700 rounded text-xs font-medium",children:"Raise Limit"}),(0,u.jsx)("button",{onClick:()=>W(null),className:"ml-2 text-red-500 hover:text-red-700",children:"\u2715"})]}),(0,u.jsx)("div",{ref:je})]}),b&&!O&&(0,u.jsx)("div",{className:"shrink-0 overflow-hidden border-t border-gray-200 bg-white px-4 py-3 dark:border-gray-700 dark:bg-gray-900",children:(0,u.jsxs)("div",{className:"flex min-w-0 gap-2",children:[(0,u.jsx)("textarea",{value:k,onChange:e=>j(e.target.value),onKeyDown:Ke,placeholder:N?"Queue a follow-up message...":"Ask the agent to do something...",disabled:!b,rows:1,className:"min-w-0 flex-1 resize-none rounded-lg border-2 bg-white px-3 py-2 text-sm text-gray-900 transition-colors focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/35 dark:bg-gray-800 dark:text-gray-100 ".concat(N?"border-[#FFB52B] dark:border-[#FFCF74] animate-pulse":b?"border-[#232E3F]/35 dark:border-[#556274]":"border-gray-300 dark:border-gray-600"),style:{minHeight:"38px",maxHeight:"120px"},onInput:e=>{const t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,120)+"px"}}),(0,u.jsx)("input",{ref:Ne,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&e.target.files.length>0&&(Ye(e.target.files),e.target.value="")}}),(0,u.jsx)("button",{onClick:()=>{var e;return null===(e=Ne.current)||void 0===e?void 0:e.click()},disabled:J,className:"px-3 py-2 border border-gray-300 dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-400 text-sm rounded-lg transition-colors disabled:opacity-50",title:"Upload files to workspace",children:J?"...":"\ud83d\udcce"}),(0,u.jsx)("button",{onClick:He,disabled:!k.trim()||!b,className:"rounded-lg bg-[#FFB52B] px-4 py-2 text-sm font-medium text-[#232E3F] transition-colors hover:bg-[#FFC54D] disabled:bg-gray-400 dark:disabled:bg-gray-600",children:N?"Queue":"Send"})]})})]})]})},Wk=Mo("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
2y:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Yk=Mo("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Gk=["onSuccess","onError","useOneTap","promptMomentNotification","type","theme","size","text","shape","logo_alignment","width","locale","click_listener","containerProps"];const Kk=(0,a.createContext)(null);function Xk(e){let{clientId:t,nonce:n,onScriptLoadSuccess:r,onScriptLoadError:s,children:i}=e;const o=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{nonce:t,onScriptLoadSuccess:n,onScriptLoadError:r}=e,[s,i]=(0,a.useState)(!1),o=(0,a.useRef)(n);o.current=n;const l=(0,a.useRef)(r);return l.current=r,(0,a.useEffect)(()=>{const e=document.createElement("script");return e.src="https://accounts.google.com/gsi/client",e.async=!0,e.defer=!0,e.nonce=t,e.onload=()=>{var e;i(!0),null===(e=o.current)||void 0===e||e.call(o)},e.onerror=()=>{var e;i(!1),null===(e=l.current)||void 0===e||e.call(l)},document.body.appendChild(e),()=>{document.body.removeChild(e)}},[t]),s}({nonce:n,onScriptLoadSuccess:r,onScriptLoadError:s}),l=(0,a.useMemo)(()=>({clientId:t,scriptLoadedSuccessfully:o}),[t,o]);return a.createElement(Kk.Provider,{value:l},i)}function Jk(){const e=(0,a.useContext)(Kk);if(!e)throw new Error("Google OAuth components must be used within GoogleOAuthProvider");return e}function $k(e){var t;return null!==(t=null===e||void 0===e?void 0:e.clientId)&&void 0!==t?t:null===e||void 0===e?void 0:e.client_id}const Qk={large:40,medium:32,small:20};function Zk(e){let{onSuccess:t,onError:n,useOneTap:r,promptMomentNotification:s,type:i="standard",theme:o="outline",size:l="large",text:c,shape:u,logo_alignment:m,width:h,locale:p,click_listener:g,containerProps:x}=e,f=T(e,Gk);const b=(0,a.useRef)(null),{clientId:y,scriptLoadedSuccessfully:v}=Jk(),w=(0,a.useRef)(t);w.current=t;const k=(0,a.useRef)(n);k.current=n;const j=(0,a.useRef)(s);return j.current=s,(0,a.useEffect)(()=>{var e,t,n,a,s,x,D,C,N;if(v)return null===(n=null===(t=null===(e=null===window||void 0===window?void 0:window.google)||void 0===e?void 0:e.accounts)||void 0===t?void 0:t.id)||void 0===n||n.initialize(d({client_id:y,callback:e=>{var t;if(!(null===e||void 0===e?void 0:e.credential))return null===(t=k.current)||void 0===t?void 0:t.call(k);const{credential:n,select_by:a}=e;w.current({credential:n,clientId:$k(e),select_by:a})}},f)),null===(x=null===(s=null===(a=null===window||void 0===window?void 0:window.google)||void 0===a?void 0:a.accounts)||void 0===s?void 0:s.id)||void 0===x||x.renderButton(b.current,{type:i,theme:o,size:l,text:c,shape:u,logo_alignment:m,width:h,locale:p,click_listener:g}),r&&(null===(N=null===(C=null===(D=null===window||void 0===window?void 0:window.google)||void 0===D?void 0:D.accounts)||void 0===C?void 0:C.id)||void 0===N||N.prompt(j.current)),()=>{var e,t,n;r&&(null===(n=null===(t=null===(e=null===window||void 0===window?void 0:window.google)||void 0===e?void 0:e.accounts)||void 0===t?void 0:t.id)||void 0===n||n.cancel())}},[y,v,r,i,o,l,c,u,m,h,p]),a.createElement("div",d(d({},x),{},{ref:b,style:d({height:Qk[l]},null===x||void 0===x?void 0:x.style)}))}const ej={NODE_ENV:"production",PUBLIC_URL:"https://files.rescript.info",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_GOOGLE_CLIENT_ID:"650914284514-arrnrmrkrk8r37chamjmk7ta7tfj5nuk.apps.googleusercontent.com"}.REACT_APP_API_URL||"",tj={devLoginEnabled:!1};let nj=null;const aj=()=>{const[e,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let e=!0;return(nj||(nj=fetch("".concat(ej,"/api/auth/config"),{credentials:"include"}).then(async e=>{if(!e.ok)return tj;const t=await e.json().catch(()=>null);return{devLoginEnabled:!0===(null===t||void 0===t?void 0:t.devLoginEnabled)}}).catch(()=>(nj=null,tj))),nj).then(n=>{e&&t(!0===n.devLoginEnabled)}),()=>{e=!1}},[]),e};function rj(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.search;const t=new URLSearchParams(e).get("returnTo")||"";return/^\/[rs]\/[A-Za-z0-9_\-/?=&.%]*$/.test(t)&&!t.startsWith("//")?t:"/"}const sj={NODE_ENV:"production",PUBLIC_URL:"https://files.rescript.info",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_GOOGLE_CLIENT_ID:"650914284514-arrnrmrkrk8r37chamjmk7ta7tfj5nuk.apps.googleusercontent.com"}.REACT_APP_API_URL||"",ij=()=>{const e=oc(),{login:t}=am(),[n,r]=(0,a.useState)(!1),[s,i]=(0,a.useState)(null),o=aj(),l=[{icon:gp,title:"Editorial transcript access",body:"Open the archive, jump between sessions, and use the transcript tools reserved for signed-in users."},{icon:Wk,title:"Organization-aware permissions",body:"Your Google account is mapped to the correct MLST organization and role on sign-in."},{icon:Po,title:"A cleaner workflow",body:"Move from public reading to the full ReScript experience without changing products."}];return(0,u.jsx)("div",{className:"brand-shell brand-grid",children:(0,u.jsx)("div",{className:"relative z-10 flex min-h-screen items-center px-4 py-10 sm:px-6 lg:px-8",children:(0,u.jsxs)("div",{className:"mx-auto grid w-full max-w-6xl gap-6 lg:grid-cols-[minmax(0,1.05fr)_460px]",children:[(0,u.jsxs)(Do.section,{initial:{opacity:0,y:16}
2,animate:{opacity:1,y:0},transition:{duration:.45},className:"brand-card overflow-hidden bg-brand-navy px-8 py-10 text-brand-cloud sm:px-10 sm:py-12",children:[(0,u.jsxs)("div",{className:"flex items-center gap-4",children:[(0,u.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-[1.35rem] bg-white/10 shadow-brand",children:(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"Machine Learning Street Talk",className:"h-8 w-auto"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-[0.68rem] font-bold uppercase tracking-[0.32em] text-brand-cloud/72",children:"Machine Learning Street Talk"}),(0,u.jsx)("p",{className:"mt-1 font-headlines text-2xl font-bold tracking-tight text-brand-yellow",children:"ReScript"})]})]}),(0,u.jsx)("p",{className:"mt-10 brand-kicker border-white/15 bg-white/10 text-brand-cloud",children:"Member Sign-In"}),(0,u.jsx)("h1",{className:"mt-6 max-w-2xl font-headlines text-5xl font-bold tracking-tight text-brand-cloud sm:text-6xl",children:"Sign into the MLST transcript room."}),(0,u.jsx)("p",{className:"mt-6 max-w-2xl text-lg leading-8 text-brand-cloud/74",children:"Use your Google account to move from the public editorial archive into the full MLST workspace with organization-aware permissions."}),(0,u.jsx)("div",{className:"mt-10 space-y-4",children:l.map(e=>{let{icon:t,title:n,body:a}=e;return(0,u.jsx)("div",{className:"rounded-[1.5rem] border border-white/10 bg-white/[0.06] px-5 py-5",children:(0,u.jsxs)("div",{className:"flex items-start gap-4",children:[(0,u.jsx)("div",{className:"mt-1 flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-brand-yellow text-brand-navy",children:(0,u.jsx)(t,{className:"h-5 w-5"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"font-headlines text-lg font-bold text-brand-cloud",children:n}),(0,u.jsx)("p",{className:"mt-2 text-sm leading-7 text-brand-cloud/72",children:a})]})]})},n)})})]}),(0,u.jsxs)(Do.section,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},transition:{duration:.45,delay:.08},className:"brand-card p-8 sm:p-10",children:[(0,u.jsx)("p",{className:"brand-kicker",children:"Authentication"}),(0,u.jsx)("h2",{className:"brand-highlight-text mt-6 font-headlines text-3xl font-bold tracking-tight",children:"Continue with Google"}),(0,u.jsx)("p",{className:"mt-4 text-base leading-8 text-brand-navy/68",children:"Sign in with the Google account your MLST organization admin has approved. If you are not approved yet, you will be guided to the access request state after sign-in."}),s&&(0,u.jsx)("div",{className:"mt-6 rounded-[1.25rem] border border-red-300/70 bg-red-50 px-4 py-3 text-sm text-red-700",children:s}),(0,u.jsx)("div",{className:"mt-8 flex flex-col items-start gap-4",children:n?(0,u.jsxs)("div",{className:"flex items-center gap-3 rounded-full border border-brand-navy/10 bg-white px-5 py-3 text-sm text-brand-navy/70",children:[(0,u.jsx)("span",{className:"brand-spinner h-5 w-5 !border-2"}),"Authenticating..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Zk,{onSuccess:async e=>{const n=e.credential;if(n)try{r(!0),i(null);const e=await fetch("".concat(sj,"/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({idToken:n})});if(!e.ok){const t=await e.json();throw new Error(t.error||"Login failed")}const a=await e.json();await t(a.accessProfile||null),window.location.href=rj()}catch(a){console.error("[LOGIN] Failed to exchange token:",a),i(a instanceof Error?a.message:"Login failed")}finally{r(!1)}else i("No token received from Google")},onError:()=>{i("Google authentication failed")},theme:"outline",shape:"pill",size:"large",text:"continue_with",logo_alignment:"left"}),o&&(0,u.jsx)("button",{onClick:()=>{(async()=>{try{r(!0),i(null);const e=await fetch("".concat(sj,"/api/auth/dev-login"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"});if(!e.ok)throw new Error("Dev login failed");const n=await e.json();await t(n.accessProfile||null),window.location.href=rj()}catch(e){console.error("[LOGIN] Dev login failed:",e),i(e instanceof Error?e.message:"Dev login failed")}finally{r(!1)}})()},className:"brand-button-secondary",children:"Dev login"})]})}),(0,u.jsx)("div",{className:"mt-10",children:(0,u.jsxs)("button",{onClick:()=>e("/"),className:"brand-button-ghost",children:[(0,u.jsx)(Yk,{className:"h-4 w-4"}),"Back to archive"]})})]})]})})})},oj=Mo("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
2y:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),lj=Mo("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),cj=e=>{let{email:t}=e;const{logout:n}=am();return(0,u.jsx)("div",{className:"brand-shell brand-grid",children:(0,u.jsx)("div",{className:"relative z-10 flex min-h-screen items-center px-4 py-10 sm:px-6 lg:px-8",children:(0,u.jsxs)("div",{className:"mx-auto grid w-full max-w-5xl gap-6 lg:grid-cols-[minmax(0,1.05fr)_420px]",children:[(0,u.jsxs)(Do.section,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.45},className:"brand-card overflow-hidden bg-brand-navy px-8 py-10 text-brand-cloud sm:px-10 sm:py-12",children:[(0,u.jsx)("div",{className:"flex h-14 w-14 items-center justify-center rounded-[1.35rem] bg-white/10 shadow-brand",children:(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"Machine Learning Street Talk",className:"h-8 w-auto"})}),(0,u.jsx)("p",{className:"mt-10 brand-kicker border-white/15 bg-white/10 text-brand-cloud",children:"Organization Access"}),(0,u.jsx)("h1",{className:"mt-6 max-w-2xl font-headlines text-5xl font-bold tracking-tight text-brand-cloud sm:text-6xl",children:"That Google account is not on an approved MLST workspace."}),(0,u.jsxs)("p",{className:"mt-6 max-w-2xl text-lg leading-8 text-brand-cloud/74",children:["You signed in as ",(0,u.jsx)("span",{className:"font-headlines text-brand-yellow",children:t}),". Access is now managed directly by organization admins inside the application settings."]}),(0,u.jsxs)("div",{className:"mt-10 rounded-[1.75rem] border border-white/10 bg-white/[0.06] p-6",children:[(0,u.jsx)("h2",{className:"font-headlines text-xl font-bold text-brand-cloud",children:"What to do next"}),(0,u.jsx)("div",{className:"mt-6 space-y-4",children:["Ask an organization admin or master user to add this Google account to the correct MLST organization.","Confirm that the role they assign includes the workspace access you expect.","Return and sign in again with the same Google account once the invite is in place."].map((e,t)=>(0,u.jsxs)("div",{className:"flex items-start gap-4",children:[(0,u.jsxs)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-brand-yellow font-headlines text-sm font-bold text-brand-navy",children:["0",t+1]}),(0,u.jsx)("p",{className:"text-sm leading-7 text-brand-cloud/74",children:e})]},e))})]})]}),(0,u.jsxs)(Do.section,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},transition:{duration:.45,delay:.08},className:"brand-card p-8 text-center sm:p-10",children:[(0,u.jsx)("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-brand-yellow text-brand-navy",children:(0,u.jsx)(oj,{className:"h-8 w-8"})}),(0,u.jsx)("p",{className:"mt-8 brand-kicker",children:"Access Denied"}),(0,u.jsx)("h2",{className:"mt-6 font-headlines text-3xl font-bold tracking-tight text-brand-navy",children:"Admin approval required"}),(0,u.jsxs)("p",{className:"mt-4 text-base leading-8 text-brand-navy/68",children:["Once an admin adds ",(0,u.jsx)("span",{className:"font-headlines text-brand-navy",children:t})," to the right organization and role, sign in again to continue."]}),(0,u.jsx)("div",{className:"mt-8 brand-divider"}),(0,u.jsx)("div",{className:"mt-8 flex flex-col gap-3",children:(0,u.jsxs)("button",{onClick:()=>{n()},className:"brand-button-primary w-full",children:["Logout",(0,u.jsx)(lj,{className:"h-4 w-4"})]})})]})]})})})},dj=e=>{let{sessionId:t,filename:n,transcriptionChecksum:r,onRecoverySuccess:s,className:i=""}=e;const{token:o}=am(),[l,c]=(0,a.useState)(!1),[d,m]=(0,a.useState)(!1),[h,p]=(0,a.useState)(null),g=(0,a.useRef)(null);return d?(0,u.jsx)("div",{className:"bg-green-50 border border-green-200 rounded-lg p-6 ".concat(i),children:(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)(ph,{className:"h-8 w-8 text-green-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-lg font-semibold text-green-800",children:"Audio Recovered Successfully!"}),(0,u.jsx)("p",{className:"text-green-700",children:"The audio file has been uploaded and linked to this session."})]})]})}):(0,u.jsx)("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-6 ".concat(i),children:(0,u.jsxs)("div",{className:"flex items-start space-x-4",children:[(0,u.jsx)(fp,{className:"h-8 w-8 text-amber-600 flex-shrink-0 mt-1"}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsx)("h3",{className:"text-lg font-semibold text-amber-800 mb-2",children:"Missing Audio File"}),(0,u.jsx)("p",{className:"text-amber-700 mb-4",children:"This session appears to be missing its original audio file. This can happen for sessions created before our S3 storage migration. To restore full functionality including audio playback and speaker samples, please upload the original audio file."}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsxs)("div",{className:"text-sm text-amber-600",children:[(0,u.jsxs)("p",{children:[(0,u.jsx)("strong",{children:"Session:"})," ",n]}),(0,u.jsxs)("p",{children:[(0,u.jsx)("strong",{children:"Expected file:"})," Audio file that matches this transcript"]})]}),h&&(0,u.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-md p-3",children:(0,u.jsx)("p",{className:"text-red-700 text-sm",children:h})}),(0,u.jsx)("button",{onClick:()=>{var e;null===(e=g.current)||void 0===e||e.click()},disabled:l,className:"inline-flex items-center px-4 py-2 bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:l?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Eu,{className:"h-4 w-4 mr-2"}),"Upload Audio File"]})}),(0,u.jsx)("input",{ref:g,type:"file",accept:"audio/*,.mp3,.wav,.m4a,.mp4",onChange:async e=>{var n;const a=null===(n=e.target.files)||void 0===n?void 0:n[0];if(!a)return;if(["audio/mpeg","audio/mp3","audio/wav","audio/mp4","audio/m4a"].includes(a.type)||a.name.match(/\.(mp3|wav|m4a|mp4)$/i)){c(!0),p(null);try{console.log("[ORPHAN-RECOVERY] Starting upload process for file:",a.name,"Size:",a.size);const e=new FormData;e.append("audio",a),console.log("[ORPHAN-RECOVERY] Sending request to:","/api/recover-session-audio/".concat(t));const n=await fetch("".concat("","/api/recover-session-audio/").concat(t),{method:"POST",headers:{Authorization:"Bearer ".concat(o)},body:e});if(console.log("[ORPHAN-RECOVERY] Response status:",n.status,n.statusText),!n.ok){const e=await n.json().catch(()=>({error:"Unknown error"}));throw console.error("[ORPHAN-RECOVERY] Server error response:",e),new Error(e.error||"Server error: ".concat(n.status," ").concat(n.statusText))}const r=await n.json();console.log("[ORPHAN-RECOVERY] Audio recovery successful:",r),console.log("[ORPHAN-RECOVERY] S3 key:",r.s3Key),console.log("[ORPHAN-RECOVERY] File size uploaded:",r.fileSize),m(!0),setTimeout(()=>{s()},1500)}catch(h){console.error("[ORPHAN-RECOVERY] Upload failed:",h),p(h instanceof Error?h.message:"Upload failed")}finally{c(!1)}}else p("Please select a valid audio file (MP3, WAV, M4A, MP4)")},className:"hidden"})]})]})]})})},uj=Mo("film",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]]),mj=Mo("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]),hj=Mo("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]),pj=Mo("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]),gj=Mo("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),xj=Mo("folder-input",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]),fj=Mo("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),bj=Mo("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]),yj=Mo("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}
2],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]),vj=e=>{let{isOpen:t,onClose:n,onConfirm:r,title:s,message:i,confirmText:o="Confirm",cancelText:l="Cancel",confirmButtonClassName:c="bg-red-600 hover:bg-red-700",isLoading:d=!1,confirmationValue:m,confirmationHint:h,confirmationLabel:p="Type to confirm",confirmationPlaceholder:g}=e;const[x,f]=(0,a.useState)("");if((0,a.useEffect)(()=>{t&&f("")},[t,m]),!t)return null;const b=!!m,y=d||b&&x.trim()!==m;return mk.createPortal((0,u.jsx)(S,{children:t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Do.div,{initial:{opacity:0},animate:{opacity:.5},exit:{opacity:0},className:"fixed inset-0 bg-black z-[9998]",onClick:n}),(0,u.jsx)(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2},className:"fixed inset-0 flex items-center justify-center z-[9999] p-4",onClick:n,children:(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full p-6",onClick:e=>e.stopPropagation(),children:[(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:s}),(0,u.jsx)("div",{className:"text-gray-600 dark:text-gray-300 mb-6",children:i}),b&&(0,u.jsxs)("div",{className:"mb-6",children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-800 dark:text-gray-200 mb-2",children:p}),(0,u.jsx)("input",{type:"text",value:x,onChange:e=>f(e.target.value),placeholder:g||m,className:"w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100"}),(0,u.jsx)("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:h||'Enter "'.concat(m,'" exactly to continue.')})]}),(0,u.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,u.jsx)("button",{onClick:n,disabled:d,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-200 dark:bg-gray-700 rounded-md hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:l}),(0,u.jsx)("button",{onClick:r,disabled:y,className:"px-4 py-2 text-white rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed ".concat(c),children:d?"Processing...":o})]})]})})]})}),document.body)},wj=Mo("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),kj=Mo("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),jj=Mo("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),Dj=Mo("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]),Cj=Mo("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);function Nj(e){let{title:t,onClose:n,children:r}=e;const s=(0,a.useRef)(null);return(0,a.useEffect)(()=>{const e=s.current;return e&&!e.open&&e.showModal(),()=>null===e||void 0===e?void 0:e.close()},[]),(0,u.jsxs)("dialog",{ref:s,className:"project-dialog","aria-label":t,onCancel:e=>{e.preventDefault(),n()},children:[(0,u.jsxs)("div",{className:"project-tools",style:{justifyContent:"space-between"},children:[(0,u.jsx)("h2",{children:t}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Close dialog","data-tip":"Close",onClick:n,children:(0,u.jsx)(Pu,{size:18})})]}),r]})}function Fj(e){let{project:t}=e;const n={film:uj,mic:_o,flask:wj}[t.iconToken||""]||kj,a={yellow:"#b97900",teal:"#158078",navy:"#7285a1",purple:"#9973c1"}[t.colourToken||""];
2return(0,u.jsx)(n,{size:18,"aria-hidden":"true",style:a?{color:a}:void 0})}function Sj(e){let{token:t,project:n,onChanged:r}=e;const[s,i]=(0,a.useState)(null),[o,l]=(0,a.useState)(n.name),[c,d]=(0,a.useState)(""),[m,h]=(0,a.useState)(""),[p,g]=(0,a.useState)(!1),[x,f]=(0,a.useState)(""),[b,y]=(0,a.useState)("navy"),[v,w]=(0,a.useState)("folder"),[k,j]=(0,a.useState)(""),[D,C]=(0,a.useState)(""),[N,F]=(0,a.useState)(""),S=!k.trim()||/^\d{4}(-(0[1-9]|1[0-2])(-(0[1-9]|[12]\d|3[01]))?)?$/.test(k.trim()),[E,A]=(0,a.useState)([]);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"project-tools","aria-label":"Manage ".concat(n.name),children:[{key:"rename",label:"Edit project",Icon:jj},{key:"merge",label:"Merge project",Icon:Dj},{key:"history",label:"Project history",Icon:Cj},{key:"archive",label:"archived"===n.status?"Reopen project":"Archive project",Icon:pj}].map(e=>{let{key:a,label:r,Icon:s}=e;return(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"".concat(r,": ").concat(n.name),"data-tip":r,title:r,onClick:()=>{l(n.name),f(n.description||""),j(Ym(n)||""),C(Gm(n)||""),F(Km(n).join("\n")),y(n.colourToken||""),w(n.iconToken||""),d(""),h(""),i(a),"history"===a&&(A([]),Qm(t,"/projects/".concat(encodeURIComponent(n.id),"/history?limit=50")).then(e=>A(e.history)).catch(e=>h(e.message)))},children:(0,u.jsx)(s,{size:16,"aria-hidden":"true"})},a)})}),s&&(0,u.jsx)(Nj,{title:"".concat("history"===s?"History:":"rename"===s?"Edit":"merge"===s?"Merge":"archived"===n.status?"Reopen":"Archive"," ").concat(n.name),onClose:()=>!p&&i(null),children:(0,u.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),s&&"history"!==s){g(!0),h("");try{await function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Qm(e,"/projects/".concat(encodeURIComponent(t),"/").concat(n),"POST",a)}(t,n.id,s,"rename"===s?{name:o.trim(),description:x,colourToken:b||null,iconToken:v||null,shootDate:k.trim()||null,workingProjectFolder:D.trim()||null,notes:N.split("\n").map(e=>e.trim()).filter(Boolean).length?N.split("\n").map(e=>e.trim()).filter(Boolean):null}:"merge"===s?{targetProjectId:c}:{archived:"archived"!==n.status}),th(),null===r||void 0===r||r(),i(null)}catch(BH){h(BH.message)}finally{g(!1)}}},children:["rename"===s&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("input",{"aria-label":"Project name",className:"project-input",required:!0,value:o,onChange:e=>l(e.target.value)}),(0,u.jsx)("textarea",{className:"project-input","aria-label":"Project description",placeholder:"Description",value:x,onChange:e=>f(e.target.value)}),(0,u.jsx)("input",{className:"project-input","aria-label":"Shoot date","aria-invalid":!S,placeholder:"Shoot date YYYY-MM-DD",value:k,onChange:e=>j(e.target.value)}),(0,u.jsx)("input",{className:"project-input","aria-label":"Dropbox shoot folder",placeholder:"Dropbox shoot folder (absolute path)",value:D,onChange:e=>C(e.target.value)}),(0,u.jsx)("textarea",{className:"project-input","aria-label":"Project notes, one per line",placeholder:"Notes, one per line",value:N,onChange:e=>F(e.target.value)}),(0,u.jsxs)("div",{className:"project-picker-row",children:[(0,u.jsxs)("select",{className:"project-input","aria-label":"Project colour",value:b,onChange:e=>y(e.target.value),children:[(0,u.jsx)("option",{value:"",children:"no colour"}),["navy","yellow","teal","purple"].map(e=>(0,u.jsx)("option",{children:e},e))]}),(0,u.jsxs)("select",{className:"project-input","aria-label":"Project icon",value:v,onChange:e=>w(e.target.value),children:[(0,u.jsx)("option",{value:"",children:"default icon"}),["folder","film","mic","flask"].map(e=>(0,u.jsx)("option",{children:e},e))]})]})]}),"history"===s&&(0,u.jsx)("ol",{className:"project-history",children:E.length?E.map(e=>(0,u.jsxs)("li",{children:[(0,u.jsx)("strong",{children:e.action.replace(/_/g," ")}),(0,u.jsx)("br",{}),(0,u.jsxs)("small",{children:[e.actorEmail," \xb7 ",e.createdAt]})]},e.id)):(0,u.jsx)("li",{children:"No history loaded."})}),"merge"===s&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{children:"Move all sessions and arrangements to:"}),(0,u.jsx)(ih,{token:t,value:c,onChange:d,required:!0,label:"Destination project"})]}),"archive"===s&&(0,u.jsx)("p",{children:"archived"===n.status?"Show this project in the active project list again.":"Hide this project from active lists. Its sessions, arrangements and history remain available."}),m&&(0,u.jsx)("p",{className:"project-error",role:"alert",children:m}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Cancel","data-tip":"Cancel",onClick:()=>i(null),disabled:p,children:(0,u.jsx)(Pu,{size:18})}),"history"!==s&&(0,u.jsx)("button",{type:"submit",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Confirm project change","data-tip":"Confirm",disabled:p||"rename"===s&&(!o.trim()||!S)||"merge"===s&&(!c||c===n.id),children:(0,u.jsx)(Wm,{size:18})})]})]})})]})}const Ej=Mo("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}
2]]),Aj=Mo("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),Tj=Mo("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]),Mj=Mo("circle-dashed",[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]]),_j=Mo("hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]),Bj=Mo("megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]),Ij=Mo("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]),Pj=Mo("calendar-days",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]),Lj=Mo("calendar-clock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]),Rj=Mo("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]),zj=Mo("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),Oj=Mo("calendar-x-2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 13V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"3spt84"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m17 22 5-5",key:"1k6ppv"}],["path",{d:"m17 17 5 5",key:"p7ous7"}]]),Uj=Mo("arrow-right-left",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);async function Vj(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"GET";const r=await fetch("".concat("/api/v1/publication-calendar").concat(e),d({method:a,credentials:"include",headers:d({"Content-Type":"application/json"},t?{Authorization:"Bearer ".concat(t)}:{})},n?{body:JSON.stringify(n)}:{})),s=await r.json();if(!r.ok)throw new Error(s.message||s.error||"Request failed (".concat(r.status,")"));return s}const Hj=e=>e.publicationId||e.arrangementId;function qj(e){return"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"),"-").concat(String(e.getDate()).padStart(2,"0"))}function Wj(e){const[t,n,a]=e.slice(0,10).split("-").map(Number);return new Date(t,n-1,a,12)}function Yj(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a=Wj(e);if(n){const e=a.getDate();a.setDate(1),a.setMonth(a.getMonth()+n),a.setDate(Math.min(e,new Date(a.getFullYear(),a.getMonth()+1,0).getDate()))}return a.setDate(a.getDate()+t),qj(a)}function Gj(e){return Yj(e,-(Wj(e).getDay()+6)%7)}const Kj=(e,t)=>{var n,a;return null!==(n=e["public"===t?"publicPublished":"patreonPublished"])&&void 0!==n?n:!(null===(a=e.publicationEvidence)||void 0===a||!a[t])},Xj=(e,t)=>{var n;return"patreon"===t?["Patreon"]:null!==(n=e.platforms)&&void 0!==n&&n.filter(e=>"Patreon"!==e).length?e.platforms.filter(e=>"Patreon"!==e):"short"===e.format?["YouTube Shorts","Instagram Reels"]:"midform"===e.format?["X"]:["YouTube","Spotify"]},Jj=Mo("linkedin",[["path",{d:"M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z",key:"c2jq9f"}],["rect",{width:"4",height:"12",x:"2",y:"9",key:"mk3on5"}],["circle",{cx:"4",cy:"4",r:"2",key:"bt5ra8"}]]),$j={youtube:"M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z",patreon:"M22.957 7.21c-.004-3.064-2.391-5.576-5.191-6.482-3.478-1.125-8.064-.962-11.384.604C2.357 3.231 1.093 7.391 1.046 11.54c-.039 3.411.302 12.396 5.369 12.46 3.765.047 4.326-4.804 6.068-7.141 1.24-1.662 2.836-2.132 4.801-2.618 3.376-.836 5.678-3.501 5.673-7.031Z",x:"M14.234 10.162 22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299-.929-1.329L3.076 1.56h3.182l5.965 8.532.929 1.329 7.754 11.09h-3.182z",spotify:"M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z",instagram:"M7.0301.084c-1.2768.0602-2.1487.264-2.911.5634-.7888.3075-1.4575.72-2.1228 1.3877-.6652.6677-1.075 1.3368-1.3802 2.127-.2954.7638-.4956 1.6365-.552 2.914-.0564 1.2775-.0689 1.6882-.0626 4.947.0062 3.2586.0206 3.6671.0825 4.9473.061 1.2765.264 2.1482.5635 2.9107.308.7889.72 1.4573 1.388 2.1228.6679.6655 1.3365 1.0743 2.1285 1.38.7632.295 1.6361.4961 2.9134.552 1.2773.056 1.6884.069 4.9462.0627 3.2578-.0062 3.668-.0207 4.9478-.0814 1.28-.0607 2.147-.2652 2.9098-.5633.7889-.3086 1.4578-.72 2.1228-1.3881.665-.6682 1.0745-1.3378 1.3795-2.1284.2957-.7632.4966-1.636.552-2.9124.056-1.2809.0692-1.6898.063-4.948-.0063-3.2583-.021-3.6668-.0817-4.9465-.0607-1.2797-.264-2.1487-.5633-2.9117-.3084-.7889-.72-1.4568-1.3876-2.1228C21.2982 1.33 20.628.9208 19.8378.6165 19.074.321 18.2017.1197 16.9244.0645 15.6471.0093 15.236-.005 11.977.0014 8.718.0076 8.31.0215 7.0301.0839m.1402 21.6932c-1.17-.0509-1.8053-.2453-2.2287-.408-.5606-.216-.96-.4771-1.3819-.895-.422-.4178-.6811-.8186-.9-1.378-.1644-.4234-.3624-1.058-.4171-2.228-.0595-1.2645-.072-1.6442-.079-4.848-.00
27-3.2037.0053-3.583.0607-4.848.05-1.169.2456-1.805.408-2.2282.216-.5613.4762-.96.895-1.3816.4188-.4217.8184-.6814 1.3783-.9003.423-.1651 1.0575-.3614 2.227-.4171 1.2655-.06 1.6447-.072 4.848-.079 3.2033-.007 3.5835.005 4.8495.0608 1.169.0508 1.8053.2445 2.228.408.5608.216.96.4754 1.3816.895.4217.4194.6816.8176.9005 1.3787.1653.4217.3617 1.056.4169 2.2263.0602 1.2655.0739 1.645.0796 4.848.0058 3.203-.0055 3.5834-.061 4.848-.051 1.17-.245 1.8055-.408 2.2294-.216.5604-.4763.96-.8954 1.3814-.419.4215-.8181.6811-1.3783.9-.4224.1649-1.0577.3617-2.2262.4174-1.2656.0595-1.6448.072-4.8493.079-3.2045.007-3.5825-.006-4.848-.0608M16.953 5.5864A1.44 1.44 0 1 0 18.39 4.144a1.44 1.44 0 0 0-1.437 1.4424M5.8385 12.012c.0067 3.4032 2.7706 6.1557 6.173 6.1493 3.4026-.0065 6.157-2.7701 6.1506-6.1733-.0065-3.4032-2.771-6.1565-6.174-6.1498-3.403.0067-6.156 2.771-6.1496 6.1738M8 12.0077a4 4 0 1 1 4.008 3.9921A3.9996 3.9996 0 0 1 8 12.0077"};function Qj(e){let{names:t}=e;return(0,u.jsx)("span",{className:"pub-platform-icons",children:t.map(e=>{const t=e.startsWith("YouTube")?"youtube":e.startsWith("Instagram")?"instagram":e.toLowerCase();return(0,u.jsx)("span",{className:"pub-platform-icon pub-platform-".concat(t),title:e,"aria-label":e,children:"linkedin"===t?(0,u.jsx)(Jj,{size:16,"aria-hidden":"true"}):$j[t]?(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor","aria-hidden":"true",children:(0,u.jsx)("path",{d:$j[t]})}):(0,u.jsx)("span",{"aria-hidden":"true",children:e.slice(0,1)})},e)})})}const Zj=e=>"show"===e?["YouTube","Spotify"]:"midform"===e?["X","LinkedIn"]:["YouTube Shorts","Instagram Reels"],eD=["Idea","Outreach","Agreed","Drafting","Filming","Editing","Ready for review","In review","Approved for publishing","Scheduled","Published","On hold","Not Doing","Superceded"],tD=e=>"public"===e?"Public":"Patreon",nD=(e,t)=>{var n,a;return(Kj(e,t)?e["public"===t?"publicPublishedDate":"patreonPublishedDate"]||(null===(n=e.publicationEvidence)||void 0===n||null===(a=n[t])||void 0===a?void 0:a.publishedDate):null)||e["public"===t?"publicDate":"patreonDate"]},aD=e=>"public"===e?"publicDate":"patreonDate",rD=e=>Wj(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"}),sD=e=>"midform"===e.format?"Midform":"short"===e.format?"Short":"Full show",iD=e=>Array.isArray(e)?e.join(", ")||"Not set":e||"Not set",oD=["YouTube","Spotify","Patreon","X","YouTube Shorts","Instagram Reels","LinkedIn"],lD="application/x-rescript-publication";function cD(e){var t,n,r,s,i,o;let{token:l}=e;const[c,m]=(0,a.useState)(null),[h,p]=(0,a.useState)(""),[g,x]=(0,a.useState)(""),[f,b]=(0,a.useState)(!1),[y,v]=(0,a.useState)(!1),w=(0,a.useRef)(null),k=(0,a.useRef)(null),[j,D]=(0,a.useState)(!1),[C,N]=(0,a.useState)(!0),[F,S]=(0,a.useState)(()=>window.innerWidth<640?"agenda":"month"),[E,A]=(0,a.useState)(()=>qj(new Date)),[T,M]=(0,a.useState)(""),[_,B]=(0,a.useState)("all"),[I,P]=(0,a.useState)("all"),[L,R]=(0,a.useState)("existing"),[z,O]=(0,a.useState)(null),[U,V]=(0,a.useState)(""),[H,q]=(0,a.useState)("all"),[W,Y]=(0,a.useState)(""),[G,K]=(0,a.useState)("show"),[X,J]=(0,a.useState)([]),[$,Q]=(0,a.useState)(!1),[Z,ee]=(0,a.useState)(!1),[te,ne]=(0,a.useState)(""),[ae,re]=(0,a.useState)("public"),[se,ie]=(0,a.useState)({public:!1,patreon:!1}),[oe,le]=(0,a.useState)([]),[ce,de]=(0,a.useState)({}),[ue,me]=(0,a.useState)({}),[he,pe]=(0,a.useState)(""),[ge,xe]=(0,a.useState)("planned"),[fe,be]=(0,a.useState)([]),[ye,ve]=(0,a.useState)("all"),[we,ke]=(0,a.useState)(null),[je,De]=(0,a.useState)(""),[Ce,Ne]=(0,a.useState)(0),[Fe,Se]=(0,a.useState)(null),[Ee,Ae]=(0,a.useState)(""),[Te,Me]=(0,a.useState)(""),[_e,Be]=(0,a.useState)(""),[Ie,Pe]=(0,a.useState)(!1),[Le,Re]=(0,a.useState)(""),[ze,Oe]=(0,a.useState)(!1),[Ue,Ve]=(0,a.useState)(""),[He,qe]=(0,a.useState)(!1),[We,Ye]=(0,a.useState)(!1),[Ge,Ke]=(0,a.useState)(""),[Xe,Je]=(0,a.useState)(!1),[$e,Qe]=(0,a.useState)(""),[Ze,et]=(0,a.useState)(""),[tt,nt]=(0,a.useState)(null),[at,rt]=(0,a.useState)(""),[st,it]=(0,a.useState)(""),[ot,lt]=(0,a.useState)(0),[ct,dt]=(0,a.useState)(null),ut=(0,a.useRef)(!0),mt=(0,a.useRef)(0),ht=(0,a.useRef)(!1),pt=(0,a.useRef)(null),gt=(0,a.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=++mt.current;try{const n=await(e=>Vj("",e))(l);ut.current&&t===mt.current&&(m(n),e&&p(""))}catch(BH){ut.current&&t===mt.current&&p(BH.message)}finally{ut.current&&t===mt.current&&N(!1)}},[l]);(0,a.useEffect)(()=>{ut.current=!0,gt();const e=window.setInterval(()=>{document.hidden||ht.current||gt()},6e4);return()=>{ut.current=!1,window.clearInterval(e)}},[gt]),(0,a.useEffect)(()=>
2{if(!g)return;const e=window.setTimeout(()=>x(""),8e3);return()=>window.clearTimeout(e)},[g]);const xt=!!(Fe||we||z);(0,a.useEffect)(()=>{if(!f)return;const e=document.body.style.overflow;document.body.style.overflow="hidden";const t=e=>{var t;"Escape"!==e.key||xt||(b(!1),null===(t=k.current)||void 0===t||t.focus())};return document.addEventListener("keydown",t),()=>{document.body.style.overflow=e,document.removeEventListener("keydown",t)}},[f,xt]);const ft=Fe?"edit":we?"picker":z?"create":null;(0,a.useEffect)(()=>{var e,t;if(!xt)return;const n=document.activeElement;null===(e=pt.current)||void 0===e||null===(t=e.querySelector("input,button,select"))||void 0===t||t.focus();const a=e=>{var t;if("Escape"!==e.key||ht.current||(ke(null),Se(null),O(null)),"Tab"!==e.key)return;const n=Array.from((null===(t=pt.current)||void 0===t?void 0:t.querySelectorAll("button:not(:disabled),input,select,a[href]"))||[]),a=n[0],r=n[n.length-1];e.shiftKey&&document.activeElement===a&&(e.preventDefault(),null===r||void 0===r||r.focus()),e.shiftKey||document.activeElement!==r||(e.preventDefault(),null===a||void 0===a||a.focus())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a),null===n||void 0===n||n.focus()}},[xt,ft]);const bt=async function(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(ht.current)return!1;ht.current=!0,++mt.current,D(!0),p(""),x("");try{const a=await((e,t,n)=>{if(("midform"===e.format||"short"===e.format)&&!e.publicationId)return Promise.reject(new Error("This release is missing its publication ID. Refresh the calendar."));const a=!!e.publicationId&&e.publicationId!==e.arrangementId;return a&&!e.publicationId?Promise.reject(new Error("This release is missing its publication ID. Refresh the calendar.")):Vj(a?"/releases/".concat(encodeURIComponent(e.publicationId)):"/".concat(encodeURIComponent(e.arrangementId)),n,d(d({},t),{},{version:e.version}),"PATCH")})(e,t,l);if(m(t=>t?d(d({},t),{},{items:t.items.map(t=>Hj(t)===Hj(e)?a:t)}):t),n){const n={};for(const a of Object.keys(t))["publicDate","patreonDate","pipelineStatus","title","format","platforms","hidden","adInventoryHidden","quality","hiddenReason","ads","adMediaUrl","adState","adPlacements","publicPublished","patreonPublished"].includes(a)&&(n[a]="adInventoryHidden"===a?!!e.adInventoryHidden:e[a]);dt(Object.keys(n).length?{item:a,patch:n}:null)}else dt(null);return x("Saved ".concat(e.title,".")),!0}catch(BH){return p(BH.message),await gt(),!1}finally{ht.current=!1,D(!1)}},yt=async e=>{if(!ht.current){ht.current=!0,D(!0),p("");try{const t=await((e,t)=>Vj("/reflow",t,e,"POST"))({dryRun:!e,fillUndated:!0},l);e?(await gt(),x("Reflow applied: ".concat(t.moves.length," release").concat(1===t.moves.length?"":"s"," moved, ").concat((t.placements||[]).length," undated placed").concat(t.errors.length?", ".concat(t.errors.length," left for the next run"):"",".")),nt(null)):nt(t)}catch(BH){p(BH.message)}finally{ht.current=!1,D(!1)}}},vt=e=>{V(e.quality||""),Y(e.title),K(e.format||e.suggestedFormat||"show"),J(Xj(e,"public")),ie({public:Kj(e,"public"),patreon:Kj(e,"patreon")}),me(e.adPlacements||{}),be(e.ads||[]),pe(e.adMediaUrl||""),xe(e.adState||"planned"),le([]),de(Object.fromEntries(Object.entries(e.publishedVersions||{}).map(e=>{let[t,n]=e;return[t,n.versionId]}))),fetch("/api/v1/arrangements/".concat(encodeURIComponent(e.arrangementId),"/versions"),{credentials:"include",headers:l?{Authorization:"Bearer ".concat(l)}:{}}).then(e=>e.ok?e.json():null).then(e=>{e&&le(Array.isArray(e)?e:e.versions||[])}).catch(()=>{}),Se(e),Ae(e.publicDate||""),Me(e.patreonDate||""),Be(e.pipelineStatus||""),rt(e.notionPageId||""),Pe(!!e.contractual),Re(e.contractualNote||""),Oe("committed"===e.flexibility),Ve(e.note||""),qe(!!e.estimated),Ye(!!e.noAutoPlace),Ke(e.noAutoPlaceReason||""),Je(!!e.exhausted),Qe(e.exhaustedReason||""),et(e.contractDeadline||"")},wt=e=>{ke({date:e,channel:"patreon"===_?"patreon":"public"}),De(""),Ne(0),R("existing")},kt=qj(new Date),jt=(0,a.useMemo)(()=>((null===c||void 0===c?void 0:c.items)||[]).filter(e=>(Z||!e.hidden)&&"".concat(e.title," ").concat(e.sourceTitle||""," ").concat(e.arrangementId).toLowerCase().includes(T.toLowerCase())&&("all"===I||(e.format||"show")===I)&&("all"===H||(e.quality||"unrated")===H)&&("all"===ye||(e.pipelineStatus||e.arrangementStatus)===ye)),[c,T,ye,I,Z,H]),Dt=(0,a.useMemo)(()=>jt.flatMap(e=>["public","patreon"].filter(t=>("all"===_||_===t)&&nD(e,t)).map(t=>({item:e,channel:t,date:nD(e,t)}))).sort((e,t)=>
2e.date.localeCompare(t.date)||e.item.title.localeCompare(t.item.title)),[jt,_]),Ct="".concat(E.slice(0,7),"-01"),Nt=Gj("week"===F?E:Ct),Ft=new Date(Wj(E).getFullYear(),Wj(E).getMonth()+1,0).getDate(),St=(Wj(Ct).getDay()+6)%7,Et=Array.from({length:"week"===F?7:7*Math.ceil((St+Ft)/7)},(e,t)=>Yj(Nt,t)),At=Yj(Yj(Ct,0,1),-1),Tt=Dt.filter(e=>e.date>=Ct&&e.date<=At),Mt="midform"===ae||"short"===ae,_t=e=>"show"===(e.format||e.suggestedFormat||"show"),Bt=(Mt?jt.filter(e=>e.format===ae?!Kj(e,"public")&&!e.publicDate:Hj(e)===e.arrangementId&&_t(e)):jt.filter(e=>_t(e)&&("all"===_?(e=>{var t;return 1===(null===(t=e.platforms)||void 0===t?void 0:t.length)&&"Patreon"===e.platforms[0]?["patreon"]:Hj(e)===e.arrangementId&&"show"===(e.format||e.suggestedFormat||"show")?["public","patreon"]:["public"]})(e):[_]).some(t=>!nD(e,t)&&!Kj(e,t)))).filter(e=>"".concat(e.title," ").concat(e.sourceTitle||""," ").concat(e.arrangementId).toLowerCase().includes(te.toLowerCase()));(0,a.useEffect)(()=>{lt(e=>Math.min(e,Math.max(0,Math.ceil(Bt.length/12)-1)))},[Bt.length]);const It=((null===c||void 0===c?void 0:c.items)||[]).filter(e=>!e.hidden&&("existing"===L||Hj(e)===e.arrangementId&&_t(e))&&"".concat(e.title," ").concat(e.arrangementId).toLowerCase().includes(je.toLowerCase())),Pt=[...jt.filter(e=>!e.hidden&&!Kj(e,"public")&&"midform"!==e.format&&"short"!==e.format&&!(e.durationSeconds&&e.durationSeconds<900)&&($||!e.adInventoryHidden)).map(e=>({key:Hj(e),title:e.title,ads:e.ads||[],date:e.publicDate,media:e.adMediaUrl,placements:e.adPlacements||{},state:e.adState,item:e,url:e.notionUrl,hidden:e.adInventoryHidden})),...((null===c||void 0===c?void 0:c.inventory)||[]).filter(e=>!e.published&&($||!e.adInventoryHidden)&&e.ads.length&&!(null!==c&&void 0!==c&&c.items.some(t=>t.notionPageId===e.notionPageId))&&e.title.toLowerCase().includes(T.toLowerCase())).map(e=>({key:e.notionPageId,title:e.title,ads:e.ads,date:e.publicDate,media:e.adMediaUrl,placements:{},state:e.adState,item:null,url:e.notionUrl,hidden:e.adInventoryHidden}))],Lt=Array.from(new Set([...null!==c&&void 0!==c&&null!==(t=c.sync.qualityOptions)&&void 0!==t&&t.length?c.sync.qualityOptions:["S+","S","A","B","C","D"],...((null===c||void 0===c?void 0:c.items)||[]).map(e=>e.quality).filter(e=>!!e)])),Rt=e=>!1!==e.canWrite,zt=(e,t,n)=>{e.dataTransfer.setData(lD,JSON.stringify({id:Hj(t),channel:"midform"===n||"short"===n?"public":n,format:"midform"===n||"short"===n?n:void 0})),e.dataTransfer.effectAllowed="move"},Ot=e=>{var t,n,a;let{item:r,channel:s,date:i}=e;return(0,u.jsxs)("button",{type:"button",className:"pub-event pub-".concat(s," pub-format-").concat(r.format||"show"),disabled:j,draggable:!j&&Rt(r)&&!Kj(r,s),onDragStart:e=>zt(e,r,s),onDragEnd:()=>it(""),onClick:()=>vt(r),"aria-label":"".concat(r.title,", ").concat(tD(s),", ").concat(rD(i),". Edit publication"),children:[Kj(r,s)&&(0,u.jsx)(Ej,{size:19,className:"pub-published-tick","aria-label":"Published"}),(0,u.jsxs)("div",{className:"pub-event-meta",children:[(0,u.jsx)(Qj,{names:Xj(r,s)}),r.contractual&&(0,u.jsx)("span",{className:"pub-commitment",title:"Contractual date: never moved".concat(r.contractualNote?" \xb7 ".concat(r.contractualNote):""),children:(0,u.jsx)(Aj,{size:13,"aria-label":"Contractual date"})}),r.noAutoPlace&&(0,u.jsx)("span",{className:"pub-commitment",title:"Never auto-placed".concat(r.noAutoPlaceReason?" \xb7 ".concat(r.noAutoPlaceReason):""),children:(0,u.jsx)(Tj,{size:13,"aria-label":"Never auto-placed"})}),r.exhausted&&(0,u.jsx)("span",{className:"pub-commitment",title:"Show exhausted: no more automatic cuts".concat(r.exhaustedReason?" \xb7 ".concat(r.exhaustedReason):""),children:(0,u.jsx)(pj,{size:13,"aria-label":"Show exhausted"})}),r.estimated&&(0,u.jsx)("span",{className:"pub-commitment",title:"Estimated date: a placeholder, never a firm slip",children:(0,u.jsx)(Mj,{size:13,"aria-label":"Estimated date"})}),r.contractDeadline&&(0,u.jsx)("span",{className:"pub-commitment",title:"Contract deadline: publish on or before ".concat(r.contractDeadline),children:(0,u.jsx)(_
2j,{size:13,"aria-label":"Contract deadline"})}),!r.contractual&&"committed"===(null!==(t=null===(n=r.flexibilityByChannel)||void 0===n?void 0:n[s])&&void 0!==t?t:r.flexibility)&&(0,u.jsx)("span",{className:"pub-commitment",title:"Committed date: moves are proposed, never applied".concat(r.commitmentReason?" \xb7 ".concat(r.commitmentReason):""),children:(0,u.jsx)(Ey,{size:13,"aria-label":"Committed date"})}),r.quality&&(0,u.jsx)("span",{className:"pub-quality",title:"Quality: ".concat(r.quality),children:r.quality})]}),(0,u.jsxs)("span",{className:"pub-event-channel",children:[sD(r)," \xb7 ",tD(s),Kj(r,s)?" \xb7 Published":i<kt&&"Published"!==r.pipelineStatus?" \xb7 overdue":""]}),(0,u.jsx)("strong",{children:r.title}),(null===(a=r.project)||void 0===a?void 0:a.name)&&(0,u.jsx)("span",{className:"pub-project-label",title:"Project: ".concat(r.project.name),children:r.project.name}),"public"===s&&!Kj(r,"public")&&(0,u.jsxs)("span",{className:"pub-ad-icon",title:(r.ads||[]).filter(e=>"Potential Ad"!==e).join(", ")||"Open ad slot",children:[(0,u.jsx)(Bj,{size:14}),(r.ads||[]).some(e=>"Potential Ad"!==e)?(0,u.jsx)(Ej,{size:12}):(0,u.jsx)(Ij,{size:12})]}),["conflict","error","pending","unconfigured","unlinked"].includes(r.syncState)&&(0,u.jsx)("span",{className:"pub-event-sync",children:"conflict"===r.syncState?"Needs sync review":r.syncState})]},"".concat(Hj(r),"-").concat(s))},Ut=null!==c&&void 0!==c&&c.sync.error?"Notion sync failed: ".concat(c.sync.error):null!==c&&void 0!==c&&c.sync.configured?c.sync.lastSyncedAt?"Notion checked ".concat(new Date(c.sync.lastSyncedAt).toLocaleString()):"Notion connected \xb7 awaiting first sync":"Notion not connected \xb7 dates are saved in ReScript",Vt=(0,u.jsxs)("section",{ref:w,className:"publication-calendar".concat(f?" pub-fullscreen":""),"aria-label":"Publication calendar",children:[(0,u.jsxs)("div",{className:"pub-heading",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("h2",{children:[(0,u.jsx)(Pj,{size:24})," Publication calendar"]}),(0,u.jsx)("p",{children:"Plan full shows, midforms and shorts. Move a release to change its date."})]}),(0,u.jsxs)("div",{className:"pub-heading-actions",children:[(0,u.jsx)("button",{className:"pub-sync-button","aria-label":"Preview the calendar reflow",title:"Retrospective + reflow: preview what slipped and where flexible releases would move (contractual dates never move; committed ones are proposed)",onClick:()=>{yt(!1)},disabled:j,children:(0,u.jsx)(Lj,{size:18})}),(0,u.jsx)("button",{className:"pub-sync-button".concat(null!==c&&void 0!==c&&c.sync.error?" pub-sync-error":""),"aria-label":"Sync Notion",title:Ut,onClick:async()=>{if(!ht.current){ht.current=!0,D(!0),p("");try{await(e=>Vj("/sync",e,{},"POST"))(l),await gt(),x("Notion sync checked.")}catch(BH){p(BH.message)}finally{ht.current=!1,D(!1)}}},disabled:j||!(null!==c&&void 0!==c&&c.sync.configured),children:(0,u.jsx)(vp,{size:18,className:j?"animate-spin":""})}),(0,u.jsxs)("button",{ref:k,type:"button","aria-pressed":f,onClick:()=>{var e;f||v(!(null===(e=w.current)||void 0===e||!e.closest(".dark"))),b(e=>!e)},children:[f?(0,u.jsx)(Rj,{size:16}):(0,u.jsx)(zj,{size:16}),f?"Exit fullscreen":"Fullscreen"]}),(0,u.jsxs)("button",{className:"pub-primary",onClick:()=>wt(kt),disabled:j,children:[(0,u.jsx)(ik,{size:16})," Schedule release"]})]})]}),(h||(null===c||void 0===c?void 0:c.sync.error))&&(0,u.jsxs)("div",{className:"pub-alert",role:"alert",children:[h||(null===c||void 0===c?void 0:c.sync.error),(0,u.jsx)("button",{onClick:()=>{gt(!0)},disabled:j,children:"Refresh"})]}),g&&(0,u.jsxs)("div",{className:"pub-notice",role:"status",children:[g,ct&&(0,u.jsx)("button",{disabled:j,onClick:()=>{bt(ct.item,ct.patch,!1)},children:"Undo last change"}),(0,u.jsx)("button",{"aria-label":"Dismiss notification",onClick:()=>x(""),children:(0,u.jsx)(Pu,{size:16})})]}),tt&&(0,u.jsxs)("div",{className:"pub-reflow",role:"region","aria-label":"Calendar reflow preview",children:[(0,u.jsxs)("div",{className:"pub-reflow-head",children:[(0,u.jsxs)("h3",{children:["Reflow preview \xb7 ",rD(tt.today)]}),(0,u.jsx)("button",{"aria-label":"Apply the flexible moves",title:tt.moves.length+(tt.placements||[]).length?"Apply ".concat(tt.moves.length," flexible move").concat(1===tt.moves.length?"":"s"," and ").concat((tt.placements||[]).length," placement").concat(1===(tt.placements||[]).length?"":"s"," (proposals and contractual dates are never applied)"):"Nothing to move",disabled:j||!(tt.moves.length+(tt.placements||[]).length),onClick:()=>{yt(!0)},children:(0,u.jsx)(Wm,{size:18})}),(0,u.jsx)("button",{"aria-label":"Close the reflow preview",title:"Close",onClick:()=>nt(null),children:(0,u.jsx)(Pu,{size:18})})]}),[["URGENT \xb7 contractual date passed",tt.alerts,e=>e.why],["At risk \xb7 contractual",tt.atRisk,e=>e.why],["Never auto-placed (left as they are)",tt.excluded||[],e=>e.reason],["Placeholders (estimated dates passed: never slips)",tt.placeholders||[],e=>e.reason],["Decide (published show or marked done: never moved)",tt.decisions||[],e=>e.reason],["Slipped",tt.retrospective,e=>"".concat(e.channelName," ").concat(e.date," \xb7 ").concat(e.daysLate,"d late \xb7 ").concat(e.flexibility).concat(e.exported?"":" \xb7 never exported")],["Undated \xb7 placed on confirm (after the parent show)",tt.placements||[],e=>e.reason],["Moves (applied on confirm)",tt.moves,e=>e.reason],["Proposed to Tim (committed, never applied)",tt.proposals,e=>e.reason]].map(e=>{let[t,n,a]=e;return n.length?(0,u.jsxs)("section",{children:[(0,u.jsxs)("h4",{children:[t," ",(0,u.jsx)("span",{children:n.length})]}),(0,u.jsx)("ul",{children:n.map((e,t)=>(0,u.jsxs)("li",{children:["fixed"===e.flexibility?(0,u.jsx)(Aj,{size:13,"aria-label":"Contractual"}):"committed"===e.flexibility?(0,u.jsx)(Ey,{size:13,"aria-label":"Committed"}):null,(0,u.jsx)("strong",{children:e.title})," ",a(e)]},"".concat(e.publicationId,"-").concat(e.channel,"-").concat(t)))})]},t):null}),!(null===(n=tt.undated)||void 0===n||!n.filter(e=>"show"===e.format).length)&&(0,u.jsxs)("section",{children:[(0,u.jsxs)("h4",{children:["Undated shows (a person dates them) ",(0,u.jsx)("span",{children:tt.undated.filter(e=>"show"===e.format).length})]}),(0,u.jsx)("ul",{children:tt.undated.filter(e=>"show"===e.format).map(e=>(0,u.jsxs)("li",{children:[(0,u.jsx)("strong",{children:e.title})," last edited ",e.lastEdited||"unknown"]},e.publicationId))})]}),!(null===(r=tt.undatedDormant)||void 0===r||!r.length)&&(0,u.jsxs)("p",{className:"pub-muted",children:[tt.undatedDormant.length," dormant undated release",1===tt.undatedDormant.length?"":"s"," (not edited for 14 days) left for a person."]}),!tt.moves.length&&!(tt.placements||[]).length&&!tt.retrospective.length&&!tt.alerts.length&&!tt.atRisk.length&&(0,u.jsx)("p",{className:"pub-muted",children:"Nothing slipped: every past date is published and nothing needs to move."})]}),(0,u.jsxs)("div",{className:"pub-toolbar",children:[(0,u.jsx)("div",{className:"pub-views",role:"group","aria-label":"Calendar view",children:["month","week","agenda","ads"].map(e=>(0,u.jsx)("button",{"aria-pressed":F===e,className:F===e?"selected":"",onClick:()=>S(e),children:e},e))}),(0,u.jsxs)("label",{className:"pub-search",children:[(0,u.jsx)(Mu,{size:16}),(0,u.jsx)("input",{"aria-label":"Search publication calendar",placeholder:"Search shows\u2026",value:T,onChange:e=>{M(e.target.value),lt(0)}})]}),(0,u.jsxs)("select",{"aria-label":"Publication channel",value:_,onCh
2ange:e=>{B(e.target.value),lt(0)},children:[(0,u.jsx)("option",{value:"all",children:"Public + Patreon"}),(0,u.jsx)("option",{value:"public",children:"Public only"}),(0,u.jsx)("option",{value:"patreon",children:"Patreon only"})]}),(0,u.jsxs)("select",{"aria-label":"Quality filter",value:H,onChange:e=>{q(e.target.value),lt(0)},children:[(0,u.jsx)("option",{value:"all",children:"All quality ratings"}),(0,u.jsx)("option",{value:"unrated",children:"Unrated"}),Lt.map(e=>(0,u.jsx)("option",{value:e,children:e},e))]}),(0,u.jsxs)("select",{"aria-label":"Publication format filter",value:I,onChange:e=>{P(e.target.value),lt(0)},children:[(0,u.jsx)("option",{value:"all",children:"All formats"}),(0,u.jsx)("option",{value:"show",children:"Full shows"}),(0,u.jsx)("option",{value:"midform",children:"Midforms"}),(0,u.jsx)("option",{value:"short",children:"Shorts"})]}),(0,u.jsxs)("select",{"aria-label":"Pipeline status filter",value:ye,onChange:e=>{ve(e.target.value),lt(0)},children:[(0,u.jsx)("option",{value:"all",children:"All stages"}),Array.from(new Set([...eD,...((null===c||void 0===c?void 0:c.items)||[]).map(e=>e.pipelineStatus||e.arrangementStatus)])).filter(Boolean).map(e=>(0,u.jsx)("option",{children:e},e))]})]}),"ads"!==F&&(0,u.jsxs)("div",{className:"pub-period",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("button",{"aria-label":"Previous period",onClick:()=>A(Yj(E,"week"===F?-7:0,"week"===F?0:-1)),children:(0,u.jsx)(dk,{size:18})}),(0,u.jsx)("h3",{children:"week"===F?"".concat(rD(Nt)," \u2013 ").concat(rD(Et[6])):Wj(E).toLocaleDateString(void 0,{month:"long",year:"numeric"})}),(0,u.jsx)("button",{"aria-label":"Next period",onClick:()=>A(Yj(E,"week"===F?7:0,"week"===F?0:1)),children:(0,u.jsx)(bp,{size:18})})]}),(0,u.jsx)("button",{onClick:()=>A(kt),children:"Today"})]}),C?(0,u.jsx)("p",{role:"status",children:"Loading publication plans\u2026"}):(0,u.jsxs)(u.Fragment,{children:[("month"===F||"week"===F)&&(0,u.jsx)("div",{className:"pub-grid-scroll",children:(0,u.jsxs)("div",{className:"pub-grid",children:[["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(e=>(0,u.jsx)("div",{className:"pub-weekday",children:e},e)),Et.map(e=>(0,u.jsxs)("div",{className:"pub-day ".concat(e===kt?"today":""," ").concat(e.slice(0,7)!==E.slice(0,7)?"outside":""," ").concat(st===e?"drag-over":""),onDragOver:t=>{Array.from(t.dataTransfer.types).includes(lD)&&(t.preventDefault(),it(e))},onDrop:t=>((e,t)=>{e.preventDefault(),it("");try{const n=JSON.parse(e.dataTransfer.getData(lD)),a=null===c||void 0===c?void 0:c.items.find(e=>Hj(e)===n.id);if(a&&Rt(a)&&!j&&["midform","short"].includes(n.format)&&a.format!==n.format)return ke(null),Se(null),void O({source:a,title:"".concat(a.title," \u2014 ").concat(n.format),format:n.format,channel:"public",date:t,platforms:Zj(n.format)});a&&Rt(a)&&!j&&["public","patreon"].includes(n.channel)&&!Kj(a,n.channel)&&bt(a,{[aD(n.channel)]:t})}catch(_H){}})(t,e),children:[(0,u.jsxs)("button",{className:"pub-day-add",onClick:()=>wt(e),"aria-label":"Schedule on ".concat(rD(e)),disabled:j,children:[(0,u.jsx)("span",{children:Wj(e).getDate()}),(0,u.jsx)(ik,{size:13})]}),Dt.filter(t=>t.date===e).map(Ot)]},e))]})}),"agenda"===F&&(0,u.jsx)("div",{className:"pub-agenda",children:Tt.length?Tt.map(e=>(0,u.jsxs)("div",{className:"pub-agenda-row",children:[(0,u.jsx)("time",{dateTime:e.date,children:rD(e.date)}),Ot(e),(0,u.jsx)("span",{children:e.item.pipelineStatus||e.item.arrangementStatus}),(0,u.jsx)("button",{disabled:j||!Rt(e.item)||Kj(e.item,e.channel),onClick:()=>{bt(e.item,{[aD(e.channel)]:Yj(e.date,1)})},children:"+1 day"}),(0,u.jsx)("button",{disabled:j||!Rt(e.item)||Kj(e.item,e.channel),onClick:()=>{bt(e.item,{[aD(e.channel)]:Yj(e.date,7)})},children:"+1 week"}),(0,u.jsx)("button",{disabled:j||!Rt(e.item)||Kj(e.item,e.channel),onClick:()=>{bt(e.item,{[aD(e.channel)]:Yj(e.date,0,1)})},children:"+1 month"})]},"".concat(Hj(e.item),"-").concat(e.channel))):(0,u.jsx)("div",{className:"pub-empty",children:"No releases planned this month. Click \u201cSchedule release\u201d to add one."})}),"ads"===F&&(0,u.jsxs)("div",{className:"pub-ad-inventory",children:[(0,u.jsx)("h3",{children:"Ad
2inventory"}),(0,u.jsx)("p",{children:"Upcoming assignments and open slots. Shorts, midforms and arrangements under 15 minutes are excluded; Patreon remains ad-free."}),(0,u.jsxs)("label",{className:"pub-ad-hidden-toggle",children:[(0,u.jsx)("input",{type:"checkbox",checked:$,onChange:e=>Q(e.target.checked)})," Show hidden ad inventory"]}),(0,u.jsx)("div",{className:"pub-ad-summary",children:Array.from(new Set(Pt.filter(e=>!e.hidden).flatMap(e=>e.ads).filter(e=>"Potential Ad"!==e))).map(e=>(0,u.jsxs)("span",{children:[(0,u.jsx)(Bj,{size:16}),(0,u.jsx)("strong",{children:e})," ",Pt.filter(t=>!t.hidden&&t.ads.includes(e)).length," upcoming"]},e))}),(0,u.jsx)("div",{className:"pub-ad-table",children:Pt.map(e=>(0,u.jsxs)("div",{className:"pub-ad-row ".concat(e.hidden?"pub-hidden":""),children:[(0,u.jsx)(Bj,{size:18}),(0,u.jsxs)("div",{children:[(0,u.jsx)("strong",{children:e.title}),(0,u.jsxs)("small",{children:[e.date?rD(e.date):"Unscheduled"," \xb7 ",e.ads.filter(e=>"Potential Ad"!==e).join(", ")||"Open ad slot",e.ads.includes("Potential Ad")&&" \xb7 Potential ad"]})]}),(0,u.jsx)("span",{children:e.state||"planned"}),Object.entries(e.placements).filter(t=>{let[n,a]=t;return e.ads.includes(n)&&a.mediaUrl}).map(e=>{let[t,n]=e;return(0,u.jsxs)("a",{href:n.mediaUrl,target:"_blank",rel:"noreferrer",title:"Open ".concat(t," ad video \xb7 ").concat(n.state),children:[(0,u.jsx)(uj,{size:18}),(0,u.jsx)("small",{children:t})]},t)}),e.media?(0,u.jsx)("a",{href:e.media,target:"_blank",rel:"noreferrer",title:"Open ad video",children:(0,u.jsx)(uj,{size:18})}):!Object.entries(e.placements).some(t=>{let[n,a]=t;return e.ads.includes(n)&&a.mediaUrl})&&(0,u.jsx)("span",{title:"Ad video not assigned",children:(0,u.jsx)(Ij,{size:18})}),e.item?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{"aria-label":"".concat(e.hidden?"Restore to":"Hide from"," ad inventory: ").concat(e.title),title:e.hidden?"Restore to ad inventory":"Hide from ad inventory only",disabled:j||!Rt(e.item),onClick:()=>{bt(e.item,{adInventoryHidden:!e.hidden})},children:[(0,u.jsx)(Fy,{size:16}),e.hidden&&"Restore"]}),(0,u.jsx)("button",{onClick:()=>vt(e.item),children:"Manage"})]}):e.url&&(0,u.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",children:"Notion \u2197"})]},e.key))})]}),"ads"!==F&&(0,u.jsxs)("div",{className:"pub-backlog",children:[(0,u.jsxs)("h3",{children:[Mt?"".concat("midform"===ae?"Midform":"Short"," sources"):"Unscheduled"," ","all"!==_&&"for ".concat(tD(_))," ",(0,u.jsx)("span",{children:Bt.length})]}),(0,u.jsxs)("div",{className:"pub-backlog-tools",children:[(0,u.jsxs)("label",{className:"pub-backlog-search",children:[(0,u.jsx)(Mu,{size:16}),(0,u.jsx)("input",{type:"search","aria-label":"Search unscheduled arrangements",placeholder:"Find an unscheduled show\u2026",value:te,onChange:e=>{ne(e.target.value),lt(0)}})]}),(0,u.jsx)("p",{children:Mt?"Drag an existing ".concat(ae," to schedule it, or a full show to prepare a separate release."):"Full shows stay here until main and Patreon are assigned. Choose which release to drag."}),(0,u.jsxs)("label",{children:["Drag as",(0,u.jsxs)("select",{value:ae,onChange:e=>re(e.target.value),children:[(0,u.jsx)("option",{value:"public",children:"Main \xb7 YouTube + Spotify"}),(0,u.jsx)("option",{value:"patreon",children:"Patreon"}),(0,u.jsx)("option",{value:"midform",children:"Midform \xb7 X + LinkedIn"}),(0,u.jsx)("option",{value:"short",children:"Short \xb7 YouTube + Instagram"})]})]}),(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"checkbox",checked:Z,onChange:e=>ee(e.target.checked)})," Show hidden"]})]}),(0,u.jsx)("div",{className:"pub-backlog-items",children:Bt.slice(12*ot,12*(ot+1)).map(e=>(0,u.jsxs)("div",{className:"pub-backlog-card ".concat(e.hidden?"pub-hidden":""),children:[(0,u.jsxs)("button",{"aria-label":"".concat(e.title," ").concat(e.pipelineStatus||e.arrangementStatus),draggable:!j&&Rt(e)&&(Mt?e.format!==ae||!Kj(e,"public"):!Kj(e,ae)),disabled:j,onDragStart:t=>zt(t,e,ae),onClick:()=>vt(e),children:[(0,u.jsx)("strong",{children:e.title}),(0,u.jsxs)("span",{children:[sD(d(d({},e),{},{format:e.format||e.suggestedFormat}))," \xb7 ",Math.round((e.durationSeconds||0)/60)," min"]}),(0,u.jsx)("span",{className:"pub-assignment-progress",children:["public","patreon"].map(t=>(0,u.jsxs)("span",{title:"".concat(tD(t),": ").concat(Kj(e,t)?"published":nD(e,t)?"scheduled":"unassigned"),className:nD(e,t)||Kj(e,t)?"assigned":"",children:[(0,u.jsx)(Qj,{names:Xj(e,t)}),Kj(e,t)?(0,u.jsx)(Ej,{size:13}):nD(e,t)?(0,u.jsx)(Pj,{size:13}):(0,u.jsx)(Ij,{size:13})]},t))})]}),(0,u.jsxs)("button",{className:"pub-hide-button","aria-label":"".concat(e.hidden?"Unhide":"Hide"," ").concat(e.title),title:e.hiddenReason||"Hide from planning",disabled:j||!Rt(e),onClick:()=>{bt(e,{hidden:!e.hidden,hiddenReason:e.hidden?null:"Hidden manually"})},children:[(0,u.jsx)(Fy,{size:15}),e.hidden&&"Unhide"]})]},Hj(e)))}),Bt.length>12&&(0,u.jsxs)("div",{className:"pub-pagination",children:[(0,u.jsx)("button",{disabled:!ot,onClick:()=>lt(e=>e-1),children:"Previous"}
2),(0,u.jsxs)("span",{children:["Page ",ot+1," of ",Math.ceil(Bt.length/12)]}),(0,u.jsx)("button",{disabled:12*(ot+1)>=Bt.length,onClick:()=>lt(e=>e+1),children:"Next"})]})]})]}),xt&&(0,mk.createPortal)((0,u.jsx)("div",{className:"pub-modal-overlay publication-calendar",children:(0,u.jsxs)("div",{className:"pub-modal",role:"dialog","aria-modal":"true","aria-labelledby":"pub-modal-title",ref:pt,children:[(0,u.jsx)("button",{className:"pub-close","aria-label":"Close publication dialog",disabled:j,onClick:()=>{ke(null),Se(null),O(null)},children:(0,u.jsx)(Pu,{size:20})}),h&&(0,u.jsx)("div",{className:"pub-alert",role:"alert",children:h}),we&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{id:"pub-modal-title",children:"Schedule release"}),(0,u.jsxs)("label",{children:["Schedule",(0,u.jsxs)("select",{value:L,onChange:e=>{R(e.target.value),Ne(0)},children:[(0,u.jsx)("option",{value:"existing",children:"Main or Patreon \xb7 existing show"}),(0,u.jsx)("option",{value:"show",children:"Additional full-show release \xb7 separate platform/edit"}),(0,u.jsx)("option",{value:"midform",children:"New midform \xb7 ~10 minutes"}),(0,u.jsx)("option",{value:"short",children:"New short \xb7 vertical"})]})]}),(0,u.jsxs)("div",{className:"pub-form-row",children:[(0,u.jsxs)("label",{children:["Release date",(0,u.jsx)("input",{type:"date",required:!0,value:we.date,onChange:e=>ke(d(d({},we),{},{date:e.target.value}))})]}),(0,u.jsxs)("label",{children:["Channel",(0,u.jsxs)("select",{value:we.channel,onChange:e=>ke(d(d({},we),{},{channel:e.target.value})),children:[(0,u.jsx)("option",{value:"public",children:"Public"}),(0,u.jsx)("option",{value:"patreon",children:"Patreon"})]})]})]}),(0,u.jsxs)("label",{children:["existing"===L?"Find an arrangement or release":"Choose a source arrangement",(0,u.jsx)("input",{type:"search",placeholder:"Search by title or ID\u2026",value:je,onChange:e=>{De(e.target.value),Ne(0)}})]}),(0,u.jsxs)("div",{className:"pub-picker-results",children:[It.slice(10*Ce,10*(Ce+1)).map(e=>(0,u.jsxs)("button",{disabled:j||!we.date||!Rt(e),onClick:async()=>{"existing"!==L?(O({source:e,title:"".concat(e.title," \u2014 ").concat(L),format:L,channel:we.channel,date:we.date,platforms:"patreon"===we.channel?["Patreon"]:Zj(L)}),ke(null)):await bt(e,{[aD(we.channel)]:we.date})&&ke(null)},children:[(0,u.jsx)("strong",{children:e.title}),(0,u.jsx)("span",{children:"existing"!==L?"Source arrangement":e[aD(we.channel)]?"Move from ".concat(rD(e[aD(we.channel)])):e.pipelineStatus||e.arrangementStatus}),(0,u.jsx)(ik,{size:16})]},Hj(e))),!It.length&&(0,u.jsx)("p",{children:"No matching arrangements."})]}),(0,u.jsxs)("div",{className:"pub-pagination",children:[(0,u.jsx)("button",{disabled:!Ce||j,onClick:()=>Ne(e=>e-1),children:"Previous"}),(0,u.jsxs)("span",{children:[It.length," arrangements \xb7 page ",Ce+1," of ",Math.max(1,Math.ceil(It.length/10))]}),(0,u.jsx)("button",{disabled:10*(Ce+1)>=It.length||j,onClick:()=>Ne(e=>e+1),children:"Next"})]})]}),z&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("h2",{id:"pub-modal-title",children:["New ","show"===z.format?"full-show release":z.format]}),(0,u.jsxs)("p",{children:["Source: ",z.source.title]}),(0,u.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),!ht.current){ht.current=!0,++mt.current,D(!0),p("");try{const e=await((e,t)=>Vj("/releases",t,e,"POST"))(d({arrangementId:z.source.arrangementId,title:z.title.trim(),format:z.format,platforms:z.platforms},"patreon"===z.channel?{patreonDate:z.date||null}:{publicDate:z.date||null}),l);m(t=>t?d(d({},t),{},{items:[...t.items,e]}):t),x("Created ".concat(e.title,".")),O(null),dt(null)}catch(t){p(t.message)}finally{ht.current=!1,D(!1)}}},children:[(0,u.jsxs)("label",{children:["Release title",(0,u.jsx)("input",{required:!0,maxLength:200,value:z.title,onChange:e=>O(d(d({},z),{},{title:e.target.value}))})]}),(0,u.jsxs)("label",{children:["Release channel",(0,u.jsxs)("select",{value:z.channel,onChange:e=>{const t=e.target.value;O(d(d({},z),{},{channel:t,platforms:"patreon"===t?["Patreon"]:Zj(z.format)}))},children:[(0,u.jsx)("option",{value:"public",children:"Main / public"}),(0,u.jsx)("option",{value:"patreon",children:"Patreon"})]})]}),(0,u.jsxs)("label",{children:["Release date",(0,u.jsx)("input",{type:"date",value:z.date,onChange:e=>O(d(d({},z),{},{date:e.target.value}))})]}),(0,u.jsxs)("fieldset",{className:"pub-platforms",children:[(0,u.jsx)("legend",{children:"Target platforms"}),oD.filter(e=>"patreon"===z.channel?"Patreon"===e:"Patreon"!==e).map(e=>(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"checkbox",checked:z.platforms.includes(e),onChange:t=>O(d(d({},z),{},{platforms:t.target.checked?[...z.platforms,e]:z.platforms.filter(t=>t!==e)}))}),e]},e))]}),(0,u.jsx)("p",{children:"show"===z.format?"Full show \xb7 an independent release of this arrangement for the selected channel and platforms.":"midform"===z.format?"Midform \xb7 typically around 10 minutes, for X and LinkedIn.":"Short \xb7 vertical video for YouTube Shorts, Instagram Reels and other feeds."}),(0,u.jsx)("p",{children:null!==c&&void 0!==c&&c.sync.configured?"A separate linked card will be added to the Notion publishing calendar.":"Saved in ReScript; a linked Notion card will be created once sync is connected."}),(0,u.jsxs)("div",{className:"pub-modal-actions",children:[(0,u.jsx)("button",{type:"button",disabled:j,onClick:()=>{ke({date:z.date||kt,channel:z.channel}),R(z.format),O(null)},children:"Back"}),(0,u.jsx)("button",{type:"submit",className:"pub-primary",disabled:j||!z.title.trim()||!z.platforms.length,children:j?"Creating\u2026":"Create release"})]})]})]}),Fe&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{id:"pub-modal-title",children:Fe.title}),(0,u.jsxs)("p",{className:"pub-muted",children:["Publication plans \xb7 ","unconfigured"===Fe.syncState?Fe.n
2otionUrl?"Notion linked \xb7 auto-sync not connected":"Auto-sync not connected":Fe.syncState]}),(0,u.jsxs)("form",{onSubmit:async e=>{e.preventDefault();const t={};var n;((U||null)!==(Fe.quality||null)&&(t.quality=U||null),Hj(Fe)!==Fe.arrangementId&&W!==Fe.title&&(t.title=W.trim()),G!==(Fe.format||Fe.suggestedFormat||"show")&&(t.format=G),JSON.stringify([...X].sort())!==JSON.stringify([...Xj(Fe,"public")].sort())&&(t.platforms=X),Hj(Fe)===Fe.arrangementId||Ee===(Fe.publicDate||"")&&Te===(Fe.patreonDate||""))||(Ee&&null!==(n=Fe.platforms)&&void 0!==n&&n.includes("Patreon")&&!Te&&!se.patreon&&(t.platforms=X),!Te||Ee||se.public||(t.platforms=["Patreon"]));for(const s of["public","patreon"])se[s]!==Kj(Fe,s)&&(t[s+"Published"]=se[s]);JSON.stringify(fe)!==JSON.stringify(Fe.ads||[])&&(t.ads=fe),JSON.stringify(ue)!==JSON.stringify(Fe.adPlacements||{})&&(t.adPlacements=ue);const a=Object.fromEntries(Object.entries(ce).filter(e=>{var t,n;let[a,r]=e;return r!==(null===(t=Fe.publishedVersions)||void 0===t||null===(n=t[a])||void 0===n?void 0:n.versionId)}).map(e=>{let[t,n]=e;return[t,n||null]}));if(Object.keys(a).length&&(t.publishedVersions=a),(he||null)!==(Fe.adMediaUrl||null)&&(t.adMediaUrl=he||null),ge!==(Fe.adState||"planned")&&(t.adState=ge),(Ee||null)!==Fe.publicDate&&(t.publicDate=Ee||null),(Te||null)!==Fe.patreonDate&&(t.patreonDate=Te||null),(_e||null)!==Fe.pipelineStatus&&(t.pipelineStatus=_e||null),Ie!==!!Fe.contractual&&(t.contractual=Ie),Ie&&(Le.trim()||null)!==(Fe.contractualNote||null)&&(t.contractualNote=Le.trim()||null),(Ue.trim()||null)!==(Fe.note||null)&&(t.note=Ue.trim()||null),He!==!!Fe.estimated&&(t.estimated=He),We!==!!Fe.noAutoPlace&&(t.noAutoPlace=We),We&&(Ge.trim()||null)!==(Fe.noAutoPlaceReason||null)&&(t.noAutoPlaceReason=Ge.trim()||null),Xe!==!!Fe.exhausted&&(t.exhausted=Xe),Xe&&($e.trim()||null)!==(Fe.exhaustedReason||null)&&(t.exhaustedReason=$e.trim()||null),(Ze||null)!==(Fe.contractDeadline||null)&&(t.contractDeadline=Ze||null),ze!==("committed"===Fe.flexibility)&&(t.commitment=ze?"committed":"flexible",ze&&(t.commitmentReason="set in the calendar")),at!==(Fe.notionPageId||"")){var r;const e=null===(r=at.split("?")[0].replace(/\/$/,"").match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{32})$/i))||void 0===r?void 0:r[1];if(!e)return void p("Paste a valid Notion calendar card link or page ID.");t.notionPageId=e}Object.keys(t).length&&!await bt(Fe,t)||Se(null)},children:[(0,u.jsxs)("section",{className:"pub-schedule-editor","aria-label":"Release schedule",children:[(0,u.jsx)("h3",{children:"Release schedule"}),(0,u.jsx)("p",{className:"pub-muted",children:"Main / YouTube and Patreon have separate dates. Move a release to keep its date and change its channel. Save to apply changes."}),["public","patreon"].map(e=>{var t;const n="public"===e?Ee:Te,a="public"===e?Ae:Me,r=null===(t=Fe.publicationEvidence)||void 0===t?void 0:t[e],s="public"===e?"patreon":"public",i="public"===e?Te:Ee,o="public"===s?"Main / YouTube":"Patreon",l="Move ".concat(tD(e)," release to ").concat(o);return r&&se[e]?(0,u.jsxs)("div",{className:"pub-date-editor",children:[(0,u.jsxs)("strong",{children:[tD(e)," release \xb7 Published"]}),(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"checkbox",checked:se[e],onChange:t=>ie(d(d({},se),{},{[e]:t.target.checked}))})," Confirmed published"]}),(0,u.jsx)("p",{children:(0,u.jsxs)("a",{href:r.url,target:"_blank",rel:"noreferrer",children:["Published on ","public"===e?"YouTube":"Patreon"," \xb7 ",r.publishedAt?new Date(r.publishedAt).toLocaleString():rD(r.publishedDate)," \u2197"]})}),n&&n!==r.publishedDate&&(0,u.jsxs)("p",{children:["Originally planned for ",rD(n),"."]})]},e):(0,u.jsxs)("div",{className:"pub-date-editor",children:[(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"checkbox",checked:se[e],onChange:t=>{ie(d(d({},se),{},{[e]:t.target.checked})),t.target.checked&&(!n||n>kt)&&a(kt)}})," ",(0,u.jsx)(Ej,{size:16})," Published on ",tD(e)]}),(0,u.jsxs)("label",{children:[tD(e)," release",(0,u.jsx)("input",{type:"date",value:n,onChange:e=>a(e.target.value)})]}),(0,u.jsxs)("div",{className:"pub-postpone",children:[(0,u.jsx)("span",{children:"Postpone"}),(0,u.jsx)("button",{type:"button",onClick:()=>a(Yj(n||kt,1)),children:"1 day"}),(0,u.jsx)("button",{type:"button",onClick:()=>a(Yj(n||kt,7)),children:"1 week"}),(0,u.jsx)("button",{type:"button",onClick:()=>a(Yj(n||kt,0,1)),children:"1 month"}),(0,u.jsx)("button",{type:"button",title:"Clear date","aria-label":"Clear date",disabled:!n||se[e],onClick:()=>a(""),children:(0,u.jsx)(Oj,{size:16})})]}),n&&!se[e]&&(0,u.jsxs)("div",{className:"pub-schedule-tools",children:[(0,u.jsxs)("span",{children:["Move to ",o]}),(0,u.jsx)("button",{type:"button",title:i||se[s]?"".concat(o," already has a release; edit its date separately"):l,"aria-label":l,disabled:j||!Rt(Fe)||!!i||se[s],onClick:()=>{("public"===s?Ae:Me)(n),a("")},children:(0,u.jsx)(Uj,{size:16})})]})]},e)}),(0,u.jsxs)("div",{className:"pub-schedule-tools",children:[(0,u.jsx)("span",{children:"Remove scheduled releases from calendar"}),(0,u.jsx)("button",{type:"button",title:"Remove scheduled releases from calendar","aria-label":"Remove scheduled releases from calendar",disabled:j||!Rt(Fe)||(!Ee||se.public)&&(!Te||se.patreon),onClick:()=>{se.public||Ae(""),se.patreon||Me("")},children:(0,u.jsx)(Oj,{size:18})})]}),(0,u.jsx)("p",{className:"pub-muted",children:"Removing a schedule returns it to the backlog. Published releases and the arrangement are kept."})]}),(0,u.jsxs)(u.Fragment,{children:[Hj(Fe)!==Fe.arrangementId&&(0,u.jsxs)("label",{children:["Release title",(0,u.jsx)("input",{required:!0,maxLength:200,value:W,onChange:e=>Y(e.target.value)})]}),(0,u.jsxs)("label",{children:["Quality",(0,u.jsxs)("select",{value:U,onChange:e=>V(e.target.value),children:[(0,u.jsx)("option",{value:"",children:"Unrated"}),Lt.map(e=>(0,u.jsx)("option",{value:e,children:e},e))]})]}),(0,u.jsxs)("label",{children:["Publication format",(0,u.jsxs)("select",{value:G,onChange:e=>K(e.target.value),children:[(0,u.jsx)("option",{value:"show",children:"Full show"}),(0,u.jsx)("option",{value:"midform",children:"Midform \xb7 under 15 minutes"}),(0,u.jsx)("option",{value:"short",children:"Short \xb7 vertical"})]})]}),(0,u.jsxs)("fieldset",{className:"pub-platforms",children:[(0,u.jsx)("legend",{children:"Main release platforms"}),Array.from(new Set([...oD,...X])).filter(e=>"Patreon"!==e).map(e=>(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"checkbox",checked:X.includes(e),onChange:t=>J(t.target.checked?[...X,e]:X.filter(t=>t!==e))}),e]},e))]}),Fe.sourceTitle&&(0,u.jsxs)("p",{children:["Source: ",Fe.sourceTitle]})]}),(0,u.jsxs)("fieldset",{className:"pub-platforms",children:[(0,u.jsx)("legend",{children:"Advertising"}),Array.from(new Set(["Potential Ad","Cyber","Parallel Web Systems","Tufa","Prolific","Google",...fe])).map(e=>(0,u.jsxs)("label",{children:[(0,u.jsx)("input",{type:"checkbox",checked:fe.includes(e),onChange:t=>be(t.target.checked?[...fe,e]:fe.filter(t=>t!==e))}),(0,u.jsx)(Bj,{size:14}),e]},e))]}),fe.filter(e=>"Potential Ad"!==e).map(e=>{var t,n;return(0,u.jsxs)("fieldset",{className:"pub-date-editor",children:[(0,u.jsxs)("legend",{children:[e," \xb7 main release"]}),(0,u.jsxs)("label",{children:["Video for ",e,(0,u.jsx)("input",{type:"url",placeholder:"https://www.dropbox.com/\u2026",value:(null===(t=ue[e])||void 0===t?void 0:t.mediaUrl)||"",onChange:t=>{var n;return me(d(d({},ue),{},{[e]:{state:(null===(n=ue[e])||void 0===n?void 0:n.state)||"planned",mediaUrl:t.target.value||null}}))}})]}),(0,u.jsxs)("label",{children:["Insertion for ",e,(0,u.jsx)("select",{value:(null===(n=ue[e])||void 0===n?void 0:n.state)||"planned",onChange:t=>{var n;return me(d(d({},ue),{},{[e]:{mediaUrl:(null===(n=ue[e])||void 0===n?void 0:n.mediaUrl)||null,state:t.target.value}}))},children:["planned","ready","inserted","verified","unconfirmed"].map(e=>(0,u.jsx)("option",{children:e},e))})]})]},e)}),(0,u.jsxs)("details",{children:[(0,u.jsx)("summary",{children:"Default ad media"}),(0,u.jsxs)("label",{children:["Default ad video \xb7 main release",(0,u.jsx)("input",{type:"url",value:he,placeholder:"https://www.dropbox.com/\u2026",onChange:e=>pe(e.target.value)})]}),(0,u.jsxs)("label",{children:["Ad insertion",(0,u.jsx)("select",{value:ge,onChange:e=>xe(e.target.value),children:["planned","ready","inserted","verified"].map(e=>(0,u.jsx)("option",{children:e},e))})]})]}),(0,u.jsx)("p",{className:"pub-muted",children:"Main-release ads are inserted after the ad-free Patreon cut. A separate platform release can use a different video."}),(0,u.jsxs)("section",{className:"pub-commitment-editor","aria-label":"Date commitment",children:[(0,u.jsx)("h3",{children:"Date commitment"}),(0,u.jsxs)("div",{className:"pub-commitment-toggles",children:[(0,u.jsx)("button",{type:"button","aria-pressed":Ie,"aria-label":"Contractual date",title:Ie?"Contractual: must ship on its date; the reflow never moves it (click to clear)":"Mark as contractual: under contract to publish on this date (only a person can set this)",disabled:j||!Rt(Fe),onClick:()=>Pe(e=>!e),children:(0,u.jsx)(Aj,{size:18})}),(0,u.jsx)("button",{type:"button","aria-pressed":ze,"aria-label":"Committed date",title:ze?"Committed (announced, sponsor, guest, embargo or slot): moves are proposed, never applied".concat(Fe.commitmentReason?" \xb7 ".concat(Fe.commitmentReason):""," (click to make flexible)"):"Mark as committed: the reflow proposes moves instead of applying them",disabled:j||!Rt(Fe)||Ie,onClick:()=>Oe(e=>!e),children:(0,u.jsx)(Ey,{size:18})}),(0,u.jsx)("button",{type:"button","aria-pressed":He,"aria-label":"Estimated date",title:He?"Estimated: these dates are a placeholder; a passed estimate is never a slip (click to make firm)":"Mark the dates as an estimate (a placeholder, e.g. awaiting a sponsor)",disabled:j||!Rt(Fe),onClick:()=>qe(e=>!e),children:(0,u.jsx)(Mj,{size:18})}),(0,u.jsx)("button",{type:"button","aria-pressed":We,"aria-label":"Never auto-place",title:We?"Never auto-placed: the calendar agent and the reflow never move or place it (click to allow)":"Never auto-place this release (it is not deleted; a real publication is still recorded)",disabled:j||!Rt(Fe),onClick:()=>Ye(e=>!e),children:(0,u.jsx)(Tj,{size:18})}),"show"===(Fe.format||"show")&&(0,u.jsx)("button",{type:"button","aria-pressed":Xe,"aria-label":"Show exhausted",title:Xe?"Exhausted: no more automatic cuts from this show (click to allow)":"Mark the show exhausted: done, obligation met; its cuts are never auto-placed",disabled:j||!Rt(Fe),onClick:()=>Je(e=>!e),children:(0,u.jsx)(pj,{size:18})})]}),We&&(0,u.jsxs)("label",{children:["Why never auto-placed",(0,u.jsx)("input",{maxLength:200,value:Ge,onChange:e=>Ke(e.target.value)})]}),Xe&&(0,u.jsxs)("label",{children:["Why exhausted",(0,u.jsx)("input",{maxLength:200,value:$e,onChange:e=>Qe(e.target.value)})]}),(0,u.jsxs)("label",{children:["Contract deadline (on or before)",(0,u.jsx)("input",{type:"date",value:Ze,onCh
2ange:e=>et(e.target.value)})]}),Ie&&(0,u.jsxs)("label",{children:["Contract",(0,u.jsx)("input",{maxLength:300,value:Le,placeholder:"Client and terms, e.g. Cyber: publish 2 Oct",onChange:e=>Re(e.target.value)})]}),(0,u.jsxs)("label",{children:["Note",(0,u.jsx)("input",{maxLength:300,value:Ue,placeholder:"e.g. Tim uploading to Patreon himself",onChange:e=>Ve(e.target.value)})]}),!(null===(s=Fe.moves)||void 0===s||!s.length)&&(0,u.jsxs)("details",{children:[(0,u.jsxs)("summary",{children:["Calendar moves (",Fe.moves.length,")"]}),(0,u.jsx)("ul",{className:"pub-moves",children:Fe.moves.slice().reverse().map((e,t)=>(0,u.jsxs)("li",{children:[(0,u.jsx)("time",{dateTime:e.at,children:new Date(e.at).toLocaleString()})," ",e.reason]},"".concat(e.at,"-").concat(t)))})]}),(null===(i=Fe.publicationEvidence)||void 0===i?void 0:i.spotify)&&(0,u.jsx)("p",{children:(0,u.jsxs)("a",{href:Fe.publicationEvidence.spotify.url,target:"_blank",rel:"noreferrer",children:["On Spotify \xb7 ",Fe.publicationEvidence.spotify.publishedAt?new Date(Fe.publicationEvidence.spotify.publishedAt).toLocaleString():rD(Fe.publicationEvidence.spotify.publishedDate)," \u2197"]})})]}),(0,u.jsxs)("label",{children:["Production stage",(0,u.jsxs)("select",{value:_e,onChange:e=>Be(e.target.value),children:[(0,u.jsx)("option",{value:"",disabled:!0,children:"Not set"}),Array.from(new Set([...null!==c&&void 0!==c&&null!==(o=c.sync.pipelineStatuses)&&void 0!==o&&o.length?c.sync.pipelineStatuses:eD,..._e?[_e]:[]])).map(e=>(0,u.jsx)("option",{children:e},e))]})]}),!Fe.notionPageId&&(0,u.jsxs)("label",{children:["Link a Notion calendar card",(0,u.jsx)("input",{value:at,onChange:e=>rt(e.target.value),placeholder:"Paste the existing card\u2019s Notion link"})]}),(0,u.jsxs)("details",{children:[(0,u.jsx)("summary",{children:"Published revisions"}),["public","patreon"].map(e=>(0,u.jsxs)("label",{children:[tD(e)," published revision",(0,u.jsxs)("select",{value:ce[e]||"",onChange:t=>de(d(d({},ce),{},{[e]:t.target.value})),children:[(0,u.jsx)("option",{value:"",children:"Suggest latest recorded XML export when published"}),oe.map(e=>(0,u.jsxs)("option",{value:e.id,children:["v",e.versionNumber," \xb7 ",e.createdAt]},e.id))]})]},e))]}),Object.entries(Fe.publishedVersions||{}).map(e=>{let[t,n]=e;return(0,u.jsxs)("p",{children:[(0,u.jsx)(uj,{size:14})," ",t," \xb7 ",n.inferred?"Suggested last XML export":"Published revision"," ",(0,u.jsxs)("a",{target:"_blank",rel:"noreferrer",href:"/arrangement/".concat(encodeURIComponent(Fe.previewToken||Fe.arrangementId),"/transcript?version=").concat(encodeURIComponent(n.versionId)),children:["v",n.versionNumber," \u2197"]})]},t)}),Fe.syncError&&(0,u.jsx)("p",{className:"pub-alert",children:Fe.syncError}),"conflict"===Fe.syncState&&(0,u.jsxs)("div",{className:"pub-alert",children:[(0,u.jsx)("p",{children:"Both ReScript and Notion have changes. Choose which values to keep."}),(0,u.jsxs)("table",{className:"pub-conflicts",children:[(0,u.jsx)("thead",{children:(0,u.jsxs)("tr",{children:[(0,u.jsx)("th",{children:"Field"}),(0,u.jsx)("th",{children:"ReScript"}),(0,u.jsx)("th",{children:"Notion"})]})}),(0,u.jsx)("tbody",{children:Object.entries(Fe.conflicts||{}).map(e=>{let[t,n]=e;return(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{children:"publicDate"===t?"Public date":"patreonDate"===t?"Patreon date":"pipelineStatus"===t?"Stage":t}),(0,u.jsx)("td",{children:iD(n.rescript)}),(0,u.jsx)("td",{children:iD(n.notion)})]},t)})})]}),(0,u.jsx)("button",{type:"button",disabled:j||!Rt(Fe),onClick:async()=>{await bt(Fe,{resolution:"notion"},!1)&&Se(null)},children:"Use Notion values"}),(0,u.jsx)("button",{type:"button",disabled:j||!Rt(Fe),onClick:async()=>{await bt(Fe,{resolution:"rescript"},!1)&&Se(null)},children:"Keep ReScript values"})]}),(0,u.jsx)("button",{type:"button",onClick:()=>{Se(null),wt(kt),R("show"),De(Fe.title)},children:"Schedule another platform release"}),(0,u.jsxs)("div",{className:"pub-modal-actions",children:[Fe.previewToken&&(0,u.jsx)("a",{href:"/arrangement/".concat(encodeURIComponent(Fe.previewToken)),target:"_blank",rel:"noreferrer",children:"Open arrangement \u2197"}),Fe.notionUrl&&(0,u.jsx)("a",{href:Fe.notionUrl,target:"_blank",rel:"noreferrer",children:"Open in Notion \u2197"}),(0,u.jsx)("button",{className:"pub-primary",type:"submit",title:j?"Saving\u2026":"Save dates","aria-label":j?"Saving\u2026":"Save dates",disabled:j||!Rt(Fe),children:(0,u.jsx)(Dh,{size:18})})]})]})]})]})}),document.body)]});return f?(0,mk.createPortal)((0,u.jsx)("div",{className:y?"dark":void 0,children:Vt}),document.body):Vt}const dD=Mo("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]),uD=Mo("pencil-line",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}],["path",{d:"m15 5 3 3",key:"1w25hb"}]]),mD=Mo("calendar-plus",[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]]),hD=Mo("arrow-down-a-z",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}
2],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]),pD=Mo("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]),gD=Mo("funnel-x",[["path",{d:"M12.531 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14v6a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341l.427-.473",key:"ol2ft2"}],["path",{d:"m16.5 3.5 5 5",key:"15e6fa"}],["path",{d:"m21.5 3.5-5 5",key:"m0lwru"}]]),xD=Mo("arrow-down-wide-narrow",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]]),fD=Mo("arrow-up-narrow-wide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]),bD=Mo("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),yD=Mo("tv",[["path",{d:"m17 2-5 5-5-5",key:"16satq"}],["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",key:"1e6viu"}]]),vD=Mo("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]),wD=Mo("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]),kD=Mo("notebook-text",[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M9.5 8h5",key:"11mslq"}],["path",{d:"M9.5 12H16",key:"ktog6x"}],["path",{d:"M9.5 16H14",key:"p1seyn"}]]),jD=Mo("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),DD=12,CD=e=>{var t,n;let{isOpen:r,onClose:s,anchorRef:i,align:o="end",offset:l=12,className:c="",children:d}=e;const m=(0,a.useRef)(null),[h,p]=(0,a.useState)(null);return(0,a.useLayoutEffect)(()=>{if(!r)return void p(null);const e=()=>{const e=i.current,t=m.current;if(!e||!t)return;const n=e.getBoundingClientRect(),a=t.getBoundingClientRect();let r=n.left;"center"===o?r=n.left+n.width/2-a.width/2:"end"===o&&(r=n.right-a.width);const s=window.innerWidth-a.width-DD,c=(d=r,u=DD,h=Math.max(DD,s),Math.min(Math.max(d,u),h));var d,u,h;const g=n.bottom+l+a.height<=window.innerHeight-DD?n.bottom+l:Math.max(DD,n.top-a.height-l);p({left:c,top:g})};e();const t=()=>{window.requestAnimationFrame(e)};return window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[o,i,r,l]),(0,a.useEffect)(()=>{if(!r)return;const e=e=>{const t=m.current,n=i.current,a=e.target;a&&(null!==t&&void 0!==t&&t.contains(a)||null!==n&&void 0!==n&&n.contains(a)||s())},t=e=>{"Escape"===e.key&&s()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[i,r,s]),r&&"undefined"!==typeof document?(0,mk.createPortal)((0,u.jsx)("div",{ref:m,className:"fixed z-[1200] ".concat(c),style:{left:null!==(t=null===h||void 0===h?void 0:h.left)&&void 0!==t?t:DD,top:null!==(n=null===h||void 0===h?void 0:h.top)&&void 0!==n?n:DD,animation:"fadeIn 0.15s ease-out"},children:d}),document.body):null};function ND(e){const t=String(null!==e&&void 0!==e?e:"").trim().toLowerCase();return""!==t&&"draft"!==t}const FD=e=>e.toLowerCase().replace(/(?:[\0-\/:-@\[-`\{-\xA9\xAB-\xB1\xB4\xB6-\xB8\xBB\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u036F\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482-\u0489\u
20530\u0557\u0558\u055A-\u055F\u0589-\u05CF\u05EB-\u05EE\u05F3-\u061F\u064B-\u065F\u066A-\u066D\u0670\u06D4\u06D6-\u06E4\u06E7-\u06ED\u06FD\u06FE\u0700-\u070F\u0711\u0730-\u074C\u07A6-\u07B0\u07B2-\u07BF\u07EB-\u07F3\u07F6-\u07F9\u07FB-\u07FF\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u083F\u0859-\u085F\u086B-\u086F\u0888\u088F-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962-\u0965\u0970\u0981-\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA-\u09BC\u09BE-\u09CD\u09CF-\u09DB\u09DE\u09E2-\u09E5\u09F2\u09F3\u09FA\u09FB\u09FD-\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A-\u0A58\u0A5D\u0A5F-\u0A65\u0A70\u0A71\u0A75-\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA-\u0ABC\u0ABE-\u0ACF\u0AD1-\u0ADF\u0AE2-\u0AE5\u0AF0-\u0AF8\u0AFA-\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A-\u0B3C\u0B3E-\u0B5B\u0B5E\u0B62-\u0B65\u0B70\u0B78-\u0B82\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BCF\u0BD1-\u0BE5\u0BF3-\u0C04\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C3E-\u0C57\u0C5B\u0C5C\u0C5E\u0C5F\u0C62-\u0C65\u0C70-\u0C77\u0C7F\u0C81-\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA-\u0CBC\u0CBE-\u0CDC\u0CDF\u0CE2-\u0CE5\u0CF0\u0CF3-\u0D03\u0D0D\u0D11\u0D3B\u0D3C\u0D3E-\u0D4D\u0D4F-\u0D53\u0D57\u0D62-\u0D65\u0D79\u0D80-\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DE5\u0DF0-\u0E00\u0E31\u0E34-\u0E3F\u0E47-\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EB1\u0EB4-\u0EBC\u0EBE\u0EBF\u0EC5\u0EC7-\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F1F\u0F34-\u0F3F\u0F48\u0F6D-\u0F87\u0F8D-\u0FFF\u102B-\u103E\u104A-\u104F\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B-\u1368\u137D-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u1712-\u171E\u1732-\u173F\u1752-\u175F\u176D\u1771-\u177F\u17B4-\u17D6\u17D8-\u17DB\u17DD-\u17DF\u17EA-\u17EF\u17FA-\u180F\u181A-\u181F\u1879-\u187F\u1885\u1886\u18A9\u18AB-\u18AF\u18F6-\u18FF\u191F-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DB-\u19FF\u1A17-\u1A1F\u1A55-\u1A7F\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1B04\u1B34-\u1B44\u1B4D-\u1B4F\u1B5A-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BFF\u1C24-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C8B-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1CFB-\u1CFF\u1DC0-\u1DFF\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u206F\u2072\u2073\u207A-\u207E\u208A-\u208F\u209D-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A-\u245F\u249C-\u24E9\u2500-\u2775\u2794-\u2BFF\u2CE5-\u2CEA\u2CEF-\u2CF1\u2CF4-\u2CFC\u2CFE\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7F\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF-\u2E2E\u2E30-\u3004\u3008-\u3020\u302A-\u3030\u3036\u3037\u303D-\u3040\u3097-\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u3191\u3196-\u319F\u31C0-\u31EF\u3200-\u321F\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA66F-\uA67E\uA69E\uA69F\uA6F0-\uA716\uA720\uA721\uA789\uA78A\uA7CE\uA7CF\uA7D2\uA7D4\uA7DD-\uA7F1\uA802\uA806\uA80B\uA823-\uA82F\uA836-\uA83F\uA874-\uA881\uA8B4-\uA8CF\uA8DA-\uA8F1\uA8F8-\uA8FA\uA8FC\uA8FF\uA926-\uA92F\uA947-\uA95F\uA97D-\uA983\uA9B3-\uA9CE\uA9DA-\uA9DF\uA9E5\uA9FF\uAA29-\uAA3F\uAA43\uAA4C-\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAC3-\uAADA\uAADE\uAADF\uAAEB-\uAAF1\uAAF5-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABE3-\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB1E\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD06\uDD34-\uDD3F\uDD79-\uDD89\uDD8C-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEE0\uDEFC-\uDEFF\uDF24-\uDF2C\uDF4B-\uDF4F\uDF76-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDD6F\uDD7B\uDD8B\uDD93\uDD96\uDDA2\uDDB2\uDDBA\uDDBD-\uDDBF\uDDF4-\uDDFF\uD
2F37-\uDF3F\uDF56-\uDF5F\uDF68-\uDF7F\uDF86\uDFB1\uDFBB-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56\uDC57\uDC77\uDC78\uDC9F-\uDCA6\uDCB0-\uDCDF\uDCF3\uDCF6-\uDCFA\uDD1C-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBB\uDDD0\uDDD1\uDE01-\uDE0F\uDE14\uDE18\uDE36-\uDE3F\uDE49-\uDE5F\uDE7F\uDEA0-\uDEBF\uDEC8\uDEE5-\uDEEA\uDEF0-\uDEFF\uDF36-\uDF3F\uDF56\uDF57\uDF73-\uDF77\uDF92-\uDFA8\uDFB0-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCF9\uDD24-\uDD2F\uDD3A-\uDD3F\uDD66-\uDD6E\uDD86-\uDE5F\uDE7F\uDEAA-\uDEAF\uDEB2-\uDEC1\uDEC5-\uDEFF\uDF28-\uDF2F\uDF46-\uDF50\uDF55-\uDF6F\uDF82-\uDFAF\uDFCC-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC00-\uDC02\uDC38-\uDC51\uDC70\uDC73\uDC74\uDC76-\uDC82\uDCB0-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDD02\uDD27-\uDD35\uDD40-\uDD43\uDD45\uDD46\uDD48-\uDD4F\uDD73-\uDD75\uDD77-\uDD82\uDDB3-\uDDC0\uDDC5-\uDDCF\uDDDB\uDDDD-\uDDE0\uDDF5-\uDDFF\uDE12\uDE2C-\uDE3E\uDE41-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEDF-\uDEEF\uDEFA-\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A-\uDF3C\uDF3E-\uDF4F\uDF51-\uDF5C\uDF62-\uDF7F\uDF8A\uDF8C\uDF8D\uDF8F\uDFB6\uDFB8-\uDFD0\uDFD2\uDFD4-\uDFFF]|\uD805[\uDC35-\uDC46\uDC4B-\uDC4F\uDC5A-\uDC5E\uDC62-\uDC7F\uDCB0-\uDCC3\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDAF-\uDDD7\uDDDC-\uDDFF\uDE30-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEAB-\uDEB7\uDEB9-\uDEBF\uDECA-\uDECF\uDEE4-\uDEFF\uDF1B-\uDF2F\uDF3C-\uDF3F\uDF47-\uDFFF]|\uD806[\uDC2C-\uDC9F\uDCF3-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD30-\uDD3E\uDD40\uDD42-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD1-\uDDE0\uDDE2\uDDE4-\uDDFF\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE4F\uDE51-\uDE5B\uDE8A-\uDE9C\uDE9E-\uDEAF\uDEF9-\uDFBF\uDFE1-\uDFEF\uDFFA-\uDFFF]|\uD807[\uDC09\uDC2F-\uDC3F\uDC41-\uDC4F\uDC6D-\uDC71\uDC90-\uDCFF\uDD07\uDD0A\uDD31-\uDD45\uDD47-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8A-\uDD97\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF3-\uDF01\uDF03\uDF11\uDF34-\uDF4F\uDF5A-\uDFAF\uDFB1-\uDFBF\uDFD5-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD812-\uD817\uD819\uD824-\uD82A\uD82D\uD82E\uD830-\uD832\uD836\uD83D\uD83F\uD87C\uD87D\uD87F\uD889-\uDBFF][\uDC00-\uDFFF]|\uD80B[\uDC00-\uDF8F\uDFF1-\uDFFF]|\uD80D[\uDC30-\uDC40\uDC47-\uDC5F]|\uD810[\uDFFB-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD818[\uDC00-\uDCFF\uDD1E-\uDD2F\uDD3A-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDE6F\uDEBF\uDECA-\uDECF\uDEEE-\uDEFF\uDF30-\uDF3F\uDF44-\uDF4F\uDF5A\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDD3F\uDD6D-\uDD6F\uDD7A-\uDE3F\uDE97-\uDEFF\uDF4B-\uDF4F\uDF51-\uDF92\uDFA0-\uDFDF\uDFE2\uDFE4-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFE\uDD09-\uDFFF]|\uD82B[\uDC00-\uDFEF\uDFF4\uDFFC\uDFFF]|\uD82C[\uDD23-\uDD31\uDD33-\uDD4F\uDD53\uDD54\uDD56-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDFFF]|\uD833[\uDC00-\uDCEF\uDCFA-\uDFFF]|\uD834[\uDC00-\uDEBF\uDED4-\uDEDF\uDEF4-\uDF5F\uDF79-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD837[\uDC00-\uDEFF\uDF1F-\uDF24\uDF2B-\uDFFF]|\uD838[\uDC00-\uDC2F\uDC6E-\uDCFF\uDD2D-\uDD36\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDE8F\uDEAE-\uDEBF\uDEEC-\uDEEF\uDEFA-\uDFFF]|\uD839[\uDC00-\uDCCF\uDCEC-\uDCEF\uDCFA-\uDDCF\uDDEE\uDDEF\uDDFB-\uDFDF\uDFE7\uDFEC\uDFEF\uDFFF]|\uD83A[\uDCC5\uDCC6\uDCD0-\uDCFF\uDD44-\uDD4A\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDC70\uDCAC\uDCB0\uDCB5-\uDD00\uDD2E\uDD3E-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEE0-\uDEFF]|\uD86D[\uDF3A-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFEF]|\uD87B[\uDE5E-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDF4F]|\uD888[\uDFB0-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+/g," ").trim(),SD=/^(#{1,6}\s|[-*_]{3,}\s*$|>\s*$|\|)/,ED=/^(status|state|draft|draft only|work in progress|wip
2)\s*[:\u2014\u2013-]/i,AD=/^(draft|draft only|wip|work in progress|not published|unpublished)\.?$/i;function TD(e){return e.replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/`([^`]*)`/g,"$1").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(^|[\s(])[*_]([^*_]+)[*_](?=[\s).,;:!?]|$)/g,"$1$2").replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+|>\s*)/,"").replace(/\s+/g," ").trim()}function MD(e){const t=Number(e)||0;if(t<=0)return"0s";const n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=Math.floor(t%60);return n>0?"".concat(n,"h ").concat(a,"m"):a>0?"".concat(a,"m ").concat(r,"s"):"".concat(r,"s")}function _D(e){const t=Number(e)||0;if(t<=0)return"0 B";const n=["B","KB","MB","GB","TB"];let a=t,r=0;for(;a>=1024&&r<n.length-1;)a/=1024,r+=1;const s=0===r?0:a>=10?1:2;return"".concat(a.toFixed(s)," ").concat(n[r])}function BD(e){const t=Number(e)||0;return t<=0?"$0.00/mo":t<.01?"<$0.01/mo":"$".concat(t.toFixed(t<1?2:1),"/mo")}function ID(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;if(!e)return"";const n=new Date(String(e).includes("T")?e:"".concat(String(e).replace(" ","T"),"Z"));if(Number.isNaN(n.getTime()))return"";const a={day:"numeric",month:"short"};return n.getFullYear()!==t.getFullYear()&&(a.year="numeric"),n.toLocaleDateString(void 0,a)}const PD=["none","month","project"],LD=["modified","next","shoot","publish","title","created","duration"],RD={modified:"desc",next:"asc",shoot:"desc",publish:"asc",title:"asc",created:"desc",duration:"desc"},zD={group:"none",sort:"modified",order:"desc",undated:"show"},OD="rescript.arrangements.viewPrefs",UD="rescript.arrangements.showTests",VD=["group","sort","order","undated"];function HD(e){return"modified"===e?"updated":e}function qD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:zD;const n="string"===typeof(a=null===e||void 0===e?void 0:e.group)&&PD.includes(a)?e.group:t.group;var a;const r=(e=>"string"===typeof e&&LD.includes(e))(null===e||void 0===e?void 0:e.sort),s=r?e.sort:t.sort,i=(e=>"asc"===e||"desc"===e)(null===e||void 0===e?void 0:e.order)?e.order:r?RD[s]:t.order;return{group:n,sort:s,order:i,undated:"hide"===(null===e||void 0===e?void 0:e.undated)||"show"===(null===e||void 0===e?void 0:e.undated)?e.undated:t.undated}}function WD(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"===typeof window?"":window.location.search;const t=function(){try{const e=window.localStorage.getItem(OD);return e?qD(JSON.parse(e)):zD}catch(_H){return zD}}();let n;try{n=new URLSearchParams(e)}catch(r){return t}const a={};for(const s of VD){const e=n.get(s);e&&(a[s]=e)}return Object.keys(a).length?qD(d({undated:"show"},a),t):t}function YD(){try{return"1"===window.localStorage.getItem(UD)}catch(e){return!1}}const GD=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function KD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date;const n=/^(\d{4})-(\d{2})-(\d{2})/.exec(e||"");if(!n)return"";const a=GD[Number(n[2])-1];return a?[String(Number(n[3])),a,Number(n[1])!==t.getFullYear()?n[1]:""].filter(Boolean).join(" "):""}const XD={show:{label:"Full show",Icon:yD},midform:{label:"Midform",Icon:uj},short:{label:"Short",Icon:vD},test:{label:"Test / QA",Icon:wj}},JD=["show","midform","short","test"],$D={published:"border-emerald-600/25 bg-emerald-500/10 text-emerald-700 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-300",active:"border-accent-600/30 bg-accent-500/15 text-accent-800 dark:border-accent-500/30 dark:bg-accent-500/10 dark:text-accent-300"},QD="ds-tip inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-primary-400 transition-colors hover:bg-primary-50 hover:text-primary-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-500/70 dark:text-primary-200 dark:hover:bg-primary-700 dark:hover:text-brand-cloud",ZD="flex w-full items-center gap-2 px-3 py-1.5 text-left font-headlines text-xs text-primary-600 outline-none transition-colors hover:bg-primary-50 focus-visible:bg-primary-50 dark:text-brand-cloud dark:hover:bg-primary-700 dark:focus-visible:bg-primary-700",eC=e=>"/arrangement/".concat(encodeURIComponent(e));function tC(e){let{item:t,busy:n=!1,onDoneChange:a}=e;const r=!!t.done,s=function(e){var t,n;const a=e.doneReason||(null===(t=e.doneState)||void 0===t?void 0:t.reason)||"";return e.done?"Done".concat(a?": ".concat(a):"",". Reopen to render again"):"reopened"===(null===(n=e.doneState)||void 0===n?void 0:n.source)?"Reopened".concat(a?": ".concat(a.replace(/^reopened\s*/i,"")):"",". Mark done"):"Mark done: stop rendering".concat(a?" (".concat(a,")"):"")}(t);return(0,u.jsx)("button",{type:"button","data-testid":"arrangement-done-toggle","aria-pressed":r,"aria-label":"".concat(s," (").concat(t.title||"Untitled arrangement",")"),"data-tip":s,"data-tip-align":"end",disabled:n,onClick:()=>a(t,!r),className:"".concat(QD," ").concat(r?"bg-accent-500/15 text-accent-800 hover:bg-accent-500/25 hover:text-accent-800 dark:bg-accent-500/15 dark:text-accent-300 dark:hover:bg-accent-500/25 dark:hover:text-accent-300":"opacity-0 focus-visible:opacity-100 group-hover:opacity-100 [@media(hover:none)]:opacity-100"),children:(0,u.jsx)(ph,{className:"h-4 w-4","aria-hidden":"true"})})}function nC(e){let{item:t,onKindChange:n,onRequestPurge:r,onRequestDelete:s,onRequestMove:i}=e;const[o,l]=(0,a.useState)(!1),c=(0,a.useRef)(null),d=(0,a.useRef)(null),m=t.title||"Untitled arrangement",h=t.kind||"show",p=(0,a.useCallback)(function(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];l(!1),t&&(null===(e=c.current)||void 0===e||e.focus())},[]);(0,a.useEffect)(()=>
2{if(!o)return;const e=window.requestAnimationFrame(()=>{var e,t;null===(e=d.current)||void 0===e||null===(t=e.querySelector('[role^="menuitem"]'))||void 0===t||t.focus()});return()=>window.cancelAnimationFrame(e)},[o]);const g=e=>()=>{p(!0),e()};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{ref:c,type:"button","data-testid":"arrangement-card-menu","aria-label":"More actions for ".concat(m),"data-tip":"More actions","data-tip-align":"end","aria-haspopup":"menu","aria-expanded":o,onClick:()=>l(e=>!e),className:"".concat(QD," ").concat(o?"bg-primary-50 text-primary-600 dark:bg-primary-700 dark:text-brand-cloud":""),children:(0,u.jsx)(wD,{className:"h-4 w-4","aria-hidden":"true"})}),(0,u.jsx)(CD,{isOpen:o,onClose:()=>p(!1),anchorRef:c,align:"end",offset:6,children:(0,u.jsxs)("div",{ref:d,role:"menu","aria-label":"Actions for ".concat(m),"data-testid":"arrangement-card-menu-panel",onKeyDown:e=>{var t;const n=Array.from((null===(t=d.current)||void 0===t?void 0:t.querySelectorAll('[role^="menuitem"]'))||[]),a=n.indexOf(document.activeElement);if("ArrowDown"===e.key||"ArrowUp"===e.key){var r;e.preventDefault();null===(r=n[(a+("ArrowDown"===e.key?1:-1)+n.length)%n.length])||void 0===r||r.focus()}else if("Home"===e.key||"End"===e.key){var s;e.preventDefault(),null===(s=n["Home"===e.key?0:n.length-1])||void 0===s||s.focus()}else"Escape"===e.key?(e.preventDefault(),e.stopPropagation(),p(!0)):"Tab"===e.key&&p(!1)},className:"w-52 overflow-hidden rounded-xl border border-primary-100 bg-white py-1 shadow-brand dark:border-primary-500/50 dark:bg-primary-800",children:[(0,u.jsxs)("a",{role:"menuitem",href:eC(t.previewToken),target:"_blank",rel:"noopener noreferrer",onClick:()=>p(!1),className:ZD,children:[(0,u.jsx)(Ep,{className:"h-3.5 w-3.5 text-primary-400 dark:text-primary-200","aria-hidden":"true"}),"Open in new tab"]}),(0,u.jsxs)("a",{role:"menuitem",href:(x=t.previewToken,"/arrangement/".concat(encodeURIComponent(x),"/transcript/")),target:"_blank",rel:"noopener noreferrer",onClick:()=>p(!1),className:ZD,children:[(0,u.jsx)(gp,{className:"h-3.5 w-3.5 text-primary-400 dark:text-primary-200","aria-hidden":"true"}),"Transcript view"]}),t.notionUrl&&(0,u.jsxs)("a",{role:"menuitem",href:t.notionUrl,target:"_blank",rel:"noopener noreferrer",onClick:()=>p(!1),className:ZD,children:[(0,u.jsx)(kD,{className:"h-3.5 w-3.5 text-primary-400 dark:text-primary-200","aria-hidden":"true"}),"Open in Notion"]}),(0,u.jsx)("div",{role:"separator",className:"my-1 border-t border-primary-100 dark:border-primary-500/40"}),i&&(0,u.jsxs)("button",{type:"button",role:"menuitem",onClick:g(()=>i(t)),className:ZD,children:[(0,u.jsx)(xj,{className:"h-3.5 w-3.5 text-primary-400 dark:text-primary-200","aria-hidden":"true"}),"Move to project\u2026"]}),(0,u.jsx)("div",{role:"group","aria-label":"Kind",children:JD.map(e=>{const{label:a,Icon:r}=XD[e],s=e===h;return(0,u.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":s,onClick:g(()=>n(t,e)),className:ZD,children:[(0,u.jsx)(r,{className:"h-3.5 w-3.5 text-primary-400 dark:text-primary-200","aria-hidden":"true"}),(0,u.jsx)("span",{className:"flex-1",children:a}),s&&(0,u.jsx)(Wm,{className:"h-3.5 w-3.5 text-accent-700 dark:text-accent-400","aria-hidden":"true"})]},e)})}),(0,u.jsx)("div",{role:"separator",className:"my-1 border-t border-primary-100 dark:border-primary-500/40"}),(0,u.jsxs)("button",{type:"button",role:"menuitem",onClick:g(()=>r(t)),className:ZD,children:[(0,u.jsx)(jD,{className:"h-3.5 w-3.5 text-primary-400 dark:text-primary-200","aria-hidden":"true"}),"Delete cached files\u2026"]}),(0,u.jsxs)("button",{type:"button",role:"menuitem",onClick:g(()=>s(t)),className:"".concat(ZD," text-red-600 dark:text-red-400"),children:[(0,u.jsx)(kp,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Delete arrangement\u2026"]})]})})]});var x}const aC=e=>{var t,n,a,r;let{item:s,dateField:i="updated",busy:o=!1,onKindChange:l,onDoneChange:c,onRequestPurge:d,onRequestDelete:m,onRequestMove:h}=e;const p=s.title||"Untitled arrangement",g=s.kind||"show",{label:x,Icon:f}=XD[g]||XD.show,b=function(e,t){if(!e)return"";const n=FD(t||"");for(const a of String(e).split(/\r?\n/)){const e=a.trim();if(!e||SD.test(e))continue;let r=TD(e);if(r&&!ED.test(r)&&!AD.test(r)){if(n){const e=FD(r);if(e===n)continue;if(e.startsWith("".concat(n," "))&&r.length>(t||"").length){const e=r.slice((t||"").length).replace(/^[\s:\u2014\u2013\-|\xb7.]+/,"");FD(r.slice(0,(t||"").length))===n&&e&&(r=e)}}if(r)return r}}return""}(s.description,s.title),y=null!==(t=null!==(n=s.totalBytes)&&void 0!==n?n:s.storageBytes)&&void 0!==t?t:0,v=null!==(a=s.estimatedMonthlyTotalCostUsd)&&void 0!==a?a:s.estimatedMonthlyCostUsd,w=["Storage ".concat(_D(y)),void 0!==v?BD(v):null,"number"===typeof s.estimatedMonthlyDeliveryCostUsd&&s.estimatedMonthlyDeliveryCostUsd>0?"storage ".concat(BD(s.estimatedMonthlyCostUsd)," + CDN ").concat(BD(s.estimatedMonthlyDeliveryCostUsd)):null,"number"===typeof s.sharedSourceVideoBytes&&s.sharedSourceVideoBytes>0?"shared source ".concat(_D(s.sharedSourceVideoBytes)):null].filter(
2Boolean).join(" \xb7 "),k=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"updated";if("next"===t){const t=KD(e.nextUnpublishedDate);if(e.done)return{text:"Done",tip:e.doneReason||"Done"};if(!t&&e.publishStale)return{text:"Stale \xb7 was due ".concat(KD(e.publishStaleSince)),tip:"Missed more than 30 days ago and nothing else is scheduled"};if(!t)return{text:"Not scheduled",tip:"No unpublished date on the publication calendar"};if(e.publishOverdue)return{text:"Overdue \xb7 was due ".concat(t),tip:"Its publish date passed and it is not confirmed published",overdue:!0};const n=new Date,a="".concat(n.getFullYear(),"-").concat(String(n.getMonth()+1).padStart(2,"0"),"-").concat(String(n.getDate()).padStart(2,"0"));return{text:e.nextUnpublishedDate===a?"Publishes today":"Publishes ".concat(t),tip:"Next unpublished date on the publication calendar"}}if("shoot"===t){var n,a;const t=Jm((null===(n=e.project)||void 0===n?void 0:n.shootDate)||null);return t?{text:"Shot ".concat(t),tip:"Shoot date of ".concat((null===(a=e.project)||void 0===a?void 0:a.name)||"its project")}:{text:"No shoot date",tip:e.project?"".concat(e.project.name," has no shoot date"):"Not in a project"}}if("publish"===t){const t=KD(e.nextPublishDate);return t?{text:"Publishes ".concat(t),tip:"Next unpublished date on the publication calendar"}:{text:"Not scheduled",tip:"No upcoming date on the publication calendar"}}const r=ID("created"===t?e.createdAt:e.updatedAt);return r?{text:"created"===t?"Created ".concat(r):r,tip:"created"===t?"Created":"Last modified"}:null}(s,i);return(0,u.jsx)("li",{"data-testid":"arrangement-card","data-project-id":s.projectId||s.project_id||void 0,"data-arrangement-id":s.id,className:"group relative rounded-2xl border border-primary-100 bg-white/80 px-4 py-3 transition-colors hover:border-accent-500/50 hover:bg-white dark:border-primary-500/30 dark:bg-primary-800/40 dark:hover:border-accent-500/40 dark:hover:bg-primary-800/70 ".concat(o?"opacity-60":""),"aria-busy":o||void 0,children:(0,u.jsxs)("div",{className:"flex items-start gap-2",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsx)("h4",{className:"line-clamp-2 break-words font-headlines text-[15px] font-semibold leading-snug text-primary-600 dark:text-brand-cloud",children:(0,u.jsx)("a",{href:eC(s.previewToken),"data-card-link":!0,className:"outline-none after:absolute after:inset-0 after:rounded-2xl after:content-[''] focus-visible:after:ring-2 focus-visible:after:ring-accent-500/80",children:p})}),b&&(0,u.jsx)("p",{"data-testid":"arrangement-snippet",className:"mt-0.5 truncate font-body text-[13px] text-primary-400 dark:text-primary-200",children:b}),(0,u.jsxs)("div",{"data-testid":"arrangement-meta",className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-0.5 whitespace-nowrap font-headlines sm:flex-nowrap sm:overflow-hidden text-xs text-primary-400 dark:text-primary-200",children:[(0,u.jsxs)("span",{"data-testid":"arrangement-kind-tag",className:"inline-flex items-center gap-1 font-semibold uppercase tracking-[0.06em] text-[11px] text-primary-500 dark:text-primary-100",children:[(0,u.jsx)(f,{className:"h-3.5 w-3.5","aria-hidden":"true"}),x]}),ND(s.status)&&(0,u.jsx)("span",{"data-testid":"arrangement-status-badge",className:"rounded-full border px-1.5 py-px text-[10px] font-semibold uppercase tracking-[0.08em] ".concat($D[s.status]||"border-primary-200 bg-primary-50 text-primary-500 dark:border-primary-500/50 dark:bg-primary-700/60 dark:text-primary-100"),children:s.status}),(0,u.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,u.jsxs)("span",{className:"tabular-nums",children:[null!==(r=s.totalClips)&&void 0!==r?r:0," clip",1===s.totalClips?"":"s"]}),(0,u.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,u.jsx)("span",{className:"tabular-nums",children:MD(s.totalDurationSeconds)}),k&&(0,u.jsxs)("span",{"data-testid":"arrangement-date","data-date-field":i,className:"".concat("updated"===i?"hidden sm:inline-flex":"inline-flex"," items-center gap-2.5"),children:[(0,u.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),k.overdue?(0,u.jsx)("span",{"data-testid":"arrangement-overdue",className:"rounded-full border border-red-600/30 bg-red-500/10 px-1.5 py-px text-[10px] font-semibold uppercase tracking-[0.06em] text-red-700 dark:border-red-400/40 dark:bg-red-400/10 dark:text-red-300",children:k.text}):(0,u.jsx)("span",{children:k.text})]}),y>0&&(0,u.jsxs)("span",{className:"relative z-10 hidden items-center gap-2.5 sm:inline-flex",children:[(0,u.jsx)("span",{"aria-hidden":"true",children:"\xb7"}),(0,u.jsx)("span",{"data-testid":"arrangement-size",className:"ds-tip tabular-nums","data-tip":w,"data-tip-pos":"above",children:_D(y)})]})]})]}),(0,u.jsxs)("div",{className:"relative z-10 flex shrink-0 items-center gap-0.5",children:[c&&(0,u.jsx)(tC,{item:s,busy:o,onDoneChange:c}),(0,u.jsx)("a",{href:eC(s.previewToken),target:"_blank",rel:"noopener noreferrer","aria-label":"Open ".concat(p," in a
2new tab"),"data-tip":"Open in new tab","data-tip-align":"end",className:"".concat(QD," opacity-0 focus-visible:opacity-100 group-hover:opacity-100 [@media(hover:none)]:hidden"),children:(0,u.jsx)(Ep,{className:"h-4 w-4","aria-hidden":"true"})}),(0,u.jsx)(nC,{onRequestMove:h,item:s,onKindChange:l,onRequestPurge:d,onRequestDelete:m})]})]})})},rC=Mo("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),sC=Mo("scan-search",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"m16 16-1.9-1.9",key:"1dq9hf"}]]);function iC(e){let{token:t}=e;const[n,r]=(0,a.useState)(!1),[s,i]=(0,a.useState)(!1),[o,l]=(0,a.useState)(""),[c,m]=(0,a.useState)(null),[h,p]=(0,a.useState)("apply"),[g,x]=(0,a.useState)(""),[f,b]=(0,a.useState)(""),[y,v]=(0,a.useState)(""),[w,k]=(0,a.useState)(""),[j,D]=(0,a.useState)(null);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"start","aria-label":"Review project organisation","data-tip":"Review project organisation",onClick:()=>{(async()=>{r(!0),i(!0),l(""),m(null),k(""),D(null);try{const e=await Qm(t,"/projects/backfill","POST",{mode:"dry-run"});m(e.plan)}catch(BH){l(BH.message)}finally{i(!1)}})()},children:(0,u.jsx)(sC,{size:18})}),n&&(0,u.jsxs)(Nj,{title:"Project organisation preview",onClose:()=>r(!1),children:[s&&(0,u.jsx)("p",{role:"status",children:"Preparing proposal\u2026"}),o&&(0,u.jsx)("p",{role:"alert",className:"project-error",children:o}),c&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("p",{children:["No memberships changed. ",c.projects.length," projects; ",c.ambiguous.length," items need review."]}),(0,u.jsxs)("ol",{className:"project-history",children:[c.projects.map(e=>(0,u.jsxs)("li",{children:[e.name," \xb7 ",e.members.length," items"]},e.name)),c.ambiguous.map(e=>(0,u.jsxs)("li",{children:[(0,u.jsx)("strong",{children:e.title}),(0,u.jsx)("br",{}),e.reason]},e.id))]}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Download project proposal","data-tip":"Download proposal",onClick:()=>{const e=URL.createObjectURL(new Blob([JSON.stringify(c,null,2)],{type:"application/json"})),t=document.createElement("a");t.href=e,t.download="project-proposal.json",t.click(),window.setTimeout(()=>URL.revokeObjectURL(e),1e3)},children:(0,u.jsx)(Sp,{size:18})})]}),(0,u.jsxs)("details",{style:{marginTop:16},children:[(0,u.jsx)("summary",{children:"Apply or revert a reviewed plan"}),(0,u.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),w===h.toUpperCase()&&f.trim()){i(!0),l(""),D(null);try{const e="apply"===h?{plan:JSON.parse(g)}:{batchId:y.trim()},n=await Qm(t,"/projects/backfill","POST",d({mode:h,approval:f.trim()},e));D(JSON.stringify(n,null,2)),k(""),window.dispatchEvent(new Event("rescript-projects-changed"))}catch(BH){l(BH.message)}finally{i(!1)}}},style:{marginTop:12},children:[(0,u.jsxs)("select",{className:"project-input","aria-label":"Backfill operation",value:h,onChange:e=>{p(e.target.value),k("")},children:[(0,u.jsx)("option",{value:"apply",children:"Apply reviewed plan"}),(0,u.jsx)("option",{value:"revert",children:"Revert batch"})]}),"apply"===h?(0,u.jsx)("textarea",{className:"project-input","aria-label":"Reviewed project plan JSON",placeholder:"Paste the reviewed proposal JSON",required:!0,rows:5,value:g,onChange:e=>x(e.target.value)}):(0,u.jsx)("input",{className:"project-input","aria-label":"Backfill batch ID",required:!0,value:y,onChange:e=>v(e.target.value)}),(0,u.jsx)("input",{className:"project-input","aria-label":"Approval reference",placeholder:"Coordinator or Tim approval reference",required:!0,value:f,onChange:e=>b(e.target.value)}),(0,u.jsx)("input",{className:"project-input","aria-label":"Type ".concat(h.toUpperCase()," to confirm"),placeholder:"Type ".concat(h.toUpperCase()," to confirm"),value:w,onChange:e=>k(e.target.value)}),(0,u.jsx)("footer",{children:(0,u.jsx)("button",{type:"submit",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Confirm backfill ".concat(h),"data-tip":"Confirm ".concat(h),disabled:s||!f.trim()||w!==h.toUpperCase()||!("apply"===h?g.trim():y.trim()),children:(0,u.jsx)(Wm,{size:18})})})]}),j&&(0,u.jsx)("pre",{className:"project-history",role:"status",children:j})]})]})]})}const oC=Mo("calendar-off",[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function lC(e){let{token:t,excludeTest:n,sort:r,order:s,hideUndated:i=!1}=e;const o="next"===r,l="".concat(n,":").concat(o,":").concat(i),[c,m]=(0,a.useState)(()=>IC(t,"month",{excludeTest:n,nextToPublish:o,hideUndated:i})),[h,p]=(0,a.useState)(""),[g,x]=(0,a.useState)(0),[f,b]=(0,a.useState)(()=>new Set);(0,a.useEffect)(()=>{const e=()=>x(e=>e+1);return window.addEventListener("rescript-projects-changed",e),window.addEventListener(TC,e),()=>{window.removeEventListener("rescript-projects-changed",e),window.removeEventListener(TC,e)}},[]),(0,a.useEffect)(()=>
2{if(!t)return;const e={excludeTest:n,nextToPublish:o,hideUndated:i},a=IC(t,"month",e);a&&m(a);const r=new AbortController;return async function(e,t,n,a){const r=await Um(e,d(d({groupBy:t,kind:n.excludeTest?"show,midform,short":void 0},n.nextToPublish?{sort:"next",undated:n.hideUndated?"hide":void 0}:{}),{},{limit:1}),{signal:a});return SC.set(BC(e,t,n),{page:r,at:Date.now()}),r.groups||[]}(t,"month",e,r.signal).then(e=>{r.signal.aborted||(m(e),p(""))}).catch(e=>{r.signal.aborted||(e=>"AbortError"===(null===e||void 0===e?void 0:e.name))(e)||p(e instanceof Error?e.message:"Unknown error")}),()=>r.abort()},[t,l,g]);return h&&!c?(0,u.jsxs)("div",{role:"alert",className:"project-error project-picker-row",children:[(0,u.jsx)("span",{className:"min-w-0 flex-1",children:h}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Retry","data-tip":"Retry",onClick:()=>x(e=>e+1),children:(0,u.jsx)(vp,{size:16,"aria-hidden":"true"})})]}):c?c.length?(0,u.jsx)("div",{className:"space-y-3","data-testid":"arrangement-month-groups",children:c.map(e=>{const a=f.has(e.key),o="undated"===e.key,l=o?oC:Pj,c="month-members-".concat(e.key);return(0,u.jsxs)("section",{className:"project-group","data-testid":"arrangement-month-group","data-month":e.key,children:[(0,u.jsxs)("div",{className:"project-group-head",children:[(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"start","data-tip":"".concat(a?"Collapse":"Expand"," ").concat(e.label),"aria-label":"".concat(a?"Collapse":"Expand"," ").concat(e.label),"aria-expanded":a,"aria-controls":c,onClick:()=>{return t=e.key,b(e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});var t},children:a?(0,u.jsx)(wd,{size:16,"aria-hidden":"true"}):(0,u.jsx)(bp,{size:16,"aria-hidden":"true"})}),(0,u.jsx)(l,{size:18,"aria-hidden":"true",className:"project-month-glyph"}),(0,u.jsxs)("span",{className:"min-w-0 project-group-text",children:[(0,u.jsx)("span",{className:"project-group-name",children:e.label}),(0,u.jsxs)("span",{className:"project-group-meta block","data-testid":"arrangement-month-count",children:[(d=e.count,m="arrangement","".concat(d," ").concat(m).concat(1===d?"":"s")),e.lastUpdatedAt?" \xb7 modified ".concat(ID(e.lastUpdatedAt)):""]}),o&&(0,u.jsx)("span",{className:"project-group-meta block",children:"Projects without a shoot date, and arrangements without a project"})]})]}),a&&(0,u.jsx)("div",{id:c,className:"project-group-body",children:(0,u.jsx)(VC,{token:t,shootMonth:e.key,excludeTest:n,sort:r,order:s,hideUndated:i},String(n))})]},e.key);var d,m})}):(0,u.jsx)("p",{role:"status",className:"project-hidden-note",children:o?"Nothing left to publish":"No arrangements yet"}):(0,u.jsx)("p",{role:"status",className:"project-hidden-note",children:"Loading shoot months\u2026"})}const cC=Mo("rows-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]),dC=Mo("calendar-range",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]),uC=Mo("folders",[["path",{d:"M20 17a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3.9a2 2 0 0 1-1.69-.9l-.81-1.2a2 2 0 0 0-1.67-.9H8a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2Z",key:"4u7rpt"}],["path",{d:"M2 8v11a2 2 0 0 0 2 2h14",key:"1eicx1"}]]),mC=Mo("rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]),hC=[{value:"none",label:"One list, no grouping",Icon:cC},{value:"month",label:"Group by shoot month",Icon:dC},{value:"project",label:"Group by project",Icon:uC}],pC=[{value:"modified",label:"Last modified",Icon:Cj},{value:"next",label:"Next to publish",Icon:mC},{value:"shoot",label:"Shoot date",Icon:Bu},{value:"publish",label:"Next publication date",Icon:Lj},{value:"title",label:"Title",Icon:hD},{value:"created",label:"Created",Icon:mD},{value:"duration",label:"Duration",Icon:pD}],gC={modified:{desc:"newest first",asc:"oldest first"},next:{asc:"overdue first",desc:"latest first"},shoot:{desc:"newest shoot first",asc:"oldest shoot first"},publish:{asc:"soonest first",desc:"latest first"},title:{asc:"A to Z",desc:"Z to A"},created:{desc:"newest first",asc:"oldest first"},duration:{desc:"longest first",asc:"shortest first"}};function xC(e){let{value:t,onChange:n}=e;return(0,u.jsx)("div",{role:"group","aria-label":"Group arrangements",className:"project-segment","data-testid":"arrangement-group-control",children:hC.map(e=>{let{value:a,label:r,Icon:s}=e;return(0,u.jsx)("button",{type:"button",className:"project-icon project-toggle ds-tip","data-tip-align":"end","aria-pressed":t===a,"aria-label":r,"data-tip":r,"data-group":a,onClick:()=>n(a),children:(0,u.jsx)(s,{size:18,"aria-hidden":"true"})},a)})})}function fC(e){let{prefs:t,onChange:n}=e;const a="next"===t.sort,r="hide"===t.undated;return(0,u.jsxs)("div",{role:"group","aria-label":"Next to publish",className:"project-segment","data-testid":"arrangement-next-control",children:[(0,u.jsx)("button",{type:"button",className:"project-icon project-toggle ds-tip","data-tip-align":"end","data-testid":"toggle-next-to-publish","aria-pressed":a,"aria-label":"Next to publish: what is still to publish, overdue first","data-tip":a?"Next to publish (on): overdue first, then by date; published and done left out":"Next to publish: overdue first, then by date",onClick:()=>n(a?{sort:"modified",order:RD.modified}:{sort:"next",order:RD.next,group:"none"}),children:(0,u.jsx)(mC,{size:18,"aria-hidden":"true"})}),a&&(0,u.jsx)("button",{type:"button",className:"project-icon project-toggle ds-tip","data-tip-align":"end","data-testid":"toggle-hide-unscheduled","aria-pressed":r,"aria-label":"Hide arrangements with no publish date","data-tip":r?"Unscheduled hidden \xb7 show them":"Hide arrangements with no publish date",onClick:()=>n({undated:r?"show":"hide"}),children:(0,u.jsx)(oC,{size:18,"aria-hidden":"true"})})]})}function bC(e){let{prefs:t,onChange:n}=e;const[r,s]=(0,a.useState)(!1),i=(0,a.useRef)(null),o=(0,a.useRef)(null),l=pC.find(e=>e.value===t.sort)||pC[0],c=l.Icon,d=((e,t)=>gC[e][t])(t.sort,t.order),m=(0,a.useCallback)(e=>{var t;s(!1),e&&(null===(t=i.current)||void 0===t||t.focus())},[]);(0,a.useEffect)(()=>
2{if(!r)return;const e=window.requestAnimationFrame(()=>{var e,t,n;null===(e=(null===(t=o.current)||void 0===t?void 0:t.querySelector('[aria-checked="true"]'))||(null===(n=o.current)||void 0===n?void 0:n.querySelector('[role="menuitemradio"]')))||void 0===e||e.focus()});return()=>window.cancelAnimationFrame(e)},[r]);return(0,u.jsxs)("div",{role:"group","aria-label":"Sort arrangements",className:"project-segment","data-testid":"arrangement-sort-control",children:[(0,u.jsx)("button",{ref:i,type:"button",className:"project-icon project-toggle ds-tip","data-tip-align":"end","data-testid":"arrangement-sort-menu","aria-haspopup":"menu","aria-expanded":r,"aria-label":"Sort by ".concat(l.label.toLowerCase()," (").concat(d,"). Change sort"),"data-tip":"Sort: ".concat(l.label),"data-sort":t.sort,onClick:()=>s(e=>!e),children:(0,u.jsx)(c,{size:18,"aria-hidden":"true"})}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","data-testid":"arrangement-sort-order","aria-label":"Sort direction: ".concat(d,". Reverse"),"data-tip":"".concat(d.charAt(0).toUpperCase()).concat(d.slice(1)," \xb7 reverse"),"data-order":t.order,onClick:()=>n({sort:t.sort,order:"desc"===t.order?"asc":"desc"}),children:t.order===RD[t.sort]?(0,u.jsx)(xD,{size:18,"aria-hidden":"true"}):(0,u.jsx)(fD,{size:18,"aria-hidden":"true"})}),(0,u.jsx)(CD,{isOpen:r,onClose:()=>m(!1),anchorRef:i,align:"end",offset:6,children:(0,u.jsx)("div",{ref:o,role:"menu","aria-label":"Sort arrangements by","data-testid":"arrangement-sort-menu-panel",onKeyDown:e=>{var t;const n=Array.from((null===(t=o.current)||void 0===t?void 0:t.querySelectorAll('[role="menuitemradio"]'))||[]),a=n.indexOf(document.activeElement);var r;if("ArrowDown"===e.key||"ArrowUp"===e.key)e.preventDefault(),null===(r=n[(a+("ArrowDown"===e.key?1:-1)+n.length)%n.length])||void 0===r||r.focus();else if("Home"===e.key||"End"===e.key){var s;e.preventDefault(),null===(s=n["Home"===e.key?0:n.length-1])||void 0===s||s.focus()}else"Escape"===e.key?(e.preventDefault(),e.stopPropagation(),m(!0)):"Tab"===e.key&&m(!1)},className:"w-72 max-w-[calc(100vw-24px)] overflow-hidden rounded-xl border border-primary-100 bg-white py-1 shadow-brand dark:border-primary-500/50 dark:bg-primary-800",children:pC.map(e=>{let{value:a,label:r,Icon:s}=e;const i=a===t.sort;return(0,u.jsxs)("button",{type:"button",role:"menuitemradio","aria-checked":i,"data-sort":a,onClick:()=>{m(!0),n({sort:a,order:RD[a]})},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left font-headlines text-xs text-primary-600 outline-none transition-colors hover:bg-primary-50 focus-visible:bg-primary-50 dark:text-brand-cloud dark:hover:bg-primary-700 dark:focus-visible:bg-primary-700",children:[(0,u.jsx)(s,{size:14,className:"shrink-0 text-primary-400 dark:text-primary-200","aria-hidden":"true"}),(0,u.jsx)("span",{className:"flex-1 whitespace-nowrap",children:r}),(0,u.jsx)("span",{className:"whitespace-nowrap text-[11px] text-primary-300 dark:text-primary-300",children:gC[a][RD[a]]}),(0,u.jsx)(Wm,{size:14,className:"shrink-0 ".concat(i?"text-accent-700 dark:text-accent-400":"invisible"),"aria-hidden":"true"})]},a)})})})]})}const yC="testing";function vC(e){let{projects:t,showTests:n,onOpen:a,onKeyDown:r,listRef:s}=e;return t.length?(0,u.jsxs)("section",{"aria-label":"Matching projects","data-testid":"project-search-results",className:"project-results",children:[(0,u.jsx)("h3",{className:"project-results-heading",children:"Projects"}),(0,u.jsx)("ul",{ref:s,className:"project-results-list",onKeyDown:r,children:t.map(e=>{var t;const r=Jm(Ym(e)),s=n||e.slug===yC?0:(null===(t=e.kindRollup)||void 0===t?void 0:t.test)||0,i=Math.max(0,(e.arrangementCount||0)-s);return(0,u.jsx)("li",{children:(0,u.jsxs)("a",{href:"?view=arrangements&project=".concat(encodeURIComponent(e.slug)),"data-search-result":!0,"data-testid":"project-search-result",className:"project-result","aria-label":"Open project ".concat(e.name),onClick:t=>{t.metaKey||t.ctrlKey||t.shiftKey||0!==t.button||(t.preventDefault(),a(e))},children:[(0,u.jsx)(Fj,{project:e}),(0,u.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,u.jsx)("span",{className:"project-group-name block truncate",children:e.name}),(0,u.jsxs)("span",{className:"project-group-meta block",children:[r&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{className:"project-result-shot",children:[(0,u.jsx)(Pj,{size:12,"aria-hidden":"true"}),"Shot ",r]})," \xb7 "]}),(o=i,l="arrangement","".concat(o," ").concat(l).concat(1===o?"":"s")),"archived"===e.status?" \xb7 archived":""]})]}),(0,u.jsx)(bp,{size:16,"aria-hidden":"true",className:"project-result-chevron"})]})},e.id);var o,l})}),(0,u.jsx)("h3",{className:"project-results-heading",children:"Arrangements"})]}):null}const wC=(e,t)=>"".concat(e," ").concat(t).concat(1===e?"":"s"),kC="testing";const jC=24,DC={search:"",status:"",kind:"",sort:"updated",order:"desc",page:0},CC=[{value:"",label:"All kinds",Icon:dD},...["show","midform","short","test"].map(e=>({value:e,label:XD[e].label,Icon:XD[e].Icon}))],NC=[{value:"",label:"All statuses",Icon:ck},{value:"draft",label:"Draft",Icon:uD},{value:"active",label:"Active",Icon:yp},{value:"published",label:"Published",Icon:bj},{value:"archived",label:"Archived",Icon:pj}],FC=[{value:"updated",label:"Last updated",Icon:Cj},{value:"created",label:"Created",Icon:mD},{value:"title",label:"Title",Icon:hD},{value:"duration",label:"Duration",Icon:pD}],SC=new Map;let EC=null;const AC=(e,t)=>JSON.stringify([e,t.search.trim().toLowerCase(),t.status,t.kind,t.sort,t.order,t.page,t.project||null,!!t.excludeTest,t.shootMonth||null,"next"===t.sort&&!!t.hideUndated]),TC="rescript-arrangements-changed";function MC(){SC.clear(),EC=null;try{window.dispatchEvent(new Event(TC))}catch(_H){}}async function _C(e,t,n){const a=await Um(e,(e=>({project:e.project||void 0,shootMonth:e.shootMonth||void 0,undated:"next"===e.sort&&e.hideUndated?"hide":void 0,search:e.search.trim()||void 0,status:e.status||void 0,kind:e.kind||(e.excludeTest?"show,midform,short":void 0),sort:e.sort,order:e.order,limit:jC,offset:e.page*jC}))(t),{signal:n});return SC.set(AC(e,t),{page:a,at:Date.now()}),a}const BC=(e,t,n)=>JSON.stringify(["groups",e,t,n.excludeTest,!!n.nextToPublish,!!n.nextToPublish&&!!n.hideUndated]);function IC(e,t,n){var a;return e&&(null===(a=SC.get(BC(e,t,n)))||void 0===a?void 0:a.page.groups)||null}const PC=e=>{const t=window.requestIdleCallback;"function"===typeof t?t(e,{timeout:1500}):window.setTimeout(e,400)};const LC="ds-tip inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-500/70 disabled:cursor-not-allowed disabled:opacity-40",RC="text-primary-400 hover:bg-primary-50 hover:text-primary-600 dark:text-primary-200 dark:hover:bg-primary-700 dark:hover:text-brand-cloud",zC="inline-flex items-center gap-0.5 rounded-xl border border-primary-100 bg-white/70 p-0.5 dark:border-primary-500/40 dark:bg-primary-800/50";function OC(e){let{label:t,value:n,options:a,onChange:r,testId:s,bare:i=!1}=e;return(0,u.jsx)("div",{role:"group","aria-label":t,className:i?"inline-flex items-center gap-0.5":zC,"data-testid":s,children:a.map((e,a)=>{let{value:s,label:i,Icon:o}=e;const l=n===s,c="".concat(t,": ").concat(i);return(0,u.jsx)("button",{type:"button","aria-pressed":l,"aria-label":c,"data-tip":c,"data-tip-align":0===a?"start":void 0,onClick:()=>r(s),className:"".concat(LC," ").concat(l?"bg-accent-500 text-primary-600 shadow-sm":RC),children:(0,u.jsx)(o,{className:"h-4 w-4","aria-hidden":"true"})},s||"all")})})}function UC(){return(0,u.jsx)("li",{"aria-hidden":"true","data-testid":"arrangement-skeleton",className:"rounded-2xl border border-primary-100 bg-white/70 px-4 py-3.5 dar
2k:border-primary-500/30 dark:bg-primary-800/40",children:(0,u.jsxs)("div",{className:"flex items-start gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1 space-y-2.5",children:[(0,u.jsx)("div",{className:"arr-skeleton-bar h-4 w-3/5"}),(0,u.jsx)("div",{className:"arr-skeleton-bar h-3 w-11/12"}),(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("div",{className:"arr-skeleton-bar h-3 w-16"}),(0,u.jsx)("div",{className:"arr-skeleton-bar h-3 w-12"}),(0,u.jsx)("div",{className:"arr-skeleton-bar h-3 w-14"}),(0,u.jsx)("div",{className:"arr-skeleton-bar h-3 w-12"})]})]}),(0,u.jsx)("div",{className:"arr-skeleton-bar h-8 w-8 rounded-lg"})]})})}const VC=e=>{var t,n,r;let{token:s,projectId:i="",shootMonth:o="",initialSearch:l="",hideSearch:c=!1,excludeTest:m=!1,sort:h,order:p,hideUndated:g=!1,onFocusAbove:x}=e;const f=void 0!==h,b=d(d({},DC),{},{project:i,shootMonth:o||void 0,search:l,excludeTest:m,hideUndated:g},f?{sort:h,order:p||("publish"===h||"title"===h?"asc":"desc")}:{}),[y,v]=(0,a.useState)(b),[w,k]=(0,a.useState)(l),[j,D]=(0,a.useState)(null),[C,N]=(0,a.useState)(""),[F,S]=(0,a.useState)(!1),[E,A]=(0,a.useState)(""),[T,M]=(0,a.useState)(()=>{if(!s)return null;const e=SC.get(AC(s,b));return e?{items:e.page.arrangements,total:e.page.total}:null}),[_,B]=(0,a.useState)(!1),[I,P]=(0,a.useState)(null),[L,R]=(0,a.useState)(0),[z,O]=(0,a.useState)(()=>{var e;return(null===(e=EC)||void 0===e?void 0:e.byId)||new Map}),[U,V]=(0,a.useState)(null),[H,q]=(0,a.useState)(null),[W,Y]=(0,a.useState)(!1),G=(0,a.useRef)(null),K=(0,a.useRef)(null),X=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(w.trim()===y.search.trim())return;const e=window.setTimeout(()=>v(e=>d(d({},e),{},{search:w,page:0})),120);return()=>window.clearTimeout(e)},[w,y.search]);const J=(0,a.useCallback)(e=>{v(t=>d(d({},t),{},{page:0},e))},[]);(0,a.useEffect)(()=>{f&&v(e=>e.sort===h&&e.order===(p||e.order)&&!!e.hideUndated===g?e:d(d({},e),{},{sort:h,order:p||e.order,hideUndated:g,page:0}))},[f,h,p,g]),(0,a.useEffect)(()=>{if(!s)return;const e=SC.get(AC(s,y));e&&(M({items:e.page.arrangements,total:e.page.total}),P(null));const t=new AbortController;return B(!e),_C(s,y,t.signal).then(e=>{t.signal.aborted||(y.page>0&&e.total>0&&y.page*jC>=e.total?v(t=>d(d({},t),{},{page:Math.max(0,Math.ceil(e.total/jC)-1)})):(M({items:e.arrangements,total:e.total}),P(null),B(!1)))}).catch(e=>{t.signal.aborted||(e=>e instanceof DOMException?"AbortError"===e.name:"AbortError"===(null===e||void 0===e?void 0:e.name))(e)||(P(e instanceof Error?e.message:"Unknown error"),B(!1))}),()=>t.abort()},[s,y,L]),(0,a.useEffect)(()=>{if(!s||!T||EC&&EC.token===s)return;let e=!1;return PC(()=>{(async function(e){const t={"Content-Type":"application/json"};e&&(t.Authorization="Bearer ".concat(e));const n=await fetch("".concat(Im,"/arrangements/storage/summary"),{headers:t});if(!n.ok){const e=await n.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(n.status))}return n.json()})(s).then(t=>{const n=new Map(((null===t||void 0===t?void 0:t.arrangements)||[]).map(e=>[e.id,e]));EC={token:s,byId:n},e||O(n)}).catch(e=>console.error("Failed to load arrangement storage summary:",e))}),()=>{e=!0}},[s,T]),(0,a.useEffect)(()=>{if(!s||!T||i||o||X.current)return;X.current=!0;const{sort:e,order:t,excludeTest:n}=y;PC(()=>{["show","midform","short","test"].forEach(a=>{const r=d(d({},DC),{},{project:"",excludeTest:n,sort:e,order:t,kind:a});SC.has(AC(s,r))||_C(s,r).catch(()=>{})})})},[s,T]),(0,a.useEffect)(()=>{const e=e=>{var t,n;if("/"!==e.key||e.metaKey||e.ctrlKey||e.altKey)return;const a=e.target;a&&(a.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(a.tagName))||document.querySelector('[role="dialog"], [role="menu"]')||(e.preventDefault(),null===(t=G.current)||void 0===t||t.focus(),null===(n=G.current)||void 0===n||n.select())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);const $=(0,a.useCallback)(()=>{var e;return Array.from((null===(e=K.current)||void 0===e?void 0:e.querySelectorAll("a[data-card-link]"))||[])},[]),Q=(0,a.useCallback)(e=>{var t;const n=$(),a=n.indexOf(document.activeElement);if(a<0)return;let r=null;"ArrowDown"===e.key?r=Math.min(n.length-1,a+1):"ArrowUp"===e.key?r=a-1:"Home"===e.key?r=0:"End"===e.key&&(r=n.length-1),null!==r&&(e.preventDefault(),r<0?G.current?G.current.focus():null===x||void 0===x||x():null===(t=n[r])||void 0===t||t.focus())},[$,x]),Z=(0,a.useCallback)(e=>
2{if("ArrowDown"===e.key){const t=$()[0];t&&(e.preventDefault(),t.focus())}else if("Escape"===e.key){var t;w?k(""):null===(t=G.current)||void 0===t||t.blur()}},[$,w]),ee=!!(y.search.trim()||w.trim()||y.status||y.kind),te=(0,a.useCallback)(()=>{k(""),v(e=>d(d({},e),{},{search:"",status:"",kind:"",page:0}))},[]),ne=!!s&&SC.has(AC(s,y)),ae=(0,a.useMemo)(()=>{const e=(null===T||void 0===T?void 0:T.items)||[];let t=e;if(_&&!ne){const n=e.filter(e=>function(e,t){if(t.status&&e.status!==t.status)return!1;if(t.kind&&!t.kind.split(",").includes(e.kind||"show"))return!1;if(!t.kind&&t.excludeTest&&"test"===e.kind)return!1;const n=t.search.trim().toLowerCase();return!(n&&![e.title,e.description].some(e=>String(e||"").toLowerCase().includes(n)))}(e,d(d({},y),{},{search:w||y.search})));n.length&&(t=n)}return t.map(e=>{const t=z.get(e.id);return t?d(d({},e),{},{totalBytes:t.totalBytes,sharedSourceVideoBytes:t.sharedSourceVideoBytes,estimatedMonthlyCostUsd:t.estimatedMonthlyCostUsd,estimatedMonthlyDeliveryCostUsd:t.estimatedMonthlyDeliveryCostUsd,estimatedMonthlyTotalCostUsd:t.estimatedMonthlyTotalCostUsd}):e})},[T,_,ne,y,w,z]),re=(0,a.useCallback)(async(e,t)=>{if(s&&t!==(e.kind||"show")){V(e.id);try{await async function(e,t,n){const a={"Content-Type":"application/json"};n&&(a.Authorization="Bearer ".concat(n));const r=await fetch("".concat(Im,"/arrangements/").concat(encodeURIComponent(e)),{method:"PUT",headers:a,body:JSON.stringify({kind:t})});if(!r.ok){const e=await r.json().catch(()=>({error:"Network error"}));throw new Error(e.message||e.error||"HTTP ".concat(r.status))}return r.json()}(e.id,t,s),MC(),M(n=>n&&d(d({},n),{},{items:n.items.map(n=>n.id===e.id?d(d({},n),{},{kind:t}):n)})),y.kind&&!y.kind.split(",").includes(t)&&R(e=>e+1)}catch(n){P("Kind could not be saved: ".concat(n instanceof Error?n.message:"Unknown error"))}finally{V(null)}}},[s,y.kind]),se=(0,a.useCallback)(async(e,t)=>{if(s){V(e.id);try{const n=await async function(e,t,n){const a={"Content-Type":"application/json"};n&&(a.Authorization="Bearer ".concat(n));const r=await fetch("".concat(Im,"/arrangements/").concat(encodeURIComponent(e)),{method:"PUT",headers:a,body:JSON.stringify({done:t})});if(!r.ok){const e=await r.json().catch(()=>({error:"Network error"}));throw new Error(e.message||e.error||"HTTP ".concat(r.status))}return r.json()}(e.id,t,s);MC(),M(t=>t&&d(d({},t),{},{items:t.items.map(t=>{var a,r;return t.id===e.id?d(d({},t),{},{done:!!n.done,doneReason:null!==(a=n.doneReason)&&void 0!==a?a:null,doneState:null!==(r=n.doneState)&&void 0!==r?r:null}):t})}))}catch(n){P("Done state could not be saved: ".concat(n instanceof Error?n.message:"Unknown error"))}finally{V(null)}}},[s]),ie=(0,a.useCallback)(async()=>{if(s&&H){Y(!0);try{"cache"===H.mode?await async function(e,t){const n={"Content-Type":"application/json"};t&&(n.Authorization="Bearer ".concat(t));const a=await fetch("".concat(Im,"/arrangements/").concat(e,"/cache-purge"),{method:"POST",headers:n});if(!a.ok){const e=await a.json().catch(()=>({error:"Network error"}));throw new Error(e.message||e.error||"HTTP ".concat(a.status))}return a.json()}(H.item.id,s):await async function(e,t,n){const a={"Content-Type":"application/json"};n&&(a.Authorization="Bearer ".concat(n));const r=await fetch("".concat(Im,"/arrangements/").concat(e),{method:"DELETE",headers:a,body:JSON.stringify({confirmation:t})});if(!r.ok){const e=await r.json().catch(()=>({error:"Network error"}));throw new Error(e.message||e.error||"HTTP ".concat(r.status))}return r.json()}(H.item.id,H.item.title||H.item.id,s),MC(),O(new Map),q(null),R(e=>e+1)}catch(e){P(e instanceof Error?e.message:"The arrangement could not be changed")}finally{Y(!1)}}},[s,H]),oe=null!==(t=null===T||void 0===T?void 0:T.total)&&void 0!==t?t:0,le=Math.max(1,Math.ceil(oe/jC)),ce=0===oe?0:y.page*jC+1,de=Math.min((y.page+1)*jC,oe),ue=!T&&!I,me=H?"".concat(_D(null!==(n=H.item.totalBytes)&&void 0!==n?n:H.item.storageBytes)," \xb7 ").concat(BD(null!==(r=H.item.estimatedMonthlyTotalCostUsd)&&void 0!==r?r:H.item.estimatedMonthlyCostUsd)):"";return(0,u.jsxs)("div",{"data-testid":"arrangement-discovery",className:"space-y-3",children:[(0,u.jsxs)("div",{"data-testid":"arrangement-toolbar",className:"space-y-2.5",children:[!c&&(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(Mu,{className:"pointer-events-none absolute left-3.5 to
2p-1/2 h-4 w-4 -translate-y-1/2 text-primary-300 dark:text-primary-200","aria-hidden":"true"}),(0,u.jsx)("input",{ref:G,type:"search","aria-label":"Search arrangements","aria-keyshortcuts":"/",placeholder:"Search",value:w,onChange:e=>k(e.target.value),onKeyDown:Z,className:"h-10 w-full appearance-none rounded-xl border border-primary-100 bg-white/80 pl-10 pr-10 font-headlines text-sm text-primary-600 placeholder:text-primary-300 transition-colors focus:border-accent-500/70 focus:outline-none focus:ring-2 focus:ring-accent-500/25 dark:border-primary-500/40 dark:bg-primary-800/50 dark:text-brand-cloud dark:placeholder:text-primary-300 [&::-webkit-search-cancel-button]:hidden"}),w&&(0,u.jsx)("button",{type:"button","aria-label":"Clear search","data-tip":"Clear search","data-tip-align":"end",onClick:()=>{var e;k(""),null===(e=G.current)||void 0===e||e.focus()},className:"".concat(LC," ").concat(RC," absolute right-1 top-1"),children:(0,u.jsx)(Pu,{className:"h-4 w-4","aria-hidden":"true"})})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsx)(OC,{label:"Kind",testId:"arrangement-kind-filter",value:y.kind,options:CC,onChange:e=>J({kind:e})}),(0,u.jsx)(OC,{label:"Status",testId:"arrangement-status-filter",value:y.status,options:NC,onChange:e=>J({status:e})}),(0,u.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[ee&&(0,u.jsx)("button",{type:"button","aria-label":"Clear search and filters","data-tip":"Clear search and filters",onClick:te,className:"".concat(LC," ").concat(RC),children:(0,u.jsx)(gD,{className:"h-4 w-4","aria-hidden":"true"})}),!f&&(0,u.jsxs)("div",{className:zC,children:[(0,u.jsx)(OC,{bare:!0,label:"Sort",testId:"arrangement-sort-field",value:y.sort,options:FC,onChange:e=>J({sort:e})}),(0,u.jsx)("button",{type:"button","data-testid":"arrangement-sort-direction","aria-label":"Sort direction: ".concat("desc"===y.order?"descending":"ascending"),"data-tip":"desc"===y.order?"Descending":"Ascending","data-tip-align":"end",onClick:()=>J({order:"desc"===y.order?"asc":"desc"}),className:"".concat(LC," ").concat(RC),children:"desc"===y.order?(0,u.jsx)(xD,{className:"h-4 w-4","aria-hidden":"true"}):(0,u.jsx)(fD,{className:"h-4 w-4","aria-hidden":"true"})})]})]})]})]}),(0,u.jsx)("div",{className:"arr-loading-bar ".concat(_&&T?"bg-accent-500/20":"invisible"),role:"progressbar","aria-label":"Loading arrangements","aria-hidden":!(_&&T)}),I&&(0,u.jsxs)("div",{role:"alert",className:"flex items-center gap-3 rounded-xl border border-red-200 bg-red-50/80 px-3 py-2 font-headlines text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/30 dark:text-red-300",children:[(0,u.jsx)(Lu,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),(0,u.jsx)("span",{className:"min-w-0 flex-1 truncate",children:I}),(0,u.jsx)("button",{type:"button","aria-label":"Retry","data-tip":"Retry","data-tip-align":"end",onClick:()=>R(e=>e+1),className:"".concat(LC," text-red-700 hover:bg-red-100 dark:text-red-300 dark:hover:bg-red-900/30"),children:(0,u.jsx)(vp,{className:"h-4 w-4","aria-hidden":"true"})})]}),ue&&(0,u.jsx)("ul",{className:"space-y-2","aria-busy":"true","aria-label":"Loading arrangements",children:Array.from({length:6},(e,t)=>(0,u.jsx)(UC,{},t))}),T&&0===ae.length&&!_&&(0,u.jsxs)("div",{role:"status",className:"flex flex-col items-center gap-3 rounded-2xl border border-dashed border-primary-100 px-6 py-10 text-center dark:border-primary-500/40",children:[(0,u.jsx)(bD,{className:"h-8 w-8 text-primary-300 dark:text-primary-300","aria-hidden":"true"}),(0,u.jsx)("p",{className:"font-headlines text-sm font-semibold text-primary-500 dark:text-primary-100",children:ee?"No matching arrangements":"No arrangements yet"}),ee&&(0,u.jsx)("button",{type:"button","aria-label":"Clear search and filters","data-tip":"Clear search and filters",onClick:te,className:"".concat(LC," ").concat(RC),children:(0,u.jsx)(gD,{className:"h-4 w-4","aria-hidden":"true"})})]}),T&&ae.length>0&&(0,u.jsx)("ul",{ref:K,"data-testid":"arrangement-list","aria-label":"Arrangements","aria-busy":_,onKeyDown:Q,className:"space-y-2 transition-opacity duration-150 ".concat(_?"opacity-60":"opacity-100"),children:ae.map(e=>(0,u.jsx)(aC,{item:e,dateField:"shoot"===y.sort||"publish"===y.sort||"created"===y.sort||"next"===y.sort?y.sort:"updated",busy:U===e.id,onKindChange:re,onDoneChange:se,onRequestPurge:e=>q({item:e,mode:"cache"}),onRequestDelete:e=>q({item:e,mode:"delete"}),onRequestMove:e=>{A(""),D(e),N(e.projectId||e.project_id||"")}},e.id))}),T&&oe>0&&(0,u.jsxs)("nav",{"aria-label":"Arrangement pages",className:"flex items-center justify-between gap-3 pt-1 transition-opacity duration-150 ".concat(_?"opacity-60":"opacity-100"),children:[(0,u.jsxs)("span",{"aria-live":"polite",className:"font-headlines text-xs tabular-nums text-primary-400 dark:text-primary-200",children:[ce,"\u2013",de," of ",oe]}),(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsx)("button",{type:"button","aria-label":"Previous page","data-tip":"Previous page","data-tip-pos":"above",disabled:0===y.page,onClick:()=>v(e=>d(d({},e),{},{page:Math.max(0,e.page-1)})),className:"".concat(LC," ").concat(RC),children:(0,u.jsx)(dk,{className:"h-4 w-4","aria-hidden":"true"})}),(0,u.jsxs)("span",{className:"min-w-[3.5rem] text-center font-headlines text-xs tabular-nums text-primary-400 dark:text-primary-200",children:[y.page+1," / ",le]}),(0,u.jsx)("button",{type:"button","aria-label":"Next page","data-tip":"Next page","data-tip-pos":"above","data-tip-align":"end",disabled:y.page+1>=le,onClick:()=>v(e=>d(d({},e),{},{page:e.page+1})),className:"".concat(LC," ").concat(RC),children:(0,u.jsx)(bp,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),j&&(0,u.jsx)(Nj,{title:"Move ".concat(j.title),onClose:()=>!F&&D(null),children:(0,u.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),C&&s){S(!0);try{await eh(s,C,{arrangementIds:[j.id]}),MC(),th(),D(null),R(e=>e+1)}catch(t){A(t.message)}finally{S(!1)}}},children:[(0,u.jsx)(ih,{token:s,value:C,onChange:N,required:!0,label:"Destination project"}),E&&(0,u.jsx)("p",{role:"alert",className:"project-error",children:E}),(0,u.jsx)("footer",{children:(0,u.jsx)("button",{type:"submit",className:"project-icon ds-tip","aria-label":"Move arrangement","data-tip":"Move arrangement",disabled:F||!C,children:(0,u.jsx)(Wm,{size:18})})})]})}),(0,u.jsx)(vj,{isOpen:"cache"===(null===H||void 0===H?void 0:H.mode),onClose:()=>q(null),onConfirm:ie,title:"Delete cached files",message:(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{children:"Removes generated clip media, composite renders, the show MP3 and the local source cache. The arrangement, its revisions and uploaded visuals stay."}),(0,u.jsx)("div",{className:"text-sm text-primary-400 dark:text-primary-200",children:me})]}),confirmText:"Delete cached files",confirmButtonClassName:"bg-accent-600 text-primary-700 hover:bg-accent-500",isLoading:W}),(0,u.jsx)(vj,{isOpen:"delete"===(null===H||void 0===H?void 0:H.mode),onClose:()=>q(null),onConfirm:ie,title:"Delete arrangement",message:(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{children:"Permanently removes the arrangement, its generated media and any source-video cache only it uses."}),(0,u.jsx)("div",{className:"text-sm text-primary-400 dark:text-primary-200",children:me})]}),confirmText:"Delete arrangement",isLoading:W,confirmationValue:(null===H||void 0===H?void 0:H.item.title)||(null===H||void 0===H?void 0:H.item.id),confirmationLabel:"Type the arrangement title to confirm"})]})},HC=function(e){var t;let{token:n}=e;const[r,s]=(0,a.useState)(""),[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(()=>WD()),m=e=>c(t=>{const n=d(d({},t),e);return"next"===n.sort&&"project"===n.group&&("project"===e.group?(n.sort="modified",n.order="desc"):n.group="none"),function(e){try{window.localStorage.setItem(OD,JSON.stringify(e))}catch(t){}}(n),n});(0,a.useEffect)(()=>{!function(e){try{const t=new URL(window.location.href);t.searchParams.set("group",e.group),t.searchParams.set("sort",e.sort),e.order!==RD[e.sort]?t.searchParams.set("order",e.order):t.searchParams.delete("order"),"next"===e.sort&&"hide"===e.undated?t.searchParams.set("undated","hide"):t.searchParams.delete("undated"),t.href!==window.location.href&&window.history.replaceState(window.history.state,"",t.href)}catch(t){}}(l)},[l]),(0,a.useEffect)(()=>()=>function(){try{const e=new URL(window.location.href);
2VD.forEach(t=>e.searchParams.delete(t)),e.href!==window.location.href&&window.history.replaceState(window.history.state,"",e.href)}catch(e){}}(),[]);const h=HD(l.sort),p=l.order,g="next"===l.sort&&"hide"===l.undated,{projects:x,loading:f,error:b}=sh(n,i?"all":"active"),[y,v]=(0,a.useState)(()=>new Set),[w,k]=(0,a.useState)(""),[j,D]=(0,a.useState)(""),[C,N]=(0,a.useState)(!1),[F,S]=(0,a.useState)(""),[E,A]=(0,a.useState)(""),[T,M]=(0,a.useState)("show"),[_,B]=(0,a.useState)(""),[I,P]=(0,a.useState)(!1),[L,R]=(0,a.useState)(""),[z,O]=(0,a.useState)(YD),[U,V]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(!n)return;let e=!0;return Um(n,{kind:"test",limit:1}).then(t=>{e&&V(t.total)}).catch(()=>{e&&V(null)}),()=>{e=!1}},[n]);const H=z?"Hide test & QA arrangements":"Show test & QA arrangements".concat(U?" (".concat(U," hidden)"):"");(0,a.useEffect)(()=>{s(""),v(new Set),k("")},[n]);const[q,W]=(0,a.useState)(!1);(0,a.useEffect)(()=>{if(q||f)return;const e=new URLSearchParams(window.location.search).get("project"),t=e&&("unassigned"===e?{id:"unassigned"}:x.find(t=>t.slug===e||t.id===e));t&&s(t.id),W(!0)},[q,f,x]),(0,a.useEffect)(()=>{if(q)try{var e;const t=new URL(window.location.href),n="unassigned"===r?"unassigned":null===(e=x.find(e=>e.id===r))||void 0===e?void 0:e.slug;n?t.searchParams.set("project",n):t.searchParams.delete("project"),t.href!==window.location.href&&window.history.replaceState(window.history.state,"",t.href)}catch(_H){}},[r,q,x]);const Y=a.useMemo(()=>[...x].sort($m).filter(e=>z||e.slug!==kC||e.id===r),[x,z,r]);(0,a.useEffect)(()=>{const e=window.setTimeout(()=>D(w.trim()),120);return()=>window.clearTimeout(e)},[w]);const G=a.useMemo(()=>r?[]:function(e,t,n){let{showTests:a}=n;const r=t.trim().toLowerCase();return r?e.filter(e=>{if(!a&&e.slug===yC)return!1;const t=Ym(e);return[e.name,e.slug,e.description,Gm(e),t,Jm(t),...Km(e)].some(e=>String(e||"").toLowerCase().includes(r))}):[]}(x,j,{showTests:z}).sort($m),[x,j,z,r]),K=(0,a.useRef)(null),X=(0,a.useRef)(null),J=(0,a.useRef)(null),$=(0,a.useCallback)(()=>{var e,t;return[...Array.from((null===(e=X.current)||void 0===e?void 0:e.querySelectorAll("a[data-search-result]"))||[]),...Array.from((null===(t=J.current)||void 0===t?void 0:t.querySelectorAll("a[data-card-link]"))||[]).slice(0,1)]},[]),Q=(0,a.useCallback)(e=>{var t,n;if(e.defaultPrevented||"ArrowDown"!==e.key&&"ArrowUp"!==e.key)return;const a=$(),r=a.indexOf(document.activeElement);if(r<0)return;e.preventDefault();const s=r+("ArrowDown"===e.key?1:-1);s<0?null===(t=K.current)||void 0===t||t.focus():null===(n=a[Math.min(s,a.length-1)])||void 0===n||n.focus()},[$]),Z=(0,a.useCallback)(()=>{var e,t;const n=Array.from((null===(e=X.current)||void 0===e?void 0:e.querySelectorAll("a[data-search-result]"))||[]);null===(t=n[n.length-1]||K.current)||void 0===t||t.focus()},[]);return(0,u.jsxs)("div",{className:"space-y-3","data-testid":"arrangement-projects",children:[(0,u.jsxs)("div",{className:"project-tools",children:[(0,u.jsx)(iC,{token:n}),(0,u.jsx)(ih,{token:n,value:r,onChange:s,allowAll:!0,label:"Filter arrangements by project"}),(0,u.jsx)("button",{type:"button",className:"project-icon project-toggle ds-tip","data-tip-align":"end","data-testid":"toggle-test-arrangements","aria-label":"Show test & QA arrangements","aria-pressed":z,"data-tip":H,onClick:()=>O(e=>(function(e){try{window.localStorage.setItem(UD,e?"1":"0")}catch(t){}}(!e),!e)),children:(0,u.jsx)(wj,{size:18,"aria-hidden":"true"})}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Show archived projects","aria-pressed":i,"data-tip":"Include archived projects",onClick:()=>o(e=>!e),children:(0,u.jsx)(pj,{size:18})}),(0,u.jsxs)("div",{className:"project-view-tools","data-testid":"arrangement-view-tools",children:[(0,u.jsx)(xC,{value:l.group,onChange:e=>{m({group:e}),s("")}}),(0,u.jsx)(fC,{prefs:l,onChange:m}),(0,u.jsx)(bC,{prefs:l,onChange:m})]}),(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Create arrangement","data-tip":"Create arrangement",onClick:()=>{A(x.some(e=>e.id===r&&"active"===e.status)?r:""),S(""),B(""),N(!0)},children:(0,u.jsx)(ik,{size:18})})]}),(0,u.jsxs)("div",{className:"project-picker-row",children:[(0,u.jsx)(Mu,{size:18,"aria-hidden":"true"}),(0,u.jsx)("input",{ref:K,type:"search",className:"project-input","aria-label":"Search across projects",placeholder:r?"Search this project":"Search projects and arrangements",value:w,onChange:e=>k(e.target.value),onKeyDown:e=>{if("ArrowDown"===e.key){var t;const n=$()[0]||(null===(t=J.current)||void 0===t?void 0:t.querySelector("a[data-card-link]"));n&&(e.preventDefault(),n.focus())}else"Escape"===e.key&&w&&k("")}})]}),j&&(0,u.jsx)(vC,{projects:G,showTests:z,onOpen:e=>{var t;s(e.id),k(""),D(""),null===(t=K.current)||void 0===t||t.focus()},onKeyDown:Q,listRef:X}),(0,u.jsxs)("div",{ref:J,onKeyDown:Q,className:"space-y-3",children:[b&&(0,u.jsx)("p",{role:"alert",className:"project-error",children:b}),r||j||"none"===l.group||"project"===l.group&&!f&&!x.length?(0,u.jsx)(VC,{token:n,projectId:r,initialSearch:j,hideSearch:!0,sort:h,order:p,hideUndated:g,onFocusAbove:Z,excludeTest:!z&&(null===(t=x.find(e=>e.id===r))||void 0===t?void 0:t.slug)!==kC},"".concat(r,":").concat(j,":").concat(z)):"month"===l.group?(0,u.jsx)(lC,{token:n,excludeTest:!z,sort:h,order:p,hideUndated:g}):(0,u.jsxs)(u.Fragment,{children:[f&&!x.length&&(0,u.jsx)("p",{role:"status",children:"Loading projects\u2026"}),[...Y,{id:"unassigned",name:"Unassigned",slug:"unassigned",status:"active"}].map(e=>{var t;const a=Jm(Ym(e)),r=Gm(e),s=Km(e),i=z||e.slug===kC?0:(null===(t=e.kindRollup)||void 0===t?void 0:t.test)||0,o=Math.max(0,(e.arrangementCount||0)-i);return(0,u.jsxs)("section",{className:"project-group","data-testid":"arrangement-project-group",children:[(0,u.jsxs)("div",{className:"project-group-head",children:[(0,u.jsx)("button",{type:"button",className:"project-icon ds-tip","data-tip-align":"start","data-tip":"".concat(y.has(e.id)?"Collapse":"Expand"," ").concat(e.name),"aria-controls":"project-members-".concat(e.id),"aria-label":"".concat(y.has(e.id)?"Collapse":"Expand"," ").concat(e.name),"aria-expanded":y.has(e.id),onClick:()=>v(t=>{const n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:y.has(e.id)?(0,u.jsx)(wd,{size:16,"aria-hidden":"true"}):(0,u.jsx)(bp,{size:16,"aria-hidden":"true"})}),(0,u.jsx)(Fj,{project:e}),(0,u.jsxs)("span",{className:"min-w-0 project-group-text",children:[(0,u.jsx)("span",{className:"project-group-name",children:e.name}),a&&(0,u.jsxs)("span",{className:"project-shoot-date","data-testid":"project-shoot-date",children:[(0,u.jsx)(Pj,{size:12,"aria-hidden":"true"}),"Shot ",a]}),(0,u.jsx)("span",{className:"project-group-meta block",children:"unassigned"!==e.id&&(0,u.jsxs)(u.Fragment,{children:[wC(o,"arrangement")," \xb7 ",wC(e.sessionCount||0,"session"),e.lastActivity?" \xb7 ".concat(ID(e.lastActivity)):""]})}),(0,u.jsxs)("span",{className:"project-group-meta block",children:[Object.entries(e.statusRollup||{}).map(e=>{let[t,n]=e;return"".concat(n," ").concat(t)}).join(" \xb7 "),"archived"===e.status?" \xb7 archived":""]})]}),r&&(0,u.jsx)("button",{type:"button",className:"project-icon project-folder-mark ds-tip","data-tip-align":"end","aria-label":"Copy Dropbox folder path: ".concat(r),"data-tip":L===e.id?"Copied":"Copy Dropbox folder path: ".concat(r),"aria-pressed":L===e.id,onClick:()=>{var t;null===(t=navigator.clipboard)||void 0===t||t.writeText(r).then(()=>{R(e.id),window.setTimeout(()=>R(t=>t===e.id?"":t),1500)}).catch(()=>{})},children:(0,u.jsx)(rC,{size:16,"aria-hidden":"true"})}
2),"unassigned"!==e.id&&(0,u.jsx)(Sj,{token:n,project:e,onChanged:MC})]}),y.has(e.id)&&(0,u.jsxs)("div",{id:"project-members-".concat(e.id),className:"project-group-body",children:[s.length>0&&(0,u.jsx)("ul",{className:"project-notes","aria-label":"".concat(e.name," notes"),children:s.map((e,t)=>(0,u.jsx)("li",{children:e},t))}),(0,u.jsx)(VC,{token:n,projectId:e.id,sort:h,order:p,hideUndated:g,excludeTest:!z&&e.slug!==kC},String(z))]})]},e.id)})]})]}),!z&&!!U&&!r&&(0,u.jsxs)("p",{className:"project-hidden-note","data-testid":"hidden-test-note",children:[wC(U,"test & QA arrangement")," hidden"]}),C&&(0,u.jsx)(Nj,{title:"Create arrangement",onClose:()=>!I&&N(!1),children:(0,u.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),E&&F.trim()){P(!0),B("");try{const e=await Qm(n,"/arrangements","POST",{title:F.trim(),projectId:E,kind:T});MC(),th(),window.location.assign("/arrangement/".concat(encodeURIComponent(e.previewToken)))}catch(BH){B(BH.message)}finally{P(!1)}}},children:[(0,u.jsx)("input",{className:"project-input","aria-label":"Arrangement title",placeholder:"Arrangement title",value:F,onChange:e=>S(e.target.value),required:!0}),(0,u.jsx)(ih,{token:n,value:E,onChange:A,required:!0}),(0,u.jsxs)("select",{className:"project-input","aria-label":"Arrangement kind",value:T,onChange:e=>M(e.target.value),children:[(0,u.jsx)("option",{value:"show",children:"Full show"}),(0,u.jsx)("option",{value:"midform",children:"Midform"}),(0,u.jsx)("option",{value:"short",children:"Short"}),(0,u.jsx)("option",{value:"test",children:"Test / QA"})]}),_&&(0,u.jsx)("p",{role:"alert",className:"project-error",children:_}),(0,u.jsx)("footer",{children:(0,u.jsx)("button",{type:"submit",className:"project-icon ds-tip","data-tip-align":"end","aria-label":"Save arrangement","data-tip":"Create arrangement",disabled:I||!E||!F.trim(),children:(0,u.jsx)(Wm,{size:18})})})]})})]})},qC=[{value:"sessions",label:"Sessions",Icon:gp},{value:"arrangements",label:"Arrangements",Icon:uj},{value:"calendar",label:"Calendar",Icon:mj}],WC=e=>{var t;let{onSessionSelect:n,className:r=""}=e;const s=oc(),{token:i}=am(),{isDarkMode:o}=zu(),[l,c]=(0,a.useState)([]),[m,h]=(0,a.useState)(""),[p,g]=(0,a.useState)(()=>new URLSearchParams(window.location.search).get("project")||""),[x,f]=(0,a.useState)(new Set),{projects:b}=sh(i,"all"),[y,v]=(0,a.useState)(null),[w,k]=(0,a.useState)(""),[j,D]=(0,a.useState)(!1),[C,N]=(0,a.useState)(""),F=(0,a.useRef)(null),E=(0,a.useRef)(0);(0,a.useEffect)(()=>{const e=F.current;y&&e&&!e.open&&e.showModal(),!y&&null!==e&&void 0!==e&&e.open&&e.close()},[y]);const[A,T]=(0,a.useState)(!0),[M,_]=(0,a.useState)(!1),[B,I]=(0,a.useState)(null),[P,L]=(0,a.useState)(!1),[R,z]=(0,a.useState)(null),[O,U]=(0,a.useState)(!1),[V,H]=(0,a.useState)(!1),[q,W]=(0,a.useState)(null),[Y,G]=(0,a.useState)(!1),[K,X]=(0,a.useState)("all"),[J,$]=(0,a.useState)("all"),[Q,Z]=(0,a.useState)("owned"),[ee,te]=(0,a.useState)("all"),[ne,ae]=(0,a.useState)(new Set),[re,se]=(0,a.useState)(()=>{const e=new URLSearchParams(window.location.search).get("view");return"calendar"===e||"arrangements"===e?e:"sessions"}),[ie,oe]=(0,a.useState)(new Set),[le,ce]=(0,a.useState)(null),[de,ue]=(0,a.useState)(!1),me=(0,a.useCallback)(e=>{se(e);const t=new URLSearchParams(window.location.search);"sessions"!==e?t.set("view",e):t.delete("view");const n=t.toString();s({pathname:window.location.pathname,search:n?"?".concat(n):""},{replace:!0})},[s]),he="overflow-hidden rounded-[30px] border border-[#D6DCE4] bg-[linear-gradient(180deg,rgba(255,255,255,0.9),rgba(248,248,247,0.8))] shadow-[0_34px_72px_-40px_rgba(35,46,63,0.45)] backdrop-blur-2xl dark:border-[#344052] dark:bg-[linear-gradient(180deg,rgba(27,36,50,0.92),rgba(20,28,40,0.82))] ".concat(r),pe="rounded-[24px] border border-[#D6DCE4] bg-white/80 shadow-[0_20px_40px_-28px_rgba(35,46,63,0.3)] dark:border-[#344052] dark:bg-[#202A3A]/80",ge=o?"sticky top-0 z-20 border-[#344052] bg-[#232E3F]/85 text-[#F4F4F4] backdrop-blur-2xl":"sticky top-0 z-20 border-[#D6DCE4] bg-[linear-gradient(180deg,rgba(255,255,255,0.84),rgba(244,244,244,0.84))] text-[#232E3F] backdrop-blur-2xl",xe=o?"border-white/[0.12] bg-white/[0.08] text-white/[0.78] hover:bg-white/[0.14] hover:text-white":"border-[#D6DCE4] bg-white/[0.9] text-[#4A586E] hover:bg-[#232E3F]/[0.05] hover:text-[#232E3F]",fe=o?"w-full rounded-2xl border border-white/[0.12] bg-white/[0.08] py-3 pl-12 pr-4 font-body text-sm text-[#F4F4F4] placeholder:text-white/[0.45] transition-all duration-200 focus:border-[#FFB52B]/[0.45] focu
2s:bg-white/[0.1] focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/20":"w-full rounded-2xl border border-[#D6DCE4] bg-white/[0.92] py-3 pl-12 pr-4 font-body text-sm text-[#232E3F] placeholder:text-[#6B788B] transition-all duration-200 focus:border-[#FFB52B]/[0.5] focus:bg-white focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/20",be=o?"rounded-2xl border border-white/[0.12] bg-white/[0.08] px-4 py-3 font-body text-sm text-[#F4F4F4] transition-all duration-200 focus:border-[#FFB52B]/[0.45] focus:bg-white/[0.1] focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/20":"rounded-2xl border border-[#D6DCE4] bg-white/[0.92] px-4 py-3 font-body text-sm text-[#232E3F] transition-all duration-200 focus:border-[#FFB52B]/[0.5] focus:bg-white focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/20",ye=o?"text-white/[0.58]":"text-[#7B8798]",ve=o?"text-white/[0.55]":"text-[#7B8798]",we="rounded-full px-2.5 py-1 font-headlines text-[11px] font-semibold",ke={version:"".concat(we," uppercase tracking-[0.1em] bg-[#EAF7EF] text-[#2D7250] dark:bg-emerald-950/40 dark:text-emerald-300"),count:"".concat(we," uppercase tracking-[0.1em] bg-[#EEF3FF] text-[#355E9A] dark:bg-blue-950/35 dar
2k:text-blue-200"),gold:"".concat(we," uppercase tracking-[0.1em] border border-[#F2D9A6] bg-[#FFF4D9] text-[#8A6100] dark:border-brand-yellow/25 dark:bg-brand-yellow/15 dark:text-brand-yellow"),danger:"".concat(we," uppercase tracking-[0.1em] bg-[#FDE8E8] text-[#B54747] dark:bg-red-950/40 dark:text-red-300"),show:"".concat(we," uppercase tracking-[0.1em] bg-[#F1EFFA] text-[#5E548E] dark:bg-violet-950/35 dark:text-violet-200"),external:"".concat(we," uppercase tracking-[0.1em] bg-[#E6F2FF] text-[#225C9C] dark:bg-blue-950/40 dark:text-blue-200"),neutral:"".concat(we," uppercase tracking-[0.1em] bg-[#232E3F]/[0.08] text-[#566377] dark:bg-brand-navy/30 dark:text-brand-cloud"),speaker:"".concat(we," border border-[#F2D9A6] bg-[#FFF4D9] text-[#8A6100] dark:border-brand-yellow/25 dark:bg-brand-yellow/15 dark:text-brand-yellow"),more:"".concat(we," bg-[#E8ECF1] text-[#566377] dark:bg-brand-navy/30 dark:text-brand-cloud"),tag:"".concat(we," bg-[#EAF7EF] text-[#2D7250] dark:bg-emerald-950/35 dark:text-emerald-300")},je=e=>"".concat("inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 font-headlines text-xs font-semibold uppercase tracking-[0.12em] transition-all duration-200"," ").concat(K===e?"border-[#FFB52B]/40 bg-[#FFB52B] text-[#232E3F] shadow-[0_18px_32px_-24px_rgba(255,181,43,0.85)]":xe),De="all"!==K?hj:gp,Ce="all"!==K?"No matching sessions":m?"No sessions found":"No sessions yet",Ne="all"!==K?"deprecated"===K?"No deprecated sessions are currently hidden from the main list.":"augmentation"===K?"No bridge, insert, pickup, or other augmentation sessions were found.":"No sessions match the current filter. Try selecting a different filter.":m?"Try adjusting your search terms.":"Start by transcribing your first audio file or YouTube video.",Fe=(0,a.useCallback)(async(e,t)=>{if(!i)return;const n=++E.current;try{_(!!e||"all"!==t||"all"!==J||"owned"!==Q||"all"!==ee);const a=await Vm.listSessions(i,e,50,t,{project:p||void 0,show:J,contentSource:Q,contentVisibility:ee,includeExternal:"all"===Q||"external"===Q});if(n!==E.current)return;c(a),I(null)}catch(a){console.error("Failed to load sessions:",a),n===E.current&&I("Failed to load sessions")}finally{n===E.current&&(T(!1),_(!1))}},[i,p,J,Q,ee]),Se=(0,a.useCallback)(async(e,t)=>{if(i)try{const n=await Vm.getSessionStorageSummary(i,e,t,{show:J,contentSource:Q,contentVisibility:ee,includeExternal:"all"===Q||"external"===Q});ce(n)}catch(n){console.error("Failed to load session storage summary:",n),ce(null)}},[i,J,Q,ee]);(0,a.useEffect)(()=>{const e=setTimeout(()=>{Fe(m||void 0,K)},m?300:0);return()=>clearTimeout(e)},[m,K,J,Q,ee,Fe]),(0,a.useEffect)(()=>{if(p)return void ce(null);if("sessions"!==re||A||M)return;if(!de)return;const e=setTimeout(()=>{Se(m||void 0,K)},m?300:1200);return()=>clearTimeout(e)},[re,p,m,K,J,Q,ee,A,M,de,Se]),(0,a.useEffect)(()=>{if(!i||de||"sessions"!==re)return;const e=window.setTimeout(()=>{(async function(e){if(!e)return;const t=WD("");if("none"!==t.group)return;const n=d(d({},DC),{},{project:"",excludeTest:!YD(),sort:HD(t.sort),order:t.order,hideUndated:"hide"===t.undated}),a=SC.get(AC(e,n));a&&Date.now()-a.at<6e4||await _C(e,n)})(i).catch(e=>console.error("Failed to prefetch arrangements:",e)).finally(()=>ue(!0))},250);return()=>window.clearTimeout(e)},[i,de,re]),(0,a.useEffect)(()=>{const e=()=>{"sessions"===re&&(Fe(m||void 0,K),Se(m||void 0,K))};return window.addEventListener("rescript-session-storage-updated",e),()=>window.removeEventListener("rescript-session-storage-updated",e)},[re,m,K,Fe,Se]);const Ee=e=>{const t=e||0;if(t<=0)return"0 B";const n=["B","KB","MB","GB","TB"];let a=t,r=0;for(;a>=1024&&r<n.length-1;)a/=1024,r+=1;const s=0===r?0:a>=10?1:2;return"".concat(a.toFixed(s)," ").concat(n[r])},Ae=e=>{const t=e||0;return t<=0?"$0.00/mo":t<.01?"<$0.01/mo":"$".concat(t.toFixed(t<1?2:1),"/mo")},Te=(0,a.useMemo)(()=>{const e=new Map;return l.forEach(t=>{t.showSlug&&t.showTitle&&e.set(t.showSlug,t.showTitle)}),Array.from(e.entries()).map(e=>{let[t,n]=e;return{slug:t,title:n}}).sort((e,t)=>e.title.localeCompare(t.title))},[l]),Me=(0,a.useMemo)(()=>new Map((p?[]:(null===le||void 0===le?void 0:le.sessions)||[]).map(e=>[e.sessionId,e])),[le,p]),_e=(0,a.useMemo)(()=>{const e=new Map;return l.forEach(t=>{var n,a;const r=null!==(n=t.family)&&void 0!==n&&n.slug&&(t.family.versionCount||0)>1?"project:".concat(t.projectId||(null===(a=t.project)||void 0===a?void 0:a.id)||"unassigned",":family:").concat(t.family.slug):"session:".concat(t.sessionId),s=e.get(r);s?s.items.push(t):e.set(r,{key:r,family:t.family||null,items:[t]})}),Array.from(e.values()).map(e=>{const t=[...e.items].sort((e,t)=>
2{var n,a,r,s;const i=null!==(n=null===(a=e.family)||void 0===a?void 0:a.versionNumber)&&void 0!==n?n:Number.NEGATIVE_INFINITY,o=null!==(r=null===(s=t.family)||void 0===s?void 0:s.versionNumber)&&void 0!==r?r:Number.NEGATIVE_INFINITY;if(i!==o)return o-i;const l=new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime();return 0!==l?l:new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()});return{key:e.key,family:e.family,items:t,primary:t[0],latestUpdatedAt:Math.max(...t.map(e=>new Date(e.updatedAt).getTime())),storage:t.reduce((e,t)=>{const n=Me.get(t.sessionId);return n?(e.sourceBytes+=n.sourceBytes||0,e.proxyBytes+=n.proxyBytes||0,e.totalBytes+=n.totalBytes||0,e.estimatedMonthlyStorageCostUsd+=n.estimatedMonthlyStorageCostUsd||0,e.cleanupCandidateBytes+=n.proxyCleanupCandidate&&n.proxyBytes||0,e.cleanupCandidateCount+=n.proxyCleanupCandidate?1:0,e.playableCount+=n.hasPlayableVideo?1:0,e.hasPlayableVideo=e.hasPlayableVideo||n.hasPlayableVideo,e.hasYoutubeVideo=e.hasYoutubeVideo||n.hasYoutubeVideo,e.hasProxyVideo=e.hasProxyVideo||n.hasProxyVideo,e.hasAwsSource=e.hasAwsSource||n.hasAwsSource,e):e},{sourceBytes:0,proxyBytes:0,totalBytes:0,estimatedMonthlyStorageCostUsd:0,playableCount:0,cleanupCandidateCount:0,cleanupCandidateBytes:0,hasPlayableVideo:!1,hasYoutubeVideo:!1,hasProxyVideo:!1,hasAwsSource:!1})}}).sort((e,t)=>t.latestUpdatedAt-e.latestUpdatedAt)},[l,Me]),Be=(0,a.useMemo)(()=>{const e=new Map;return _e.forEach(t=>{var n;const a=t.primary.projectId||(null===(n=t.primary.project)||void 0===n?void 0:n.id)||"unassigned";let r=e.get(a);if(!r){var s;const n=b.find(e=>e.id===a);r={id:a,name:(null===n||void 0===n?void 0:n.name)||(null===(s=t.primary.project)||void 0===s?void 0:s.name)||"Unassigned",items:[],count:0,total:null===n||void 0===n?void 0:n.sessionCount},e.set(a,r)}r.items.push(t),r.count+=t.items.length}),[...e.values()]},[_e,b]);(0,a.useEffect)(()=>{"all"===J||Te.some(e=>e.slug===J)||$("all")},[J,Te]);const Ie=(0,a.useCallback)(e=>{oe(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Pe=function(e){var t,a,r;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=!s.nested&&(s.familyVersionCount||0)>1&&null!==(t=e.family)&&void 0!==t&&t.title?e.family.title:e.title,l=!!e.showTitle&&"mlst"!==e.showSlug,m=s.storage||null,h=!(null===m||void 0===m||!m.hasPlayableVideo);return(0,u.jsx)(Do.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"group cursor-pointer",onClick:()=>{return t=e.sessionId,void n(t);var t},children:(0,u.jsx)("div",{className:"".concat("rounded-[24px] border border-[#D6DCE4] bg-white/[0.72] p-4 shadow-[0_20px_40px_-28px_rgba(35,46,63,0.34)] backdrop-blur-xl transition-all duration-200 hover:-translate-y-0.5 hover:border-[#FFB52B]/40 hover:bg-[#FFF8EA]/[0.88] hover:shadow-[0_30px_52px_-28px_rgba(35,46,63,0.4)] dark:border-[#415067] dark:bg-[linear-gradient(180deg,rgba(33,45,62,0.94),rgba(24,34,49,0.94))] dark:shadow-[0_26px_48px_-30px_rgba(0,0,0,0.68)] dark:hover:border-[#FFB52B]/[0.42] dark:hover:bg-[linear-gradient(180deg,rgba(38,52,71,0.98),rgba(28,40,56,0.98))]"," ").concat(s.nested?"border-dashed dark:bg-[linear-gradient(180deg,rgba(29,39,54,0.96),rgba(23,31,45,0.96))]":""),children:(0,u.jsxs)("div",{className:"flex items-start justify-between",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[null!==m&&void 0!==m&&m.hasYoutubeVideo||"youtube"===e.videoSource||e.isYouTubeMode?(0,u.jsx)(Au,{className:"h-4 w-4 flex-shrink-0 text-red-500"}):h||"file"===e.videoSource?(0,u.jsx)(uj,{className:"h-4 w-4 flex-shrink-0 text-brand-yellow"}):"dropbox"===e.videoSource?(0,u.jsx)(Hm,{size:16,className:"flex-shrink-0 text-[#8AA0BD]"}):(0,u.jsx)(_o,{className:"h-4 w-4 flex-shrink-0 text-brand-yellow"}),(0,u.jsx)("h4",{className:"truncate font-headlines text-base font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:o}),null!=(null===(a=e.family)||void 0===a?void 0:a.versionNumber)&&(0,u.jsxs)("span",{className:ke.version,children:["v",e.family.versionNumber]}),s.familyVersionCount&&s.familyVersionCount>1&&!s.nested&&(0,u.jsxs)("span",{className:ke.count,children:[s.familyVersionCount," versions"]}),m&&m.totalBytes>0&&(0,u.jsxs)("span",{className:ke.gold,children:[Ee(m.totalBytes)," media"]}),null!==m&&void 0!==m&&m.cleanupCandidateCount?(0,u.jsx)("span",{className:ke.danger,children:"Proxy cleanup candidate"}):null,(0,u.jsx)("span",{className:ke.neutral,title:"Project",children:(null===(r=e.project)||void 0===r?void 0:r.name)||"Unassigned"}),l&&(0,u.jsx)("span",{className:ke.show,children:e.showTitle}),"external"===e.contentSource&&(0,u.jsx)("span",{className:ke.external,children:"Exter
2nal"}),"internal"===e.contentVisibility&&(0,u.jsx)("span",{className:ke.neutral,children:"Internal"}),"augmentation"===e.sessionRole&&(0,u.jsx)("span",{className:ke.gold,children:"Augmentation"}),e.isDeprecated&&(0,u.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1 px-2 ".concat(ke.neutral),title:e.deprecatedReason||"Deprecated session",children:[(0,u.jsx)(pj,{className:"h-3 w-3 text-[#566377] dark:text-[#C6CDD8]"}),(0,u.jsx)("span",{className:"font-headlines text-[11px] font-semibold uppercase tracking-[0.1em] text-[#566377] dark:text-[#C6CDD8]",children:"Deprecated"})]}),e.shareLinksCount>0&&(0,u.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-1 rounded-full bg-[#FFB52B]/[0.14] px-2 py-1 dark:bg-brand-yellow/15",title:"".concat(e.shareLinksCount," public share link").concat(1!==e.shareLinksCount?"s":""),children:[(0,u.jsx)(gj,{className:"h-3 w-3 text-[#C98A00] dark:text-brand-yellow"}),(0,u.jsx)("span",{className:"font-headlines text-[11px] font-semibold text-[#A36A00] dark:text-[#FFE3A1]",children:e.shareLinksCount})]})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-4 font-body text-xs text-[#6B788B] dark:text-[#D1D9E5]",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(sk,{className:"h-3 w-3"}),(0,u.jsx)("span",{children:Re(e.sessionId)})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(wp,{className:"h-3 w-3"}),(0,u.jsx)("span",{children:e.timeAgo})]}),e.speakerCount>0&&(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(fh,{className:"h-3 w-3"}),(0,u.jsxs)("span",{children:[e.speakerCount," speaker",1!==e.speakerCount?"s":""]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(gp,{className:"h-3 w-3"}),(0,u.jsx)("span",{children:Le(e.wordCount)})]}),m&&m.estimatedMonthlyStorageCostUsd>0&&(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,u.jsx)(mj,{className:"h-3 w-3"}),(0,u.jsx)("span",{children:Ae(m.estimatedMonthlyStorageCostUsd)})]})]}),(e.speakerNames.length>0||e.tags.length>0)&&(0,u.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1",children:[e.speakerNames.slice(0,3).map((t,n)=>(0,u.jsx)("span",{className:"inline-block ".concat(ke.speaker),children:t},"".concat(e.sessionId,"-speaker-").concat(n))),e.speakerNames.length>3&&(0,u.jsxs)("span",{className:"inline-block ".concat(ke.more),
2children:["+",e.speakerNames.length-3," more"]}),e.tags.slice(0,3).map(t=>(0,u.jsxs)("span",{className:"inline-block ".concat(ke.tag),children:["#",t]},"".concat(e.sessionId,"-tag-").concat(t)))]})]}),(0,u.jsxs)("div",{className:"ml-2 flex flex-shrink-0 flex-wrap items-center gap-1 sm:ml-4",children:[(0,u.jsx)("button",{type:"button",className:"project-icon","aria-label":"Move ".concat(e.title||e.filename," to project"),title:"Move to project",onClick:t=>{var n;t.stopPropagation(),N(""),k(e.projectId||(null===(n=e.project)||void 0===n?void 0:n.id)||""),v(e)},children:(0,u.jsx)(xj,{className:"h-4 w-4","aria-hidden":"true"})}),(0,u.jsx)("button",{onClick:t=>((e,t)=>{e.stopPropagation(),W(t),H(!0)})(t,e),className:"rounded-full p-2 text-[#8E98A8] transition-all duration-200 opacity-0 group-hover:opacity-100 hover:bg-[#E8ECF1] hover:text-[#566377] dark:hover:bg-[#2A3445] dark:hover:text-[#C6CDD8]",title:e.isDeprecated?"Restore session to the main list":"Deprecate session and hide it from the main list",children:e.isDeprecated?(0,u.jsx)(fj,{className:"h-4 w-4"}):(0,u.jsx)(pj,{className:"h-4 w-4"})}),e.youtubeUrl&&e.shareLinksCount>0&&(0,u.jsx)("button",{onClick:t=>(async(e,t)=>{if(e.stopPropagation(),i){ae(e=>new Set(e).add(t.sessionId));try{const e=!t.publishedToHomepage;await Vm.toggleHomepagePublish(t.sessionId,e,i),c(n=>n.map(n=>n.sessionId===t.sessionId?d(d({},n),{},{publishedToHomepage:e}):n))}catch(n){console.error("Failed to toggle homepage publish:",n),I("Failed to update homepage visibility")}finally{ae(e=>{const n=new Set(e);return n.delete(t.sessionId),n})}}})(t,e),disabled:ne.has(e.sessionId),className:"rounded-full p-2 transition-all duration-200 opacity-0 group-hover:opacity-100\n ".concat(e.publishedToHomepage?"text-[#C98A00] hover:bg-[#FFF4D9] dark:text-brand-yellow dark:hover:bg-[#2B3547]":"text-[#8E98A8] hover:bg-[#E8ECF1] hover:text-[#566377] dark:hover:bg-[#2A3445] dark:hover:text-[#C6CDD8]","\n ").concat(ne.has(e.sessionId)?"opacity-50 cursor-wait":""),title:e.publishedToHomepage?"Published to homepage - click to hide":"Hidden from homepage - click to publish",children:ne.has(e.sessionId)?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(bj,{className:"h-4 w-4 ".concat(e.publishedToHomepage?"":"opacity-45")})}),(0,u.jsx)("button",{onClick:t=>((e,t)=>{e.stopPropagation(),z(t),L(!0)})(t,e),className:"rounded-full p-2 text-[#8E98A8] hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20 dark:hover:text-red-400 transition-all duration-200 opacity-0 group-hover:opacity-100",title:"Delete session",children:(0,u.jsx)(kp,{className:"h-4 w-4"})}),(0,u.jsx)(lj,{className:"h-5 w-5 text-[#8E98A8] transition-all duration-200 group-hover:translate-x-1 group-hover:text-[#C98A00] dark:group-hover:text-brand-yellow"})]})]})})},e.sessionId)},Le=e=>e<1e3?"".concat(e," words"):e<1e6?"".concat((e/1e3).toFixed(1),"k words"):"".concat((e/1e6).toFixed(1),"M words"),Re=e=>"".concat(e.substring(0,8),"...");return A?(0,u.jsx)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:he,children:(0,u.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)(Lo,{className:"h-5 w-5 animate-spin text-brand-yellow"}),(0,u.jsx)("span",{className:"font-headlines text-sm font-semibold uppercase tracking-[0.18em] text-[#566377] dark:text-[#C6CDD8]",children:"Loading sessions..."})]})})}):(0,u.jsxs)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:he,children:[(0,u.jsxs)("div",{className:"border-b ".concat(ge),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-3 sm:px-6",children:[(0,u.jsx)("h3",{className:"sr-only",children:"sessions"===re?"Previous Sessions":"calendar"===re?"Publication Calendar":"Arrangements"}),(0,u.jsx)("div",{role:"tablist","aria-label":"Discovery view",className:"inline-flex items-center gap-0.5 rounded-xl border border-primary-100 bg-white/70 p-0.5 dark:border-primary-500/40 dark:bg-primary-800/50",children:qC.map(e=>{let{value:t,label:n,Icon:a}=e;const r=re===t;return(0,u.jsxs)("button",{type:"button",role:"tab","aria-selected":r,"aria-label":n,"data-tip":n,"data-tip-align":"sessions"===t?"start":void 0,onClick:()=>me(t),className:"ds-tip inline-flex h-9 min-w-[2.25rem] items-center justify-center gap-1.5 rounded-lg px-2.5 font-headlines text-[13px] font-semibold tracking-normal transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-500/70 sm:px-3 ".concat(r?"bg-accent-500 text-primary-600 shadow-sm":"text-primary-400 hover:bg-primary-50 hover:text-primary-600 dark:text-primary-200 dark:hover:bg-primary-700 dark:hover:text-brand-cloud"),children:[(0,u.jsx)(a,{className:"h-4 w-4","aria-hidden":"true"}),(0,u.jsx)("span",{className:"hidden sm:inline","aria-hidden":"true",children:n})]},t)})}),"sessions"===re&&(0,u.jsx)("button",{type:"button",onClick:()=>s("/admin/comments"),"aria-label":"Comment review","data-tip":"Comment review","data-tip-align":"end",className:"ds-tip inline-flex h-9 w-9 items-center justify-center rounded-xl border border-primary-100 bg-white/70 text-primary-500 transition-colors hover:border-accent-500/60 hover:text-primary-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-500/70 dark:border-primary-500/40 dark:bg-primary-800/50 dark:text-primary-100 dark:hover:text-brand-cloud",children:(0,u.jsx)(Fp,{className:"h-4 w-4","aria-hidden":"true"})})]}),"sessions"===re&&(0,u.jsxs)("div",{className:"mb-3 space-y-3 px-4 sm:px-6",children:[(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(Mu,{className:"absolute left-7 top-1/2 h-4 w-4 -translate-y-1/2 ".concat(ye)}),(0,u.jsx)("input",{type:"text",placeholder:"Search transcripts, topics, speakers, comments...",value:m,onChange:e=>h(e.target.value),className:fe}),M&&(0,u.jsx)("div",{className:"absolute right-4 top-1/2 -translate-y-1/2",children:(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin text-brand-yellow"})})]}),(0,u.jsx)(ih,{token:i,value:p,onChange:e=>{g(e);const t=new URLSearchParams(window.location.search);e?t.set("project",e):t.delete("project"),s({pathname:window.location.pathname,search:t.toString()?"?".concat(t):""},{replace:!0})},allowAll:!0,label:"Filter sessions by project"}),(0,u.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,u.jsxs)("select",{value:J,onChange:e=>$(e.target.value),className:be,children:[(0,u.jsx)("option",{value:"all",children:"All shows"}),Te.map(e=>(0,u.jsx)("option",{value:e.slug,children:e.title},e.slug))]}),(0,u.jsxs)("select",{value:Q,onChange:e=>Z(e.target.value),className:be,children:[(0,u.jsx)("option",{value:"owned",children:"Owned content"}),(0,u.jsx)("option",{value:"all",children:"Owned + external"}
2),(0,u.jsx)("option",{value:"external",children:"External only"})]}),(0,u.jsxs)("select",{value:ee,onChange:e=>te(e.target.value),className:be,children:[(0,u.jsx)("option",{value:"all",children:"All visibility"}),(0,u.jsx)("option",{value:"default",children:"Default visibility"}),(0,u.jsx)("option",{value:"internal",children:"Internal only"})]})]})]}),"sessions"===re&&(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 pb-5 sm:px-6 sm:pb-6",children:[(0,u.jsx)(hj,{className:"hidden h-4 w-4 sm:block ".concat(ve)}),(0,u.jsx)("button",{onClick:()=>X("all"),className:je("all"),children:"All"}),(0,u.jsxs)("button",{onClick:()=>X("youtube"),className:je("youtube"),children:[(0,u.jsx)(Au,{className:"h-3 w-3"}),"YouTube"]}),(0,u.jsxs)("button",{onClick:()=>X("video"),className:je("video"),children:[(0,u.jsx)(uj,{className:"h-3 w-3"}),"Video"]}),(0,u.jsxs)("button",{onClick:()=>X("shared"),className:je("shared"),children:[(0,u.jsx)(gj,{className:"h-3 w-3"}),"Shared"]}),(0,u.jsxs)("button",{onClick:()=>X("augmentation"),className:je("augmentation"),children:[(0,u.jsx)(yj,{className:"h-3 w-3"}),"Augmentations"]}),(0,u.jsxs)("button",{onClick:()=>X("deprecated"),className:je("deprecated"),children:[(0,u.jsx)(Fy,{className:"h-3 w-3"}),"Deprecated"]})]})]}),(0,u.jsx)("div",{className:"p-5 sm:p-6",children:"calendar"===re?(0,u.jsx)(cD,{token:i||void 0}):"arrangements"===re?(0,u.jsx)(HC,{token:i}):(0,u.jsxs)(u.Fragment,{children:[B&&(0,u.jsxs)("div",{className:"".concat(pe," px-6 py-10 text-center"),children:[(0,u.jsx)("div",{className:"mb-2 font-headlines text-sm font-semibold uppercase tracking-[0.18em] text-red-600 dark:text-red-400",children:B}),(0,u.jsx)("button",{onClick:()=>Fe(),className:"font-headlines text-sm font-semibold text-[#C98A00] underline decoration-[#FFB52B]/60 underline-offset-4 hover:opacity-80 dark:text-brand-yellow",children:"Try again"})]}),!B&&0===l.length&&(0,u.jsxs)("div",{className:"".concat(pe," px-6 py-10 text-center"),children:[(0,u.jsx)(De,{className:"mx-auto mb-4 h-12 w-12 text-brand-yellow"}),(0,u.jsx)("h4",{className:"mb-2 font-headlines text-lg font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:Ce}),(0,u.jsx)("p",{className:"font-body text-[#566377] dark:text-[#C6CDD8]",children:Ne})]}),!B&&l.length>0&&(0,u.jsxs)("div",{className:"space-y-3",children:[!p&&le&&(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[(0,u.jsxs)("div",{className:"".concat(pe," px-4 py-4"),children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] text-[#A36A00] dark:text-[#FFCC66]",children:"Matching Session Media"}),(0,u.jsx)("div",{className:"mt-2 font-headlines text-xl font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:Ee(le.summary.totalBytes)}),(0,u.jsxs)("p",{className:"mt-1 font-body text-xs text-[#6B788B] dark:text-[#A9B4C3]",children:[le.summary.totalSessions," matching sessions"]})]}),(0,u.jsxs)("div",{className:"".concat(pe," px-4 py-4"),children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] text-[#355E9A] dark:text-[#BCD7FF]",children:"Monthly Storage"}),(0,u.jsx)("div",{className:"mt-2 font-headlines text-xl font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:Ae(le.summary.estimatedMonthlyStorageCostUsd)}),(0,u.jsxs)("p",{className:"mt-1 font-body text-xs text-[#6B788B] dark:text-[#A9B4C3]",children:["Source ",Ee(le.summary.totalSourceBytes)," + proxy ",Ee(le.summary.totalProxyBytes)]})]}),(0,u.jsxs)("div",{className:"".concat(pe," px-4 py-4"),children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] text-[#2D7250] dark:text-[#9EE0BD]",children:"Playable Video"}),(0,u.jsx)("div",{className:"mt-2 font-headlines text-xl font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:le.summary.sessionsWithPlayableVideo}),(0,u.jsxs)("p",{className:"mt-1 font-body text-xs text-[#6B788B] dark:text-[#A9B4C3]",children:[le.summary.sessionsWithYoutubeVideo," YouTube \xb7 ",le.summary.sessionsWithProxyVideo," proxied"]})]}),(0,u.jsxs)("div",{className:"".concat(pe," px-4 py-4"),children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] text-[#B54747] dark:text-[#FFB3B3]",children:"Cleanup Candidates"}),(0,u.jsx)("div",{className:"mt-2 font-headlines text-xl font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:le.
2summary.proxyCleanupCandidateCount}),(0,u.jsxs)("p",{className:"mt-1 font-body text-xs text-[#6B788B] dark:text-[#A9B4C3]",children:[Ee(le.summary.proxyCleanupCandidateBytes)," proxy bytes look redundant with YouTube"]})]})]}),(0,u.jsx)(S,{children:Be.map(e=>(0,u.jsxs)("section",{className:"project-group","aria-label":"Project sessions: ".concat(e.name),children:[(0,u.jsxs)("header",{className:"project-group-head",children:[(0,u.jsx)("button",{type:"button",className:"project-icon","aria-label":"".concat(x.has(e.id)?"Expand":"Collapse"," ").concat(e.name),title:"".concat(x.has(e.id)?"Expand":"Collapse"," project"),"aria-expanded":!x.has(e.id),onClick:()=>f(t=>{const n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:x.has(e.id)?(0,u.jsx)(wd,{size:18}):(0,u.jsx)(Tu,{size:18})}),(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsx)("h3",{className:"project-group-name",children:e.name}),(0,u.jsxs)("p",{className:"project-group-meta",children:[e.count," loaded",void 0!==e.total?" \xb7 ".concat(e.total," sessions in project"):""]})]}),b.find(t=>t.id===e.id)&&(0,u.jsx)(Sj,{token:i,project:b.find(t=>t.id===e.id),onChanged:()=>{Fe(m||void 0,K)}})]}),!x.has(e.id)&&(0,u.jsx)("div",{className:"project-group-body space-y-3",children:e.items.map(e=>{var t,n;const a=e.items.slice(1),r=(null===(t=e.family)||void 0===t?void 0:t.slug)||null,s=!!r&&ie.has(r);return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"relative",children:[e.family&&e.items.length>1&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"pointer-events-none absolute inset-x-2 top-3 h-full rounded-[24px] border border-[#D6DCE4] bg-white/55 dark:border-[#344052] dark:bg-[#18212E]/45"}),(0,u.jsx)("div",{className:"pointer-events-none absolute inset-x-1 top-1.5 h-full rounded-[24px] border border-[#D6DCE4] bg-white/40 dark:border-[#344052] dark:bg-[#151D29]/40"})]}),(0,u.jsx)("div",{className:"relative",children:Pe(e.primary,{familyVersionCount:(null===(n=e.family)||void 0===n?void 0:n.versionCount)||e.items.length,storage:e.storage})})]}),e.family&&a.length>0&&(0,u.jsxs)("div",{className:"flex items-center justify-between px-2",children:[(0,u.jsx)("div",{className:"min-w-0",children:(0,u.jsx)("p",{className:"font-body text-xs text-[#6B788B] dark:text-[#A9B4C3]",children:"Most recent version stays on top. Expand to inspect older edits in this family."})}),(0,u.jsxs)("button",{type:"button",onClick:()=>Ie(e.family.slug),className:"inline-flex items-center gap-2 rounded-full border border-[#D6DCE4] bg-white/85 px-3 py-1.5 font-headlines text-[11px] font-semibold uppercase tracking-[0.12em] text-[#355E9A] transition hover:border-[#AFC5E6] hover:bg-[#EEF3FF] dark:border-[#344052] dark:bg-[#202A3A] dark:text-[#BCD7FF] dark:hover:border-[#4D6485] dark:hover:bg-[#26344A]",children:[s?(0,u.jsx)(Tu,{className:"h-3.5 w-3.5"}):(0,u.jsx)(wd,{className:"h-3.5 w-3.5"}),s?"Collapse stack":"Show ".concat(a.length," older")]})]}),e.family&&a.length>0&&s&&(0,u.jsx)("div",{className:"ml-5 space-y-2 border-l border-dashed border-[#D6DCE4] pl-4 dark:border-[#344052]",children:a.map(e=>(0,u.jsx)("div",{children:Pe(e,{nested:!0,storage:(()=>{const t=Me.get(e.sessionId);return t?{sourceBytes:t.sourceBytes||0,proxyBytes:t.proxyBytes||0,totalBytes:t.totalBytes||0,estimatedMonthlyStorageCostUsd:t.estimatedMonthlyStorageCostUsd||0,playableCount:t.hasPlayableVideo?1:0,cleanupCandidateCount:t.proxyCleanupCandidate?1:0,cleanupCandidateBytes:t.proxyCleanupCandidate&&t.proxyBytes||0,hasPlayableVideo:!!t.hasPlayableVideo,hasYoutubeVideo:!!t.hasYoutubeVideo,hasProxyVideo:!!t.hasProxyVideo,hasAwsSource:!!t.hasAwsSource}:null})()})},e.sessionId))})]},e.key)})})]},e.id))})]}),l.length>=50&&(0,u.jsx)("div",{className:"mt-4 text-center",children:(0,u.jsxs)("p",{className:"font-body text-sm text-[#566377] dark:text-[#C6CDD8]",children:["Showing ",l.length," most recent sessions","all"!==K?" with ".concat("youtube"===K?"YouTube links":"video"===K?"playable video":"shared"===K?"public shares":"deprecated status"):"",". Use search to find more."]})})]})}),(0,u.jsx)("dialog",{ref:F,className:"project-dialog","aria-labelledby":"session-project-heading",onCancel:e=>{e.preventDefault(),j||v(null)},children:(0,u.jsxs)("form",{onSubmit:e=>{e.preventDefault(),(async()=>
2{if(y&&w&&!j){D(!0),N("");try{await eh(i,w,{sessionIds:[y.sessionId]}),th(),await Fe(m||void 0,K),v(null)}catch(B){N(B instanceof Error?B.message:"Could not move session")}finally{D(!1)}}})()},children:[(0,u.jsx)("h2",{id:"session-project-heading",children:"Move session to project"}),(0,u.jsx)("p",{className:"truncate",title:null===y||void 0===y?void 0:y.title,children:(null===y||void 0===y?void 0:y.title)||(null===y||void 0===y?void 0:y.filename)}),(0,u.jsx)(ih,{token:i,value:w,onChange:k,required:!0,label:"Destination project"}),C&&(0,u.jsx)("p",{role:"alert",className:"project-error",children:C}),(0,u.jsxs)("footer",{children:[(0,u.jsx)("button",{type:"button",className:"project-icon",title:"Cancel","aria-label":"Cancel session move",disabled:j,onClick:()=>v(null),children:(0,u.jsx)(Pu,{size:18})}),(0,u.jsx)("button",{type:"submit",className:"project-icon",title:"Move session","aria-label":"Confirm session move",disabled:j||!w||w===((null===y||void 0===y?void 0:y.projectId)||(null===y||void 0===y||null===(t=y.project)||void 0===t?void 0:t.id)),children:j?(0,u.jsx)(Lo,{size:18,className:"animate-spin"}):(0,u.jsx)(Wm,{size:18})})]})]})}),(0,u.jsx)(vj,{isOpen:P,onClose:()=>{L(!1),z(null)},onConfirm:async()=>{if(R&&i)try{U(!0),await Vm.deleteSession(R.sessionId,i),c(e=>e.filter(e=>e.sessionId!==R.sessionId)),L(!1),z(null)}catch(e){console.error("Failed to delete session:",e),I("Failed to delete session")}finally{U(!1)}},title:"Delete Session",message:'Are you sure you want to delete the session "'.concat((null===R||void 0===R?void 0:R.title)||(null===R||void 0===R?void 0:R.filename),'"? This action cannot be undone.'),confirmText:"Delete",cancelText:"Cancel",confirmButtonClassName:"bg-red-600 hover:bg-red-700",isLoading:O}),(0,u.jsx)(vj,{isOpen:V,onClose:()=>{H(!1),W(null)},onConfirm:async()=>{if(!q||!i)return;const e=!q.isDeprecated,t=e?"Deprecated from the session browser":null;try{G(!0);const n=await Vm.toggleDeprecation(q.sessionId,e,e?q.deprecatedReason||t:null,i);c(t=>e?t.filter(e=>e.sessionId!==q.sessionId):t.map(e=>e.sessionId===q.sessionId?d(d({},e),{},{title:n.session.title||e.title,isDeprecated:n.session.deprecated,deprecatedAt:n.session.deprecatedAt||null,deprecatedReason:n.session.deprecatedReason||null}):e)),"deprecated"===K&&await Fe(m||void 0,K),H(!1),W(null)}catch(n){console.error("Failed to toggle session deprecation:",n),I("Failed to update session deprecation")}finally{G(!1)}},title:null!==q&&void 0!==q&&q.isDeprecated?"Restore Session":"Deprecate Session",message:null!==q&&void 0!==q&&q.isDeprecated?'Restore "'.concat(q.title||q.filename,'" to the default session list?'):(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{children:['Deprecate "',(null===q||void 0===q?void 0:q.title)||(null===q||void 0===q?void 0:q.filename),'" and hide it from the default session list?']}),(0,u.jsx)("div",{className:"text-sm text-amber-700 dark:text-amber-300",children:"Warning: once deprecated, this session disappears from the normal browser. Restoring it later requires switching to the deprecated filter first."})]}),confirmText:null!==q&&void 0!==q&&q.isDeprecated?"Restore":"Deprecate",cancelText:"Cancel",confirmButtonClassName:null!==q&&void 0!==q&&q.isDeprecated?"bg-[#2563eb] hover:bg-[#1d4ed8]":"bg-[#566377] hover:bg-[#3F4E62]",isLoading:Y,confirmationValue:null!==q&&void 0!==q&&q.isDeprecated?void 0:"DEPRECATE",confirmationLabel:null!==q&&void 0!==q&&q.isDeprecated?void 0:"Type DEPRECATE to continue",confirmationPlaceholder:null!==q&&void 0!==q&&q.isDeprecated?void 0:"DEPRECATE",confirmationHint:null!==q&&void 0!==q&&q.isDeprecated?void 0:"This is a high-friction action because the session will no longer appear in the default UI list."})]})},YC="summaries",GC="payloads",KC="audio",XC="audioChunks",JC="shareTokens",$C=1048576,QC="mlst-offline-summaries-v1",ZC="mlst-offline-share-map-v1",eN="/__offline_cache__/sessions";function tN(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error||new Error("IndexedDB request failed"))})}function nN(e,t,n){return new Promise((a,r)=>{const s=window.setTimeout(()=>{r(new Error(n))},t);e.then(e=>{window.clearTimeout(s),a(e)}).catch(e=>{window.clearTimeout(s),r(e)})})}function aN(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error||new Error("IndexedDB transaction failed")),e.onabort=()=>n(e.error||new Error("IndexedDB transaction aborted"))})}function rN(){return new Promise((e,t)=>
2{if("undefined"===typeof indexedDB)return void t(new Error("IndexedDB is unavailable in this browser context"));const n=indexedDB.open("mlst-offline-sessions",3);n.onupgradeneeded=()=>{const e=n.result;if(e.objectStoreNames.contains(YC)||e.createObjectStore(YC,{keyPath:"sessionId"}),e.objectStoreNames.contains(GC)||e.createObjectStore(GC,{keyPath:"sessionId"}),e.objectStoreNames.contains(KC)||e.createObjectStore(KC,{keyPath:"sessionId"}),!e.objectStoreNames.contains(XC)){e.createObjectStore(XC,{keyPath:"id"}).createIndex("sessionId","sessionId",{unique:!1})}if(!e.objectStoreNames.contains(JC)){e.createObjectStore(JC,{keyPath:"shareToken"}).createIndex("sessionId","sessionId",{unique:!1})}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error||new Error("Failed to open IndexedDB"))})}function sN(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:180;const n=(e||"").replace(/\s+/g," ").trim();return n?n.length<=t?n:"".concat(n.slice(0,t).trimEnd(),"..."):""}function iN(e,t,n){const a=e.finalTranscript||e.currentTranscript||"",r=a.trim()?a.trim().split(/\s+/).length:0;return{sessionId:e.sessionId,shareToken:n||null,thumbnailUrl:e.thumbnailUrl||null,title:e.title||e.filename||"Untitled Session",filename:e.filename||"Untitled Session",transcriptPreview:sN(a,220),descriptionPreview:sN(e.youtubeDescription,180),duration:Number(e.duration)||0,wordCount:r,savedAt:t,updatedAt:t}}function oN(e){return"".concat(eN,"/").concat(encodeURIComponent(e),"/payload.json")}function lN(e){return"".concat(eN,"/").concat(encodeURIComponent(e),"/audio")}function cN(e){return"".concat(eN,"/").concat(encodeURIComponent(e),"/thumbnail")}function dN(e,t){if("undefined"===typeof localStorage)return t;try{const n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return console.warn("[OFFLINE] Failed to read local storage key:",e,n),t}}function uN(e,t){"undefined"!==typeof localStorage&&localStorage.setItem(e,JSON.stringify(t))}function mN(){return dN(QC,{})}function hN(e){uN(QC,e)}function pN(){return dN(ZC,{})}function gN(e){uN(ZC,e)}async function xN(){if("undefined"===typeof caches)throw new Error("Cache Storage is unavailable in this browser context");return caches.open("mlst-offline-session-assets-v1")}async function fN(e){const t=await xN(),[n,a]=await Promise.all([t.match(oN(e)),t.match(lN(e))]);return{hasPayload:!!n,hasAudio:!!a}}async function bN(e){try{const t=await fN(e);return t.hasPayload&&t.hasAudio}catch(t){return console.warn("[OFFLINE] Failed to inspect Cache Storage resources:",t),!1}}async function yN(e){try{const t=await xN();await Promise.all([t.delete(oN(e)),t.delete(lN(e)),t.delete(cN(e))])}catch(t){console.warn("[OFFLINE] Failed to delete cached session resources:",t)}}async function vN(e,t,n,a){const r=await rN();try{var s;await async function(e,t){const n=e.transaction(XC,"readwrite"),a=n.objectStore(XC),r=a.index("sessionId");(await tN(r.getAllKeys(t))).forEach(e=>{a.delete(e)}),await aN(n)}(r,e);const i=null===(s=t.body)||void 0===s?void 0:s.getReader();if(!i){const a=await nN(t.blob(),45e3,"Preparing the offline audio fallback took too long on this device."),s=r.transaction(KC,"readwrite");return s.objectStore(KC).put({sessionId:e,audioBlob:a,audioMimeType:n,storageKind:"blob"}),void await aN(s)}let o=0,l=0;for(;;){const{done:t,value:s}=await i.read();if(t)break;if(s&&0!==s.byteLength)for(let i=0;i<s.byteLength;i+=$C){const t=s.slice(i,i+$C),c=r.transaction(XC,"readwrite");c.objectStore(XC).put({id:"".concat(e,":").concat(o),sessionId:e,index:o,chunk:t}),await aN(c),o+=1,l+=t.byteLength,1!==o&&o%4!==0||null===a||void 0===a||a("Saving audio in fallback browser storage",{sessionId:e,audioMimeType:n,chunkCount:o,totalBytes:l})}}if(0===o)throw new Error("The offline audio fallback did not produce any audio chunks.");const c=r.transaction(KC,"readwrite");c.objectStore(KC).put({sessionId:e,audioMimeType:n,storageKind:"chunked",chunkCount:o}),await aN(c)}finally{r.close()}}async function wN(e){const t=await rN();try{const n=t.transaction(YC,"readonly"),a=await tN(n.objectStore(YC).get(e));return await aN(n),a||null}finally{t.close()}}async function kN(e){const t=await rN();try{const n=t.transaction([YC,GC,KC],"readonly"),[a,r,s]=await Promise.all([tN(n.objectStore(YC).get(e)),tN(n.objectStore(GC).get(e)),tN(n.objectStore(KC).get(e))]);if(await aN(n),!a||!r||!s)return null;const i=r,o=s;let l=o.audioBlob;if(!l&&"chunked"===o.storageKind){const n=t.transaction(XC,"readonly"),a=n.objectStore(XC).index("sessionId"),r=await tN(a.getAll(e));if(await aN(n),!r.length)return null;r.sort((e,t)=>
2e.index-t.index),l=new Blob(r.map(e=>e.chunk),{type:o.audioMimeType||"audio/mpeg"})}return l?d(d({},a),{},{sessionData:i.sessionData,audioBlob:l,audioMimeType:o.audioMimeType}):null}finally{t.close()}}async function jN(e){const t=await rN();try{const n=t.transaction([GC,KC],"readonly"),[a,r]=await Promise.all([tN(n.objectStore(GC).get(e)),tN(n.objectStore(KC).get(e))]);if(await aN(n),!a||!r)return!1;const s=r;return!!s.audioBlob||"chunked"===s.storageKind&&Number(s.chunkCount)>0}finally{t.close()}}async function DN(e){const t=await rN();try{const n=t.transaction([YC,GC,KC,JC,XC],"readwrite");n.objectStore(YC).delete(e),n.objectStore(GC).delete(e),n.objectStore(KC).delete(e);const a=n.objectStore(XC),r=a.index("sessionId");(await tN(r.getAllKeys(e))).forEach(e=>{a.delete(e)});const s=n.objectStore(JC),i=s.index("sessionId");(await tN(i.getAllKeys(e))).forEach(e=>{s.delete(e)}),await aN(n)}finally{t.close()}}async function CN(e,t,n){const a=iN(e,(new Date).toISOString(),null===n||void 0===n?void 0:n.shareToken);let r=!1,s=!1,i=null;const o=t.headers.get("Content-Type")||"audio/mpeg",l=t.clone();let c=null,u=!1;if(null!==n&&void 0!==n&&n.thumbnailUrl)try{c=await fetch(n.thumbnailUrl,{mode:"no-cors"})}catch(f){console.warn("[OFFLINE] Failed to cache thumbnail for offline card:",f)}try{var m;if(await async function(e,t,n,a,r){null===r||void 0===r||r("Opening browser cache",{sessionId:e.sessionId});const s=await xN(),i=oN(e.sessionId),o=lN(e.sessionId),l=cN(e.sessionId),c=t instanceof Response?t:new Response(t,{headers:{"Content-Type":n||"audio/mpeg"}});null===r||void 0===r||r("Saving transcript and metadata",{payloadUrl:i}),await Promise.all([s.put(i,new Response(JSON.stringify({sessionData:e}),{headers:{"Content-Type":"application/json"}})),(async()=>{null===r||void 0===r||r("Saving audio to browser storage",{audioUrl:o,audioMimeType:n}),await s.put(o,c)})(),a?(async()=>{null===r||void 0===r||r("Saving thumbnail for offline cards",{thumbnailUrl:l}),await s.put(l,a)})():Promise.resolve()]),null===r||void 0===r||r("Browser cache write completed",{sessionId:e.sessionId})}(e,t,o,c,null===n||void 0===n?void 0:n.onProgress),null===n||void 0===n||null===(m=n.onProgress)||void 0===m||m.call(n,"Verifying saved audio and transcript",{sessionId:e.sessionId}),u=await async function(e,t){const n=[0,400,1200,2500,5e3];for(let a=0;a<n.length;a+=1){const r=n[a];r>0&&(null===t||void 0===t||t("Waiting for browser cache to settle",{sessionId:e,attempt:a+1,delayMs:r}),await new Promise(e=>window.setTimeout(e,r)));try{const n=await fN(e);if(n.hasPayload&&n.hasAudio)return null===t||void 0===t||t("Verified saved audio and transcript",{sessionId:e,attempt:a+1}),!0;null===t||void 0===t||t("Browser cache verification is still incomplete",d({sessionId:e,attempt:a+1},n))}catch(f){null===t||void 0===t||t("Browser cache verification failed",{sessionId:e,attempt:a+1,error:f instanceof Error?f.message:String(f)})}}return!1}(e.sessionId,null===n||void 0===n?void 0:n.onProgress),!u)throw new Error("The browser did not retain the offline audio in Cache Storage.");r=!0}catch(f){i=f instanceof Error?f:new Error("Failed to cache offline session assets"),console.warn("[OFFLINE] Primary cache storage failed, attempting IndexedDB fallback:",f),!1===u&&await yN(e.sessionId)}if(r)try{var h;null===n||void 0===n||null===(h=n.onProgress)||void 0===h||h.call(n,"Recording offline library entry",{sessionId:a.sessionId}),function(e,t){const n=mN();if(n[e.sessionId]=e,hN(n),t){const n=pN();n[t]=e.sessionId,gN(n)}}(a,null===n||void 0===n?void 0:n.shareToken)}catch(f){console.warn("[OFFLINE] Failed to write local offline metadata:",f)}try{var p;null===n||void 0===n||null===(p=n.onProgress)||void 0===p||p.call(n,"Recording browser fallback metadata",{sessionId:a.sessionId}),await async function(e,t,n,a){const r=await rN(),s=(new Date).toISOString(),i=iN(e,s,null===a||void 0===a?void 0:a.shareToken);try{const o=r.transaction([YC,GC,KC,JC],"readwrite");o.objectStore(YC).put(i),o.objectStore(GC).put({sessionId:e.sessionId,sessionData:e}),t&&o.objectStore(KC).put({sessionId:e.sessionId,audioBlob:t,audioMimeType:n||"audio/mpeg",storageKind:"blob"}),null!==a&&void 0!==a&&a.shareToken&&o.objectStore(JC).put({shareToken:a.shareToken,sessionId:e.sessionId,savedAt:s}),await aN(o)}finally{r.close()}}(e,null,o,n),s=!0}catch(f){console.warn("[OFFLINE] IndexedDB metadata backup save failed:",f)}if(!r)try{var g,x;null===n||void 0===n||null===(g=n.onProgress)||void 0===g||g.call(n,"Primary cache failed, trying fallback storage",{sessionId:e.sessionId}),null===n||void 0===n||null===(x=n.onProgress)||void 0===x||x.call(n,"Saving audio in fallback browser storage",{sessionId:e.sessionId,audioMimeType:o}),await nN(vN(e.sessionId,l,o,null===n||void 0===n?void 0:n.onProgress),18e4,"Saving audio in fallback browser storage took too long on this device."),r=!0,s=!0}catch(f){console.warn("[OFFLINE] IndexedDB audio fallback save failed:",f)}if(!r){if(s)try{await DN(e.sessionId)}catch(b){console.warn("[OFFLINE] Failed to clean up incomplete IndexedDB offline session:",b)}throw i||new Error("Failed to store offline session locally")}return a}
2async function NN(){const e=Object.values(mN()),t=(await Promise.all(e.map(async e=>await bN(e.sessionId)?e:null))).filter(e=>null!==e);if(t.length!==e.length){hN(t.reduce((e,t)=>(e[t.sessionId]=t,e),{}));const e=new Set(t.map(e=>e.sessionId)),n=pN();gN(Object.fromEntries(Object.entries(n).filter(t=>{let[,n]=t;return e.has(n)})))}let n=[];try{const e=await async function(){const e=await rN();try{const t=e.transaction(YC,"readonly"),n=await tN(t.objectStore(YC).getAll());return await aN(t),n}finally{e.close()}}();n=(await Promise.all(e.map(async e=>{const[t,n]=await Promise.all([bN(e.sessionId),jN(e.sessionId)]);return t||n?e:null}))).filter(e=>null!==e)}catch(a){console.warn("[OFFLINE] Failed to list IndexedDB offline sessions:",a)}return function(e){const t=new Map;return e.forEach(e=>{const n=t.get(e.sessionId);(!n||new Date(e.updatedAt).getTime()>new Date(n.updatedAt).getTime())&&t.set(e.sessionId,e)}),Array.from(t.values())}([...t,...n]).sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime())}async function FN(e){let t=mN()[e]||null;if(!t)try{t=await wN(e)}catch(n){console.warn("[OFFLINE] Failed to load IndexedDB summary for cache lookup:",n)}if(t){const a=await async function(e,t){try{const n=await xN(),[a,r]=await Promise.all([n.match(oN(e)),n.match(lN(e))]);if(!a||!r)return null;const s=await a.json();if(!s.sessionData)return null;const i=await r.blob();return d(d({},t),{},{sessionData:s.sessionData,audioBlob:i,audioMimeType:i.type||r.headers.get("Content-Type")||"audio/mpeg"})}catch(n){return console.warn("[OFFLINE] Failed to load cached session record:",n),null}}(e,t);if(a)return a}try{return await kN(e)}catch(n){return console.warn("[OFFLINE] Failed to load IndexedDB offline session:",n),null}}async function SN(e){if(mN()[e]){const[t,n]=await Promise.all([bN(e),jN(e).catch(e=>(console.warn("[OFFLINE] Failed to check IndexedDB offline record:",e),!1))]);return t||n}try{if(await wN(e)){const[t,n]=await Promise.all([bN(e),jN(e)]);return t||n}}catch(t){console.warn("[OFFLINE] Failed to check IndexedDB summary availability:",t)}try{return!!await kN(e)}catch(t){return console.warn("[OFFLINE] Failed to check IndexedDB offline availability:",t),!1}}async function EN(e){const t=pN()[e];if(t){if(await SN(t))return t}try{const t=await async function(e){const t=await rN();try{const n=t.transaction(JC,"readonly"),a=await tN(n.objectStore(JC).get(e));return await aN(n),(null===a||void 0===a?void 0:a.sessionId)||null}finally{t.close()}}(e);if(!t)return null;return await SN(t)?t:null}catch(n){return console.warn("[OFFLINE] Failed to read IndexedDB share token mapping:",n),null}}async function AN(e,t){const n=pN();n[e]=t,gN(n);try{await async function(e,t){const n=await rN();try{const a=n.transaction(JC,"readwrite");a.objectStore(JC).put({shareToken:e,sessionId:t,savedAt:(new Date).toISOString()}),await aN(a)}finally{n.close()}}(e,t)}catch(a){console.warn("[OFFLINE] Failed to update IndexedDB share token mapping:",a)}}const TN=()=>{const{shareToken:e}=lc(),t=oc(),n=rc(),{isDarkMode:r}=zu(),[s,i]=(0,a.useState)(""),o=(0,a.useMemo)(()=>{const e=new URLSearchParams(n.search),t=new URLSearchParams,a=e.get("t");a&&t.set("t",a);const r=t.toString();return r?"&".concat(r):""},[n.search]),l=(0,a.useCallback)(async()=>{i("");const n=async()=>{if(!e)return!1;const n=await EN(e);return!!n&&(t("/session/".concat(n,"?share=").concat(e).concat(o),{replace:!0}),!0)};try{if(!navigator.onLine&&await n())return;const a=await Wu("".concat("","/api/public/share/").concat(e),{cache:"no-store",credentials:"omit"},12e3,"Timed out while loading the shared session");if(!a.ok)return void(404===a.status?i("Share link not found"):410===a.status?i("This share link is not currently available"):403===a.status?i("This share link has been disabled or reached its viewer limit"):i("Failed to load shared session"));const r=await a.json();await fetch("".concat("","/api/public/share/").concat(e,"/events"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify({event:"TAB_VIEW",metadata:{tab:"initial"}})}).catch(console.error),t("/session/".concat(r.session.session_id,"?share=").concat(e).concat(o),{replace:!0})}catch(a){if(console.error("[PUBLIC-SHARE] Error loading data:",a),await n())return;i("Failed to load shared session")}},[o,t,e]);return(0,a.useEffect)(()=>{e&&l()},[l,e]),(0,u.jsx)("div",{className:r?"dark":void 0,children:(0,u.jsx)("div",{className:"brand-shell brand-grid",children:(0,u.jsx)("div",{className:"relative z-10 flex min-h-screen items-center justify-center px-4 py-10 sm:px-6 lg:px-8",children:(0,u.jsxs)(Do.div,{initial:{opacity:0,y:16}
2,animate:{opacity:1,y:0},transition:{duration:.45},className:"brand-card w-full max-w-xl p-8 text-center sm:p-10",children:[(0,u.jsx)("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-[1.35rem] bg-brand-navy shadow-brand dark:bg-white/10",children:(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"Machine Learning Street Talk",className:"h-8 w-auto"})}),s?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{className:"mt-8 brand-kicker",children:"Public Share"}),(0,u.jsx)("div",{className:"mx-auto mt-6 flex h-16 w-16 items-center justify-center rounded-full bg-red-50 text-red-600 dark:bg-red-500/12 dark:text-red-300",children:(0,u.jsx)(Lu,{className:"h-8 w-8"})}),(0,u.jsx)("h1",{className:"mt-6 font-headlines text-4xl font-bold tracking-tight text-brand-navy dark:text-brand-cloud sm:text-5xl",children:s}),(0,u.jsx)("p",{className:"mt-4 text-base leading-8 text-brand-navy/68 dark:text-brand-cloud/72",children:"The shared transcript is not currently available. The link may be disabled or no longer public."}),(0,u.jsxs)("div",{className:"mt-8 flex flex-col items-center justify-center gap-3 sm:flex-row",children:[(0,u.jsxs)("button",{onClick:()=>t("/"),className:"brand-button-primary",children:[(0,u.jsx)(Io,{className:"h-4 w-4"}),"Back to archive"]}),(0,u.jsxs)("button",{onClick:()=>{l()},className:"brand-button-secondary",children:["Try again",(0,u.jsx)(lj,{className:"h-4 w-4"})]})]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{className:"mt-8 brand-kicker",children:"Public Share"}),(0,u.jsx)("div",{className:"mx-auto mt-6 brand-spinner"}),(0,u.jsx)("h1",{className:"mt-6 font-headlines text-4xl font-bold tracking-tight text-brand-navy dark:text-brand-cloud sm:text-5xl",children:"Opening shared transcript"}),(0,u.jsx)("p",{className:"mt-4 text-base leading-8 text-brand-navy/68 dark:text-brand-cloud/72",children:"We are validating the share link and redirecting you into the MLST transcript view."})]})]})})})})},MN=Mo("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),_N=Mo("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),BN=Mo("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),IN=Mo("refresh-ccw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]),PN=Mo("locate-fixed",[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),LN=(e,t)=>{const n=new Headers(t);return n.set("Content-Type","application/json"),e&&n.set("Authorization","Bearer ".concat(e)),n},RN=async e=>{const t=e.clone();try{const t=await e.json();if(t.error)return t.error;if(t.message)return t.message}catch(_H){const n=await t.text().catch(()=>"");if(n)return n}return"HTTP ".concat(e.status)},zN=async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=await fetch("".concat("/api/v1").concat(e),d(d({},n),{},{headers:LN(t,n.headers)}));if(!a.ok)throw new Error(await RN(a));if(204!==a.status)return a.json()},ON=async(e,t,n,a,r,s)=>{const i={operations:a,revisionNotes:r,autoSelect:!0};return zN("/episodes/".concat(encodeURIComponent(e),"/ttml/versions/").concat(encodeURIComponent(t),"/").concat(n,"/mutate"),s,{method:"POST",body:JSON.stringify(i)})}
2,UN={getStructure:(e,t,n)=>zN("/episodes/".concat(encodeURIComponent(e),"/ttml/versions/").concat(encodeURIComponent(t),"/structure"),n),async getPublicStructure(e,t){const n=await fetch("".concat("/api","/public/share/").concat(encodeURIComponent(e),"/ttml-versions/").concat(encodeURIComponent(t),"/structure"),{headers:{Accept:"application/json"},cache:"no-store",credentials:"omit"});if(!n.ok)throw new Error(await RN(n));return n.json()},mutateTopics:(e,t,n,a,r)=>ON(e,t,"topics",n,a,r),mutateClips:(e,t,n,a,r)=>ON(e,t,"clips",n,a,r),mutateEdits:(e,t,n,a,r)=>ON(e,t,"edits",n,a,r),mutateReferences:(e,t,n,a,r)=>ON(e,t,"references",n,a,r),setTopicRatings(e,t,n,a,r){const s={ratings:n,revisionNotes:a,autoSelect:!0};return zN("/episodes/".concat(encodeURIComponent(e),"/ttml/versions/").concat(encodeURIComponent(t),"/ratings/set"),r,{method:"POST",body:JSON.stringify(s)})}},VN={overall:"Overall",substance:"Substance (S)",resonance:"Relevance (R)",clarity:"Clarity (C)",production:"Pacing (P)",creative_risk:"Cross-reference (CR)"},HN="rescript.topicVisualization.mode",qN="rescript.topicVisualization.showGradient",WN="rescript.topicVisualization.retentionMode",YN="rescript.topicVisualization.overlayMode",GN=["topics","questions"],KN=["overall","substance","resonance","clarity","production","creative_risk"],XN=["off","relative","absolute","adjusted","drops"],JN=()=>{if("undefined"===typeof window)return"overall";const e=window.localStorage.getItem(HN);return KN.includes(e)?e:"overall"},$N=()=>{if("undefined"===typeof window)return!0;const e=window.localStorage.getItem(qN);if(null===e)return!0;try{return JSON.parse(e)}catch(_H){return!0}},QN=()=>{if("undefined"===typeof window)return"topics";const e=window.localStorage.getItem(YN);return GN.includes(e)?e:"topics"},ZN=()=>{if("undefined"===typeof window)return"off";const e=window.localStorage.getItem(WN);return XN.includes(e)?e:"off"},eF=(0,a.createContext)(void 0),tF=()=>{const e=(0,a.useContext)(eF);if(!e)throw new Error("useTopicVisualization must be used within a TopicVisualizationProvider");return e},nF=e=>{let{children:t}=e;const[n,r]=(0,a.useState)(JN),[s,i]=(0,a.useState)($N),[o,l]=(0,a.useState)(ZN),[c,d]=(0,a.useState)(null),[m,h]=(0,a.useState)(QN);return(0,a.useEffect)(()=>{"undefined"!==typeof window&&window.localStorage.setItem(HN,n)},[n]),(0,a.useEffect)(()=>{"undefined"!==typeof window&&window.localStorage.setItem(qN,JSON.stringify(s))},[s]),(0,a.useEffect)(()=>{"undefined"!==typeof window&&window.localStorage.setItem(WN,o)},[o]),(0,a.useEffect)(()=>{"undefined"!==typeof window&&window.localStorage.setItem(YN,m)},[m]),(0,u.jsx)(eF.Provider,{value:{mode:n,showGradient:s,setMode:r,setShowGradient:i,retentionMode:o,setRetentionMode:l,retentionData:c,setRetentionData:d,overlayMode:m,setOverlayMode:h},children:t})},aF=function(e){const t=e/10;return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?t>=.8?"bg-green-100 dark:bg-green-800 border-green-300 dark:border-green-600 text-green-800 dark:text-green-200":t>=.6?"bg-lime-100 dark:bg-lime-800 border-lime-300 dark:border-lime-600 text-lime-800 dark:text-lime-200":t>=.4?"bg-yellow-100 dark:bg-yellow-800 border-yellow-300 dark:border-yellow-600 text-yellow-800 dark:text-yellow-200":t>=.2?"bg-orange-100 dark:bg-orange-800 border-orange-300 dark:border-orange-600 text-orange-800 dark:text-orange-200":"bg-red-100 dark:bg-red-800 border-red-300 dark:border-red-600 text-red-800 dark:text-red-200":t>=.67?"bg-green-100 dark:bg-green-800 border-green-300 dark:border-green-600 text-green-800 dark:text-green-200":t>=.33?"bg-yellow-100 dark:bg-yellow-800 border-yellow-300 dark:border-yellow-600 text-yellow-800 dark:text-yellow-200":"bg-red-100 dark:bg-red-800 border-red-300 dark:border-red-600 text-red-800 dark:text-red-200"},rF=10,sF=1600,iF=(e,t,n)=>Math.min(Math.max(e,t),n),oF=e=>Number.isFinite(e)&&e>0,lF=(e,t,n)=>{if(!oF(e))return 0;const a=e,r=oF(n)?n:a;return iF(r,t,e)};function cF(e){let{totalDuration:t,visibleWidth:n,currentTime:r,isMobile:s,autoFollowEnabled:i=!0,minVisibleDurationSeconds:o=rF,autoFollowIdleMs:l
2=sF}=e;const c=oF(t)?t:0,d=oF(n)?n:0,u=c?iF(Number.isFinite(r)?r:0,0,c):0,[m,h]=(0,a.useState)(0),[p,g]=(0,a.useState)(0),x=(0,a.useRef)(0),f=(0,a.useRef)(!1),b=(0,a.useRef)(!1),y=(0,a.useRef)(null),v=(0,a.useMemo)(()=>c?Math.min(c,o):o,[o,c]),w=(0,a.useCallback)((e,t)=>((e,t,n)=>{if(!oF(e))return 0;const a=Math.max(0,e-n);return iF(t,0,a)})(c,e,t),[c]),k=(0,a.useCallback)((e,t)=>{if(!c)return h(0),void g(0);const n=lF(c,v,t),a=w(e,n);g(n),h(a)},[w,v,c]);(0,a.useEffect)(()=>{if(!c)return h(0),g(0),b.current=!1,void(y.current=null);const e=lF(c,v,p),t=w(m,e);e!==p&&g(e),t!==m&&h(t)},[w,v,c,p,m]),(0,a.useEffect)(()=>{s&&c?(y.current!==c&&(b.current=!1,y.current=c),b.current||(b.current=!0,k(0,c))):s||(b.current=!1,y.current=null)},[k,s,c]);const j=(0,a.useMemo)(()=>c&&p?c/p:1,[c,p]),D=(0,a.useMemo)(()=>d?Math.max(d,d*j):0,[d,j]),C=(0,a.useMemo)(()=>c&&D?m/c*D:0,[D,c,m]),N=(0,a.useMemo)(()=>c?Math.min(m+p,c):0,[c,p,m]),F=(0,a.useCallback)(()=>{x.current=Date.now()},[]),S=(0,a.useCallback)(()=>{F(),f.current=!1,k(0,c||v)},[k,F,v,c]),E=(0,a.useCallback)(e=>{!p||p>=c||(F(),f.current=!0,h(t=>w(t+e,p)))},[w,F,c,p]),A=(0,a.useCallback)(e=>{d&&p&&E(e/d*p)},[E,d,p]),T=(0,a.useCallback)(e=>{if(!c||!p)return;const t=iF(e,0,c);f.current=!1,h(w(t-p/2,p))},[w,c,p]),M=(0,a.useCallback)((e,t)=>{if(!c||!p||!Number.isFinite(t)||t<=0)return;const n=iF(e,0,c),a=lF(c,v,p*t),r=p>0?iF((n-m)/p,0,1):.5,s=w(n-a*r,a);F(),f.current=!0,g(a),h(s)},[w,F,v,c,p,m]),_=(0,a.useCallback)(e=>{if(!c||!D)return 0;return iF(e,0,c)/c*D-C},[C,D,c]),B=(0,a.useCallback)(e=>c&&D?iF((e+C)/D*c,0,c):0,[C,D,c]);return(0,a.useEffect)(()=>{if(!i||!c||p<=0||p>=c)return;if(f.current)return;if(Date.now()-x.current<l)return;(u<m+.3*p||u>N-.3*p)&&h(w(u-p/2,p))},[l,i,w,u,c,p,N,m]),{viewportStart:m,viewportEnd:N,viewportDuration:p,zoomRatio:j,contentWidth:D,contentOffsetX:C,isZoomed:p>0&&p<c,timeToX:_,xToTime:B,resetZoom:S,panByTime:E,panByPixels:A,zoomAroundTime:M,centerOnTime:T,markUserInteracted:F}}const dF=20,uF=46,mF=e=>{let{comments:t,duration:n,currentTime:r,viewportStart:s,viewportEnd:i,timeToX:o,onAddComment:l,onDeleteComment:c,onReply:m,onReact:h,onSelectComment:p,selectedCommentId:g,isDarkMode:x,width:f,height:b=uF,onHeightChange:y}=e;const{user:v}=am(),w=(0,a.useRef)(null),[k,j]=(0,a.useState)(!1),[D,C]=(0,a.useState)(""),[N,F]=(0,a.useState)(!1),[E,A]=(0,a.useState)(null),T=(0,a.useCallback)(e=>o?o(e):n<=0||f<=0?0:e/n*f,[n,o,f]),M=e=>{if(!e||"Anonymous"===e)return"AN";if(e.includes("@"))return e.split("@")[0].substring(0,2).toUpperCase();const t=e.trim().split(" ");return t.length>1?(t[0][0]+t[t.length-1][0]).toUpperCase():e.substring(0,2).toUpperCase()},_=(0,a.useMemo)(()=>[{background:"#33455f",border:"rgba(196, 212, 236, 0.34)",color:"#f4f7fb"},{background:"#516889",border:"rgba(218, 228, 244, 0.34)",color:"#f4f7fb"},{background:"#8f6a23",border:"rgba(255, 229, 176, 0.34)",color:"#fff7e6"},{background:"#7f4b3a",border:"rgba(255, 219, 206, 0.34)",color:"#fff2ed"},{background:"#5d7253",border:"rgba(216, 239, 203, 0.34)",color:"#f3fbef"},{background:"#6f4a67",border:"rgba(241, 214, 239, 0.34)",color:"#fff3fe"},{background:"#5c5648",border:"rgba(231, 223, 206, 0.34)",color:"#faf5ea"},{background:"#9f7b27",border:"rgba(255, 234, 189, 0.34)",color:"#fff8ea"}],[]),B=(0,a.useMemo)(()=>[{background:"#dce8f7",border:"rgba(56, 88, 132, 0.28)",color:"#24354c"},{background:"#d9edf0",border:"rgba(36, 105, 111, 0.26)",color:"#21424a"},{background:"#f7e2bb",border:"rgba(146, 102, 26, 0.28)",color:"#5c4208"},{background:"#f3d7ce",border:"rgba(142, 77, 55, 0.28)",color:"#5e3123"},{background:"#dce9d6",border:"rgba(77, 109, 68, 0.28)",color:"#2f4630"},{background:"#ead8e8",border:"rgba(118, 71, 113, 0.26)",color:"#4a2f47"},{background:"#e7e0d1",border:"rgba(100, 86, 61, 0.24)",color:"#453b2b"},{background:"#f4dfb2",border:"rgba(151, 108, 23, 0.28)",color:"#5f4308"}],[]),I=(0,a.useCallback)(e=>{const t=x?_:B;return t[e.split("").reduce((e,t)=>e+t.charCodeAt(0),0)%t.length]},[_,x,B]),P=e=>{if(!e.replies||0===e.replies.length)return 0;let t=e.replies.length;return e.replies.forEach(e=>{t+=P(e)}
2),t},L=(0,a.useMemo)(()=>{const e=new Map,n=[];return t.forEach(t=>{e.set(t.id,d(d({},t),{},{replies:[]}))}),t.forEach(t=>{if(t.parentCommentId){const n=e.get(t.parentCommentId);n&&n.replies&&n.replies.push(e.get(t.id))}else n.push(e.get(t.id))}),n},[t]),R=(0,a.useMemo)(()=>L.filter(e=>{const t=e.timestampSeconds;return null!==t&&void 0!==t&&(void 0===s||void 0===i||t>=s&&t<=i)}),[L,i,s]),z=(0,a.useMemo)(()=>{const e=[...R].sort((e,t)=>(e.timestampSeconds||0)-(t.timestampSeconds||0)),t=[];return e.forEach(e=>{const n=T(e.timestampSeconds||0);if(n<-20||n>f+dF)return;const a=t[t.length-1];if(a&&n-a.lastX<30){const t=a.comments.length+1;return a.comments.push(e),a.startTime=Math.min(a.startTime,e.timestampSeconds||0),a.endTime=Math.max(a.endTime,e.timestampSeconds||0),a.x=(a.x*(t-1)+n)/t,void(a.lastX=n)}t.push({id:e.id,comments:[e],x:n,lastX:n,startTime:e.timestampSeconds||0,endTime:e.timestampSeconds||0})}),t.map(e=>d(d({},e),{},{id:e.comments.length>1?"cluster-".concat(e.comments.map(e=>e.id).join("-")):e.id}))},[T,R,f]),O=(0,a.useMemo)(()=>{return e=uF,Math.min(Math.max(e,34),88);var e},[]),U=(0,a.useCallback)(e=>x?e?"0 0 16px 5px rgba(255, 181, 43, 0.62)":"0 0 12px 3px rgba(255, 181, 43, 0.42)":e?"0 0 16px 4px rgba(255, 181, 43, 0.34)":"0 0 10px 2px rgba(255, 181, 43, 0.18)",[x]),V=(0,a.useCallback)(e=>x?e?"0 0 16px 5px rgba(255, 181, 43, 0.62)":"0 0 10px 3px rgba(255, 181, 43, 0.36)":e?"0 0 16px 4px rgba(255, 181, 43, 0.32)":"0 0 10px 2px rgba(255, 181, 43, 0.16)",[x]),H=(0,a.useMemo)(()=>x?{backgroundColor:"#FFB52B",color:"#232E3F",borderColor:"rgba(255, 249, 236, 0.38)"}:{backgroundColor:"rgba(255, 187, 61, 0.96)",color:"#24354c",borderColor:"rgba(146, 102, 26, 0.26)"},[x]),q=(0,a.useMemo)(()=>x?{backgroundColor:"#FFB52B",color:"#232E3F",borderColor:"rgba(255, 249, 236, 0.38)"}:{backgroundColor:"rgba(255, 187, 61, 0.94)",color:"#24354c",borderColor:"rgba(146, 102, 26, 0.24)"},[x]);(0,a.useEffect)(()=>{null===y||void 0===y||y(O)},[O,y]),(0,a.useEffect)(()=>{const e=e=>{w.current&&!w.current.contains(e.target)&&A(null)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const W=(0,a.useMemo)(()=>((e,t)=>Math.min(Math.max(e,0),t))(T(r),f),[r,T,f]),Y=((0,a.useCallback)(()=>{j(!0),C("".concat(Iw(r)," - "))},[r]),(0,a.useCallback)(async()=>{if(D.trim()&&!N){F(!0);try{await l(D,r),C(""),j(!1)}catch(e){console.error("Failed to add comment:",e)}finally{F(!1)}}},[D,r,l,N]),e=>{const t=String(e.content||"").replace(/\s+/g," ").trim();return t.length>96?"".concat(t.slice(0,96),"..."):t}),G=x?"border border-white/10 bg-[rgba(17,27,42,0.58)] text-[#F4F4F4] shadow-[0_24px_52px_-30px_rgba(0,0,0,0.66)] backdrop-blur-[28px]":"border border-[rgba(215,222,233,0.86)] bg-[rgba(255,255,255,0.52)] text-[#172033] shadow-[0_20px_48px_-28px_rgba(15,23,42,0.16)] backdrop-blur-[28px]",K=x?"text-[#ffcf74] border-white/10":"text-[#8d5a00] border-[#e5ebf2]",X=x?"text-[#d9e2f1]":"text-[#55657d]",J=x?"bg-black/20 text-[#ffe2a6]":"bg-[rgba(255,255,255,0.56)] text-[#8d5a00]",$=x?"rgba(17,27,42,0.58)":"rgba(255,255,255,0.52)";return(0,u.jsxs)("div",{ref:w,className:"relative overflow-visible rounded-xl ".concat(x?"bg-[#1d2636]":"bg-[#ecedf0]"),style:{width:f,height:O,backgroundImage:x?"radial-gradient(circle at 12% 18%, rgba(255,181,43,0.10), transparent 22%), radial-gradient(circle at 86% 16%, rgba(111,137,182,0.08), transparent 22%), radial-gradient(circle at 26% 84%, rgba(80,112,166,0.08), transparent 24%), radial-gradient(circle at 92% 82%, rgba(245,158,11,0.05), transparent 18%)":"radial-gradient(circle at 12% 18%, rgba(255,181,43,0.12), transparent 22%), radial-gradient(circle at 86% 16%, rgba(111,137,182,0.08), transparent 22%), radial-gradient(circle at 26% 84%, rgba(80,112,166,0.07), transparent 24%), radial-gradient(circle at 92% 82%, rgba(245,158,11,0.04), transparent 18%)"},children:[(0,u.jsx)("div",{className:"absolute inset-0 opacity-60 ".concat(x?"bg-[#253146]":"bg-white/70")}),l&&(0,u.jsx)(Do.button,{className:"absolute z-30 flex items-center justify-center rounded-full border shadow-lg transition-colors",style:d({left:"".concat(W-10,"px"),top:"".concat(O/2-10,"px"),width:"".concat(dF,"px"),height:"".concat(dF,"px")},H),onClick:()=>l("",r),title:"Add comment at ".concat(Iw(r)),whileHover:{scale:1.1},whileTap:{scale:.95},children:(0,u.jsx)(ik,{size:12})}),(0,u.jsx)(S,{children:z.map(e=>{const t=e.comments.length>1,n=E===e.id,a=e.comments.some(e=>e.id===g),r=(s=e.x)<140?{containerClassName:"left-0",arrowClassName:"left-5"}:s>f-140?{containerClassName:"right-0",arrowClassName:"right-5"}:{containerClassName:"left-1/2 -translate-x-1/2",arrowClassName:"left-1/2 -translate-x-1/2"};var s;if(!t){const t=e.comments[0],n=t.avatarColor?null:I(t.displayName||t.userName||t.userEmail);return(0,u.jsxs)(Do.div,{"data-timeline-pan-ignore":"true",initial:{scale:0,opacity:0}
2,animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.1},className:"absolute cursor-pointer z-20 hover:z-40 group",style:{left:"".concat(e.x-10,"px"),top:"".concat(O/2-10,"px")},onClick:()=>null===p||void 0===p?void 0:p(t.id),children:[(0,u.jsx)("div",{className:"flex h-5 w-5 items-center justify-center rounded-full border text-[9px] font-semibold leading-none tracking-[0.06em] ".concat(a?"ring-2 ring-[#ffcf74] ring-offset-[1px] ring-offset-transparent":x?"ring-1 ring-white/25":"ring-1 ring-black/10"),style:d(d({},t.avatarColor?{backgroundColor:t.avatarColor,color:"#f8fbff",borderColor:x?"rgba(255,255,255,0.22)":"rgba(35,46,63,0.16)"}:{backgroundColor:null===n||void 0===n?void 0:n.background,color:null===n||void 0===n?void 0:n.color,borderColor:null===n||void 0===n?void 0:n.border}),{},{fontFamily:"var(--font-headlines)",boxShadow:U(a)}),children:t.displayName||t.userName?M(t.displayName||t.userName):t.userEmail.includes("@")&&"Anonymous"!==t.userEmail?M(t.userEmail):(0,u.jsx)(vh,{size:11})}),t.replies&&t.replies.length>0&&(0,u.jsx)("div",{className:"absolute -bottom-1 -right-1 flex h-3.5 w-3.5 items-center justify-center rounded-full border border-white/70 bg-[rgba(35,46,63,0.92)] text-[9px] font-semibold text-[#FFCF74] shadow-[0_0_8px_1px_rgba(255,181,43,0.26)] backdrop-blur-sm",children:P(t)}),(0,u.jsx)("div",{className:"absolute bottom-full left-1/2 z-20 mb-2 -translate-x-1/2 transform pointer-events-none opacity-0 transition-opacity duration-200 group-hover:opacity-100",children:(0,u.jsxs)("div",{className:"".concat(G," rounded-lg px-4 py-3 text-sm whitespace-normal"),style:{minWidth:"300px",maxWidth:"450px"},children:[(0,u.jsx)("div",{className:"mb-1 text-xs font-semibold font-headlines",children:t.displayName||t.userName||t.userEmail}),(0,u.jsx)("div",{className:"text-xs leading-5",children:(0,u.jsx)(my,{components:{p:e=>{let{children:t}=e;return(0,u.jsx)("p",{className:"mb-0",children:t})},strong:e=>{let{children:t}=e;return(0,u.jsx)("strong",{className:"font-bold",children:t})},em:e=>{let{children:t}=e;return(0,u.jsx)("em",{className:"italic",children:t})},code:e=>{let{children:t}=e;return(0,u.jsx)("code",{className:"".concat(J," rounded px-1 text-xs"),children:t})}},children:t.content.length>100?"".concat(t.content.slice(0,100),"..."):t.content})}),(0,u.jsx)("div",{className:"mt-2 text-[11px] ".concat(X),children:Iw(t.timestampSeconds||0)}),(0,u.jsx)("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 -mt-px",children:(0,u.jsx)("div",{className:"w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px]",style:{borderTopColor:$}})})]})})]},e.id)}return(0,u.jsxs)(Do.div,{"data-timeline-pan-ignore":"true",initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.04},className:"absolute z-20 hover:z-40",style:{left:"".concat(e.x-15,"px"),top:"".concat(O/2-10,"px")},children:[(0,u.jsxs)("button",{type:"button",onClick:()=>A(t=>t===e.id?null:e.id),className:"flex h-5 min-w-[30px] items-center justify-center gap-1 rounded-full border px-1.5 text-[10px] font-semibold transition-colors ".concat(a?"ring-2 ring-[#ffcf74] ring-offset-[1px] ring-offset-transparent":x?"ring-1 ring-white/25":"ring-1 ring-black/10"),style:d(d({},q),{},{boxShadow:V(a),fontFamily:"var(--font-headlines)"}),title:"".concat(e.comments.length," nearby comments"),children:[(0,u.jsx)(ky,{size:12}),(0,u.jsx)("span",{children:e.comments.length})]}),n&&(0,u.jsxs)("div",{className:"absolute bottom-full mb-3 w-80 ".concat(r.containerClassName),children:[(0,u.jsxs)("div",{className:"".concat(G," rounded-xl"),children:[(0,u.jsxs)("div",{className:"border-b px-3 py-2 text-xs font-semibold uppercase tracking-wide ".concat(K),children:[e.comments.length," comments nearby"]}),(0,u.jsx)("div",{className:"max-h-72 overflow-y-auto p-2",children:e.comments.map(e=>{const t=P(e);return(0,u.jsxs)("button",{type:"button",onClick:()=>{null===p||void 0===p||p(e.id),A(null)},className:"mb-2 w-full rounded-lg border px-3 py-2 text-left transition-colors last:mb-0 ".concat(g===e.id?x?"border-[#ffcf74] bg-white/10":"border-[#efc15c]/45 bg-[rgba(255,245,220,0.62)]":x?"border-white/10 hover:bg-white/5":"border-[rgba(215,222,233,0.72)] hover:bg-[rgba(255,255,255,0.46)]"),children:[(0,u.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-3",children:[(0,u.jsx)("span",{className:"truncate text-xs font-semibold font-headlines",children:e.displayName||e.userName||e.userEmail}),(0,u.jsx)("span",{className:"shrink-0 text-[11px] ".concat(X),children:Iw(e.timestampSeconds||0)})]}),(0,u.jsx)("div",{className:"text-xs leading-5 ".concat(X),children:Y(e)||"Open comment"}),t>0&&(0,u.jsxs)("div",{className:"mt-2 inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold ".concat(x?"bg-white/10 text-[#ffcf74]":"bg-[rgba(255,245,220,0.62)] text-[#8d5a00]"),children:[(0,u.jsx)(Nw,{size:10}),(0,u.jsxs)("span",{children:[t," repl",1===t?"y":"ies"]})]})]},e.id)})})]}),(0,u.jsx)("div",{className:"absolute top-full -mt-px ".concat(r.arrowClassName),children:(0,u.jsx)("div",{className:"h-0 w-0 border-l-[6px] border-r-[6px] border-t-[6px] border-l-transparent border-r-transparent",style:{borderTopColor:$}})})]})]},e.id)})}),(0,u.jsx)(S,{children:!1})]})},hF=Mo("beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}
2]]),pF=Mo("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),gF=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return t>0?"".concat(t,":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")):"".concat(n,":").concat(a.toString().padStart(2,"0"))},xF=e=>{let{time:t,x:n,y:a,isDarkMode:r,label:s}=e;const i=(0,u.jsxs)("div",{className:"fixed z-[9999] pointer-events-none",style:{left:n,top:a-36,transform:"translateX(-50%)"},children:[(0,u.jsxs)("div",{className:"px-2.5 py-1.5 rounded-md text-xs font-mono shadow-lg ".concat(r?"bg-gray-800 text-white border border-gray-700":"bg-gray-900 text-white"),children:[s&&(0,u.jsxs)("span",{className:"text-pink-400 mr-1.5",children:[s,":"]}),(0,u.jsx)("span",{className:"font-semibold",children:gF(t)})]}),(0,u.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2 -bottom-1.5",style:{width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderTop:r?"6px solid rgb(31, 41, 55)":"6px solid rgb(17, 24, 39)"}})]});return(0,mk.createPortal)(i,document.body)},fF=20,bF=e=>{const t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0,n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0")):"".concat(a,":").concat(r.toString().padStart(2,"0"))},yF=e=>{var t,n,a;const r=(null===(t=e.url)||void 0===t?void 0:t.toLowerCase())||"",s=(null===(n=e.category)||void 0===n?void 0:n.toLowerCase())||"",i=(null===(a=e.title)||void 0===a?void 0:a.toLowerCase())||"";return r.includes("arxiv")||r.includes("doi.org")||s.includes("paper")?(0,u.jsx)(gp,{size:10}):r.includes("amazon")||s.includes("book")?(0,u.jsx)(Ap,{size:10}):r.includes("youtube")||s.includes("mlst")||s.includes("video")?(0,u.jsx)(Ep,{size:10}):s.includes("person")||null!==i&&void 0!==i&&i.match(/\b(Dr\.?|Prof\.?|Professor)\b/i)?(0,u.jsx)(vh,{size:10}):s.includes("research")||s.includes("experiment")?(0,u.jsx)(hF,{size:10}):(0,u.jsx)(pF,{size:10})},vF=e=>{let{references:t,duration:n,width:r,isDarkMode:s,showEditorialVisualSuggestion:i=!0,viewportStart:o,viewportEnd:l,timeToX:c,xToTime:d,onSelectReference:m,selectedReferenceId:h,currentTime:p=0,onAddReference:g,canEdit:x=!1,onDragStart:f,onDragMove:b,onDragEnd:y}=e;const[v,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)(null),[D,C]=(0,a.useState)(null),[N,F]=(0,a.useState)(0),[E,A]=(0,a.useState)(0),[T,M]=(0,a.useState)({x:0,y:0}),_=(0,a.useRef)(null),B=(0,a.useRef)(null),I=(0,a.useCallback)(e=>{j(null),null===m||void 0===m||m(e)},[m]),P=(0,a.useCallback)(e=>c?c(e):n<=0||r<=0?0:e/n*r,[n,c,r]),L=(0,a.useCallback)(e=>{const t=Math.max(10,Math.min(r-10,e));return d?d(t):Math.max(0,Math.min(n,t/r*n))},[n,r,d]),R=(0,a.useCallback)(e=>{if(!D||!_.current||!B.current)return;if(B.current.pointerId!==e.pointerId)return;const t=_.current.getBoundingClientRect(),n=e.clientX-t.left,a=Math.max(10,Math.min(r-10,n)),s=L(a);F(a),A(s),M({x:e.clientX,y:t.top}),null===b||void 0===b||b(D,s)},[D,b,L,r]),z=(0,a.useCallback)(e=>{B.current&&B.current.pointerId!==e.pointerId||D&&(null===y||void 0===y||y(D,E),C(null),B.current=null)},[D,E,y]);(0,a.useEffect)(()=>{if(D)return document.addEventListener("pointermove",R),document.addEventListener("pointerup",z),document.addEventListener("pointercancel",z),()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",z),document.removeEventListener("pointercancel",z)}},[D,R,z]),(0,a.useEffect)(()=>{if(!k)return;const e=e=>{var t;null!==(t=_.current)&&void 0!==t&&t.contains(e.target)||j(null)},t=e=>{"Escape"===e.key&&j(null)};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[k]);const O=(0,a.useMemo)(()=>Math.max(10,Math.min(r-10,P(p))),[p,P]),U=(0,a.useMemo)(()=>t.length&&0!==r?[...t].filter(e=>void 0===o||void 0===l||e.end>=o&&e.start<=l).sort((e,t)=>
2e.start-t.start):[],[t,l,o,r]),V=(0,a.useMemo)(()=>{if(!U.length||0===r)return[];if(x)return U.map(e=>({type:"reference",reference:e,x:P(e.start)}));const e=U.map(e=>({reference:e,x:P(e.start)})),t=[];let n=[];const a=()=>{if(0!==n.length){if(1===n.length)t.push({type:"reference",reference:n[0].reference,x:n[0].x});else{const e=n.reduce((e,t)=>e+t.x,0)/n.length;t.push({type:"cluster",id:"cluster:".concat(n.map(e=>{let{reference:t}=e;return t.id}).join("|")),references:n.map(e=>{let{reference:t}=e;return t}),x:Math.max(14,Math.min(r-14,e))})}n=[]}};return e.forEach(e=>{if(0===n.length)return void(n=[e]);const t=n[n.length-1];e.x-t.x<24?n.push(e):(a(),n=[e])}),a(),t},[x,P,U,r]);(0,a.useEffect)(()=>{if(!k)return;V.some(e=>"cluster"===e.type&&e.id===k)||j(null)},[k,V]);const H=(0,a.useMemo)(()=>!(!x||!g)&&V.some(e=>{const t=(("cluster"===e.type?28:fF)+fF)/2+6;return Math.abs(e.x-O)<t}),[O,x,g,V]),q=s?"bg-[rgba(17,27,42,0.52)] text-[#F4F4F4] border border-white/10 shadow-[0_24px_52px_-30px_rgba(0,0,0,0.58)] backdrop-blur-[32px]":"bg-[rgba(255,255,255,0.52)] text-[#172033] border border-[rgba(215,222,233,0.86)] shadow-[0_20px_48px_-28px_rgba(15,23,42,0.16)] backdrop-blur-[28px]",W=s?"text-[#ffcf74] border-white/10":"text-[#8d5a00] border-[#e5ebf2]",Y=s?"text-[#d9e2f1]":"text-[#55657d]",G=s?"border-[#ffcf74]/30 bg-[#ffcf74]/10 text-[#ffe7ad]":"border-[#efc15c]/45 bg-[#fff6dd] text-[#8d5a00]",K=s?"border-[#ffcf74]/25 bg-[#ffcf74]/10 text-[#ffe7ad]":"border-[#d8b25b] bg-[#ffe9af] text-[#5f4308]",X=s?"text-[#ffcf74] border-white/10":"text-[#946200] border-[#e5ebf2]",J=s?"rgba(17,27,42,0.52)":"rgba(255,255,255,0.52)";return 0!==V.length||x?(0,u.jsxs)("div",{ref:_,className:"relative",style:{width:r,height:28,marginTop:4,cursor:D?"grabbing":void 0,touchAction:x?"none":"auto"},children:[x&&g&&n>0&&!H&&(0,u.jsxs)(Do.div,{"data-timeline-pan-ignore":"true",className:"absolute cursor-pointer z-30",style:{left:"".concat(Math.max(0,Math.min(r-fF,O-10)),"px"),top:"4px"},initial:{scale:0,opacity:0},animate:{scale:v?1.15:1,opacity:1},whileTap:{scale:.95},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),onClick:()=>{j(null),g(p)},children:[(0,u.jsx)("div",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[#232E3F] shadow-lg transition-all ring-1 ring-white/50",style:{backgroundColor:"#FFB52B",boxShadow:v?"0 0 12px 4px rgba(255, 181, 43, 0.5)":"0 0 8px 2px rgba(255, 181, 43, 0.32)"},children:(0,u.jsx)(ik,{size:12,strokeWidth:3})}),v&&(0,u.jsx)("div",{className:"absolute bottom-full mb-2 left-1/2 transform -translate-x-1/2 pointer-events-none z-50",children:(0,u.jsxs)("div",{className:"".concat(s?"bg-gray-800":"bg-gray-900"," text-white rounded-lg px-3 py-2 text-sm shadow-lg whitespace-nowrap"),children:["Add reference at current time",(0,u.jsx)("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 -mt-px",children:(0,u.jsx)("div",{className:"w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px]",style:{borderTopColor:s?"#1f2937":"#111827"}})})]})})]}),(0,u.jsx)(S,{children:V.map(e=>{if("cluster"===e.type){const t=e.references.length>99?"99+":String(e.references.length),n=k===e.id,a=e.references.some(e=>e.id===h),o=e.references.some(e=>!!e.url),l=e.references.some(e=>i&&!!e.visualSuggestion||!!e.attachedVisualCount),c=e.x<120,d=e.x>r-120;return(0,u.jsxs)(Do.div,{"data-timeline-pan-ignore":"true",initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},whileHover:{scale:1.05},className:"absolute z-20 hover:z-40",style:{left:"".concat(e.x-14,"px"),top:"4px",userSelect:"none"},children:[(0,u.jsx)("button",{type:"button",className:"\n w-7 h-5 rounded-full flex items-center justify-center text-[#232E3F] shadow-lg transition-all\n ".concat(a?"ring-2 ring-[#ffcf74] ring-offset-1":"","\n "),style:{backgroundColor:"#FFB52B",boxShadow:o?l?"0 0 14px 4px rgba(255, 181, 43, 0.52)":"0 0 10px 3px rgba(255, 181, 43, 0.45)":l?"0 0 10px 3px rgba(255, 181, 43, 0.38)":"0 0 4px rgba(255, 181, 43, 0.28)",opacity:o?1:.8},onClick:t=>{t.stopPropagation(),j(t=>t===e.id?null:e.id)},children:(0,u.jsx)("span",{className:"text-[10px] font-semibold leading-none",children:t})}),(0,u.jsx)(S,{children:n&&(0,u.jsxs)(Do.div,{initial:{opacity:0,y:4,scale:.96}
2,animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,scale:.96},transition:{duration:.14},className:"\n absolute bottom-full mb-2 z-50\n ".concat(c?"left-0":d?"right-0":"left-1/2 -translate-x-1/2","\n "),style:{width:240},children:[(0,u.jsxs)("div",{className:"".concat(q," rounded-lg overflow-hidden"),children:[(0,u.jsxs)("div",{className:"px-3 py-2 text-[11px] uppercase tracking-wide border-b ".concat(W),children:[e.references.length," references"]}),(0,u.jsx)("div",{className:"max-h-64 overflow-y-auto py-1",children:e.references.map(e=>{const t=h===e.id;return(0,u.jsx)("button",{type:"button",className:"\n w-full text-left px-3 py-2 transition-colors\n ".concat(t?s?"bg-yellow-400/10":"bg-[#fff4d6]":s?"hover:bg-white/5":"hover:bg-[#f5f8fc]","\n "),onClick:t=>{t.stopPropagation(),I(e)},children:(0,u.jsxs)("div",{className:"flex items-start gap-2",children:[(0,u.jsx)("div",{className:"mt-0.5 text-[#ffcf74]",children:yF(e)}),(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsx)("div",{className:"text-sm font-medium truncate",children:e.title||e.linkText||"Untitled reference"}),(0,u.jsxs)("div",{className:"text-[11px] mt-0.5 ".concat(s?"opacity-70":"text-[#66768b]"),children:[bF(e.start),e.category?" \u2022 ".concat(e.category):""]}),(i&&e.visualSuggestion||e.attachedVisualCount)&&(0,u.jsxs)("div",{className:"mt-1 inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] ".concat(G),children:[(0,u.jsx)(Cp,{size:10}),e.attachedVisualCount?"".concat(e.attachedVisualCount," asset").concat(1===e.attachedVisualCount?"":"s"):"Visual"]}),e.linkText&&e.linkText!==e.title&&(0,u.jsx)("div",{className:"text-[11px] truncate mt-0.5 ".concat(Y),children:e.linkText})]}),e.url&&(0,u.jsx)("span",{className:"text-[#ffe2a6] mt-0.5",children:(0,u.jsx)(Ep,{size:11})})]})},e.id)})})]}),(0,u.jsx)("div",{className:"absolute top-full -mt-px ".concat(c?"left-3":d?"right-3":"left-1/2 transform -translate-x-1/2"),children:(0,u.jsx)("div",{className:"w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px]",style:{borderTopColor:J}})})]})})]},e.id)}const{reference:t,x:n}=e,a=!!t.url,o=i&&!!t.visualSuggestion||!!t.attachedVisualCount,l=(e=>{const t=(e.attachedVisualPlacements||[]).map(e=>({id:e.id,previewUrl:Dm(e)||""})).filter(e=>e.previewUrl);return t.length>0?t.slice(0,3):e.attachedVisualPreviewUrl?[{id:"".concat(e.id,":preview"),previewUrl:e.attachedVisualPreviewUrl}]:[]})(t),c=(t.attachedVisualPlacements||[]).map(e=>{const n=Number.isFinite(e.displayEnd)&&Number.isFinite(e.displayStart)?Math.max(t.start,e.displayStart):null,a=Number.isFinite(e.displayEnd)?e.displayEnd:null;return null==n||null==a||a<=n?null:{start:n,end:a}}).filter(e=>null!=e).sort((e,t)=>e.start-t.start).reduce((e,t)=>{const n=e[e.length-1];return n&&t.start<=n.end+.1?(n.end=Math.max(n.end,t.end),e):(e.push(t),e)},[]),d=h===t.id,m=(null===D||void 0===D?void 0:D.id)===t.id,p=m?N:n,g=c.map(e=>{const t=Math.max(p+10,Math.min(r,P(e.start))),n=Math.max(t,Math.min(r,P(e.end))),a=Math.max(0,n-t);return a<=0?null:{left:t-p+10,width:a}}).filter(e=>null!=e);let b="center",y="-translate-x-1/2";return p<137?(b="left",y="translate-x-0"):p>r-137&&(b="right",y="-translate-x-full"),(0,u.jsxs)(Do.div,{"data-timeline-pan-ignore":"true",initial:{scale:0,opacity:0},animate:{scale:m?1.2:1,opacity:1},exit:{scale:0,opacity:0},whileHover:m?void 0:{scale:1.15},className:"absolute z-20 hover:z-40 group ".concat(x?"cursor-grab":"cursor-pointer"," ").concat(m?"cursor-grabbing z-40":""),style:{left:"".concat(p-10,"px"),top:"4px",userSelect:"none"},onClick:()=>{m||I(t)},onPointerDown:e=>{x&&((e,t,n)=>{var a;if(!x)return;e.preventDefault(),e.stopPropagation();const r=null===(a=_.current)||void 0===a?void 0:a.getBoundingClientRect();r&&(C(t),F(n),A(t.start),M({x:e.clientX,y:r.top}),B.current={pointerId:e.pointerId,refX:n},null===f||void 0===f||f(t))})(e,t,n)},children:[o&&g.map((e,n)=>(0,u.jsx)("div",{className:"pointer-events-none absolute top-1/2 -translate-y-1/2 roun
2ded-full",style:{left:"".concat(e.left,"px"),width:"".concat(e.width,"px"),height:"3px",background:"linear-gradient(90deg, rgba(255,181,43,0.95) 0%, rgba(255,207,116,0.72) 68%, rgba(255,207,116,0.18) 100%)",boxShadow:"0 0 10px 1px rgba(255, 181, 43, 0.28)",opacity:m?.72:.95}},"".concat(t.id,"-visual-rail-").concat(n,"-").concat(e.left))),(0,u.jsx)("div",{className:"\n w-5 h-5 rounded-full flex items-center justify-center text-[#232E3F] shadow-lg transition-all\n ".concat(d?"ring-2 ring-[#ffcf74] ring-offset-1":"","\n ").concat(a?"ring-1 ring-white/30":"","\n ").concat(o?"ring-2 ring-[#ffe3a1]/50 ring-offset-[1px]":"","\n ").concat(m?"ring-2 ring-white ring-offset-1":"","\n "),style:{backgroundColor:"#FFB52B",boxShadow:m?"0 0 16px 6px rgba(255, 181, 43, 0.65)":o?"0 0 14px 4px rgba(255, 181, 43, 0.5)":a?"0 0 10px 3px rgba(255, 181, 43, 0.42)":"0 0 4px rgba(255, 181, 43, 0.24)",opacity:a||m?1:.6},children:yF(t)}),!m&&(0,u.jsx)("div",{className:"\n absolute bottom-full mb-2\n ".concat("left"===b?"left-0":"right"===b?"right-0":"left-1/2","\n transform ").concat(y,"\n pointer-events-none opacity-0 group-hover:opacity-100\n transition-opacity duration-200 z-50\n "),children:(0,u.jsxs)("div",{className:"".concat(q," rounded-lg px-3 py-2 text-sm"),style:{minWidth:"200px",maxWidth:"350px"},children:[l.length>0&&(0,u.jsxs)("div",{className:"mb-2 flex gap-1.5",children:[l.map((e,n)=>(0,u.jsx)("div",{className:"relative flex-1 overflow-hidden rounded-md border border-white/10 bg-white/5",children:(0,u.jsx)("img",{src:e.previewUrl,alt:t.attachedVisualLabel||t.title||"Reference visual preview",className:"h-20 w-full object-cover ".concat(n>0?"opacity-90":""),loading:"lazy"})},e.id)),(t.attachedVisualCount||0)>l.length&&(0,u.jsxs)("div",{className:"flex w-12 flex-shrink-0 items-center justify-center rounded-md border text-[11px] font-semibold ".concat(s?"border-white/10 bg-white/8 text-[#ffe7ad]":"border-[#ead49a] bg-[#fff8e8] text-[#8d5a00]"),children:["+",(t.attachedVisualCount||0)-l.length]})]}),(0,u.jsxs)("div",{className:"font-semibold text-xs mb-1 flex items-center gap-1.5",children:[a&&(0,u.jsx)("span",{className:"text-[#ffcf74]",children:(0,u.jsx)(pF,{size:12})}),t.title]}),t.category&&(0,u.jsx)("div",{className:"text-xs mb-1 ".concat(s?"text-[#d7ba7a]":"text-[#8d5a00]"),children:t.category}),t.context&&(0,u.jsx)("div",{className:"text-xs opacity-80 mb-1",children:t.context.length>100?t.context.slice(0,100)+"...":t.context}),(i&&t.visualSuggestion||t.attachedVisualCount)&&(0,u.jsxs)("div",{className:"mt-2 rounded-md border px-2 py-1.5 text-xs ".concat(K),children:[(0,u.jsxs)("div",{className:"mb-0.5 flex items-center gap-1 font-semibold uppercase tracking-[0.12em]",children:[(0,u.jsx)(Cp,{size:10}),t.attachedVisualCount?"Attached assets":"Visual"]}),t.attachedVisualCount?t.attachedVisualLabel||"".concat(t.attachedVisualCount," attached asset").concat(1===t.attachedVisualCount?"":"s"):(t.visualSuggestion||"").length>110?"".concat((t.visualSuggestion||"").slice(0,110),"..."):t.visualSuggestion]}),a&&t.linkText&&(0,u.jsxs)("div",{className:"text-xs flex items-center gap-1 mt-1 ".concat(Y),children:[(0,u.jsx)(Ep,{size:10}),t.linkText]}),x&&(0,u.jsx)("div",{className:"text-xs mt-2 pt-1 border-t ".concat(X),children:"Drag to reposition"}),(0,u.jsx)("div",{className:"absolute top-full -mt-px ".concat("left"===b?"left-3":"right"===b?"right-3":"left-1/2 transform -translate-x-1/2"),children:(0,u.jsx)("div",{className:"w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px]",style:{borderTopColor:J}})})]})})]},t.id)})}),D&&(0,u.jsx)(xF,{time:E,x:T.x,y:T.y,isDarkMode:s})]}):null},wF=e=>{const{currentTime:t}=Jw();return(0,u.jsx)(vF,d(d({},e),{},{currentTime:t}))},kF="/api/v1";class jF extends Error{constructor(e){var t,n,a,r,s;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e),this.code=void 0,this.status=void 0,this.conflicts=void 0,this.canOverride=void 0,this.currentVersionId=void 0,this.name="ArrangementMutationError",this.co
2de=null!==(t=i.code)&&void 0!==t?t:null,this.status=null!==(n=i.status)&&void 0!==n?n:0,this.conflicts=null!==(a=i.conflicts)&&void 0!==a?a:null,this.canOverride=null!==(r=i.canOverride)&&void 0!==r&&r,this.currentVersionId=null!==(s=i.currentVersionId)&&void 0!==s?s:null}}function DF(e){const t={"Content-Type":"application/json"};return e&&(t.Authorization="Bearer ".concat(e)),t}async function CF(e){const t=await e.json().catch(()=>({}));return new jF(t.message||t.error||"HTTP ".concat(e.status),{code:t.code||null,status:e.status,conflicts:t.conflicts||null,canOverride:!0===t.canOverride,currentVersionId:t.currentVersionId||null})}const NF=1e6,FF={ok:!0,code:null,message:"",blockers:[]};function SF(e){const t=Number(e);return Number.isFinite(t)?Math.round(t*NF):NaN}function EF(e){return e/NF}function AF(e,t){return{ok:!1,code:e,message:t,blockers:arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]}}function TF(e){return e.clipCode||e.clipId.slice(0,8)}function MF(e){if(!Number.isFinite(e))return"--:--";const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60,s=e=>String(e).padStart(2,"0");return n>0?"".concat(n,":").concat(s(a),":").concat(s(r)):"".concat(a,":").concat(s(r))}function _F(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const a=SF(e),r=SF(t);if(!Number.isFinite(a)||!Number.isFinite(r)||r<=a)return[];const s=(Array.isArray(n)?n:[]).map(e=>{var t,n;const s=null!==(t=null===e||void 0===e?void 0:e.start_time)&&void 0!==t?t:null===e||void 0===e?void 0:e.start,i=null!==(n=null===e||void 0===e?void 0:e.end_time)&&void 0!==n?n:null===e||void 0===e?void 0:e.end,o=SF(s),l=SF(i);if(!Number.isFinite(o)||!Number.isFinite(l))return null;const c=Math.max(a,Math.min(o,r)),d=Math.max(a,Math.min(l,r));return d<=c?null:{start:c,end:d}}).filter(e=>null!==e).sort((e,t)=>e.start-t.start||e.end-t.end),i=[];for(const c of s){const e=i[i.length-1];!e||c.start>e.end?i.push(d({},c)):e.end=Math.max(e.end,c.end)}const o=[];let l=a;for(const c of i)c.start>l&&o.push({start:EF(l),end:EF(c.start)}),l=Math.max(l,c.end);return r>l&&o.push({start:EF(l),end:EF(r)}),o}function BF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=new Set(arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]),a=[];for(const r of e)if(!n.has(r.id)&&"cut"!==r.status)for(const e of _F(r.startTime,r.endTime,r.deletedSpans))a.push(d({clipId:r.id,clipCode:r.clipCode},e));for(const r of t)n.has(r.clipId)||a.push(r);return a.sort((e,t)=>e.start-t.start||e.end-t.end)}function IF(e,t){return SF(Math.max(e.start,t.start))<SF(Math.min(e.end,t.end))}function PF(e,t){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const a=BF(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],[e.id]);let r=0,s=null,i=Number.isFinite(n)&&n>0?n:Number.POSITIVE_INFINITY,o=i!==Number.POSITIVE_INFINITY,l=null;for(const c of a)c.end<=e.startTime&&c.end>r&&(r=c.end,s={clipId:c.clipId,clipCode:c.clipCode,start:c.start,end:c.end}),c.start>=e.endTime&&c.start<i&&(i=c.start,l={clipId:c.clipId,clipCode:c.clipCode,start:c.start,end:c.end},o=!1);return{minStart:r,maxEnd:i,blockedStartBy:s,blockedEndBy:l,startLimitedBySession:null===s,endLimitedBySession:o}}function LF(e,t,n,a){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;if(!Number.isFinite(t)||!Number.isFinite(n)||SF(n)<=SF(t))return AF("CLIP_EMPTY","A clip needs a positive duration \u2014 the end must sit after the start.");if(SF(t)<0)return AF("OUT_OF_SESSION_BOUNDS","A clip cannot start before the beginning of the session.");if(Number.isFinite(s)&&s>0&&SF(n)>SF(s))return AF("OUT_OF_SESSION_BOUNDS","A clip cannot run past the end of the session (".concat(MF(s),")."));const i=_F(t,n,e.deletedSpans);if(0===i.length)return AF("CLIP_EMPTY","Nothing would be left of this clip \u2014 its deleted spans cover the whole range.");const o=BF(a,r,[e.id]),l=_F(e.startTime,e.endTime,e.deletedSpans),c=new Set(o.filter(e=>l.some(t=>IF(t,e))).map(e=>e.clipId)),d=[];
2for(const u of o)c.has(u.clipId)||i.some(e=>IF(e,u))&&(d.some(e=>e.clipId===u.clipId)||d.push({clipId:u.clipId,clipCode:u.clipCode,start:u.start,end:u.end}));if(d.length>0){const e=d.map(TF).join(", ");return AF("SOURCE_REUSE_CONFLICT","This would overlap ".concat(1===d.length?"clip":"clips"," ").concat(e,". Every clip has to be a distinct piece of the source."),d)}return SF(t)===SF(e.startTime)&&SF(n)===SF(e.endTime)?AF("NO_CHANGE","Nothing moved."):FF}function RF(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;const r=LF({id:"__new__",clipCode:null,index:-1,sessionId:"",title:"",speaker:"",act:null,sequenceKey:null,status:"keep",startTime:0,endTime:0,placed:!0,position:null,deletedSpans:[],keepSpans:[],bindings:[]},e.start,e.end,t,n,a);return"NO_CHANGE"===r.code?FF:r}function zF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!e.placed)return AF("NO_CHANGE","This clip is already out of the cut.");if(0===t.length)return FF;const n=t.map(e=>e.clipCode||e.clipId.slice(0,8)),a=n.slice(0,4).join(", ");return AF("PLACEMENT_BLOCKED_BY_DEPENDENTS","".concat(t.length," placed clip").concat(1===t.length?"":"s"," (").concat(a).concat(n.length>4?", \u2026":"",") ")+"depend on this one. A binding says it must have played already, and an unplaced clip never plays. Take those out of the cut first, or drop the binding.",t.map(e=>({clipId:e.clipId,clipCode:e.clipCode})))}const OF=(0,a.createContext)(null),UF=[];function VF(e){return"arrangementOverlay_".concat(e)}const HF=e=>{var t;let{sessionId:n,token:r,isPublicView:s,children:i}=e;const o=Boolean(n&&r&&!s),[l,c]=(0,a.useState)([]),[m,h]=(0,a.useState)(!1),[p,g]=(0,a.useState)(null),[x,f]=(0,a.useState)(null),[b,y]=(0,a.useState)(null),[v,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)(null),[D,C]=(0,a.useState)(new Map),[N,F]=(0,a.useState)(null),[S,E]=(0,a.useState)(null),[A,T]=(0,a.useState)(null),[M,_]=(0,a.useState)(null),[B,I]=(0,a.useState)(null),[P,L]=(0,a.useState)(null),R=(0,a.useRef)(0);(0,a.useEffect)(()=>{if(o&&n)try{const e=window.localStorage.getItem(VF(n));f(e||null)}catch(e){f(null)}else f(null)},[o,n]);const z=(0,a.useCallback)(async()=>{if(o&&n){h(!0),g(null);try{const e=await async function(e,t){const n=await fetch("".concat(kF,"/session-arrangements/").concat(encodeURIComponent(e)),{headers:DF(t),credentials:"include"});if(!n.ok)throw await CF(n);return n.json()}(n,r);c(e.arrangements||[])}catch(e){c([]),g(e.message||"Could not load arrangements")}finally{h(!1)}}else c([])},[o,n,r]);(0,a.useEffect)(()=>{z()},[z]),(0,a.useEffect)(()=>{x&&0!==l.length&&(l.some(e=>e.id===x)||f(null))},[l,x]);const O=(0,a.useCallback)(async()=>{if(!o||!n||!x)return void y(null);const e=R.current+1;R.current=e,w(!0),j(null);try{const t=await async function(e,t,n){const a=await fetch("".concat(kF,"/session-arrangements/").concat(encodeURIComponent(e))+"/arrangements/".concat(encodeURIComponent(t)),{headers:DF(n),credentials:"include"});if(!a.ok)throw await CF(a);return a.json()}(n,x,r);if(R.current!==e)return;y(t)}catch(t){if(R.current!==e)return;y(null),j(t.message||"Could not load clips")}finally{R.current===e&&w(!1)}},[o,x,n,r]);(0,a.useEffect)(()=>{O()},[O]);const U=(0,a.useMemo)(()=>{var e;return(null===(e=l.find(e=>e.id===x))||void 0===e?void 0:e.previewToken)||null},[l,x]);(0,a.useEffect)(()=>{if(!o||!U)return void C(new Map);let e=!1;return async function(e,t){const n=await fetch("".concat("","/api/public/arrangement/").concat(encodeURIComponent(e),"/editorial-approvals"),{headers:DF(t),credentials:"include"});if(!n.ok)throw await CF(n);return n.json()}(U,r).then(t=>{e||C(new Map((t.clipPublicationApprovals||[]).map(e=>[e.subjectKey,e])))}).catch(t=>{e||(console.warn("[ARRANGEMENT-OVERLAY] Could not load clip publication approvals:",t),C(new Map))}),()=>{e=!0}},[o,U,r]);const V=(0,a.useCallback)(e=>{if(f(e),E(null),T(null),I(null),L(null),n)try{e?window.localStorage.setItem(VF(n),e):window.localStorage.removeItem(VF(n))}catch(t){}},[n]),H=(null===b||void 0===b?void 0:b.clips)||UF,q=(0,a.useMemo)(()=>(null===b||void 0===b?void 0:b.siblingSpans)||[],[b]),W=null!==(t=null===b||void 0===b?void 0:b.sessionDuration)&&void 0!==t?t:null,Y=(0,a.useMemo)(()=>{const e=new Map;
2for(const t of H)e.set(t.id,t);return e},[H]),G=(0,a.useMemo)(()=>b?function(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5;const a=BF(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],[]),r=Number.isFinite(t)&&t>0?t:a.reduce((e,t)=>Math.max(e,t.end),0),s=[];let i=0;for(const o of a)o.start>i&&s.push({start:i,end:Math.min(o.start,r)}),i=Math.max(i,o.end);return r>i&&s.push({start:i,end:r}),s.filter(e=>e.end-e.start>=n)}(H,q,W,.5):[],[H,b,W,q]),K=(0,a.useCallback)(e=>{const t=Y.get(e);return t?PF(t,H,q,W):null},[H,Y,W,q]),X=(0,a.useCallback)((e,t,n)=>{const a=Y.get(e);return a?LF(a,t,n,H,q,W):{ok:!1,code:null,message:"Clip is no longer in this arrangement.",blockers:[]}},[H,Y,W,q]),J=(0,a.useCallback)(e=>RF(e,H,q,W),[H,W,q]),$=(0,a.useCallback)(e=>{var t;const n=Y.get(e);return n?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n=[];if(t.length>0){const e=t.map(e=>e.clipCode||e.clipId.slice(0,8));n.push("".concat(t.length," clip").concat(1===t.length?"":"s"," (").concat(e.slice(0,4).join(", "))+"".concat(e.length>4?", \u2026":"",") have bindings pointing at this clip. Deleting it orphans them."))}return e.sequenceKey&&n.push('This clip belongs to sequence "'.concat(e.sequenceKey,'", which will lose a member.')),e.placed&&n.push("This clip is in the cut, so the arrangement gets shorter and downstream renders go stale."),{warnings:n,dependents:t}}(n,(null===b||void 0===b||null===(t=b.dependentsByClip)||void 0===t?void 0:t[e])||[]):null},[Y,b]),Q=(0,a.useCallback)(e=>{var t;const n=Y.get(e);return n?zF(n,(null===b||void 0===b||null===(t=b.dependentsByClip)||void 0===t?void 0:t[e])||[]):null},[Y,b]),Z=(0,a.useCallback)(()=>{I(null),L(null)},[]),ee=(0,a.useCallback)((e,t)=>{const n=Y.get(e);n&&(E(e),T({clipId:e,start:n.startTime,end:n.endTime,edge:t,verdict:{ok:!0,code:null,message:"",blockers:[]},blocked:!1}))},[Y]),te=(0,a.useCallback)((e,t,n)=>{const a=Y.get(e);if(!a)return null;const r=PF(a,H,q,W),s=function(e,t,n,a){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.05;const s=Number.isFinite(a.maxEnd)?a.maxEnd:n;let i=Math.max(a.minStart,t),o=Math.min(s,n);return o-i<r&&(t!==e.startTime?i=Math.min(i,o-r):o=Math.max(o,i+r)),{start:i,end:o,clampedStart:SF(i)!==SF(t),clampedEnd:SF(o)!==SF(n)}}(a,"start"===t?n:a.startTime,"end"===t?n:a.endTime,r),i=LF(a,s.start,s.end,H,q,W),o="start"===t?s.clampedStart:s.clampedEnd,l={clipId:e,start:s.start,end:s.end,edge:t,verdict:i,blocked:o};return T(l),l},[H,Y,W,q]),ne=(0,a.useCallback)(()=>T(null),[]),ae=(0,a.useCallback)(async(e,t,n,a)=>{if(!b)return!1;_(e),I(null),L(null);try{return await async function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=await fetch("".concat(kF,"/arrangements/").concat(encodeURIComponent(e),"/clips/mutate"),{method:"POST",headers:DF(a.token),credentials:"include",body:JSON.stringify(d(d({operations:t,change_summary:n},a.baseVersionId?{base_version_id:a.baseVersionId}:{}),{},{media_dispatch_priority:"interactive"}))});if(!r.ok)throw await CF(r);return r.json()}(b.arrangement.id,t,n,{token:r,baseVersionId:b.arrangement.activeVersionId}),await Promise.all([O(),z()]),L(a),!0}catch(s){const e=s;return I({code:e.code||null,message:e.message}),"INSERT_ANCHOR_STALE"===e.code&&await O(),!1}finally{_(null)}},[b,z,O,r]),re=(0,a.useCallback)(async(e,t,n)=>{const a=X(e,t,n);if(!a.ok)return"NO_CHANGE"!==a.code&&I({code:a.code,message:a.message}),!1;const r=Y.get(e),s=(null===r||void 0===r?void 0:r.clipCode)||e.slice(0,8);return ae(e,[{op:"update",clip_id:e,fields:{start_time:t,end_time:n}}],"Adjusted ".concat(s," boundaries from the session view"),"".concat(s," now runs ").concat((n-t).toFixed(1),"s."))},[Y,X,ae]),se=(0,a.useCallback)(async()=>{if(!A)return;const e=A;T(null),await re(e.clipId,e.start,e.end)},[re,A]),ie=(0,a.useCallback)(async e=>{const t=Y.get(e),n=(null===t||void 0===t?void 0:t.clipCode)||e.slice(0,8),a=await ae(e,[{op:"remove",clip_id:e}],"Removed ".concat(n," from the session view"),"".concat(n," removed from the cut."));return a&&S===e&&E(null),a},[Y,ae,S]),oe=(0,a.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!b||!n)return!1;const a=RF(e,H,q,W);return a.ok?ae(null,[{op:"insert",clip:{type:"session_clip",session_id:n,start_time:e.start,end_time:e.end,title:t.title||""}}],"Added a clip from the session view","Added a ".concat((e.end-e.start).toFixed(1),"s clip to ").concat(b.arrangement.title,".")):(I({code:a.code,message:a.message}),!1)},[H,b,ae,W,n,q]),le=(0,a.useCallback)(async e=>{if(!b)return!1;const t=Y.get(e);if(!t)return!1;const n=t.clipCode||e.slice(0,8);if(t.placed){var a;const n=zF(t,(null===(a=b.dependentsByClip)||void 0===a?void 0:a[e])||[]);if(!n.ok)return I({code:n.code,message:n.message}),!1}_(e),I(null),L(null);try{return await async function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=await fetch("".concat(kF,"/arrangements/").concat(encodeURIComponent(e))+"/clips/".concat(encodeURIComponent(t),"/placement"),{method:"PUT",headers:DF(a.token),credentials:"include",body:JSON.stringify({placed:n,change_summary:a.changeSummary||(n?"Placed clip from session view":"Unplaced clip from session view")})});if(!r.ok)throw await CF(r);return r.json()}
2(b.arrangement.id,e,!t.placed,{token:r}),await Promise.all([O(),z()]),L(t.placed?"".concat(n," taken out of the cut."):"".concat(n," placed back in the cut.")),!0}catch(s){const e=s;return I({code:e.code||null,message:e.message}),!1}finally{_(null)}},[Y,b,z,O,r]),ce=(0,a.useMemo)(()=>({enabled:o,sessionId:n||null,arrangements:l,arrangementsLoading:m,arrangementsError:p,selectedArrangementId:x,selectArrangement:V,detail:b,detailLoading:v,detailError:k,refresh:O,clips:H,clipsById:Y,clipPublicationApprovals:D,freeGaps:G,sessionDuration:W,hoveredClipId:N,setHoveredClipId:F,selectedClipId:S,setSelectedClipId:E,trimDraft:A,beginTrim:ee,updateTrim:te,cancelTrim:ne,commitTrim:se,boundsFor:K,previewTrim:X,previewNewClip:J,deleteImpactFor:$,unplaceVerdictFor:Q,busyClipId:M,lastError:B,lastSuccess:P,clearMessages:Z,trimClip:re,deleteClip:ie,addClip:oe,togglePlacement:le}),[oe,l,p,m,ee,K,M,ne,Z,D,H,Y,se,ie,$,b,k,v,o,G,N,B,P,O,J,X,V,x,S,W,n,le,re,A,Q,te]);return(0,u.jsx)(OF.Provider,{value:ce,children:i})};function qF(){return(0,a.useContext)(OF)}const WF=Mo("arrow-left-to-line",[["path",{d:"M3 19V5",key:"rwsyhb"}],["path",{d:"m13 6-6 6 6 6",key:"1yhaz7"}],["path",{d:"M7 12h14",key:"uoisry"}]]),YF=Mo("arrow-right-to-line",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);function GF(){const e=qF(),{playSegment:t}=Kw(),n=(0,a.useCallback)(function(n){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[];const s=e.clipsById.get(n);if(!s)return[];const i=[],o=e.busyClipId===n?"Waiting for the last change to land.":null;i.push({id:"play",label:"Play this clip",icon:a.createElement(kh,{size:13}),hint:MF(s.endTime-s.startTime),onSelect:()=>{t(s.startTime,s.endTime)}});const l=(t,a,r,s,i)=>{const l=e.previewTrim(n,s,i);return{id:t,label:a,icon:r,hint:l.ok?MF(i-s):void 0,blockedReason:o||(l.ok?null:l.message),onSelect:()=>{e.trimClip(n,s,i)}}};if(null!=r.atTime&&Number.isFinite(r.atTime)){const e=r.atTime;e<s.endTime&&i.push(l("start-to-here","Move start to ".concat(MF(e)),a.createElement(WF,{size:13}),e,s.endTime)),e>s.startTime&&i.push(l("end-to-here","Move end to ".concat(MF(e)),a.createElement(YF,{size:13}),s.startTime,e))}i.push(l("expand-start","Expand start by ".concat(2,"s"),a.createElement(WF,{size:13}),s.startTime-2,s.endTime)),i.push(l("expand-end","Expand end by ".concat(2,"s"),a.createElement(YF,{size:13}),s.startTime,s.endTime+2)),i.push(l("trim-start","Trim ".concat(2,"s off the start"),a.createElement(yj,{size:13}),s.startTime+2,s.endTime)),i.push(l("trim-end","Trim ".concat(2,"s off the end"),a.createElement(yj,{size:13}),s.startTime,s.endTime-2));const c=e.unplaceVerdictFor(n);return i.push({id:"placement",label:s.placed?"Take out of the cut":"Put back in the cut",icon:a.createElement(s.placed?Fy:Cp,{size:13}),blockedReason:o||(s.placed&&c&&!c.ok?c.message:null),onSelect:()=>{e.togglePlacement(n)}}),i.push({id:"delete",label:"Delete this clip",icon:a.createElement(kp,{size:13}),danger:!0,blockedReason:o,onSelect:()=>{e.deleteClip(n)}}),i},[e,t]),r=(0,a.useCallback)(function(n){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return[];const s=e.previewNewClip(n);return[{id:"add-clip",label:r.label||"Add a clip here (".concat(MF(n.start),"\u2013").concat(MF(n.end),")"),icon:a.createElement(ik,{size:13}),hint:MF(n.end-n.start),blockedReason:s.ok?null:s.message,onSelect:()=>{e.addClip(n)}},{id:"preview-range",label:"Play this range first",icon:a.createElement(kh,{size:13}),onSelect:()=>{t(n.start,n.end)}}]},[e,t]);return{buildClipItems:n,buildEmptySpaceItems:r}}const KF=e=>{let{x:t,y:n,title:r,subtitle:s,warnings:i=[],items:o,isDarkMode:l,onClose:c}=e;const d=(0,a.useRef)(null),[m,h]=(0,a.useState)({left:t,top:n});return(0,a.useLayoutEffect)(()=>{const e=d.current;if(!e)return;const a=e.getBoundingClientRect(),r=Math.max(8,Math.min(t,window.innerWidth-a.width-8)),s=a.height+n>window.innerHeight-8?Math.max(8,n-a.height):n;h({left:r,top:s})},[t,n,o.length,i.length]),(0,a.useEffect)(()=>{const e=e=>{d.current&&!d.current.contains(e.target)&&c()},t=e=>{"Escape"===e.key&&c()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),window.addEventListener("resize",c),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t),window.removeEventListener("resize",c)}},[c]),(0,mk.createPortal)((0,u.jsxs)("div",{ref:d,"data-testid":"arrangement-clip-menu",className:"fixed z-[10000] overflow-hidden rounded-2xl border shadow-2xl backdrop-blur-xl ".concat(l?"border-white/10 bg-[rgba(17,27,42,0.9
26)] text-gray-100":"border-[rgba(215,222,233,0.9)] bg-[rgba(255,255,255,0.98)] text-gray-800"),style:{left:m.left,top:m.top,width:288},onContextMenu:e=>e.preventDefault(),children:[(0,u.jsxs)("div",{className:"px-3 py-2.5 border-b ".concat(l?"border-white/10":"border-gray-200/80"),children:[(0,u.jsx)("div",{className:"truncate text-[12px] font-semibold tracking-tight",children:r}),s&&(0,u.jsx)("div",{className:"mt-0.5 truncate text-[11px] ".concat(l?"text-gray-400":"text-gray-500"),children:s})]}),i.length>0&&(0,u.jsx)("div",{className:"px-3 py-2 text-[11px] leading-snug ".concat(l?"bg-amber-500/10 text-amber-200":"bg-amber-50 text-amber-800"),children:i.map(e=>(0,u.jsxs)("div",{className:"flex gap-1.5",children:[(0,u.jsx)(fp,{size:12,className:"mt-0.5 shrink-0"}),(0,u.jsx)("span",{children:e})]},e))}),(0,u.jsx)("div",{className:"py-1",children:o.map((e,t)=>{var n;const a=Boolean(e.blockedReason),r=e.section||null,s=Boolean(r)&&r!==((null===(n=o[t-1])||void 0===n?void 0:n.section)||null);return(0,u.jsxs)("div",{children:[s&&(0,u.jsx)("div",{"data-testid":"arrangement-clip-menu-section-".concat(r),className:"mt-1 border-t px-3 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-[0.14em] ".concat(l?"border-white/10 text-gray-400":"border-gray-200/80 text-gray-500"," ").concat(0===t?"mt-0 border-t-0 pt-1":""),children:r}),(0,u.jsxs)("button",{type:"button",disabled:a,"data-testid":"arrangement-clip-menu-item-".concat(e.id),onClick:()=>{var t;a||(null===(t=e.onSelect)||void 0===t||t.call(e),c())},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-[12px] transition-colors ".concat(a?l?"cursor-not-allowed text-gray-500":"cursor-not-allowed text-gray-400":e.danger?l?"text-red-300 hover:bg-red-500/15":"text-red-600 hover:bg-red-50":l?"hover:bg-white/10":"hover:bg-gray-100"),children:[(0,u.jsx)("span",{className:"shrink-0 opacity-80",children:e.icon}),(0,u.jsx)("span",{className:"flex-1 truncate",children:e.label}),e.hint&&!a&&(0,u.jsx)("span",{className:"shrink-0 text-[10px] tabular-nums ".concat(l?"text-gray-500":"text-gray-400"),children:e.hint})]}),a&&(0,u.jsx)("div",{className:"px-3 pb-2 pl-[38px] text-[11px] leading-snug ".concat(l?"text-red-300/80":"text-red-600/90"),children:e.blockedReason})]},e.id)})})]}),document.body)},XF=Object.freeze({count:0,threadCount:0,newestCommentId:null,newestThreadRootId:null,comments:[]}),JF=e=>{const t="number"===typeof e?e:Number(e);return Number.isFinite(t)?t:null};function $F(e){return String(e.displayName||e.userName||e.userEmail||e.display_name||e.user_name||e.user_email||"Anonymous").trim()||"Anonymous"}function QF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:140;const n=String(e||"").replace(/```[\s\S]*?```/g," [code] ").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/(^|\s)[#>*-]+(?=\S)/g,"$1").replace(/[*_~`]+/g,"").replace(/\s+/g," ").trim();return n.length<=t?n:"".concat(n.slice(0,Math.max(0,t-1)).trimEnd(),"\u2026")}function ZF(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if(null===e||void 0===e||""===e)return"Time unavailable";const n=e instanceof Date?e:new Date(e),a=n.getTime();if(!Number.isFinite(a))return"Time unavailable";const r=Math.max(0,t-a),s=6e4,i=36e5,o=24*i;if(r<s)return"just now";if(r<i){const e=Math.floor(r/s);return"".concat(e," min ago")}if(r<o){const e=Math.floor(r/i);return"".concat(e," hr").concat(1===e?"":"s"," ago")}if(r<7*o){const e=Math.floor(r/o);return"".concat(e," day").concat(1===e?"":"s"," ago")}return new Intl.DateTimeFormat("en",{month:"short",day:"numeric",year:n.getFullYear()===new Date(t).getFullYear()?void 0:"numeric"}).format(n)}function eS(e){const t=new Map;let n=0;const a=(e,r,s)=>{const i=String((null===e||void 0===e?void 0:e.id)||"").trim();if(!i||s.has(i))return;const o=String(e.parentCommentId||e.parent_comment_id||"").trim()||null,l=t.get(i),c=l?d(d({},l),{},{source:d(d({},l.source),e),parentId:o||l.parentId||r}):{source:e,id:i,parentId:o||r,order:n++};t.set(i,c);const u=new Set(s);u.add(i),(e.replies||[]).forEach(e=>a(e,i,u))};
2return e.forEach(e=>a(e,null,new Set)),[...t.values()]}function tS(e,t){let n=e,a=0;const r=new Set([e.id]);for(;n.parentId;){const e=t.get(n.parentId);if(!e||r.has(e.id))break;r.add(e.id),n=e,a+=1}return{root:n,depth:a}}function nS(e,t,n,a){const r=Math.min(e,t),s=Math.max(e,t),i=new Map(n.map(e=>[e.id,e])),o=new Map(n.map(e=>[e.id,tS(e,i)])),l=new Map;n.forEach(e=>{var t;const n=(null===(t=o.get(e.id))||void 0===t?void 0:t.root)||e,a=l.get(n.id)||[];a.push(e),l.set(n.id,a)});const c=new Set;l.forEach((e,t)=>{const n=i.get(t);if(!n)return;const a=function(e,t){var n;const a=JF(null!==(n=e.source.timestampSeconds)&&void 0!==n?n:e.source.timestamp_seconds);if(null!==a)return a;for(const s of t){var r;const e=JF(null!==(r=s.source.timestampSeconds)&&void 0!==r?r:s.source.timestamp_seconds);if(null!==e)return e}return null}(n,e);null!==a&&a>=r&&a<=s&&c.add(t)});const d=n.filter(e=>{var t;const n=(null===(t=o.get(e.id))||void 0===t?void 0:t.root)||e;return c.has(n.id)});if(!d.length)return XF;const u=d.map(e=>{var t,n;const{root:a,depth:r}=o.get(e.id)||{root:e,depth:0},s=e.parentId?i.get(e.parentId):null,l=function(e){var t,n;const a=null!==(t=null!==(n=e.createdAt)&&void 0!==n?n:e.created_at)&&void 0!==t?t:e.timestamp;if(null===a||void 0===a||""===a)return null;const r=a instanceof Date?a:new Date(a);return Number.isFinite(r.getTime())?r:null}(e.source),c=String(e.source.content||"");return{id:e.id,author:$F(e.source),content:c,excerpt:QF(c),createdAt:l,createdAtMs:null!==(t=null===l||void 0===l?void 0:l.getTime())&&void 0!==t?t:null,timestampSeconds:JF(null!==(n=e.source.timestampSeconds)&&void 0!==n?n:e.source.timestamp_seconds),thread:{rootCommentId:a.id,rootAuthor:$F(a.source),rootExcerpt:QF(a.source.content),parentCommentId:null===s||void 0===s?void 0:s.id,parentAuthor:s?$F(s.source):void 0,parentExcerpt:s?QF(s.source.content,84):void 0,depth:r}}}).sort((e,t)=>{var n,a;return null!==e.createdAtMs&&null!==t.createdAtMs&&e.createdAtMs!==t.createdAtMs?t.createdAtMs-e.createdAtMs:null!==e.createdAtMs?-1:null!==t.createdAtMs?1:((null===(n=i.get(t.id))||void 0===n?void 0:n.order)||0)-((null===(a=i.get(e.id))||void 0===a?void 0:a.order)||0)}),m=u[0];return{count:d.length,threadCount:c.size,newestCommentId:(null===m||void 0===m?void 0:m.id)||null,newestThreadRootId:(null===m||void 0===m?void 0:m.thread.rootCommentId)||null,comments:u.slice(0,a)}}function aS(e){if(null===e||void 0===e)return null;if("boolean"===typeof e)return{approved:e,actor:null,changedAt:null};const t=null===e.changedAt||void 0===e.changedAt?null:new Date(e.changedAt);return{approved:Boolean(e.approved),actor:String(e.actorName||e.actorIdentifier||"").trim()||null,changedAt:t&&Number.isFinite(t.getTime())?t:null}}const rS=e=>e.stopPropagation(),sS=e=>{let{count:t,expanded:n=!1,isDarkMode:a=!1,describedBy:r,onClick:s}=e;if(t<=0)return null;const i=t>99?"99+":String(t);return(0,u.jsxs)("button",{type:"button","data-testid":"clip-comment-badge","aria-label":"Open ".concat(t," clip comment").concat(1===t?"":"s"),"aria-describedby":r,className:"inline-flex h-[18px] min-w-[18px] shrink-0 items-center justify-center gap-1 rounded-full border px-1 text-[9px] font-bold leading-none shadow-sm transition-colors ".concat(a?"border-sky-300/35 bg-sky-950/90 text-sky-100 hover:bg-sky-800":"border-sky-600/25 bg-white/95 text-sky-700 hover:bg-sky-50"),onPointerDown:rS,onClick:e=>{e.stopPropagation(),null===s||void 0===s||s(e)},children:[(0,u.jsx)(ky,{"aria-hidden":"true",size:11,strokeWidth:2.4}),(0,u.jsxs)("span",{children:[i,n&&" comment".concat(1===t?"":"s")]})]})},iS=e=>{let{decision:t,expanded:n=!1,isDarkMode:a=!1,showUnapproved:r=!1}=e;const s=aS(t);if(!s||!s.approved&&!r)return null;const i=s.actor?" by ".concat(s.actor):"",o=s.changedAt?" \xb7 ".concat(ZF(s.changedAt)):"",l=s.approved?"Approved for publication".concat(i).concat(o):"Not approved for publication".concat(i).concat(o);return(0,u.jsxs)("span",{"data-testid":"clip-approval-indicator",role:"img","aria-label":l,title:l,className:"inline-flex h-[18px] shrink-0 items-center justify-center gap-1 rounded-full border px-1 text-[9px] font-bold leading-none shadow-sm ".concat(s.approved?a?"border-emerald-300/35 bg-emerald-950/90 text-emerald-200":"border-emerald-600/25 bg-emerald-50/95 text-emerald-700":a?"border-white/15 bg-slate-900/90 text-slate-400":"border-slate-400/30 bg-white/90 text-slate-500"),children:[(0,u.jsx)(Wm,{"aria-hidden":"true",size:11,strokeWidth:3}),n&&(0,u.jsx)("span",{children:"Approved"})]})},oS=e=>{let{summary:t,isDarkMode:n=!1,onPointerEnter:a,onPointerLeave:r}=e;return(0,u.jsxs)("div",{"data-testid":"clip-comment-preview",role:"tooltip",className:"w-[min(22rem,calc(100vw-24px))] rounded-xl border p-2.5 shadow-2xl ".concat(n?"border-white/10 bg-[#111b2a
2]/[0.98] text-slate-100":"border-slate-200 bg-white/[0.98] text-slate-900"),onPointerEnter:a,onPointerLeave:r,children:[(0,u.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2 px-0.5",children:[(0,u.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] opacity-70",children:"Recent clip comments"}),(0,u.jsxs)("span",{className:"text-[10px] opacity-60",children:[t.count," in ",t.threadCount," thread",1===t.threadCount?"":"s"]})]}),(0,u.jsx)("div",{className:"space-y-1.5",children:t.comments.map(e=>{var t,a;const r=e.thread.depth>0;return(0,u.jsxs)("article",{className:"rounded-lg border px-2.5 py-2 ".concat(n?"border-white/10 bg-white/[0.05]":"border-slate-200/80 bg-slate-50"),children:[(0,u.jsxs)("div",{className:"flex min-w-0 items-baseline justify-between gap-2",children:[(0,u.jsx)("span",{className:"truncate text-[11px] font-semibold",children:e.author}),(0,u.jsx)("time",{className:"shrink-0 text-[10px] opacity-60",dateTime:null===(t=e.createdAt)||void 0===t?void 0:t.toISOString(),title:null===(a=e.createdAt)||void 0===a?void 0:a.toLocaleString(),children:ZF(e.createdAt)})]}),r&&(0,u.jsxs)("div",{className:"mt-0.5 truncate text-[9px] opacity-60",children:["Reply to ",e.thread.parentAuthor||e.thread.rootAuthor,e.thread.parentExcerpt||e.thread.rootExcerpt?" \xb7 ".concat(e.thread.parentExcerpt||e.thread.rootExcerpt):""]}),(0,u.jsx)("p",{className:"mt-1 line-clamp-2 break-words text-[11px] leading-[1.35]",children:e.excerpt||"Empty comment"})]},e.id)})})]})},lS=e=>{let{clipId:t,summary:n,approval:r,clipPixelWidth:s,availableHeight:i=28,availablePreviewHeight:o=160,variant:l="auto",isDarkMode:c=!1,showUnapproved:m=!1,className:h="",style:p,onOpenComments:g}=e;const x=aS(r),f=function(e){let{clipPixelWidth:t,availableHeight:n=28,availablePreviewHeight:a=160,commentCount:r=0,isApproved:s=!1,variant:i="auto"}=e;const o=r>0||s,l=Number.isFinite(t)&&Number.isFinite(n)&&t>=18&&n>=18;if(!o||!l)return{mode:"hidden",maxPreviewComments:0,showCommentLabel:!1,showApprovalLabel:!1};const c="expanded"===i?"expanded":"compact"===i?"compact":t>=96&&n>=24?"expanded":"compact";return{mode:c,maxPreviewComments:a>=132?2:1,showCommentLabel:"expanded"===c&&t>=96,showApprovalLabel:"expanded"===c&&t>=168}}({clipPixelWidth:s,availableHeight:i,availablePreviewHeight:o,commentCount:n.count,isApproved:Boolean((null===x||void 0===x?void 0:x.approved)||m&&x),variant:l}),b=(0,a.useMemo)(()=>d(d({},n),{},{comments:n.comments.slice(0,f.maxPreviewComments)}),[f.maxPreviewComments,n]),y=(0,a.useRef)(null),v=(0,a.useRef)(null),[w,k]=(0,a.useState)(!1),j=(0,a.useId)(),D=(0,a.useCallback)(()=>{null!==v.current&&(window.clearTimeout(v.current),v.current=null)},[]),C=(0,a.useCallback)(()=>{D(),n.count>0&&k(!0)},[D,n.count]),N=(0,a.useCallback)(()=>{D(),v.current=window.setTimeout(()=>{k(!1),v.current=null},120)},[D]);if((0,a.useEffect)(()=>()=>D(),[D]),"hidden"===f.mode)return null;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{ref:y,"data-testid":"clip-review-affordances",className:"inline-flex min-w-0 items-center gap-1 ".concat(h),style:p,onMouseEnter:C,onMouseLeave:N,onFocusCapture:C,onBlurCapture:N,onPointerDown:rS,onClick:e=>e.stopPropagation(),children:[(0,u.jsx)(sS,{count:n.count,expanded:f.showCommentLabel,isDarkMode:c,describedBy:w?j:void 0,onClick:()=>{if(g)return g({clipId:t,focusCommentId:n.newestCommentId,threadRootCommentId:n.newestThreadRootId,commentCount:n.count}),void k(!1);k(e=>!e)}}),(0,u.jsx)(iS,{decision:r,expanded:f.showApprovalLabel,isDarkMode:c,showUnapproved:m})]}),(0,u.jsx)(CD,{isOpen:w&&b.comments.length>0,onClose:()=>k(!1),anchorRef:y,align:"center",offset:8,children:(0,u.jsx)("div",{id:j,children:(0,u.jsx)(oS,{summary:b,isDarkMode:c,onPointerEnter:D,onPointerLeave:N})})})]})};function cS(e,t){return t(e.endTime)-t(e.startTime)}
2const dS=e=>{var t,n;let{isDarkMode:r,width:s,timeToX:i,xToTime:o,viewportStart:l,viewportEnd:c,onSeek:d}=e;const m=qF(),{setHoveredTimeRange:h}=wk(),{buildClipItems:p,buildEmptySpaceItems:g}=GF(),x=(0,a.useRef)(null),f=(0,a.useRef)(null),[b,y]=(0,a.useState)(null),v=null===m||void 0===m?void 0:m.clips,w=(null===m||void 0===m?void 0:m.trimDraft)||null,k=(0,a.useMemo)(()=>v?v.filter(e=>e.endTime>=l&&e.startTime<=c):[],[v,c,l]),j=(0,a.useCallback)(e=>w&&w.clipId===e.id?{start:w.start,end:w.end}:{start:e.startTime,end:e.endTime},[w]),D=(0,a.useCallback)(e=>{const t=x.current,n=null===t||void 0===t?void 0:t.getBoundingClientRect();if(!t||!n||!n.width)return 0;const a=t.offsetWidth/n.width;return o((e-n.left)*a)},[o]),C=(0,a.useCallback)((e,t,n)=>{if(m){e.preventDefault(),e.stopPropagation();try{e.currentTarget.setPointerCapture(e.pointerId)}catch(a){}f.current={clipId:t.id,edge:n},m.beginTrim(t.id,n)}},[m]),N=(0,a.useCallback)(e=>{if(!m||!f.current)return;e.preventDefault(),e.stopPropagation();const{clipId:t,edge:n}=f.current;m.updateTrim(t,n,D(e.clientX))},[m,D]),F=(0,a.useCallback)(e=>{e.preventDefault(),e.stopPropagation();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch(t){}f.current=null},[]),S=(0,a.useCallback)(e=>{m&&f.current&&(F(e),m.commitTrim())},[F,m]),E=(0,a.useCallback)(e=>{m&&f.current&&(F(e),m.cancelTrim())},[F,m]),A=(0,a.useCallback)((e,t,n)=>{var a;if(!m)return;const r=(null===(a=m.trimDraft)||void 0===a?void 0:a.clipId)===t.id?m.trimDraft:null,s=r?"start"===n?r.start:r.end:"start"===n?t.startTime:t.endTime;if("ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault(),e.stopPropagation();const a=e.shiftKey?1:.1,i="ArrowLeft"===e.key?-a:a;return r||m.beginTrim(t.id,n),void m.updateTrim(t.id,n,s+i)}if(r&&("Enter"===e.key||" "===e.key))return e.preventDefault(),e.stopPropagation(),void m.commitTrim();r&&"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),m.cancelTrim())},[m]),T=(0,a.useCallback)(e=>{var t;m&&!f.current&&(null===(t=m.trimDraft)||void 0===t?void 0:t.clipId)===e.id&&m.cancelTrim()},[m]),M=(0,a.useCallback)((e,t)=>{if(!m)return;e.preventDefault(),e.stopPropagation();const n=m.deleteImpactFor(t.id);y({x:e.clientX,y:e.clientY,title:"".concat(t.clipCode||t.id.slice(0,8)," \xb7 ").concat(MF(t.startTime),"\u2013").concat(MF(t.endTime)),subtitle:t.title||t.speaker,warnings:(null===n||void 0===n?void 0:n.warnings)||[],items:p(t.id,{atTime:D(e.clientX)})})},[p,m,D]),_=(0,a.useCallback)(e=>{var t;if(!m)return;e.preventDefault();const n=D(e.clientX),a=m.freeGaps.find(e=>n>=e.start&&n<=e.end),r=a?{start:Math.max(a.start,n-12),end:Math.min(a.end,n+12)}:{start:Math.max(0,n-12),end:n+12};y({x:e.clientX,y:e.clientY,title:"Empty at ".concat(MF(n)),subtitle:(null===(t=m.detail)||void 0===t?void 0:t.arrangement.title)||null,warnings:[],items:g(r)})},[g,m,D]);if(!m||!m.enabled||!m.detail||s<=0)return null;const B=m.selectedClipId?m.clipsById.get(m.selectedClipId):null,I=Boolean(B&&cS(B,i)<24),P=w&&w.blocked?w:null,L=P?P.verdict.ok?"Stopped by ".concat((null===(t=m.boundsFor(P.clipId))||void 0===t||null===(n=t["start"===P.edge?"blockedStartBy":"blockedEndBy"])||void 0===n?void 0:n.clipCode)||"the session boundary"):P.verdict.message:null;return(0,u.jsxs)("div",{className:"relative",style:{height:46},"data-testid":"arrangement-timeline-lane",children:[(0,u.jsxs)("div",{ref:x,className:"absolute inset-0 overflow-hidden border-t ".concat(r?"border-white/5 bg-[rgba(17,27,42,0.55)]":"border-gray-200/70 bg-[rgba(244,246,250,0.75)]"),onContextMenu:_,onMouseLeave:()=>{m.setHoveredClipId(null),h(null)},children:[(0,u.jsxs)("div",{className:"pointer-events-none absolute left-2 top-0 truncate text-[9px] font-semibold uppercase tracking-[0.16em] ".concat(r?"text-[#ffc766]/70":"text-[#8a6115]/80"),style:{height:14,lineHeight:"".concat(14,"px"),maxWidth:s-16},children:[m.detail.arrangement.title,(0,u.jsxs)("span",{className:r?"ml-2 text-gray-500":"ml-2 text-gray-400",children:[m.clips.length," clip",1===m.clips.length?"":"s"," from this session"]}),I&&(0,u.jsxs)("span",{"data-testid":"arrangement-lane-zoom-hint",className:"ml-2 normal-case tracking-normal ".concat(r?"text-[#ffc766]/60":"text-[#8a6115]/70"),children:["zoom in to drag ",(null===B||void 0===B?void 0:B.clipCode)||"its"," edges \u2014 or right-click to trim"]})]}),m.freeGaps.map(e=>{const t=i(e.start),n=i(e.end);return n<0||t>s?null:(0,u.jsx)("div",{className:"pointer-events-none absolute",style:{to
2p:28,left:t,width:Math.max(1,n-t),height:3,background:r?"repeating-linear-gradient(90deg, rgba(148,163,184,0.28) 0 5px, transparent 5px 10px)":"repeating-linear-gradient(90deg, rgba(100,116,139,0.24) 0 5px, transparent 5px 10px)"}},"gap-".concat(e.start,"-").concat(e.end))}),k.map(e=>{const t=j(e),n=i(t.start),a=i(t.end),o=a-n,l=Math.max(2,o);if(a<-40||n>s+40)return null;const c=(null===w||void 0===w?void 0:w.clipId)===e.id,p=o>=24||c,g=m.hoveredClipId===e.id,x=m.selectedClipId===e.id,f=m.busyClipId===e.id,b=p?m.boundsFor(e.id):null,y=e.clipCode||e.title||e.speaker||"clip",v=e.placed?r?{bg:"rgba(255,181,43,0.26)",border:"rgba(255,181,43,0.72)",text:"#ffd88a"}:{bg:"rgba(255,181,43,0.30)",border:"rgba(198,133,12,0.72)",text:"#6e4d0e"}:r?{bg:"rgba(111,137,182,0.18)",border:"rgba(111,137,182,0.5)",text:"#b9c8e4"}:{bg:"rgba(148,163,184,0.22)",border:"rgba(100,116,139,0.5)",text:"#475569"};return(0,u.jsxs)("div",{"data-testid":"arrangement-clip-block-".concat(e.id),className:"absolute flex items-center rounded-md transition-shadow ".concat(f?"animate-pulse":""),style:{top:16,left:n,width:l,height:26,backgroundColor:v.bg,borderWidth:1,borderColor:v.border,borderStyle:e.placed?"solid":"dashed",boxShadow:x||c?"0 0 0 2px ".concat(r?"rgba(255,181,43,0.55)":"rgba(198,133,12,0.45)"):g?"0 0 0 1px ".concat(v.border):"none",cursor:"pointer"},onMouseEnter:()=>{m.setHoveredClipId(e.id),h({start:t.start,end:t.end})},onClick:n=>{n.stopPropagation(),m.setSelectedClipId(e.id),null===d||void 0===d||d(t.start)},onContextMenu:t=>M(t,e),title:p?"".concat(e.clipCode||""," ").concat(e.title||e.speaker).trim():"".concat("".concat(e.clipCode||""," ").concat(e.title||e.speaker).trim()," \u2014 zoom in to drag its edges, or right-click to trim"),children:[p&&(0,u.jsx)("div",{"data-testid":"arrangement-clip-handle-start-".concat(e.id),className:"absolute inset-y-0 left-0 z-10",style:{width:8,cursor:"ew-resize",touchAction:"none"},role:"slider",tabIndex:0,"aria-label":"Start of ".concat(y),"aria-valuemin":b?b.minStart:void 0,"aria-valuemax":t.end,"aria-valuenow":t.start,"aria-valuetext":"".concat(MF(t.start)," \u2014 arrow keys to trim, Enter to save, Escape to discard"),onPointerDown:t=>C(t,e,"start"),onPointerMove:N,onPointerUp:S,onPointerCancel:E,onKeyDown:t=>A(t,e,"start"),onBlur:()=>T(e),onClick:e=>e.stopPropagation(),children:(0,u.jsx)("div",{className:"absolute inset-y-1 left-0.5 w-[3px] rounded-full",style:{backgroundColor:v.border}})}),l>46&&(0,u.jsxs)("span",{className:"pointer-events-none mx-2.5 truncate text-[10px] font-semibold uppercase tracking-[0.1em]",style:{color:v.text},children:[e.clipCode||e.title||e.speaker,!e.placed&&" \xb7 unplaced"]}),(0,u.jsx)(lS,{clipId:e.id,summary:XF,approval:m.clipPublicationApprovals.get(e.id),clipPixelWidth:l,availableHeight:26,isDarkMode:r,style:{position:"absolute",right:p?10:2,top:"50%",transform:"translateY(-50%)",zIndex:20}}),p&&(0,u.jsx)("div",{"data-testid":"arrangement-clip-handle-end-".concat(e.id),className:"absolute inset-y-0 right-0 z-10",style:{width:8,cursor:"ew-resize",touchAction:"none"},role:"slider",tabIndex:0,"aria-label":"End of ".concat(y),"aria-valuemin":t.start,"aria-valuemax":b?b.maxEnd:void 0,"aria-valuenow":t.end,"aria-valuetext":"".concat(MF(t.end)," \u2014 arrow keys to trim, Enter to save, Escape to discard"),onPointerDown:t=>C(t,e,"end"),onPointerMove:N,onPointerUp:S,onPointerCancel:E,onKeyDown:t=>A(t,e,"end"),onBlur:()=>T(e),onClick:e=>e.stopPropagation(),children:(0,u.jsx)("div",{className:"absolute inset-y-1 right-0.5 w-[3px] rounded-full",style:{backgroundColor:v.border}})})]},e.id)}),P&&(0,u.jsxs)("div",{"data-testid":"arrangement-trim-blocked",className:"pointer-events-none absolute z-20 flex items-center gap-1.5 whitespace-nowrap rounded-md px-2 py-1 text-[10px] font-semibold shadow-lg ".concat(r?"bg-red-900/90 text-red-100":"bg-red-600 text-white"),style:{left:Math.max(4,Math.min(i("start"===P.edge?P.start:P.end)-60,Math.max(4,s-260))),top:0},children:[(0,u.jsx)(Aj,{size:11}),L]})]}),b&&(0,u.jsx)(KF,{x:b.x,y:b.y,title:b.title,subtitle:b.subtitle,warnings:b.warnings,items:b.items,isDarkMode:r,onClose:()=>y(null)})]})},uS=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60),r=M
2ath.round(e%1*1e3);return"".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"),".").concat(r.toString().padStart(3,"0"))},mS=e=>{const t=Math.floor(e/60),n=Math.floor(e%60);return"".concat(t,":").concat(n.toString().padStart(2,"0"))},hS=e=>{let{isOpen:t,onClose:n,onSave:r,timestamp:s,isDarkMode:i}=e;const[o,l]=(0,a.useState)(""),[c,d]=(0,a.useState)(""),[m,h]=(0,a.useState)(""),[p,g]=(0,a.useState)(""),[x,f]=(0,a.useState)(""),[b,y]=(0,a.useState)(""),[v,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)(null),D=s+30,C=()=>{v||(l(""),d(""),h(""),g(""),f(""),y(""),j(null),n())};return(0,u.jsx)(S,{children:t&&(0,u.jsx)(Do.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:C,children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"".concat(i?"bg-gray-800":"bg-white"," rounded-lg w-full max-w-lg shadow-xl overflow-hidden"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"p-4 border-b ".concat(i?"border-gray-700":"border-gray-200"," flex items-center justify-between"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:"rgb(236, 72, 153)"},children:(0,u.jsx)(pF,{size:14,className:"text-white"})}),(0,u.jsx)("h3",{className:"text-lg font-semibold ".concat(i?"text-white":"text-gray-900"),children:"Add Reference"})]}),(0,u.jsx)("button",{onClick:C,disabled:v,className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-600 hover:text-gray-900"),children:(0,u.jsx)(Pu,{size:20})})]}),(0,u.jsxs)("form",{onSubmit:async e=>{if(e.preventDefault(),o.trim())if(!p||p.startsWith("http://")||p.startsWith("https://")){w(!0),j(null);try{await r({startTime:s,endTime:D,name:o.trim(),category:c.trim()||void 0,linkText:m.trim()||void 0,url:p.trim()||void 0,context:x.trim()||void 0,visualSuggestion:b.trim()||void 0}),l(""),d(""),h(""),g(""),f(""),y(""),n()}catch(t){j(t instanceof Error?t.message:"Failed to save reference")}finally{w(!1)}}else j("URL must start with http:// or https://");else j("Reference name is required")},className:"p-4 space-y-4",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg ".concat(i?"bg-gray-900":"bg-gray-50"),children:[(0,u.jsx)(wp,{size:16,className:"text-[#B57700] dark:text-[#FFCF74]"}),(0,u.jsxs)("span",{className:"text-sm ".concat(i?"text-gray-300":"text-gray-700"),children:["Timestamp: ",mS(s)]}),(0,u.jsxs)("span",{className:"text-xs ".concat(i?"text-gray-500":"text-gray-400"),children:["(",uS(s),")"]})]}),k&&(0,u.jsx)("div",{className:"px-3 py-2 rounded-lg bg-red-100 dark:bg-red-900/30 border border-red-300 dark:border-red-700 text-red-700 dark:text-red-300 text-sm",children:k}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"block text-sm font-medium mb-1 ".concat(i?"text-gray-300":"text-gray-700"),children:["Name ",(0,u.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,u.jsx)("input",{type:"text",value:o,onChange:e=>l(e.target.value),placeholder:"Reference name...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(i?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(i?"text-gray-300":"text-gray-700"),children:"Category"}),(0,u.jsx)("input",{type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"Person, Paper, Book...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(i?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(i?"text-gray-300":"text-gray-700"),children:"Link Text"}),(0,u.jsx)("input",{type:"text",value:m,onChange:e=>h(e.target.value),placeholder:"arXiv Paper, Website...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(i?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(i?"text-gray-300":"text-gray-700"),children:"URL"}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("input",{type:"url",value:p,onChange:e=>g(e.target.value),placeholder:"https://...",disabled:v,className:"flex-1 px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(i?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")}),p&&p.startsWith("http")&&(0,u.jsx)("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"rounded-lg p-2 text-[#B57700] transition-colors hover:bg-[#FFF4D8] hover:text-[#8B5B00] dark:hover:bg-[#232E3F]/40 dark:text-[#FFCF74]",title:"Open URL",children:(0,u.jsx)(Ep,{size:18})})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(i?"text-gray-300":"text-gray-700"),children:"Context"}),(0,u.jsx)("textarea",{value:x,onChange:e=>f(e.target.value),placeholder:"Why this reference is relevant...",rows:2,disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] resize-y ".concat(i?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(i?"text-gray-300":"text-gray-700"),children:"Visual Suggestion"}),(0,u.jsx)("input",{type:"text",value:b,onChange:e=>y(e.target.value),placeholder:"Photo, diagram, book cover...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(i?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,u.jsx)("button",{type:"button",onClick:C,disabled:v,className:"px-4 py-2 rounded-lg font-medium transition-colors ".concat(i?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"),children:"Cancel"}),(0,u.jsx)("button",{type:"submit",disabled:v||!o.trim(),className:"flex items-center gap-2 rounded-lg bg-[#FFB52B] px-4 py-2 font-medium text-[#232E3F] transition-colors disabled:cursor-not-allowed disabled:opacity-50 hover:bg-[#FFC54D]",children:v?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),"Saving..."]}):"Add Reference"})]})]})]})})})},pS={topic:"Topic Title",clip:"Clip Title",reference:"Reference Visual",asset:"Session Asset",title:"Session Title"},gS={topic:{badge:"text-[#ffcf74]",visualDark:"border-[#ffcf74]/35 bg-[#4b3913]/30 text-[#ffe09b]",visualLight:"border-[#f2d28d] bg-[linear-gradient(180deg,rgba(255,248,232,0.96),rgba(255,243,214,0.92))] text-[#6e4d0e] shadow-[inset_0_1px_0_rgba(255,255,255,0.7)]"},clip:{badge:"text-[#9cc7ff]",visualDark:"border-[#78a6f5]/30 bg-[#1f3559]/35 text-[#d7e7ff]",visualLight:"border-[#adc8f2] bg-[linear-gradient(180deg,rgba(240,246,255,0.96),rgba(230,240,255,0.92))] text-[#27456f] shadow-[inset_0_1px_0_rgba(255,255,255,0.72)]"},reference:{badge:"text-[#f4c96b]",visualDark:"border-[#f4c96b]/35 bg-[#2e2b23]/40 text-[#f7e4b4]",visualLight:"border-[#f0cf84] bg-[linear-gradient(180deg,rgba(255,249,236,0.97),rgba(255,244,221,0.92))] text-[#6e4d0e] shadow-[inset_0_1px_0_rgba(255,255,255,0.74)]"},asset:{badge:"text-[#9fe2c4]",visualDark:"border-[#8ce1b8]/30 bg-[#16352a]/35 text-[#d8fff0]",visualLight:"border-[#9fd9bf] bg-[linear-gradient(180deg,rgba(239,251,244,0.96),rgba(227,248,236,0.92))] text-[#1d6140] shadow-[inset_0_1px_0_rgba(255,255,255,0.74)]"},title:{badge:"text-[#f7b6d9]",visualDark:"border-[#f7b6d9]/30 bg-[#44263a]/30 text-[#ffe1f1]",visualLight:"border-[#efbdd8] bg-[linear-gradient(180deg,rgba(255,244,249,0.96),rgba(255,236,245,0.92))] text-[#7d4061] shadow-[inset_0_1px_0_rgba(255,255,255,0.72)]"}},xS=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:140;if(e)return e.length>t?"".concat(e.slice(0,t),"..."):e},fS=e=>{let{kind:t,title:n,description:a,visualSuggestion:r,meta:s,linkHref:i,seekLabel:o,previewImageUrl:l,attachmentLabel:c,isDarkMode:d,compact:m=!1,onSeek:h,onCardClick:p}=e;const g=d?"border-white/10 bg-[#0f1724]/85 text-white":"border-[#d7dee9]/80 bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(247,250,252,0.92))] text-[#1f2937]",x=d?"text-gray-300":"text-[#536173]",f=d?"text-gray-400":"text-[#6a7688]";return(0,u.jsxs)("div",{className:"rounded-2xl border shadow-[0_18px_40px_-28px_rgba(15,23,36,0.9)] backdrop-blur-sm ".concat(g," ").concat(m?"p-3":"p-4"," ").concat(p?"cursor-pointer transition-transform hover:-translate-y-0.5":""," ").concat(d?"":"shadow-[0_18px_40px_-28px_rgba(68,84,108,0.24)]"),onClick:p,onKeyDown:p?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),p())}:void 0,role:p?"button":void 0,tabIndex:p?0:void 0,children:[l&&(0,u.jsx)("div",{className:"overflow-hidden rounded-xl border ".concat(d?"border-white/10 bg-white/5":"border-[#d7dee9]/80 bg-[rgba(243,247,252,0.94)]"," ").concat(m?"mb-3":"mb-4"),children:(0,u.jsx)("img",{src:l,alt:n,className:"w-full object-contain bg-black/5 ".concat(m?"max-h-28":"max-h-40"),loading:"lazy"})}),(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] ".concat(gS[t].badge),
2children:pS[t]}),(0,u.jsx)("div",{className:"mt-1 font-semibold leading-tight ".concat(m?"text-sm":"text-[15px]"),children:n}),s&&(0,u.jsx)("div",{className:"mt-1 text-xs ".concat(f),children:s}),c&&(0,u.jsx)("div",{className:"mt-2 inline-flex items-center rounded-full px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] ".concat(d?"bg-white/8 text-gray-200":"border border-[#d7dee9]/80 bg-[rgba(242,246,251,0.92)] text-[#516174]"),children:c})]}),(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[h&&o&&(0,u.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),h()},className:"inline-flex items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium transition-colors ".concat(d?"bg-white/8 text-gray-200 hover:bg-white/14":"border border-[#d7dee9]/80 bg-[rgba(243,246,251,0.92)] text-[#455468] hover:bg-[#e7ecf5]"),children:[(0,u.jsx)(wp,{size:11}),o]}),i&&(0,u.jsx)("a",{href:i,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"inline-flex h-8 w-8 items-center justify-center rounded-full transition-colors ".concat(d?"bg-white/8 text-[#ffcf74] hover:bg-white/14":"border border-[#f0d8a2] bg-[rgba(255,244,216,0.94)] text-[#8a6115] hover:bg-[#ffe5ad]"),"aria-label":"Open link",children:(0,u.jsx)(Ep,{size:14})})]})]}),r&&(0,u.jsxs)("div",{className:"mt-3 rounded-xl border px-3 py-2 ".concat(d?gS[t].visualDark:gS[t].visualLight),children:[(0,u.jsxs)("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-[0.18em]",children:[(0,u.jsx)(Cp,{size:11}),"Visual Note"]}),(0,u.jsx)("div",{className:"mt-1 leading-snug ".concat(m?"text-xs":"text-sm"),children:xS(r,m?110:180)})]}),a&&(0,u.jsx)("p",{className:"mt-3 leading-snug ".concat(m?"text-xs":"text-sm"," ").concat(x),children:xS(a,m?120:180)})]})},bS=Mo("expand",[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16v5h-5",key:"1ck2sf"}],["path",{d:"M21 8V3h-5",key:"1qoq8a"}],["path",{d:"M3 16v5h5",key:"1t08am"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 8V3h5",key:"1ln10m"}],["path",{d:"M9 9 3 3",key:"v551iv"}]]),yS=e=>{const t=Number.isFinite(e.displayStart)?e.displayStart:null,n=Number.isFinite(e.displayEnd)?e.displayEnd:null;if(null==t||null==n)return"Attached visual";const a=e=>{const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0")):"".concat(a,":").concat(r.toString().padStart(2,"0"))};return"".concat(a(t),"-").concat(a(n))},vS=e=>{let{placements:t,isDarkMode:n,compact:r=!1,initialPlacementId:s=null,onSeek:i,onPreviewClick:o,enableLightbox:l=!0}=e;const c=(0,a.useMemo)(()=>[...t].sort((e,t)=>{const n=Number.isFinite(e.displayOrder)?Number(e.displayOrder):0,a=Number.isFinite(t.displayOrder)?Number(t.displayOrder):0;return e.displayStart!==t.displayStart?e.displayStart-t.displayStart:n!==a?n-a:String(e.id).localeCompare(String(t.id))}),[t]),d=(0,a.useMemo)(()=>{if(!s)return 0;const e=c.findIndex(e=>e.id===s);return e>=0?e:0},[s,c]),[m,h]=(0,a.useState)(d),[p,g]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{h(d)},[d]),(0,a.useEffect)(()=>{h(e=>Math.min(e,Math.max(c.length-1,0)))},[c.length]),!c.length)return null;const x=c[m]||c[0],f=Nm(x),b=Dm(x),y=l&&Boolean(f||b),v=n?"border-white/10 bg-[#0f1724]/88 text-white":"border-[#d7dee9] bg-[rgba(255,255,255,0.94)] text-[#1f2937]",w=n?"text-[#CBD2DB]":"text-[#536173]",k=n?"border-white/12 bg-white/6 hover:bg-white/10":"border-[#d7dee9] bg-[#f7f9fc] hover:bg-[#eef3f9]",j=()=>{h(e=>0===e?c.length-1:e-1)},D=()=>{h(e=>e===c.length-1?0:e+1)},C=()=>{o?o(x):y&&g(!0)},N=(e,t)=>{const n=Nm(e),a=Cm(e),s=String(e.mimeType||"").toLowerCase().startsWith("video/");return n||a?s&&n?(0,u.jsx)("video",{src:n,className:"w-full ".concat("lightbox"===t?"max-h-[72vh] object-contain bg-black":r?"max-h-40 object-contain bg-black/85":"max-h-[18rem] object-contain bg-black/85 sm:max-h-[20rem]"),muted:!0,playsInline:!0,loop:"inline"===t,autoPlay:"inline"===t,controls:"lightbox"===t,preload:"metadata"}):(0,u.jsx)("img",{src:a||n||"",alt:e.altText||e.label||e.referenceTitle||"Attached session visual",className:"w-full ".concat("lightbox"===t?"max-h-[72vh] object-contain bg-black/10":r?"max-h-40 object-contain":"max-h-[18rem] object-contain sm:max-h-[20rem]"," bg-black/5"),loading:"lazy"}):null};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"rounded-2xl border shadow-[0_18px_40px_-28px_rgba(15,23,36,0.9)] backdrop-blur-sm ".concat(v," ").concat(r?"p-3"
2:"p-4"),children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-[#ffcf74]",children:"Attached Visuals"}),(0,u.jsx)("div",{className:"mt-1 font-semibold leading-tight ".concat(r?"text-sm":"text-[15px]"),children:x.referenceTitle||x.label||x.description||x.filename||"Session visual"}),(0,u.jsxs)("div",{className:"mt-1 text-xs ".concat(w),children:[yS(x),c.length>1?" \u2022 ".concat(m+1," of ").concat(c.length):""]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[y&&(0,u.jsx)("button",{type:"button",onClick:C,className:"inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors ".concat(k),"aria-label":"Open fullscreen visual browser",children:(0,u.jsx)(bS,{size:14})}),c.length>1&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{type:"button",onClick:j,className:"inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors ".concat(k),"aria-label":"Previous visual",children:(0,u.jsx)(dk,{size:14})}),(0,u.jsx)("button",{type:"button",onClick:D,className:"inline-flex h-8 w-8 items-center justify-center rounded-full border transition-colors ".concat(k),"aria-label":"Next visual",children:(0,u.jsx)(bp,{size:14})})]})]})]}),(f||b)&&(0,u.jsx)("button",{type:"button",onClick:C,className:"mt-3 block w-full overflow-hidden rounded-2xl border text-left ".concat(k," ").concat(y||o?"cursor-zoom-in":"cursor-default"),children:N(x,"inline")}),(0,u.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[i&&(0,u.jsx)("button",{type:"button",onClick:()=>i(x),className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-[11px] font-medium transition-colors ".concat(n?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),children:"Jump to cue"}),x.sourceUrl&&(0,u.jsxs)("a",{href:x.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-[11px] font-medium transition-colors ".concat(n?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),children:[(0,u.jsx)(Ep,{size:12}),"Source"]})]}),c.length>1&&(0,u.jsx)("div",{className:"mt-3 flex gap-2 overflow-x-auto pb-1",children:c.map((e,t)=>{const n=Dm(e),a=Nm(e),r=String(e.mimeType||"").toLowerCase().startsWith("video/");return(0,u.jsx)("button",{type:"button",onClick:()=>h(t),className:"relative h-16 w-24 flex-shrink-0 overflow-hidden rounded-xl border transition ".concat(t===m?"border-[#FFB52B] ring-2 ring-[#FFB52B]/45":k),title:e.referenceTitle||e.label||e.filename||"Attached visual",children:n||a?r&&!n?(0,u.jsx)("video",{src:a,className:"h-full w-full object-cover",muted:!0,playsInline:!0,preload:"metadata"}):(0,u.jsx)("img",{src:n||a||"",alt:e.altText||e.label||"Visual thumbnail",className:"h-full w-full object-cover",loading:"lazy"}):(0,u.jsx)("div",{className:"flex h-full w-full items-center justify-center text-[10px] ".concat(w),children:"Visual"})},e.id)})})]}),p&&y&&(0,u.jsx)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/82 p-4 backdrop-blur-sm",children:(0,u.jsxs)("div",{className:"relative w-full max-w-6xl overflow-hidden rounded-[28px] border shadow-[0_28px_80px_-38px_rgba(0,0,0,0.92)] ".concat(n?"border-white/10 bg-[#08111d]/96 text-white":"border-[#d7dee9] bg-[rgba(255,255,255,0.97)] text-[#1f2937]"),children:[(0,u.jsx)("button",{type:"button",onClick:()=>g(!1),className:"absolute right-4 top-4 z-10 inline-flex h-10 w-10 items-center justify-center rounded-full transition-colors ".concat(n?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),"aria-label":"Close fullscreen visual browser",children:(0,u.jsx)(Pu,{size:16})}),(0,u.jsxs)("div",{className:"grid gap-4 p-5 pt-14 lg:grid-cols-[minmax(0,1fr)_320px]",children:[(0,u.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,u.jsx)("div",{className:"overflow-hidden rounded-[24px] border ".concat(n?"border-white/10 bg-black/30":"border-[#d7dee9] bg-[#f7f9fc]"),children:N(x,"lightbox")}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c.length>1&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{type:"button",onClick:j,className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-[11px] font-medium transition-colors ".concat(n?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),children:[(0,u.jsx)(dk,{size:12}),"Previous"]}),(0,u.jsxs)("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-[11px] font-medium transition-colors ".concat(n?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),children:["Next",(0,u.jsx)(bp,{size:12})]})]}),i&&(0,u.jsx)("button",{type:"button",onClick:()=>i(x),className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-[11px] font-medium transition-colors ".concat(n?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),children:"Jump to cue"}),x.sourceUrl&&(0,u.jsxs)("a",{href:x.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-[11px] font-medium transition-colors ".concat(n?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),children:[(0,u.jsx)(Ep,{size:12}),"Source"]})]})]}),(0,u.jsxs)("div",{className:"min-w-0 space-y-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.22em] text-[#ffcf74]",children:"Attached Visuals"}),(0,u.jsx)("div",{className:"mt-1 text-lg font-semibold leading-tight",children:x.referenceTitle||x.label||x.description||x.filename||"Session visual"}),(0,u.jsxs)("div",{className:"mt-2 text-sm ".concat(w),children:[yS(x),c.length>1?" \u2022 ".concat(m+1," of ").concat(c.length):""]}),x.description&&(0,u.jsx)("div",{className:"mt-2 text-sm leading-relaxed ".concat(w),children:x.description})]}),c.length>1&&(0,u.jsx)("div",{className:"space-y-2",children:c.map((e,t)=>{const a=Dm(e),r=Nm(e),s=String(e.mimeType||"").toLowerCase().startsWith("video/"),i=t===m;return(0,u.jsxs)("button",{type:"button",onClick:()=>h(t),className:"flex w-full items-center gap-3 rounded-2xl border p-2 text-left transition ".concat(i?"border-[#FFB52B] ring-2 ring-[#FFB52B]/35":n?"border-white/10 bg-white/4 hover:bg-white/8":"border-[#d7dee9] bg-[#f7f9fc] hover:bg-[#eef3f9]"),children:[(0,u.jsx)("div",{className:"h-16 w-24 flex-shrink-0 overflow-hidden rounded-xl bg-black/10",children:a||r?s&&!a?(0,u.jsx)("video",{src:r,className:"h-full w-full object-cover",muted:!0,playsInl
2ine:!0,preload:"metadata"}):(0,u.jsx)("img",{src:a||r||"",alt:e.altText||e.label||"Visual thumbnail",className:"h-full w-full object-cover",loading:"lazy"}):null}),(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsx)("div",{className:"truncate text-sm font-medium",children:e.referenceTitle||e.label||e.filename||"Visual ".concat(t+1)}),(0,u.jsx)("div",{className:"mt-1 text-xs ".concat(w),children:yS(e)})]})]},e.id)})})]})]})]})})]})},wS=e=>{const t=Math.floor(e/60),n=Math.floor(e%60);return"".concat(t,":").concat(n.toString().padStart(2,"0"))};const kS=function(e){var t,n;let{isOpen:r,onClose:s,reference:i,allReferences:o,onSelectReference:l,onSave:c,onDelete:d,onSeek:m,onManageVisuals:h,isDarkMode:p,canEdit:g,canManageVisuals:x=!1,showEditorialVisualSuggestion:f=!0}=e;const[b,y]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)(!1),[D,C]=(0,a.useState)(!1),[N,F]=(0,a.useState)(null),[E,A]=(0,a.useState)(""),[T,M]=(0,a.useState)(""),[_,B]=(0,a.useState)(""),[I,P]=(0,a.useState)(""),[L,R]=(0,a.useState)(""),[z,O]=(0,a.useState)("");(0,a.useEffect)(()=>{i&&(A(i.title||""),M(i.category||""),B(i.linkText||""),P(i.url||""),R(i.context||""),O(i.visualSuggestion||"")),y(!1),C(!1),F(null)},[i,r]);const U=()=>{v||k||s()};return i?(0,u.jsx)(S,{children:r&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:U,children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},exit:{scale:.9,opacity:0,y:20},className:"".concat(p?"bg-gray-800":"bg-white"," mx-4 flex max-h-[88vh] w-full max-w-3xl flex-col overflow-hidden rounded-xl shadow-2xl"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b ".concat(p?"border-gray-700":"border-gray-200"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-gradient-to-br from-[#232E3F] to-[#FFB52B]",children:(0,u.jsx)(pF,{size:16,className:"text-white"})}),(0,u.jsx)("h3",{className:"text-lg font-semibold ".concat(p?"text-white":"text-gray-900"),children:b?"Edit Reference":"Reference"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[g&&!b&&!D&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:()=>{y(!0),F(null)},className:"p-2 rounded-full transition-colors ".concat(p?"hover:bg-gray-700 text-gray-400 hover:text-[#FFCF74]":"hover:bg-gray-100 text-gray-500 hover:text-[#232E3F]"),title:"Edit reference",children:(0,u.jsx)(jj,{size:18})}),(0,u.jsx)("button",{onClick:()=>C(!0),className:"p-2 rounded-full transition-colors ".concat(p?"hover:bg-gray-700 text-gray-400 hover:text-red-400":"hover:bg-gray-100 text-gray-500 hover:text-red-600"),title:"Delete reference",children:(0,u.jsx)(kp,{size:18})})]}),(0,u.jsx)("button",{onClick:U,disabled:v||k,className:"p-2 rounded-full transition-colors ".concat(p?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-500"),children:(0,u.jsx)(Pu,{size:20})})]})]}),N&&(0,u.jsx)("div",{className:"mx-5 mt-4 px-3 py-2 rounded-lg bg-red-100 dark:bg-red-900/30 border border-red-300 dark:border-red-700 text-red-700 dark:text-red-300 text-sm",children:N}),D&&(0,u.jsx)("div",{className:"px-5 py-4",children:(0,u.jsxs)("div",{className:"p-4 rounded-lg ".concat(p?"bg-red-900/30 border border-red-700":"bg-red-50 border border-red-200"),children:[(0,u.jsx)("p",{className:"text-sm mb-4 ".concat(p?"text-red-200":"text-red-800"),children:"Are you sure you want to delete this reference? This action cannot be undone."}),(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("button",{onClick:()=>C(!1),disabled:k,className:"px-4 py-2 rounded-lg font-medium transition-colors ".concat(p?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"),children:"Cancel"}),(0,u.jsx)("button",{onClick:async()=>{if(i){j(!0),F(null);try{await d(i),s()}catch(e){F(e instanceof Error?e.message:"Failed to delete reference"),C(!1)}finally{j(!1)}}},disabled:k,className:"px-4 py-2 rounded-lg font-medium text-white bg-red-600 hover:bg-red-700 transition-colors flex items-center gap-2 disabled:opacity-50",children:k?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),"Deleting..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(kp,{size:16}),"Delete Reference"]})})]})]})}),!b&&!D&&(0,u.jsxs)("div",{className:"overflow-y-auto px-5 py-4 space-y-4",children:[(0,u.jsx)("div",{children:(0,u.jsx)("h4",{className:"text-xl font-medium ".concat(p?"text-white":"text-gray-900"),children:i.title})}),i.category&&(0,u.jsx)("div",{className:"flex items-center gap-2",children:(0,u.jsx)("span",{className:"text-sm px-2 py-0.5 rounded-full ".concat(p?"bg-[#232E3F] text-[#FFE3A1]":"bg-[#EEF1F3] text-[#232E3F]"),children:i.category})}),i.context&&(0,u.jsx)("p",{className:"text-sm ".concat(p?"text-gray-300":"text-gray-600"),children:i.context}),null!==(t=i.attachedVisualPlacements)&&void 0!==t&&t.length?(0,u.jsx)(vS,{placements:i.attachedVisualPlacements,isDarkMode:p,compact:!0,onSeek:()=>{m(i.start),s()}}):f&&i.visualSuggestion||i.attachedVisualPreviewUrl?(0,u.jsx)(fS,{kind:"reference",title:i.title||"Reference",description:i.context,visualSuggestion:f?i.visualSuggestion:void 0,meta:i.category,linkHref:i.url,previewImageUrl:Cm(null===(n=i.attachedVisualPlacements)||void 0===n?void 0:n[0])||i.attachedVisualPreviewUrl,attachmentLabel:i.attachedVisualCount?"".concat(i.attachedVisualCount," attached asset").concat(1===i.attachedVisualCount?"":"s"):i.attachedVisualLabel,seekLabel:wS(i.start),onSeek:()=>{m(i.start),s()},isDarkMode:p,compact:!0}):null,g&&x&&h&&(0,u.jsx)("button",{type:"button",onClick:()=>h(i),className:"rounded-full px-3 py-1.5 text-xs font-medium transition-colors ".concat(p?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#eef3f9] text-[#455468] hover:bg-[#e1e8f2]"),children:i.attachedVisualCount?"Add or manage attached visuals":"Attach visuals to this reference"}),i.url&&(0,u.jsxs)("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-4 py-3 rounded-lg transition-colors ".concat(p?"bg-[#232E3F]/75 hover:bg-[#2F3B4E] text-[#FFE3A1]":"bg-[#FFF8EA] hover:bg-[#FFE7AD] text-[#8B5B00]"),children:[(0,u.jsx)(Ep,{size:18}),(0,u.jsx)("span",{className:"flex-1 truncate",children:i.linkText||i.url})]}),(0,u.jsxs)("button",{onClick:()=>{m(i.start),s()},className:"text-xs flex items-center gap-1.5 px-2 py-1 rounded transition-colors ".concat(p?"text-[#FFCF74] hover:bg-[#232E3F]/40":"text-[#B57700] hover:bg-[#FFF4D8]"),children:[(0,u.jsx)(wp,{size:12}),wS(i.start)]})]}),b&&!D&&(0,u.jsxs)("div",{className:"overflow-y-auto px-5 py-4 space-y-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"block text-sm font-medium mb-1 ".concat(p?"text-gray-300":"text-gray-700"),children:["Name ",(0,u.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,u.jsx)("input",{type:"text",value:E,onChange:e=>A(e.target.value),placeholder:"Reference name...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(p?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(p?"text-gray-300":"text-gray-700"),children:"Category"}),(0,u.jsx)("input",{type:"text",value:T,onChange:e=>M(e.target.value),placeholder:"Person, Paper, Book...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(p?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(p?"text-gray-300":"text-gray-700"),children:"Link Text"}
2),(0,u.jsx)("input",{type:"text",value:_,onChange:e=>B(e.target.value),placeholder:"arXiv Paper, Website...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(p?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(p?"text-gray-300":"text-gray-700"),children:"URL"}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("input",{type:"url",value:I,onChange:e=>P(e.target.value),placeholder:"https://...",disabled:v,className:"flex-1 px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(p?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")}),I&&I.startsWith("http")&&(0,u.jsx)("a",{href:I,target:"_blank",rel:"noopener noreferrer",className:"rounded-lg p-2 text-[#B57700] transition-colors hover:bg-[#FFF4D8] hover:text-[#8B5B00] dark:text-[#FFCF74] dark:hover:bg-[#232E3F]/40",title:"Open URL",children:(0,u.jsx)(Ep,{size:18})})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(p?"text-gray-300":"text-gray-700"),children:"Context"}),(0,u.jsx)("textarea",{value:L,onChange:e=>R(e.target.value),placeholder:"Why this reference is relevant...",rows:2,disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] resize-y ".concat(p?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(p?"text-gray-300":"text-gray-700"),children:"Visual Suggestion"}),(0,u.jsx)("input",{type:"text",value:z,onChange:e=>O(e.target.value),placeholder:"Photo, diagram, book cover...",disabled:v,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B] ".concat(p?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,u.jsx)("button",{onClick:()=>{i&&(A(i.title||""),M(i.category||""),B(i.linkText||""),P(i.url||""),R(i.context||""),O(i.visualSuggestion||"")),y(!1),F(null)},disabled:v,className:"px-4 py-2 rounded-lg font-medium transition-colors ".concat(p?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"),children:"Cancel"}),(0,u.jsx)("button",{onClick:async()=>{if(i)if(E.trim())if(!I||I.startsWith("http://")||I.startsWith("https://")){w(!0),F(null);try{await c(i,{name:E.trim(),category:T.trim()||void 0,linkText:_.trim()||void 0,url:I.trim()||void 0,context:L.trim()||void 0,visualSuggestion:z.trim()||void 0}),y(!1)}catch(e){F(e instanceof Error?e.message:"Failed to save changes")}finally{w(!1)}}else F("URL must start with http:// or https://");else F("Reference name is required")},disabled:v||!E.trim(),className:"px-4 py-2 rounded-lg font-medium text-white transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",style:{backgroundColor:"rgb(236, 72, 153)"},children:v?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),"Saving..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Dh,{size:16}),"Save Changes"]})})]})]}),o.length>1&&!b&&!D&&(0,u.jsxs)("div",{className:"px-5 py-4 border-t ".concat(p?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("h5",{className:"text-xs font-medium mb-3 ".concat(p?"text-gray-400":"text-gray-500"),children:["All References (",o.length,")"]}),(0,u.jsx)("div",{className:"max-h-48 overflow-y-auto",children:(0,u.jsx)("table",{className:"w-full text-xs",children:(0,u.jsx)("tbody",{children:o.map(e=>(0,u.jsxs)("tr",{onClick:()=>l(e),className:"cursor-pointer transition-colors ".concat((null===i||void 0===i?void 0:i.id)===e.id?p?"bg-[#232E3F]/70":"bg-[#EEF1F3]":p?"hover:bg-gray-700":"hover:bg-gray-100"),children:[(0,u.jsx)("td",{className:"py-1.5 px-2 w-8",children:e.url?(0,u.jsx)(pF,{size:12,className:"text-[#FFCF74]"}):(0,u.jsx)("span",{className:"inline-block w-3 h-3 rounded-full ".concat(p?"bg-gray-600":"bg-gray-300")})}),(0,u.jsxs)("td",{className:"py-1.5 px-2 ".concat(p?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("span",{className:"font-medium",children:e.title}),e.category&&(0,u.jsx)("span",{className:"ml-2 text-[10px] px-1.5 py-0.5 rounded ".concat(p?"bg-gray-700 text-gray-400":"bg-gray-200 text-gray-500"),children:e.category})]}),(0,u.jsx)("td",{className:"py-1.5 px-2 text-right",children:e.url&&(0,u.jsxs)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"text-[#FFCF74] hover:text-[#FFE3A1] hover:underline",children:[e.linkText||"Link"," \u2197"]})})]},e.id))})})})]})]})})}):null},jS=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return t>0?"".concat(t,":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")):"".concat(n,":").concat(a.toString().padStart(2,"0"))},DS=e=>{const t=e.split(":").map(e=>parseInt(e.trim(),10));return t.some(e=>isNaN(e))?null:2===t.length?60*t[0]+t[1]:3===t.length?3600*t[0]+60*t[1]+t[2]:null},CS=(e,t)=>{const n=e.split("<br/>").map(e=>
2e.trim()).filter(Boolean),a={};if(0===n.length)return a;const r=n[0],s="clip"===t?"[CLIP]":"[EDIT]";if(r.startsWith(s)){const e=r.substring(s.length).split("|").map(e=>e.trim());"clip"===t?(a.title=e[0]||"",a.clipType=e[1]||"",a.description=e[2]||"",a.visual=e[3]||""):(a.title=e[0]||"",a.suggestion=e[1]||"",a.improvement=e[2]||"",a.priority=e[3]||"")}return a};const NS=function(e){let{isOpen:t,onClose:n,element:r,elementType:s,onSave:i,onDelete:o,onSeek:l,allowDelete:c=!0,isDarkMode:d,canEdit:m}=e;const[h,p]=(0,a.useState)(!1),[g,x]=(0,a.useState)(!1),[f,b]=(0,a.useState)(!1),[y,v]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),[j,D]=(0,a.useState)(""),[C,N]=(0,a.useState)(""),[F,E]=(0,a.useState)(""),[A,T]=(0,a.useState)(""),[M,_]=(0,a.useState)(""),[B,I]=(0,a.useState)(""),[P,L]=(0,a.useState)(""),[R,z]=(0,a.useState)(""),[O,U]=(0,a.useState)("");(0,a.useEffect)(()=>{if(r){const e=CS(r.content,s);D(e.title||r.title||""),N(e.clipType||""),E(e.description||""),T(e.priority||""),_(e.suggestion||""),I(e.improvement||""),L(e.visual||""),z(jS(r.start)),U(jS(r.end))}p(!1),v(!1),k(null)},[r,t,s]);const V=()=>{g||f||n()};if(!r)return null;const H=CS(r.content,s),q=H.title||r.title||"Untitled ".concat(s),W="clip"===s?uj:yj,Y="clip"===s?"rgb(59, 130, 246)":"rgb(239, 68, 68)",G=d?"border border-white/10 bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.07),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.64),rgba(17,27,42,0.58))] text-gray-100 backdrop-blur-[32px]":"border border-[rgba(215,222,233,0.84)] bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.06),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.56),rgba(255,255,255,0.48))] text-gray-900 backdrop-blur-[30px]",K=d?"border-white/10 bg-white/[0.06] text-white placeholder-gray-400 backdrop-blur-[18px]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.44)] text-gray-900 placeholder-gray-400 backdrop-blur-[18px]",X=d?"bg-white/[0.07] text-gray-200 hover:bg-white/[0.12]":"bg-[rgba(255,255,255,0.42)] text-gray-700 hover:bg-[rgba(255,255,255,0.58)]";return(0,u.jsx)(S,{children:t&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:V,children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0,y:20},animate:{scale:1,opacity:1,y:0},exit:{scale:.9,opacity:0,y:20},className:"".concat(G," mx-4 w-full max-w-2xl overflow-hidden rounded-[24px] shadow-[0_28px_70px_-34px_rgba(0,0,0,0.52)]"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b ".concat(d?"border-gray-700":"border-gray-200"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center",style:{backgroundColor:Y},children:(0,u.jsx)(W,{size:16,className:"text-white"})}),(0,u.jsx)("h3",{className:"text-lg font-semibold ".concat(d?"text-white":"text-gray-900"),children:h?"Edit ".concat("clip"===s?"Clip":"Edit Point"):"clip"===s?"Clip":"Edit Point"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[m&&!h&&!y&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:()=>{p(!0),k(null)},className:"rounded-full p-2 transition-colors ".concat(X," ").concat(d?"hover:text-blue-300":"hover:text-blue-600"),title:"Edit ".concat(s),children:(0,u.jsx)(jj,{size:18})}),c&&(0,u.jsx)("button",{onClick:()=>v(!0),className:"rounded-full p-2 transition-colors ".concat(X," ").concat(d?"hover:text-red-300":"hover:text-red-600"),title:"Delete ".concat(s),children:(0,u.jsx)(kp,{size:18})})]}),(0,u.jsx)("button",{onClick:V,disabled:g||f,className:"rounded-full p-2 transition-colors ".concat(X),children:(0,u.jsx)(Pu,{size:20})})]})]}),w&&(0,u.jsx)("div",{className:"mx-5 mt-4 px-3 py-2 rounded-lg bg-red-100 dark:bg-red-900/30 border border-red-300 dark:border-red-700 text-red-700 dark:text-red-300 text-sm",children:w}),y&&(0,u.jsx)("div",{className:"px-5 py-4",children:(0,u.jsxs)("div",{className:"rounded-2xl border p-4 backdrop-blur-[22px] ".concat(d?"border-red-500/30 bg-red-900/22":"border-red-200/80 bg-[rgba(255,240,242,0.56)]"),children:[(0,u.jsxs)("p",{className:"text-sm mb-4 ".concat(d?"text-red-200":"text-red-800"),children:["Are you sure you want to delete this ",s,"? This action cannot be undone."]}),(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("button",{onClick:()=>v(!1),disabled:f,className:"rounded-xl px-4 py-2 font-medium transition-colors ".concat(X),children:"Cancel"}),(0,u.jsx)("button",{onClick:async()=>{if(r){b(!0),k(null);try{await o(r),n()}catch(e){k(e instanceof Error?e.message:"Failed to delete ".concat(s)),v(!1)}finally{b(!1)}}},disabled:f,className:"px-4 py-2 rounded-lg font-medium text-white bg-red-600 hover:bg-red-700 transition-colors flex items-center gap-2 disabled:opacity-50",children:f?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),"Deleting..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(kp,{size:16}),"Delete ","clip"===s?"Clip":"Edit Point"]})})]})]})}),!h&&!y&&(0,u.jsxs)("div",{className:"px-5 py-4 space-y-4",children:[(0,u.jsx)("div",{children:(0,u.jsx)("h4",{className:"text-xl font-medium ".concat(d?"text-white":"text-gray-900"),children:q})}),("clip"===s?H.clipType:H.priority)&&(0,u.jsx)("div",{className:"flex items-center gap-2",children:(0,u.jsx)("span",{className:"text-sm px-2 py-0.5 rounded-full text-white",style:{backgroundColor:Y},children:"clip"===s?H.clipType:H.priority})}),("clip"===s?H.description:H.suggestion)&&(0,u.jsx)("p",{className:"text-sm ".concat(d?"text-gray-300":"text-gray-600"),children:"clip"===s?H.description:H.suggestion}),"edit"===s&&H.improvement&&(0,u.jsxs)("div",{className:"text-sm ".concat(d?"text-gray-400":"text-gray-500"),children:[(0,u.jsx)("span",{className:"font-medium",children:"Improvement:"})," ",H.improvement]}),"clip"===s&&H.visual&&(0,u.jsxs)("div",{className:"text-sm ".concat(d?"text-gray-400":"text-gray-500"),children:[(0,u.jsx)("span",{className:"font-medium",children:"Visual:"})," ",H.visual]}),(0,u.jsxs)("button",{onClick:()=>{l(r.start),n()},className:"text-xs flex items-center gap-1.5 px-2 py-1 rounded transition-colors ".concat(d?"text-blue-400 hover:bg-blue-900/30":"text-blue-600 hover:bg-blue-50"),children:[(0,u.jsx)(wp,{size:12}),jS(r.start)," - ",jS(r.end)]})]}),h&&!y&&(0,u.jsxs)("div",{className:"px-5 py-4 space-y-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:["Title ",(0,u.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,u.jsx)("input",{type:"text",value:j,onChange:e=>D(e.target.value),placeholder:"".concat("clip"===s?"Clip":"Edit point"," title..."),disabled:g,className:"w-full rounded-xl border px-3 py-2 transition-colors focus:border-transparent focus:ring-2 ".concat(K),style:{"--tw-ring-color":Y}})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"Start Time"}),(0,u.jsx)("input",{type:"text",value:R,onChange:e=>z(e.target.value),placeholder:"MM:SS",disabled:g,className:"w-full rounded-xl border px-3 py-2 font-mono transition-colors focus:border-transparent focus:ring-2 ".concat(K)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"End Time"}),(0,u.jsx)("input",{type:"text",value:O,onChange:e=>U(e.target.value),placeholder:"MM:SS",disabled:g,className:"w-full rounded-xl border px-3 py-2 font-mono transition-colors focus:border-transparent focus:ring-2 ".concat(K)})]})]}),"clip"===s&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"Type"}),(0,u.jsxs)("select",{value:C,onChange:e=>N(e.target.value),disabled:g,className:"w-full rounded-xl border px-3 py-2 transition-colors focus:border-transparent focus:ring-2 ".concat(K),children:[(0,u.jsx)("option",{value:"",children:"Select type..."}),(0,u.jsx)("option",{value:"Viral Hook",children:"Viral Hook"}),(0,u.jsx)("option",{value:"Educational Nugget",children:"Educational Nugget"}),(0,u.jsx)("option",{value:"Humorous Aside",children:"Humorous Aside"}),(0,u.jsx)("option",{value:"Key Insight",children:"Key Insight"}),(0,u.jsx)("option",{value:"Quotable Moment",children:"Quotable Moment"}),(0,u.jsx)("option",{value:"Technical Deep Dive",children:"Technical Deep Dive"})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"Description"}),(0,u.jsx)("textarea",{value:F,onChange:e=>E(e.target.value),placeholder:"Describe this clip...",rows:2,disabled:g,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:border-transparent resize-y ".concat(d?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"Visual Suggestion"}),(0,u.jsx)("input",{type:"text",value:P,onChange:e=>L(e.target.value),placeholder:"Suggested visual treatment...",disabled:g,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:border-transparent ".concat(d?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]})]}),"edit"===s&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"Priority"}),(0,u.jsxs)("select",{value:A,onChange:e=>T(e.target.value),disabled:g,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:border-transparent ".concat(d?"bg-gray-900 border-gray-600 text-white":"bg-white border-gray-300 text-gray-900"),children:[(0,u.jsx)("option",{value:"",children:"Select priority..."}),(0,u.jsx)("option",{value:"High",children:"High"}),(0,u.jsx)("option",{value:"Medium",children:"Medium"}),(0,u.jsx)("option",{value:"Low",children:"Low"})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"Suggestion"}),(0,u.jsx)("textarea",{value:M,onChange:e=>_(e.target.value),placeholder:"What should be edited...",rows:2,disabled:g,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:border-transparent resize-y ".concat(d?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-1 ".concat(d?"text-gray-300":"text-gray-700"),children:"Improvement"}),(0,u.jsx)("input",{type:"text",value:B,onChange:e=>I(e.target.value),placeholder:"Expected improvement...",disabled:g,className:"w-full px-3 py-2 rounded-lg border transition-colors focus:ring-2 focus:border-transparent ".concat(d?"bg-gray-900 border-gray-600 text-white placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-400")})]})]}),(0,u.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,u.jsx)("button",{onClick:()=>
2{if(r){const e=CS(r.content,s);D(e.title||r.title||""),N(e.clipType||""),E(e.description||""),T(e.priority||""),_(e.suggestion||""),I(e.improvement||""),L(e.visual||""),z(jS(r.start)),U(jS(r.end))}p(!1),k(null)},disabled:g,className:"px-4 py-2 rounded-lg font-medium transition-colors ".concat(d?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"),children:"Cancel"}),(0,u.jsx)("button",{onClick:async()=>{if(!r)return;if(!j.trim())return void k("Title is required");const e=DS(R),t=DS(O);if(null!==e)if(null!==t)if(t<=e)k("End time must be after start time");else{x(!0),k(null);try{const n={title:j.trim(),start:e,end:t};"clip"===s?(n.clipType=C.trim()||void 0,n.description=F.trim()||void 0,n.visual=P.trim()||void 0):(n.priority=A.trim()||void 0,n.suggestion=M.trim()||void 0,n.improvement=B.trim()||void 0),await i(r,n),p(!1)}catch(n){k(n instanceof Error?n.message:"Failed to save changes")}finally{x(!1)}}else k("Invalid end time format (use MM:SS or HH:MM:SS)");else k("Invalid start time format (use MM:SS or HH:MM:SS)")},disabled:g||!j.trim(),className:"px-4 py-2 rounded-lg font-medium text-white transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",style:{backgroundColor:Y},children:g?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),"Saving..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Dh,{size:16}),"Save Changes"]})})]})]})]})})})},FS=Mo("square-stack",[["path",{d:"M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"4i38lg"}],["path",{d:"M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2",key:"mlte4a"}],["rect",{width:"8",height:"8",x:"14",y:"14",rx:"2",key:"1fa9i4"}]]),SS=Mo("clock-3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]),ES="/api/v1",AS=(e,t)=>{const n=new Headers(t);return n.set("Authorization","Bearer ".concat(e)),n},TS=async e=>{try{const t=await e.json();return(null===t||void 0===t?void 0:t.message)||(null===t||void 0===t?void 0:t.error)||"HTTP ".concat(e.status)}catch(_H){return await e.text().catch(()=>"")||"HTTP ".concat(e.status)}},MS=async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=await fetch("".concat(ES).concat(e),d(d({},n),{},{headers:AS(t,n.headers)}));if(!a.ok)throw new Error(await TS(a));return a.json()},_S=(e,t,n)=>{null!=n&&String(n).trim()&&e.append(t,String(n).trim())},BS=(e,t,n)=>{null!=n&&Number.isFinite(n)&&e.append(t,String(n))},IS=(e,t,n)=>{const a=new FormData;return a.append("file",e),_S(a,"label",t.label),_S(a,"description",t.description),_S(a,"role",t.role),_S(a,"alt_text",t.altText),_S(a,"source_url",t.sourceUrl),_S(a,"notes",t.notes),_S(a,"source_kind",t.sourceKind),n&&(_S(a,"ttml_checksum",n.ttmlChecksum),BS(a,"display_start",n.displayStart),BS(a,"display_end",n.displayEnd),BS(a,"source_start",n.sourceStart),BS(a,"source_end",n.sourceEnd),_S(a,"layout_mode",n.layoutMode),BS(a,"layout_x",n.layoutX),BS(a,"layout_y",n.layoutY),BS(a,"layout_width",n.layoutWidth),BS(a,"layout_height",n.layoutHeight),BS(a,"reference_index",n.referenceIndex),_S(a,"reference_title",n.referenceTitle)),a},PS=e=>{var t,n,a,r,s,i,o;return{ttml_checksum:e.ttmlChecksum||void 0,display_start:e.displayStart,display_end:e.displayEnd,source_start:null!==(t=e.sourceStart)&&void 0!==t?t:void 0,source_end:null!==(n=e.sourceEnd)&&void 0!==n?n:void 0,layout_mode:e.layoutMode||void 0,layout_x:null!==(a=e.layoutX)&&void 0!==a?a:void 0,layout_y:null!==(r=e.layoutY)&&void 0!==r?r:void 0,layout_width:null!==(s=e.layoutWidth)&&void 0!==s?s:void 0,layout_height:null!==(i=e.layoutHeight)&&void 0!==i?i:void 0,reference_index:null!==(o=e.referenceIndex)&&void 0!==o?o:void 0,reference_title:e.referenceTitle||void 0}},LS=e=>({ttml_checksum:e.ttmlChecksum||void 0,text:e.text,subtitle:e.subtitle||void 0,variant:e.variant||void 0,visibility:e.visibility||void 0,display_start:e.displayStart,display_end:e.displayEnd}),RS={async listSnapshot(e,t,n){const a=n?"?ttml_checksum=".concat(encodeURIComponent(n)):"",[r,s,i]=await Promise.all([MS("/episodes/".concat(encodeURIComponent(e),"/visuals/assets"),t),MS("/episodes/".concat(encodeURIComponent(e),"/visuals/placements").concat(a),t),MS("/episodes/".concat(encodeURIComponent(e),"/visuals/titles").concat(a),t)]);return Sm({selectedTtmlChecksum:n||null,assets:r,placements:s,titles:i,counts:{assets:r.length,placements:s.length,titles:i.length}})},async uploadAsset(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=await fetch("".concat(ES,"/episodes/").concat(encodeURIComponent(e),"/visuals/assets"),{method:"POST",headers:AS(t),body:IS(n,a)});if(!r.ok)throw new Error(await TS(r));return r.json()},updateAsset:(e,t,n,a)=>MS("/episodes/".concat(encodeURIComponent(e),"/visuals/assets/").concat(encodeURIComponent(n)),t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:a.label||void 0,description:a.description||void 0,role:a.role||void 0,alt_text:a.altText||void 0,source_url:a.sourceUrl||void 0,notes:a.notes||void 0,source_kind:a.sourceKind||void 0})}),async uploadAndPlace(e,t,n,a,r){const s=await fetch("".concat(ES,"/episodes/").concat(encodeURIComponent(e),"/visuals/assets/upload-and-place"),{method:"POST",headers:AS(t),body:IS(n,a,r)});if(!s.ok)throw new Error(await TS(s));return s.json()},createPlacement:(e,t,n,a)=>MS("/episodes/".concat(encodeURIComponent(e),"/visuals/placements"),t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d({asset_id:n},PS(a)))}),updatePlacementTiming(e,t,n,a){var r,s;return MS("/episodes/".concat(encodeURIComponent(e),"/visuals/placements/").concat(encodeURIComponent(n)),t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({display_start:a.displayStart,display_end:a.displayEnd,source_start:null!==(r=a.sourceStart)&&void 0!==r?r:void 0,source_end:null!==(s=a.sourceEnd)&&void 0!==s?s:void 0})})},updatePlacementLayout(e,t,n,a){var r,s,i,o;return MS("/episodes/".concat(encodeURIComponent(e),"/visuals/placements/").concat(encodeURIComponent(n),"/layout"),t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({layout_mode:a.layoutMode||void 0,layout_x:null!==(r=a.layoutX)&&void 0!==r?r:void 0,layout_y:null!==(s=a.layoutY)&&void 0!==s?s:void 0,layout_width:null!==(i=a.layoutWidth)&&void 0!==i?i:void 0,layout_height:null!==(o=a.layoutHeight)&&void 0!==o?o:void 0})})},async replacePlacement(e,t,n,a){var r,s,i,o,l,c,u,m,h,p;const g={ttmlChecksum:null!==(r=n.ttmlChecksum)&&void 0!==r?r:null,displayStart:n.displayStart,displayEnd:n.displayEnd,sourceStart:null!==(s=n.sourceStart)&&void 0!==s?s:null,
2sourceEnd:null!==(i=n.sourceEnd)&&void 0!==i?i:null,layoutMode:null!==(o=n.layoutMode)&&void 0!==o?o:null,layoutX:null!==(l=n.layoutX)&&void 0!==l?l:null,layoutY:null!==(c=n.layoutY)&&void 0!==c?c:null,layoutWidth:null!==(u=n.layoutWidth)&&void 0!==u?u:null,layoutHeight:null!==(m=n.layoutHeight)&&void 0!==m?m:null,referenceIndex:null!==(h=n.referenceIndex)&&void 0!==h?h:null,referenceTitle:null!==(p=n.referenceTitle)&&void 0!==p?p:null};await this.deletePlacement(e,t,n.id);try{var x,f;return await this.createPlacement(e,t,n.assetId,d(d({},a),{},{ttmlChecksum:null!==(x=null!==(f=a.ttmlChecksum)&&void 0!==f?f:n.ttmlChecksum)&&void 0!==x?x:null}))}catch(b){try{await this.createPlacement(e,t,n.assetId,g)}catch(y){}throw b}},deleteAsset:(e,t,n)=>MS("/episodes/".concat(encodeURIComponent(e),"/visuals/assets/").concat(encodeURIComponent(n)),t,{method:"DELETE"}),deletePlacement:(e,t,n)=>MS("/episodes/".concat(encodeURIComponent(e),"/visuals/placements/").concat(encodeURIComponent(n)),t,{method:"DELETE"}),createTitle:(e,t,n)=>MS("/episodes/".concat(encodeURIComponent(e),"/visuals/titles"),t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(LS(n))}),updateTitle:(e,t,n,a)=>MS("/episodes/".concat(encodeURIComponent(e),"/visuals/titles/").concat(encodeURIComponent(n)),t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(LS(a))}),deleteTitle:(e,t,n)=>MS("/episodes/".concat(encodeURIComponent(e),"/visuals/titles/").concat(encodeURIComponent(n)),t,{method:"DELETE"}),async exportOtio(e,t,n){const a=n?"?ttml_checksum=".concat(encodeURIComponent(n)):"",r=await fetch("".concat(ES,"/episodes/").concat(encodeURIComponent(e),"/visuals/export/otio").concat(a),{method:"GET",headers:AS(t)});if(!r.ok)throw new Error(await TS(r));const s=await r.blob(),i=(r.headers.get("content-disposition")||"").match(/filename="?([^"]+)"?/i);return{blob:s,filename:(null===i||void 0===i?void 0:i[1])||"session-visuals-".concat(e,".zip")}}},zS=10,OS=e=>{const t=Number(e);return Number.isFinite(t)?Math.min(30,Math.max(3,Math.round(t))):zS},US=e=>{if(null==e||!Number.isFinite(e))return"Unknown size";if(e<1024)return"".concat(e," B");const t=["KB","MB","GB"];let n=e,a=-1;for(;n>=1024&&a<t.length-1;)n/=1024,a+=1;return"".concat(n.toFixed(n>=10?0:1)," ").concat(t[Math.max(a,0)])},VS=(e,t,n,a)=>e<a&&t>n,HS=e=>String(e||"").startsWith("video/")?"Video asset":"Image asset",qS=e=>{let{label:t,file:n,disabled:r=!1,isDarkMode:s,helperText:i,onFileChange:o}=e;const l=(0,a.useRef)(null),[c,d]=(0,a.useState)(!1),m=e=>{null!==e&&void 0!==e&&e.length&&o(e[0])};return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"text-sm font-medium ".concat(s?"text-gray-200":"text-[#253245]"),children:t}),(0,u.jsxs)("div",{onDragOver:e=>{e.preventDefault(),r||d(!0)},onDragLeave:()=>d(!1),onDrop:e=>{e.preventDefault(),d(!1),r||m(e.dataTransfer.files)},className:"rounded-2xl border border-dashed p-4 transition-colors ".concat(c?s?"border-[#ffcf74] bg-[#3a2d0e]":"border-[#b57700] bg-[#fff6e1]":s?"border-white/12 bg-[#0d1522]":"border-[#d7dee9] bg-[#f8fafc]"),children:[(0,u.jsx)("input",{ref:l,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif,video/mp4,video/webm,video/quicktime",className:"hidden",onChange:e=>m(e.target.files),disabled:r}),(0,u.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{className:"text-sm font-medium ".concat(s?"text-white":"text-[#172033]"),children:n?n.name:"Drop a visual here or choose a file"}),(0,u.jsx)("div",{className:"mt-1 text-xs ".concat(s?"text-gray-400":"text-[#607089]"),children:n?"".concat(US(n.size)," \u2022 ").concat(n.type||"Unknown type"):i||"PNG, JPEG, WEBP, GIF, MP4, WEBM, MOV. Max 100 MB."})]}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.click()},disabled:r,className:"inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm font-medium transition-colors ".concat(s?"bg-[#1c2737] text-white hover:bg-[#243247]":"bg-white text-[#233044] hover:bg-[#eef3f9]"," disabled:cursor-not-allowed disabled:opacity-50"),children:[(0,u.jsx)(Eu,{size:15}),"Choose file"]}),n&&(0,u.jsxs)("button",{type:"button",onClick:()=>o(null),disabled:r,className:"inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm font-medium transition-colors ".concat(s?"bg-[#351a1f] text-[#ffd7df] hover:bg-[#432229]":"bg-[#fff0f2] text-[#8
2c2434] hover:bg-[#ffe2e6]"," disabled:cursor-not-allowed disabled:opacity-50"),children:[(0,u.jsx)(Pu,{size:15}),"Clear"]})]})]})]})]})},WS=e=>{let{title:t,subtitle:n,meta:a,badge:r,previewUrl:s,isDarkMode:i,linkHref:o,onSeek:l,actionLabel:c,actionDisabled:d=!1,onAction:m,onEdit:h,onDelete:p}=e;return(0,u.jsx)("div",{className:"rounded-2xl border p-3 ".concat(i?"border-white/10 bg-[#0f1724]":"border-[#d7dee9] bg-white"),children:(0,u.jsxs)("div",{className:"flex gap-3",children:[(0,u.jsx)("div",{className:"flex h-20 w-24 shrink-0 items-center justify-center overflow-hidden rounded-xl ".concat(i?"bg-white/5":"bg-[#f3f6fb]"),children:s?(0,u.jsx)("img",{src:s,alt:t,className:"h-full w-full object-cover",loading:"lazy"}):(0,u.jsx)(FS,{size:18,className:i?"text-gray-500":"text-[#8b99ad]"})}),(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{className:"truncate text-sm font-semibold ".concat(i?"text-white":"text-[#172033]"),children:t}),n&&(0,u.jsx)("div",{className:"mt-1 line-clamp-2 text-xs ".concat(i?"text-gray-300":"text-[#55657d]"),children:n})]}),r&&(0,u.jsx)("div",{className:"rounded-full px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.16em] ".concat(i?"bg-white/10 text-[#ffcf74]":"bg-[#fff3cf] text-[#8d5a00]"),children:r})]}),(0,u.jsx)("div",{className:"mt-2 text-xs ".concat(i?"text-gray-400":"text-[#6b7a8f]"),children:a}),(0,u.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[l&&(0,u.jsxs)("button",{type:"button",onClick:l,className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1.5 text-xs font-medium ".concat(i?"bg-white/10 text-gray-200 hover:bg-white/15":"bg-[#eef3f9] text-[#405167] hover:bg-[#e5ecf5]"),children:[(0,u.jsx)(SS,{size:12}),"Jump"]}),c&&(0,u.jsxs)("button",{type:"button",onClick:m,disabled:d||!m,className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1.5 text-xs font-medium ".concat(d||!m?i?"bg-white/8 text-gray-400":"bg-[#f1f4f8] text-[#8b97a8]":i?"bg-[#233148] text-[#ffcf74] hover:bg-[#2b3a54]":"bg-[#fff1ce] text-[#8a5b00] hover:bg-[#ffe6ae]"," disabled:cursor-not-allowed"),children:[(0,u.jsx)(ik,{size:12}),c]}),o&&(0,u.jsxs)("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1.5 text-xs font-medium ".concat(i?"bg-[#1d2940] text-[#ffcf74] hover:bg-[#24324d]":"bg-[#fff5da] text-[#8d5a00] hover:bg-[#ffeab6]"),children:[(0,u.jsx)(Ep,{size:12}),"Open"]}),h&&(0,u.jsxs)("button",{type:"button",onClick:h,className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1.5 text-xs font-medium ".concat(i?"bg-[#1d2940] text-[#d9e7ff] hover:bg-[#24324d]":"bg-[#edf3fb] text-[#39516a] hover:bg-[#e4ebf5]"),children:[(0,u.jsx)(jj,{size:12}),"Edit"]}),p&&(0,u.jsxs)("button",{type:"button",onClick:p,className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1.5 text-xs font-medium ".concat(i?"bg-[#341a1f] text-[#ffcfd8] hover:bg-[#442128]":"bg-[#fff0f2] text-[#9a2438] hover:bg-[#ffe1e6]"),children:[(0,u.jsx)(kp,{size:12}),"Delete"]})]})]})]})})},YS=e=>{let{isOpen:t,onClose:n,sessionId:r,token:s,isDarkMode:i,sessionTitle:o,selectedTtmlChecksum:l,initialDisplayStartSeconds:c=0,initialDisplayEndSeconds:d,initialReferenceIndex:m=null,initialReferenceTitle:h=null,onSeekTo:p,onChanged:g}=e;const[x,f]=(0,a.useState)({selectedTtmlChecksum:l||null,assets:[],placements:[],titles:[],counts:{assets:0,placements:0,titles:0}}),[b,y]=(0,a.useState)(!1),[v,w]=(0,a.useState)(null),[k,j]=(0,a.useState)(null),[D,C]=(0,a.useState)("asset"),[N,F]=(0,a.useState)("placements"),[E,A]=(0,a.useState)(null),[T,M]=(0,a.useState)(null),[_,B]=(0,a.useState)(!1),[I,P]=(0,a.useState)(null),[L,R]=(0,a.useState)(null),[z,O]=(0,a.useState)(""),[U,V]=(0,a.useState)(""),[H,q]=(0,a.useState)(""),[W,Y]=(0,a.useState)(""),[G,K]=(0,a.useState)(""),[X,J]=(0,a.useState)(""),[$,Q]=(0,a.useState)("authenticated"),[Z,ee]=(0,a.useState)(String(c)),[te,ne]=(0,a.useState)(String(null!==d&&void 0!==d?d:c+zS)),[ae,re]=(0,a.useState)(zS),se=null!=m||Boolean(h),ie=c,oe=Number.isFinite(d)&&Number(d)>c?Number(d):c+zS,le=(0,a.useMemo)(()=>se?x.placements.filter(e=>null!=m&&e.referenceIndex===m||(!(!h||!e.referenceTitle||e.referenceTitle.trim().toLowerCase()!==h.trim().toLowerCase())||null==e.referenceIndex&&!String(e.referenceTitle||"").trim()&&VS(e.displayStart,e.displayEnd,ie,oe))):x.placements,[se,m,h,oe,ie,x.placements]),ce=(0,a.useMemo)(()=>se?x.titles.filter(e=>VS(e.displayStart,e.displayEnd,ie,oe)):x.titles,[se,oe,ie,x.titles]),de=(0,a.useMemo)(()=>({assets:x.assets.length,placements:le.length,titles:ce.length}),[le.length,ce.length,x.assets.length]),ue="asset"===(null===I||void 0===I?void 0:I.kind),me="title"===(null===I||void 0===I?void 0:I.kind),he=(0,a.useCallback)(()=>
2{R(null),O(""),V(""),q(""),Y(""),K(""),J(""),Q("authenticated"),ee(String(c)),ne(String(null!==d&&void 0!==d?d:c+zS)),re(zS)},[c,d]),pe=(0,a.useCallback)(()=>{P(null),he()},[he]),ge=(0,a.useCallback)(async()=>{if(r)if(s){y(!0),w(null);try{const e=await RS.listSnapshot(r,s,l);f(e),null===g||void 0===g||g(e)}catch(e){w(e instanceof Error?e.message:"Failed to load session visuals")}finally{y(!1)}}else w("You must be logged in to manage session visuals")},[g,l,r,s]);(0,a.useEffect)(()=>{t&&ge()},[t,ge]),(0,a.useEffect)(()=>{t&&(P(null),C("asset"),F(se?"assets":"placements"),he(),j(null),w(null))},[se,t,he]);const xe=async(e,t)=>{A(e),w(null),j(null);try{await t(),await ge()}catch(n){w(n instanceof Error?n.message:"Action failed")}finally{A(null)}},fe=()=>{const e=se?ie:Number(Z),t=OS(ae);if(!Number.isFinite(e))throw new Error("Reference start time is unavailable");return{start:e,end:e+t}},be=async()=>{await xe(me?"update-title":"create-title",async()=>{if(!s)throw new Error("You must be logged in to edit visuals");const{start:e,end:t}=se?fe():((e,t)=>{const n=Number(e),a=Number(t);if(!Number.isFinite(n)||!Number.isFinite(a))throw new Error("Start and end must be valid numbers");if(n<0)throw new Error("Start must be 0 or greater");if(a<=n)throw new Error("End must be greater than start");return{start:n,end:a}})(Z,te),n=W.trim();if(!n)throw new Error("Title text is required");const a={ttmlChecksum:l,displayStart:e,displayEnd:t,text:n,subtitle:G,variant:X,visibility:$};if(me)return await RS.updateTitle(r,s,I.id,a),pe(),F("titles"),void j("Session title updated");await RS.createTitle(r,s,a),pe(),F("titles"),j("Session title created")})};if(!t)return null;const ye=i?"border-white/10 bg-[rgba(10,17,27,0.74)] text-white backdrop-blur-[28px]":"border-[rgba(215,222,233,0.86)] bg-[rgba(245,247,251,0.5)] text-[#172033] backdrop-blur-[32px]",ve=i?"border-white/10 bg-[rgba(17,27,42,0.52)] backdrop-blur-2xl":"border-[rgba(215,222,233,0.84)] bg-[rgba(255,255,255,0.42)] backdrop-blur-[30px]",we=i?"text-gray-400":"text-[#64748b]",ke=i?"border-white/12 bg-[rgba(10,17,27,0.58)] text-white placeholder:text-gray-500 backdrop-blur-xl":"border-[rgba(215,222,233,0.84)] bg-[rgba(255,255,255,0.48)] text-[#172033] placeholder:text-[#8c99ad] backdrop-blur-[24px]",je="upload-asset"===E||"update-asset"===E,De="create-title"===E||"update-title"===E,Ce="export-otio"===E;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(S,{children:t&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-black/55 backdrop-blur-sm",onClick:n,children:(0,u.jsxs)(Do.div,{initial:{opacity:0,y:20,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:18,scale:.98},className:"mx-auto mt-6 flex max-h-[92vh] w-[min(1180px,calc(100vw-24px))] flex-col overflow-hidden rounded-[28px] border shadow-[0_36px_90px_-45px_rgba(15,23,36,0.9)] ".concat(ye),onClick:e=>e.stopPropagation(),children:[(0,u.jsx)("div",{className:"border-b px-5 py-4 ".concat(i?"border-white/10":"border-[#d7dee9]"),children:(0,u.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-2xl ".concat(i?"bg-[#1b2a41]":"bg-[#edf3fb]"),children:(0,u.jsx)(uj,{size:18,className:i?"text-[#ffcf74]":"text-[#a56900]"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-lg font-semibold",children:"Session Visuals"}),(0,u.jsx)("div",{className:"text-sm ".concat(we),children:o||r})]})]}),(0,u.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2 text-xs ".concat(we),children:[(0,u.jsxs)("span",{className:"rounded-full px-2 py-1 ".concat(i?"bg-white/8":"bg-[#eef3f9]"),children:[de.assets," assets"]}),(0,u.jsx)("span",{className:"rounded-full px-2 py-1 ".concat(i?"bg-white/8":"bg-[#eef3f9]"),children:"".concat(de.placements,se?" on this ref":" placements")}),(0,u.jsx)("span",{className:"rounded-full px-2 py-1 ".concat(i?"bg-white/8":"bg-[#eef3f9]"),children:"".concat(de.titles,se?" title overlap":" titles")}),l&&(0,u.jsxs)("span",{className:"rounded-full px-2 py-1 ".concat(i?"bg-[#21304a] text-[#ffcf74]":"bg-[#fff4d5] text-[#8b5b00]"),children:["TTML ",l.slice(0,10)]})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{await xe("export-otio",async()=>{if(!s)throw new Error("You must be logged in to export session visuals");const{blob:e,filename:t}=await RS.exportOtio(r,s,l||x.selectedTtmlChecksum||null),n=window.URL.createObjectURL(e),a=document.createElement("a");a.href=n,a.download=t,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>window.URL.revokeObjectURL(n),1e3),j("OTIO package downloaded")})})()},disabled:Ce||!s,className:"inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm font-medium transition-colors ".concat(i?"bg-[#233148] text-[#ffcf74] hover:bg-[#2b3a54]":"bg-[#fff1ce] text-[#8a5b00] hover:bg-[#ffe6ae]"," disabled:cursor-not-allowed disabled:opacity-60"),title:s?"Download OTIO zip bundle for the active TTML revision":"Log in to export session visuals",children:[Ce?(0,u.jsx)(Lo,{size:15,className:"animate-spin"}):(0,u.jsx)(Sp,{size:15}),"Export OTIO"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{ge()},disabled:b,className:"inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm font-medium transition-colors ".concat(i?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#edf3fb] text-[#304257] hover:bg-[#e3ebf6]"," disabled:cursor-not-allowed disabled:opacity-60"),children:[b?(0,u.jsx)(Lo,{size:15,className:"animate-spin"}):(0,u.jsx)(vp,{size:15}),"Refresh"]}),(0,u.jsx)("button",{type:"button",onClick:n,className:"inline-flex h-10 w-10 items-center justify-center rounded-full transition-colors ".concat(i?"bg-white/8 text-gray-300 hover:bg-white/14":"bg-[#edf3fb] text-[#304257] hover:bg-[#e3ebf6]"),children:(0,u.jsx)(Pu,{size:18})})]})]})}),(v||k)&&(0,u.jsxs)("div",{className:"px-5 pt-4",children:[v&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(i?"border-[#5c2630] bg-[#33171d] text-[#ffd4dc]":"border-[#f0bcc6] bg-[#fff1f4] text-[#92263b]"),children:v}),!v&&k&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(i?"border-[#24513d] bg-[#11271d] text-[#cbffe7]":"border-[#bfe8d0] bg-[#effcf4] text-[#1d6a46]"),children:k})]}),(0,u.jsxs)("div",{className:"grid min-h-0 flex-1 gap-4 overflow-hidden px-5 py-4 lg:grid-cols-[380px_minmax(0,1fr)]",children:[(0,u.jsx)("div",{className:"min-h-0 overflow-y-auto pr-1",children:(0,u.jsxs)("div",{className:"rounded-[24px] border p-4 ".concat(ve),children:[(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:[{key:"asset",label:"Upload Asset",icon:Eu},{key:"title",label:"Create Title",icon:_w}].map(e=>{let{key:t,label:n,icon:a}=e;const r=D===t;return(0,u.jsxs)("button",{type:"button",onClick:()=>{D!==t&&pe(),C(t)},className:"inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm font-medium transition-colors ".concat(r?i?"bg-[#233148] text-[#ffcf74]":"bg-[#fff1ce] text-[#8a5b00]":i?"bg-white/6 text-gray-300 hover:bg-white/12":"bg-[#f2f5fa] text-[#4d6076] hover:bg-[#e7edf6]"),children:[(0,u.jsx)(a,{size:15}),n]},t)})}),(0,u.jsxs)("div",{className:"mt-4 space-y-4",children:[se&&(0,u.jsxs)("div",{className:"rounded-2xl border px-4 py-3 ".concat(i?"border-[#3c4f6a] bg-[#0e1826]":"border-[#d7dee9] bg-[#f8fbff]"),children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-sm font-semibold ".concat(i?"text-white":"text-[#172033]"),children:"This dialog is scoped to the current reference"}),(0,u.jsxs)("div",{className:"mt-1 text-xs ".concat(we),children:[h||"Reference #".concat(null!==m&&void 0!==m?m:"?")," at ",jm(ie),". New visuals inherit this reference start and stay on screen for the duration below."]})]}),null!=m&&(0,u.jsxs)("div",{className:"rounded-full px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] ".concat(i?"bg-[#233148] text-[#ffcf74]":"bg-[#fff1ce] text-[#8a5b00]"),children:["Ref #",m]})]}),(0,u.jsxs)("div",{className:"mt-4",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,u.jsx)("label",{className:"text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"On-screen duration"}),(0,u.jsxs)("div",{className:"text-sm font-semibold ".concat(i?"text-[#ffcf74]":"text-[#8a5b00]"),children:[OS(ae),"s"]})]}),(0,u.jsx)("input",{type:"range",min:3,max:30,step:1,value:OS(ae),onChange:e=>re(OS(Number(e.target.value))),className:"mt-3 w-full accent-[#ffcf74]"}),(0,u.jsxs)("div",{className:"mt-2 flex justify-between text-[11px] ".concat(we),children:[(0,u.jsxs)("span",{children:[3,"s"]}
2),(0,u.jsxs)("span",{children:[30,"s"]})]})]})]}),(ue||me)&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(i?"border-[#3c4f6a] bg-[#122034] text-[#d9e7ff]":"border-[#c9d8ea] bg-[#eef5ff] text-[#284562]"),children:(0,u.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,u.jsxs)("div",{children:["Editing existing ",ue?"asset":"title","."]}),(0,u.jsxs)("button",{type:"button",onClick:pe,className:"inline-flex items-center gap-2 rounded-full px-3 py-1.5 text-xs font-semibold ".concat(i?"bg-white/10 text-white hover:bg-white/15":"bg-white text-[#284562] hover:bg-[#f8fbff]"),children:[(0,u.jsx)(Pu,{size:12}),"Cancel edit"]})]})}),"asset"===D&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qS,{label:"Asset file",file:L,onFileChange:R,isDarkMode:i,disabled:je,helperText:ue?"Editing metadata only. Leave the file empty unless you want to abandon edit mode and upload a fresh asset.":se?"Uploads into the session-wide library. Use \u201cAdd to this reference\u201d from the Assets tab when you want it on screen here.":void 0}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Label"}),(0,u.jsx)("input",{type:"text",value:z,onChange:e=>O(e.target.value),placeholder:"Homepage still, chart, paper figure...",className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Description"}),(0,u.jsx)("textarea",{value:U,onChange:e=>V(e.target.value),placeholder:"What is this visual for?",rows:3,className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Source URL"}),(0,u.jsx)("input",{type:"url",value:H,onChange:e=>q(e.target.value),placeholder:"https://...",className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{ue||L?await xe(ue?"update-asset":"upload-asset",async()=>{if(!s)throw new Error("You must be logged in to edit visuals");if(ue)return await RS.updateAsset(r,s,I.id,{label:z,description:U,sourceUrl:H}),pe(),F("assets"),void j("Visual asset updated");const e=L;if(!e)throw new Error("Choose a file to upload");await RS.uploadAsset(r,s,e,{label:z||void 0,description:U||void 0,sourceUrl:H||void 0}),pe(),F("assets"),j("Visual asset uploaded")}):w("Choose a file to upload")})()},disabled:je,className:"inline-flex w-full items-center justify-center gap-2 rounded-2xl px-4 py-3 text-sm font-semibold ".concat(i?"bg-[#ffcf74] text-[#231b08] hover:bg-[#ffd789]":"bg-[#232e3f] text-white hover:bg-[#1a2432]"," disabled:cursor-not-allowed disabled:opacity-60"),children:[je?(0,u.jsx)(Lo,{size:16,className:"animate-spin"}):(0,u.jsx)(Eu,{size:16}),ue?"Update asset":"Upload asset"]})]}),"title"===D&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Title text"}),(0,u.jsx)("input",{type:"text",value:W,onChange:e=>Y(e.target.value),placeholder:"Main title",className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Subtitle"}),(0,u.jsx)("input",{type:"text",value:G,onChange:e=>K(e.target.value),placeholder:"Optional subtitle",className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]}),!se&&(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Display start (episode seconds)"}),(0,u.jsx)("input",{type:"number",min:"0",step:"0.1",value:Z,onChange:e=>ee(e.target.value),className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Display end (episode seconds)"}),(0,u.jsx)("input",{type:"number",min:"0",step:"0.1",value:te,onChange:e=>ne(e.target.value),className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Visibility"}),(0,u.jsxs)("select",{value:$,onChange:e=>Q(e.target.value),className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke),children:[(0,u.jsx)("option",{value:"authenticated",children:"Authenticated"}),(0,u.jsx)("option",{value:"public",children:"Public"}),(0,u.jsx)("option",{value:"private",children:"Private"})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"mb-1 block text-sm font-medium ".concat(i?"text-gray-200":"text-[#253245]"),children:"Variant"}),(0,u.jsx)("input",{type:"text",value:X,onChange:e=>J(e.target.value),placeholder:"Optional variant",className:"w-full rounded-2xl border px-3 py-2.5 text-sm outline-none transition-colors focus:border-[#ffcf74] ".concat(ke)})]})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{be()},disabled:De,className:"inline-flex w-full items-center justify-center gap-2 rounded-2xl px-4 py-3 text-sm font-semibold ".concat(i?"bg-[#ffcf74] text-[#231b08] hover:bg-[#ffd789]":"bg-[#232e3f] text-white hover:bg-[#1a2432]"," disabled:cursor-not-allowed disabled:opacity-60"),children:[De?(0,u.jsx)(Lo,{size:16,className:"animate-spin"}):(0,u.jsx)(_w,{size:16}
2),me?"Update title":"Create title"]})]})]})]})}),(0,u.jsx)("div",{className:"min-h-0 overflow-y-auto pr-1",children:(0,u.jsxs)("div",{className:"rounded-[24px] border p-4 ".concat(ve),children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-sm font-semibold",children:se?"Current reference":"Current library"}),(0,u.jsx)("div",{className:"mt-1 text-xs ".concat(we),children:se?"Visuals shown in \u201cAttached Here\u201d are filtered to this reference. Assets remain session-wide, and titles are reusable on this TTML revision. Use the action buttons to cue them at this reference start.":"Assets are reusable media for the session. Placements are timed uses of an asset on this TTML revision. Titles are timed text overlays on this TTML revision."})]}),(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:[{key:"placements",label:"".concat(se?"Attached Here":"Placements"," (").concat(de.placements,")"),icon:uj},{key:"titles",label:"Titles (".concat(se?ce.length:x.titles.length,")"),icon:_w},{key:"assets",label:"Assets (".concat(de.assets,")"),icon:Ty}].map(e=>{let{key:t,label:n,icon:a}=e;const r=N===t;return(0,u.jsxs)("button",{type:"button",onClick:()=>F(t),className:"inline-flex items-center gap-2 rounded-full px-3 py-2 text-sm font-medium transition-colors ".concat(r?i?"bg-[#233148] text-[#ffcf74]":"bg-[#fff1ce] text-[#8a5b00]":i?"bg-white/6 text-gray-300 hover:bg-white/12":"bg-[#f2f5fa] text-[#4d6076] hover:bg-[#e7edf6]"),children:[(0,u.jsx)(a,{size:15}),n]},t)})})]}),(0,u.jsx)("div",{className:"mt-4",children:b?(0,u.jsx)("div",{className:"flex min-h-[240px] items-center justify-center rounded-2xl border ".concat(i?"border-white/10 bg-[#0a111b]":"border-[#d7dee9] bg-[#f8fafc]"),children:(0,u.jsxs)("div",{className:"inline-flex items-center gap-2 text-sm ".concat(we),children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),"Loading session visuals"]})}):"placements"===N?le.length?(0,u.jsx)("div",{className:"space-y-3",children:le.map(e=>{var t;return(0,u.jsx)(WS,{title:e.label||e.referenceTitle||e.filename||HS(e.mimeType),subtitle:e.description||e.referenceTitle||null,badge:null!==(t=e.mimeType)&&void 0!==t&&t.startsWith("video/")?"Video":"Image",meta:["".concat(jm(e.displayStart)," for ").concat(Math.max(1,Math.round(e.displayEnd-e.displayStart)),"s"),e.renderQuality?"quality ".concat(e.renderQuality):null,null!=e.referenceIndex?"ref #".concat(e.referenceIndex):null].filter(Boolean).join(" \u2022 "),previewUrl:Dm(e),isDarkMode:i,linkHref:e.playbackUrl||e.url||e.originalUrl||null,onSeek:p?()=>p(e.displayStart):void 0,onDelete:()=>M({kind:"placement",id:e.id,label:e.referenceTitle||e.filename||e.id})},e.id)})}):(0,u.jsx)("div",{className:"rounded-2xl border border-dashed p-6 text-sm ".concat(i?"border-white/12 text-gray-400":"border-[#d7dee9] text-[#607089]"),children:se?"No visuals are attached to this reference yet. Use the Assets tab to add one from the session library.":"No placements on this TTML revision yet. Assets stay in the session library until you place them on this specific TTML revision."}):"titles"===N?x.titles.length?(0,u.jsx)("div",{className:"space-y-3",children:x.titles.map(e=>(()=>{const t=se&&VS(e.displayStart,e.displayEnd,ie,oe);return(0,u.jsx)(WS,{title:e.text,subtitle:e.subtitle||null,badge:e.visibility||null,meta:["".concat(jm(e.displayStart)," for ").concat(Math.max(1,Math.round(e.displayEnd-e.displayStart)),"s"),e.variant||null,t?"already on this reference":null].filter(Boolean).join(" \u2022 "),previewUrl:e.url||void 0,isDarkMode:i,linkHref:e.url||null,onSeek:p?()=>p(e.displayStart):void 0,actionLabel:se?t?"On this reference":"Add to this reference":null,actionDisabled:t,onAction:se&&!t?()=>{(async e=>{if(!se)return void w("Open Session Visuals from a reference to cue an existing title here");const t=x.titles.find(t=>t.id===e);t?await xe("reuse-title-".concat(e),async()=>{if(!s)throw new Error("You must be logged in to edit visuals");const{start:e,end:n}=fe();await RS.createTitle(r,s,{ttmlChecksum:l||x.selectedTtmlChecksum||null,text:t.text,subtitle:t.subtitle||"",variant:t.variant||"",visibility:t.visibility||"authenticated",displayStart:e,displayEnd:n}),F("titles"),j("Title cued at this reference")}):w("Title not found in current TTML snapshot")})(e.id)}:void 0,onEdit:()=>(e=>{const t=x.titles.find(t=>
2t.id===e);t&&(C("title"),P({kind:"title",id:e}),Y(t.text||""),K(t.subtitle||""),J(t.variant||""),Q(t.visibility||"authenticated"),ee(String(t.displayStart)),ne(String(t.displayEnd)),re(OS(t.displayEnd-t.displayStart)),w(null),j(null))})(e.id),onDelete:()=>M({kind:"title",id:e.id,label:e.text})},e.id)})())}):(0,u.jsx)("div",{className:"rounded-2xl border border-dashed p-6 text-sm ".concat(i?"border-white/12 text-gray-400":"border-[#d7dee9] text-[#607089]"),children:"No authored titles on this TTML revision yet."}):x.assets.length?(0,u.jsx)("div",{className:"space-y-3",children:x.assets.map(e=>(0,u.jsx)(WS,{title:e.label||e.filename||HS(e.mimeType),subtitle:e.description||e.notes||null,badge:HS(e.mimeType),meta:[e.mimeType||null,US(e.fileSize),e.width&&e.height?"".concat(e.width,"x").concat(e.height):null,e.durationSeconds?"".concat(e.durationSeconds.toFixed(1),"s"):null].filter(Boolean).join(" \u2022 "),previewUrl:Dm(e),isDarkMode:i,linkHref:e.playbackUrl||e.url||e.originalUrl||null,actionLabel:se?"Add to this reference":null,onAction:se?()=>{(async e=>{se?await xe("attach-asset-".concat(e),async()=>{if(!s)throw new Error("You must be logged in to edit visuals");const{start:t,end:n}=fe();await RS.createPlacement(r,s,e,{ttmlChecksum:l||x.selectedTtmlChecksum||null,displayStart:t,displayEnd:n,referenceIndex:null!==m&&void 0!==m?m:void 0,referenceTitle:h||void 0}),F("placements"),j("Asset attached to this reference")}):w("Open Session Visuals from a reference to attach an existing asset")})(e.id)}:void 0,onEdit:()=>(e=>{const t=x.assets.find(t=>t.id===e);t&&(C("asset"),P({kind:"asset",id:e}),R(null),O(t.label||""),V(t.description||""),q(t.sourceUrl||""),w(null),j(null))})(e.id),onDelete:()=>M({kind:"asset",id:e.id,label:e.label||e.filename||e.id})},e.id))}):(0,u.jsx)("div",{className:"rounded-2xl border border-dashed p-6 text-sm ".concat(i?"border-white/12 text-gray-400":"border-[#d7dee9] text-[#607089]"),children:"No uploaded assets yet. Upload one on the left, then add it to this reference from here."})})]})})]})]})})}),(0,u.jsx)(vj,{isOpen:!!T,onClose:()=>{_||M(null)},onConfirm:()=>{(async()=>{if(T){B(!0),w(null),j(null);try{if(!s)throw new Error("You must be logged in to delete visuals");"asset"===T.kind?await RS.deleteAsset(r,s,T.id):"placement"===T.kind?await RS.deletePlacement(r,s,T.id):await RS.deleteTitle(r,s,T.id),M(null),j("Deleted ".concat(T.kind)),await ge()}catch(e){w(e instanceof Error?e.message:"Delete failed")}finally{B(!1)}}})()},title:"Delete ".concat((null===T||void 0===T?void 0:T.kind)||"item"),message:'Delete "'.concat((null===T||void 0===T?void 0:T.label)||"",'"? This cannot be undone.'),confirmText:"Delete",confirmButtonClassName:"bg-red-600 hover:bg-red-700",isLoading:_})]})},GS=e=>{const t=(0,a.useRef)(e),[n,r]=a.useState(0);console.log("[IsolatedCommentsWrapper] Props received:",{sessionId:e.sessionId,token:e.token,isPublicView:e.isPublicView,isInline:e.isInline}),(0,a.useEffect)(()=>{(t.current.sessionId!==e.sessionId||t.current.token!==e.token||t.current.isPublicView!==e.isPublicView||t.current.pendingTimestamp!==e.pendingTimestamp||t.current.selectedCommentId!==e.selectedCommentId)&&(t.current=e,r(e=>e+1))},[e.sessionId,e.token,e.isPublicView,e.pendingTimestamp,e.selectedCommentId]);const s=(0,a.useRef)(e.onClose),i=(0,a.useRef)(e.onCommentsChange);return(0,a.useEffect)(()=>{s.current=e.onClose,i.current=e.onCommentsChange}),(0,u.jsx)(rk,{sessionId:t.current.sessionId,token:t.current.token,isPublicView:t.current.isPublicView,isInline:t.current.isInline,pendingTimestamp:t.current.pendingTimestamp,selectedCommentId:t.current.selectedCommentId,onClose:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.call(s)},onCommentsChange:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.call(i,e)},initialComments:t.current.initialComments,disablePolling:t.current.disablePolling},n)},KS=a.memo(GS),XS=Mo("radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);function JS(e){return e.name||e.email||"Anonymous ".concat(e.animal.name)}function $S(e,t){const n=String(e.email||"").trim().toLowerCase(),a=String(t||"").trim().toLowerCase();return Boolean(n&&a&&n===a)}function QS(e){const t=String(e.name||e.email||"").trim();if(!t)return"?";
2const n=t.split(/\s+/).filter(Boolean);return n.length>1?"".concat(n[0][0]).concat(n[n.length-1][0]).toUpperCase():t.slice(0,2).toUpperCase()}const ZS={NODE_ENV:"production",PUBLIC_URL:"https://files.rescript.info",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_GOOGLE_CLIENT_ID:"650914284514-arrnrmrkrk8r37chamjmk7ta7tfj5nuk.apps.googleusercontent.com"}.REACT_APP_API_URL||"",eE=(0,a.createContext)(void 0);const tE=e=>{let{children:t}=e;const n=rc(),{token:r,user:s}=am(),{duration:i,isPlaying:o,playbackRate:l,play:c,pause:d,seekTo:m,setPlaybackRate:h,getPlaybackSnapshot:p}=Kw(),g=(0,a.useMemo)(()=>function(e){const t=e.match(/^\/session\/([^/?#]+)/);return t?decodeURIComponent(t[1]):null}(n.pathname),[n.pathname]),x=(0,a.useMemo)(()=>new URLSearchParams(n.search).get("share"),[n.search]),f=Boolean(g&&(x||r&&s)),b=(0,a.useRef)("undefined"!==typeof crypto&&"function"===typeof crypto.randomUUID?crypto.randomUUID():"presence-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2))),[y,v]=(0,a.useState)([]),[w,k]=(0,a.useState)("inactive"),[j,D]=(0,a.useState)("session"),[C,N]=(0,a.useState)(null),F=(0,a.useRef)(0),S=(0,a.useRef)([]),E=(0,a.useRef)(null),A=(0,a.useRef)(j),T=(0,a.useRef)(l),M=(0,a.useRef)(Date.now());(0,a.useEffect)(()=>{E.current=C},[C]),(0,a.useEffect)(()=>{A.current=j},[j]),(0,a.useEffect)(()=>{T.current=l},[l]);const _=(0,a.useCallback)(function(e){return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a=e.playback,r=Number.isFinite(a.duration)&&a.duration>0?a.duration:Number.POSITIVE_INFINITY,s=a.isPlaying?Math.max(0,(t+n-a.updatedAt)/1e3):0;return Math.max(0,Math.min(r,a.time+s*a.playbackRate))}(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),F.current)},[]),B=(0,a.useCallback)(e=>x?"".concat(ZS,"/api/public/share/").concat(encodeURIComponent(x),"/presence"):"".concat(ZS,"/api/sessions/").concat(encodeURIComponent(e),"/presence"),[x]),I=(0,a.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=p(),a=await fetch(B(e),{method:"POST",credentials:x?"omit":"include",keepalive:t,headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:b.current,activityAt:M.current,activeArea:A.current,playback:{time:n.currentTime,duration:n.duration,isPlaying:n.isPlaying,playbackRate:T.current}})});if(!a.ok)throw new Error("Presence update failed (".concat(a.status,")"))},[p,B,x]),P=(0,a.useCallback)(e=>{fetch(B(e),{method:"DELETE",credentials:x?"omit":"include",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:b.current})}).catch(()=>{})},[B,x]);(0,a.useEffect)(()=>{if(!g||!f)return v([]),k("inactive"),void N(null);let e=!1,t=null;k("connecting");const n="".concat(B(g),"/stream"),a=new EventSource(n,{withCredentials:!x});a.onopen=()=>{e||k("connected")},a.onerror=()=>{e||k("reconnecting")},a.onmessage=t=>{if(!e)try{const e=JSON.parse(t.data),n=Date.now();F.current=e.serverTime-n,v(e.participants||[])}catch(n){console.warn("[PRESENCE] Ignoring malformed snapshot:",n)}};const r=async()=>{if(e)return;try{await I(g)}catch(a){e||console.warn("[PRESENCE] Update failed; the stream will retry:",a)}if(e)return;const n=p();t=setTimeout(r,n.isPlaying?750:4e3)};r();const s=()=>P(g),i=()=>{M.current=Date.now()},o=()=>{i(),I(g).catch(()=>{})},l=()=>{"visible"===document.visibilityState&&o()};return window.addEventListener("pagehide",s),window.addEventListener("pointerdown",i,!0),window.addEventListener("keydown",i,!0),window.addEventListener("focus",o),document.addEventListener("visibilitychange",l),()=>{e=!0,a.close(),t&&clearTimeout(t),window.removeEventListener("pagehide",s),window.removeEventListener("pointerdown",i,!0),window.removeEventListener("keydown",i,!0),window.removeEventListener("focus",o),document.removeEventListener("visibilitychange",l),P(g)}},[p,P,I,f,B,g,x]),(0,a.useEffect)(()=>{g&&f&&I(g).catch(()=>{})},[j,i,o,l,I,f,g]);const L=(0,a.useMemo)(()=>y.find(e=>e.clientId===b.current||$S(e,null===s||void 0===s?void 0:s.email))||null,[y,null===s||void 0===s?void 0:s.email]),R=(0,a.useMemo)(()=>y.filter(e=>e.clientId!==b.current&&!$S(e,null===s||void 0===s?void 0:s.email)),[y,null===s||void 0===s?void 0:s.email]);(0,a.useEffect)(()=>{S.current=R},[R]);const z=(0,a.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=_(e),a=p();(t||Math.abs(a.currentTime-n)>.35)&&m(n),Math.abs(l-e.playback.playbackRate)>.001&&h(e.playback.playbackRate),e.playback.isPlaying&&!a.isPlaying?c():!e.playback.isPlaying&&a.isPlaying&&d()},[_,p,d,c,l,m,h]),O=(0,a.useCallback)(()=>N(null),[]),U=(0,a.useCallback)(e=>{if(E.current===e)return void N(null);const t=S.current.find(t=>
2t.id===e);t&&(N(e),z(t,!0))},[z]);(0,a.useEffect)(()=>{if(!C)return;const e=()=>{const e=S.current.find(e=>e.id===E.current);e?z(e):N(null)};e();const t=setInterval(e,500);return()=>clearInterval(t)},[C,z]);const V=(0,a.useMemo)(()=>{const e=Date.now();return R.map(t=>({id:t.id,label:JS(t),color:t.animal.color,glyph:t.animal.glyph,picture:t.picture,isAnonymous:t.isAnonymous,initials:QS(t),time:_(t,e),isPlaying:t.playback.isPlaying,isFollowing:t.id===C}))},[R,_,C]),H=(0,a.useMemo)(()=>({sessionId:g,connectionState:w,participants:y,collaborators:R,self:L,followingParticipantId:C,setActiveArea:D,estimateTime:_,transcriptCursors:V,followParticipant:U,stopFollowing:O}),[R,w,_,U,C,y,L,g,O,V]);return(0,u.jsx)(eE.Provider,{value:H,children:t})};function nE(){const e=(0,a.useContext)(eE);if(!e)throw new Error("usePresence must be used within a PresenceProvider");return e}function aE(e,t){return/^#[0-9a-f]{6}$/i.test(e)?"".concat(e).concat(t):e}const rE=e=>{let{glyph:t,color:n,label:r,picture:s=null,isAnonymous:i=!0,initials:o="?",size:l=32,isPlaying:c=!1,isFollowing:d=!1,showPlaybackState:m=!1,className:h=""}=e;const[p,g]=(0,a.useState)(!1);(0,a.useEffect)(()=>g(!1),[s]);const x=i?n:"#475569";return(0,u.jsxs)("span",{className:"relative inline-flex shrink-0 items-center justify-center rounded-full border-2 border-white text-center shadow-lg dark:border-[#111826] ".concat(h),style:{width:l,height:l,fontSize:Math.round(.52*l),lineHeight:1,backgroundColor:x,backgroundImage:i?"radial-gradient(circle at 30% 24%, rgba(255,255,255,0.72), transparent 27%), repeating-linear-gradient(135deg, transparent 0 6px, ".concat(aE(n,"33")," 6px 9px)"):"linear-gradient(145deg, #64748b, #334155)",boxShadow:d?"0 0 0 3px ".concat(aE(n,"66"),", 0 8px 18px rgba(15,23,42,0.28)"):"0 8px 18px rgba(15,23,42,0.24)"},title:r,"aria-label":r,children:[i?(0,u.jsx)("span",{"data-presence-avatar-kind":"animal","aria-hidden":"true",style:{transform:"translateY(1px)"},children:t}):s&&!p?(0,u.jsx)("img",{"data-presence-avatar-kind":"profile",src:s,alt:"",referrerPolicy:"no-referrer",className:"h-full w-full rounded-full object-cover",onError:()=>g(!0)}):(0,u.jsx)("span",{"data-presence-avatar-kind":"initials","aria-hidden":"true",className:"inline-flex h-full w-full items-center justify-center rounded-full font-bold tracking-tight",style:{fontSize:Math.max(8,Math.round(.3*l))},children:o}),m&&(0,u.jsx)("span",{className:"absolute -bottom-1 -right-1 inline-flex items-center justify-center rounded-full border border-white bg-[#232E3F] text-white shadow-sm dark:border-[#111826]",style:{width:Math.max(13,.4*l),height:Math.max(13,.4*l)},"aria-hidden":"true",children:c?(0,u.jsx)(kh,{size:Math.max(7,.22*l),fill:"currentColor"}):(0,u.jsx)(wh,{size:Math.max(7,.22*l),fill:"currentColor"})})]})};function sE(e){const[t,n]=(0,a.useState)(()=>Date.now());return(0,a.useEffect)(()=>{if(!e)return;const t=setInterval(()=>n(Date.now()),250);return()=>clearInterval(t)},[e]),t}function iE(e,t,n,a){return e.map(e=>({participant:e,displayTime:a(n(e,t))})).filter(e=>null!==e.displayTime&&Number.isFinite(e.displayTime))}const oE=e=>{let{visibleWidth:t,timeToX:n,mapSourceTimeToDisplay:r,isDarkMode:s}=e;const{sessionId:i,connectionState:o,collaborators:l,followingParticipantId:c,followParticipant:d,estimateTime:m}=nE(),h=sE(l.some(e=>e.playback.isPlaying)),p=(0,a.useMemo)(()=>iE(l,h,m,r),[l,m,r,h]);if(!i||"inactive"===o)return null;const g=0===l.length?"connected"===o?"Just you":"Connecting\u2026":"".concat(l.length," here");return(0,u.jsxs)("div",{"data-testid":"presence-timeline-lane",className:"relative h-12 overflow-hidden border-b ".concat(s?"border-white/[0.08] bg-[linear-gradient(180deg,rgba(25,36,52,0.98),rgba(20,30,44,0.96))]":"border-[#d6dce4] bg-[linear-gradient(180deg,rgba(249,251,253,0.98),rgba(238,243,248,0.96))]"),children:[(0,u.jsxs)("div",{className:"pointer-events-none absolute left-2 top-1/2 z-20 flex -translate-y-1/2 items-center gap-1.5 rounded-full border px-2 py-1 text-[9px] font-semibold uppercase tracking-[0.15em] backdrop-blur ".concat(s?"border-white/10 bg-[#111826]/80 text-slate-300":"border-[#d6dce4] bg-white/85 text-slate-600"),children:[(0,u.jsx)(XS,{size:10,
2className:"connected"===o?"text-emerald-400":"text-amber-400"}),(0,u.jsx)("span",{children:"Presence"}),(0,u.jsx)("span",{className:"normal-case tracking-normal opacity-70",children:g})]}),p.map(e=>{let{participant:a,displayTime:r}=e;const s=n(r),i=Math.max(18,Math.min(Math.max(18,t-18),s)),o=JS(a),l=a.id===c,m="".concat(l?"Stop following":"Follow"," ").concat(o," at ").concat(r.toFixed(1)," seconds");return(0,u.jsxs)("button",{type:"button","data-testid":"presence-orb-".concat(a.id),className:"group absolute top-1.5 z-30 -translate-x-1/2 rounded-full outline-none transition-transform hover:-translate-y-0.5 focus:-translate-y-0.5",style:{left:"".concat(i,"px")},onClick:()=>d(a.id),title:"".concat(l?"Stop following":"Synchronize with"," ").concat(o," at ").concat(r.toFixed(1),"s"),"aria-label":m,children:[(0,u.jsx)(rE,{glyph:a.animal.glyph,color:a.animal.color,label:o,picture:a.picture,isAnonymous:a.isAnonymous,initials:QS(a),size:34,isPlaying:a.playback.isPlaying,isFollowing:l,showPlaybackState:!0}),(0,u.jsxs)("span",{className:"pointer-events-none absolute left-1/2 top-full hidden -translate-x-1/2 whitespace-nowrap rounded-md bg-[#111826] px-2 py-1 text-[10px] font-medium normal-case tracking-normal text-white shadow-xl group-hover:block group-focus:block",children:[l?"Following ":"",o]})]},a.id)})]})},lE=e=>{let{displayDuration:t,mapSourceTimeToDisplay:n}=e;const{collaborators:r,estimateTime:s,followingParticipantId:i}=nE(),o=sE(r.some(e=>e.playback.isPlaying)),l=(0,a.useMemo)(()=>iE(r,o,s,n),[r,s,n,o]);return t<=0?null:(0,u.jsx)(u.Fragment,{children:l.map(e=>{let{participant:n,displayTime:a}=e;return(0,u.jsx)("div",{"data-testid":"presence-ghost-playhead-".concat(n.id),className:"pointer-events-none absolute inset-y-0 z-[56] w-px",style:{left:"".concat(Math.max(0,Math.min(100,a/t*100)),"%"),backgroundColor:n.animal.color,boxShadow:n.id===i?"0 0 0 1px ".concat(n.animal.color,", 0 0 14px ").concat(n.animal.color):"0 0 9px ".concat(n.animal.color),opacity:n.playback.isPlaying?.92:.58}},n.id)})})},cE=new Map;let dE=null,uE=null;const mE=/[<&]/,hE=(e,t)=>{if(cE.set(e,t),cE.size>2e3){const e=cE.keys().next().value;e&&cE.delete(e)}return t},pE=(e,t)=>{const n=e.trim();return t?n.split("\n").map(e=>e.replace(/\s+/g," ").trim()).filter(Boolean).join("\n"):n.replace(/\s+/g," ").trim()};function gE(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!e)return"";const n=String(e),a="".concat(t?"1":"0",":").concat(n),r=cE.get(a);if(void 0!==r)return r;if("undefined"===typeof document||!mE.test(n))return hE(a,pE(n,t));let s=n;const i=(dE||(dE=document.createElement("textarea")),dE);for(let o=0;o<2;o+=1){i.innerHTML=s;const e=i.value;if(e===s)break;s=e}if(s.includes("<")){const e=(uE||(uE=document.createElement("div")),uE);e.innerHTML=s,s=e.textContent||e.innerText||"",e.textContent=""}return i.value="",hE(a,pE(s,t))}const xE={NODE_ENV:"production",PUBLIC_URL:"https://files.rescript.info",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_GOOGLE_CLIENT_ID:"650914284514-arrnrmrkrk8r37chamjmk7ta7tfj5nuk.apps.googleusercontent.com"}.REACT_APP_API_URL||"",fE=(e,t,n)=>Math.min(Math.max(e,t),n),bE=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return t>0?"".concat(t,":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")):"".concat(n,":").concat(a.toString().padStart(2,"0"))};const yE=(e,t,n)=>Number.isFinite(e)?1===t?16*e:2===t?e*n:e:0,vE=(e,t)=>{if(!e.length)return null;let n=0,a=e.length-1;for(;n<=a;){const r=n+a>>1,s=e[r];if(t<s.start)a=r-1;else{if(!(t>s.end))return s;n=r+1}}for(let r=Math.max(0,a-1);r<=Math.min(e.length-1,n+1);r+=1){const n=e[r];if(t>=n.start&&t<=n.end)return n}return null},wE=(e,t)=>{if(!e.length)return-1;let n=0,a=e.length-1;for(;n<=a;){const r=n+a>>1,s=e[r].timestamp;if(s<t)n=r+1;else{if(!(s>t))return r;a=r-1}}const r=Math.max(0,a),s=Math.min(e.length-1,n);return r===s||Math.abs(e[r].timestamp-t)<=Math.abs(e[s].timestamp-t)?r:s},kE=e=>{if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;return!!e.closest('input, textarea, select, [contenteditable="true"], [role="textbox"]')},jE=e=>{if(e.raw)return e.raw;const t=[];var n,a;null!=e.segmentNumber&&e.title?t.push("[".concat(e.segmentNumber,": ").concat(null!==(n=e.qualityRank)&&void 0!==n?n:"?","/").concat(null!==(a=e.totalTopics)&&void 0!==a?a:"?","] >> [").concat(gE(e.title),"]")):e.title&&t.push(gE(e.title));if(null!=e.score&&t.push("Score: ".concat(e.score,"/10")),e.scoreBreakdown){const n=["S","R","C","P","CR"].map(t=>{var n;const a=null===(n=e.scoreBreakdown)||void 0===n?void 0:n[t];return a?"".concat(t,": ").concat(a.score,"/").concat(a.max):null}
2).filter(Boolean).join(" | ");n&&t.push(n)}return e.justification&&t.push("Justification: ".concat(gE(e.justification,!0))),t.join("\n")},DE=e=>e.raw?e.raw:"[CLIP] ".concat(gE(e.title)," | ").concat(gE(e.clipType)," | ").concat(gE(e.description,!0)," | ").concat(gE(e.visual,!0)).trim(),CE=e=>e.raw?e.raw:"[EDIT] ".concat(gE(e.title)," | ").concat(gE(e.suggestion,!0)," | ").concat(gE(e.improvement,!0)," | ").concat(gE(e.priority)).trim(),NE=e=>{if(e.raw)return e.raw;const t=[gE(e.category),gE(e.context,!0),gE(e.visual,!0)].filter(Boolean);return["[REF] ".concat(gE(e.name)," | ").concat(gE(e.linkText)," | ").concat(e.url||"").trim(),...t].join("\n")},FE=e=>{var t,n;return{id:"topic_".concat(e.index,"_").concat(e.startTime),index:e.index,start:e.startTime,end:e.endTime,type:"topic",content:jE(e),title:gE(e.title)||void 0,rank:null!==(t=e.score)&&void 0!==t?t:void 0,maxRank:10,segmentNumber:null!==(n=e.segmentNumber)&&void 0!==n?n:void 0}},SE=e=>({id:"clip_".concat(e.index,"_").concat(e.startTime),index:e.index,start:e.startTime,end:e.endTime,type:"clip",content:DE(e),title:gE(e.title)||void 0}),EE=e=>({id:"edit_".concat(e.index,"_").concat(e.startTime),index:e.index,start:e.startTime,end:e.endTime,type:"edit",content:CE(e),title:gE(e.title)||void 0}),AE=e=>({id:"reference_".concat(e.index,"_").concat(e.startTime),index:e.index,start:e.startTime,end:e.endTime,type:"reference",content:NE(e),title:gE(e.name)||void 0,url:e.url||void 0,linkText:gE(e.linkText)||void 0,category:gE(e.category)||void 0,context:gE(e.context,!0)||void 0,visualSuggestion:gE(e.visual,!0)||void 0}),TE=(0,a.memo)(e=>{let{totalDuration:t,displayDuration:n}=e;const{currentTime:a}=Jw(),r=null!==n&&void 0!==n?n:t;return(0,u.jsxs)("div",{className:"absolute top-0 z-30",style:{left:r>0?"".concat(a/r*100,"%"):"0%",transform:"translateX(-50%)"},children:[(0,u.jsx)("div",{className:"absolute top-0 w-1 h-full bg-red-500 pointer-events-none"}),(0,u.jsx)("div",{className:"absolute -top-2 left-1/2 transform -translate-x-1/2 pointer-events-none",children:(0,u.jsx)("div",{className:"w-0 h-0 border-l-[8px] border-l-transparent border-r-[8px] border-r-transparent border-b-[8px] border-b-red-500"})}),(0,u.jsx)("div",{className:"absolute -bottom-2 left-1/2 transform -translate-x-1/2 pointer-events-none",children:(0,u.jsx)("div",{className:"w-0 h-0 border-l-[8px] border-l-transparent border-r-[8px] border-r-transparent border-t-[8px] border-t-red-500"})})]})}),ME=e=>{const{currentTime:t}=Jw();return(0,u.jsx)(mF,d(d({},e),{},{currentTime:t}))},_E=(0,a.memo)(e=>{var t;let{totalDuration:n,isDarkMode:a,displayDuration:r,timeMapper:s,showKeyboardHints:i=!0}=e;const{currentTime:o}=Jw(),l=s&&null!==(t=s(o))&&void 0!==t?t:o,c=null!==r&&void 0!==r?r:n;return(0,u.jsxs)("div",{className:"shrink-0",children:[(0,u.jsxs)("div",{className:"whitespace-nowrap tabular-nums text-xs ".concat(a?"text-gray-400":"text-gray-500"),children:[bE(l)," / ",bE(c)]}),i&&(0,u.jsx)("div",{className:"text-[10px] ".concat(a?"text-gray-500":"text-gray-400"),children:"Space/\u2190/\u2192 for controls"})]})}),BE=(0,a.memo)(e=>{let{totalDuration:t,displayDuration:n}=e;const{currentTime:a}=Jw(),r=null!==n&&void 0!==n?n:t;return 0===r?null:(0,u.jsx)("div",{className:"absolute bottom-0 h-1 bg-orange-500 z-30",style:{width:"".concat(a/r*100,"%")}})}),IE=e=>{var t,n,r,s,i,o,l;let{sessionId:c,sessionTitle:m=null,sessionVisuals:h=null,speakerSegments:p,speakerLabels:g,transcriptionData:x,ttmlFiles:f,duration:b,selectedTtmlId:y,selectedTtmlChecksum:v=null,shareToken:w,isPublicView:k,retentionData:j,youtubeUrl:D,initialComments:C,fromCdn:N=!1,onTtmlRevisionCreated:F,onSessionVisualsChanged:S,searchMatches:E=[],gapClusters:A,nonClusteredGaps:T}=e;zw("AUDIO-PLAYER","Component rendering with props:",{sessionId:null===c||void 0===c?void 0:c.substring(0,8),ttmlFilesCount:(null===f||void 0===f?void 0:f.length)||0,selectedTtmlId:null===y||void 0===y?void 0:y.substring(0,8),selectedTtmlChecksum:null===v||void 0===v?void 0:v.substring(0,8),hasShareToken:!!w,isPublicView:k});const{isDarkMode:M}=zu(),{token:_}=am(),{permissions:B,shareToken:I}=Hp(),P=(0,a.useMemo)(()=>[],[]),L=!1,R=!1,z=null,O=(0,a.useCallback)((e,t)=>!1,[L,z]),U=w||I,V=void 0!==k?k:!!B,H=(0,a.useCallback)(async e=>{if(V){if(!U)return null;const t=await fetch("".concat(xE,"/api/public/share/").concat(U,"/ttml-content/").concat(e));if(!t.ok){const e=await t.json().catch(()=>null);throw new Error((null===e||void 0===e?void 0:e.error)||"Failed to fetch TTML: ".concat(t.status))}return t.text()}if(!_)return null;return(await Op.downloadCachedTTML(e,_)).text()},[V,U,_]),{play:q,playSegment:W,pause:Y,seekTo:G,duration:K,isPlaying:X,volume:J,setVolume:$,currentTime:Q,playbackRate:Z,setPlaybackRate:ee,playerMode:te}=Jw(),{isCompactTouchLayout:ne}=Ww(),[ae,re]=(0,a.useState)(!1),[se,ie]=(0,a.useState)(null),[oe,le]=(0,a.useState)(!1),[ce,de]=((0,a.useRef)(new Map),(0,a.useState)(!1)),[ue,me]=(0,a.useState)(null),[he,pe]=(0,a.useState)(null),[ge,xe]=(0,a.useState)(null),[fe,be]=(0,a.useState)(null),[ye,ve]=(0,a.useState)(null),[we,ke]=(0,a.useState)(null),[je,De]=(0,a.useState)(null),[Ce,Ne]=(0,a.useState)(!1),[Fe,Se]=(0,a.useState)(!1),[Ee,Ae]=(0,a.useState)(!1),[Te,Me]=(0,a.useState)(null),[_e,Be]=(0,a.useState)(null),[Ie,Pe]=(0,a.useState)(!1),Le=(0,a.useRef)(null),[Re,ze]=(0,a.useState)(null),[Oe,Ue]=(0,a.useState)(null),[Ve,He]=(0,a.useState)(null),[qe,We]=(0,a.useState)(null),Ye=(0,a.useRef)(!1),Ge=(0,a.useRef)(null),Ke=(0,a.useRef)(null),Xe=(0,a.useRef)(null),Je=(0,a.useRef)(null),[$e,Qe]=(0,a.useState)(null),Ze=(0,a.useRef)(null),[et,tt]=(0,a.useState)(0),[nt,at]=(0,a.useState)({clips:[],topics:[],edits:[],references:[]}),[rt,st]=(0,a.useState)([]),[it,ot]=(0,a.useState)(null),[lt,ct]=(0,a.useState)(!1),[dt,ut]=(0,a.useState)(!1),[mt,ht]=(0,a.useState)(()=>!ne),[pt,gt]=(0,a.useState)(0),xt=(0,a.useRef)(null),ft=(0,a.useRef)(null),[bt,yt]=(0,a.useState)(null),[vt,wt]=(0,a.useState)(null),kt=!V||null===(t=null===B||void 0===B?void 0:B.commentsRead)||void 0===t||t,[jt,Dt]=(0,a.useState)(()=>"undefined"===typeof window?kt:kt&&!ne),[Ct,Nt]=(0,a.useState)([]),Ft=(0,a.useMemo)(()=>function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;const a=eS(t);return new Map(e.map(e=>[e.id,nS(e.start,e.end,a,n)]))}(nt.clips.map(e=>{let{id:t,start:n,end:a}=e;return{id:t,start:n,end:a}}),Ct,2),[Ct,nt.clips]),[St,Et]=(0,a.useState)(!1),[At,Tt]=(0,a.useState)(null),[Mt,_t]=(0,a.useState)(null),[Bt,It]=(0,a.useState)(!1),[Pt,Lt]=(0,a.useState)(60),{mode:Rt,showGradient:zt,setMode:Ot,setShowGradient:Ut,retentionMode:Vt,setRetentionMode:Ht,setRetentionData:qt,overlayMode:Wt,setOverlayMode:Yt}=tF();(0,a.useEffect)(()=>{qt(j||null)},[j,qt]),(0,a.useEffect)(()=>
2{if(!c)return void st([]);let e=!1;return(V&&U?fm(U):xm(c,_||void 0)).then(t=>{if(!e){const e=t.questions.filter(e=>null!==e.timestampSeconds&&Number.isFinite(e.timestampSeconds)).sort((e,t)=>e.timestampSeconds-t.timestampSeconds);st(e)}}).catch(t=>{e||(console.warn("[CentralAudioPlayer] Failed to load questions:",t.message),st([]))}),()=>{e=!0}},[c,_,V,U]),(0,a.useEffect)(()=>{"questions"===Wt&&0===rt.length&&Yt("topics")},[Wt,rt.length,Yt]);const Gt=()=>{switch(Vt){case"relative":return{label:"Rel",color:"bg-[#314159]",title:"Relative retention (vs similar videos)"};case"absolute":return{label:"Abs",color:"bg-[#232E3F]",title:"Absolute retention (% still watching)"};case"adjusted":return{label:"Adj",color:"bg-[#8a6115]",title:"Adjusted (relative \xd7 \u221aabsolute)"};case"drops":return{label:"Drops",color:"bg-[#7b3f32]",title:"Viewer drops (started/stopped watching)"};default:return{label:"Off",color:"bg-gray-600",title:"Retention hidden"}}},Kt=Boolean((null===j||void 0===j||null===(n=j.retentionData)||void 0===n?void 0:n.length)&&"off"!==Vt),Xt=ne&&!Kt,Jt=Xt?"h-12":"h-24",$t=(0,a.useMemo)(()=>Xt?{topicTop:"0px",topicHeight:"10px",speakerTop:"10px",speakerHeight:"10px",editTop:"22px",editHeight:"5px",clipTop:"29px",clipHeight:"5px",gapBarBottom:"8px",gapBarHeight:"3px",gapTickBottom:"11px",nonClusteredGapBottom:"8px"}:{topicTop:"0%",topicHeight:"33.333333%",speakerTop:"0%",speakerHeight:"100%",editTop:"25%",editHeight:"25%",clipTop:"25%",clipHeight:"25%",gapBarBottom:"10px",gapBarHeight:"6px",gapTickBottom:"16px",nonClusteredGapBottom:"10px"},[Xt]),{hoveredTimeRange:Qt,setDragHighlightTime:Zt,setTimelineHoverTime:en,setTimelineViewportRange:tn,transcriptSelectionRange:nn,cursorSyncEnabled:an,setCursorSyncEnabled:rn,syncRequestId:sn,syncRequestTargetTime:on,requestCursorSync:ln}=wk(),cn=(0,a.useRef)(null),dn=(0,a.useRef)(null),un=(0,a.useRef)(null),[mn,hn]=(0,a.useState)(0),[pn,gn]=(0,a.useState)(!1),xn=(0,a.useRef)(null),fn=(0,a.useRef)(null),bn=(0,a.useRef)(!1),yn=(0,a.useRef)(0),vn=(0,a.useRef)(null),wn=(0,a.useRef)(null),kn=(0,a.useRef)(null),jn=(0,a.useRef)(null),Dn=(0,a.useRef)(null),Cn=(0,a.useRef)(0);(0,a.useEffect)(()=>{const e=()=>{if(cn.current){const e=cn.current.clientWidth||cn.current.getBoundingClientRect().width;hn(t=>Math.abs(t-e)>.5?e:t)}};e();const t=setTimeout(e,100);return window.addEventListener("resize",e),()=>{clearTimeout(t),window.removeEventListener("resize",e)}},[]),(0,a.useEffect)(()=>{kt?ne&&Dt(!1):Dt(!1)},[kt,ne]);const Nn=(0,a.useRef)(Q),Fn=(0,a.useRef)(X);(0,a.useEffect)(()=>{Nn.current=Q},[Q]),(0,a.useEffect)(()=>{Fn.current=X},[X]);const{segments:Sn,totalDuration:En}=(0,a.useMemo)(()=>{if(!p||(p instanceof Map?0===p.size:0===Object.keys(p).length))return{segments:[],totalDuration:b||0};const e=[],t=p instanceof Map?Array.from(p.entries()):Object.entries(p);for(const[a,r]of t){const t=Array.isArray(r)?r:r?[r]:[];for(const n of t)n&&"number"===typeof n.start&&"number"===typeof n.end&&e.push({start:n.start,end:n.end,speaker:"number"===typeof a?a:parseInt(String(a),10)||0})}e.sort((e,t)=>e.start-t.start);const n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(e.length<=1)return e;const n=[];for(const a of e){const e=n[n.length-1];e&&e.speaker===a.speaker&&a.start-e.end<=t?e.end=Math.max(e.end,a.end):n.push(d({},a))}return n}(e);return{segments:n,totalDuration:b||K||(e.length>0?Math.max(...e.map(e=>e.end)):0)}},[p,b,K]),An=(0,a.useMemo)(()=>{var e,t,n,a;if(null===x||void 0===x||!x.results)return[];if(Array.isArray(x.results.utterances)&&x.results.utterances.length>0)return x.results.utterances.flatMap(e=>(e.words||[]).filter(e=>{var t;return"number"===typeof e.start&&"number"===typeof e.end&&!(null===(t=e.word)||void 0===t||!t.trim())}).map(e=>({text:String(e.punctuated_word||e.word||"").trim(),start:Number(e.start),end:Number(e.end)})));return((null===(e=x.results.channels)||void 0===e||null===(t=e[0])||void 0===t||null===(n=t.alternatives)||void 0===n||null===(a=n[0])||void 0===a?void 0:a.words)||[]).filter(e=>{var t;return"number"===typeof e.start&&"number"===typeof e.end&&!(null===(t=e.word)||void 0===t||!t.trim())}).map(e=>({text:String(e.punctuated_word||e.word||"").trim(),start:Number(e.start),end:Number(e.end)}))},[x]),Tn=(0,a.useMemo)(()=>En,[R,L,z,En]),Mn=En,{viewportStart:_n,viewportEnd:Bn,viewportDuration:In,contentWidth:Pn,contentOffsetX:Ln,isZoomed:Rn,timeToX:zn,xToTime:On,resetZoom:Un,panByPixels:Vn,zoomAroundTime:Hn,centerOnTime:qn,markUserInteracted:Wn}=cF({totalDuration:Mn,visibleWidth:mn,currentTime:Q,isMobile:ne,autoFollowEnabled:an}),Yn=!(!_||V||!vt),Gn=(0,a.useCallback)(function(){Yn&&(Me(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null),Ae(!0))},[Yn]),Kn=(0,a.useMemo)(()=>Tm(nt.references.map((e,t)=>({id:Em({title:e.title,start:e.start,end:e.end},t),title:e.title,start:e.start,end:e.end})),h),[h,nt.references]),Xn=(0,a.useMemo)(()=>nt.references.map((e,t)=>{const n=Kn.get(Em({title:e.title,start:e.start,end:e.end},t));return n?d(d({},e),{},{attachedVisualCount:n.assetCount,attachedVisualPreviewUrl:n.previewImageUrl,attachedVisualLabel:n.attachmentLabel,attachedVisualPlacements:n.placements}):e}),[Kn,nt.references]),Jn=(0,a.useMemo)(()=>je?Xn.find(e=>e.id===je.id)||je:null,[je,Xn]),$n=(0,a.useMemo)(()=>"questions"!==Wt||0===rt.length?[]:rt.map((e,t)=>({start:Number(e.timestampSeconds)||0,end:t<rt.length-1&&Number(rt[t+1].timestampSeconds)||1/0,questionNumber:t+1,question:e})),[Wt,rt]),Qn=In||Mn,Zn=Rn&&Qn<=24,ea=Qn>120,ta=!ea&&Qn>24,na=(0,a.useMemo)(()=>ea?ne?8.5:6.2:ta?ne?6.1:4.2:Zn?ne?4.2:2.6:ne?2.5:1.2,[ne,Zn,ta,ea]),aa=(0,a.useMemo)(()=>
2{if(Mn<=0)return.016;const e=mn||Pn||0;if(e<=0)return Math.max(Mn/1200,.016);const t=Math.max(Mn/e*.85,.016);return ea?Math.max(2.4*t,.2):ta?Math.max(1.55*t,.11):Zn?Math.max(t,.06):t},[mn,Zn,ta,ea,Pn,Mn]),ra=(0,a.useCallback)(()=>{null!==vn.current&&(window.cancelAnimationFrame(vn.current),vn.current=null),wn.current=null,kn.current=null,jn.current=null,Dn.current=null,Cn.current=0,cn.current&&cn.current.style.removeProperty("--timeline-hover-x"),de(!1),me(null),pe(null),xe(null),be(null),ve(null),ke(null),en(null)},[en]),sa=(0,a.useCallback)(e=>{if(null===e)return void ra();jn.current=e;const t=vE(nt.topics,e),n=vE(nt.clips,e),a=vE(nt.edits,e),r=vE(Xn,e),s=vE($n,e),i="undefined"!==typeof performance?performance.now():Date.now(),o=Dn.current,l=ea?.32:ta?.18:Zn?.11:.05,c=ea?110:ta?72:Zn?60:32,d=null===o||Math.abs(o-e)>=l||i-Cn.current>=c;me(t=>null!==t&&Math.abs(t-e)<5e-4?t:e),pe(e=>(null===e||void 0===e?void 0:e.id)===(null===t||void 0===t?void 0:t.id)?e:t),xe(e=>(null===e||void 0===e?void 0:e.id)===(null===n||void 0===n?void 0:n.id)?e:n),be(e=>(null===e||void 0===e?void 0:e.id)===(null===a||void 0===a?void 0:a.id)?e:a),ve(e=>(null===e||void 0===e?void 0:e.id)===(null===r||void 0===r?void 0:r.id)?e:r),ke(e=>{var t,n;return(null===e||void 0===e?void 0:e.questionNumber)===(null===s||void 0===s?void 0:s.questionNumber)&&(null===e||void 0===e||null===(t=e.question)||void 0===t?void 0:t.id)===(null===s||void 0===s||null===(n=s.question)||void 0===n?void 0:n.id)?e:s}),d&&(Dn.current=e,Cn.current=i)},[ra,$n,Zn,ta,ea,Xn,nt]),ia=(0,a.useCallback)((e,t)=>{var n;if(null===e)return void ra();if("number"===typeof t&&null!==kn.current&&Math.abs(t-kn.current)<na)return;const a=null!==(n=wn.current)&&void 0!==n?n:jn.current;null!==a&&Math.abs(e-a)<aa?"number"===typeof t&&(kn.current=t):(wn.current=e,"number"===typeof t&&(kn.current=t),null===vn.current&&(vn.current=window.requestAnimationFrame(()=>{vn.current=null;const e=wn.current;wn.current=null,null!==e&&sa(e)})))},[ra,na,aa,sa]),oa=(0,a.useCallback)(e=>{if(!cn.current)return null;const t=cn.current.getBoundingClientRect(),n=cn.current.clientWidth||t.width,a=t.width>0?n/t.width:1,r=fE(e-t.left,0,t.width);return{rect:t,layoutWidth:n,pixelsPerClientPixel:a,localX:fE(r*a,0,n)}},[]),la=(0,a.useMemo)(()=>fE(zn(Q),0,mn),[Q,mn,zn]),ca=(0,a.useMemo)(()=>null===ue?null:ue,[ue,R,z]),da=(0,a.useMemo)(()=>null===ca?null:fE(zn(ca),0,mn),[ca,mn,zn]),ua=(0,a.useMemo)(()=>{if(null===ue)return null;let e=vE(Sn,ue)||null;if(!e){let t=null,n=null;for(const e of Sn)if(e.end<=ue)t=e;else if(e.start>ue){n=e;break}t&&n&&ue>=t.end&&ue<n.start&&n.start-t.end<=2&&(e=t)}if(!e)return null;const t=Number(e.speaker);return{id:t,label:(null===g||void 0===g?void 0:g[t])||"Speaker ".concat(t),color:mp(t,M)}},[ue,M,g,Sn]),ma=(0,a.useCallback)(e=>e,[R,z,L]),ha=(0,a.useCallback)(e=>e,[L,R,z]),pa=(0,a.useMemo)(()=>{var e,t;if(!nn)return null;const n=null!==(e=ma(nn.start))&&void 0!==e?e:nn.start,a=null!==(t=ma(nn.end))&&void 0!==t?t:nn.end,r=Math.max(0,Math.min(n,a));return{start:r,end:Math.max(r,Math.max(n,a)),duration:nn.end-nn.start}},[ma,nn]),ga=Boolean(V?U:c),xa=Boolean(ga&&Rn&&!Re&&!Oe&&(In||Mn)<=120),fa=!1,ba=xa,ya=In||Mn,va=fE(1-ya/120,0,1),wa=Number((8.3+4.9*va).toFixed(2)),ka=Number((wa+3.2).toFixed(2));(0,a.useEffect)(()=>{if(null!==un.current&&(window.clearTimeout(un.current),un.current=null),!_||V||!xa||Re||Oe)return void tn(null);const e=null!==Bn&&void 0!==Bn?Bn:Mn,t=ha(null!==_n&&void 0!==_n?_n:0),n=ha(e),a=Math.max(0,Math.min(t,n)),r=Math.max(a,Math.max(t,n));return un.current=window.setTimeout(()=>{tn({start:a,end:r}),un.current=null},140),()=>{null!==un.current&&(window.clearTimeout(un.current),un.current=null)}},[V,ha,tn,xa,Re,Oe,Mn,_,Bn,_n]);const ja=(0,a.useMemo)(()=>{if(!xa||!An.length)return[];const e=null!==_n&&void 0!==_n?_n:0,t=null!==Bn&&void 0!==Bn?Bn:Mn;return An.filter(n=>{var a,r;const s=null!==(a=ma(n.start))&&void 0!==a?a:n.start;return(null!==(r=ma(n.end))&&void 0!==r?r:n.end)>=e-.5&&s<=t+.5})},[xa,An,_n,Bn,Mn,ma]),Da=(0,a.useMemo)(()=>{if(!xa||!ja.length||Mn<=0)return[];const e=Pn||mn||0;return ja.map((t,n)=>{var a,r;const s=null!==(a=ma(t.start))&&void 0!==a?a:t.start,i=null!==(r=ma(t.end))&&void 0!==r?r:t.end,o=Math.max(i-s,.06),l=s/Mn*100,c=Math.max(o/Mn*100,.22),d=t.text.replace(/\s+/g," ").trim()||"\u2026",u=e>0?c/100*e:0,m=d.length*wa*.46+8,h=u>=1.08*m;return{key:"".concat(t.start,"-").concat(t.end,"-").concat(n),displayStart:s,displayEnd:i,midpoint:(s+i)/2,left:l,width:c,widthPx:u,durationSeconds:o,label:d,estimatedLabelPx:m,stronglyFitsLabel:h,isEven:n%2===0}})},[wa,mn,Pn,ma,xa,Mn,ja]);(0,a.useEffect)(()=>(ie(null),void le(!1)),[V,U,c,mn,fa,Pn,ha,_n,Bn,Mn]);const Ca=(0,a.useMemo)(()=>
2{if(!xa||0===Da.length||Mn<=0)return null;const e=Math.max(7.8,wa-2.2),t=Math.max(8.2,wa-1.8),n=Math.max(10.4,ka-2.2),a=Math.max(10.8,ka-1.8),r=ya<=12||ya<=24||ya<=36?1:2,s=new Set;return ya<=12?Da.forEach(e=>{s.add(e.key)}):Da.forEach((e,t)=>{e.widthPx<.35||t%r===0&&s.add(e.key)}),(0,u.jsxs)("div",{className:"absolute inset-0 pointer-events-none z-[28]",children:[(0,u.jsx)("div",{className:"absolute inset-0",children:Da.map(e=>{var t,n;const a="questions"===Wt?null:vE(nt.topics,e.midpoint),r=a?Math.min(Math.max((null!==(t=a.rank)&&void 0!==t?t:5)/Math.max(null!==(n=a.maxRank)&&void 0!==n?n:10,1),0),1):null,s=null===r?null:zt?r>=.8?"rgb(34, 197, 94)":r>=.6?"rgb(132, 204, 22)":r>=.4?"rgb(250, 204, 21)":r>=.2?"rgb(251, 146, 60)":"rgb(239, 68, 68)":r>=.67?"rgb(34, 197, 94)":r>=.33?"rgb(234, 179, 8)":"rgb(239, 68, 68)",i=s?(()=>{const e=s.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!e)return s;const[,t,n,a]=e;return"linear-gradient(to right, rgba(".concat(t,", ").concat(n,", ").concat(a,", 0.8), rgba(").concat(t,", ").concat(n,", ").concat(a,", 1), rgba(").concat(t,", ").concat(n,", ").concat(a,", 0.8))")})():null,o=s?"".concat(s.replace("rgb(","rgba(").replace(")",M?", 0.36)":", 0.28)")):M?"rgba(255,211,109,0.30
2)":"rgba(161,109,11,0.18)",l=i?M?"linear-gradient(180deg, rgba(6,9,14,0.22), rgba(10,15,24,0.42)), ".concat(i):"linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,249,238,0.34)), ".concat(i):M?e.isEven?"linear-gradient(180deg, rgba(5,8,13,0.985), rgba(16,23,35,0.96))":"linear-gradient(180deg, rgba(10,15,24,0.985), rgba(22,30,43,0.95))":e.isEven?"linear-gradient(180deg, rgba(255,254,250,0.99), rgba(246,237,208,0.965))":"linear-gradient(180deg, rgba(251,244,223,0.99), rgba(239,229,193,0.955))";return(0,u.jsx)("div",{className:"absolute border-r border-b overflow-hidden",style:{left:"".concat(e.left,"%"),width:"".concat(e.width,"%"),top:$t.topicTop,height:$t.topicHeight,zIndex:18,borderColor:o,background:l,boxShadow:M?i?"inset 0 -1px 0 rgba(255,255,255,0.14), inset 1px 0 0 rgba(255,255,255,0.03), 0 0 12px rgba(0,0,0,0.12)":"inset 0 -1px 0 rgba(255,211,109,0.16), inset 1px 0 0 rgba(255,255,255,0.02)":i?"inset 0 -1px 0 rgba(255,255,255,0.52), inset 1px 0 0 rgba(255,255,255,0.24), 0 0 10px rgba(255,181,43,0.08)":"inset 0 -1px 0 rgba(255,255,255,0.46), inset 1px 0 0 rgba(255,255,255,0.22)"}},"".concat(e.key,"-cell"))})}),(0,u.jsx)("div",{className:"absolute inset-0 z-[19]",children:Da.map(r=>{if(!s.has(r.key))return null;const i=Xt?e:t,o=Xt?n:a,l=Math.max(ya<=18?9.2:ya<=36?8.8:8.2,Math.min(i,ya<=18?10.6:9.8));return(0,u.jsx)("div",{className:"absolute pointer-events-none overflow-visible",style:{left:"".concat(r.left,"%"),width:"".concat(r.width,"%"),top:$t.topicTop,height:$t.topicHeight},children:(0,u.jsx)("div",{className:"absolute left-[2px] top-1/2 whitespace-nowrap ".concat(M?"text-[#ffe6a7]":"text-[#7a4b00]"),style:{transform:"translateY(-50%)",paddingLeft:Xt?"0.08rem":"0.12rem",paddingRight:Xt?"0.06rem":"0.1rem",fontSize:"".concat(l,"px"),lineHeight:"".concat(Math.max(o,l+1.8),"px"),letterSpacing:"".concat(ya<=16?.002:0,"em"),background:M?"linear-gradient(180deg, rgba(10,15,24,0.28), rgba(10,15,24,0.18))":"linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,247,228,0.22))",borderRadius:"999px",textShadow:M?"0 0 10px rgba(255,181,43,0.34), 0 1px 2px rgba(0,0,0,0.84)":"0 1px 0 rgba(255,255,255,0.92), 0 0 6px rgba(255,181,43,0.18)",WebkitTextStroke:M?"0.14px rgba(255,239,194,0.24)":"0.14px rgba(110,66,0,0.12)",fontFamily:"Inter, ui-sans-serif, system-ui, sans-serif",fontWeight:700},children:r.label})},"".concat(r.key,"-label"))})})]})},[ya,wa,ka,Xt,M,mn,xa,Wt,zt,Pn,Mn,$t.topicHeight,$t.topicTop,nt.topics,Da]),Na=((0,a.useMemo)(()=>null,[M,fa,se]),(0,a.useCallback)(e=>{Ge.current=e,He(e)},[])),Fa=(0,a.useCallback)(()=>{null!==Je.current&&(window.cancelAnimationFrame(Je.current),Je.current=null),Na(Ke.current),We(Xe.current),Ke.current=null,Xe.current=null},[Na]),Sa=(0,a.useCallback)((e,t)=>{Ke.current=e,Xe.current=t,null===Je.current&&(Je.current=window.requestAnimationFrame(()=>{Je.current=null,Na(Ke.current),We(Xe.current),Ke.current=null,Xe.current=null}))},[Na]),Ea=(0,a.useMemo)(()=>nt.topics,[nt.topics,R,z,L]),Aa=(0,a.useMemo)(()=>{if(0===rt.length||0===En)return[];const e=[];for(let t=0;t<rt.length;t++){const n=rt[t],a=n.timestampSeconds,r=t<rt.length-1?rt[t+1].timestampSeconds:En;e.push({id:"qspan_".concat(t),start:a,end:Math.max(r,a+1),questionNumber:t+1,question:n})}return e},[rt,En]),Ta=(0,a.useMemo)(()=>Aa,[Aa,R,z,L]),Ma=(0,a.useMemo)(()=>Sn,[Sn,R,z,L]),_a=(0,a.useCallback)(()=>{if(!Sn.length||!En)return{};const e={};let t=0;Sn.forEach(n=>{const a=n.end-n.start;e[n.speaker]=(e[n.speaker]||0)+a,t+=a});const n={};return Object.entries(e).forEach(e=>{let[a,r]=e;n[parseInt(a)]=Math.round(r/t*100)}),n},[Sn,En]),Ba=_a();(0,a.useEffect)(()=>{const e=e=>e.defaultPrevented||kE(e.target)||kE(document.activeElement),t=t=>{if(!e(t))switch(t.code){case"Space":if(t.repeat)return;t.preventDefault(),t.stopPropagation(),Fn.current?Y():q();break;case"ArrowLeft":{const e=Math.max(0,Nn.current-15);t.preventDefault(),t.stopPropagation(),G(e),ln(e)}break;case"ArrowRight":{const e=Math.min(En,Nn.current+15);t.preventDefault(),t.stopPropagation(),G(e),ln(e)}}},n=t=>{e(t)||"Space"!==t.code&&"ArrowLeft"!==t.code&&"ArrowRight"!==t.code||(t.preventDefault(),t.stopPropagation())},a={capture:!0};return document.addEventListener("keydown",t,a),document.addEventListener("keyup",n,a),()=>{document.removeEventListener("keydown",t,a),document.removeEventListener("keyup",n,a)}},[Y,q,ln,G,En]),(0,a.useEffect)(()=>{const e=e=>{xt.current&&!xt.current.contains(e.target)&&ct(!1)};return lt&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[lt]);const Ia=(0,a.useCallback)(e=>{const t=oa(e.clientX);if(!t||0===Mn)return;e.preventDefault();const n=yE(e.deltaX,e.deltaMode,t.rect.width)*t.pixelsPerClientPixel,a=yE(e.deltaY,e.deltaMode,t.rect.height)*t.pixelsPerClientPixel,r=!e.ctrlKey&&(e.metaKey||e.shiftKey||Math.abs(n)>
2Math.abs(a));if(rn(!1),Wn(),r){const e=Math.abs(n)>Math.abs(a)?n:a;return void Vn(e)}const s=On(t.localX),i=fE(a,-200,200),o=Math.exp(.003*i);Hn(s,o)},[oa,Wn,Vn,rn,Mn,On,Hn]);(0,a.useEffect)(()=>{sn&&yn.current!==sn&&(yn.current=sn,Rn&&null===on&&qn(Q))},[qn,Q,Rn,sn,on]);const Pa=(0,a.useCallback)(()=>{var e;const t=document.activeElement;t instanceof HTMLElement&&kE(t)&&t.blur(),null===(e=cn.current)||void 0===e||e.focus({preventScroll:!0})},[]),La=(0,a.useCallback)(e=>e instanceof HTMLElement&&!!e.closest('button, a, input, textarea, select, [role="button"], [data-timeline-pan-ignore="true"]'),[]),Ra=(0,a.useCallback)(e=>{Pa(),Rn&&0===e.button&&!La(e.target)&&(xn.current={pointerId:e.pointerId,lastClientX:e.clientX,pixelsPerClientPixel:(()=>{const t=e.currentTarget.getBoundingClientRect(),n=e.currentTarget.clientWidth||t.width;return t.width>0?n/t.width:1})(),moved:!1},e.currentTarget.setPointerCapture(e.pointerId))},[Pa,Rn,La]),za=(0,a.useCallback)(e=>{const t=xn.current;if(!t||t.pointerId!==e.pointerId)return;const n=(e.clientX-t.lastClientX)*t.pixelsPerClientPixel;Math.abs(n)<.5||(t.lastClientX=e.clientX,t.moved=t.moved||Math.abs(n)>3,Wn(),rn(!1),Vn(-n))},[Wn,Vn,rn]),Oa=(0,a.useCallback)((e,t)=>{const n=xn.current;n&&n.pointerId===e&&(bn.current=n.moved,xn.current=null,t.hasPointerCapture(e)&&t.releasePointerCapture(e))},[]),Ua=(0,a.useCallback)(e=>{const t=e[0];if(!t)return null;const n=oa(t.clientX);if(!n)return null;const a=e[1];if(!a)return{localX:n.localX};const r=fE((a.clientX-n.rect.left)*n.pixelsPerClientPixel,0,n.layoutWidth);return{localX:n.localX,centerX:fE((n.localX+r)/2,0,n.layoutWidth),distance:Math.abs(r-n.localX)}},[oa]),Va=(0,a.useCallback)(e=>{if(!La(e.target)){if(2===e.touches.length){const t=Ua(e.touches);if(!t||void 0===t.centerX||void 0===t.distance)return;return void(fn.current={mode:"pinch",lastCenterX:t.centerX,lastDistance:Math.max(t.distance,1),moved:!1})}if(1===e.touches.length&&Rn){const t=Ua(e.touches);if(!t)return;fn.current={mode:"pan",lastX:t.localX,moved:!1}}}},[Ua,Rn,La]),Ha=(0,a.useCallback)(e=>{var t;if(2===e.touches.length){var n;const t=Ua(e.touches);if(!t||void 0===t.centerX||void 0===t.distance)return;const a=fn.current;if(!a||"pinch"!==a.mode)return void(fn.current={mode:"pinch",lastCenterX:t.centerX,lastDistance:Math.max(t.distance,1),moved:!1});Wn(),rn(!1);const r=Math.max(a.lastDistance||t.distance,1)/Math.max(t.distance,1);Hn(On(t.centerX),r);const s=t.centerX-(null!==(n=a.lastCenterX)&&void 0!==n?n:t.centerX);return Math.abs(s)>.5&&(Vn(-s),a.moved=!0),a.lastCenterX=t.centerX,void(a.lastDistance=Math.max(t.distance,1))}if(1!==e.touches.length)return;const a=fn.current,r=Ua(e.touches);if(!r||!a||"pan"!==a.mode)return;const s=r.localX-(null!==(t=a.lastX)&&void 0!==t?t:r.localX);Math.abs(s)<.5||(Wn(),rn(!1),Vn(-s),a.lastX=r.localX,a.moved=!0)},[Ua,Wn,Vn,rn,On,Hn]),qa=(0,a.useCallback)(e=>{const t=fn.current;if(t){if(bn.current=t.moved,1===e.touches.length&&Rn){const n=Ua(e.touches);if(n)return void(fn.current={mode:"pan",lastX:n.localX,moved:t.moved})}if(2===e.touches.length){const n=Ua(e.touches);if(n&&void 0!==n.centerX&&void 0!==n.distance)return void(fn.current={mode:"pinch",lastCenterX:n.centerX,lastDistance:Math.max(n.distance,1),moved:t.moved})}fn.current=null}},[Ua,Rn]),Wa=(0,a.useCallback)(()=>{rn(!1),Hn(Q,.8)},[Q,rn,Hn]),Ya=(0,a.useCallback)(()=>{rn(!1),Hn(Q,1.25)},[Q,rn,Hn]),Ga=(0,a.useCallback)(()=>{Un(),ln()},[ln,Un]),Ka=(0,a.useMemo)(()=>{var e;if(null===j||void 0===j||null===(e=j.retentionData)||void 0===e||!e.length||0===En)return[];const t=j.videoDurationSeconds||En;return j.retentionData.map(e=>({timestamp:void 0!==e.timestampSeconds?e.timestampSeconds:e.ratio*t,relative:e.relativeRetention,absolute:e.absoluteRetention/100})).sort((e,t)=>e.timestamp-t.timestamp)},[j,En]),Xa=(0,a.useMemo)(()=>Ka.map(e=>e.absolute).sort((e,t)=>e-t),[Ka]),Ja=(0,a.useMemo)(()=>Ka.length?Ka.reduce((e,t)=>e+t.absolute,0)/Ka.length:0,[Ka]),$a=e=>{if(!Ka.length||0===En)return null;if("off"===Vt)return null;const t=((e,t)=>{if(!e.length)return null;let n=0,a=e.length-1;for(;n<=a;){const r=n+a>>1,s=e[r].timestamp;if(s<t)n=r+1;else{if(!(s>t))return{beforeIndex:r,afterIndex:r};a=r-1}}return{beforeIndex:Math.max(0,a),afterIndex:Math.min(e.length-1,n)}})(Ka,e);if(!t)return null;const n=Ka[t.beforeIndex],a=Ka[t.afterIndex];let r,s;if(n.timestamp===a.timestamp)r=n.relative,s=n.absolute;else{const t=(e-n.timestamp)/(a.timestamp-n.timestamp);r=n.relative+t*(a.relative-n.relative),s=n.absolute+t*(a.absolute-n.absolute)}const i=r*Math.sqrt(s);let o,l;
2let c,d,u;switch(Vt){case"absolute":o=s,l="".concat(Math.round(100*s),"%"),c=0;break;case"adjusted":{o=i;c=i-.5*Math.sqrt(Ja||0);const e=Math.round(100*c);l=e>=0?"+".concat(e,"%"):"".concat(e,"%");break}case"drops":o=s,l="".concat(Math.round(100*s),"% watching"),c=0;break;default:o=r,c=r-.5;const e=Math.round(100*c);l=e>=0?"+".concat(e,"%"):"".concat(e,"%")}if("relative"===Vt||"adjusted"===Vt)c>=.25?(d="Very High",u="#22c55e"):c>=.15?(d="High",u="#84cc16"):c>=.05?(d="Above Avg",u="#eab308"):c>=-.05?(d="Average",u="#fbbf24"):c>=-.15?(d="Below Avg",u="#f97316"):(d="Low",u="#ef4444");else{const e=Xa.filter(e=>e<=o).length/Xa.length;e>=.9?(d="Very High",u="#22c55e"):e>=.75?(d="High",u="#84cc16"):e>=.5?(d="Above Avg",u="#eab308"):e>=.25?(d="Below Avg",u="#f97316"):e>=.1?(d="Low",u="#ef4444"):(d="Very Low",u="#dc2626")}return{value:o,label:d,color:u,displayValue:l}},Qa=(0,a.useMemo)(()=>{if(!Ka.length||En<=0||"off"===Vt||"drops"===Vt)return null;null===j||void 0===j||j.videoDurationSeconds;const e=e=>e/En*100,t=e=>{switch(Vt){case"absolute":return Math.log10(1+9*e.absolute);case"adjusted":return e.relative*Math.sqrt(e.absolute);default:return e.relative}},n=Ka.map(n=>{const a=e(n.timestamp);return null===a?null:d(d({},n),{},{x:Math.max(0,Math.min(100,a)),graphValue:t(n)})}).filter(e=>null!==e);if(!n.length)return null;const a=n.map(e=>e.graphValue),r=Math.min(...a),s=Math.max(...a),i=s-r,o=Math.max(.1*i,.02),l=Math.max(0,r-o),c=s+o,u=Math.max(c-l,.001),m=e=>100-100*((e-l)/u),h=n.map(e=>d(d({},e),{},{y:m(e.graphValue)}));let p=50,g=!0;switch(Vt){case"absolute":p=m(Math.log10(5.5));break;case"adjusted":p=m(.5*Math.sqrt(Ja||0));break;default:p=m(.5),g=p>=0&&p<=100}const x="absolute"===Vt?"#232E3F":"adjusted"===Vt?"#8a6115":"#FFB52B",f="relative"===Vt?.5:.5*Math.sqrt(Ja||0),b="relative"===Vt||"adjusted"===Vt,y=e=>{if(!b)return x;const t=e-f;return t>=.25?"#22c55e":t>=.15?"#84cc16":t>=.05?"#eab308":t>=-.05?"#fbbf24":t>=-.15?"#f97316":"#ef4444"},v=b?h.slice(1).map((e,t)=>{const n=h[t],a=(n.graphValue+e.graphValue)/2;return{x1:n.x,y1:n.y,x2:e.x,y2:e.y,color:y(a)}}):[],w=h.map(e=>"".concat(e.x,",").concat(e.y)).join(" "),k=g&&p>=0&&p<=100?p:50,D=h.length>0?"M0,".concat(h[0].y," L").concat(h.map(e=>"".concat(e.x,",").concat(e.y)).join(" L")," L100,").concat(h[h.length-1].y," L100,").concat(k," L0,").concat(k," Z"):"";return{avgLineY:p,fillPath:D,graphColor:x,lineSegments:v,polylinePoints:w,retentionToY:m,showAvgLine:g,toHoverGraphValue:e=>"absolute"===Vt?Math.log10(1+9*e):e,getDisplayX:e,useTrafficLightColors:b}},[Tn,R,Ja,j,Vt,Ka,z,En]),Za=(0,a.useMemo)(()=>{var e;if(!Ka.length||En<=0||"drops"!==Vt||!j)return null;const t=j.videoDurationSeconds||En,n=(j.videoDurationSeconds,e=>e/En*100),a=(null===(e=j.videoStats)||void 0===e?void 0:e.views)||1e5,r=Math.ceil(t/30),s=Array.from({length:r}).map((e,n)=>{const r=30*n,s=Math.min(30*(n+1),t),i=wE(Ka,r),o=wE(Ka,s),l=i>=0?Ka[i].absolute:0,c=o>=0?Ka[o].absolute:0,d=a*c-a*l;return{start:r,end:s,dropped:d<0?Math.abs(d):0,gained:d>0?d:0}}),i=[...s.map(e=>e.dropped)].sort((e,t)=>e-t),o=[...s.map(e=>e.gained)].sort((e,t)=>e-t),l=Math.floor(.75*i.length),c=i[l]||1,u=o[l]||1,m=Math.max(c,u,1),h=s.map(e=>{const t=n(e.start),a=n(e.end);return null===t||null===a?null:d(d({},e),{},{xStart:t,xEnd:a,width:a-t})}).filter(e=>null!==e);return{bucketSize:30,drops:s,displayDrops:h,scaleValue:m}},[Tn,R,j,Vt,Ka,z,En]),er=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return t>0?"".concat(t,":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0")):"".concat(n,":").concat(a.toString().padStart(2,"0"))},tr=e=>{const t=gE(e,!0).match(/Justification:\s*([^\n]+)/i);if(!t)return;return gE(t[1]).replace(/Optimal Placement:.*$/i,"").trim()||void 0},nr=(0,a.useCallback)(e=>{var t,n;let a=null!==(t=e.rank)&&void 0!==t?t:5,r=null!==(n=e.maxRank)&&void 0!==n?n:10;if("overall"===Rt){const t=e.content.match(/Score:\s*\[?(\d+)\/(\d+)\]?/);t&&(a=parseInt(t[1]),r=parseInt(t[2]))}else if("substance"===Rt){const t=e.content.match(/S:\s*(\d+)\/(\d+)/);t&&(a=parseInt(t[1]),r=parseInt(t[2]))}else if("resonance"===Rt){const t=e.content.match(/R:\s*(\d+)\/(\d+)/);t&&(a=parseInt(t[1]),r=parseInt(t[2]))}else if("clarity"===Rt){const t=e.content.match(/C:\s*(\d+)\/(\d+)/);t&&(a=parseInt(t[1]),r=parseInt(t[2]))}else if("production"===Rt){const t=e.content.match(/P:\s*(\d+)\/(\d+)/);t&&(a=parseInt(t[1]),r=parseInt(t[2]))}else if("creative_risk"===Rt){const t=e.content.match(/CR:\s*(\d+)\/(\d+)/);t&&(a=parseInt(t[1]),r=parseInt(t[2]))}return{score:a,maxScore:r,ratio:r>0?a/r:0}},[Rt]),ar=(0,a.useCallback)(()=>VN[Rt]||Rt,[Rt]),rr="".concat(Rt,"-").concat(Vt,"-").concat(zt,"-").concat(Wt),sr=(0,a.useMemo)(()=>{const e=[],t=!!h&&(h.placements.length>0||h.titles.length>0),n=((null===h||void 0===h?void 0:h.titles)||[]).map(e=>({title:e,isActive:_m(e.displayStart,e.displayEnd,Q),distance:Mm(e.displayStart,e.displayEnd,Q)})).filter(e=>{let{isActive:t,distance:n}=e;return t||n<=45}).sort((e,t)=>
2e.isActive!==t.isActive?e.isActive?-1:1:e.distance!==t.distance?e.distance-t.distance:e.title.displayStart-t.title.displayStart).slice(0,2).map(e=>{let{title:t,isActive:n}=e;return{id:"title:".concat(t.id),kind:"title",title:t.text||"Session title",meta:"".concat(n?"On screen":"Nearby"," \u2022 ").concat(jm(t.displayStart),"-").concat(jm(t.displayEnd)),description:t.subtitle||t.variant||void 0,previewImageUrl:Dm(t),seekTime:t.displayStart}});e.push(...n);const a=((null===h||void 0===h?void 0:h.placements)||[]).map(e=>({placement:e,isActive:_m(e.displayStart,e.displayEnd,Q),distance:Mm(e.displayStart,e.displayEnd,Q)})).filter(e=>{let{isActive:t,distance:n}=e;return t||n<=45}).sort((e,t)=>e.isActive!==t.isActive?e.isActive?-1:1:e.distance!==t.distance?e.distance-t.distance:e.placement.displayStart-t.placement.displayStart).slice(0,3).map(e=>{var t;let{placement:n,isActive:a}=e;return{id:"asset:".concat(n.id),kind:"asset",title:gE(n.referenceTitle||n.description||n.filename||"Session asset"),meta:"".concat(a?"Visible now":"Upcoming"," \u2022 ").concat(jm(n.displayStart),"-").concat(jm(n.displayEnd)),description:null!==(t=n.mimeType)&&void 0!==t&&t.startsWith("video/")?"Attached video clip":"Attached still asset",previewImageUrl:Dm(n),attachmentLabel:n.layoutMode?n.layoutMode.toUpperCase():void 0,seekTime:n.displayStart}});if(e.push(...a),!t){const t=nt.topics.find(e=>Q>=e.start&&Q<e.end);if(null!==t&&void 0!==t&&t.title){var r,s;const n=nr(t);e.push({id:"topic:".concat(t.id),kind:"topic",title:gE(t.title),meta:"Topic ".concat(t.segmentNumber||nt.topics.indexOf(t)+1," \u2022 ").concat(ar()," ").concat(null!==(r=n.score)&&void 0!==r?r:"?"," / ").concat(null!==(s=n.maxScore)&&void 0!==s?s:"?"),description:tr(t.content),seekTime:t.start})}const n=nt.clips.find(e=>Q>=e.start&&Q<e.end);if(n){const t=(e=>{const t=gE(String(e||"").replace(/\[CLIP\]\s*/gi,""),!0);if(!t)return{};if(t.includes("|")){const e=t.split("|").map(e=>e.trim());return{title:gE(e[0]||"")||void 0,type:gE(e[1]||"")||void 0,description:gE(e[2]||"")||void 0,visualSuggestion:gE(e[3]||"")||void 0}}const n=t.split("\n").map(e=>e.trim()).filter(Boolean);let a,r,s,i;for(const o of n){const e=o.toLowerCase();if(e.startsWith("visual:"))i=o.replace(/^visual:\s*/i,"").trim()||void 0;else{if(e.includes("viral hook")||e.includes("viral:")){r="Viral Hook";const e=o.indexOf(":");e>-1&&!s&&(s=o.substring(e+1).trim()||void 0);continue}if(e.includes("educational nugget")||e.includes("educational:")){r="Educational Nugget";const e=o.indexOf(":");e>-1&&!s&&(s=o.substring(e+1).trim()||void 0);continue}if(e.includes("humorous aside")||e.includes("humorous:")||e.includes("humor:")){r="Humorous Aside";const e=o.indexOf(":");e>-1&&!s&&(s=o.substring(e+1).trim()||void 0);continue}a?s||(s=o):a=o}}return{title:a,type:r,description:s,visualSuggestion:i}})(n.content);(t.title||t.visualSuggestion)&&e.push({id:"clip:".concat(n.id),kind:"clip",title:t.title||"Clip",meta:t.type||"Clip",description:t.description,visualSuggestion:t.visualSuggestion,seekTime:n.start})}}const i=Xn.filter(e=>e.attachedVisualCount||e.visualSuggestion||e.url||e.title).map(e=>{const t=_m(e.start,e.end,Q);return{reference:e,distance:Mm(e.start,e.end,Q),isActive:t}}).filter(e=>{let{distance:t,isActive:n}=e;return n||t<=90}).sort((e,t)=>e.isActive!==t.isActive?e.isActive?-1:1:e.distance!==t.distance?e.distance-t.distance:e.reference.start-t.reference.start).slice(0,t?2:4).map(e=>{let{reference:t}=e;return{id:"reference:".concat(t.id),kind:"reference",title:gE(t.title||t.linkText||"Reference"),meta:t.category?gE(t.category):"Reference",description:t.context?gE(t.context,!0):void 0,visualSuggestion:t.visualSuggestion?gE(t.visualSuggestion,!0):void 0,previewImageUrl:t.attachedVisualPreviewUrl,attachmentLabel:t.attachedVisualCount?"".concat(t.attachedVisualCount," attached asset").concat(1===t.attachedVisualCount?"":"s"):void 0,seekTime:t.start,linkHref:t.url,referenceId:t.id}});return e.push(...i),e},[Q,nr,ar,h,Xn,nt.clips,nt.topics]),ir=(sr[pt],(0,a.useMemo)(()=>Xn.filter(e=>Boolean(e.visualSuggestion||e.attachedVisualCount)).length,[Xn])),or=(null===h||void 0===h?void 0:h.placements.length)||0,lr=(null===h||void 0===h?void 0:h.titles.length)||0;or>0||lr>0||nt.topics.length>0||nt.clips.length;(0,a.useEffect)(()=>{sr.length?gt(e=>Math.min(e,sr.length-1)):gt(0)},[sr]);const cr=(0,a.useCallback)(e=>{var t;if(null===j||void 0===j||null===(t=j.retentionData)||void 0===t||!t.length)return fE(e,0,1);const n=j.retentionData;if("relative"===Vt){const t=.5,a=n.map(e=>{var t;return null!==(t=e.relativeRetention)&&void 0!==t?t:.5}),r=Math.min(...a),s=Math.max(...a);if(e>=t){const n=s-t;return n>.001?.4+(e-t)/n*.6:.5}{const n=t-r;return n>.001?(e-r)/n*.4:.3}}if("adjusted"===Vt){const t=n.reduce((e,t)=>
2{var n;return e+(null!==(n=t.absoluteRetention)&&void 0!==n?n:50)/100},0)/n.length,a=.5*Math.sqrt(t),r=n.map(e=>{var t,n;const a=null!==(t=e.relativeRetention)&&void 0!==t?t:.5,r=(null!==(n=e.absoluteRetention)&&void 0!==n?n:50)/100;return a*Math.sqrt(r)}),s=Math.min(...r),i=Math.max(...r);if(e>=a){const t=i-a;return t>.001?.4+(e-a)/t*.6:.5}{const t=a-s;return t>.001?(e-s)/t*.4:.3}}{const t=n.map(e=>{var t;return(null!==(t=e.absoluteRetention)&&void 0!==t?t:50)/100}),a=Math.min(...t),r=Math.max(...t)-a;return r>.001?fE((e-a)/r,0,1):.5}},[Vt,j]),dr=(0,a.useCallback)(e=>{var t;if("off"!==Vt&&"drops"!==Vt&&null!==j&&void 0!==j&&null!==(t=j.retentionData)&&void 0!==t&&t.length){const t=(e.start+e.end)/2,n=$a(t);if(n){const e=cr(n.value);return zt?e>=.8?"rgb(34, 197, 94)":e>=.6?"rgb(132, 204, 22)":e>=.4?"rgb(250, 204, 21)":e>=.2?"rgb(251, 146, 60)":"rgb(239, 68, 68)":e>=.67?"rgb(34, 197, 94)":e>=.33?"rgb(234, 179, 8)":"rgb(239, 68, 68)"}}const{ratio:n}=nr(e);return zt?n>=.8?"rgb(34, 197, 94)":n>=.6?"rgb(132, 204, 22)":n>=.4?"rgb(250, 204, 21)":n>=.2?"rgb(251, 146, 60)":"rgb(239, 68, 68)":n>=.67?"rgb(34, 197, 94)":n>=.33?"rgb(234, 179, 8)":"rgb(239, 68, 68)"},[$a,nr,cr,j,Vt,zt]),ur=(0,a.useCallback)(e=>{const t=dr(e),n=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(n){const[,e,t,a]=n;return"linear-gradient(to right, rgba(".concat(e,", ").concat(t,", ").concat(a,", 0.8), rgba(").concat(e,", ").concat(t,", ").concat(a,", 1), rgba(").concat(e,", ").concat(t,", ").concat(a,", 0.8))")}return t},[dr]),mr=!(!c||!_||V),hr=mr&&!!vt&&!pn;(0,a.useEffect)(()=>{gn(!1)},[vt,y]),(0,a.useEffect)(()=>{if(zw("[AUDIO-PLAYER] Auto-select effect running:",{ttmlFilesCount:(null===f||void 0===f?void 0:f.length)||0,selectedTtmlId:null===y||void 0===y?void 0:y.substring(0,8),currentSelectedTtmlFile:it,currentLastLoadedChecksum:null===vt||void 0===vt?void 0:vt.substring(0,8),availableChecksums:null===f||void 0===f?void 0:f.map(e=>{var t;return null===(t=e.checksum)||void 0===t?void 0:t.substring(0,8)}).join(","),filesWithContent:(null===f||void 0===f?void 0:f.filter(e=>!!e.content).length)||0}),f&&f.length>0){if(y){zw("[AUDIO-PLAYER] Looking for file with selectedTtmlId:",y.substring(0,8));const e=f.find(e=>e.checksum===y||(e.filename||e.name)===y);if(e){const t=e.filename||e.name,n=e.checksum||y;return zw("[AUDIO-PLAYER] Found file:",{newFileName:t,newChecksum:null===n||void 0===n?void 0:n.substring(0,8),hasContent:!!e.content}),ot(t),wt(n),void(e.content&&(zw("[AUDIO-PLAYER] Setting content directly, length:",e.content.length),yt(e.content)))}zw("[AUDIO-PLAYER] File NOT found in ttmlFiles for selectedTtmlId:",y.substring(0,8))}if(!y){const e=f[0];if(e){const t=e.filename||e.name,n=e.checksum||null;zw("[AUDIO-PLAYER] Auto-selecting first file:",t,"checksum:",null===n||void 0===n?void 0:n.substring(0,8),"hasContent:",!!e.content),ot(t),wt(n),e.content&&(zw("[AUDIO-PLAYER] File has content, setting directly, length:",e.content.length),yt(e.content))}}}},[f,y]),(0,a.useEffect)(()=>{if(hr)return;if(!f||0===f.length)return;if(!it&&!vt)return;if(bt)return;zw("[AUDIO-PLAYER] Fallback content load check:",{selectedTtmlFile:it,lastLoadedChecksum:null===vt||void 0===vt?void 0:vt.substring(0,8),hasCurrentContent:!!bt});const e=vt?f.find(e=>e.checksum===vt):f.find(e=>(e.filename||e.name)===it);null!==e&&void 0!==e&&e.content&&(zw("[AUDIO-PLAYER] Fallback: Found file with content, loading it, length:",e.content.length),yt(e.content))},[f,it,vt,bt,hr]),(0,a.useEffect)(()=>{if(hr)return;if(!y)return;const e=null===f||void 0===f?void 0:f.find(e=>e.checksum===y||(e.filename||e.name)===y);if(e&&e.content)return void zw("[AUDIO-PLAYER] File exists in ttmlFiles with content, skipping direct fetch");if(V&&!e)return void zw("[AUDIO-PLAYER] Public share has no matching TTML metadata, skipping direct preview fetch");(async()=>{zw("[AUDIO-PLAYER] Fetching preview for checksum:",y);try{const e=await H(y);e&&(zw("[AUDIO-PLAYER] Loaded preview TTML content, length:",e.length),yt(e))}catch(e){console.error("[AUDIO-PLAYER] Failed to fetch preview TTML:",e)}})()},[y,f,V,H,hr]),(0,a.useEffect)(()=>
2{if(hr)return;if(zw("[AUDIO-PLAYER] Load content effect:",{selectedTtmlFile:it,lastLoadedChecksum:null===vt||void 0===vt?void 0:vt.substring(0,8),ttmlFilesCount:(null===f||void 0===f?void 0:f.length)||0,hasToken:!!_}),!it||!f)return void zw("[AUDIO-PLAYER] Load content effect returning early - missing selectedTtmlFile or ttmlFiles");(async()=>{var e,t;let n=vt?f.find(e=>e.checksum===vt):null;if(zw("[AUDIO-PLAYER] Looking for file by checksum:",null===vt||void 0===vt?void 0:vt.substring(0,8),"found:",!!n),n||(n=f.find(e=>(e.filename||e.name)===it),zw("[AUDIO-PLAYER] Looking for file by filename:",it,"found:",!!n)),n){zw("[AUDIO-PLAYER] Found file to load:",{name:n.name||n.filename,checksum:null===(e=n.checksum)||void 0===e?void 0:e.substring(0,8),hasContent:!!n.content,contentLength:(null===(t=n.content)||void 0===t?void 0:t.length)||0});try{let e=n.content;var a;if(!e&&n.checksum)zw("[AUDIO-PLAYER] Loading TTML content for checksum:",null===(a=n.checksum)||void 0===a?void 0:a.substring(0,8)),e=await H(n.checksum)||void 0;e?(zw("[AUDIO-PLAYER] Setting currentTtmlContent, length:",e.length,"starts with:",e.substring(0,50)),yt(e)):zw("[AUDIO-PLAYER] No ttmlContent to set!")}catch(r){console.error("Error loading TTML content:",r)}}else zw("[AUDIO-PLAYER] No file found, returning")})()},[it,f,H,vt,hr]),(0,a.useEffect)(()=>{if(!mr||!vt||!c)return;let e=!1;return(async()=>{try{const t=V&&U?await UN.getPublicStructure(U,vt):await UN.getStructure(c,vt,_);if(e)return;at({clips:t.clips.map(SE),topics:t.topics.map(FE),edits:t.edits.map(EE),references:t.references.map(AE)}),gn(!1)}catch(t){console.error("[AUDIO-PLAYER] Failed to load structured TTML metadata:",t),e||gn(!0)}})(),()=>{e=!0}},[mr,V,U,vt,c,_]),(0,a.useEffect)(()=>{if(hr)return;if(zw("[AUDIO-PLAYER] Parse effect running, currentTtmlContent length:",(null===bt||void 0===bt?void 0:bt.length)||0),!bt)return zw("[AUDIO-PLAYER] No currentTtmlContent, clearing elements"),void at({clips:[],topics:[],edits:[],references:[]});(()=>{zw("[AUDIO-PLAYER] parseElements() called");const e=[],t=[],n=[],a=[];try{var r;zw("[AUDIO-PLAYER] Starting XML parse, content preview:",bt.substring(0,200));const s={"ä":"ä","ö":"ö","ü":"ü","Ä":"Ä","Ö":"Ö","Ü":"Ü","ß":"ß"," ":" ","©":"©","®":"®","™":"™","–":"–","—":"—","‘":"‘","’":"’","“":"“","”":"”","•":"•","…":"…","é":"é","è":"è","á":"á","à":"à","í":"í","ó":"ó","ú":"ú","ñ":"ñ","ç":"ç"};let i=bt;for(const[e,t]of Object.entries(s))i=i.split(e).join(t);i=i.replace(/&(?!amp;|lt;|gt;|apos;|quot;|#\d+;|#x[0-9a-fA-F]+;)([a-zA-Z]+);/g,(e,t)=>(console.warn("[AUDIO-PLAYER] Unknown HTML entity encountered:",e),""));const o=(new DOMParser).parseFromString(i,"application/xml");zw("[AUDIO-PLAYER] XML parsed, document element:",null===(r=o.documentElement)||void 0===r?void 0:r.tagName);const l=o.querySelector("parsererror"),c=o.getElementsByTagName("parsererror");if(zw("[AUDIO-PLAYER] Parse error check - querySelector:",!!l,", getElementsByTagName:",c.length),l)return void console.error("[AUDIO-PLAYER] XML parse error:",l.textContent);if(c.length>0)return void console.error("[AUDIO-PLAYER] XML parse error (NS check):",c[0].textContent);const d=e=>{const t=e.split(":");if(3===t.length){return 3600*parseInt(t[0])+60*parseInt(t[1])+parseFloat(t[2])}return 0},u=(e,t)=>{let n=e.querySelectorAll(t);if(0===n.length){const n=e.getElementsByTagNameNS("*",t);return Array.from(n)}return Array.from(n)},m=(e,t)=>u(e,t).filter(e=>e.getAttribute("begin")&&e.getAttribute("end")),h=u(o,"div");zw("[AUDIO-PLAYER] Found",h.length,"div elements"),h.forEach(r=>{const s=r.getAttribute("xml:id");if(zw("[AUDIO-PLAYER] Processing div with xml:id:",s),"d_clip"===s){m(r,"p").forEach(t=>{const n=t.getAttribute("begin"),a=t.getAttribute("end");let r=t.textContent||"";r=r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'"),n&&a&&!r.includes("PLACEHOLDER")&&e.push({id:"clip_".concat(e.length+1),start:d(n),end:d(a),type:"clip",content:r.trim()})})}
2else if("d_summary"===s){m(r,"p").forEach(e=>{const n=e.getAttribute("begin"),a=e.getAttribute("end");let r=e.textContent||"";if(r=r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'"),n&&a){const e=r.match(/\[(\d+):\s*(\d+|\?)\/(\d+)\]\s*(?:>>)\s*\[([^\]]+)\]/);let i=5,o=10,l=r.substring(0,50),c=t.length+1;if(e){c=parseInt(e[1],10);parseInt(e[2],10),parseInt(e[3],10);l=e[4].trim();const t=r.match(/Score:\s*\[?(\d+)\/(\d+)\]?/);t?(i=parseInt(t[1],10),o=parseInt(t[2],10)):(i=5,o=10,console.warn("[CentralAudioPlayer] No score found for topic:",l))}else{var s;const e=null===(s=r.match(/^([^:]+):/))||void 0===s?void 0:s[1];e&&(l=e.trim());const t=r.match(/Score:\s*\[?(\d+)\/(\d+)\]?/);t?(i=parseInt(t[1],10),o=parseInt(t[2],10)):(i=5,o=10),console.warn("[CentralAudioPlayer] No segment pattern found for topic:",l)}const u=isNaN(i)||i<0?5:i,m=isNaN(o)||o<=0?10:o;t.push({id:"topic_".concat(t.length+1),start:d(n),end:d(a),type:"topic",content:r.trim(),title:l,rank:u,maxRank:m,segmentNumber:c})}})}else if("d_edit"===s){m(r,"p").forEach(e=>{const t=e.getAttribute("begin"),a=e.getAttribute("end"),r=e.textContent||"";t&&a&&n.push({id:"edit_".concat(n.length+1),start:d(t),end:d(a),type:"edit",content:r.trim()})})}else if("d_references"===s){m(r,"p").forEach(e=>{const t=e.getAttribute("begin"),n=e.getAttribute("end"),r=[];let s="";e.childNodes.forEach(e=>{e.nodeType===Node.TEXT_NODE?s+=e.textContent||"":"br"===e.nodeName.toLowerCase()&&(r.push(s.trim()),s="")}),s.trim()&&r.push(s.trim());const i=r.map(e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")),o=i[0]||"";if(zw("[REF-PARSE] headerLine:",o),zw("[REF-PARSE] decodedLines:",i),t&&n){const e=o.match(/\[REF\]\s*([^|\n]+?)(?:\s*\|\s*([^|\n]+?)\s*\|\s*(https?:\/\/[^\s<>\n]+))?$/);zw("[REF-PARSE] refMatch:",e);let r,s,u,m,h,p=o.substring(0,50);var l,c;if(e)p=e[1].trim(),s=null===(l=e[2])||void 0===l?void 0:l.trim(),r=null===(c=e[3])||void 0===c?void 0:c.trim(),zw("[REF-PARSE] Extracted - title:",p,"linkText:",s,"url:",r);else zw("[REF-PARSE] NO MATCH for headerLine:",o);i.length>1&&i[1]&&(u=i[1]),i.length>2&&i[2]&&(m=i[2]),i.length>3&&i[3]&&(h=i[3]);const g=i.join("\n");a.push({id:"ref_".concat(a.length+1),start:d(t),end:d(n),type:"reference",content:g,title:p,url:r,linkText:s,category:u,context:m,visualSuggestion:h})}})}}),zw("[CentralAudioPlayer] Parsed TTML elements:",{clips:e.length,topics:t.length,edits:n.length,references:a.length}),at({clips:e,topics:t,edits:n,references:a}),t.length>0&&zw("[CentralAudioPlayer] Topic parsing details:",{totalTopics:t.length,sampleTopics:t.slice(0,3).map(e=>({title:e.title,rank:e.rank,maxRank:e.maxRank,hasRank:void 0!==e.rank,hasMaxRank:void 0!==e.maxRank}))})}catch(s){console.error("Error parsing TTML content:",s)}})()},[bt,hr]);(0,a.useCallback)(async()=>{if(c&&_)try{const e=await fetch("".concat(xE,"/api/sessions/").concat(c,"/comments"),{headers:{Authorization:"Bearer ".concat(_)}});if(e.ok){const t=await e.json();Nt(t.comments||[])}}catch(e){console.error("Failed to fetch comments:",e)}},[c,_]);const pr=(0,a.useCallback)(async(e,t)=>{c&&(Tt(t),Et(!0),_t(null))},[c]),gr=(0,a.useCallback)(e=>{_t(e),Et(!0),Tt(null)},[]),xr=((0,a.useCallback)(()=>{Tt(Q),Et(!0),_t(null)},[Q]),(0,a.useCallback)(e=>{zw("[CentralAudioPlayer] handleCommentsChange called with",e.length,"comments"),Nt(t=>JSON.stringify(t)===JSON.stringify(e)?(zw("[CentralAudioPlayer] Comments unchanged, skipping update"),t):(zw("[CentralAudioPlayer] Updating comments from",t.length,"to",e.length),e))},[])),fr=(0,a.useCallback)(()=>{Et(!1),Tt(null),_t(null)},[]),br=(0,a.useCallback)(e=>{tt(e),Se(!0)},[]),yr=(0,a.useCallback)(()=>{if(!vt||!_||!c)throw new Error("Missing required data to edit metadata");return{checksum:vt,authToken:_,currentSessionId:c}},[vt,c,_]),vr=(0,a.useCallback)(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};gn(!1),e.checksum&&wt(e.checksum),!n.suppressExternalRevisionUpdate&&F&&F({checksum:e.checksum,version:e.version,parentChecksum:e.parentChecksum,rootChecksum:e.rootChecksum,generatedAt:(new Date).toISOString(),model:"manual-edit",revisionNotes:t,editedBy:"manual-editor"})},[F]),wr=(0,a.useCallback)((e,t,n,a)=>{const r="clip"===t?"clips":"edits";at(t=>d(d({},t),{},{[r]:t[r].map(t=>{const r=void 0!==e.index&&t.index===e.index,s=t.id===e.id;return r||s?d(d({},t),{},{start:n,end:a}):t})})),Be(r=>{if(!r||r.type!==t)return r;const s=void 0!==e.index&&r.element.index===e.index,i=r.element.i
2d===e.id;return s||i?d(d({},r),{},{element:d(d({},r.element),{},{start:n,end:a})}):r})},[]),kr=(0,a.useCallback)(async e=>{const{checksum:t,authToken:n,currentSessionId:a}=yr(),r='# Revision Notes\n\n## Summary\nManually added reference "'.concat(e.name,'" at ').concat(er(e.startTime),'.\n\n## Changes Made\n- Added new reference: "').concat(e.name,'"').concat(e.category?" (".concat(e.category,")"):"").concat(e.url?"\n- URL: ".concat(e.url):"","\n\n## Timestamp\n- Position: ").concat(er(e.startTime)),s=await UN.mutateReferences(a,t,[{op:"add",data:{startTime:e.startTime,endTime:e.endTime,name:e.name,linkText:e.linkText,url:e.url,category:e.category,context:e.context,visual:e.visualSuggestion}}],r,n);vr(s,r,{suppressExternalRevisionUpdate:!0})},[vr,yr]),jr=(0,a.useCallback)(async(e,t)=>{const{checksum:n,authToken:a,currentSessionId:r}=yr();if(void 0===e.index)throw new Error("Reference index is missing");const s=[];t.name!==e.title&&s.push('Name: "'.concat(e.title,'" -> "').concat(t.name,'"')),t.category!==e.category&&s.push("Category updated"),t.url!==e.url&&s.push("URL updated"),t.linkText!==e.linkText&&s.push("Link text updated"),t.context!==e.context&&s.push("Context updated"),t.visualSuggestion!==e.visualSuggestion&&s.push("Visual suggestion updated");const i='# Revision Notes\n\n## Summary\nManually edited reference "'.concat(t.name,'" at ').concat(er(e.start),".\n\n## Changes Made\n").concat(s.length>0?s.map(e=>"- ".concat(e)).join("\n"):"- Minor edits","\n\n## Timestamp\n- Position: ").concat(er(e.start)),o=await UN.mutateReferences(r,n,[{op:"update",index:e.index,data:{name:t.name,linkText:t.linkText,url:t.url,category:t.category,context:t.context,visual:t.visualSuggestion}}],i,a);De(e=>e?d(d({},e),{},{title:t.name,linkText:t.linkText,url:t.url,category:t.category,context:t.context,visualSuggestion:t.visualSuggestion}):e),vr(o,i,{suppressExternalRevisionUpdate:!0})},[vr,yr]),Dr=(0,a.useCallback)(async e=>{const{checksum:t,authToken:n,currentSessionId:a}=yr();if(void 0===e.index)throw new Error("Reference index is missing");const r='# Revision Notes\n\n## Summary\nManually deleted reference "'.concat(e.title,'" at ').concat(er(e.start),".\n\n## Changes Made\n- Deleted reference\n\n## Timestamp\n- Position: ").concat(er(e.start)),s=await UN.mutateReferences(a,t,[{op:"remove",index:e.index}],r,n);De(null),vr(s,r)},[vr,yr]),Cr=(0,a.useCallback)(async(e,t)=>{var n,a;const{checksum:r,authToken:s,currentSessionId:i}=yr();if(void 0===e.index)throw new Error("Reference index is missing");const o=null!==(n=e._originalStart)&&void 0!==n?n:e.start,l=(null!==(a=e._originalEnd)&&void 0!==a?a:e.end)-o,c='# Revision Notes\n\n## Summary\nMoved reference "'.concat(e.title,'" from ').concat(er(o)," to ").concat(er(t),".\n\n## Changes Made\n- Timestamp: ").concat(er(o)," -> ").concat(er(t),"\n\n## Method\n- Dragged on timeline"),d=await UN.mutateReferences(i,r,[{op:"update",index:e.index,data:{startTime:t,endTime:t+l}}],c,s);vr(d,c)},[vr,yr]),Nr=(0,a.useCallback)(e=>{zw("[CentralAudioPlayer] Reference drag started:",e.title)},[]),Fr=(0,a.useCallback)((e,t)=>{},[]),Sr=(0,a.useCallback)(async(e,t)=>{var n;Zt(null);const a=null!==(n=e._originalStart)&&void 0!==n?n:e.start;Math.abs(t-a)<.5||await Cr(e,t)},[Cr,Zt]),Er=(0,a.useCallback)(async(e,t)=>{const{checksum:n,authToken:a,currentSessionId:r}=yr();if(void 0===e.index)throw new Error("Clip index is missing");const s='# Revision Notes\n\n## Summary\nManually edited clip "'.concat(t.title,'" at ').concat(er(t.start),".\n\n## Changes Made\n- Updated clip content and/or timing\n\n## Timestamp\n- Position: ").concat(er(t.start)," - ").concat(er(t.end)),i=await UN.mutateClips(r,n,[{op:"update",index:e.index,data:{title:t.title,clipType:t.clipType,description:t.description,visual:t.visual,startTime:t.start,endTime:t.end}}],s,a);vr(i,s)},[vr,yr]),Ar=(0,a.useCallback)(async e=>{const{checksum:t,authToken:n,currentSessionId:a}=yr();if(void 0===e.index)throw new Error("Clip index is missing");const r='# Revision Notes\n\n## Summary\nManually deleted clip "'.concat(e.title,'" at ').concat(er(e.start),".\n\n## Changes Made\n- Deleted clip\n\n## Timestamp\n- Position: ").concat(er(e.start)),s=await UN.mutateClips(a,t,[{op:"remove",index:e.index}
2],r,n);Be(null),vr(s,r)},[vr,yr]),Tr=(0,a.useCallback)(async(e,t)=>{const{checksum:n,authToken:a,currentSessionId:r}=yr();if(void 0===e.index)throw new Error("Edit index is missing");const s='# Revision Notes\n\n## Summary\nManually edited edit suggestion "'.concat(t.title,'" at ').concat(er(t.start),".\n\n## Changes Made\n- Updated edit content and/or timing\n\n## Timestamp\n- Position: ").concat(er(t.start)," - ").concat(er(t.end)),i=await UN.mutateEdits(r,n,[{op:"update",index:e.index,data:{title:t.title,suggestion:t.suggestion,improvement:t.improvement,priority:t.priority,startTime:t.start,endTime:t.end}}],s,a);vr(i,s)},[vr,yr]),Mr=(0,a.useCallback)(async e=>{const{checksum:t,authToken:n,currentSessionId:a}=yr();if(void 0===e.index)throw new Error("Edit index is missing");const r='# Revision Notes\n\n## Summary\nManually deleted edit suggestion "'.concat(e.title,'" at ').concat(er(e.start),".\n\n## Changes Made\n- Deleted edit\n\n## Timestamp\n- Position: ").concat(er(e.start)),s=await UN.mutateEdits(a,t,[{op:"remove",index:e.index}],r,n);Be(null),vr(s,r)},[vr,yr]),_r=(0,a.useCallback)(async(e,t)=>{"clip"!==(null===_e||void 0===_e?void 0:_e.type)?await Tr(e,t):await Er(e,t)},[Er,Tr,null===_e||void 0===_e?void 0:_e.type]),Br=(0,a.useCallback)(async e=>{"clip"!==(null===_e||void 0===_e?void 0:_e.type)?await Mr(e):await Ar(e)},[Ar,Mr,null===_e||void 0===_e?void 0:_e.type]),Ir=(0,a.useCallback)(async(e,t,n,a)=>{var r;const{checksum:s,authToken:i,currentSessionId:o}=yr();if(void 0===e.index)throw new Error("Clip index is missing");const l=null!==(r=e._originalStart)&&void 0!==r?r:e.start,c="# Revision Notes\n\n## Summary\n".concat("move"===a?"Moved":"Resized",' clip "').concat(e.title,'" via timeline drag.\n\n## Changes Made\n- Timing: ').concat(er(l)," -> ").concat(er(t)," to ").concat(er(n),"\n\n## Timestamp\n- New position: ").concat(er(t)," - ").concat(er(n)),d=await UN.mutateClips(o,s,[{op:"update",index:e.index,data:{startTime:t,endTime:n}}],c,i);vr(d,c,{suppressExternalRevisionUpdate:!0})},[vr,yr]),Pr=(0,a.useCallback)(async(e,t,n,a)=>{var r;const{checksum:s,authToken:i,currentSessionId:o}=yr();if(void 0===e.index)throw new Error("Edit index is missing");const l=null!==(r=e._originalStart)&&void 0!==r?r:e.start,c="# Revision Notes\n\n## Summary\n".concat("move"===a?"Moved":"Resized",' edit "').concat(e.title,'" via timeline drag.\n\n## Changes Made\n- Timing: ').concat(er(l)," -> ").concat(er(t)," to ").concat(er(n),"\n\n## Timestamp\n- New position: ").concat(er(t)," - ").concat(er(n)),d=await UN.mutateEdits(o,s,[{op:"update",index:e.index,data:{startTime:t,endTime:n}}],c,i);vr(d,c,{suppressExternalRevisionUpdate:!0})},[vr,yr]),Lr=(0,a.useCallback)((e,t,n,a)=>{var r,s;if("button"in e&&0!==e.button)return;e.stopPropagation(),e.preventDefault(),Ze.current&&(clearTimeout(Ze.current),Ze.current=null),Qe(null);const i=null!==(r=ma(t.start))&&void 0!==r?r:t.start,o=null!==(s=ma(t.end))&&void 0!==s?s:t.end;Ye.current=!1,ze({element:t,type:n,handle:a,pointerId:"pointerId"in e?e.pointerId:-1,initialStart:t.start,initialEnd:t.end,initialDisplayStart:i,initialDisplayEnd:o,initialMouseX:e.clientX}),Na({start:i,end:o})},[Na,ma]),Rr=(0,a.useCallback)((e,t,n,a)=>{var r,s;if("mouse"===e.pointerType){if(Pa(),"move"===a){var i,o,l,c;if("button"in e&&0!==e.button)return;return e.stopPropagation(),e.preventDefault(),null===(i=(o=e.currentTarget).setPointerCapture)||void 0===i||i.call(o,e.pointerId),void Ue({element:t,type:n,pointerId:e.pointerId,initialStart:t.start,initialEnd:t.end,initialDisplayStart:null!==(l=ma(t.start))&&void 0!==l?l:t.start,initialDisplayEnd:null!==(c=ma(t.end))&&void 0!==c?c:t.end,initialMouseX:e.clientX,initialMouseY:e.clientY})}null===(r=(s=e.currentTarget).setPointerCapture)||void 0===r||r.call(s,e.pointerId),Lr(e,t,n,a)}},[Pa,Lr,ma]),zr=(0,a.useCallback)(e=>{e.stopPropagation(),e.preventDefault()},[]),Or=(0,a.useCallback)((e,t,n)=>{if(e.stopPropagation(),e.preventDefault(),Re||Oe)return;const a="".concat(n,":").concat(void 0!==t.index?"index:".concat(t.index):"id:".concat(t.id));Le.current!==a?(Be({element:t,type:n}),Pe(!0)):Le.current=null},[Re,Oe]),Ur=(0,a.useCallback)(e=>{var t,n;const a=En,r=Pn||mn;if(!a||!r)return 0;const s=null!==(t=ma(e.start))&&void 0!==t?t:e.start;return((null!==(n=ma(e.end))&&void 0!==n?n:e.end)-s)/a*r},[Tn,R,mn,ma,Pn,En]),Vr=(0,a.useMemo)(()=>!!_e&&("clip"!==_e.type||Ur(_e.element)>=72),[Ur,_e]),Hr=(0,a.useCallback)(e=>{G(e),ln(e)},[ln,G]);(0,a.useEffect)(()=>
2{if(!Oe||Re)return;const e=e=>{if(-1!==Oe.pointerId&&e.pointerId!==Oe.pointerId)return;if(0===e.buttons)return void t(e);const n=e.clientX-Oe.initialMouseX,a=e.clientY-Oe.initialMouseY;Math.max(Math.abs(n),Math.abs(a))<8||((e,t)=>{const n=cn.current;if(!n)return;const a=n.getBoundingClientRect();if(!a.width)return;const r=(e-Oe.initialMouseX)/a.width,s=En,i=r*(In||s),o=Oe.initialDisplayEnd-Oe.initialDisplayStart,l=Math.max(0,Math.min(Oe.initialDisplayStart+i,s-o)),c=l+o;Ye.current=!0,ze({element:Oe.element,type:Oe.type,handle:"move",pointerId:Oe.pointerId,initialStart:Oe.initialStart,initialEnd:Oe.initialEnd,initialDisplayStart:Oe.initialDisplayStart,initialDisplayEnd:Oe.initialDisplayEnd,initialMouseX:Oe.initialMouseX}),Sa({start:l,end:c},{x:e,y:t}),Ue(null)})(e.clientX,e.clientY)},t=e=>{var t,n,a;if(e&&-1!==Oe.pointerId&&e.pointerId!==Oe.pointerId)return;const r=null!==(t=null===e||void 0===e?void 0:e.clientX)&&void 0!==t?t:Oe.initialMouseX,s=null!==(n=null===e||void 0===e?void 0:e.clientY)&&void 0!==n?n:Oe.initialMouseY;if(0!==(null!==(a=null===e||void 0===e?void 0:e.buttons)&&void 0!==a?a:0)&&e)return;const i=r-Oe.initialMouseX,o=s-Oe.initialMouseY;Math.max(Math.abs(i),Math.abs(o))<8&&(Be({element:Oe.element,type:Oe.type}),Pe(!0)),Ue(null)},n=()=>t();return document.addEventListener("pointermove",e),document.addEventListener("pointerup",t),document.addEventListener("pointercancel",t),window.addEventListener("blur",n),()=>{document.removeEventListener("pointermove",e),document.removeEventListener("pointerup",t),document.removeEventListener("pointercancel",t),window.removeEventListener("blur",n)}},[Tn,Re,R,Oe,cn,Mn,En,In]),(0,a.useEffect)(()=>{if(!Re)return;const e=e=>{if(-1!==Re.pointerId&&e.pointerId!==Re.pointerId)return;if(0===e.buttons)return void t();const n=cn.current;if(!n)return;const a=n.getBoundingClientRect();if(!a.width)return;const r=e.clientX-Re.initialMouseX;if(Math.abs(r)<8)return void Sa({start:Re.initialDisplayStart,end:Re.initialDisplayEnd},null);Ye.current=!0;const s=r/a.width,i=En,o=s*(In||i);let l=Re.initialDisplayStart,c=Re.initialDisplayEnd;switch(Re.handle){case"left":l=Math.max(0,Math.min(Re.initialDisplayStart+o,c-1));break;case"right":c=Math.min(i,Math.max(Re.initialDisplayEnd+o,l+1));break;case"move":const e=Re.initialDisplayEnd-Re.initialDisplayStart;l=Math.max(0,Math.min(Re.initialDisplayStart+o,i-e)),c=l+e}Sa({start:l,end:c},{x:e.clientX,y:e.clientY})},t=e=>{var t;if(e&&-1!==Re.pointerId&&e.pointerId!==Re.pointerId)return;const n=null!==(t=Ke.current)&&void 0!==t?t:Ge.current,a=Re&&n?(()=>{const{element:e,type:t,handle:a,initialStart:r,initialEnd:s}=Re,{start:i,end:o}=n,l=ha(i),c=ha(o),d=Number.isFinite(l)?l:r,u=Number.isFinite(c)?c:s;return Ye.current&&(Math.abs(d-r)>.05||Math.abs(u-s)>.05)?{element:e,type:t,handle:a,initialStart:r,initialEnd:s,newStart:d,newEnd:u}:null})():null;a&&(Le.current="".concat(a.type,":").concat(void 0!==a.element.index?"index:".concat(a.element.index):"id:".concat(a.element.id)),wr(a.element,a.type,a.newStart,a.newEnd)),Ye.current=!1,ze(null),Fa(),Na(null),We(null),a&&(async()=>{try{"clip"===a.type?await Ir(a.element,a.newStart,a.newEnd,a.handle):await Pr(a.element,a.newStart,a.newEnd,a.handle)}catch(e){console.error("[CentralAudioPlayer] Failed to update element timing:",e),wr(a.element,a.type,a.initialStart,a.initialEnd)}})()},n=()=>t(),a=document.body.style.cursor,r=document.body.style.userSelect;return document.body.style.cursor="move"===Re.handle?"grabbing":"ew-resize",document.body.style.userSelect="none",document.addEventListener("pointermove",e),document.addEventListener("pointerup",t),document.addEventListener("pointercancel",t),window.addEventListener("blur",n),()=>{document.removeEventListener("pointermove",e),document.removeEventListener("pointerup",t),document.removeEventListener("pointercancel",t),window.removeEventListener("blur",n),document.body.style.cursor=a,document.body.style.userSelect=r}},[wr,Na,Tn,Re,Fa,Ir,Pr,R,ha,cn,Sa,En,In]);const qr=(0,a.useCallback)((e,t,n)=>{Ze.current&&clearTimeout(Ze.current),Ze.current=setTimeout(()=>{const a=n.target.getBoundingClientRect();Qe({element:e,type:t,x:a.left+a.width/2,y:a.top})},600)},[]),Wr=(0,a.useCallback)(()=>{Ze.current&&(clearTimeout(Ze.current),Ze.current=null),Ze.current=setTimeout(()=>{Qe(null)},150)},[]);(0,a.useEffect)(()=>()=>{Ze.current&&clearTimeout(Ze.current)},[]),(0,a.useEffect)(()=>
2{if(!c||Bt)return;if(!kt)return Nt([]),void It(!1);if(N&&V&&C)return zw("[CentralAudioPlayer] Using pre-loaded comments from CDN bundle:",C.length,"comments"),Nt(C),void It(!1);(async()=>{It(!0);try{let t;if(V&&U)t=await fetch("".concat(xE,"/api/public/share/").concat(U,"/comments"));else{if(!_)return;t=await fetch("".concat(xE,"/api/sessions/").concat(c,"/comments"),{headers:{Authorization:"Bearer ".concat(_)}})}if(t&&t.ok){var e;const n=await t.json();zw("[CentralAudioPlayer] Loaded comments from API:",(null===(e=n.comments)||void 0===e?void 0:e.length)||0,"comments"),Nt(n.comments||[])}}catch(t){console.error("Failed to load comments from API:",t)}finally{It(!1)}})()},[c,_,V,U,N,C,kt]);const Yr=(0,a.useMemo)(()=>(0,u.jsxs)(u.Fragment,{children:[Ca,(0,u.jsxs)("div",{className:"absolute inset-0 pointer-events-none",style:{zIndex:10},children:[Ma.map((e,t)=>{const n=En,a=e.start/n*100,r=(e.end-e.start)/n*100;return(0,u.jsx)("div",{className:"absolute overflow-hidden",style:{left:"".concat(a,"%"),width:"".concat(r,"%"),top:$t.speakerTop,height:$t.speakerHeight,background:hp(e.speaker,M),opacity:.85},children:(0,u.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{background:ba?"none":M?"linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%), repeating-linear-gradient(135deg, rgba(255,255,255,0.045) 0px, rgba(255,255,255,0.045) 1px, transparent 1px, transparent 5px)":"linear-gradient(180deg, rgba(255,255,255,0.14) 0%, rgba(255,255,255,0.04) 100%), repeating-linear-gradient(135deg, rgba(255,255,255,0.06) 0px, rgba(255,255,255,0.06) 1px, transparent 1px, transparent 5px)",opacity:ba?0:.72,backdropFilter:ba?"none":"blur(2px) saturate(0.94)",WebkitBackdropFilter:ba?"none":"blur(2px) saturate(0.94)"}})},"speaker-".concat(t))}),(0,u.jsx)(a.Fragment,{children:"questions"===Wt?Ta.map(e=>{const t=En,n=e.start/t*100,a=(e.end-e.start)/t*100,r=(null===we||void 0===we?void 0:we.questionNumber)===e.questionNumber,s=e.questionNumber%2===0?"rgba(147, 130, 255, 0.75)":"rgba(100, 160, 255, 0.75)";return(0,u.jsxs)("div",{className:"absolute",style:{left:"".concat(n,"%"),width:"".concat(a,"%"),top:$t.topicTop,height:$t.topicHeight},children:[(0,u.jsx)("div",{className:"absolute inset-0",style:{background:"linear-gradient(to right, ".concat(s,", ").concat(s.replace("0.75","0.95"),", ").concat(s,")"),opacity:.95}}),(0,u.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{background:M?"linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%), repeating-linear-gradient(135deg, rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 1px, transparent 1px, transparent 5px)":"linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%), repeating-linear-gradient(135deg, rgba(255,255,255,0.065) 0px, rgba(255,255,255,0.065) 1px, transparent 1px, transparent 5px)",opacity:.68,backdropFilter:"blur(2px) saturate(0.95)",WebkitBackdropFilter:"blur(2px) saturate(0.95)"}}),r&&(0,u.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{background:"repeating-linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0.3) 0px,\n rgba(255, 255, 255, 0.3) 2px,\n transparent 2px,\n transparent 4px\n )",zIndex:10}}),!ne&&(0,u.jsxs)("div",{className:"absolute left-0 top-0 bg-black text-white text-xs px-1 rounded-br z-20",style:{fontSize:"10px",lineHeight:"12px"},children:["Q",e.questionNumber]})]},e.id)}):xa?null:Ea.map((e,t)=>{const n=e.start,a=e.end,r=n/En*100,s=(a-n)/En*100,i=he&&he.id===e.id;return(0,u.jsxs)("div",{className:"absolute",style:{left:"".concat(r,"%"),width:"".concat(s,"%"),top:$t.topicTop,height:$t.topicHeight},children:[(0,u.jsx)("div",{className:"absolute inset-0",style:{background:ur(e),opacity:.95}}),(0,u.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{background:ba?"none":M?"linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%), repeating-linear-gradient(135deg, rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 1px, transparent 1px, transparent 5px)":"linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%), repeating-linear-gradient(135deg, rgba(255,255,255,0.065) 0px, rgba(255,255,255,0.065) 1px, transparent 1px, transparent 5px)",opacity:ba?0:.68,backdropFilter:ba?"none":"blur(2px) saturate(0.95)",WebkitBackdropFilter:ba?"none":"blur(2px) saturate(0.95)"}}),i&&(0,u.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{background:"repeating-linear-gradient(\n 90deg,\n rgba(255, 255, 255, 0.3) 0px,\
2n rgba(255, 255, 255, 0.3) 2px,\n transparent 2px,\n transparent 4px\n )",zIndex:10}}),!ne&&(0,u.jsx)("div",{className:"absolute left-0 top-0 bg-black text-white text-xs px-1 rounded-br z-20",style:{fontSize:"10px",lineHeight:"12px"},children:e.segmentNumber||t+1})]},e.id)})},rr),nt.edits.filter(e=>!0).map(e=>{var t,n;const a=En,r=Pn||mn,s=void 0!==e.index?"edit_index_".concat(e.index):e.id,i=(void 0!==(null===Re||void 0===Re?void 0:Re.element.index)?"edit_index_".concat(Re.element.index):null===Re||void 0===Re?void 0:Re.element.id)===s&&"edit"===(null===Re||void 0===Re?void 0:Re.type),o=i&&Ve?Ve.start:null!==(t=ma(e.start))&&void 0!==t?t:e.start,l=i&&Ve?Ve.end:null!==(n=ma(e.end))&&void 0!==n?n:e.end,c=o/a*100,d=(l-o)/a*100,m=(l-o)/a*r,h=(null===fe||void 0===fe?void 0:fe.id)===e.id,p=Yn&&!ne,g=p&&m>=48,x=M?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.28)";return(0,u.jsx)("div",{className:"absolute overflow-hidden transition-opacity duration-75 ".concat(h||i?"opacity-100":"opacity-80"," ").concat(i?"z-50 transition-none":""," ").concat(p?"cursor-grab active:cursor-grabbing":""),style:{left:"".concat(c,"%"),width:"".concat(d,"%"),top:$t.editTop,height:$t.editHeight,background:"repeating-linear-gradient(\n 0deg,\n rgb(239, 68, 68) 0px,\n rgb(239, 68, 68) 2px,\n transparent 2px,\n transparent 4px\n )",boxShadow:h||i?"0 0 14px 5px rgba(239, 68, 68, 0.62)":"0 0 8px 2px rgba(239, 68, 68, 0.26)",pointerEvents:"auto"},onPointerDown:p?t=>Rr(t,e,"edit","move"):void 0,onClick:p?t=>Or(t,e,"edit"):void 0,onMouseEnter:t=>{p&&qr(e,"edit",t)},onMouseLeave:()=>{Wr()},children:g&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"absolute inset-y-0 left-0 z-20 flex items-center justify-center",style:{width:"".concat(10,"px"),cursor:"ew-resize",background:x},onPointerDown:t=>{t.stopPropagation(),Rr(t,e,"edit","left")},onClick:zr,children:(0,u.jsx)("span",{className:"h-3/5 w-px rounded-full bg-white/90 shadow-[0_0_6px_rgba(255,255,255,0.4)]"})}),(0,u.jsx)("div",{className:"absolute inset-y-0 right-0 z-20 flex items-center justify-center",style:{width:"".concat(10,"px"),cursor:"ew-resize",background:x},onPointerDown:t=>{t.stopPropagation(),Rr(t,e,"edit","right")},onClick:zr,children:(0,u.jsx)("span",{className:"h-3/5 w-px rounded-full bg-white/90 shadow-[0_0_6px_rgba(255,255,255,0.4)]"})})]})},s)}),nt.clips.filter(e=>!0).map(e=>{var t,n,a;const r=En,s=Pn||mn,i=void 0!==e.index?"clip_index_".concat(e.index):e.id,o=(void 0!==(null===Re||void 0===Re?void 0:Re.element.index)?"clip_index_".concat(Re.element.index):null===Re||void 0===Re?void 0:Re.element.id)===i&&"clip"===(null===Re||void 0===Re?void 0:Re.type),l=o&&Ve?Ve.start:null!==(t=ma(e.start))&&void 0!==t?t:e.start,c=o&&Ve?Ve.end:null!==(n=ma(e.end))&&void 0!==n?n:e.end,d=l/r*100,m=(c-l)/r*100,h=(c-l)/r*s,p=(null===ge||void 0===ge?void 0:ge.id)===e.id,g=Yn&&!ne,x=g&&h>=48,f=M?"rgba(59, 130, 246, 0.42)":"rgba(59, 130, 246, 0.28)",b=null!==(a=Ft.get(e.id))&&void 0!==a?a:XF,y=b.count>0;return(0,u.jsxs)("div",{className:"absolute ".concat(y?"overflow-visible":"overflow-hidden"," transition-opacity duration-75 ").concat(p||o?"opacity-100":"opacity-90"," ").concat(o?"z-50 transition-none":""," ").concat(g?"cursor-grab active:cursor-grabbing":""),style:{left:"".concat(d,"%"),width:"".concat(m,"%"),top:$t.clipTop,height:$t.clipHeight,background:"repeating-linear-gradient(\n 0deg,\n rgb(59, 130, 246) 0px,\n rgb(59, 130, 246) 2px,\n transparent 2px,\n transparent 4px\n )",boxShadow:p||o?"0 0 14px 5px rgba(59, 130, 246, 0.62)":"0 0 8px 2px rgba(59, 130, 246, 0.28)",pointerEvents:"auto"},onPointerDown:g?t=>Rr(t,e,"clip","move"):void 0,onClick:g?t=>Or(t,e,"clip"):void 0,onMouseEnter:t=>{g&&qr(e,"clip",t)},onMouseLeave:()=>{Wr()},children:[x&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"absolute inset-y-0 left-0 z-20 flex items-center justify-center",style:{width:"".concat(10,"px"),cursor:"ew-resize",background:f},onPointerDown:t=>{t.stopPropagation(),Rr(t,e,"clip","left")},onClick:zr,children:(0,u.jsx)("span",{className:"h-3/5 w-px rounded-full bg-white/90 shadow-[0_0_6px_rgba(255,255,255,0.4)]"})}),(0,u.jsx)("div",{className:"absolute inset-y-0 right-0 z-20 flex items-center justify-center",style:{width:"".concat(10,"px"),cursor:"ew-resize",background:f},onPointerDown:t=>{t.stopPropagation(),Rr(t,e,"clip","right")},onClick:zr,children:(0,u.jsx)("span",{className:"h-3/5 w-px rounded-full bg-white/90 shadow-[0_0_6px_rgba(255,255,255,0.4)]"})})]}),(0,u.jsx)(lS,{clipId:e.id,summary:b,clipPixelWidth:h,availableHeight:Xt?18:24,availablePreviewHeight:Pt,variant:Xt?"compact":"auto",isDarkMode:M,style:{position:"absolute",right:x?12:2,top:"50%",transform:"translateY(-50%)",zIndex:30},onOpenComments:e=>{let{focusCommentId:t}=e;t&&gr(t)}})]},i)}),L,E&&E.length>0&&En>0&&(0,u.jsx)(u.Fragment,{children:E.map((e,t)=>{const n=En,a=e.timestampSeconds;const r=a/n*100;return(0,u.jsx)("div",{className:"absolute top-0 bottom-0",style:{left:"".concat(r,"%"),width:"2px",background:"rgb(239, 68, 68)",boxShadow:"0 0 4px rgba(239, 68, 68, 0.6)",zIndex:25},title:"Search match ".concat(t+1)},"search-".concat(t))})}),A&&A.length>0&&En>0&&(0,u.jsx)(u.Fragment,{children:A.map((e,t)=>{const n=En,r=e.startTime/n*100,s=(e.endTime-e.startTime)/n*100,i="high"===e.severity?"rgba(239, 68, 68, 0.85)":"medium"===e.severity?"rgba(245, 158, 11, 0.80)":"rgba(234, 179, 8, 0.75)";return(0,u.jsxs)(a.Fragment,{children:[(0,u.jsx)("div",{className:"absolute pointer-events-none",style:{left:"".concat(r,"%"),width:"".concat(Math.max(s,.3),"%"),bottom:$t.gapB
2arBottom,height:$t.gapBarHeight,backgroundColor:i,zIndex:31,borderRadius:"1px"},title:"Gap cluster: ".concat(e.gapCount," gaps, z=").concat(e.avgZScore," (").concat(e.editorialSignal,")")}),e.gaps&&e.gaps.map((e,a)=>{const r=e.startTime/n*100;return(0,u.jsx)("div",{className:"absolute pointer-events-none",style:{left:"".concat(r,"%"),width:"1px",bottom:$t.gapTickBottom,height:"".concat(Math.min(4+3*e.zScore,20),"px"),backgroundColor:i,zIndex:31}},"gap_".concat(t,"_t").concat(a))})]},"gap_".concat(t))})}),T&&T.length>0&&En>0&&(0,u.jsx)(u.Fragment,{children:T.map((e,t)=>{const n=En,a=e.startTime/n*100,r=e.zScore>=2.5?"rgba(239, 68, 68, 0.7)":e.zScore>=1.5?"rgba(245, 158, 11, 0.65)":"rgba(234, 179, 8, 0.6)";return(0,u.jsx)("div",{className:"absolute pointer-events-none",style:{left:"".concat(a,"%"),width:"1px",bottom:$t.nonClusteredGapBottom,height:"".concat(Math.min(4+3*e.zScore,20),"px"),backgroundColor:r,zIndex:31},title:"Gap: ".concat(e.gapDuration.toFixed(1),"s, z=").concat(e.zScore)},"ncgap_".concat(t))})})]},rr)]}),[Yn,Ft,Ca,Ta,Ma,Ea,P,Tn,Ve,Re,A,ur,Wr,qr,gr,Or,Rr,L,ge,fe,we,he,ne,Xt,M,R,O,T,Wt,mn,ma,E,xa,zr,Pn,Pt,$t,z,rr,En,nt.clips,nt.edits,ba]);return ae?(0,u.jsx)("div",{className:"flex-shrink-0",children:(0,u.jsxs)("button",{onClick:()=>re(!1),className:"w-full px-4 py-2 flex items-center justify-center gap-2 transition-colors ".concat(M?"bg-gray-800 hover:bg-gray-700 text-gray-300":"bg-white hover:bg-gray-50 text-gray-700 border-t"),children:[(0,u.jsx)(Tu,{size:16}),(0,u.jsx)("span",{className:"text-sm",children:"Show Audio Player"})]})}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"flex-shrink-0 relative ".concat(M?"bg-gray-900 border-gray-700":"bg-white border-gray-200"," border-t"),style:{overflow:"visible"},children:(0,u.jsxs)("div",{className:"relative",style:{overflow:"visible"},children:[!ne&&(0,u.jsx)(oE,{visibleWidth:mn,timeToX:zn,mapSourceTimeToDisplay:e=>e,isDarkMode:M}),(0,u.jsxs)("div",{ref:cn,"data-progress-bar":!0,"data-testid":"timeline-viewport",tabIndex:0,className:"relative cursor-pointer overflow-hidden outline-none ".concat(Jt),onClick:e=>{if(bn.current)return void(bn.current=!1);Pa();const t=oa(e.clientX);if(!t||0===Mn)return;const n=On(t.localX);let a=n;const r=Math.abs(t.localX-la)<18;X&&r?Y():(Wn(),ln(a),W(n)),ne&&sa(a)},onMouseMove:e=>{if(xn.current||fn.current||Re||Oe)return;const t=oa(e.clientX);if(!t||0===Mn)return;const n=On(t.localX);let a=n;cn.current&&cn.current.style.setProperty("--timeline-hover-x","".concat(t.localX,"px")),ce||de(!0),ia(a,t.localX)},onMouseLeave:ra,onPointerDown:Ra,onPointerMove:za,onPointerUp:e=>Oa(e.pointerId,e.currentTarget),onPointerCancel:e=>Oa(e.pointerId,e.currentTarget),onWheel:Ia,onTouchStart:Va,onTouchMove:Ha,onTouchEnd:qa,onTouchCancel:qa,style:{touchAction:"none"},children:[(0,u.jsx)("div",{className:"absolute inset-0 ".concat(M?"bg-gray-800":"bg-[#273142]"),style:{backgroundImage:ba?"none":M?"radial-gradient(circle at 12% 14%, rgba(255,181,43,0.10), transparent 24%), radial-gradient(circle at 86% 14%, rgba(111,137,182,0.08), transparent 22%), radial-gradient(circle at 24% 84%, rgba(80,112,166,0.08), transparent 24%), radial-gradient(circle at 92% 82%, rgba(248,113,113,0.05), transparent 18%)":"radial-gradient(circle at 12% 14%, rgba(255,181,43,0.10), transparent 24%), radial-gradient(circle at 86% 14%, rgba(111,137,182,0.08), transparent 22%), radial-gradient(circle at 24% 84%, rgba(80,112,166,0.07), transparent 24%), radial-gradient(circle at 92% 82%, rgba(248,113,113,0.04), transparent 18%)"}}),(0,u.jsxs)("div",{className:"absolute inset-y-0 left-0",style:{width:Pn||"100%",transform:"translateX(".concat(-Ln,"px)"),pointerEvents:"none"},children:[Qt&&En>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"absolute top-0 bottom-0 pointer-events-none z-50",style:{left:"".concat(Qt.start/En*100,"%"),width:Qt.end?"".concat((Qt.end-Qt.start)/En*100,"%"):"3px",background:"rgba(59, 130, 246, 0.5)",borderLeft:"2px solid rgb(59, 130, 246)",borderRight:Qt.end?"2px solid rgb(59, 130, 246)":"none"}}),(0,u.jsx)("div",{className:"absolute -top-2 pointer-events-none z-50 animate-pulse",style:{left:"".concat(Qt.start/En*100,"%"),width:Qt.end?"".concat((Qt.end-Qt.start)/En*100,"%"):"3px",height:"4px",background:"rgb(59, 130, 246)",boxShadow:"0 0 10px rgba(59, 130, 246, 0.8), 0 2px 4px rgba(59, 130, 246, 0.6)"}}),(0,u.jsx)("div",{className:"absolute top-0 bottom-0 pointer-events-none z-49",style:{left:"".concat(Qt.start/En*100,"%"),width:Qt.end?"".concat((Qt.end-Qt.start)/En*100,"%"):"2px",background:"rgba(147, 197, 253, 0.2)",filter:"blur(8px)"}})]}),pa&&_&&!V&&Mn>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"absolute pointer-events-none z-[52]",style:{left:"".concat(pa.start/Mn*100,"%"),width:"".concat(Math.max((pa.end-pa.start)/Mn*100,.15),"%"),top:$t.speakerTop,height:$t.speakerHeight,background:"linear-gradient(180deg, rgba(255,181,43,0.20), rgba(255,181,43,0.12))",boxShadow:"0 0 0 1px rgba(255,181,43,0.24), 0 0 16px rgba(255,181,43,0.18)",borderRadius:"10px"}}),(0,u.jsx)("div",{className:"absolute pointer-events-none z-[53]",style:{left:"".concat(pa.start/Mn*100,"%"),width:"".concat(Math.max((pa.end-pa.start)/Mn*100,.15),"%"),top:Xt?"18px":"34%",height:Xt?"4px":"6px",background:"linear-gradient(90deg, rgba(255,196,77,0.95), rgba(255,181,43,0.82))",boxShadow:"0 0 14px rgba(255,181,43,0.55), 0 0 28px rgba(255,181,43,0.22)",borderRadius:"999px"}}),(0,u.jsx)("div",{className:"absolute pointer-events-none z-[54] rounded-full border px-2 py-1 text-[10px] font-semibold tracking-[0.12em] shadow-lg ".concat(M?"border-white/10 text-amber-100":"border-[rgba(255,205,122,0.55)] text-[#6d4c00]"),style:{left:"".concat(Math.min(pa.end/Mn*100+.35,92),"%"),top:Xt?"4px":"8px",background:M?"linear-gradient(180deg, rgba(35,25,8,0.78), rgba(35,25,8,0.68))":"linear-gradient(180deg, rgba(255,249,232,0.92), rgba(255,239,204,0.84))",backdropFilter:"blur(16px)"},children:(e=>{const t=Math.max(0,e),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=M
2ath.floor(t%60);return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0")):a>0?"".concat(a,":").concat(r.toString().padStart(2,"0")):"".concat(r,"s")})(pa.duration)})]}),Yr,Qa&&(0,u.jsxs)("div",{className:"absolute inset-0 z-20 pointer-events-none",children:[(0,u.jsx)("div",{className:"absolute inset-0",style:{backgroundColor:"rgba(0, 0, 0, 0.5)"}}),(0,u.jsxs)("svg",{className:"absolute inset-0",width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:[Qa.showAvgLine&&Qa.avgLineY>=0&&Qa.avgLineY<=100&&(0,u.jsx)("line",{x1:"0",y1:Qa.avgLineY,x2:"100",y2:Qa.avgLineY,stroke:"rgba(255,255,255,0.8)",strokeWidth:"1.5",strokeDasharray:"6,4",vectorEffect:"non-scaling-stroke"}),(0,u.jsx)("path",{d:Qa.fillPath,style:{fill:"".concat(Qa.graphColor,"66")}}),(0,u.jsx)("polyline",{points:Qa.polylinePoints,fill:"none",stroke:"rgba(255, 255, 255, 0.6)",strokeWidth:"5",vectorEffect:"non-scaling-stroke"}),Qa.useTrafficLightColors?(0,u.jsx)(u.Fragment,{children:Qa.lineSegments.map((e,t)=>(0,u.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.color,strokeWidth:"3",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"},t))}):(0,u.jsx)("polyline",{points:Qa.polylinePoints,fill:"none",stroke:Qa.graphColor,strokeWidth:"3",vectorEffect:"non-scaling-stroke"}),null!==ue&&(()=>{const e=$a(ue);if(!e)return null;const t=Qa.getDisplayX(ue);if(null===t)return null;const n=Qa.retentionToY(Qa.toHoverGraphValue(e.value));return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("circle",{cx:t,cy:n,r:"8",fill:e.color,opacity:"0.3"}),(0,u.jsx)("circle",{cx:t,cy:n,r:"5",fill:"white",stroke:e.color,strokeWidth:"2",vectorEffect:"non-scaling-stroke"}),(0,u.jsx)("circle",{cx:t,cy:n,r:"3",fill:e.color})]})})()]})]}),fa,Za&&(0,u.jsxs)("div",{className:"absolute inset-0 z-20 pointer-events-none",children:[(0,u.jsx)("div",{className:"absolute inset-0",style:{backgroundColor:"rgba(0, 0, 0, 0.5)"}}),(0,u.jsx)("div",{className:"absolute left-0 right-0 top-1/2 h-px bg-white opacity-50"}),(0,u.jsx)("svg",{className:"absolute inset-0",width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:Za.displayDrops.map((e,t)=>{const n=Math.max(.8*e.width,.5),a=e.xStart+e.width/2-n/2,r=Math.min(e.dropped/Za.scaleValue*45,45),s=Math.min(e.gained/Za.scaleValue*45,45);return(0,u.jsxs)("g",{children:[r>0&&(0,u.jsx)("rect",{x:a,y:50,width:n,height:r,fill:"#ef4444",opacity:"0.9"}),s>0&&(0,u.jsx)("rect",{x:a,y:50-s,width:n,height:s,fill:"#22c55e",opacity:"0.9"})]},t)})}),(0,u.jsxs)("div",{className:"absolute bottom-1 left-2 flex items-center gap-3 text-xs text-white",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsx)("div",{className:"w-3 h-3 bg-red-500 rounded-sm"}),(0,u.jsx)("span",{children:"Stopped"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsx)("div",{className:"w-3 h-3 bg-[#FFB52B] rounded-sm"}),(0,u.jsx)("span",{children:"Started"})]})]}),null!==ue&&(()=>{const e=Math.floor(ue/Za.bucketSize);if(e<0||e>=Za.drops.length)return null;const t=Za.drops[e];return(0,u.jsxs)("div",{className:"absolute top-2 left-1/2 transform -translate-x-1/2 bg-gray-900 text-white text-xs px-2 py-1 rounded",children:[t.dropped>0&&(0,u.jsxs)("span",{className:"text-red-400",children:["-",Math.round(t.dropped).toLocaleString()," left"]}),t.dropped>0&&t.gained>0&&(0,u.jsx)("span",{className:"mx-1",children:"|"}),t.gained>0&&(0,u.jsxs)("span",{className:"text-[#ffcf74]",children:["+",Math.round(t.gained).toLocaleString()," joined"]}),0===t.dropped&&0===t.gained&&(0,u.jsx)("span",{className:"text-gray-400",children:"No change"})]})})()]}),(0,u.jsx)(BE,{totalDuration:En,displayDuration:void 0}),!ne&&(0,u.jsx)(lE,{displayDuration:Mn,mapSourceTimeToDisplay:e=>e}),(0,u.jsx)("div",{className:"absolute top-0 bottom-0 w-0.5 bg-orange-500 pointer-events-none z-10",style:{left:En>0?"".concat(Q/En*100,"%"):"0%"}}),(0,u.jsx)(TE,{totalDuration:En,displayDuration:void 0}),(ce||null!==ue)&&(0,u.jsx)("div",{className:"absolute top-0 w-1 h-full bg-white pointer-events-none opacity-70",style:{left:"var(--timeline-hover-x, 0px)"}})]})]}),null!==ue&&((e,t,n,a)=>{const r=ue,s=$a(ue),i=(e=>{var t;if(!Ka.length||0===En)return null;const n=(null===j||void 0===j||null===(t=j.videoStats)||void 0===t?void 0:t.views)||1e5,a=30*Math.floor(e/30),r=Math.min(a+30,(null===j||void 0===j?void 0:j.videoDurationSeconds)||En),s=e=>{const t=wE(Ka,e);return t<0?0:Ka[t].absolute},i=s(a),o=n*s(r)-n*i;return{dropped:o<0?Math.abs(o):0,gained:o>0?o:0}})(ue),o=s&&(null===j||void 0===j||null===(t=j.retentionData)||void 0===t?void 0:t.length),l=i&&(i.dropped>0||i.gained>0),c=ne,d=c?M?"border-white/10 bg-[rgba(17,27,42,0.52)] text-white shadow-[0_24px_52px_-30px_rgba(0,0,0,0.58)] backdrop-blur-[32px]":"border-[rgba(214,220,228,0.88)] bg-[rgba(255,255,255,0.52)] text-[#232E3F] shadow-[0_20px_48px_-28px_rgba(15,23,42,0.16)] backdrop-blur-[28px]":M?"border-white/10 bg-[rgba(17,27,42,0.5)] text-white shadow-[0_24px_52px_-30px_rgba(0,0,0,0.58)] backdrop-blur-[32px]":"border-[rgba(214,220,228,0.88)] bg-[rgba(255,255,255,0.5)] text-[#232E3F] shadow-[0_20px_48px_-28px_rgba(15,23,42,0.16)] backdrop-blur-[28px]",m=M?"text-white":"text-[#232E3F]",h=M?"text-gray-300":"text-[#4a586e]",p=M?"text-gray-400":"text-[#6b7280]",g=M?"text-[#d9e2f1]":"text-[#36506b]",x=M?"bg-[#314159]/50 text-[#d9e2f1]":"bg-[#e7eef7] text-[#36506b]",f=(null===(n=cn.current)||void 0===n?void 0:n.getBoundingClientRect())||null,b=(null===(a=cn.current)||void 0===a?void 0:a.clientWidth)||(null===f||void 0===f?void 0:f.width)||0,y=f&&b>0?f.width/b:1,v="undefined"!==typeof window?window.innerWidth:0,w=v>0?Math.max(220,Math.min(320,v-32)):320,k=f?f.left+(null!==da&&void 0!==da?da:0)*y:null!==da&&void 0!==da?da:0,D=v>0?Math.min(Math.max(k-w/2,16),v-w-16):k-w/2,C=f?(D-f.left)/y:Math.max(0,null!==da&&void 0!==da?da:0),N=e=>{switch(e){case"success":return M?"bg-emerald-950/35 text-emerald-300":"bg-[#EAF7EF] text-[#2D7250]";case"gold":return M?"border border-brand-yellow/25 bg-brand-yellow/15 text-brand-yellow":"border border-[#F2D9A6] bg-[#FFF4D9] text-[#8A6100]";case"danger":return M?"bg-red-950/40 text-red-300":"bg-[#FDE8E8] text-[#B54747]";default:return x}},F=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return gE(String(e||"").replace(/<br\s*\/?>/gi,"\n").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),t)},S=e=>{const t=F(e,!0).match(/Justification:\s*([^\n]+)/);if(!t)return null;let n=F(t[1]);return n=n.replace(/Optimal Placement:.*$/i,"").trim(),n||null};return(0,u.jsxs)("div",{className:c?"absolute left-0 right-0 rounded-[22px] border px-4 py-3 text-sm shadow-2xl ".concat(d):"absolute rounded-lg border px-4 py-3 text-sm pointer-events-none ".concat(d),style:c?{bottom:"calc(100% + 8px)",zIndex:1e3}:{bottom:"calc(100% + 8px)",left:"".concat(C,"px"),width:"".concat(w,"px"),maxWidth:"calc(100vw - ".concat(32,"px)"),transform:"translateX(0)",zIndex:1e3},children:[c?(0,u.jsxs)("div",{className:"mb-3 flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.2em] ".concat(M?"text-[#ffcf74]":"text-[#8a6115]"),children:"Timeline Details"}),(0,u.jsx)("div",{className:"mt-1 font-medium ".concat(M?"text-gray-200":"text-[#232E3F]"),children:er(r)})]}),(0,u.jsx)("button",{type:"button",onClick:ra,className:"shrink-0 rounded-full border p-1.5 transition-colors ".concat(M?"border-white/10 bg-white/[0.04] text-gray-300 hover:bg-white/[0.1]":"border-[#d6dce4] bg-[#f5f7fa] text-[#5b687c] hover:bg-[#e9edf2]"),"aria-label":"Close timeline details",children:(0,u.jsx)(Pu,{size:14})})]}):(0,u.jsx)("div",{className:"mb-1 whitespace-nowrap font-medium ".concat(h),children:er(r)}),ua&&(0,u.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,u.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(p),children:"Speaker"}),(0,u.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full border px-2 py-1 text-[11px] ".concat(x),children:[(0,u.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:ua.color}}),(0,u.jsx)("span",{className:m,children:ua.label})]})]}),"questions"===Wt&&we?(0,u.jsxs)("div",{className:"border-l-2 border-[#a
278bfa] pl-2 mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,u.jsxs)("span",{className:"font-semibold text-[#a78bfa]",children:["Q",we.questionNumber]}),(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat("implicit"===we.question.questionType?N("gold"):N("neutral")),children:"implicit"===we.question.questionType?"Implicit":"Explicit"}),we.question.askedBy&&(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat(N("neutral")),children:we.question.askedBy})]}),(0,u.jsx)("div",{className:"mt-0.5 break-words text-[11px] font-medium ".concat(M?"text-white":"text-[#232E3F]"," ").concat(c?"max-w-none":"max-w-xs"),children:we.question.questionText.length>140?we.question.questionText.substring(0,140)+"...":we.question.questionText}),we.question.answerSummary&&(0,u.jsx)("div",{className:"mt-0.5 break-words text-[11px] ".concat(M?"text-gray-300":"text-[#4a586e]"," ").concat(c?"max-w-none":"max-w-xs"),children:we.question.answerSummary.length>120?we.question.answerSummary.substring(0,120)+"...":we.question.answerSummary}),we.question.topic&&(0,u.jsxs)("div",{className:"mt-0.5 text-[10px] ".concat(M?"text-gray-400":"text-gray-500"),children:["Topic: ",we.question.topic]})]}):he&&(0,u.jsxs)("div",{className:"border-l-2 border-[#ffcf74] pl-2 mb-2",children:[((e,t)=>{const n=nr(he);return(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsxs)("span",{className:"font-semibold text-[#ffcf74]",children:["Topic ",nt.topics.indexOf(he)+1]}),he.title&&(0,u.jsxs)("span",{className:m,children:[": ",gE(he.title)]}),(0,u.jsxs)("span",{className:"text-xs opacity-60 ml-1",children:["(",ar(),": ",null!==(e=n.score)&&void 0!==e?e:"?","/",null!==(t=n.maxScore)&&void 0!==t?t:"?",")"]})]})})(),S(he.content)&&(0,u.jsx)("div",{className:"mt-0.5 break-words text-[11px] ".concat(M?"text-gray-300":"text-[#4a586e]"," ").concat(c?"max-w-none":"max-w-xs"),children:S(he.content)})]}),ge&&(()=>{const e=(e=>{let t=F(e.replace(/\[CLIP\]\s*/gi,""),!0);if(t.includes("|")){const e=t.split("|").map(e=>e.trim());return{title:F(e[0]||"")||void 0,type:F(e[1]||"")||void 0,description:F(e[2]||"")||void 0}}const n=t.split("\n").map(e=>e.trim()).filter(e=>e.length>0);let a,r,s;for(const i of n){if(i.toLowerCase().startsWith("visual:"))continue;const e=i.toLowerCase();if(e.includes("viral hook")||e.includes("viral:")){r="Viral Hook";const e=i.indexOf(":");if(e>-1){const t=i.substring(e+1).trim();t&&!s&&(s=t)}}else if(e.includes("educational nugget")||e.includes("educational:")){r="Educational Nugget";const e=i.indexOf(":");if(e>-1){const t=i.substring(e+1).trim();t&&!s&&(s=t)}}else if(e.includes("humorous aside")||e.includes("humorous:")||e.includes("humor:")){r="Humorous Aside";const e=i.indexOf(":");if(e>-1){const t=i.substring(e+1).trim();t&&!s&&(s=t)}}else a?s||(s=i):a=i}return{title:a,type:r,description:s}})(ge.content);return(0,u.jsxs)("div",{className:"border-l-2 border-[#d9e2f1] pl-2 mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,u.jsx)("span",{className:"font-semibold ".concat(g),children:"Clip"}),e.type&&(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat(e.type.toLowerCase().includes("viral")?N("danger"):e.type.toLowerCase().includes("educational")?N("success"):N("gold")),children:e.type})]}),e.title&&(0,u.jsx)("div",{className:"mt-0.5 text-[11px] font-medium ".concat(M?"text-white":"text-[#232E3F]"),children:e.title}),e.description&&(0,u.jsx)("div",{className:"mt-0.5 break-words text-[11px] ".concat(M?"text-gray-300":"text-[#4a586e]"," ").concat(c?"max-w-none":"max-w-xs"),children:e.description.length>120?e.description.substring(0,120)+"...":e.description})]})})(),fe&&(()=>{const e=(e=>{let t=F(e.replace(/\[EDIT\]\s*/gi,""),!0);if(t.includes("|")){const e=t.split("|").map(e=>e.trim());return{title:F(e[0]||"")||void 0,priority:F(e[1]||"")||void 0,suggestion:F(e[2]||"")||void 0,improvement:F(e[3]||"")||void 0}}t=t.replace(/(?=Suggestion:|Improvement:|Priority:|Note:)/g,"\n");const n=t.split("\n").map(e=>e.trim()).filter(e=>e.length>0);let a,r,s,i;for(const o of n)if(o.startsWith("Suggestion:")){const e=o.replace("Suggestion:","").trim();r?s||(s=e):r=e}else o.startsWith("Improvement:")?s=o.replace("Improvement:","").trim():o.startsWith("Priority:")?i=o.replace("Priority:","").trim():a||r||(a=o);return{title:a,suggestion:r,improvement:s,priority:i}})(fe.content);return(0,u.jsxs)("div",{className:"border-l-2 border-red-400 pl-2 mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,u.jsx)("span",{className:"font-semibold text-red-400",children:"Edit"}),e.priority&&(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat(e.priority.toLowerCase().includes("high")?N("danger"):e.priority.toLowerCase().includes("medium")?N("gold"):N("neutral")),children:e.priority})]}),e.suggestion&&(0,u.jsxs)("div",{className:"mt-0.5 break-words text-[11px] ".concat(M?"text-gray-300":"text-[#4a586e]"," ").concat(c?"max-w-none":"max-w-xs"),children:[(0,u.jsx)("span",{className:p,children:"Suggestion:"})," ",e.suggestion.length>100?e.suggestion.substring(0,100)+"...":e.suggestion]}),e.improvement&&(0,u.jsxs)("div",{className:"mt-0.5 break-words text-[10px] italic ".concat(p," ").concat(c?"max-w-none":"max-w-xs"),children:[(0,u.jsx)("span",{className:"text-[#ffcf74]",children:"Improvement:"})," ",e.improvement.length>80?e.improvement.substring(0,80)+"...":e.improvement]}
2)]})})(),ye&&(0,u.jsxs)("div",{className:"border-l-2 border-[#c9a85a] pl-2 mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1 flex-wrap",children:[(0,u.jsx)("span",{className:"font-semibold text-[#c9a85a]",children:"Reference"}),ye.url&&(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat(x),children:"Has Link"}),ye.attachedVisualCount&&(0,u.jsxs)("span",{className:"text-[10px] px-1.5 py-0.5 rounded ".concat(M?"bg-[#4b3913]/55 text-[#ffe09b]":"bg-[#fff1cc] text-[#6e4d0e]"),children:[ye.attachedVisualCount," asset",1===ye.attachedVisualCount?"":"s"]})]}),ye.title&&(0,u.jsx)("div",{className:"mt-0.5 text-[11px] font-medium ".concat(M?"text-white":"text-[#232E3F]"),children:gE(ye.title)}),ye.category&&(0,u.jsx)("div",{className:"mt-0.5 text-[10px] ".concat(h),children:gE(ye.category)}),ye.context&&(0,u.jsx)("div",{className:"mt-0.5 break-words text-[10px] ".concat(p," ").concat(c?"max-w-none":"max-w-xs"),children:(()=>{const e=gE(ye.context,!0);return e.length>80?"".concat(e.substring(0,80),"..."):e})()}),(!V&&ye.visualSuggestion||ye.attachedVisualPreviewUrl)&&(0,u.jsxs)("div",{className:"mt-1 rounded-md border px-2 py-1.5 text-[10px] ".concat(M?"border-[#ffcf74]/30 bg-[#ffcf74]/10 text-[#ffe7ad]":"border-[#d8b25b] bg-[#ffe9af] text-[#5f4308]"),children:[(()=>{const e=(ye.attachedVisualPlacements||[]).map(e=>({id:e.id,previewUrl:Dm(e)||""})).filter(e=>e.previewUrl).slice(0,3);return e.length>0?(0,u.jsx)("div",{className:"mb-1 flex gap-1",children:e.map(e=>(0,u.jsx)("img",{src:e.previewUrl,alt:ye.title||"Attached visual",className:"h-16 min-w-0 flex-1 rounded object-cover",loading:"lazy"},e.id))}):ye.attachedVisualPreviewUrl?(0,u.jsx)("img",{src:ye.attachedVisualPreviewUrl,alt:ye.title||"Attached visual",className:"mb-1 h-20 w-full rounded object-cover",loading:"lazy"}):null})(),(0,u.jsxs)("div",{className:"mb-0.5 flex items-center gap-1 font-semibold uppercase tracking-[0.12em]",children:[(0,u.jsx)(Cp,{size:10}),ye.attachedVisualCount?"Attached assets":"Visual"]}),!V&&ye.visualSuggestion?gE(ye.visualSuggestion,!0):ye.attachedVisualLabel||"Attached session visual"]})]}),o&&(0,u.jsxs)("div",{className:"mt-1 flex items-center gap-1.5 ".concat(c?"flex-wrap":"whitespace-nowrap"),children:[(0,u.jsx)("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:s.color}}),(0,u.jsx)("span",{children:"Retention:"}),(0,u.jsx)("span",{className:"font-semibold",style:{color:s.color},children:s.label}),(0,u.jsxs)("span",{className:"opacity-70",children:["(",s.displayValue,")"]})]}),l&&(0,u.jsxs)("div",{className:"mt-1 flex items-center gap-1.5 ".concat(c?"flex-wrap":"whitespace-nowrap"),children:[i.dropped>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"inline-block w-2 h-2 rounded-full bg-red-500"}),(0,u.jsxs)("span",{className:"text-red-400",children:["-",Math.round(i.dropped).toLocaleString()," left"]})]}),i.dropped>0&&i.gained>0&&(0,u.jsx)("span",{className:"mx-1 opacity-50",children:"|"}),i.gained>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"inline-block w-2 h-2 rounded-full bg-[#FFB52B]"}),(0,u.jsxs)("span",{className:"text-[#ffcf74]",children:["+",Math.round(i.gained).toLocaleString()," joined"]})]})]})]})})(),jt&&kt&&c&&En>0&&mn>0&&(0,u.jsx)("div",{ref:dn,"data-testid":"timeline-secondary-viewport",className:"relative z-40",onPointerDown:Ra,onPointerMove:za,onPointerUp:e=>Oa(e.pointerId,e.currentTarget),onPointerCancel:e=>Oa(e.pointerId,e.currentTarget),onWheel:Ia,onTouchStart:Va,onTouchMove:Ha,onTouchEnd:qa,onTouchCancel:qa,style:{overflow:"visible",touchAction:"none"},children:(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(ME,{comments:Ct,duration:En,onAddComment:pr,onSelectComment:gr,selectedCommentId:Mt,isDarkMode:M,width:mn,height:Pt,viewportStart:_n,viewportEnd:Bn,timeToX:zn,onHeightChange:Lt}),(nt.references.length>0||Yn)&&(0,u.jsx)(wF,{references:Xn.filter(e=>!0).map(e=>e),duration:En,width:mn,isDarkMode:M,showEditorialVisualSuggestion:!V,viewportStart:_n,viewportEnd:Bn,timeToX:zn,xToTime:On,onSelectReference:e=>{De(e),Ne(!0)},selectedReferenceId:null===je||void 0===je?void 0:je.id,onAddReference:br,canEdit:Yn,onDragStart:Nr,onDragMove:Fr,onDragEnd:Sr})]})}),mn>0&&(0,u.jsx)(dS,{isDarkMode:M,width:mn,timeToX:zn,xToTime:On,viewportStart:_n,viewportEnd:Bn,onSeek:G}),(0,u.jsx)("div",{className:"px-4 py-2 relative",children:(0,u.jsxs)("div",{className:"relative flex flex-wrap items-center justify-between gap-y-2 gap-2 rounded-2xl border px-3 py-2.5 md:flex-nowrap md:gap-4 ".concat(M?"border-white/10 bg-[radial-gradient(circle_at_12%_18%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_14%,rgba(111,137,
2182,0.07),transparent_22%),radial-gradient(circle_at_26%_82%,rgba(80,112,166,0.06),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.34),rgba(17,27,42,0.32))] shadow-[0_24px_52px_-32px_rgba(0,0,0,0.62)] backdrop-blur-[28px]":"border-[rgba(215,222,233,0.82)] bg-[radial-gradient(circle_at_12%_18%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_14%,rgba(111,137,182,0.06),transparent_22%),radial-gradient(circle_at_26%_82%,rgba(80,112,166,0.05),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.36),rgba(255,255,255,0.34))] shadow-[0_22px_48px_-34px_rgba(15,23,42,0.18)] backdrop-blur-[24px]"),children:[(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 md:gap-3 min-w-0",children:[(0,u.jsx)("button",{onClick:()=>X?Y():q(),className:"p-2 rounded-full transition-all flex-shrink-0 ".concat(M?"bg-brand-yellow text-brand-navy hover:bg-[#f6c15e]":"bg-brand-yellow text-brand-navy hover:bg-[#f0a91a]"),title:X?"Pause (Space)":"Play (Space)",children:X?(0,u.jsx)(wh,{size:16}):(0,u.jsx)(kh,{size:16,className:"ml-0.5"})}),(0,u.jsx)(_E,{totalDuration:En,isDarkMode:M,displayDuration:void 0,timeMapper:void 0,showKeyboardHints:!ne})]}),(0,u.jsx)("div",{className:"flex flex-1 justify-center",children:(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsxs)("button",{ref:ft,type:"button",onClick:()=>ut(e=>!e),className:"inline-flex items-center gap-2 rounded-xl border px-3 py-2 text-xs transition-colors ".concat(M?"border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-200 hover:bg-[rgba(255,255,255,0.08)]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),title:"Timeline controls",children:[(0,u.jsx)(MN,{size:14}),(0,u.jsx)("span",{className:"hidden sm:inline",children:"Timeline"})]}),(0,u.jsx)(CD,{isOpen:dt,onClose:()=>ut(!1),anchorRef:ft,align:"center",offset:12,className:"w-[min(24rem,calc(100vw-1rem))] rounded-2xl border p-4 shadow-2xl ".concat(M?"border-white/10 bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.07),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.44),rgba(17,27,42,0.42))] text-gray-100 backdrop-blur-[32px]":"border-[rgba(215,222,233,0.84)] bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.06),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.44),rgba(255,255,255,0.4))] text-gray-900 backdrop-blur-[28px]"),children:(0,u.jsxs)("div",{className:"space-y-4",children:[!ne&&Object.keys(g||{}).length>0&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] ".concat(M?"text-gray-400":"text-gray-500"),children:"Speakers"}),(0,u.jsx)("div",{className:"max-h-32 space-y-2 overflow-y-auto pr-1",children:Object.entries(g||{}).map(e=>{let[t,n]=e;const a=Ba[parseInt(t,10)]||0;return(0,u.jsxs)("div",{className:"flex items-center justify-between rounded-xl border px-3 py-2 text-xs ".concat(M?"border-white/10 bg-[rgba(255,255,255,0.04)]":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)]"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,u.jsx)("div",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:{backgroundColor:mp(parseInt(t,10),M)}}),(0,u.jsx)("span",{className:"truncate",children:n})]}),(0,u.jsxs)("span",{className:M?"text-gray-400":"text-gray-500",children:[a,"%"]})]},t)})})]}),it&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] ".concat(M?"text-gray-400":"text-gray-500"),children:"Timeline Layers"}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-2",children:[nt.clips.length>0&&(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-full border px-3 py-1 text-xs ".concat(M?"border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-300":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700"),children:[(0,u.jsx)("div",{className:"w-3 h-3 rounded-sm",style:{background:"repeating-linear-gradient(0deg, rgb(59, 130, 246) 0px, rgb(59, 130, 246) 1px, transparent 1px, transparent 2px)"}}),(0,u.jsx)("span",{children:"Clips"})]}),nt.edits.length>0&&(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-full border px-3 py-1 text-xs ".concat(M?"border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-300":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700"),children:[(0,u.jsx)("div",{className:"w-3 h-3 rounded-sm",style:{background:"repeating-linear-gradient(0deg, rgb(239, 68, 68) 0px, rgb(239, 68, 68) 1px, transparent 1px, transparent 2px)"}}),(0,u.jsx)("span",{children:"Edits"})]}),nt.references.length>0&&(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-full border px-3 py-1 text-xs ".concat(M?"border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-300":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700"),children:[(0,u.jsx)("div",{className:"w-2.5 h-2.5 rotate-45",style:{backgroundColor:"#FFB52B"}}),(0,u.jsx)("span",{children:"Refs"})]})]})]}),(nt.topics.length>0||rt.length>0)&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] ".concat(M?"text-gray-400":"text-gray-500"),children:"Overlay Mode"}),(0,u.jsxs)("div",{className:"flex gap-2",children:[nt.topics.length>0&&(0,u.jsxs)("button",{type:"button",onClick:()=>Yt("topics"),className:"rounded-xl px-3 py-2 text-xs font-medium transition-colors ".concat(rt.length>0?"flex-1":"w-full"," ").concat("topics"===Wt?"bg-[#FFB52B] text-[#232E3F]":M?"border border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-200 hover:bg-[rgba(255,255,255,0.08)]":"border border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),children:["Topics (",nt.topics.length,")"]}),rt.length>0&&(0,u.jsxs)("button",{type:"button",onClick:()=>Yt("questions"),className:"rounded-xl px-3 py-2 text-xs font-medium transition-colors ".concat(nt.topics.length>0?"flex-1":"w-full"," ").concat("questions"===Wt?"bg-[#a78bfa] text-white":M?"border border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-200 hover:bg-[rgba(255,255,255,0.08)]":"border border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),children:["Questions (",rt.length,")"]})]})]}),Yn&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] ".concat(M?"text-gray-400":"text-gray-500"),children:"Session Visuals"}),Yn&&(0,u.jsxs)("button",{type:"button",onClick:()=>Gn(),className:"flex w-full items-center justify-between rounded-xl px-3 py-2 text-xs transition-colors ".concat(M?"border border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-200 hover:bg-[rgba(255,255,255,0.08)]":"border border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),children:[(0,u.jsx)("span",{children:"Manage package"}),(0,u.jsx)("span",{children:((null===h||void 0===h?void 0:h.assets.length)||0)+or+lr})]})]}),(nt.topics.length>0||(null===j||void 0===j||null===(r=j.retentionData)||void 0===r?void 0:r.length))&&(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[nt.topics.length>0&&"topics"===Wt&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{Ut(!zt)},className:"rounded-xl px-3 py-2 text-xs transition-colors ".concat(M?"border border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-200 hover:bg-[rgba(255,255,255,0.08)]":"border border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),title:zt?"Switch to traffic light colors":"Switch to gradient colors",children:["Palette: ",zt?"Gradient":"Traffic"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{const e=["overall","substance","resonance","clarity","production","creative_risk"],t=(e.indexOf(Rt)+1)%e.length;Ot(e[t])},className:"rounded-xl px-3 py-2 text-xs transition-colors ".concat(M?"border border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-200 hover:bg-[rgba(255,255,255,0.08)]":"border border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),children:["Rank: ",ar()]})]}),null!==j&&void 0!==j&&null!==(s=j.retentionData)&&void 0!==s&&s.length?(0,u.jsxs)("button",{type:"button",onClick:()=>{const e=["off","relative","absolute","adjusted","drops"],t=(e.indexOf(Vt)+1)%e.length;Ht(e[t])},className:"col-span-2 rounded-xl px-3 py-2 text-xs text-white transition-opacity hover:opacity-90 ".concat(Gt().color),title:Gt().title,children:["Retention: ",Gt().label]}):null]})]})})]})}),(0,u.jsxs)("div",{className:"flex items-center gap-2 md:gap-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[!ne&&(0,u.jsx)("button",{type:"button","aria-label":"Zoom out","data-testid":"timeline-zoom-out",onClick:Ya,className:"p-2 rounded-lg transition-colors ".concat(M?"hover:bg-white/[0.08] text-gray-300":"hover:bg-[rgba(255,255,255,0.36)] text-gray-600"),title:"Zoom out",children:(0,u.jsx)(_N,{size:16})}),!ne&&(0,u.jsx)("button",{type:"button","aria-label":"Zoom in","data-testid":"timeline-zoom-in",onClick:Wa,className:"p-2 rounded-lg transition-colors ".concat(M?"hover:bg-white/[0.08] text-gray-300":"hover:bg-[rgba(255,255,255,0.36)] text-gray-600"),title:"Zoom in",children:(0,u.jsx)(BN,{size:16})}),(0,u.jsx)("button",{type:"button","aria-label":"Reset zoom","data-testid":"timeline-reset-zoom",onClick:Ga,className:"p-2 rounded-lg transition-colors ".concat(Rn?M?"bg-brand-yellow text-brand-navy hover:bg-[#f6c15e]":"bg-[#ffe2a6] text-brand-navy hover:bg-[#ffd47c]":M?"hover:bg-white/[0.08] text-gray-400":"hover:bg-[rgba(255,255,255,0.36)] text-gray-500"),title:"Reset zoom",children:(0,u.jsx)(IN,{size:16})}),!an&&(0,u.jsx)("button",{type:"button","aria-label":"Resync transcript and timeline",onClick:()=>ln(),className:"p-2 rounded-lg transition-colors ".concat(M?"bg-brand-yellow text-brand-navy hover:bg-[#f6c15e]":"bg-[#ffe2a6] text-brand-navy hover:bg-[#ffd47c]"),title:"Resync transcript and timeline to the playhead",children:(0,u.jsx)(PN,{size:16})})]}),kt&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:()=>Dt(!jt),className:"p-2 rounded-lg transition-colors ".concat(jt?M?"bg-brand-yellow text-brand-navy":"bg-[#ffe2a6] text-brand-navy":M?"hover:bg-white/[0.08] text-gray-400":"hover:bg-[rgba(255,255,255,0.36)] text-gray-600"),title:jt?"Hide timeline comments":"Show timeline comments",children:jt?(0,u.jsx)(Cp,{size:16}):(0,u.jsx)(Fy,{size:16})}),(0,u.jsxs)("button",{onClick:()=>{St?(Et(!1),Tt(null),_t(null)):(Tt(null),_t(null),Et(!0))},className:"relative p-2 rounded-lg transition-colors ".concat(St?M?"bg-brand-yellow text-brand-navy":"bg-[#ffe2a6] text-brand-navy":M?"hover:bg-white/[0.08] text-gray-400":"hover:bg-[rgba(255,255,255,0.36)] text-gray-600"),title:"Toggle comments panel",children:[(0,u.jsx)(ky,{size:16}),Ct.length>0&&(0,u.jsx)("span",{className:"absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full w-5 h-5 flex items-center justify-center",children:Ct.length>99?"99+":Ct.length})]})]}),(0,u.jsxs)("div",{className:"relative",ref:xt,children:[(0,u.jsxs)("button",{onClick:()=>ct(!lt),className:"flex items-center gap-1 rounded-xl border px-2.5 py-1.5 transition-colors text-sm font-medium ".concat(M?"border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-300 hover:bg-[rgba(255,255,255,0.08)]":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),children:[(0,u.jsx)(MN,{size:16}),(0,u.jsxs)("span",{children:[Z,"x"]})]}),lt&&(0,u.jsx)("div",{className:"absolute bottom-full right-0 mb-2 rounded-2xl border shadow-lg z-50 ".concat(M?"border-white/10 bg-[radial-gradient(circle_at_16%_16%,rgba(255,181,43,0.08),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.42),rgba(17,27,42,0.4))] backdrop-blur-[28px]":"border-[rgba(215,222,233,0.82)] bg-[radial-gradient(circle_at_16%_16%,rgba(255,181,43,0.08),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.42),rgba(255,255,255,0.4))] backdrop-blur-[24px]"),children:[1,1.5,2,2.5].map(e=>(0,u.jsxs)("button",{onClick:()=>{ee(e),ct(!1)},className:"block w-full px-4 py-2 text-sm text-left transition-colors ".concat(Z===e?"bg-brand-yellow text-brand-navy":M?"hover:bg-white/[0.08] text-gray-300":"hover:bg-[rgba(255,255,255,0.36)] text-gray-700"),children:[e,"x"]},e))})]}),!ne&&(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(jh,{size:14,className:M?"text-gray-400":"text-gray-600"}),(0,u.jsx)("input",{type:"range",min:"0",max:"1",step:"0.1",value:J,onChange:e=>{return t=parseFloat(e.target.value),void $(t);var t},className:"w-16"})]}),(0,u.jsx)("button",{onClick:()=>re(!0),className:"p-1.5 rounded transition-colors ".concat(M?"hover:bg-white/[0.08] text-gray-400":"hover:bg-[rgba(255,255,255,0.36)] text-gray-600"),title:"Minimize player",children:(0,u.jsx)(wd,{size:16})})]})]})})]})}),c&&St&&kt&&(0,u.jsx)(KS,{sessionId:c,token:V?null!==U&&void 0!==U?U:null:_,isPublicView:V,onCommentsChange:xr,isInline:!1,pendingTimestamp:At,selectedCommentId:Mt,onClose:fr,initialComments:C,disablePolling:N&&V}),(0,u.jsx)(kS,{isOpen:Ce,onClose:()=>Ne(!1),reference:Jn,allReferences:Xn,onSelectReference:e=>{const t=Xn.find(t=>
2t.id===e.id)||e;De(t)},onSave:jr,onDelete:Dr,onSeek:G,onManageVisuals:!V&&Yn?e=>{Ne(!1),Gn(e)}:void 0,isDarkMode:M,canEdit:Yn,canManageVisuals:!V&&Yn,showEditorialVisualSuggestion:!V}),c&&_&&!V&&(0,u.jsx)(YS,{isOpen:Ee,onClose:()=>{Ae(!1),Me(null)},sessionId:c,sessionTitle:m,token:_,selectedTtmlChecksum:v||vt||y||null,isDarkMode:M,initialDisplayStartSeconds:null!==(i=null===Te||void 0===Te?void 0:Te.start)&&void 0!==i?i:Q,initialDisplayEndSeconds:null!==(o=null===Te||void 0===Te?void 0:Te.end)&&void 0!==o?o:Q+7,initialReferenceIndex:"reference"===(null===Te||void 0===Te?void 0:Te.type)&&null!==(l=Te.index)&&void 0!==l?l:null,initialReferenceTitle:"reference"===(null===Te||void 0===Te?void 0:Te.type)&&(Te.title||Te.content)||null,onSeekTo:G,onChanged:S}),(0,u.jsx)(hS,{isOpen:Fe,onClose:()=>Se(!1),onSave:kr,timestamp:et,isDarkMode:M}),$e&&(0,u.jsxs)("div",{className:"fixed z-[9999] transform -translate-x-1/2 -translate-y-full pointer-events-auto ".concat(M?"text-white":"text-gray-900"),style:{left:$e.x,top:$e.y-8},onMouseEnter:()=>{Ze.current&&(clearTimeout(Ze.current),Ze.current=null)},onMouseLeave:()=>{Qe(null)},children:[(0,u.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 rounded-lg shadow-lg border ".concat(M?"bg-gray-800 border-gray-600":"bg-white border-gray-300"),children:[(0,u.jsxs)("button",{className:"px-3 py-1 text-sm font-medium rounded transition-colors ".concat("clip"===$e.type?M?"bg-brand-yellow hover:bg-[#f6c15e] text-brand-navy":"bg-brand-yellow hover:bg-[#f0a91a] text-brand-navy":M?"bg-red-600 hover:bg-red-500 text-white":"bg-red-500 hover:bg-red-600 text-white"),onClick:()=>{Be({element:$e.element,type:$e.type}),Pe(!0),Qe(null)},children:["Edit ","clip"===$e.type?"Clip":"Edit"]}),(0,u.jsx)("button",{className:"px-3 py-1 text-sm font-medium rounded transition-colors ".concat(M?"bg-gray-700 hover:bg-gray-600 text-gray-200":"bg-gray-200 hover:bg-gray-300 text-gray-700"),onClick:()=>{Hr($e.element.start),Qe(null)},children:"Go to"}),(0,u.jsx)("button",{className:"p-1 rounded transition-colors ".concat(M?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-500"),onClick:()=>Qe(null),children:(0,u.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,u.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),(0,u.jsx)("div",{className:"absolute left-1/2 transform -translate-x-1/2 top-full w-0 h-0 border-l-8 border-r-8 border-t-8 border-l-transparent border-r-transparent ".concat(M?"border-t-gray-800":"border-t-white")})]}),(0,u.jsx)(NS,{isOpen:Ie,onClose:()=>{Pe(!1),Be(null)},element:(null===_e||void 0===_e?void 0:_e.element)||null,elementType:(null===_e||void 0===_e?void 0:_e.type)||"clip",onSave:_r,onDelete:Br,onSeek:Hr,allowDelete:Vr,isDarkMode:M,canEdit:Yn}),Re&&Ve&&qe&&(0,u.jsx)(xF,{time:"right"===Re.handle?Ve.end:Ve.start,x:qe.x,y:qe.y,isDarkMode:M,label:"move"===Re.handle?"".concat(er(Ve.start)," - ").concat(er(Ve.end)):void 0})]})},PE=(0,a.memo)(IE,(e,t)=>e.sessionId===t.sessionId&&e.sessionTitle===t.sessionTitle&&e.speakerSegments===t.speakerSegments&&e.speakerLabels===t.speakerLabels&&e.transcriptionData===t.transcriptionData&&e.ttmlFiles===t.ttmlFiles&&e.sessionVisuals===t.sessionVisuals&&e.duration===t.duration&&e.selectedTtmlId===t.selectedTtmlId&&e.retentionData===t.retentionData&&e.searchMatches===t.searchMatches&&e.gapClusters===t.gapClusters&&e.nonClusteredGaps===t.nonClusteredGaps&&e.onSessionVisualsChanged===t.onSessionVisualsChanged),LE=Mo("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),RE=Mo("moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]),zE=Mo("message-circle-question",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),OE=Mo("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}
2]]),UE=Mo("panels-top-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]),VE=Mo("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),HE=Mo("cloud-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193",key:"yfwify"}],["path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07",key:"jlfiyv"}]]),qE=Mo("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]),WE=Mo("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]),YE=Mo("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]),GE=Mo("flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]),KE=Mo("trending-up",[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]]),XE=Mo("snowflake",[["path",{d:"m10 20-1.25-2.5L6 18",key:"18frcb"}],["path",{d:"M10 4 8.75 6.5 6 6",key:"7mghy3"}],["path",{d:"m14 20 1.25-2.5L18 18",key:"1chtki"}],["path",{d:"m14 4 1.25 2.5L18 6",key:"1b4wsy"}],["path",{d:"m17 21-3-6h-4",key:"15hhxa"}],["path",{d:"m17 3-3 6 1.5 3",key:"11697g"}],["path",{d:"M2 12h6.5L10 9",key:"kv9z4n"}],["path",{d:"m20 10-1.5 2 1.5 2",key:"1swlpi"}],["path",{d:"M22 12h-6.5L14 15",key:"1mxi28"}],["path",{d:"m4 10 1.5 2L4 14",key:"k9enpj"}],["path",{d:"m7 21 3-6-1.5-3",key:"j8hb9u"}],["path",{d:"m7 3 3 6h4",key:"1otusx"}]]),JE=Mo("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),$E=Mo("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),QE=["className","children"],ZE="/api";function eA(e){var t;if(!e)return"frozen";if(e.access_count_7d>=50)return"hot";if(e.access_count_7d>=10)return"active";if(e.access_count_7d>=1)return"used";return((null===(t=e.daily_counts)||void 0===t?void 0:t.reduce((e,t)=>e+t.count,0))||0)>0?"dormant":"frozen"}function tA(e){let{tier:t,isDarkMode:n,size:a=13}=e;switch(t){case"hot":return(0,u.jsx)("span",{title:"Hot: 50+ accesses in 7d",children:(0,u.jsx)(GE,{size:a,className:"text-orange-500"})});case"active":return(0,u.jsx)("span",{title:"Active: 10-49 accesses in 7d",children:(0,u.jsx)(KE,{size:a,className:"text-green-500"})});case"used":return(0,u.jsx)("span",{title:"Used: 1-9 accesses in 7d",children:(0,u.jsx)(hh,{size:a,className:"text-yellow-500"})});case"dormant":return(0,u.jsx)("span",{title:"Dormant: 0 accesses in 7d",children:(0,u.jsx)(RE,{size:a,className:n?"text-gray-500":"text-gray-400"})});case"frozen":return(0,u.jsx)("span",{title:"Frozen: 0 accesses in 30d",children:(0,u.jsx)(XE,{size:a,className:n?"text-blue-400/50":"text-blue-300"})})}}function nA(e){let{stat:t,isDarkMode:n}=e;if(!t||!t.daily_counts||0===t.daily_counts.length)return null;const a=t.daily_counts.map(e=>e.count),r=Math.max(...a,1),s=eA(t),i={hot:n?"bg-orange-500":"bg-orange-400",active:n?"bg-green-500":"bg-green-400",used:n?"bg-yellow-500":"bg-yellow-400",dormant:n?"bg-gray-600":"bg-gray-300",frozen:n?"bg-blue-800":"bg-blue-200"}[s],o=t.last_accessed_at?function(e){const t=new Date,n=new Date(e),a=t.getTime()-n.getTime(),r=Math.floor(a/6e4);if(r<1)return"just now";if(r<60)return"".concat(r,"m ago");const s=Math.floor(r/60);if(s<24)return"".concat(s,"h ago");const i=Math.floor(s/24);return i<30?"".concat(i,"d ago"):"".concat(Math.floor(i/30),"mo ago")}(t.last_accessed_at):"Never";return(0,u.jsxs)("div",{className:"px-4 py-2 border-b ".concat(n?"border-gray-800":"border-gray-200"),children:[(0,u.jsx)("div",{className:"flex items-end gap-px h-[24px]",title:"Daily access counts (30 days). Total: ".concat(t.total_access_count),children:a.map((e,a)=>(0,u.jsx)("div",{className:"flex-1 rounded-t-sm ".concat(e>0?i:n?"bg-gray-800":"bg-gray-100"),style:{height:"".concat(Math.max(e/r*100,e>0?8:2),"%")},title:"".concat(t.daily_counts[a].day,": ").concat(e," access").concat(1!==e?"es":"")},a))}),(0,u.jsxs)("div",{className:"flex items-center justify-between mt-1 text-[10px] ".concat(n?"text-gray-500":"text-gray-400"),children:[(0,u.jsxs)("span",{children:["Last accessed: ",o]}),(0,u.jsxs)("span",{className:"px-1.5 py-0.5 rounded-full font-medium ".concat(n?"bg-gray-800 text-gray-400":"bg-gray-100 text-gray-500"),children:[t.total_access_count.toLocaleStr
2ing()," total"]})]})]})}function aA(e){let{type:t,isDarkMode:n}=e;return"reference"===t.kind?(0,u.jsx)("span",{title:"Reference entry: supporting material (recipes, code samples, notes) loaded on demand via `prompts get`; excluded from agent bootstrap",className:"text-[10px] shrink-0 ml-1 px-1.5 py-0.5 rounded font-medium uppercase tracking-wide ".concat(n?"bg-sky-900/50 text-sky-300":"bg-sky-100 text-sky-700"),children:"ref"}):!1===t.builtin?(0,u.jsx)("span",{title:"Custom canonical type registered in Prompt Manager; required reading for the workflow that names it",className:"text-[10px] shrink-0 ml-1 px-1.5 py-0.5 rounded font-medium uppercase tracking-wide ".concat(n?"bg-gray-700 text-gray-300":"bg-gray-200 text-gray-600"),children:"custom"}):null}const rA={metadata_generation:"Metadata Generation",show_grammar:"Show Grammar",agent_system:"Agent System Prompt",transcript_refinement:"Transcript Refinement",metadata_validation_rules:"Metadata Validation Rules",description_compression:"Description Compression",narrative_generation:"Narrative Generation",agent_narrative_generation:"Agent: Topic Map Generation",description_generation:"Description Generation",agent_transcript_refinement:"Agent: Transcript Refinement",agent_description_generation:"Agent: Description Generation",speaker_inference:"Speaker Inference",title_generation:"Title Generation",chat_system:"Chat System Prompt",llm_api_docs:"CLI and MCP Docs",humanizer:"Humanizer",diarization_enrichment:"Diarization Enrichment"};const sA=[12,14,16,18],iA={12:"S",14:"M",16:"L",18:"XL"},oA="promptManager_fontSize",lA=e=>{let{isOpen:t,onClose:n,token:r,isDarkMode:s}=e;const{toggleDarkMode:i}=zu(),[o,l]=(0,a.useState)([]),[c,m]=(0,a.useState)(null),[h,p]=(0,a.useState)([]),[g,x]=(0,a.useState)(!1),[f,b]=(0,a.useState)(""),[y,v]=(0,a.useState)(""),[w,k]=(0,a.useState)(""),[j,D]=(0,a.useState)(!1),[C,N]=(0,a.useState)(!1),[F,S]=(0,a.useState)(null),[E,A]=(0,a.useState)(null),[M,_]=(0,a.useState)(null),[B,I]=(0,a.useState)(!1),[P,L]=(0,a.useState)(!0),[R,z]=(0,a.useState)(""),O=(0,a.useRef)(null),[U,V]=(0,a.useState)(()=>{try{const e=localStorage.getItem(oA);if(e&&sA.includes(Number(e)))return Number(e)}catch(_H){}return 14}),H=(0,a.useCallback)(e=>{V(t=>{const n=sA.indexOf(t),a=sA[n+e];return void 0!==a?(localStorage.setItem(oA,String(a)),a):t})},[]),[q,W]=(0,a.useState)([]),[Y,G]=(0,a.useState)(!1),[K,X]=(0,a.useState)(!1),[J,$]=(0,a.useState)({promptType:"",displayName:"",description:"",aliases:"",kind:"canonical"}),[Q,Z]=(0,a.useState)(!1),[ee,te]=(0,a.useState)(!1),ne=(0,a.useCallback)(()=>({Authorization:"Bearer ".concat(r),"Content-Type":"application/json"}),[r]);(0,a.useEffect)(()=>{t&&(fetch("".concat(ZE,"/v1/prompts/types"),{headers:ne()}).then(e=>e.json()).then(e=>{const t=e.types||[];l(t),t.length>0&&!c&&m(t[0].prompt_type)}).catch(()=>S("Failed to load prompt types")),fetch("".concat(ZE,"/v1/prompts/usage"),{headers:ne()}).then(e=>e.json()).then(e=>W(e.stats||[])).catch(()=>{}))},[t,ne,c]);const ae=(0,a.useMemo)(()=>{const e={};for(const t of q)e[t.prompt_type]=t;return e},[q]);(0,a.useEffect)(()=>{c&&(x(!0),p([]),b(""),D(!1),_(null),I(!1),L(!1),S(null),A(null),Promise.all([fetch("".concat(ZE,"/v1/prompts/").concat(c,"/versions"),{headers:ne()}).then(e=>e.json()),fetch("".concat(ZE,"/v1/prompts/").concat(c),{headers:ne()}).then(e=>e.json())]).then(e=>{let[t,n]=e;p(t.versions||[]),b(n.content||""),v(n.content||"")}).catch(()=>{S("Failed to load versions")}).finally(()=>{x(!1)}))},[c,ne]);const re=()=>{const e=c;m(null),setTimeout(()=>m(e),50)},se=async()=>{if(c&&y.trim()){N(!0),S(null),A(null);try{const e=await fetch("".concat(ZE,"/v1/prompts/").concat(c,"/versions"),{method:"POST",headers:ne(),body:JSON.stringify({content:y,change_summary:w||void 0})}),t=await e.json();if(!e.ok)throw new Error(t.error||"Failed to save");t.deduplicated?A("Content unchanged \u2014 no new version created"):A("Version ".concat(t.version_number," created")),D(!1),k(""),re()}catch(e){S(e.message)}finally{N(!1)}}},ie=null!=M&&!M.is_active,oe=a.useMemo(()=>ie&&B?function(e,t){const n=e.split("\n"),a=t.split("\n"),r=n.length,s=a.length,i=Array.from({length:r+1},()=>Array(s+1).fill(0));for(let d=1;d<=r;d++)for(let e=1;e<=s;e++)n[d-1]===a[e-1]?i[d][e]=i[d-1][e-1]+1:i[d][e]=Math.max(i[d-1][e],i[d][e-1]);const o=[];let l=r,c=s;for(;l>0||c>0;)l>0&&c>0&&n[l-1]===a[c-1]?(o.push({type:"same",text:n[l-1]}),l--,c--):c>0&&(0===l||i[l][c-1]>=i[l-1][c])?(o.push({type:"add",text:a[c-1]}),c--):(o.push({type:"remove",text:n[l-1]}),l--);return o.reverse()}(f,(null===M||void 0===M?void 0:M.content)||""):[],[ie,B,f,M]),le=M?M.content||"":f,ce=M?"v".concat(M.version_number," \u2014 ").concat(M.change_summary||"No summary"):"Active Content",de=o.find(e=>e.prompt_type===c),ue=(null===de||void 0===de?void 0:de.display_name)||(c?rA[c]||c:"");return t?(0,u.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col",onKeyDown:e=>{"s"===e.key&&(e.metaKey||e.ctrlKey)&&j&&(e.preventDefault(),se()),"Escape"===e.key&&(j?(D(!1),v(f),k("")):n())},children:[(0,u.jsx)("div",{className:"absolute inset-0 ".concat(s?"bg-gray-950":"bg-gray-50")}),(0,u.jsxs)("div",{className:"relative z-10 flex items-center justify-between px-4 py-2 border-b shrink-0 ".concat(s?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-200 text-gray-900"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)(gp,{size:18}),(0,u.jsx)("h2",{className:"text-sm font-semibold",children:"Prompt Manager"}),c&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(bp,{size:14,className:"text-gray-400"}),(0,u.jsx)("span",{className:"text-sm font-medium",title:"CLI: mlst-rescript prompts get ".concat(c),children:ue}),(0,u.jsx)("code",{className:"text-xs px-1.5 py-0.5 rounded font-mono ".concat(s?"bg-gray-800 text-gray-400":"bg-gray-100 text-gray-500"),children:c}),j&&(0,u.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-brand-yellow/15 text-brand-yellow font-medium",children:"EDITING"}),M&&!j&&(0,u.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded bg-brand-yellow/15 text-brand-yellow font-medium",children:["Viewing v",M.version_number]})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[F&&(0,u.jsxs)("span",{className:"text-xs px-2 py-1 rounded bg-red-600/20 text-red-400",children:[F,(0,u.jsx)("button",{onClick:()=>S(null),className:"ml-1 underline",children:"dismiss"})]}),E&&(0,u.jsxs)("span",{className:"text-xs px-2 py-1 rounded bg-brand-yellow/15 text-brand-yellow",children:[E,(0,u.jsx)("button",{onClick:()=>A(null),className:"ml-1 underline",children:"dismiss"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-0.5 rounded border ".concat(s?"border-gray-700":"border-gray-300"),children:[(0,u.jsx)("button",{onClick:()=>H(-1),disabled:U===sA[0],title:"Decrease font size",className:"p-1 rounded-l transition-colors disabled:opacity-30 ".concat(s?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(JE,{size:14})}),(0,u.jsx)("span",{className:"text-[10px] font-mono px-1 select-none ".concat(s?"text-gray-500":"text-gray-400"),children:iA[U]}),(0,u.jsx)("button",{onClick:()=>H(1),disabled:U===sA[sA.length-1],title:"Increase font size",className:"p-1 rounded-r transition-colors disabled:opacity-30 ".concat(s?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(ik,{size:14})})]}),(0,u.jsx)("button",{onClick:i,title:s?"Switch to light mode":"Switch to dark mode",className:"p-1.5 rounded transition-colors ".concat(s?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-600"),children:s?(0,u.jsx)(LE,{size:16}):(0,u.jsx)(RE,{size:16})}),(0,u.jsx)("button",{onClick:n,className:"p-1.5 rounded transition-colors ".concat(s?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(Pu,{size:18})})]})]}),(0,u.jsxs)("div",{className:"relative z-10 flex flex-1 min-h-0",children:[(0,u.jsxs)("div",{className:"w-64 shrink-0 flex flex-col border-r overflow-hidden ".concat(s?"bg-gray-900 border-gray-700":"bg-white border-gray-200"),children:[(0,u.jsxs)("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider border-b flex items-center justify-between ".concat(s?"text-gray-500 border-gray-700":"text-gray-400 border-gray-200"),children:[(0,u.jsx)("span",{children:"Prompt Types"}),(0,u.jsx)("button",{onClick:()=>G(!0),title:"Create new prompt type",className:"p-0.5 rounded transition-colors ".concat(s?"hover:bg-gray-700 text-gray-400 hover:text-brand-yellow":"hover:bg-gray-200 text-gray-400 hover:text-brand-navy"),children:(0,u.jsx)(ik,{size:14})})]}),(0,u.jsx)("div",{className:"px-2 py-2 border-b ".concat(s?"border-gray-700":"border-gray-200"),children:(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(Mu,{size:13,className:"absolute left-2 top-1/2 -translate-y-1/2 ".concat(s?"text-gray-500":"text-gray-400")}),(0,u.jsx)("input",{type:"text",value:R,onChange:e=>z(e.target.value),placeholder:"Filter prompts...",className:"w-full text-xs pl-7 pr-2 py-1.5 rounded border focus:outline-none focus:ring-1 ".concat(s?"border-gray-600 bg-gray-800 text-gray-200 placeholder-gray-500 focus:ring-brand-yellow/40":"border-gray-300 bg-white text-gray-900 placeholder-gray-400 focus:ring-brand-yellow/60")})]})}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:[...o].sort((e,t)=>
2{const n=e.created_at?new Date(e.created_at).getTime():0,a=t.created_at?new Date(t.created_at).getTime():0;return n!==a?a-n:(t.version_number||0)-(e.version_number||0)}).filter(e=>{if(!R.trim())return!0;const t=R.toLowerCase(),n=(e.display_name||rA[e.prompt_type]||e.prompt_type).toLowerCase(),a=e.prompt_type.toLowerCase();return n.includes(t)||a.includes(t)}).map(e=>(0,u.jsxs)("button",{onClick:()=>{m(e.prompt_type),_(null)},className:"w-full text-left px-3 py-2.5 text-sm flex items-center justify-between transition-colors ".concat(c===e.prompt_type?s?"bg-gray-800 text-white border-l-2 border-brand-yellow":"bg-[#fff6e5] text-brand-navy border-l-2 border-brand-yellow":s?"text-gray-300 hover:bg-gray-800":"text-gray-700 hover:bg-gray-50"),children:[(0,u.jsx)("span",{className:"truncate flex-1",title:"".concat(e.prompt_type,"\nCLI: mlst-rescript prompts get ").concat(e.prompt_type).concat("reference"===e.kind?"\nkind: reference (on-demand; not bootstrap reading)":!1===e.builtin?"\nkind: canonical (custom type)":""),children:e.display_name||rA[e.prompt_type]||e.prompt_type}),(0,u.jsx)(aA,{type:e,isDarkMode:s}),(0,u.jsx)("span",{className:"shrink-0 ml-1",children:(0,u.jsx)(tA,{tier:eA(ae[e.prompt_type]),isDarkMode:s,size:12})}),(0,u.jsxs)("span",{className:"text-xs shrink-0 ml-1 px-1.5 py-0.5 rounded-full font-medium ".concat((()=>{const t=e.version_number||1;return t>=10?s?"bg-green-900/50 text-green-400":"bg-green-100 text-green-700":t>=5?s?"bg-yellow-900/50 text-yellow-400":"bg-yellow-100 text-yellow-700":t>=3?s?"bg-orange-900/50 text-orange-400":"bg-orange-100 text-orange-700":s?"bg-red-900/50 text-red-400":"bg-red-100 text-red-700"})()),children:["v",e.version_number||1]})]},e.prompt_type))}),c&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wider border-t border-b flex items-center justify-between ".concat(s?"text-gray-500 border-gray-700":"text-gray-400 border-gray-200"),children:[(0,u.jsxs)("span",{className:"flex items-center gap-1",children:[(0,u.jsx)(wp,{size:12})," Versions"]}),(0,u.jsx)("span",{children:h.length})]}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0",children:g?(0,u.jsx)("p",{className:"px-3 py-4 text-xs text-gray-500",children:"Loading..."}):h.map(e=>(0,u.jsxs)("div",{className:"px-3 py-2 text-xs border-b cursor-pointer transition-colors ".concat(e.is_active?s?"bg-brand-yellow/10 border-brand-yellow/30":"bg-[#fff6e5] border-[#f0d79a]":(null===M||void 0===M?void 0:M.id)===e.id?s?"bg-brand-navy/20 border-gray-700":"bg-[#e8edf2] border-gray-200":s?"border-gray-800 hover:bg-gray-800":"border-gray-100 hover:bg-gray-50"),onClick:()=>(async e=>{if((null===M||void 0===M?void 0:M.id)===e.id)return _(null),void I(!1);try{const t=await fetch("".concat(ZE,"/v1/prompts/").concat(c,"/versions/").concat(e.id),{headers:ne()}),n=await t.json();_(n),I(!e.is_active)}catch(t){S("Failed to load version content")}})(e),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.jsx)(sk,{size:10,className:"text-gray-400"}),(0,u.jsxs)("span",{className:"font-mono font-medium",children:["v",e.version_number]}),e.is_active&&(0,u.jsx)("span",{className:"px-1 py-0.5 rounded text-[10px] font-medium ".concat(s?"bg-brand-yellow/15 text-brand-yellow":"bg-[#fff3d6] text-[#7a560c]"),children:"active"})]}),(0,u.jsxs)("span",{className:"text-gray-500",children:[(e.content_size/1024).toFixed(1),"KB"]})]}),(0,u.jsxs)("div",{className:"mt-1 flex items-center gap-1.5 ".concat(s?"text-gray-500":"text-gray-400"),children:[(0,u.jsx)("span",{children:e.created_by}),(0,u.jsx)("span",{children:new Date(e.created_at).toLocaleDateString()})]}),e.change_summary&&(0,u.jsx)("div",{className:"mt-0.5 italic truncate ".concat(s?"text-gray-500":"text-gray-400"),children:e.change_summary}),!e.is_active&&(0,u.jsxs)("button",{onClick:t=>{t.stopPropagation(),(async e=>{if(c){S(null);try{if(!(await fetch("".concat(ZE,"/v1/prompts/").concat(c,"/versions/").concat(e,"/activate"),{method:"PUT",headers:ne()})).ok)throw new Error("Failed to activate version");A("Version activated"),re()}catch(t){S(t.message)}}})(e.id)},className:"mt-1.5 px-2 py-0.5 rounded text-[10px] bg-brand-yellow text-brand-navy hover:bg-[#ffc54d] flex items-center gap-1 w-fit",children:[(0,u.jsx)(Cy,{size:9})," Revert to this version"]})]},e.id))})]})]}),(0,u.jsx)("div",{className:"flex-1 flex flex-col min-h-0 ".concat(s?"bg-gray-950":"bg-gray-50"),children:c?g?(0,u.jsx)("div",{className:"flex-1 flex items-center justify-center text-gray-500 text-sm",children:"Loading..."}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 border-b shrink-0 ".concat(s?"bg-gray-900/50 border-gray-800":"bg-white border-gray-200"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[(0,u.jsx)("span",{children:ce}),(0,u.jsxs)("span",{className:"text-gray-400",children:["(",le.length.toLocaleStr
2ing()," chars)"]})]}),(0,u.jsx)("div",{className:"flex items-center gap-2",children:j?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("input",{value:w,onChange:e=>k(e.target.value),placeholder:"Change summary...",className:"text-xs px-2 py-1 rounded border w-56 ".concat(s?"border-gray-600 bg-gray-800 text-gray-200":"border-gray-300 bg-white text-gray-900"),onKeyDown:e=>{"Enter"===e.key&&se()}}),(0,u.jsxs)("button",{onClick:se,disabled:C,className:"text-xs px-3 py-1 rounded bg-brand-yellow text-brand-navy hover:bg-[#ffc54d] disabled:opacity-50 flex items-center gap-1",children:[(0,u.jsx)(Dh,{size:12})," ",C?"Saving...":"Save Version"]}),(0,u.jsx)("button",{onClick:()=>{D(!1),v(f),k("")},className:"text-xs px-3 py-1 rounded ".concat(s?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:"Cancel"}),(0,u.jsx)("span",{className:"text-[10px] text-gray-500",children:"Ctrl+S to save"})]}):(0,u.jsxs)(u.Fragment,{children:[M&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:()=>{_(null),I(!1)},className:"text-xs px-3 py-1 rounded ".concat(s?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:"Back to Active"}),ie&&(0,u.jsxs)("div",{className:"flex rounded overflow-hidden border ".concat(s?"border-gray-600":"border-gray-300"),children:[(0,u.jsx)("button",{onClick:()=>I(!1),className:"text-xs px-3 py-1 transition-colors ".concat(B?s?"bg-gray-800 text-gray-400 hover:text-gray-200":"bg-white text-gray-600 hover:text-gray-900":"bg-brand-navy text-brand-cloud"),children:"Content"}),(0,u.jsx)("button",{onClick:()=>I(!0),className:"text-xs px-3 py-1 transition-colors ".concat(B?"bg-brand-navy text-brand-cloud":s?"bg-gray-800 text-gray-400 hover:text-gray-200":"bg-white text-gray-600 hover:text-gray-900"),children:"Diff vs Active"})]})]}),!B&&(0,u.jsxs)("div",{className:"flex rounded overflow-hidden border ".concat(s?"border-gray-600":"border-gray-300"),children:[(0,u.jsxs)("button",{onClick:()=>L(!1),title:"View raw text",className:"text-xs px-2.5 py-1 transition-colors flex items-center gap-1 ".concat(P?s?"bg-gray-800 text-gray-400 hover:text-gray-200":"bg-white text-gray-600 hover:text-gray-900":"bg-brand-navy text-brand-cloud"),children:[(0,u.jsx)($E,{size:11})," Raw"]}),(0,u.jsxs)("button",{onClick:()=>L(!0),title:"Preview rendered markdown",className:"text-xs px-2.5 py-1 transition-colors flex items-center gap-1 ".concat(P?"bg-brand-navy text-brand-cloud":s?"bg-gray-800 text-gray-400 hover:text-gray-200":"bg-white text-gray-600 hover:text-gray-900"),children:[(0,u.jsx)(Cp,{size:11})," Preview"]})]}),(0,u.jsxs)("button",{onClick:()=>{D(!0),L(!1),v(M?M.content||"":f),_(null)},className:"text-xs px-3 py-1 rounded bg-brand-navy text-brand-cloud hover:bg-[#1a2230] flex items-center gap-1",children:[(0,u.jsx)(Ro,{size:12})," Edit"]}),(0,u.jsx)("button",{onClick:()=>X(!0),title:"Delete prompt type",className:"p-1 rounded transition-colors ".concat(s?"text-gray-500 hover:text-red-400 hover:bg-red-900/20":"text-gray-400 hover:text-red-600 hover:bg-red-50"),children:(0,u.jsx)(kp,{size:14})})]})})]}),de&&(de.description||!1===de.builtin)&&(0,u.jsxs)("div",{className:"px-4 py-2 text-xs border-b flex items-start gap-2 ".concat(s?"bg-gray-900/30 border-gray-800 text-gray-400":"bg-[#fff8eb] border-gray-200 text-gray-500"),children:[(0,u.jsx)(aA,{type:de,isDarkMode:s}),(0,u.jsxs)("span",{className:"flex-1",children:[de.description,"reference"===de.kind&&(0,u.jsxs)("span",{className:"block mt-0.5 ".concat(s?"text-gray-500":"text-gray-400"),children:["Reference entry: loaded on demand via ",(0,u.jsxs)("code",{className:"font-mono",children:["mlst-rescript prompts get ",de.prompt_type]})," when a canonical prompt names it; excluded from agent bootstrap."]})]})]}),c&&!j&&(0,u.jsx)(nA,{stat:ae[c],isDarkMode:s}),(0,u.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:j?(0,u.jsx)("textarea",{ref:O,value:y,onChange:e=>v(e.target.value),className:"w-full h-full font-mono p-4 resize-none focus:outline-none ".concat(s?"bg-gray-950 text-gray-200 caret-white":"bg-white text-gray-900"),style:{fontSize:"".concat(U,"px")},spellCheck:!1,autoFocus:!0}):B&&ie&&oe.length>0?(0,u.jsxs)("div",{className:"w-full h-full overflow-auto ".concat(s?"bg-gray-950":"bg-white"),children:[(0,u.jsxs)("div",{className:"px-4 py-2 text-xs border-b sticky top-0 z-10 ".concat(s?"bg-gray-900 border-gray-800 text-gray-400":"bg-gray-50 border-gray-200 text-gray-500"),children:[(0,u.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm mr-1.5 align-middle border ".concat(s?"bg-red-900/30 border-red-700":"bg-red-100 border-red-300")})," Removed from active",(0,u.jsx)("span",{className:"ml-4 inline-block w-3 h-3 rounded-sm mr-1.5 align-middle border ".concat(s?"bg-green-900/30 border-green-700":"bg-green-100 border-green-300")})," Added in v",null===M||void 0===M?void 0:M.version_number]}),(0,u.jsx)("pre",{className:"font-mono p-4 whitespace-pre-wrap break-words",style:{fontSize:"".concat(U,"px")},children:oe.map((e,t)=>"remove"===e.type?(0,u.jsxs)("div",{className:"".concat(s?"bg-red-900/30 text-red-300":"bg-red-100 text-red-800"),children:[(0,u.jsx)("span",{className:"inline-block w-6 text-center select-none opacity-60",children:"-"}),e.text]},t):"add"===e.type?(0,u.jsxs)("div",{className:"".concat(s?"bg-green-900/30 text-green-300":"bg-green-100 text-green-800"),children:[(0,u.jsx)("span",{className:"inline-block w-6 text-center select-none opacity-60",children:"+"}),e.text]},t):(0,u.jsxs)("div",{className:"".concat(s?"text-gray-400":"text-gray-600"),children:[(0,u.jsx)("span",{className:"inline-block w-6 text-center select-none opacity-30",children:"\xa0"}),e.text]},t))})]}):P?(0,u.jsx)("div",{className:"w-full h-full overflow-auto p-6 ".concat(s?"bg-gray-950 text-gray-200":"bg-white text-gray-800"),style:{fontSize:"".concat(U,"px")},children:(0,u.jsx)("div",{className:"max-w-4xl mx-auto prompt-preview ".concat(s?"prompt-preview-dark":"prompt-preview-light"),children:(0,u.jsx)(my,{remarkPlugins:[Cw],components:{h1:e=>{let{children:t}=e;return(0,u.jsx)("h1",{className:"text-2xl font-bold mt-6 mb-3 pb-2 border-b ".concat(s?"text-gray-100 border-gray-700":"text-gray-900 border-gray-200"),children:t})},h2:e=>{let{children:t}=e;return(0,u.jsx)("h2",{className:"text-xl font-semibold mt-5 mb-2 pb-1 border-b ".concat(s?"text-gray-200 border-gray-800":"text-gray-800 border-gray-100"),children:t})},h3:e=>{let{children:t}=e;return(0,u.jsx)("h3",{className:"text-lg font-semibold mt-4 mb-2 ".concat(s?"text-gray-200":"text-gray-800"),children:t})},h4:e=>{let{children:t}=e;return(0,u.jsx)("h4",{className:"text-base font-semibold mt-3 mb-1 ".concat(s?"text-gray-300":"text-gray-700"),children:t})},p:e=>{let{children:t}=e;return(0,u.jsx)("p",{className:"my-2 leading-relaxed ".concat(s?"text-gray-300":"text-gray-700"),children:t})},ul:e=>{let{children:t}=e;return(0,u.jsx)("ul",{className:"my-2 ml-5 list-disc space-y-1 ".concat(s?"text-gray-300":"text-gray-700"),children:t})},ol:e=>{let{children:t}=e;return(0,u.jsx)("ol",{className:"my-2 ml-5 list-decimal space-y-1 ".concat(s?"text-gray-300":"text-gray-700"),children:t})},li:e=>{let{children:t}=e;return(0,u.jsx)("li",{className:"leading-relaxed",children:t})},code:e=>{let{className:t,children:n}=e,a=T(e,QE);return(null===t||void 0===t?void 0:t.includes("language-"))?(0,u.jsx)("code",d(d({className:"block font-mono text-[0.9em] ".concat(s?"text-gray-200":"text-gray-800")},a),{},{children:n})):(0,u.jsx)("code",d(d({className:"font-mono text-[0.9em] px-1.5 py-0.5 rounded ".concat(s?"bg-gray-800 text-orange-300":"bg-gray-100 text-orange-700")},a),{},{children:n}))},pre:e=>{let{children:t}=e;return(0,u.jsx)("pre",{className:"my-3 p-3 rounded-lg overflow-x-auto font-mono text-[0.9em] ".concat(s?"bg-gray-900 border border-gray-700":"bg-gray-50 border border-gray-200"),children:t})},blockquote:e=>{let{children:t}=e;return(0,u.jsx)("blockquote",{className:"my-3 pl-4 border-l-4 italic ".concat(s?"border-gray-600 text-gray-400":"border-gray-300 text-gray-500"),children:t})},a:e=>{let{href:t,children:n}=e;return(0,u.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"underline ".concat(s?"text-blue-400 hover:text-blue-300":"text-blue-600 hover:text-blue-800"),children:n})},strong:e=>{let{children:t}=e;return(0,u.jsx)("strong",{className:"font-semibold ".concat(s?"text-gray-100":"text-gray-900"),children:t})},em:e=>{let{children:t}=e;return(0,u.jsx)("em",{className:"italic",children:t})},hr:()=>(0,u.jsx)("hr",{className:"my-4 ".concat(s?"border-gray-700":"border-gray-200")}),table:e=>{let{children:t}=e;return(0,u.jsx)("div",{className:"my-3 overflow-x-auto",children:(0,u.jsx)("table",{className:"min-w-full text-sm border-collapse ".concat(s?"border-gray-700":"border-gray-200"),children:t})})},thead:e=>{let{children:t}=e;return(0,u.jsx)("thead",{className:s?"bg-gray-800":"bg-gray-50",children:t})},th:e=>{let{children:t}=e;return(0,u.jsx)("th",{className:"px-3 py-2 text-left font-semibold border ".concat(s?"border-gray-700 text-gray-200":"border-gray-200 text-gray-700"),children:t})},td:e=>{let{children:t}=e;return(0,u.jsx)("td",{className:"px-3 py-2 border ".concat(s?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"),children:t})}},children:le})})}):(0,u.jsx)("pre",{className:"w-full h-full font-mono p-4 overflow-auto whitespace-pre-wrap break-words ".concat(s?"bg-gray-950 text-gray-300":"bg-white text-gray-800"),style:{fontSize:"".concat(U,"px")},children:le})})]}):(0,u.jsx)("div",{className:"flex-1 flex items-center justify-center text-gray-500 text-sm",children:"Select a prompt type from the sidebar"})})]}),Y&&(0,u.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>G(!1)}),(0,u.jsxs)("div",{className:"relative w-full max-w-md rounded-lg shadow-xl overflow-hidden ".concat(s?"bg-gray-900":"bg-white"),children:[(0,u.jsxs)("div",{className:"bg-brand-navy px-5 py-3 flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 text-brand-cloud",children:[(0,u.jsx)(ik,{size:16,className:"text-brand-yellow"}),(0,u.jsx)("h3",{className:"text-sm font-semibold",children:"New Prompt Type"})]}),(0,u.jsx)("button",{onClick:()=>G(!1),className:"text-brand-cloud/60 hover:text-brand-cloud",children:(0,u.jsx)(Pu,{size:16})})]}),(0,u.jsxs)("div",{className:"px-5 py-4 space-y-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"block text-xs font-medium mb-1 ".concat(s?"text-gray-300":"text-gray-700"),children:["Prompt Type ",(0,u.jsx)("span",{className:"text-red-500",children:"*"})]}
2),(0,u.jsx)("input",{type:"text",value:J.promptType,onChange:e=>$(t=>d(d({},t),{},{promptType:e.target.value.toLowerCase().replace(/[^a-z0-9_]/g,"_")})),placeholder:"my_custom_prompt",className:"w-full text-sm px-3 py-2 rounded border font-mono focus:outline-none focus:ring-2 focus:ring-brand-yellow/40 ".concat(s?"border-gray-600 bg-gray-800 text-gray-200 placeholder-gray-500":"border-gray-300 bg-white text-gray-900 placeholder-gray-400")}),(0,u.jsx)("p",{className:"text-[10px] mt-0.5 ".concat(s?"text-gray-500":"text-gray-400"),children:"Lowercase, underscores only. Used as the API identifier."})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"block text-xs font-medium mb-1 ".concat(s?"text-gray-300":"text-gray-700"),children:["Display Name ",(0,u.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,u.jsx)("input",{type:"text",value:J.displayName,onChange:e=>$(t=>d(d({},t),{},{displayName:e.target.value})),placeholder:"My Custom Prompt",className:"w-full text-sm px-3 py-2 rounded border focus:outline-none focus:ring-2 focus:ring-brand-yellow/40 ".concat(s?"border-gray-600 bg-gray-800 text-gray-200 placeholder-gray-500":"border-gray-300 bg-white text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium mb-1 ".concat(s?"text-gray-300":"text-gray-700"),children:"Kind"}),(0,u.jsxs)("select",{value:J.kind,onChange:e=>$(t=>d(d({},t),{},{kind:"reference"===e.target.value?"reference":"canonical"})),className:"w-full text-sm px-3 py-2 rounded border focus:outline-none focus:ring-2 focus:ring-brand-yellow/40 ".concat(s?"border-gray-600 bg-gray-800 text-gray-200":"border-gray-300 bg-white text-gray-900"),children:[(0,u.jsx)("option",{value:"canonical",children:"Canonical \u2014 required reading for the workflow that names it"}),(0,u.jsx)("option",{value:"reference",children:"Reference \u2014 recipes / code samples / notes loaded on demand"})]}),(0,u.jsx)("p",{className:"text-[10px] mt-0.5 ".concat(s?"text-gray-500":"text-gray-400"),children:"Reference entries are referenced by name from a canonical prompt and excluded from agent bootstrap loads, so the canon stays small."})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium mb-1 ".concat(s?"text-gray-300":"text-gray-700"),children:"Description"}),(0,u.jsx)("textarea",{value:J.description,onChange:e=>$(t=>d(d({},t),{},{description:e.target.value})),placeholder:"What this prompt is used for...",rows:2,className:"w-full text-sm px-3 py-2 rounded border resize-none focus:outline-none focus:ring-2 focus:ring-brand-yellow/40 ".concat(s?"border-gray-600 bg-gray-800 text-gray-200 placeholder-gray-500":"border-gray-300 bg-white text-gray-900 placeholder-gray-400")})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"block text-xs font-medium mb-1 ".concat(s?"text-gray-300":"text-gray-700"),children:["Aliases ",(0,u.jsx)("span",{className:"font-normal ".concat(s?"text-gray-500":"text-gray-400"),children:"(comma-separated)"})]}),(0,u.jsx)("input",{type:"text",value:J.aliases,onChange:e=>$(t=>d(d({},t),{},{aliases:e.target.value})),placeholder:"alias_one, alias_two",className:"w-full text-sm px-3 py-2 rounded border font-mono focus:outline-none focus:ring-2 focus:ring-brand-yellow/40 ".concat(s?"border-gray-600 bg-gray-800 text-gray-200 placeholder-gray-500":"border-gray-300 bg-white text-gray-900 placeholder-gray-400")})]})]}),(0,u.jsxs)("div",{className:"px-5 py-3 flex items-center justify-end gap-2 border-t ".concat(s?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsx)("button",{onClick:()=>G(!1),className:"text-xs px-4 py-2 rounded font-medium transition-colors ".concat(s?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:"Cancel"}),(0,u.jsxs)("button",{onClick:async()=>{if(J.promptType.trim()&&J.displayName.trim()){Z(!0),S(null);try{const e=await fetch("".concat(ZE,"/v1/prompts/types"),{method:"POST",headers:ne(),body:JSON.stringify({promptType:J.promptType.trim(),displayName:J.displayName.trim(),description:J.description.trim()||void 0,aliases:J.aliases.trim()||void 0,kind:J.kind})}
2),t=await e.json();if(!e.ok)throw new Error(t.error||"Failed to create prompt type");A('Prompt type "'.concat(J.displayName.trim(),'" created (').concat(J.kind,")")),G(!1),$({promptType:"",displayName:"",description:"",aliases:"",kind:"canonical"});const n=await fetch("".concat(ZE,"/v1/prompts/types"),{headers:ne()}),a=await n.json();l(a.types||[]),m(J.promptType.trim())}catch(e){S(e.message)}finally{Z(!1)}}},disabled:Q||!J.promptType.trim()||!J.displayName.trim(),className:"text-xs px-4 py-2 rounded font-medium bg-brand-yellow text-brand-navy hover:bg-[#ffc54d] disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",children:[(0,u.jsx)(ik,{size:12}),Q?"Creating...":"Create Prompt Type"]})]})]})]}),K&&c&&(0,u.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>X(!1)}),(0,u.jsxs)("div",{className:"relative w-full max-w-md rounded-lg shadow-xl overflow-hidden ".concat(s?"bg-gray-900":"bg-white"),children:[(0,u.jsxs)("div",{className:"px-5 py-3 flex items-center justify-between ".concat(s?"bg-red-900/40":"bg-red-50"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(fp,{size:16,className:"text-red-500"}),(0,u.jsx)("h3",{className:"text-sm font-semibold ".concat(s?"text-red-300":"text-red-800"),children:"Delete Prompt Type"})]}),(0,u.jsx)("button",{onClick:()=>X(!1),className:s?"text-red-400/60 hover:text-red-300":"text-red-400 hover:text-red-600",children:(0,u.jsx)(Pu,{size:16})})]}),(0,u.jsxs)("div",{className:"px-5 py-4 space-y-3",children:[(0,u.jsxs)("div",{className:"text-sm ".concat(s?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("p",{children:"You are about to delete the prompt type:"}),(0,u.jsxs)("div",{className:"mt-2 p-3 rounded border ".concat(s?"bg-gray-800 border-gray-700":"bg-gray-50 border-gray-200"),children:[(0,u.jsx)("p",{className:"font-semibold",children:ue}),(0,u.jsx)("code",{className:"text-xs font-mono ".concat(s?"text-gray-400":"text-gray-500"),children:c})]})]}),(()=>{const e=ae[c],t=(null===e||void 0===e?void 0:e.access_count_7d)||0;return t>0?(0,u.jsxs)("div",{className:"p-3 rounded border ".concat(s?"bg-red-900/20 border-red-800/50":"bg-red-50 border-red-200"),children:[(0,u.jsxs)("p",{className:"text-sm font-medium flex items-center gap-1.5 ".concat(s?"text-red-300":"text-red-700"),children:[(0,u.jsx)(fp,{size:14})," This prompt was accessed ",t," time",1!==t?"s":""," in the last 7 days."]}),(0,u.jsx)("p",{className:"text-xs mt-1 ".concat(s?"text-red-400/80":"text-red-600"),children:"Deleting it may break active workflows."})]}):null})(),(0,u.jsx)("p",{className:"text-xs ".concat(s?"text-gray-400":"text-gray-500"),children:"This will soft-delete the prompt type. It can be restored later."})]}),(0,u.jsxs)("div",{className:"px-5 py-3 flex items-center justify-end gap-2 border-t ".concat(s?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsx)("button",{onClick:()=>X(!1),className:"text-xs px-4 py-2 rounded font-medium transition-colors ".concat(s?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:"Cancel"}),(0,u.jsxs)("button",{onClick:async()=>{if(c){te(!0),S(null);try{const e=await fetch("".concat(ZE,"/v1/prompts/types/").concat(c),{method:"DELETE",headers:ne()}),t=await e.json();if(!e.ok)throw new Error(t.error||"Failed to delete prompt type");A('Prompt type "'.concat(ue,'" deleted')),X(!1),m(null);const n=await fetch("".concat(ZE,"/v1/prompts/types"),{headers:ne()}),a=await n.json();l(a.types||[])}catch(e){S(e.message)}finally{te(!1)}}},disabled:ee,className:"text-xs px-4 py-2 rounded font-medium bg-red-600 text-white hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5",children:[(0,u.jsx)(kp,{size:12}),ee?"Deleting...":"Delete"]})]})]})]})]}):null},cA=Mo("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const dA=e=>{var t;let{isOpen:n,onClose:r,token:s,isDarkMode:i}
2=e;const o=oc(),[l,c]=(0,a.useState)(""),[m,h]=(0,a.useState)(""),[p,g]=(0,a.useState)("all"),[x,f]=(0,a.useState)("all"),[b,y]=(0,a.useState)(""),[v,w]=(0,a.useState)(!0),[k,j]=(0,a.useState)(!0),[D,C]=(0,a.useState)(!1),[N,F]=(0,a.useState)(!1),[S,E]=(0,a.useState)(null),[A,T]=(0,a.useState)(null),M=(0,a.useRef)(null),_=(0,a.useRef)(-1);(0,a.useEffect)(()=>{if(!n)return;const e=window.setTimeout(()=>h(l.trim()),250);return()=>window.clearTimeout(e)},[n,l]);const B=0===m.length&&!b,I=(0,a.useCallback)(async function(){let{append:e=!1,offset:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(s&&n){e?F(!0):C(!0),E(null);try{const n=await async function(){var e,t,n,a,r;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;const o=await gm("".concat("","/api/questions/browser").concat(pm({q:s.query,show:s.show,person:s.person,topic:s.topic,discovery:null!==(e=s.discovery)&&void 0!==e&&e,publishedOnly:null===(t=s.publishedOnly)||void 0===t||t,requireYoutube:null===(n=s.requireYoutube)||void 0===n||n,limit:null!==(a=s.limit)&&void 0!==a?a:80,offset:null!==(r=s.offset)&&void 0!==r?r:0})),i),l=await o.json();return{total:Number(l.total||0),count:Number(l.count||0),questions:Array.isArray(l.questions)?l.questions.map(mm):[],shows:Array.isArray(l.shows)?l.shows.map(hm).filter(e=>Boolean(e)):[],people:Array.isArray(l.people)?l.people.map(hm).filter(e=>Boolean(e)):[],topics:Array.isArray(l.topics)?l.topics.map(hm).filter(e=>Boolean(e)):[],pagination:l.pagination?{limit:Number(l.pagination.limit||0),offset:Number(l.pagination.offset||0),hasMore:Boolean(l.pagination.hasMore)}:void 0}}({query:m,show:p,person:"all"===x?void 0:x,topic:m?void 0:b||void 0,discovery:B,publishedOnly:v,requireYoutube:k,limit:B?1:40,offset:t},s);T(t=>function(e,t,n){if(!n||!e)return t;const a=new Map;return[...e.questions,...t.questions].forEach(e=>{a.set(e.id,e)}),d(d({},t),{},{questions:[...a.values()],count:[...a.values()].length})}(t,n,e))}catch(a){E(a.message||"Failed to load question explorer")}finally{C(!1),F(!1)}}},[m,B,n,x,v,k,b,p,s]);(0,a.useEffect)(()=>{n&&(_.current=-1,T(null),I({append:!1,offset:0}))},[m,n,I,x,v,k,b,p]),(0,a.useEffect)(()=>{m.trim().length>0&&b&&y("")},[m,b]),(0,a.useEffect)(()=>{n||(c(""),h(""),g("all"),f("all"),y(""),w(!0),j(!0),E(null),T(null))},[n]);const P=(0,a.useMemo)(()=>(null===A||void 0===A?void 0:A.shows)||[],[A]),L=(0,a.useMemo)(()=>(null===A||void 0===A?void 0:A.people)||[],[A]),R=(0,a.useMemo)(()=>(null===A||void 0===A?void 0:A.topics)||[],[A]),z=(0,a.useMemo)(()=>(null===A||void 0===A?void 0:A.questions)||[],[A]),O=(0,a.useMemo)(()=>function(e){const t=new Map;for(const n of e){const e=(n.topic||"Uncategorized").trim()||"Uncategorized",a=t.get(e);a?a.push(n):t.set(e,[n])}return[...t.entries()].map(e=>{let[t,n]=e;return{topic:t,items:n}}).sort((e,t)=>t.items.length!==e.items.length?t.items.length-e.items.length:e.topic.localeCompare(t.topic))}(z),[z]),U=Boolean(null===A||void 0===A||null===(t=A.pagination)||void 0===t?void 0:t.hasMore),V=i?"text-[#A9B4C3]":"text-[#5B687C]",H=i?"border-[#344052] bg-[#162131]/96 text-[#F4F4F4]":"border-[#D6DCE4] bg-white/[0.97] text-[#232E3F]",q=i?"border-[#344052] bg-[#101925]/90":"border-[#D6DCE4] bg-white/90",W=i?"border-white/[0.12] bg-white/[0.08] text-[#F4F4F4] placeholder:text-[#94A0B2]":"border-[#D6DCE4] bg-white text-[#232E3F] placeholder:text-[#7B8798]";(0,a.useEffect)(()=>{if(!n||B||!U||D||N||!M.current)return;const e=M.current,t=new IntersectionObserver(e=>{const[t]=e;if(null===t||void 0===t||!t.isIntersecting)return;const n=z.length;_.current!==n&&(_.current=n,I({append:!0,offset:n}))},{rootMargin:"420px 0px"});return t.observe(e),()=>t.disconnect()},[B,U,n,I,D,N,z.length]);const Y=e=>{const t=null!=e.timestampSeconds?"?t=".concat(function(e){if(null===e||!Number.isFinite(e))return"";const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?"".concat(n,"h").concat(a,"m").concat(r,"s"):"".concat(a,"m").concat(r,"s")}(e.timestampSeconds)):"";r(),o("/session/".concat(e.episodeId).concat(t))};return n?(0,u.jsx)("div",{className:"fixed inset-0 z-[170] flex items-stretch justify-center bg-[#111826]/[0.78] backdrop-blur-sm",children:(0,u.jsxs)("div",{className:"relative flex h-full w-full flex-col overflow-hidden border-l shadow-[0_40px_90px_-40px_rgba(10,14,20,0.92)] ".concat(H),children:[(0,u.jsxs)("div",{className:"sticky top-0 z-20 border-b px-6 py-5 backdrop-blur-2xl ".concat(i?"border-white/[0.08] bg-[#162131]/88":"border-[#D6DCE4] bg-[#F4F4F4]/88"),children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.28em] ".concat(i?"text-[#FFCC66]":"text-[#A36A00]"),children:"Question Explorer"}),(0,u.jsx)("h2",{className:"mt-2 font-headlines text-2xl font-bold tracking-tight",children:"Cross-session questions"}),(0,u.jsx)("p",{className:"mt-2 max-w-3xl font-body text-sm leading-6 ".concat(V),children:"Topic-grouped question browsing across the archive. Open a question at the exact point it was asked, then refine the question bank from the session itself."})]}),(0,u.jsx)("button",{type:"button",onClick:r,className:"rounded-full p-2 transition-colors ".concat(i?"text-gray-400 hover:bg-white/[0.08]":"text-gray-600 hover:bg-[#
2E8ECF1]"),children:(0,u.jsx)(Pu,{size:18})})]}),(0,u.jsxs)("div",{className:"mt-5 grid gap-3 xl:grid-cols-[minmax(0,1.45fr)_180px_240px_auto_auto_auto]",children:[(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(Mu,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 ".concat(V)}),(0,u.jsx)("input",{value:l,onChange:e=>c(e.target.value),placeholder:"Search questions, answers, askers, sessions, topics",className:"w-full rounded-2xl border py-3 pl-11 pr-4 font-body text-sm ".concat(W)})]}),(0,u.jsxs)("select",{value:p,onChange:e=>g(e.target.value),className:"rounded-2xl border px-4 py-3 font-body text-sm ".concat(W),children:[(0,u.jsx)("option",{value:"all",children:"all"}),P.map(e=>(0,u.jsxs)("option",{value:e.slug,children:[e.slug," (",e.count,")"]},e.slug))]}),(0,u.jsxs)("select",{value:x,onChange:e=>f(e.target.value),className:"rounded-2xl border px-4 py-3 font-body text-sm ".concat(W),children:[(0,u.jsx)("option",{value:"all",children:"all people"}),L.map(e=>(0,u.jsxs)("option",{value:e.name,children:[e.name," (",e.count,")"]},e.name))]}),(0,u.jsx)("button",{type:"button",onClick:()=>w(e=>!e),className:"rounded-full border px-4 py-2 font-headlines text-sm font-semibold ".concat(v?i?"border-[#FFCC66]/35 bg-[#FFB52B]/12 text-[#FFE3A1]":"border-[#F2D9A6] bg-[#FFF6DB] text-[#A36A00]":W),children:"Published only"}),(0,u.jsx)("button",{type:"button",onClick:()=>j(e=>!e),className:"rounded-full border px-4 py-2 font-headlines text-sm font-semibold ".concat(k?i?"border-[#BCD7FF]/35 bg-[#355E9A]/18 text-[#D8E8FF]":"border-[#BFD3F0] bg-[#EEF3FF] text-[#355E9A]":W),children:"YouTube only"}),(0,u.jsx)("button",{type:"button",onClick:()=>{I({append:!1,offset:0})},className:"rounded-full border px-4 py-2 font-headlines text-sm font-semibold ".concat(W),children:"Refresh"})]}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3 text-xs ".concat(V),children:[B?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{children:[R.length," topic",1===R.length?"":"s"," ready to explore"]}),(0,u.jsx)("span",{children:"Pick a topic or start typing to switch into search mode."})]}):D?(0,u.jsx)("span",{children:"Searching..."}):(0,u.jsx)(u.Fragment,{children:0===z.length?(0,u.jsx)("span",{children:"No questions found for this search."}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{children:["Showing ",z.length,U?"+":""," question",1===z.length?"":"s"]}),U?(0,u.jsx)("span",{children:"Scroll down to load more."}):(0,u.jsx)("span",{children:"Grouped by topic."})]})}),b?(0,u.jsxs)("button",{type:"button",onClick:()=>y(""),className:"rounded-full border px-3 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.16em] ".concat(i?"border-[#FFCC66]/35 bg-[#5B3A00]/72 text-[#FFF2C7] shadow-[0_16px_30px_-22px_rgba(0,0,0,0.55)]":"border-[#F2D9A6] bg-[#FFF6DB] text-[#A36A00]"),children:["Topic: ",b]}):null]})]}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto px-6 pb-10 pt-6 ".concat(i?"bg-[#101925]":"bg-[#F4F4F4]"),children:D?(0,u.jsxs)("div",{className:"flex min-h-[45vh] items-center justify-center font-body text-sm ".concat(V),children:[(0,u.jsx)(Lo,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading questions\u2026"]}):S?(0,u.jsxs)("div",{className:"rounded-[24px] border px-6 py-8 text-center shadow-[0_20px_40px_-28px_rgba(35,46,63,0.25)] ".concat(H),children:[(0,u.jsx)("div",{className:"font-headlines text-lg font-semibold",children:"Question explorer failed to load"}),(0,u.jsx)("p",{className:"mt-2 font-body text-sm ".concat(V),children:S})]}):B?(0,u.jsxs)("div",{className:"space-y-6",children:[(0,u.jsxs)("div",{className:"rounded-[24px] border px-6 py-8 shadow-[0_20px_40px_-28px_rgba(35,46,63,0.25)] ".concat(H),children:[(0,u.jsx)("div",{className:"font-headlines text-lg font-semibold",children:"Explore by topic"}),(0,u.jsx)("p",{className:"mt-2 font-body text-sm ".concat(V),children:"Start with a topic, then open the exact session moment and refine question records from there."})]}),0===R.length?(0,u.jsxs)("div",{className:"rounded-[24px] border px-6 py-8 text-center shadow-[0_20px_40px_-28px_rgba(35,46,63,0.25)] ".concat(H),children:[(0,u.jsx)(cA,{className:"mx-auto h-8 w-8 text-brand-yellow"}),(0,u.jsx)("div",{className:"mt-3 font-headlines text-lg font-semibold",children:"No topics matched this scope"}),(0,u.jsx)("p",{className:"mt-2 font-body text-sm ".concat(V),children:"Try a different show/person scope or start with a direct search."})]}):(0,u.jsx)("div",{className:"grid gap-4 xl:grid-cols-3",children:R.map(e=>(0,u.jsx)("button",{type:"button",onClick:()=>y(e.name||""),className:"rounded-[24px] border p-5 text-left shadow-[0_20px_40px_-28px_rgba(35,46,63,0.2)] transition duration-300 hover:-translate-y-0.5 hover:shadow-[0_26px_50px_-30px_rgba(35,46,63,0.28)] ".concat(q),children:(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-xl font-bold tracking-tight",children:e.name}),(0,u.jsxs)("p",{className:"mt-2 text-xs uppercase tracking-[0.18em] ".concat(V),children:[e.count," question",1===e.count?"":"s"]})]}),(0,u.jsx)("span",{className:"rounded-full px-3 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.14em] ".concat(i?"border border-[#BCD7FF]/18 bg-[#213554]/88 text-[#F4F8FF]":"bg-[#EEF3FF] text-[#355E9A]"),children:"Topic"})]})},e.name))})]}):0===O.length?(0,u.jsxs)("div",{className:"rounded-[24px] border px-6 py-8 text-center shadow-[0_20px_40px_-28px_rgba(35,46,63,0.25)] ".concat(H),children:[(0,u.jsx)(zE,{className:"mx-auto h-8 w-8 text-brand-yellow"}),(0,u.jsx)("div",{className:"mt-3 font-headlines text-lg font-semibold",children:"No questions matched"}),(0,u.jsx)("p",{className:"mt-2 font-body text-sm ".concat(V),children:"Try a broader search or relax one of the published / YouTube filters."})]}):(0,u.jsxs)("div",{className:"space-y-6",children:[O.map(e=>(0,u.jsxs)("section",{className:"rounded-[24px] border shadow-[0_20px_40px_-28px_rgba(35,46,63,0.32)] ".concat(q),children:[(0,u.jsx)("div",{className:"border-b px-5 py-4 ".concat(i?"border-white/[0.08]":"border-[#
2E3E7EC]"),children:(0,u.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-xl font-bold tracking-tight",children:e.topic}),(0,u.jsxs)("p",{className:"mt-1 text-xs uppercase tracking-[0.22em] ".concat(V),children:[e.items.length," question",1===e.items.length?"":"s"]})]}),(0,u.jsx)("div",{className:"rounded-full px-3 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.14em] ".concat(i?"border border-[#BCD7FF]/18 bg-[#213554]/88 text-[#F4F8FF]":"bg-[#EEF3FF] text-[#355E9A]"),children:"Topic group"})]})}),(0,u.jsx)("div",{className:"grid gap-4 p-5 xl:grid-cols-2",children:e.items.map(e=>{const t="all"===p&&e.showSlug&&"mlst"!==e.showSlug;return(0,u.jsxs)("article",{className:"rounded-[24px] border p-5 shadow-[0_20px_40px_-28px_rgba(35,46,63,0.2)] ".concat(i?"border-white/[0.08] bg-white/[0.04]":"border-[#E3E7EC] bg-white/92"),children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.12em] ".concat("implicit"===e.questionType?i?"bg-[#26344A] text-[#BCD7FF]":"bg-[#EEF3FF] text-[#355E9A]":i?"bg-[#153526] text-[#A9E2C4]":"bg-[#EAF7EF] text-[#2D7250]"),children:e.questionType}),e.askedBy?(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.12em] ".concat(i?"bg-white/[0.08] text-[#D7DDE5]":"bg-[#E8ECF1] text-[#566377]"),children:e.askedBy}):null,t?(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.12em] ".concat(i?"bg-[#2D2446] text-[#D9D2FF]":"bg-[#F1EFFA] text-[#5E548E]"),children:e.showSlug}):null,e.familyTitle?(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.12em] ".concat(i?"bg-[#FFB52B]/12 text-[#FFE3A1]":"bg-[#FFF4D9] text-[#8A6100]"),children:[(0,u.jsx)(ck,{className:"h-3 w-3"}),e.familyTitle]}):null]}),(0,u.jsx)("h3",{className:"mt-4 font-headlines text-xl font-bold tracking-tight",children:e.questionText}),(0,u.jsx)("p",{className:"mt-2 font-headlines text-sm font-semibold uppercase tracking-[0.18em] ".concat(V),children:e.sessionTitle}),e.answerSummary?(0,u.jsx)("p",{className:"mt-4 line-clamp-4 font-body text-sm leading-6 ".concat(V),children:e.answerSummary}):(0,u.jsx)("p",{className:"mt-4 font-body text-sm leading-6 ".concat(V),children:"No answer summary is stored yet for this question."}),(0,u.jsxs)("div",{className:"mt-5 flex flex-wrap items-center gap-3 text-xs ".concat(V),children:[e.timecode?(0,u.jsx)("span",{children:e.timecode}):(0,u.jsx)("span",{children:"No timestamp"}),null!=e.familyVersionNumber?(0,u.jsxs)("span",{children:["v",e.familyVersionNumber]}):null,e.publishedAt?(0,u.jsx)("span",{children:new Date(e.publishedAt).toLocaleDateString()}):null]}),(0,u.jsxs)("div",{className:"mt-5 flex flex-wrap items-center justify-between gap-3",children:[(0,u.jsx)("div",{className:"text-xs ".concat(V),children:"all"===p?"Multi-show browsing":"Scoped to ".concat(p)}),(0,u.jsxs)("button",{type:"button",onClick:()=>Y(e),className:"inline-flex items-center gap-2 rounded-full bg-[#FFB52B] px-4 py-2 font-headlines text-sm font-semibold text-[#232E3F] shadow-[0_16px_32px_-22px_rgba(255,181,43,0.88)] transition hover:-translate-y-0.5 hover:bg-[#FFC54D]",children:[(0,u.jsx)(Po,{className:"h-4 w-4"}),"Open at question"]})]})]},e.id)})})]},e.topic)),U?(0,u.jsx)("div",{ref:M,className:"flex justify-center py-2",children:(0,u.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full px-4 py-2 text-sm ".concat(V),children:[(0,u.jsx)(Lo,{className:"h-4 w-4 ".concat(N?"animate-spin":"")}),"Loading more questions as you scroll"]})}):null]})})]})}):null},uA=e=>{let{isOpen:t,onClose:n,token:r,isDarkMode:s}=e;const[i,o]=(0,a.useState)(null),[l,c]=(0,a.useState)(!1),[d,m]=(0,a.useState)(null),[h,p]=(0,a.useState)(null),[g,x]=(0,a.useState)(""),[f,b]=(0,a.useState)(new Set),[y,v]=(0,a.useState)(new Set),[w,k]=(0,a.useState)(!1),[j,D]=(0,a.useState)(!0),C=(0,a.useCallback)(async()=>
2{if(r){c(!0),m(null);try{const e=await Vm.getSessionStorageSummary(r,void 0,"all",{contentSource:"all",contentVisibility:"all",includeExternal:!0});o(e)}catch(e){m(e.message||"Failed to load hosted media inventory")}finally{c(!1)}}},[r]);(0,a.useEffect)(()=>{t&&C()},[t,C]),(0,a.useEffect)(()=>{t||(x(""),b(new Set),v(new Set),p(null),m(null),D(!0))},[t]);const N=e=>{const t=Number(e||0);if(t<=0)return"0 B";const n=["B","KB","MB","GB","TB"];let a=t,r=0;for(;a>=1024&&r<n.length-1;)a/=1024,r+=1;const s=0===r?0:a>=10?1:2;return"".concat(a.toFixed(s)," ").concat(n[r])},F=e=>{const t=Number(e||0);return t<=0?"$0.00/mo":t<.01?"<$0.01/mo":"$".concat(t.toFixed(t<1?2:1),"/mo")},S=(0,a.useMemo)(()=>{const e=((null===i||void 0===i?void 0:i.sessions)||[]).filter(e=>(e.totalBytes||0)>0),t=g.trim().toLowerCase();return e.filter(e=>{if(!t)return!0;return[e.title,e.filename,e.showTitle,e.familyTitle,e.familySlug,e.sessionId,...(e.arrangementRefs||[]).map(e=>e.arrangementTitle)].filter(Boolean).join(" ").toLowerCase().includes(t)})},[g,i]),E=(0,a.useMemo)(()=>{const e=new Map;for(const n of S){var t;const a=n.familySlug?"family:".concat(n.familySlug):"session:".concat(n.sessionId);e.has(a)||e.set(a,[]),null===(t=e.get(a))||void 0===t||t.push(n)}return[...e.entries()].map(e=>{let[t,n]=e;const a=[...n].sort((e,t)=>{var n,a;const r=null!==(n=e.familyVersionNumber)&&void 0!==n?n:-1,s=null!==(a=t.familyVersionNumber)&&void 0!==a?a:-1;if(s!==r)return s-r;const i=(t.totalBytes||0)-(e.totalBytes||0);return 0!==i?i:(t.estimatedMonthlyStorageCostUsd||0)-(e.estimatedMonthlyStorageCostUsd||0)}),r=a.filter(e=>!j||"blocked_by_arrangements"!==e.cleanupReason);if(0===r.length)return null;const s=a[0],i=a.reduce((e,t)=>e+Number(t.totalBytes||0),0),o=a.reduce((e,t)=>e+Number(t.estimatedMonthlyStorageCostUsd||0),0),l=a.reduce((e,t)=>e+(t.hostedMediaDeleteEligible?Number(t.totalBytes||0):0),0),c=a.filter(e=>e.hostedMediaDeleteEligible).length,d=a.filter(e=>e.arrangementRefCount>0).length,u=j?a.filter(e=>"blocked_by_arrangements"===e.cleanupReason).length:0,m=r.filter(e=>e.hostedMediaDeleteEligible).map(e=>e.sessionId);return{key:t,isFamily:!(null===s||void 0===s||!s.familySlug)&&a.length>1,familySlug:(null===s||void 0===s?void 0:s.familySlug)||null,title:null!==s&&void 0!==s&&s.familySlug&&a.length>1?(null===s||void 0===s?void 0:s.familyTitle)||(null===s||void 0===s?void 0:s.title)||(null===s||void 0===s?void 0:s.sessionId):(null===s||void 0===s?void 0:s.title)||(null===s||void 0===s?void 0:s.sessionId),latest:s,members:a,visibleMembers:r,totalBytes:i,totalCostUsd:o,eligibleBytes:l,eligibleCount:c,arrangementBlockedCount:d,blockedHiddenCount:u,selectableMemberIds:m}}).filter(e=>null!==e).sort((e,t)=>{const n=t.eligibleBytes-e.eligibleBytes;if(0!==n)return n;const a=t.eligibleCount-e.eligibleCount;if(0!==a)return a;const r=t.totalBytes-e.totalBytes;return 0!==r?r:t.totalCostUsd-e.totalCostUsd})},[j,S]),A=(0,a.useMemo)(()=>E.flatMap(e=>e.visibleMembers).filter(e=>e.hostedMediaDeleteEligible),[E]),T=(0,a.useMemo)(()=>S.filter(e=>f.has(e.sessionId)),[S,f]),M=(0,a.useMemo)(()=>T.reduce((e,t)=>e+Number(t.totalBytes||0),0),[T]),_=(0,a.useMemo)(()=>T.reduce((e,t)=>e+Number(t.estimatedMonthlyStorageCostUsd||0),0),[T]),B=e=>{switch(e.cleanupReason){case"safe_to_delete":case"safe_direct_youtube":case"safe_newer_family_hosted":case"safe_newer_family_youtube":case"safe_newer_family_published":return"Safe to delete";case"blocked_by_arrangements":return"Blocked by arrangements";case"no_youtube_fallback":case"no_video_fallback":return"No video fallback";case"no_hosted_media":return"No hosted media";default:return"Needs review"}},I=e=>{switch(e.cleanupReason){case"safe_to_delete":case"safe_direct_youtube":case"safe_newer_family_hosted":case"safe_newer_family_youtube":case"safe_newer_family_published":return s?"border-emerald-400/30 bg-emerald-500/10 text-emerald-200":"border-emerald-200 bg-emerald-50 text-emerald-700";case"blocked_by_arrangements":return s?"border-amber-400/30 bg-amber-500/10 text-amber-200":"border-amber-200 bg-amber-50 text-amber-700";default:return s?"border-slate-500/30 bg-slate-500/10 text-slate-200":"border-slate-200 bg-slate-100 text-slate-700"}},P=s?"border-[#344052] bg-[#232E3F] text-[#F4F4F4]":"border-[#D6DCE4] bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(244,244,244,0.96))] text-[#232E3F]",L=s?"border-[#344052] bg-[#202A3A]/90 text-[#F4F4F4]":"border-[#D6DCE4] bg-white/[0.92] text-[#232E3F]",R=s?"text-[#A9B4C3]":"text-[#6B788B]",z=s?"border-white/[0.12] bg-white/[0.08] text-[#F4F4F4] placeholder:text-white/[0.4]":"border-[#D6DCE4] bg-white/[0.92] text-[#232E3F] placeholder:text-[#7B8798]",O=e=>{switch(e.cleanupScope){case"source_and_proxy":return"Deletes hosted source + proxy";case"source":return"Deletes hosted source video";case"proxy":return"Deletes hosted proxy only";default:return"No hosted video to remove"}},U=e=>{switch(e.cleanupReason){case"safe_direct_youtube":return"Safe to delete: this only removes MLST-hosted video for this session. Audio, transcript, and metadata stay intact, and YouTube already covers video playback.";case"safe_newer_family_youtube":return"Safe to delete: a newer family version".concat(e.newerFamilyVersionNumber?" (v".concat(e.newerFamilyVersionNumber,")"):""," already has YouTube playback, so this older hosted video copy can be removed.");case"safe_newer_family_hosted":return"Safe to delete: a newer family version".concat(e.newerFamilyVersionNumber?" (v".concat(e.newerFamilyVersionNumber,")"):""," still has hosted video playback, so this older hosted copy is redundant.");case"safe_newer_family_published":return"Likely safe to delete: a newer family version".concat(e.newerFamilyVersionNumber?" (v".concat(e.newerFamilyVersionNumber,")"):""," is already published, so this older hosted video copy is probably redundant.");case"blocked_by_arrangements":return"Blocked: active arrangements still reference this session\u2019s video source. Deleting it would remove MLST-hosted video for those clips and make the arrangement harder to maintain.";case"no_video_fallback":return"Keep for now: deleting this would only remove in-app video playback, but there is no YouTube or newer published family version to fall back to yet.";case"no_hosted_media":return"Nothing to clean up: no MLST-hosted session video remains for this session.";default:return"Needs review before deleting any hosted video."}},V=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{nested:n=!1,groupTitle:a}=t,r=f.has(e.sessionId),i=e.hostedMediaDeleteEligible,o=e.showSlug&&"mlst"!==e.showSlug,l=e.title&&e.title!==a?e.title:null;return(0,u.jsxs)("div",{className:"rounded-[22px] border px-4 py-4 shadow-[0_18px_34px_-26px_rgba(35,46,63,0.3)] ".concat(s?"border-[#344052] bg-[#182231]/94":"border-[#D6DCE4] bg-white/[0.95]"," ").concat(n?"ml-0 md:ml-5":""),children:[(0,u.jsxs)("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[(0,u.jsxs)("div",{className:"flex items-start gap-3",children:[(0,u.jsx)("input",{type:"checkbox",checked:r,disabled:!i,onChange:()=>{return t=e.sessionId,void b(e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});var t}
2,className:"mt-1 h-4 w-4 rounded border-gray-300"}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[e.familyVersionNumber?(0,u.jsxs)("span",{className:"rounded-full border px-2 py-0.5 text-[11px] font-semibold ".concat(s?"border-white/[0.12] bg-white/[0.08] text-white/85":"border-[#D6DCE4] bg-[#F8F8F7] text-[#445067]"),children:["v",e.familyVersionNumber]}):null,(0,u.jsx)("span",{className:"rounded-full border px-2 py-0.5 text-[11px] font-semibold ".concat(I(e)),children:B(e)}),e.hasYoutubeVideo&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] ".concat(s?"border-red-400/30 bg-red-500/10 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:[(0,u.jsx)(Au,{className:"h-3 w-3"}),"YouTube"]}),e.publishedToHomepage&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] ".concat(s?"border-brand-yellow/30 bg-brand-yellow/10 text-brand-yellow":"border-[#F2D9A6] bg-[#FFF6DB] text-[#A36A00]"),children:[(0,u.jsx)(Po,{className:"h-3 w-3"}),"Published"]})]}),l?(0,u.jsx)("p",{className:"mt-2 font-headlines text-sm font-semibold",children:l}):null,(0,u.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 font-body text-xs ".concat(R),children:[(0,u.jsx)("span",{children:e.sessionId}),o?(0,u.jsx)("span",{children:e.showTitle}):null]})]})]}),(0,u.jsxs)("div",{className:"grid gap-3 font-body text-sm lg:min-w-[300px] lg:grid-cols-2",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"font-headlines text-[10px] uppercase tracking-[0.16em] ".concat(R),children:"Hosted video"}),(0,u.jsx)("div",{className:"font-headlines text-base font-semibold",children:N(e.totalBytes)}),(0,u.jsxs)("div",{className:"text-xs ".concat(R),children:["Source ",N(e.sourceBytes)," \xb7 Proxy ",N(e.proxyBytes)]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"font-headlines text-[10px] uppercase tracking-[0.16em] ".concat(R),children:"Est. monthly"}),(0,u.jsx)("div",{className:"font-headlines text-base font-semibold",children:F(e.estimatedMonthlyStorageCostUsd)}),(0,u.jsx)("div",{className:"text-xs ".concat(R),children:O(e)})]})]})]}),(0,u.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,u.jsxs)("div",{className:"rounded-2xl border px-3 py-3 text-sm ".concat(s?"border-[#344052] bg-[#101925]/72":"border-[#D6DCE4] bg-[#F8F8F7]"),children:[(0,u.jsxs)("div",{className:"mb-2 flex items-center gap-2 font-semibold",children:[e.hostedMediaDeleteEligible?(0,u.jsx)(Ej,{className:"h-4 w-4 text-emerald-500"}):(0,u.jsx)(fp,{className:"h-4 w-4 text-amber-500"}),"Video cleanup status"]}),(0,u.jsx)("p",{className:"font-body text-sm ".concat(R),children:U(e)})]}),e.arrangementShouldUpgradeToLatestFamilyVersion?(0,u.jsxs)("div",{className:"rounded-2xl border px-3 py-3 text-sm ".concat(s?"border-amber-400/30 bg-amber-500/10 text-amber-100":"border-amber-200 bg-amber-50 text-amber-800"),children:[(0,u.jsxs)("div",{className:"mb-1 flex items-center gap-2 font-semibold",children:[(0,u.jsx)(oj,{className:"h-4 w-4"}),"Arrangement update recommended"]}),(0,u.jsxs)("p",{className:"font-body text-sm",children:["This session is part of a family, but an arrangement still points at this older version.",e.familyLatestVersionNumber?" Latest family version is v".concat(e.familyLatestVersionNumber,"."):""]})]}):null,e.arrangementRefs&&e.arrangementRefs.length>0?(0,u.jsxs)("div",{className:"rounded-2xl border px-3 py-3 text-sm ".concat(s?"border-[#344052] bg-[#101925]/72":"border-[#D6DCE4] bg-[#F8F8F7]"),children:[(0,u.jsxs)("div",{className:"mb-2 flex items-center gap-2 font-semibold",children:[(0,u.jsx)(uj,{className:"h-4 w-4 text-[#355E9A]"}),"Arrangement dependencies"]}),(0,u.jsx)("div",{className:"space-y-1 font-body text-xs ".concat(R),children:e.arrangementRefs.map(e=>(0,u.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,u.jsx)("span",{className:"truncate",children:e.arrangementTitle}),(0,u.jsx)("span",{className:"shrink-0 uppercase",children:e.arrangementStatus||"unknown"})]},e.arrangementId))})]}):null]})]},e.sessionId)},H=(e,t,n,a)=>(0,u.jsxs)("div",{className:"rounded-[22px] border px-4 py-4 shadow-[0_20px_36px_-28px_rgba(35,46,63,0.28)] ".concat(L),children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(a),children:e}),(0,u.jsx)("div",{className:"mt-2 font-headlines text-2xl font-bold",children:t}),(0,u.jsx)("p",{className:"mt-1 font-body text-xs ".concat(R),children:n})]}),q=E.reduce((e,t)=>
2e+t.blockedHiddenCount,0);return t?(0,u.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col",children:[(0,u.jsx)("div",{className:"absolute inset-0 ".concat(s?"bg-[#101925]":"bg-[#F4F4F4]")}),(0,u.jsxs)("div",{className:"relative z-10 flex shrink-0 items-center justify-between border-b px-5 py-3 ".concat(P),children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)(OE,{size:18,className:"text-brand-yellow"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.22em] text-[#A36A00] dark:text-[#FFCC66]",children:"MLST Workspace"}),(0,u.jsx)("h2",{className:"font-headlines text-sm font-semibold",children:"Storage Cleanup"})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{C()},className:"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-semibold ".concat(s?"border-white/[0.12] bg-white/[0.08] text-[#F4F4F4] hover:bg-white/[0.14]":"border-[#D6DCE4] bg-white/[0.92] text-[#232E3F] hover:bg-[#EEF3FF]"),children:[(0,u.jsx)(vp,{className:"h-3.5 w-3.5 ".concat(l?"animate-spin":"")}),"Refresh"]}),d&&(0,u.jsx)("span",{className:"rounded-full bg-red-600/20 px-3 py-1.5 text-xs text-red-300 dark:text-red-200",children:d}),h&&(0,u.jsx)("span",{className:"rounded-full bg-brand-yellow/15 px-3 py-1.5 text-xs text-brand-yellow",children:h}),(0,u.jsx)("button",{onClick:n,className:"rounded-full p-2 transition-colors ".concat(s?"text-gray-400 hover:bg-white/[0.08]":"text-gray-600 hover:bg-[#E8ECF1]"),children:(0,u.jsx)(Pu,{size:18})})]})]}),(0,u.jsx)("div",{className:"relative z-10 flex-1 overflow-y-auto ".concat(s?"bg-[#101925] text-[#F4F4F4]":"bg-[#F4F4F4] text-[#232E3F]"),children:(0,u.jsxs)("div",{className:"mx-auto max-w-7xl px-6 pb-10",children:[(0,u.jsxs)("div",{className:"sticky top-0 z-20 -mx-6 mb-6 border-b px-6 py-5 backdrop-blur-xl ".concat(s?"border-white/[0.08] bg-[#101925]/92":"border-[#D6DCE4] bg-[#F4F4F4]/94"),children:[(0,u.jsxs)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-4",children:[H("Hosted media",N(null===i||void 0===i?void 0:i.summary.totalBytes),"".concat((null===i||void 0===i?void 0:i.summary.sessionsWithHostedMedia)||0," session(s) with MLST-hosted video"),"text-[#A36A00] dark:text-[#FFCC66]"),H("Est. monthly",F(null===i||void 0===i?void 0:i.summary.estimatedMonthlyStorageCostUsd),"Source ".concat(N(null===i||void 0===i?void 0:i.summary.totalSourceBytes)," \xb7 Proxy ").concat(N(null===i||void 0===i?void 0:i.summary.totalProxyBytes)),"text-[#355E9A] dark:text-[#BCD7FF]"),H("Reclaimable now",N(null===i||void 0===i?void 0:i.summary.hostedMediaDeleteEligibleBytes),"".concat((null===i||void 0===i?void 0:i.summary.hostedMediaDeleteEligibleCount)||0," safe deletion candidate(s)"),"text-[#2D7250] dark:text-[#9EE0BD]"),H("Selection",N(M),"".concat(f.size," selected \xb7 ").concat(F(_)),"text-[#B54747] dark:text-[#FFB3B3]")]}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[(0,u.jsxs)("div",{className:"relative min-w-[280px] flex-1",children:[(0,u.jsx)(Mu,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 ".concat(R)}),(0,u.jsx)("input",{value:g,onChange:e=>x(e.target.value),placeholder:"Search titles, families, filenames, arrangements",className:"w-full rounded-2xl border py-3 pl-11 pr-4 font-body text-sm ".concat(z)})]}),(0,u.jsx)("button",{type:"button",onClick:()=>D(e=>!e),className:"rounded-full border px-4 py-2 font-headlines text-sm font-semibold ".concat(j?s?"border-amber-400/30 bg-amber-500/10 text-amber-200":"border-amber-200 bg-amber-50 text-amber-800":s?"border-white/[0.12] bg-white/[0.08] hover:bg-white/[0.14]":"border-[#D6DCE4] bg-white/[0.92] hover:bg-[#EEF3FF]"),children:j?"Hiding arrangement-blocked":"Show arrangement-blocked"}),(0,u.jsx)("button",{type:"button",onClick:()=>{b(new Set(A.map(e=>e.sessionId)))},className:"rounded-full border px-4 py-2 font-headlines text-sm font-semibold ".concat(s?"border-white/[0.12] bg-white/[0.08] hover:bg-white/[0.14]":"border-[#D6DCE4] bg-white/[0.92] hover:bg-[#
2EEF3FF]"),children:"Select reclaimable"}),(0,u.jsx)("button",{type:"button",onClick:()=>b(new Set),className:"rounded-full border px-4 py-2 font-headlines text-sm font-semibold ".concat(s?"border-white/[0.12] bg-white/[0.08] hover:bg-white/[0.14]":"border-[#D6DCE4] bg-white/[0.92] hover:bg-[#EEF3FF]"),children:"Clear"}),(0,u.jsxs)("button",{type:"button",onClick:async()=>{if(0!==f.size&&!w&&window.confirm("Delete MLST-hosted session video for ".concat(f.size," session(s)? This preserves audio, transcript, metadata, and share links. It only removes hosted video copies that are no longer needed."))){k(!0),m(null),p(null);try{const e=new Map(T.map(e=>[e.sessionId,e])),t=await Vm.deleteHostedVideoMediaBatch([...f],r),n=t.deletedSessionIds.reduce((t,n)=>{var a;return t+Number((null===(a=e.get(n))||void 0===a?void 0:a.totalBytes)||0)},0),a=t.deletedTotalBytes>0?t.deletedTotalBytes:n;if(0===t.deletedSessionIds.length){const e=t.skipped.length>0?" ".concat(t.skipped.length," session(s) were skipped by the safety checks."):"";m("No hosted video was deleted.".concat(e))}else{const e=a>0?"Deleted ".concat(N(a)):"Deleted hosted video",n=t.skipped.length>0?" ".concat(t.skipped.length," skipped."):"";p("".concat(e," across ").concat(t.deletedSessionIds.length," session(s).").concat(n))}b(new Set),await C(),window.dispatchEvent(new CustomEvent("rescript-session-storage-updated"))}catch(e){m(e.message||"Failed to delete hosted media")}finally{k(!1)}}},disabled:0===f.size||w,className:"inline-flex items-center gap-2 rounded-full bg-[#B54747] px-4 py-2 text-sm font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",children:[w?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(kp,{className:"h-4 w-4"}),"Delete selected video copies"]})]}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3 text-xs ".concat(R),children:[(0,u.jsx)("span",{children:"Sorted by reclaimable bytes, largest first."}),j&&q>0?(0,u.jsxs)("span",{children:[q," arrangement-blocked version(s) hidden"]}):null,(0,u.jsx)("span",{children:"This tool only removes MLST-hosted video copies. Audio, transcript, metadata, and share links stay intact."}),(0,u.jsx)("span",{children:"Monthly cost is an estimate over managed hosted video bytes; the deeper EFS cache audit is tracked separately."})]})]}),l?(0,u.jsxs)("div",{className:"flex min-h-[45vh] items-center justify-center font-body text-sm ".concat(R),children:[(0,u.jsx)(Lo,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading hosted media inventory\u2026"]}):0===E.length?(0,u.jsx)("div",{className:"flex min-h-[45vh] items-center justify-center",children:(0,u.jsxs)("div",{className:"max-w-md rounded-[24px] border px-6 py-8 text-center shadow-[0_20px_40px_-28px_rgba(35,46,63,0.25)] ".concat(L),children:[(0,u.jsx)(OE,{className:"mx-auto h-8 w-8 text-brand-yellow"}),(0,u.jsx)("div",{className:"mt-3 font-headlines text-lg font-semibold",children:"No hosted session video matched"}),(0,u.jsx)("p",{className:"mt-2 font-body text-sm ".concat(R),children:"Nothing currently matches this search and filter combination."})]})}):(0,u.jsx)("div",{className:"space-y-4",children:E.map(e=>{const t=y.has(e.key),n=e.isFamily&&!t?e.visibleMembers.slice(0,1):e.visibleMembers,a=e.selectableMemberIds.filter(e=>f.has(e)).length,r=e.selectableMemberIds.length>0&&a===e.selectableMemberIds.length;return(0,u.jsxs)("div",{className:"rounded-[26px] border p-5 shadow-[0_22px_42px_-30px_rgba(35,46,63,0.35)] ".concat(s?"border-[#344052] bg-[#162131]/96":"border-[#D6DCE4] bg-white/[0.97]"),children:[(0,u.jsxs)("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[e.isFamily?(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] ".concat(s?"border-brand-yellow/30 bg-brand-yellow/10 text-brand-yellow":"border-[#F2D9A6] bg-[#FFF6DB] text-[#A36A00]"),children:[(0,u.jsx)(ck,{className:"h-3 w-3"}),"Episode family"]}):null,(0,u.jsx)("p",{className:"font-headlines text-lg font-semibold",children:e.title})]}),(0,u.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs ".concat(R),children:[(0,u.jsxs)("span",{children:[e.members.length," version",1===e.members.length?"":"s"]}),(0,u.jsxs)("span",{children:[e.eligibleCount," reclaimable"]}),e.arrangementBlockedCount>0?(0,u.jsxs)("span",{children:[e.arrangementBlockedCount," blocked by arrangements"]}):null,e.blockedHiddenCount>0?(0,u.jsxs)("span",{children:[e.blockedHiddenCount," hidden by current filter"]}):null]}),e.members.some(e=>e.arrangementShouldUpgradeToLatestFamilyVersion)?(0,u.jsxs)("div",{className:"mt-3 inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs ".concat(s?"border-amber-400/30 bg-amber-500/10 text-amber-200":"border-amber-200 bg-amber-50 text-amber-800"),children:[(0,u.jsx)(oj,{className:"h-3.5 w-3.5"}),"An arrangement still points at an older family version"]}):null]}),(0,u.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3 xl:min-w-[460px]",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"font-headlines text-[10px] uppercase tracking-[0.16em] ".concat(R),children:"Reclaimable now"}),(0,u.jsx)("div",{className:"font-headlines text-lg font-semibold",children:N(e.eligibleBytes)}),(0,u.jsxs)("div",{className:"text-xs ".concat(R),children:[e.eligibleCount," version(s) currently safe"]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"font-headlines text-[10px] uppercase tracking-[0.16em] ".concat(R),children:"Hosted storage"}),(0,u.jsx)("div",{className:"font-headlines text-lg font-semibold",children:N(e.totalBytes)}),(0,u.jsx)("div",{className:"text-xs ".concat(R),children:"Across the full family stack"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"font-headlines text-[10px] uppercase tracking-[0.16em] ".concat(R),children:"Est. monthly"}),(0,u.jsx)("div",{className:"font-headlines text-lg font-semibold",children:F(e.totalCostUsd)}),(0,u.jsx)("div",{className:"text-xs ".concat(R),children:a>0?"".concat(a," selected in this family"):"Most recent visible version stays on top"})]})]})]}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[e.selectableMemberIds.length>0?(0,u.jsx)("button",{type:"button",onClick:()=>(e=>{0!==e.selectableMemberIds.length&&b(t=>{const n=new Set(t),a=e.selectableMemberIds.every(e=>n.has(e));for(const r of e.selectableMemberIds)a?n.delete(r):n.add(r);return n})})(e),className:"rounded-full border px-4 py-2 text-sm font-semibold ".concat(r?s?"border-emerald-400/30 bg-emerald-500/10 text-emerald-200":"border-emerald-200 bg-emerald-50 text-emerald-700":s?"border-white/[0.12] bg-white/[0.08] hover:bg-white/[0.14]":"border-[#D6DCE4] bg-white/[0.92] hover:bg-[#
2EEF3FF]"),children:r?"Clear family selection":"Select ".concat(e.selectableMemberIds.length," reclaimable version").concat(1===e.selectableMemberIds.length?"":"s")}):(0,u.jsx)("div",{className:"rounded-full border px-4 py-2 text-sm ".concat(s?"border-white/[0.08] bg-white/[0.04] text-white/60":"border-[#D6DCE4] bg-[#F8F8F7] text-[#6B788B]"),children:"No reclaimable versions in this group yet"}),e.isFamily&&e.visibleMembers.length>1?(0,u.jsxs)("button",{type:"button",onClick:()=>{return t=e.key,void v(e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});var t},className:"inline-flex items-center gap-2 rounded-full border px-3 py-2 text-sm font-semibold ".concat(s?"border-white/[0.12] bg-white/[0.08] text-[#F4F4F4]":"border-[#D6DCE4] bg-white text-[#232E3F]"),children:[t?(0,u.jsx)(Tu,{className:"h-3.5 w-3.5"}):(0,u.jsx)(wd,{className:"h-3.5 w-3.5"}),t?"Collapse family":"Expand ".concat(e.visibleMembers.length-1," older version").concat(e.visibleMembers.length-1===1?"":"s")]}):null]}),(0,u.jsx)("div",{className:"mt-4 space-y-3",children:n.map(t=>V(t,{nested:e.isFamily,groupTitle:e.title}))})]},e.key)})})]})})]}):null},mA=Mo("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),hA=Mo("file-pen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]),pA=Mo("square-menu",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 8h10",key:"1jw688"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M7 16h10",key:"wp8him"}]]),gA=Mo("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),xA=Mo("user-cog",[["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m14.305 16.53.923-.382",key:"1itpsq"}],["path",{d:"m15.228 13.852-.923-.383",key:"eplpkm"}],["path",{d:"m16.852 12.228-.383-.923",key:"13v3q0"}],["path",{d:"m16.852 17.772-.383.924",key:"1i8mnm"}],["path",{d:"m19.148 12.228.383-.923",key:"1q8j1v"}],["path",{d:"m19.53 18.696-.382-.924",key:"vk1qj3"}],["path",{d:"m20.772 13.852.924-.383",key:"n880s0"}],["path",{d:"m20.772 16.148.924.383",key:"1g6xey"}],["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),fA=Mo("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]),bA=[{id:"ttml",label:"Ranking and Metadata",icon:(0,u.jsx)(YE,{size:18})},{id:"transcript",label:"Timeline View",icon:(0,u.jsx)(gp,{size:18})},{id:"readable",label:"Transcript",icon:(0,u.jsx)(Ap,{size:18})},{id:"chat",label:"Chat with Transcript",icon:(0,u.jsx)(Fp,{size:18})},{id:"agent",label:"Agent",icon:(0,u.jsx)(Po,{size:18})},{id:"narrative",label:"Topic Map",icon:(0,u.jsx)(mA,{size:18})},{id:"description",label:"Description",icon:(0,u.jsx)(hA,{size:18})},{id:"context",label:"Context",icon:(0,u.jsx)(pA,{size:18})},{id:"questions",label:"Questions",icon:(0,u.jsx)("span",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-full border border-current text-[10px] font-bold leading-none",children:"Q"})},{id:"cuts",label:"Cuts",icon:(0,u.jsx)(ck,{size:18})}],yA=e=>{let{isOpen:t,onClose:n,isDarkMode:a,toggleDarkMode:r,userName:s,onLogout:i,onHome:o,sessionTitle:l,sharePermissions:c,shareMetadata:d,activeTabId:m,onTabChange:h,availableTabIds:p,selectedTtmlName:g,hasVideoUrl:x,isYoutubePlayerVisible:f,onToggleYoutubePlayer:b,hasSpeakers:y,onEditSpeakers:v,onOpenSettings:w,isOfflineAvailable:k=!1,isOfflineMode:j=!1,isOfflineActionPending:D=!1,offlineActionStatusLabel:C,onToggleOfflineAvailability:N,onCopyOfflineDiagnostics:F}=e;const E=bA.filter(e=>!p||p.includes(e.id));return(0,u.jsx)(S,{children:t&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-black/55",onClick:n}),(0,u.jsxs)(Do.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.24},className:"fixed inset-y-0 right-0 z-50 flex w-[20rem] max-w-[86vw] flex-col shadow-2xl ".concat(a?"bg-gray-900 text-gray-100":"bg-white text-gray-900"),style:{paddingTop:"var(--app-mobile-top-offset)",paddingBottom:"var(--app-mobile-bottom-offset)"},children:[(0,u.jsxs)("div",{className:"flex items-center justify-between border-b px-4 py-4 ".concat(a?"border-gray-800":"border-gray-200"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-lg font-semibold",children:"Session Menu"}),(0,u.jsx)("p",{className:"text-xs ".concat(a?"text-gray-400":"text-gray-500"),children:"Jump between tabs and session controls."})]}),(0,u.jsx)("button",{type:"button",onClick:n,className:"rounded-xl p-2 transition-colors ".concat(a?"hover:bg-gray-800":"hover:bg-gray-100"),title:"Close menu",children:(0,u.jsx)(Pu,{size:20})})]}),(0,u.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:[l&&(0,u.jsxs)("div",{className:"rounded-2xl px-4 py-3 ".concat(a?"bg-gray-800":"bg-gray-100"),children:[(0,u.jsx)("div",{className:"text-xs uppercase tracking-[0.18em] ".concat(a?"text-gray-400":"text-gray-500"),children:"Session"}),(0,u.jsx)("div",{className:"mt-2 text-sm font-semibold leading-6",children:l})]}),s&&!c&&(0,u.jsxs)("div",{className:"mt-4 rounded-2xl px-4 py-3 text-sm ".concat(a?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"),children:["Signed in as ",s]}),g&&(0,u.jsxs)("div",{className:"mt-4 rounded-2xl px-4 py-3 text-sm ".concat(a?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"),children:["Active metadata: ",g.replace(/\.ttml$/i,"")]}),c&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl px-4 py-4 ".concat(a?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"),children:(0,u.jsxs)("div",{className:"flex items-start gap-3",children:[(0,u.jsx)(jp,{size:18,className:"mt-0.5 shrink-0 text-brand-yellow"}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{className:"font-medium",children:"Public Share"}),(null===d||void 0===d?void 0:d.label)&&(0,u.jsx)("div",{className:"mt-1 text-xs ".concat(a?"text-gray-300":"text-gray-600"),children:d.label}),(0,u.jsxs)("div",{className:"mt-2 space-y-1 text-xs ".concat(a?"text-gray-400":"text-gray-500"),children:[(null===d||void 0===d?void 0:d.expiresAt)&&(0,u.jsxs)("div",{children:["Expires ",new Date(d.expiresAt).toLocaleString()]}),(null===d||void 0===d?void 0:d.maxViewers)&&(0,u.jsxs)("div",{children:["Viewers ",d.currentViewers||0," / ",d.maxViewers]}),(null===d||void 0===d?void 0:d.maxTotalViews)&&(0,u.jsxs)("div",{children:["Views ",d.totalViews||0," / ",d.maxTotalViews]})]}),(0,u.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2 text-[11px] font-medium ".concat(a?"text-gray-300":"text-gray-600"),children:[(0,u.jsxs)("span",{className:"rounded-full px-2.5 py-1 ".concat(a?"bg-gray-700":"bg-white"),children:["Transcript ",c.transcriptsEnabled?"On":"Off"]}),(0,u.jsxs)("span",{className:"rounded-full px-2.5 py-1 ".concat(a?"bg-gray-700":"bg-white"),children:["Comments ",c.commentsRead?"On":"Off"]}),c.rankingEnabled&&(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 ".concat(a?"bg-gray-700":"bg-white"),children:"Topic Map On"}),c.questionsEnabled&&(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 ".concat(a?"bg-gray-700":"bg-white"),children:"Questions On"})]})]})]})}),(0,u.jsxs)("div",{className:"mt-6",children:[(0,u.jsx)("div",{className:"px-1 text-xs font-semibold uppercase tracking-[0.18em] ".concat(a?"text-gray-400":"text-gray-500"),children:"Navigation"}),(0,u.jsx)("div",{className:"mt-3 space-y-2",children:E.map(e=>(0,u.jsxs)("button",{type:"button",onClick:()=>{null===h||void 0===h||h(e.id),n()},className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(m===e.id?a?"bg-primary-600 text-white":"bg-primary-100 text-primary-700":a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[e.icon,(0,u.jsx)("span",{children:e.label})]},e.id))})]}),(0,u.jsxs)("div",{className:"mt-6",children:[(0,u.jsx)("div",{className:"px-1 text-xs font-semibold uppercase tracking-[0.18em] ".concat(a?"text-gray-400":"text-gray-500"),children:"Actions"}),(0,u.jsxs)("div",{className:"mt-3 space-y-2",children:[!c&&w&&(0,u.jsxs)("button",{type:"button",onClick:()=>{w(),n()},className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[(0,u.jsx)(MN,{size:18}),(0,u.jsx)("span",{children:"Session Settings"})]}),N&&(0,u.jsxs)("button",{type:"button",onClick:()=>{N()},disabled:D,className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"," ").concat(D?"cursor-wait opacity-70":""),children:[D?(0,u.jsx)(Lo,{size:18,className:"animate-spin"}):k?(0,u.jsx)(HE,{size:18}):(0,u.jsx)(qE,{size:18}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{children:D?"Updating Offline Copy":k?"Remove Offline Copy":"Make Available Offline"}),D&&C&&(0,u.jsx)("div",{className:"mt-0.5 text-xs ".concat(a?"text-gray-400":"text-gray-500"),children:C})]})]}),F&&(0,u.jsxs)("button",{type:"button",onClick:()=>{F()},className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[(0,u.jsx)(Np,{size:18}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{children:"Copy Offline Diagnostics"}),(0,u.jsx)("div",{className:"mt-0.5 text-xs ".concat(a?"text-gray-400":"text-gray-500"),children:"Copies the recent offline save log so you can paste it here."})]})]}),x&&b&&(0,u.jsxs)("button",{type:"button",onClick:()=>{b()},className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[(0,u.jsx)(gA,{size:18}),(0,u.jsx)("span",{children:f?"Hide Video":"Show Video"})]}),!c&&y&&v&&(0,u.jsxs)("button",{type:"button",onClick:()=>{v(),n()},className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[(0,u.jsx)(xA,{size:18}),(0,u.jsx)("span",{children:"Edit Speaker Names"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{r()},className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[a?(0,u.jsx)(LE,{size:18}):(0,u.jsx)(RE,{size:18}),(0,u.jsx)("span",{children:a?"Light Mode":"Dark Mode"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{o(),n()},className:"flex w-full items-center gap-3 rounded-2xl px-4 py-3 text-left text-sm transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[(0,u.jsx)(Io,{size:18}),(0,u.jsx)("span",{children:c?"All Videos":"Home"})]}),!c&&(0,u.jsxs)("button",{type:"button",onClick:()=>{i(),n()},className:"flex w-full items-center gap-3 rounded-2xl bg-red-50 px-4 py-3 text-left text-sm text-red-600 transition-colors hover:bg-red-100 dark:bg-red-950/40 dark:text-red-300 dark:hover:bg-red-950/60",children:[(0,u.jsx)(fA,{size:18}),(0,u.jsx)("span",{children:"Logout"})]})]})]}),j&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl px-4 py-3 text-sm ".concat(a?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-700"),children:"Offline copy loaded. Video, chat, editing, and server actions are unavailable."})]})]})]})})};function vA(e,t){const n=String(e||"").trim(),a=String(t||"").trim();return n&&a&&n.toLowerCase()===a.toLowerCase()&&"[email protected]"===a?"Tim Scarfe":n||a||"User"}const wA=e=>{let{isDarkMode:t,name:n,email:r,picture:s,onLogout:i,actions:o=[]}=e;const[l,c]=(0,a.useState)(!1),d=(0,a.useRef)(null),m=(0,a.useMemo)(()=>vA(n,r),[n,r]),h=(0,a.useMemo)(()=>
2function(e,t){const n=vA(e,t),a=n.split(/\s+/).filter(Boolean);return a.length>=2?"".concat(a[0][0]||"").concat(a[1][0]||"").toUpperCase():n.slice(0,2).toUpperCase()}(n,r),[n,r]);return(0,a.useEffect)(()=>{if(!l)return;const e=e=>{var t;null!==(t=d.current)&&void 0!==t&&t.contains(e.target)||c(!1)},t=e=>{"Escape"===e.key&&c(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l]),(0,u.jsxs)("div",{className:"relative",ref:d,children:[(0,u.jsx)("button",{type:"button",onClick:()=>c(e=>!e),className:"flex h-10 w-10 items-center justify-center overflow-hidden rounded-full border transition-colors ".concat(t?"border-white/12 bg-[rgba(31,41,55,0.5)] backdrop-blur-xl hover:border-primary-400":"border-[rgba(214,220,228,0.84)] bg-[rgba(255,255,255,0.5)] backdrop-blur-[24px] hover:border-primary-500"),title:m,"aria-label":"Open profile menu","aria-haspopup":"menu","aria-expanded":l,children:s?(0,u.jsx)("img",{src:s,alt:m,className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):(0,u.jsx)("span",{className:"text-xs font-semibold font-headlines",children:h})}),l&&(0,u.jsxs)("div",{className:"absolute right-0 top-12 z-50 w-64 max-h-[calc(100dvh-100px)] overflow-y-auto rounded-2xl border shadow-[0_24px_52px_-30px_rgba(15,23,42,0.28)] backdrop-blur-2xl ".concat(t?"border-white/10 bg-[#111b2a] text-gray-100":"border-[rgba(214,220,228,0.84)] bg-white text-gray-900 backdrop-blur-[30px]"),role:"menu",children:[(0,u.jsx)("div",{className:"border-b px-4 py-4 ".concat(t?"border-white/10":"border-[#e5ebf2]"),children:(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("div",{className:"flex h-12 w-12 items-center justify-center overflow-hidden rounded-full ".concat(t?"bg-white/8":"bg-[rgba(255,255,255,0.5)] backdrop-blur-[24px]"),children:s?(0,u.jsx)("img",{src:s,alt:m,className:"h-full w-full object-cover",referrerPolicy:"no-referrer"}):(0,u.jsx)("span",{className:"text-sm font-semibold font-headlines",children:h})}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{className:"truncate text-sm font-semibold",children:m}),r&&(0,u.jsx)("div",{className:"truncate text-xs ".concat(t?"text-gray-400":"text-gray-500"),children:r})]})]})}),(0,u.jsxs)("div",{className:"p-2",children:[o.map(e=>(0,u.jsxs)("button",{type:"button",role:"menuitem",className:"flex w-full items-center gap-3 rounded-xl px-3 py-2 text-left text-sm transition-colors ".concat(t?"hover:bg-white/10":"hover:bg-gray-100"),onClick:()=>{c(!1),e.onClick()},children:[e.icon,(0,u.jsx)("span",{children:e.label})]},e.label)),(0,u.jsxs)("button",{type:"button",onClick:()=>{c(!1),i()},className:"flex w-full items-center gap-3 rounded-xl px-3 py-2 text-sm transition-colors ".concat(t?"text-red-300 hover:bg-red-500/10 hover:text-red-200":"text-red-600 hover:bg-[rgba(255,240,242,0.82)] hover:text-red-700"),role:"menuitem",children:[(0,u.jsx)(fA,{className:"h-4 w-4"}),(0,u.jsx)("span",{children:"Logout"})]})]})]})]})},kA=e=>{let{followOnly:t=!1}=e;const{collaborators:n,connectionState:a,followingParticipantId:r,followParticipant:s,stopFollowing:i}=nE();if("inactive"===a||0===n.length)return null;const o=n.slice(0,4),l=n.length-o.length,c=n.find(e=>e.id===r)||null;return t&&!c?null:(0,u.jsxs)("div",{className:"flex min-w-0 items-center gap-2 pr-1","aria-label":"".concat(n.length," collaborator").concat(1===n.length?"":"s"," present"),children:[c&&(0,u.jsxs)("button",{type:"button",className:"inline-flex h-8 min-w-0 max-w-[min(18rem,65vw)] items-center gap-1.5 rounded-full border border-amber-400/60 bg-amber-400/10 px-3 text-[11px] font-semibold text-slate-800 shadow-sm hover:bg-amber-400/20 focus:outline-none focus:ring-2 focus:ring-amber-400 dark:text-slate-100",onClick:i,title:"Stop following ".concat(JS(c)),"aria-label":"Stop following ".concat(JS(c)),children:[(0,u.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500 shadow-[0_0_6px_rgba(34,197,94,0.75)]"}),(0,u.jsx)("span",{className:"shrink-0",children:"Following"}),(0,u.jsx)("span",{className:"min-w-0 truncate",children:JS(c)}),(0,u.jsx)("span",{className:"shrink-0 font-bold text-amber-600 dar
2k:text-amber-300",children:"Stop"})]}),!t&&(0,u.jsxs)("div",{className:"flex items-center -space-x-2",children:[o.map(e=>{const t=JS(e),n=e.id===r;return(0,u.jsx)("button",{type:"button",className:"relative rounded-full transition-transform hover:z-10 hover:-translate-y-0.5 focus:z-10 focus:outline-none",onClick:()=>s(e.id),title:"".concat(n?"Stop following":"Follow"," ").concat(t),"aria-label":"".concat(n?"Stop following":"Follow"," ").concat(t," from collaborator list"),children:(0,u.jsx)(rE,{glyph:e.animal.glyph,color:e.animal.color,label:"".concat(t," \xb7 ").concat(e.playback.isPlaying?"playing":"paused"),picture:e.picture,isAnonymous:e.isAnonymous,initials:QS(e),size:34,isPlaying:e.playback.isPlaying,isFollowing:n,showPlaybackState:!0})},e.id)}),l>0&&(0,u.jsxs)("span",{className:"relative z-10 inline-flex h-8 min-w-8 items-center justify-center rounded-full border-2 border-white bg-[#314159] px-1 text-[10px] font-bold text-white shadow-md dark:border-[#111826]",children:["+",l]})]})]})};function jA(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return jA=function(e){this.s=e,this.n=e.next},jA.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return void 0===n?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return void 0===n?Promise.reject(e):t(n.apply(this.s,arguments))}},new jA(e)}const DA=Mo("settings-2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]),CA=Mo("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]),NA=Mo("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),FA=Mo("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),SA=[{key:"cli",label:"CLI",description:"Allow CLI and local tooling."},{key:"mcp",label:"MCP",description:"Allow MCP and automation integrations."},{key:"exports",label:"Exports",description:"Allow export and download workflows."},{key:"chat",label:"Chat",description:"Enable chat workflows in the app."},{key:"agent",label:"Agent",description:"Enable agent workflows and handoffs."},{key:"transcription",label:"Transcription",description:"Allow new transcription jobs."},{key:"videoGeneration",label:"Video Generation",description:"Allow video generation and rendering."},{key:"arrangementAudio",label:"Arrangement Audio",description:"Allow arrangement audio rendering."},{key:"showMp3",label:"Show MP3",description:"Allow show MP3 generation."}],EA=[{value:"reader",label:"Reader"},{value:"writer",label:"Writer"},{value:"org_admin",label:"Org Admin"},{value:"master",label:"Master"}],AA=[{value:"read",label:"Read"},{value:"write",label:"Write"},{value:"manage",label:"Manage"}];async function TA(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=new Headers(n.headers);void 0===n.body||a.has("Content-Type")||a.set("Content-Type","application/json"),t&&"cookie-session"!==t&&a.set("Authorization","Bearer ".concat(t));const r=await fetch("".concat("").concat(e),d(d({},n),{},{headers:a,credentials:n.credentials||"include"})),s=await r.text(),i=s?function(e){try{return JSON.parse(e)}catch(_H){return e}}(s):null;if(!r.ok){const e=i,t="object"===typeof e&&e&&(e.error||e.message)||"string"===typeof e&&e||"Request failed (".concat(r.status,")");throw new Error(t)}return i}function MA(e){return SA.reduce((t,n)=>{const a=e[n.key];return"allow"===a?t[n.key]=!0:"disable"===a&&(t[n.key]=!1),t},{})}function _A(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(Number(e||0))}function BA(e){return new Intl.NumberFormat("en-US").format(Number(e||0))}function IA(e){return new Intl.NumberFormat("en-US",{minimumFractionDigits:1,maximumFractionDigits:1}).format(Number(e||0))}function PA(e){const t=Number(e||0);if(t<1024)return"".concat(t," B");const n=["KB","MB","GB","TB"];let a=t/1024,r=0;for(;a>=1024&&r<n.length-1;)a/=1024,r+=1;return"".concat(a.toFixed(a>=100?0:1)," ").concat(n[r])}function LA(e){if(!e)return"Unknown";const t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short"}).format(t)}function RA(e){if(!e)return"No recent activity";const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=Date.now()-t.getTime(),a=6e4,r=36e5,s=24*r;return n<a?"Just now":n<r?"".concat(Math.max(1,Math.round(n/a))," min ago"):n<s?"".concat(Math.max(1,Math.round(n/r))," hr ago"):"".concat(Math.max(1,Math.round(n/s))," day").concat(1===Math.round(n/s)?"":"s"," ago")}function zA(e){var t;return(null===(t=EA.find(t=>t.value===e))||void 0===t?void 0:t.label)||e}function OA(e){return e?e.grants.map(e=>({id:e.id,email:e.email,accessLevel:e.accessLevel,grantedBy:e.grantedBy,createdAt:e.createdAt,updatedAt:e.updatedAt})):[]}function UA(e){let{isDarkMode:t,icon:n,label:a,value:r,hint:s}=e;return(0,u.jsxs)("div",{className:"rounded-2xl border p-4 ".concat(t?"border-[#41506A] bg-[#273244]/88":"border-[#
2E4D7BD] bg-[#FFF8EA]/90"),children:[(0,u.jsx)("div",{className:"mb-3 inline-flex h-10 w-10 items-center justify-center rounded-xl ".concat(t?"bg-[#1D2634] text-[#FFB52B]":"bg-white text-[#232E3F] shadow-[0_10px_18px_-16px_rgba(35,46,63,0.7)]"),children:n}),(0,u.jsx)("p",{className:"text-sm ".concat(t?"text-[#C6CDD8]":"text-[#566377]"),children:a}),(0,u.jsx)("p",{className:"mt-1 break-all text-base font-semibold",children:r}),s?(0,u.jsx)("p",{className:"mt-1 text-xs ".concat(t?"text-[#8D99A8]":"text-[#7A8593]"),children:s}):null]})}const VA=e=>{let{sessionId:t,sessionTitle:n,isActive:r}=e;const{token:s}=am(),{isDarkMode:i}=zu(),[o,l]=(0,a.useState)(null),[c,m]=(0,a.useState)(""),[h,p]=(0,a.useState)([]),[g,x]=(0,a.useState)(!1),[f,b]=(0,a.useState)(!1),[y,v]=(0,a.useState)(""),[w,k]=(0,a.useState)(""),j=!(null===o||void 0===o||!o.canManage),D=(0,a.useMemo)(()=>{if(!o)return!1;if(c.trim().toLowerCase()!==(o.ownerEmail||"").trim().toLowerCase())return!0;const e=OA(o).map(e=>"".concat(e.email.toLowerCase(),"|").concat(e.accessLevel)).sort(),t=h.filter(e=>e.email.trim()).map(e=>"".concat(e.email.trim().toLowerCase(),"|").concat(e.accessLevel)).sort();return e.length!==t.length||e.some((e,n)=>e!==t[n])},[o,h,c]),C=(0,a.useCallback)(async()=>{if(s){x(!0),v("");try{const e=await TA("/api/sessions/".concat(t,"/access"),s);l(e),m(e.ownerEmail||""),p(OA(e))}catch(e){v(e instanceof Error?e.message:"Failed to load access settings")}finally{x(!1)}}},[t,s]);(0,a.useEffect)(()=>{r&&t&&s&&C()},[r,t,s,C]);const N=(e,t)=>{p(n=>n.map((n,a)=>a===e?t(n):n))},F=i?"border-[#344052] bg-[#202A3A]/92 text-[#F4F4F4] shadow-[0_24px_44px_-30px_rgba(10,14,20,0.78)]":"border-[#D6DCE4] bg-white/[0.94] text-[#232E3F] shadow-[0_22px_42px_-30px_rgba(35,46,63,0.28)]",S=i?"border-[#41506A] bg-[#273244]/90":"border-[#E4D7BD] bg-[#FFF8EA]/90",E=i?"text-[#C6CDD8]":"text-[#566377]",A="w-full rounded-xl border px-3 py-2 text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/25 focus:border-[#FFB52B] ".concat(i?"border-[#445166] bg-[#1D2634] text-[#F4F4F4] placeholder:text-[#8693A6]":"border-[#CDD4DD] bg-white text-[#232E3F] placeholder:text-[#93A0B1]");return g&&!o?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)(vp,{className:"h-6 w-6 animate-spin text-[#FFB52B]"})}):(0,u.jsxs)("div",{className:"p-6",children:[(y||w)&&(0,u.jsx)("div",{className:"mb-4 rounded-2xl border p-4 ".concat(y?i?"border-[#8B4C4C] bg-[#331E21] text-[#F8C9C9]":"border-[#E6BBBB] bg-[#FFF2F1] text-[#9B4343]":i?"border-[#8F6A2B] bg-[#302717] text-[#FFE3A1]":"border-[#E7B14C] bg-[#FFF4D8] text-[#8B5B00]"),children:(0,u.jsxs)("div",{className:"flex items-start gap-3",children:[y?(0,u.jsx)(Lu,{className:"mt-0.5 h-5 w-5 shrink-0"}):(0,u.jsx)(Wm,{className:"mt-0.5 h-5 w-5 shrink-0"}),(0,u.jsx)("span",{className:"text-sm",children:y||w})]})}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(F),children:[(0,u.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"mb-2 inline-flex items-center gap-2 rounded-full px-3 py-1 text-xs font-medium ".concat(S),children:[(0,u.jsx)(FA,{className:"h-3.5 w-3.5"}),"Session Access"]}),(0,u.jsx)("h3",{className:"text-xl font-semibold",children:n||"Session access management"}),(0,u.jsx)("p",{className:"mt-2 text-sm ".concat(E),children:"Owners, org admins, and explicit session grants determine who can read, edit, or manage this session."})]}),(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{C()},className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(i?"border border-[#41506A] bg-[#273244] text-[#F4F4F4] hover:bg-[#2F3B4E]":"border border-[#D6DCE4] bg-white text-[#232E3F] hover:border-[#FFB52B]/50 hover:bg-[#FFF8EA]"),disabled:g,children:[(0,u.jsx)(vp,{className:"h-4 w-4 ".concat(g?"animate-spin":"")}),"Refresh"]}),j&&(0,u.jsxs)("button",{type:"button",onClick:async()=>{if(!s||!j)return;const e=c.trim().toLowerCase();if(!e)return void v("Owner email is required.");const n=new Set,a=[];for(const t of h){const e=t.email.trim().toLowerCase();if(e){if(n.has(e))return void v("Duplicate access entry for ".concat(e,"."));n.add(e),a.push({email:e,accessLevel:t.accessLevel})}}b(!0),v(""),k("");try{const n=await TA("/api/sessions/".concat(t,"/access"),s,{method:"PUT",body:JSON.stringify({ownerEmail:e,grants:a})});l(n),m(n.ownerEmail||""),p(OA(n)),k("Session access updated.")}catch(r){v(r instanceof Error?r.message:"Failed to update access settings")}finally{b(!1)}},disabled:!D||f,className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(!D||f?i?"cursor-not-allowed bg-[#273244] text-[#7C8899]":"cursor-not-allowed bg-[#EEF1F3] text-[#98A4B4]":"bg-[#FFB52B] text-[#232E3F] shadow-[0_18px_32px_-24px_rgba(255,181,43,0.9)] hover:bg-[#FFC54D]"),children:[(0,u.jsx)(Dh,{className:"h-4 w-4"}),f?"Saving\u2026":"Save Access"]})]})]}),o&&(0,u.jsxs)("div",{className:"mt-6 grid gap-3 md:grid-cols-3",children:[(0,u.jsx)(UA,{isDarkMode:i,icon:(0,u.jsx)(FA,{className:"h-5 w-5"}),label:"Your Session Access",value:o.currentUserAccess.canManage?"Manage":o.currentUserAccess.canWrite?"Write":"Read",hint:"Role: ".concat(zA(o.currentUserAccess.role))}),(0,u.jsx)(UA,{isDarkMode:i,icon:(0,u.jsx)(fh,{className:"h-5 w-5"}),label:"Owner",value:o.ownerEmail||"Unassigned",hint:o.currentUserAccess.isOwner?"You own this session":o.currentUserAccess.isOrgAdmin?"Org-admin access applies":"Owner retains manage access"}),(0,u.jsx)(UA,{isDarkMode:i,icon:(0,u.jsx)(fh,{className:"h-5 w-5"}),label:"Explicit Grants",value:String(o.grants.length),hint:j?"Grant read, write, or manage access":"Read-only view"})]})]}),o?(0,u.jsxs)("div",{className:"mt-4 rounded-3xl border p-5 ".concat(F),children:[(0,u.jsx)("div",{className:"flex items-start justify-between gap-4",children:(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-lg font-semibold",children:"Access List"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(E),children:"Direct grants are additive. Organization membership still governs broad baseline visibility."})]})}),j?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mt-5 rounded-2xl border p-4 ".concat(S),children:[(0,u.jsx)("label",{className:"block text-sm font-medium",children:"Owner email"}),(0,u.jsx)("input",{type:"email",value:c,onChange:e=>m(e.target.value),className:"".concat(A," mt-2"),placeholder:"[email protected]"}),(0,u.jsx)("p",{className:"mt-2 text-xs ".concat(E),children:"Ownership carries manage access even without an explicit grant."})]}),(0,u.jsx)("div",{className:"mt-5 space-y-3",children:0===h.length?(0,u.jsx)("div",{className:"rounded-2xl border p-4 ".concat(S),children:(0,u.jsx)("p",{className:E,
2children:"No explicit grants yet."})}):h.map((e,t)=>(0,u.jsx)("div",{className:"rounded-2xl border p-4 ".concat(S),children:(0,u.jsxs)("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_180px_auto]",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium",children:"Member email"}),(0,u.jsx)("input",{type:"email",value:e.email,onChange:e=>N(t,t=>d(d({},t),{},{email:e.target.value})),className:"".concat(A," mt-2"),placeholder:"[email protected]"}),(e.grantedBy||e.updatedAt||e.createdAt)&&(0,u.jsxs)("p",{className:"mt-2 text-xs ".concat(E),children:[e.grantedBy?"Granted by ".concat(e.grantedBy):"Explicit grant"," ",e.updatedAt||e.createdAt?"\xb7 ".concat(LA(e.updatedAt||e.createdAt)):""]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium",children:"Access level"}),(0,u.jsx)("select",{value:e.accessLevel,onChange:e=>N(t,t=>d(d({},t),{},{accessLevel:e.target.value})),className:"".concat(A," mt-2"),children:AA.map(e=>(0,u.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,u.jsx)("div",{className:"flex items-end",children:(0,u.jsxs)("button",{type:"button",onClick:()=>(e=>{p(t=>t.filter((t,n)=>n!==e))})(t),className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(i?"bg-[#3A2024] text-[#F1C3C6] hover:bg-[#4A2A2E]":"bg-[#FCEBEB] text-[#964E4E] hover:bg-[#F7DADA]"),children:[(0,u.jsx)(kp,{className:"h-4 w-4"}),"Remove"]})})]})},e.id||"".concat(e.email,"-").concat(t)))}),(0,u.jsx)("div",{className:"mt-4",children:(0,u.jsxs)("button",{type:"button",onClick:()=>p(e=>[...e,{email:"",accessLevel:"read"}]),className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat("bg-[#232E3F] text-[#F4F4F4] hover:bg-[#2F3B4E]"),children:[(0,u.jsx)(ik,{className:"h-4 w-4"}),"Add Grant"]})})]}):(0,u.jsx)("div",{className:"mt-5 space-y-3",children:0===o.grants.length?(0,u.jsx)("div",{className:"rounded-2xl border p-4 ".concat(S),children:(0,u.jsx)("p",{className:E,children:"No explicit session grants."})}):o.grants.map(e=>(0,u.jsx)("div",{className:"rounded-2xl border p-4 ".concat(S),children:(0,u.jsxs)("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-center lg:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-medium",children:e.name||e.email}),(0,u.jsx)("p",{className:"text-sm ".concat(E),children:e.email})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,u.jsx)("span",{className:"rounded-full border px-3 py-1 ".concat(i?"border-[#8F6A2B]/40 bg-[#FFB52B]/[0.16] text-[#FFE3A1]":"border-[#FFB52B]/40 bg-[#FFF4D8] text-[#8B5B00]"),children:e.accessLevel}),e.grantedBy?(0,u.jsxs)("span",{className:E,children:["Granted by ",e.grantedBy]}):null,e.updatedAt||e.createdAt?(0,u.jsx)("span",{className:E,children:LA(e.updatedAt||e.createdAt)}):null]})]})},e.id))})]}):null]})},HA="",qA=e=>{let{isOpen:t,onClose:n,sessionId:r,sessionTitle:s="Untitled Session",embedded:i=!1}=e;const{isDarkMode:o}=zu(),{token:l}=am(),[c,m]=(0,a.useState)("existing"),[h,p]=(0,a.useState)([]),[g,x]=(0,a.useState)(!1),[f,b]=(0,a.useState)(""),[y,v]=(0,a.useState)(null),[w,k]=(0,a.useState)(!1),[j,D]=(0,a.useState)(null),[C,N]=(0,a.useState)([]),[F,S]=(0,a.useState)(!1),[E,A]=(0,a.useState)("none"),[T,M]=(0,a.useState)({}),[_,B]=(0,a.useState)({}),[I,P]=(0,a.useState)({}),[L,R]=(0,a.useState)(null),[z,O]=(0,a.useState)({}),[U,V]=(0,a.useState)({label:"",expiresIn:"never",maxUniqueIps:"",maxTotalViews:"",chatEnabled:!1,rankingEnabled:!0,rankingTtmlAllowed:!1,commentsRead:!1,commentsWrite:!1,descriptionEnabled:!1,contextFilesEnabled:!0,questionsEnabled:!1}),H=o?"text-brand-yellow border-b-2 border-brand-yellow":"text-brand-navy border-b-2 border-brand-yellow",q="w-full px-3 py-2 rounded-lg border transition-colors focus:outline-none focus:ring-2 focus:ring-brand-yellow/30 focus:border-brand-yellow ".concat(o?"bg-gray-700 border-gray-600 text-white":"bg-white border-gray-300 text-gray-900"),W="mt-1 rounded border-gray-300 text-brand-navy focus:ring-brand-yellow",Y="px-4 py-2 rounded-lg bg-brand-yellow text-brand-navy hover:bg-[#ffc54d] transition-colors disabled:opacity-50",G=(0,a.useCallback)(async()=>{x(!0),b("");try{const e=await fetch("".concat(HA,"/api/sessions/").concat(r,"/share-links?t=").concat(Date.now()),{headers:{Authorization:"Bearer ".concat(l),"Cache-Control":"no-cache"}});if(!e.ok)throw new Error("Failed to fetch share links");const t=await e.json();console.log("Fetched share links:",t),console.log("First link details:",t[0]),t.length>0&&console.log("First link details:",{id:t[0].id,isEnabled:t[0].isEnabled,is_enabled:t[0].is_enabled,status:t[0].status}),p(t),m(e=>"access"===e?e:t.length>0?"existing":"create")}catch(e){b(e instanceof Error?e.message:"Failed to fetch share links")}finally{x(!1)}},[r,l]);(0,a.useEffect)(()=>{t&&r&&G()},[G,t,r]);const K=e=>{if(!e)return"Never";const t=new Date(e),n=new Date;if(t<n)return"Expired";const a=t.getTime()-n.getTime(),r=Math.floor(a/864e5),s=Math.floor(a%864e5/36e5);return r>0?"".concat(r,"d ").concat(s,"h"):"".concat(s,"h")},X=async(e,t)=>{const n=t||I[e]||"7days";B(t=>d(d({},t),{},{[e]:!0})),P(t=>d(d({},t),{},{[e]:n}));try{const t=await fetch("".concat(HA,"/api/share-links/").concat(e,"/logs?limit=10000"),{headers:{Authorization:"Bearer ".concat(l)}});if(!t.ok)throw new Error("Failed to fetch activity data");const a=(await t.json()).logs||[],r=new Date;let s,i;switch(n){case"24hours":s=new Date(r.getTime()-864e5),i="hour";break;case"7days":default:s=new Date(r.getTime()-6048e5),i="hour";break;case"30days":s=new Date(r.getTime()-2592e6),i="day";break;case"all":s=new Date(0),i="day"}const o={};console.log("Processing ".concat(a.length," logs for range ").concat(n,", startTime: ").concat(s.toISOString())),a.forEach(e
2=>{const t=new Date(e.timestamp.replace(" ","T"));if(t>=s&&"TAB_VIEW"===e.event){let n;if("hour"===i)n=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()).toISOString();else if("day"===i)n=new Date(t.getFullYear(),t.getMonth(),t.getDate()).toISOString();else{const e=new Date(t);e.setDate(t.getDate()-t.getDay()),e.setHours(0,0,0,0),n=e.toISOString()}o[n]||(o[n]={views:0,uniqueIps:new Set}),o[n].views++,o[n].uniqueIps.add(e.ip_address)}});const c=Object.entries(o).map(e=>{let[t,n]=e;return{time:new Date(t),views:n.views,uniqueIps:n.uniqueIps.size,bucketSize:i}}).sort((e,t)=>e.time.getTime()-t.time.getTime());console.log("Chart data:",c),console.log("Sample bucket:",c[0]),M(t=>d(d({},t),{},{[e]:c}))}catch(a){console.error("Failed to fetch activity data:",a)}finally{B(t=>d(d({},t),{},{[e]:!1}))}};if(!t)return null;const J=i?"w-full overflow-hidden rounded-2xl border ".concat(o?"border-gray-700 bg-gray-800":"border-gray-200 bg-white"):"relative w-full max-w-4xl max-h-[90vh] overflow-hidden rounded-lg shadow-xl ".concat(o?"bg-gray-800":"bg-white"),$=i?"overflow-y-auto":"overflow-y-auto max-h-[calc(90vh-200px)]";return(0,u.jsxs)("div",{className:i?"":"fixed inset-0 z-50 flex items-center justify-center p-4",children:[!i&&(0,u.jsx)("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:n}),(0,u.jsxs)("div",{className:J,children:[!i&&(0,u.jsxs)("div",{className:"flex items-center justify-between p-6 border-b ".concat(o?"border-gray-700":"border-gray-200"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-2xl font-bold ".concat(o?"text-white":"text-gray-900"),children:"Share Session"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(o?"text-gray-400":"text-gray-600"),children:s})]}),(0,u.jsx)("button",{onClick:n,className:"p-2 rounded-lg transition-colors ".concat(o?"hover:bg-gray-700":"hover:bg-gray-100"),children:(0,u.jsx)(Pu,{className:"w-5 h-5"})})]}),(0,u.jsxs)("div",{className:"scrollbar-hide flex overflow-x-auto border-b ".concat(o?"border-gray-700":"border-gray-200"),children:[(0,u.jsxs)("button",{onClick:()=>m("existing"),className:"shrink-0 whitespace-nowrap px-4 py-3 font-medium transition-colors sm:px-6 ".concat("existing"===c?H:o?"text-gray-400 hover:text-gray-300":"text-gray-600 hover:text-gray-900"),children:["Existing Links (",h.length,")"]}),(0,u.jsx)("button",{onClick:()=>m("create"),className:"shrink-0 whitespace-nowrap px-4 py-3 font-medium transition-colors sm:px-6 ".concat("create"===c?H:o?"text-gray-400 hover:text-gray-300":"text-gray-600 hover:text-gray-900"),children:"Create New Link"}),(0,u.jsx)("button",{onClick:()=>m("access"),className:"shrink-0 whitespace-nowrap px-4 py-3 font-medium transition-colors sm:px-6 ".concat("access"===c?H:o?"text-gray-400 hover:text-gray-300":"text-gray-600 hover:text-gray-900"),children:"Session Access"})]}),(0,u.jsxs)("div",{className:$,children:[f&&(0,u.jsxs)("div",{className:"mx-6 mt-4 p-3 bg-red-100 border border-red-300 rounded-lg flex items-center gap-2 text-red-700",children:[(0,u.jsx)(Lu,{className:"w-4 h-4"}),(0,u.jsx)("span",{className:"text-sm",children:f})]}),"access"===c?(0,u.jsx)(VA,{sessionId:r,sessionTitle:s,isActive:t&&"access"===c}):g&&"existing"===c?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-brand-yellow"})}):"existing"===c?(0,u.jsx)("div",{className:"p-6",children:0===h.length?(0,u.jsxs)("div",{className:"text-center py-12",children:[(0,u.jsx)(_u,{className:"w-16 h-16 mx-auto mb-4 ".concat(o?"text-gray-600":"text-gray-400")}),(0,u.jsx)("p",{className:"text-lg font-medium mb-2 ".concat(o?"text-gray-300":"text-gray-700"),children:"No share links yet"}),(0,u.jsx)("p",{className:"text-sm mb-4 ".concat("text-gray-500"),children:"Create your first share link to allow public access to this session"}),(0,u.jsx)("button",{onClick:()=>m("create"),className:Y,children:"Create Share Link"})]}):(0,u.jsx)("div",{className:"space-y-4",children:h.map(e=>{var t,n;return(0,u.jsxs)("div",{className:"p-4 rounded-lg border ".concat(o?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:[(0,u.jsxs)("div",{className:"mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("h3",{className:"font-medium ".concat(o?"text-white":"text-gray-900"),children:e.label}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 mt-1 text-sm",children:[(0,u.jsxs)("span",{className:"flex items-center gap-1 ".concat("active"===e.status?"text-brand-yellow":"expired"===e.status?"text-red-500":"text-gray-500"),children:["active"===e.status?(0,u.jsx)(Wm,{className:"w-3 h-3"}):"expired"===e.status?(0,u.jsx)(Pu,{className:"w-3 h-3"}):(0,u.jsx)(Fy,{className:"w-3 h-3"}),e.status]}),(0,u.jsxs)("span",{className:"flex items-center gap-1 ".concat(o?"text-gray-400":"text-gray-600"),children:[(0,u.jsx)(wp,{className:"w-3 h-3"}),"Expires: ",K(e.expiresAt)]}),(0,u.jsxs)("span",{className:"flex items-center gap-1 ".concat(o?"text-gray-400":"text-gray-600"),children:[(0,u.jsx)(fh,{className:"w-3 h-3"}),e.maxUniqueIps?"".concat(e.uniqueIps||e.uniqueViews||0,"/").concat(e.maxUniqueIps," unique IPs"):"".concat(e.uniqueIps||e.uniqueViews||0," unique IPs")]}),e.totalViews>0&&(0,u.jsxs)("span",{className:"flex items-center gap-1 ".concat(o?"text-gray-400":"text-gray-600"),children:[(0,u.jsx)(Cp,{className:"w-3 h-3"}),e.maxTotalViews?"".concat(e.totalViews,"/").concat(e.maxTotalViews," total views"):"".concat(e.totalViews," total views")]})]})]}),(0,u.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[(0,u.jsx)("button",{onClick:()=>(async e=>{S(!0);try{const t=await fetch("".concat(HA,"/api/share-links/").concat(e.id,"/logs"),{headers:{Authorization:"Bearer ".concat(l)}});if(!t.ok)throw new Error("Failed to fetch logs");const n=await t.json();N(n.logs||[]),D(e),k(!0)}catch(t){b(t instanceof Error?t.message:"Failed to fetch logs")}finally{S(!1)}})(e),className:"p-2 rounded transition-colors ".concat(o?"hover:bg-gray-600":"hover:bg-gray-200"),title:"View activity logs",children:(0,u.jsx)(yp,{className:"w-4 h-4"})}),(0,u.jsx)("button",{onClick:()=>(e=>{var t,n;let a="never";
2e.expiresAt&&(a="168"),V({label:e.label,expiresIn:a,maxUniqueIps:(null===(t=e.maxUniqueIps)||void 0===t?void 0:t.toString())||"",maxTotalViews:(null===(n=e.maxTotalViews)||void 0===n?void 0:n.toString())||"",chatEnabled:"DISABLED"!==e.chatMode,rankingEnabled:e.rankingEnabled||e.timelineEnabled||!1,rankingTtmlAllowed:!1,commentsRead:e.commentsRead||!1,commentsWrite:e.commentsWrite||!1,descriptionEnabled:e.descriptionEnabled||!1,contextFilesEnabled:!1!==e.contextFilesEnabled,questionsEnabled:!0===e.questionsEnabled}),R(e.id),m("create")})(e),className:"p-2 rounded transition-colors ".concat(o?"hover:bg-gray-600":"hover:bg-gray-200"),title:"Edit link",children:(0,u.jsx)(Sy,{className:"w-4 h-4"})}),(0,u.jsx)("button",{onClick:()=>(async(e,t)=>{console.log("Toggling share link:",e,"from",t,"to",!t);try{const n=await fetch("".concat(HA,"/api/share-links/").concat(e),{method:"PATCH",headers:{Authorization:"Bearer ".concat(l),"Content-Type":"application/json"},body:JSON.stringify({is_enabled:!t})});if(!n.ok)throw new Error("Failed to update share link");const a=await n.json();console.log("Toggle result:",a),await G()}catch(n){b(n instanceof Error?n.message:"Failed to update share link")}})(e.id,e.isEnabled),className:"p-2 rounded transition-colors ".concat(o?"hover:bg-gray-600":"hover:bg-gray-200"),title:e.isEnabled?"Disable link":"Enable link",children:e.isEnabled?(0,u.jsx)(Cp,{className:"w-4 h-4"}):(0,u.jsx)(Fy,{className:"w-4 h-4"})}),(0,u.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this share link?"))try{if(!(await fetch("".concat(HA,"/api/share-links/").concat(e),{method:"DELETE",headers:{Authorization:"Bearer ".concat(l)}})).ok)throw new Error("Failed to delete share link");await G()}catch(t){b(t instanceof Error?t.message:"Failed to delete share link")}})(e.id),className:"p-2 rounded transition-colors ".concat(o?"hover:bg-gray-600":"hover:bg-gray-200"),title:"Delete link",children:(0,u.jsx)(kp,{className:"w-4 h-4"})})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded border ".concat(o?"bg-gray-800 border-gray-600":"bg-white border-gray-300"),children:[(0,u.jsx)("input",{type:"text",value:e.url,readOnly:!0,className:"min-w-0 flex-1 bg-transparent text-sm ".concat(o?"text-gray-300":"text-gray-700")}),(0,u.jsx)("button",{onClick:()=>(async(e,t)=>{await Up(e)?(v(t),setTimeout(()=>v(null),2e3)):(b("Failed to copy to clipboard"),setTimeout(()=>b(""),3e3))})(e.url,e.id),className:"p-2 rounded transition-colors ".concat(y===e.id?"bg-brand-yellow text-brand-navy":o?"hover:bg-gray-700":"hover:bg-gray-100"),children:y===e.id?(0,u.jsx)(Wm,{className:"w-4 h-4"}):(0,u.jsx)(Np,{className:"w-4 h-4"})})]}),(0,u.jsxs)("div",{className:"mt-3",children:[(0,u.jsx)("div",{className:"text-xs ".concat(o?"text-gray-400":"text-gray-600"," mb-2 font-medium"),children:"Enabled Features:"}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(o?"bg-brand-yellow/15 text-brand-yellow":"bg-[#fff3d6] text-[#7a560c]"),children:[(0,u.jsx)(gp,{className:"w-3 h-3"})," Transcript (Always On)"]}),"DISABLED"!==e.chatMode&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(o?"bg-brand-navy text-brand-cloud":"bg-[#e8edf2] text-brand-navy"),children:[(0,u.jsx)(Fp,{className:"w-3 h-3"})," Chat (BYOK)"]}),e.commentsRead&&!e.commentsWrite&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(o?"bg-[#4c4022] text-[#ffd37a]":"bg-[#fff3d6] text-[#7a560c]"),children:[(0,u.jsx)(Fp,{className:"w-3 h-3"})," Comments (Read Only)"]}),e.commentsWrite&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(o?"bg-brand-navy text-brand-cloud":"bg-[#e8edf2] text-brand-navy"),children:[(0,u.jsx)(Fp,{className:"w-3 h-3"})," Comments (Read/Write)"]}),e.descriptionEnabled&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(o?"bg-[#384456] text-[#d8dee6]":"bg-[#ebe7de] text-brand-navy"),children:[(0,u.jsx)(hA,{className:"w-3 h-3"})," Description"]}),e.rankingEnabled&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(o?"bg-[#233546] text-[#D3E4F5]":"bg-[#E7F1FB] text-[#35506C]"),children:[(0,u.jsx)(KE,{className:"w-3 h-3"})," Topic Map"]}),e.questionsEnabled&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(o?"bg-[#25354C] text-[#D8E3F2]":"bg-[#EAF1F8] text-[#36506D]"),children:[(0,u.jsx)("span",{className:"flex h-3 w-3 items-center justify-center rounded-full border border-current text-[8px] font-bold leading-none",children:"Q"}),"Questions"]})]}),(e.maxUniqueIps||e.maxTotalViews||e.expiresAt)&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"text-xs ".concat(o?"text-gray-400":"text-gray-600"," mb-2 font-medium mt
2-3"),children:"Restrictions:"}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-2",children:[e.maxUniqueIps&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat((e.uniqueIps||0)>=e.maxUniqueIps?o?"bg-red-900 text-red-300":"bg-red-100 text-red-700":o?"bg-brand-yellow/15 text-brand-yellow":"bg-[#fff3d6] text-[#7a560c]"),children:[(0,u.jsx)(fh,{className:"w-3 h-3"}),e.uniqueIps||0,"/",e.maxUniqueIps," Unique IPs"]}),e.maxTotalViews&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat((e.totalViews||0)>=e.maxTotalViews?o?"bg-red-900 text-red-300":"bg-red-100 text-red-700":o?"bg-brand-yellow/15 text-brand-yellow":"bg-[#fff3d6] text-[#7a560c]"),children:[(0,u.jsx)(Cp,{className:"w-3 h-3"}),e.totalViews||0,"/",e.maxTotalViews," Total Views"]}),e.expiresAt&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-xs rounded ".concat(new Date(e.expiresAt)<new Date?o?"bg-red-900 text-red-300":"bg-red-100 text-red-700":o?"bg-gray-600 text-gray-300":"bg-gray-200 text-gray-700"),children:[(0,u.jsx)(wp,{className:"w-3 h-3"}),new Date(e.expiresAt)<new Date?"Expired":"Expires: ".concat(K(e.expiresAt))]})]})]})]}),(0,u.jsxs)("div",{className:"mt-4",children:[(0,u.jsxs)("button",{onClick:()=>{T[e.id]&&z[e.id]?O(t=>d(d({},t),{},{[e.id]:!1})):T[e.id]?O(t=>d(d({},t),{},{[e.id]:!0})):(X(e.id),O(t=>d(d({},t),{},{[e.id]:!0})))},className:"text-sm flex items-center gap-2 ".concat(o?"text-gray-400 hover:text-gray-300":"text-gray-600 hover:text-gray-700"),children:[(0,u.jsx)(KE,{className:"w-4 h-4"}),_[e.id]?"Loading activity...":T[e.id]&&z[e.id]?"Hide activity graph":"Show activity graph",T[e.id]&&!_[e.id]&&(z[e.id]?(0,u.jsx)(Tu,{className:"w-3 h-3"}):(0,u.jsx)(wd,{className:"w-3 h-3"}))]}),T[e.id]&&z[e.id]&&(0,u.jsx)("button",{onClick:()=>X(e.id,I[e.id]),className:"ml-4 text-xs ".concat(o?"text-gray-500 hover:text-gray-400":"text-gray-500 hover:text-gray-600"),children:"Refresh"}),T[e.id]&&z[e.id]&&(0,u.jsxs)("div",{className:"mt-3 p-3 rounded-lg ".concat(o?"bg-gray-800":"bg-gray-100"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("span",{className:"text-xs font-medium ".concat(o?"text-gray-400":"text-gray-600"),children:"Activity"}),(0,u.jsx)("div",{className:"flex gap-1",children:["24hours","7days","30days","all"].map(t=>(0,u.jsx)("button",{onClick:()=>X(e.id,t),className:"px-2 py-1 text-xs rounded transition-colors ".concat(I[e.id]===t?o?"bg-gray-700 text-white":"bg-gray-300 text-gray-900":o?"bg-gray-700/50 text-gray-400 hover:bg-gray-700":"bg-gray-200 text-gray-600 hover:bg-gray-300"),children:"24hours"===t?"24h":"7days"===t?"7d":"30days"===t?"30d":"All"},t))})]}),(0,u.jsxs)("div",{className:"flex items-center gap-4 text-xs",children:[(0,u.jsxs)("span",{className:"flex items-center gap-1 ".concat(o?"text-[#d8dee6]":"text-brand-navy"),children:[(0,u.jsx)("div",{className:"w-2 h-2 bg-brand-navy rounded-full"}),"Views"]}),(0,u.jsxs)("span",{className:"flex items-center gap-1 ".concat(o?"text-brand-yellow":"text-[#9c7010]"),children:[(0,u.jsx)("div",{className:"w-2 h-2 bg-brand-yellow rounded-full"}),"Unique IPs"]})]})]}),0===T[e.id].length?(0,u.jsx)("div",{className:"text-center py-8 text-sm ".concat("text-gray-500"),children:"No activity in this time period"}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"h-32 flex items-end gap-1",children:(()=>{const t=T[e.id],n=Math.max(...t.map(e=>Math.max(e.views,e.uniqueIps)),1);return console.log("Chart scaling:",{dataLength:t.length,maxValue:n,viewsRange:[Math.min(...t.map(e=>e.views)),Math.max(...t.map(e=>e.views))],uniqueIpsRange:[Math.min(...t.map(e=>e.uniqueIps)),Math.max(...t.map(e=>e.uniqueIps))],sampleItems:t.slice(0,3).map(e=>({views:e.views,uniqueIps:e.uniqueIps}))}),t.map((e,t)=>{return(0,u.jsxs)("div",{className:"flex-1 flex items-end justify-center gap-1 min-w-[4px] max-w-[40px] h-full",title:"".concat((a=e.time,r=e.bucketSize,"hour"===r?a.toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit"}):a.toLocaleDateString("en-US",{month:"short",day:"numeric"})),": ").concat(e.views," views, ").concat(e.uniqueIps," unique IPs"),children:[(0,u.jsx)("div",{className:"w-1/2 bg-brand-navy rounded-t transition-all duration-300",style:{height:"".concat(e.views/n*100,"%"),minHeight:e.views>0?"3px":"0"}}),(0,u.jsx)("div",{className:"w-1/2 bg-brand-yellow rounded-t transition-all duration-300",style:{height:"".concat(e.uniqueIps/n*100,"%"),minHeight:e.uniqueIps>0?"3px":"0"}})]},t);var a,r})})()}),(0,u.jsxs)("div",{className:"mt-2 text-xs ".concat(o?"text-gray-500":"text-gray-600"),children:[null===(t=T[e.id][0])||void 0===t?void 0:t.t
2ime.toLocaleDateString()," - ",null===(n=T[e.id][T[e.id].length-1])||void 0===n?void 0:n.time.toLocaleDateString()," \u2022 ","Total: ",T[e.id].reduce((e,t)=>e+t.views,0)," views, ",[...new Set(T[e.id].flatMap(e=>Array.from({length:e.uniqueIps},(t,n)=>"".concat(e.time,"-").concat(n))))].length," unique IPs"]})]})]})]})]},e.id)})})}):(0,u.jsx)("div",{className:"p-6",children:(0,u.jsxs)("form",{onSubmit:e=>{e.preventDefault(),L?(async()=>{if(L){x(!0),b("");try{const e={label:U.label};if("never"===U.expiresIn)e.expires_at=null;else if(U.expiresIn){const t=new Date(Date.now()+60*parseInt(U.expiresIn)*60*1e3);e.expires_at=t.toISOString()}if(U.maxUniqueIps?e.max_unique_ips=parseInt(U.maxUniqueIps):e.max_unique_ips=null,U.maxTotalViews?e.max_total_views=parseInt(U.maxTotalViews):e.max_total_views=null,e.chat_mode=U.chatEnabled?"FULL":"DISABLED",e.llm_call_cap=0,e.timeline_enabled=U.rankingEnabled,e.ranking_enabled=U.rankingEnabled,e.ranking_ttml_allowed=!1,e.comments_read=U.commentsRead,e.comments_write=U.commentsWrite,e.description_enabled=U.descriptionEnabled,e.context_files_enabled=U.contextFilesEnabled,e.questions_enabled=U.questionsEnabled,!(await fetch("".concat(HA,"/api/share-links/").concat(L),{method:"PATCH",headers:{Authorization:"Bearer ".concat(l),"Content-Type":"application/json"},body:JSON.stringify(e)})).ok)throw new Error("Failed to update share link");R(null),V({label:"",expiresIn:"never",maxUniqueIps:"",maxTotalViews:"",chatEnabled:!1,rankingEnabled:!0,rankingTtmlAllowed:!1,commentsRead:!1,commentsWrite:!1,descriptionEnabled:!1,contextFilesEnabled:!0,questionsEnabled:!1}),m("existing"),await G()}catch(e){b(e instanceof Error?e.message:"Failed to update share link")}finally{x(!1)}}})():(async()=>{x(!0),b("");try{if(!(await fetch("".concat(HA,"/api/sessions/").concat(r,"/share-links"),{method:"POST",headers:{Authorization:"Bearer ".concat(l),"Content-Type":"application/json"},body:JSON.stringify({label:U.label||"Share link for ".concat(s),expiresIn:"never"===U.expiresIn?null:parseInt(U.expiresIn),maxUniqueIps:U.maxUniqueIps?parseInt(U.maxUniqueIps):null,maxTotalViews:U.maxTotalViews?parseInt(U.maxTotalViews):null,chatMode:U.chatEnabled?"FULL":"DISABLED",llmCallCap:0,timelineEnabled:U.rankingEnabled,rankingEnabled:U.rankingEnabled,rankingTtmlAllowed:!1,commentsRead:U.commentsRead,commentsWrite:U.commentsWrite,descriptionEnabled:U.descriptionEnabled,contextFilesEnabled:U.contextFilesEnabled,questionsEnabled:U.questionsEnabled})})).ok)throw new Error("Failed to create share link");await G(),m("existing"),V({label:"",expiresIn:"never",maxUniqueIps:"",maxTotalViews:"",chatEnabled:!1,rankingEnabled:!0,rankingTtmlAllowed:!1,commentsRead:!1,commentsWrite:!1,descriptionEnabled:!1,contextFilesEnabled:!0,questionsEnabled:!1})}catch(e){b(e instanceof Error?e.message:"Failed to create share link")}finally{x(!1)}})()},className:"space-y-6",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-lg font-medium mb-4 ".concat(o?"text-white":"text-gray-900"),children:L?"Edit Share Link":"Basic Settings"}),(0,u.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-2 ".concat(o?"text-gray-300":"text-gray-700"),children:"Label (optional)"}),(0,u.jsx)("input",{type:"text",value:U.label,onChange:e=>V(d(d({},U),{},{label:e.target.value})),placeholder:"e.g., Public review link",className:q})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-2 ".concat(o?"text-gray-300":"text-gray-700"),children:"Expiry"}),(0,u.jsxs)("select",{value:U.expiresIn,onChange:e=>V(d(d({},U),{},{expiresIn:e.target.value})),className:q,children:[(0,u.jsx)("option",{value:"never",children:"Never (Recommended)"}),(0,u.jsx)("option",{value:"8760",children:"1 year"}),(0,u.jsx)("option",{value:"720",children:"1 month"}),(0,u.jsx)("option",{value:"168",children:"1 week"}),(0,u.jsx)("option",{value:"24",children:"24 hours"}),(0,u.jsx)("option",{value:"12",children:"12 hours"})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-2 ".concat(o?"text-gray-300":"text-gray-700"),children:"Max Unique IP Addresses (optional)"}),(0,u.jsx)("input",{type:"number",value:U.maxUniqueIps,onChange:e=>V(d(d({},U),{},{maxUniqueIps:e.target.value})),placeholder:"Unlimited",min:"1",className:q}),(0,u.jsx)("p",{className:"text-xs mt-1 ".concat(o?"text-gray-400":"text-gray-500"),children:"Limits the number of unique IP addresses that can access this link"})]}),(0,u.jsxs)("div",{className:"mt-4",children:[(0,u.jsx)("label",{className:"block text-sm font-medium mb-2 ".concat(o?"text-gray-300":"text-gray-700"),children:"Max Total Views (optional)"}),(0,u.jsx)("input",{type:"number",value:U.maxTotalViews,onChange:e=>V(d(d({},U),{},{maxTotalViews:e.target.value})),placeholder:"Unlimited",min:"1",className:q}),(0,u.jsx)("p",{className:"text-xs mt-1 ".concat(o?"text-gray-400":"text-gray-500"),children:"Limits the total number of times this link can be accessed (including repeat visits)"})]})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-lg font-medium mb-4 ".concat(o?"text-white":"text-gray-900"),children:"Tab Permissions"}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsxs)("label",{className:"flex items-center gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:!0,disabled:!0,className:W}),(0,u.jsx)(bj,{className:"w-4 h-4"}),(0,u.jsx)("span",{children:"Transcripts (always enabled)"})]}),(0,u.jsx)("div",{className:"rounded-lg border p-3 ".concat(o?"border-gray-700 bg-gray-800/50":"border-gray-200 bg-gray-50"),children:(0,u.jsxs)("label",{className:"flex items-start gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:U.chatEnabled,onChange:e=>V(d(d({},U),{},{chatEnabled:e.target.checked})),className:W}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(Fp,{className:"w-4 h-4"}),(0,u.jsx)("span",{children:"Chat with Transcript"})]}),(0,u.jsx)("p",{className:"mt-1 text-xs ".concat(o?"text-gray-400":"text-gray-500"),children:"Public viewers must bring their own OpenRouter API key to use chat."})]})]})}),(0,u.jsxs)("label",{className:"flex items-center gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:U.rankingEnabled,onChange:e=>V(d(d({},U),{},{rankingEnabled:e.target.checked})),className:W}),(0,u.jsx)(KE,{className:"w-4 h-4"}),(0,u.jsx)("span",{children:"Topic Map"})]}),(0,u.jsxs)("label",{className:"flex items-center gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:U.descriptionEnabled,onChange:e=>V(d(d({},U),{},{descriptionEnabled:e.target.checked})),className:W}),(0,u.jsx)(hA,{className:"w-4 h-4"}
2),(0,u.jsx)("span",{children:"Description (YouTube Description Editor)"})]}),(0,u.jsxs)("label",{className:"flex items-center gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:U.contextFilesEnabled,onChange:e=>V(d(d({},U),{},{contextFilesEnabled:e.target.checked})),className:W}),(0,u.jsx)(NA,{className:"w-4 h-4"}),(0,u.jsx)("span",{children:"Context Files (Reference Documents)"})]}),(0,u.jsxs)("label",{className:"flex items-center gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:U.questionsEnabled,onChange:e=>V(d(d({},U),{},{questionsEnabled:e.target.checked})),className:W}),(0,u.jsx)("span",{className:"flex h-4 w-4 items-center justify-center rounded-full border border-current text-[10px] font-bold leading-none",children:"Q"}),(0,u.jsx)("span",{children:"Questions Tab"})]})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-lg font-medium mb-4 ".concat(o?"text-white":"text-gray-900"),children:"Comments Settings"}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsxs)("label",{className:"flex items-center gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:U.commentsRead,onChange:e=>V(d(d({},U),{},{commentsRead:e.target.checked})),className:W}),(0,u.jsx)("span",{children:"Allow reading comments"})]}),(0,u.jsxs)("label",{className:"flex items-center gap-3 ".concat(o?"text-gray-300":"text-gray-700"),children:[(0,u.jsx)("input",{type:"checkbox",checked:U.commentsWrite,onChange:e=>V(d(d({},U),{},{commentsWrite:e.target.checked})),className:W}),(0,u.jsx)("span",{children:"Allow posting comments (anonymous)"})]})]})]}),(0,u.jsxs)("div",{className:"flex justify-end gap-3 pt-4",children:[L&&(0,u.jsx)("button",{type:"button",onClick:()=>{R(null),m("existing"),V({label:"",expiresIn:"never",maxUniqueIps:"",maxTotalViews:"",chatEnabled:!1,rankingEnabled:!0,rankingTtmlAllowed:!1,commentsRead:!1,commentsWrite:!1,descriptionEnabled:!1,contextFilesEnabled:!0,questionsEnabled:!1})},className:"px-4 py-2 rounded-lg transition-colors ".concat(o?"bg-gray-700 hover:bg-gray-600":"bg-gray-200 hover:bg-gray-300"),children:"Cancel Edit"}),!i&&(0,u.jsx)("button",{type:"button",onClick:n,className:"px-4 py-2 rounded-lg transition-colors ".concat(o?"bg-gray-700 hover:bg-gray-600":"bg-gray-200 hover:bg-gray-300"),children:L?"Close":"Cancel"}),(0,u.jsx)("button",{type:"submit",disabled:g,className:Y,children:g?L?"Updating...":"Creating...":L?"Update Share Link":"Create Share Link"})]})]})})]})]}),w&&j&&(0,u.jsxs)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:()=>k(!1)}),(0,u.jsxs)("div",{className:"relative w-full max-w-4xl max-h-[90vh] overflow-hidden rounded-lg shadow-xl ".concat(o?"bg-gray-800":"bg-white"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-6 border-b ".concat(o?"border-gray-700":"border-gray-200"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-xl font-bold ".concat(o?"text-white":"text-gray-900"),children:"Activity Logs"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(o?"text-gray-400":"text-gray-600"),children:j.label||"Share Link"})]}),(0,u.jsx)("button",{onClick:()=>k(!1),className:"p-2 rounded-lg transition-colors ".concat(o?"hover:bg-gray-700":"hover:bg-gray-100"),children:(0,u.jsx)(Pu,{className:"w-5 h-5"})})]}),(0,u.jsxs)("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-4",children:[(0,u.jsx)("span",{className:"text-sm ".concat(o?"text-gray-400":"text-gray-600"),children:"Group by:"}),(0,u.jsx)("div",{className:"flex gap-2",children:[{value:"none",label:"None"},{value:"ip",label:"IP Address"},{value:"action",label:"Action"},{value:"user-agent",label:"User Agent"}].map(e=>(0,u.jsx)("button",{onClick:()=>A(e.value),className:"px-3 py-1 text-xs rounded transition-colors ".concat(E===e.value?o?"bg-gray-700 text-white":"bg-gray-300 text-gray-900":o?"bg-gray-700/50 text-gray-400 hover:bg-gray-700":"bg-gray-200 text-gray-600 hover:bg-gray-300"),children:e.label},e.value))})]}),F?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-brand-yellow"})}):0===C.length?(0,u.jsx)("div",{className:"text-center py-12 ".concat(o?"text-gray-400":"text-gray-600"),children:"No access logs
2yet"}):(0,u.jsx)("div",{className:"space-y-3",children:(()=>{if("none"===E)return C.map((e,t)=>(0,u.jsx)("div",{className:"p-4 rounded-lg border ".concat(o?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:(0,u.jsxs)("div",{className:"flex items-start justify-between",children:[(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,u.jsx)("span",{className:"text-sm font-medium ".concat(o?"text-gray-300":"text-gray-700"),children:e.event}),(0,u.jsx)("span",{className:"text-xs ".concat("text-gray-500"),children:new Date(e.timestamp).toLocaleString()})]}),(0,u.jsxs)("div",{className:"text-sm space-y-1 ".concat(o?"text-gray-400":"text-gray-600"),children:[(0,u.jsxs)("div",{children:["IP: ",e.ip_address]}),(0,u.jsxs)("div",{className:"text-xs truncate",children:["User Agent: ",e.user_agent]}),e.metadata&&Object.keys(e.metadata).length>0&&(0,u.jsxs)("div",{className:"text-xs",children:["Metadata: ",JSON.stringify(e.metadata)]})]})]}),e.cost_usd>0&&(0,u.jsxs)("span",{className:"text-sm text-red-500",children:["$",e.cost_usd.toFixed(2)]})]})},e.id||t));{const e={};
2return C.forEach(t=>{const n="ip"===E?t.ip_address:"action"===E?t.event:"user-agent"===E?t.user_agent:"";e[n]||(e[n]=[]),e[n].push(t)}),Object.entries(e).map(e=>{let[t,n]=e;return(0,u.jsxs)("div",{className:"rounded-lg border ".concat(o?"bg-gray-700 border-gray-600":"bg-gray-50 border-gray-200"),children:[(0,u.jsx)("div",{className:"p-3 border-b ".concat(o?"bg-gray-700/50 border-gray-600":"bg-gray-100 border-gray-300"),children:(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("h4",{className:"font-medium ".concat(o?"text-gray-200":"text-gray-800"),children:t}),(0,u.jsxs)("span",{className:"text-sm ".concat(o?"text-gray-400":"text-gray-600"),children:[n.length," events"]})]})}),(0,u.jsxs)("div",{className:"p-3 space-y-2",children:[(0,u.jsxs)("div",{className:"grid grid-cols-3 gap-4 mb-3 text-xs ".concat(o?"text-gray-400":"text-gray-600"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"First:"})," ",new Date(Math.min(...n.map(e=>new Date(e.timestamp).getTime()))).toLocaleString()]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Last:"})," ",new Date(Math.max(...n.map(e=>new Date(e.timestamp).getTime()))).toLocaleString()]}),n.some(e=>e.cost_usd>0)&&(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Total Cost:"})," $",n.reduce((e,t)=>e+(t.cost_usd||0),0).toFixed(2)]})]}),(0,u.jsx)("div",{className:"text-xs ".concat(o?"text-gray-500":"text-gray-600"),children:(()=>{const e={};return n.forEach(t=>{e[t.event]=(e[t.event]||0)+1}),Object.entries(e).map(e=>{let[t,n]=e;return(0,u.jsxs)("span",{className:"inline-block mr-3",children:[t,": ",n]},t)})})()})]})]},t)})}})()})]})]})]})]})},WA=e=>{let{isOpen:t,onClose:n,sessionId:r,speakers:s,speakerSegments:i,currentLabels:o,onSave:l,transcriptionChecksum:c,embedded:m=!1}=e;const{token:h}=am(),{isDarkMode:p}=zu(),[g,x]=(0,a.useState)(()=>{const e={};return s.forEach(t=>{e[t]=(null===o||void 0===o?void 0:o[t])||"Speaker ".concat(t)}),e}),[f,b]=(0,a.useState)(null),[y,v]=(0,a.useState)(""),[w,k]=(0,a.useState)(!1),[j,D]=(0,a.useState)(!1),[C,N]=(0,a.useState)(null),F=(0,a.useRef)(new Map);(0,a.useEffect)(()=>{if(t){const e={};s.forEach(t=>{e[t]=(null===o||void 0===o?void 0:o[t])||"Speaker ".concat(t)}),x(e),v(""),N(null)}},[t,o,s]),(0,a.useEffect)(()=>{t||(F.current.forEach(e=>{e.src&&e.src.startsWith("blob:")&&URL.revokeObjectURL(e.src),e.pause()}),F.current.clear(),b(null))},[t]);const E=e=>{var t;return(null===(t=i.get(e))||void 0===t?void 0:t.length)||0},A=e=>(i.get(e)||[]).reduce((e,t)=>e+(t.end-t.start),0);return t?(0,u.jsx)("div",{className:m?"":"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",children:(0,u.jsxs)(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"".concat(p?"bg-gray-800":"bg-white"," ").concat(m?"w-full rounded-2xl border p-0 shadow-none ".concat(p?"border-gray-700":"border-gray-200"):"mx-4 max-w-2xl rounded-lg p-6 shadow-xl max-h-[90vh] overflow-y-auto"," overflow-y-auto"),children:[!m&&(0,u.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"rounded-lg bg-purple-100 p-2 dark:bg-purple-800",children:(0,u.jsx)(fh,{size:20,className:"text-purple-600"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-xl font-semibold ".concat(p?"text-white":"text-gray-900"),children:"Edit Speaker Names"}),(0,u.jsx)("p",{className:"text-sm ".concat(p?"text-gray-400":"text-gray-600"),children:"Update speaker labels for this session"})]})]}),(0,u.jsx)("button",{onClick:n,className:"rounded p-1 transition-colors hover:bg-gray-200 dark:hover:bg-gray-700",children:(0,u.jsx)(Pu,{className:"w-5 h-5"})})]}),0===s.length?(0,u.jsxs)("div",{className:"".concat(m?"p-6":"py-8"," text-center"),children:[(0,u.jsx)(Lu,{size:48,className:"text-gray-400 dark:text-gray-500 mx-auto mb-4"}),(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"No Speakers Detected"}),(0,u.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:"This session doesn't have multiple speakers or speaker diarization data."})]}):(0,u.jsxs)("div",{className:"space-y-4 ".concat(m?"p-6":""),children:[c&&(0,u.jsxs)("div",{className:"flex items-center justify-end space-x-2",children:[w&&(0,u.jsxs)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},className:"flex items-center space-x-2 text-sm text-blue-600 dark:text-blue-400",children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),(0,u.jsx)("span",{children:"AI is analyzing..."})]}),!w&&(0,u.jsxs)("button",{onClick:async()=>{if(r&&0!==s.length&&!w)try{k(!0),v("");const e=await $h({sessionId:r,enableWebSearch:!0},h||void 0);N(e.agentSessionId)}catch(y){console.error("Speaker name inference failed:",y),v("Failed to start the speaker inference agent. You can still label speakers manually.")}finally{k(!1)}},className:"flex items-center space-x-2 px-3 py-2 text-sm bg-blue-50 dark:bg-blue-900 text-blue-700 dark:text-blue-200 rounded-lg hover:bg-blue-100 dark:hover:bg-blue-800 transition-colors",title:"Start the speaker inference agent",children:[(0,u.jsx)(bh,{size:16}),(0,u.jsx)("span",{children:"Start Naming Agent"})]})]}),C&&!w&&(0,u.jsxs)(Do.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"bg-blue-50 dark:bg-blue-900 border border-blue-200 dark:border-blue-700 rounded-lg p-4",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)(bh,{size:16,className:"text-blue-600 dark:text-blue-400"}),(0,u.jsx)("span",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:"Speaker inference agent started"})]}),(0,u.jsxs)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("navigate-to-agent",{detail:{agentSessionId:C}})),className:"inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300",children:["Open agent",(0,u.jsx)(yh,{size:12})]})]}),(0,u.jsx)("p",{className:"mt-2 text-xs ".concat(p?"text-blue-200":"text-blue-700"),children:"The agent will infer speaker labels through the ReScript CLI and save them back onto this session. Open the agent tab if you want to supervise or interject."})]}),(0,u.jsx)("div",{className:"space-y-3",children:s.map(e=>(0,u.jsxs)("div",{className:"flex items-center space-x-4 p-4 rounded-lg ".concat(p?"bg-gray-700":"bg-gray-50"),children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3 flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("div",{className:"w-4 h-4 rounded",style:{backgroundColor:mp(e,p)}}),(0,u.jsx)("div",{className:"p-2 rounded-lg shadow-sm ".concat(p?"bg-gray-600":"bg-white"),children:(0,u.jsx)(vh,{size:16,className:p?"text-gray-300":"text-gray-600"})})]}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,u.jsxs)("span",{className:"text-sm font-medium ".concat(p?"text-gray-300":"text-gray-700"),children:["Speaker ",e]}),(0,u.jsxs)("span",{className:"text-xs ".concat(p?"text-gray-400":"text-gray-500"),children:[E(e)," segments \u2022 ",Math.round(A(e)),"s"]})]}),(0,u.jsx)("input",{type:"text",value:g[e]||"",onChange:t=>((e,t)=>{x(n=>d(d({},n),{},{[e]:t}))})(e,t.target.value),placeholder:"Enter name for Speaker ".concat(e,"..."),className:"w-full px-3 py-2 text-sm border rounded-lg transition-all duration-200 ".concat(p?"border-gray-600 bg-gray-800 text-gray-100 focus:border-primary-500":"border-gray-200 bg-white text-gray-900 focus:border-primary-500"," focus:ring-1 focus:ring-primary-200")})]})]}),c&&(0,u.jsx)("button",{onClick:()=>f===e?(e=>{const t=F.current.get(e);t&&(t.pause(),t.currentTime=0),b(null)})(e):(async e=>{try{if(v(""),null!==f){const e=F.current.get(f);e&&(e.pause(),e.currentTime=0)}if(!c)return void v("Audio not available");let n=F.current.get(e);if(!n){try{const t=await ep.fetchSpeakerSampleUrl(c,e,h||void 0);n=new Audio(t),F.current.set(e,n)}catch(t){return console.error("Failed to fetch audio:",t),void v("Failed to load audio sample for Speaker ".concat(e,"."))}n.addEventListener("ended",()=>{b(null)}),n.addEventListener("error",()=>{v("Failed to play audio sample for Speaker ".concat(e)),b(null)})}n.currentTime=0,b(e),await n.play()}catch(y){console.error("Audio playback error:",y),v("Failed to play audio sample for Speaker ".concat(e)),b(null)}})(e),disabled:null!==f&&f!==e,className:"\n flex items-center space-x-2 px-3 py-2 rounded-lg font-medium transition-all duration-200\n ".concat(f===e?"bg-red-100 dark:bg-red-800 text-red-700 dark:text-red-200 hover:bg-red-200 dark:hover:bg-red-700":"bg-primary-100 dark:bg-primary-800 text-primary-700 dark:text-primary-200 hover:bg-primary-200 dark:hover:bg-primary-700","\n disabled:opacity-50 disabled:cursor-not-allowed\n "),children:f===e?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(wh,{size:16}),(0,u.jsx)("span",{className:"text-sm",children:"Stop"})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(kh,{size:16}),(0,u.jsx)("span",{className:"text-sm",children:"Play"})]})})]},e))}),(0,u.jsx)(S,{children:y&&(0,u.jsxs)(Do.div,{initial:{opacity:0,height:0}
2,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"p-3 bg-red-50 dark:bg-red-900 border border-red-200 dark:border-red-700 rounded-lg flex items-center space-x-2",children:[(0,u.jsx)(Lu,{size:16,className:"text-red-500 flex-shrink-0"}),(0,u.jsx)("p",{className:"text-sm text-red-700 dark:text-red-200",children:y})]})}),(0,u.jsxs)("div",{className:"flex items-center justify-end space-x-3 border-t border-gray-200 pt-4 dark:border-gray-700",children:[!m&&(0,u.jsx)("button",{onClick:n,disabled:j,className:"px-4 py-2 rounded-lg font-medium transition-colors ".concat(p?"bg-gray-700 hover:bg-gray-600 text-white":"bg-gray-200 hover:bg-gray-300 text-gray-900"),children:"Cancel"}),(0,u.jsx)("button",{onClick:async()=>{try{D(!0),v("");const e={};s.forEach(t=>{e[t]=g[t]||"Speaker ".concat(t)}),await l(e),m||n()}catch(y){console.error("Failed to save speaker labels:",y),v("Failed to save speaker labels. Please try again.")}finally{D(!1)}},disabled:j,className:"btn-primary flex items-center space-x-2",children:j?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{size:16,className:"animate-spin"}),(0,u.jsx)("span",{children:"Saving..."})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Dh,{size:16}),(0,u.jsx)("span",{children:"Save Changes"})]})})]})]})]})}):null},YA="/api",GA="/api/v1";async function KA(e){const t=await e.text();try{return JSON.parse(t)}catch(_H){if(t.trim().startsWith("<")){if(502===e.status||503===e.status||504===e.status)throw new Error("Service temporarily unavailable (".concat(e.status,"). Please try again in a few moments."));if(401===e.status||403===e.status)throw new Error("Authentication error. Please try logging in again.");throw new Error("Server error (".concat(e.status,"). The service may be restarting - please try again."))}throw new Error(t||"Request failed with status ".concat(e.status))}}function XA(e){if(!e)return"";let t=e.trim();for(;t.length>=2;){const e=t[0],n=t[t.length-1];if(!('"'===e&&'"'===n||"'"===e&&"'"===n||"`"===e&&"`"===n))break;t=t.slice(1,-1).trim()}return t}function JA(e){if(!e||!e.trim())return null;if([/(?:youtube\.com\/watch\?v=)([a-zA-Z0-9_-]{11})/,/(?:youtu\.be\/)([a-zA-Z0-9_-]{11})/,/(?:youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/(?:youtube\.com\/v\/)([a-zA-Z0-9_-]{11})/].some(t=>t.test(e)))return"youtube";return/^https?:\/\/(www\.)?dropbox\.com\/(s|scl\/fi)\/[a-zA-Z0-9_-]+/.test(e)?"dropbox":null}function $A(e){if(!e)return"Not scheduled";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function QA(e){if(null==e||!Number.isFinite(e)||e<0)return"Unknown";if(e<1024)return"".concat(e," B");const t=["KB","MB","GB","TB"];let n=e,a=-1;for(;n>=1024&&a<t.length-1;)n/=1024,a+=1;return"".concat(n.toFixed(n>=10||0===a?0:1)," ").concat(t[a])}function ZA(e){if(!e)return null;try{const t=new URL(e),n="/"===t.pathname?"":t.pathname,a=n.length>30?"...".concat(n.slice(-30)):n;return"".concat(t.hostname).concat(a)}catch(t){const n=e.trim();return n.length>56?"".concat(n.slice(0,53),"..."):n}}function eT(e){return null==e?"-":e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(1),"K"):e.toLocaleString()}function tT(e){if(null==e||!Number.isFinite(e))return"-";const t=Math.max(0,Math.round(e)),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?"".concat(n,":").concat(String(a).padStart(2,"0"),":").concat(String(r).padStart(2,"0")):"".concat(a,":").concat(String(r).padStart(2,"0"))}function nT(e){if(!e)return"Expiry unknown";const t=new Date(e);if(Number.isNaN(t.getTime()))return"Expiry unknown";const n=t.getTime()-Date.now();if(n<=0)return"Expired";const a=Math.round(n/6e4);if(a<60)return"Expires in ".concat(a,"m");const r=Math.round(a/60);if(r<48)return"Expires in ".concat(r,"h");const s=Math.round(r/24);return"Expires in ".concat(s,"d")}const aT=[{id:"title",title:"Title",description:"Edit, generate, and sync the session title."},{id:"share",title:"Sharing",description:"Create and manage public share links."},{id:"speakers",title:"Speakers",description:"Rename diarized speakers without leaving settings."},{id:"transcript",title:"Transcript",description:"Request and inspect the optional hesitation-preserving transcript."},{id:"playback",title:"Playback",description:"Control linked playback and inspect the active source."}
2,{id:"thumbnail",title:"Thumbnail",description:"Pick a durable session thumbnail for homepage cards and social/share unfurls."},{id:"youtube",title:"YouTube",description:"Connect YouTube, refresh analytics, and inspect retention-linked stats."},{id:"production",title:"Production",description:"Store source metadata and manage AWS video prep."}],rT=e=>{var t,n,r,s,i,o,l,c,d,m,h,p,g;let{isOpen:x,onClose:f,initialSection:b="title",isDarkMode:y,sessionId:v,sessionTitle:w,token:k,onTitleUpdate:j,onSessionRefresh:D,youtubeUrl:C,youtubeTitle:N,youtubeTitleUpdatedAt:F,youtubeTitleSync:S,videoUrl:E,videoSource:A,onYoutubeUrlChange:T,onVideoUrlChange:M,onRefreshVideoSource:_,videoStats:B,videoDurationSeconds:I,fetchedAt:P,onRetentionDataUpdate:L,speakerIds:R=[],speakerSegments:z=new Map,speakerLabels:O={},onSaveSpeakerLabels:U,transcriptionChecksum:V,hesitationTranscriptChecksum:H,isYouTubeMode:q=!1,dropboxVideoUrl:W,videoFilename:Y,dropboxDrpUrl:G,timelineName:K,localVideoPath:X,productionNotes:J,videoFileHash:$,videoFileSize:Q,videoFrameRate:Z,videoDuration:ee,audioDuration:te,videoSourceStatus:ne,customThumbnailUrl:ae,customThumbnailTimeSeconds:re,onProductionMetadataUpdate:se,onVideoSourceStatusUpdate:ie,publishedToHomepage:oe=!1,onPublishChange:le}=e;const[ce,de]=(0,a.useState)("title"),ue=(0,a.useRef)(null),me=(0,a.useRef)(!1),[he,pe]=(0,a.useState)(()=>"undefined"!==typeof window&&window.innerWidth<768),[ge,xe]=(0,a.useState)(w||""),[fe,be]=(0,a.useState)(!1),[ye,ve]=(0,a.useState)(!1),[we,ke]=(0,a.useState)(!1),[je,De]=(0,a.useState)(!1),[Ce,Ne]=(0,a.useState)(null),[Fe,Se]=(0,a.useState)(!(null===S||void 0===S||!S.enabled)),[Ee,Ae]=(0,a.useState)(C||""),[Te,Me]=(0,a.useState)(C?"youtube":null),[_e,Be]=(0,a.useState)(!1),[Ie,Pe]=(0,a.useState)(null),[Le,Re]=(0,a.useState)(null),[ze,Oe]=(0,a.useState)(!1),[Ue,Ve]=(0,a.useState)(!1),[He,qe]=(0,a.useState)(null),[We,Ye]=(0,a.useState)(null),[Ge,Ke]=(0,a.useState)(!1),[Xe,Je]=(0,a.useState)(null),[$e,Qe]=(0,a.useState)(W||""),[Ze,et]=(0,a.useState)(Y||""),[tt,nt]=(0,a.useState)(G||""),[at,rt]=(0,a.useState)(K||""),[st,it]=(0,a.useState)(X||""),[ot,lt]=(0,a.useState)(J||""),[ct,dt]=(0,a.useState)(!1),[ut,mt]=(0,a.useState)(null),[ht,pt]=(0,a.useState)(!1),[gt,xt]=(0,a.useState)(null),[ft,bt]=(0,a.useState)(null),[yt,vt]=(0,a.useState)(ne||null),[wt,kt]=(0,a.useState)(!1),[jt,Dt]=(0,a.useState)(!1),[Ct,Nt]=(0,a.useState)(!1),[Ft,St]=(0,a.useState)(null),[Et,At]=(0,a.useState)(null),[Tt,Mt]=(0,a.useState)(!1),[_t,Bt]=(0,a.useState)(!1),[It,Pt]=(0,a.useState)(!1),[Lt,Rt]=(0,a.useState)(!1),[zt,Ot]=(0,a.useState)(null),Ut=(0,a.useRef)(null),Vt=(0,a.useRef)(null),[Ht,qt]=(0,a.useState)(!1),[Wt,Yt]=(0,a.useState)(null),[Gt,Kt]=(0,a.useState)(ae||null),[Xt,Jt]=(0,a.useState)(Number.isFinite(re)?Number(re):null),[$t,Qt]=(0,a.useState)(Number.isFinite(re)?Number(re):0),[Zt,en]=(0,a.useState)(!1),[tn,nn]=(0,a.useState)(!1),[an,rn]=(0,a.useState)(null),[sn,on]=(0,a.useState)(!1),ln=(0,a.useRef)(null);(0,a.useEffect)(()=>{if("undefined"===typeof window)return;const e=()=>{pe(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),(0,a.useEffect)(()=>{if(!x||"undefined"===typeof document)return;const e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[x]),(0,a.useEffect)(()=>{if(!x)return;const e=!me.current,t=ue.current!==v;(e||t)&&de(b),xe(w||""),Ne(null),Se(!(null===S||void 0===S||!S.enabled)),Ae(C||""),Me(C?"youtube":null),Pe(null),Qe(W||""),et(Y||""),nt(G||""),rt(K||""),it(XA(X)),lt(J||""),mt(null),xt(null),bt(null),vt(ne||null),St(null),At(null),Ot(null),Ut.current&&(Ut.current.value=""),
2Vt.current&&(Vt.current.value=""),Kt(ae||null),Jt(Number.isFinite(re)?Number(re):null),Qt(Number.isFinite(re)?Number(re):0),rn(null),on(!1),me.current=!0,ue.current=v},[x,v,w,S,C,W,Y,G,K,X,J,ne,ae,re,b]),(0,a.useEffect)(()=>{x||(me.current=!1)},[x]);const cn=(0,a.useCallback)(async()=>{if(k){Oe(!0),qe(null);try{const e=await async function(e){const t=await fetch("".concat(GA,"/youtube/auth/status"),{headers:{Authorization:"Bearer ".concat(e)}});if(!t.ok)throw new Error("Failed to check auth status");return t.json()}(k);Re(e)}catch(e){qe(e instanceof Error?e.message:"Failed to load YouTube auth status")}finally{Oe(!1)}}},[k]);(0,a.useEffect)(()=>{x&&k&&cn()},[x,cn,k]),(0,a.useEffect)(()=>{if(!x||"undefined"===typeof window)return;const e=new URLSearchParams(window.location.search),t=e.get("youtube_auth"),n=e.get("message");if(!t&&!e.has("session_settings"))return;"success"===t?(Ye("YouTube account connected."),qe(null),cn()):"error"===t&&qe(n||"YouTube authentication failed"),e.delete("youtube_auth"),e.delete("message"),e.delete("session_settings");const a=e.toString(),r="".concat(window.location.pathname).concat(a?"?".concat(a):"").concat(window.location.hash);window.history.replaceState({},document.title,r)},[x,cn]);const dn="w-full rounded-xl border px-3 py-2 text-sm ".concat(y?"border-white/10 bg-[rgba(17,27,42,0.44)] text-white placeholder-gray-500 backdrop-blur-[26px]":"border-[rgba(214,220,228,0.84)] bg-[rgba(255,255,255,0.48)] text-gray-900 placeholder-gray-400 backdrop-blur-[24px]"," focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/30"),un="".concat(y?"border-white/10 bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.1),transparent_24%),radial-gradient(circle_at_86%_12%,rgba(111,137,182,0.08),transparent_22%),linear-gradient(180deg,rgba(17,27,42,0.52),rgba(17,27,42,0.48))] text-gray-100 backdrop-blur-[36px]":"border-[rgba(214,220,228,0.84)] bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.1),transparent_24%),radial-gradient(circle_at_86%_12%,rgba(111,137,182,0.07),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.54),rgba(255,255,255,0.48))] text-gray-900 backdrop-blur-[34px]"),mn=(0,a.useCallback)(()=>{const e=XA(st);return{normalizedLocalVideoPath:e,data:{dropboxVideoUrl:$e||null,videoFilename:Ze||null,dropboxDrpUrl:tt||null,timelineName:at||null,localVideoPath:e||null,productionNotes:ot.trim()||null}}},[tt,$e,st,ot,at,Ze]),hn=(0,a.useMemo)(()=>{const{data:e}=mn();return(W||null)!==e.dropboxVideoUrl||(Y||null)!==e.videoFilename||(G||null)!==e.dropboxDrpUrl||(K||null)!==e.timelineName||(XA(X)||null)!==e.localVideoPath||((J||"").trim()||null)!==e.productionNotes},[mn,W,Y,G,K,X,J,$e,Ze,tt,at,st,ot]),pn=(0,a.useCallback)(async()=>{if(k){pt(!0),bt(null),xt(null);try{const e=await Op.ensureHesitationTranscript(v,k);xt(e.reused?"Hesitation transcript is already available.":"Hesitation transcript generated. Refreshing session state..."),await(null===D||void 0===D?void 0:D())}catch(e){bt(e instanceof Error?e.message:"Failed to generate hesitation transcript")}finally{pt(!1)}}else bt("Authentication required")},[D,v,k]),gn=!(null===yt||void 0===yt||!yt.s3Source.exists||null===yt||void 0===yt||!yt.videoMetadata.matchesDefaultProxyProfile||null!==yt&&void 0!==yt&&yt.proxy.ready),xn=(fn=A,E?"youtube"===fn?"YouTube":"dropbox"===fn?"Dropbox":"file"===fn?"Hosted AWS video":"Video link":"No playback source selected");var fn;const bn=!!H,yn=function(e){if(!e)return null;const t=[/(?:youtube\.com\/watch\?v=)([a-zA-Z0-9_-]{11})/,/(?:youtu\.be\/)([a-zA-Z0-9_-]{11})/,/(?:youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/(?:youtube\.com\/v\/)([a-zA-Z0-9_-]{11})/];for(const n of t){const t=e.match(n);if(null!==t&&void 0!==t&&t[1])return"https://img.youtube.com/vi/".concat(t[1],"/maxresdefault.jpg")}return null}(C),vn="file"===(null===yt||void 0===yt?void 0:yt.playbackSource)&&yt.playbackUrl||"file"===A&&E||null,wn=Number(null!==(t=null!==(n=null===yt||void 0===yt?void 0:yt.videoMetadata.duration)&&void 0!==n?n:ee)&&void 0!==t?t:0),kn=Gt||yn||"https://files.rescript.info/mlst-og-image.png",jn=Gt?"Custom session thumbnail":yn?"YouTube default thumbnail":"Default ReScript image",Dn=async()=>
2{if(v&&k){kt(!0),mt(null);try{const e=await Om.getVideoSourceStatus(v,k);vt(e),null===ie||void 0===ie||ie(e)}catch(e){mt(e.message||"Failed to load video source status")}finally{kt(!1)}}},Cn=(0,a.useCallback)(async()=>{if(v&&k){Mt(!0),Ot(null);try{const e=await Om.getSessionFcpxmlStatus(v,k);St(e)}catch(e){Ot(e.message||"Failed to load FCPXML status")}finally{Mt(!1)}}},[v,k]);(0,a.useEffect)(()=>{x&&"production"===ce&&k&&Cn()},[ce,x,Cn,k]),(0,a.useEffect)(()=>{const e=Vt.current;e&&(e.setAttribute("webkitdirectory",""),e.setAttribute("directory",""))},[]);const Nn=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!e||t>3)return null;try{var n;const t=await(null===(n=e.getFileHandle)||void 0===n?void 0:n.call(e,"Info.fcpxml"));if(null!==t&&void 0!==t&&t.getFile){const n=await t.getFile(),a=e.name||"Resolve.fcpxmld",r=/\.fcpxmld$/i.test(a)?a:"".concat(a,".fcpxmld");return new File([n],r,{type:"application/xml"})}}catch(l){}if(!e.entries)return null;var a,r=!1,s=!1;try{for(var i,o=function(e){var t,n,a,r=2;for("undefined"!=typeof Symbol&&(n=Symbol.asyncIterator,a=Symbol.iterator);r--;){if(n&&null!=(t=e[n]))return t.call(e);if(a&&null!=(t=e[a]))return new jA(t.call(e));n="@@asyncIterator",a="@@iterator"}throw new TypeError("Object is not async iterable")}(e.entries());r=!(i=await o.next()).done;r=!1){const[e,n]=i.value;{if("directory"!==(null===n||void 0===n?void 0:n.kind))continue;if(t>0&&!/\.fcpxmld$/i.test(e))continue;const a=await Nn(n,t+1);if(a)return a}}}catch(c){s=!0,a=c}finally{try{r&&null!=o.return&&await o.return()}finally{if(s)throw a}}return null},Fn=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(v&&k){Bt(!0),Ot(null);try{const n=await Om.uploadSessionFcpxml(v,e,k,{allowDurationMismatch:t.allowDurationMismatch,durationOverrideReason:t.allowDurationMismatch?"User confirmed FCPXML duration mismatch in Session Settings":void 0});
2St(n.status),At(null),Ut.current&&(Ut.current.value=""),Vt.current&&(Vt.current.value=""),await(null===D||void 0===D?void 0:D())}catch(a){if(!t.allowDurationMismatch&&(n=null===a||void 0===a?void 0:a.validation,(Array.isArray(null===n||void 0===n?void 0:n.errors)?n.errors:[]).some(e=>"fcpxml_video_duration_mismatch"===(null===e||void 0===e?void 0:e.code)||"fcpxml_audio_duration_mismatch"===(null===e||void 0===e?void 0:e.code)))){if(window.confirm(["This FCPXML timeline duration does not match the stored session audio/video duration.","","Upload it anyway? Use this only when you know the timeline has stray late clips or intentional extra timeline material."].join("\n")))return void await Fn(e,{allowDurationMismatch:!0})}Ot(a.message||"Failed to upload FCPXML")}finally{Bt(!1)}var n}},Sn=async e=>{const t=(e=>{const t=Array.from(e||[]).find(e=>{const t=e.webkitRelativePath||e.name;return/(^|\/)Info\.fcpxml$/i.test(t)});if(!t)return null;const n=(t.webkitRelativePath||"").split("/")[0]||"Resolve.fcpxmld",a=/\.fcpxmld$/i.test(n)?n:"".concat(n,".fcpxmld");return new File([t],a,{type:"application/xml"})})(e.target.files);if(!t)return Ot("No Info.fcpxml file was found inside the selected .fcpxmld package."),void(e.target&&(e.target.value=""));await Fn(t)},En=async e=>{if(v&&k){dt(!0),mt(null);try{const{normalizedLocalVideoPath:t,data:n}=mn();await Om.updateProductionMetadata(v,n,k),null===se||void 0===se||se(n),it(t),lt(n.productionNotes||""),(n.dropboxVideoUrl||n.localVideoPath)&&await Dn(),await(null===D||void 0===D?void 0:D()),e&&f()}catch(t){throw mt(t.message||"Failed to save production metadata"),t}finally{dt(!1)}}},An=(0,a.useCallback)(e=>{const t=ln.current;if(!t||!Number.isFinite(e))return;const n=Number.isFinite(t.duration)?t.duration:wn,a=Math.max(0,Number.isFinite(n)&&n>0?Math.min(e,Math.max(0,n-.05)):e);on(!1);try{t.currentTime=a}catch(r){}},[wn]),Tn=(0,a.useCallback)(e=>{const t=Number(e.target.value);Qt(t),An(t)},[An]),Mn=(0,a.useCallback)(async()=>{if(v&&k){en(!0),rn(null);try{const e=await Om.captureHostedThumbnailFrame(v,$t,k);Kt(e.customThumbnailUrl||null),Jt(Number.isFinite(e.customThumbnailTimeSeconds)?Number(e.customThumbnailTimeSeconds):null),Number.isFinite(e.customThumbnailTimeSeconds)&&Qt(Number(e.customThumbnailTimeSeconds)),await(null===D||void 0===D?void 0:D())}catch(e){rn(e.message||"Failed to save custom thumbnail")}finally{en(!1)}}},[D,v,$t,k]),_n=(0,a.useCallback)(async()=>{if(v&&k){nn(!0),rn(null);try{await Om.clearCustomThumbnail(v,k),Kt(null),Jt(null),await(null===D||void 0===D?void 0:D())}catch(e){rn(e.message||"Failed to clear custom thumbnail")}finally{nn(!1)}}},[D,v,k]);if((0,a.useEffect)(()=>{x&&"thumbnail"===ce&&vn&&An($t)},[ce,x,An,$t,vn]),!x)return null;const Bn=async e=>{if(!v||!k)return;const t=(null!==e&&void 0!==e?e:Ee).trim(),n=JA(t);if(t&&"youtube"!==n)Pe("Please enter a valid YouTube URL");else{Be(!0),Pe(null);try{const e=await Om.updateVideoUrl(v,t||null,k),n="youtube"===e.videoSource&&(e.youtubeUrl||e.videoUrl)||null;null===T||void 0===T||T(n),M&&M(e.videoUrl||null,e.videoSource||null),await(null===_||void 0===_?void 0:_()),await(null===D||void 0===D?void 0:D())}catch(a){Pe(a.message||"Failed to save YouTube URL")}finally{Be(!1)}}},In=async()=>{if(k&&"undefined"!==typeof window){Ve(!0),qe(null),Ye(null);try{const e=new URL(window.location.href);e.searchParams.set("session_settings","youtube");const t=await async function(e,t){const n=new URLSearchParams;t&&n.set("returnUrl",t);const a="".concat(GA,"/youtube/auth/url").concat(n.toString()?"?"+n.toString():""),r=await fetch(a,{headers:{Authorization:"Bearer ".concat(e)}});if(!r.ok){const e=await r.json();throw new Error(e.error||"Failed to get auth URL")}return(await r.json()).authUrl}(k,e.toString());window.location.assign(t)}catch(e){Ve(!1),qe(e instanceof Error?e.message:"Failed to start YouTube authentication")}}},Pn=async()=>{if(k){Ve(!0),qe(null),Ye(null);try{await async function(e){if(!(await fetch("".concat(GA,"/youtube/auth"),{method:"DELETE",headers:{Authorization:"Bearer ".concat(e)}})).ok)throw new Error("Failed to disconnect YouTube")}(k),Ye("YouTube account disconnected."),await cn()}catch(e){qe(e instanceof Error?e.message:"Failed to disconnect YouTube")}finally{Ve(!1)}}},Ln=async function(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(k&&v&&C){Ke(!0),Je(null),Ye(null);try{const t=await async function(e,t,n){let a,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{a=await fetch("".concat(YA,"/youtube-analytics/retention/").concat(e,"/fetch"),{method:"POST",headers:{Authorization:"Bearer ".concat(n),"Content-Type":"application/json"},body:JSON.stringify({youtubeUrl:t,forceRefresh:r})})}catch(s){throw new Error("Network error. Please check your connection and try again.")}if(!a.ok){const e=await KA(a);if(e.needsAuth)throw new Error("NEEDS_AUTH:"+e.message);throw new Error(e.error||e.message||"Failed to fetch retention data")}return KA(a)}(v,C,k,e);null===L||void 0===L||L(t),Ye(t.cached?"YouTube analytics refreshed from cache.":"YouTube analytics refreshed.")}catch(t){t instanceof Error&&t.message.startsWith("NEEDS_AUTH:")?Je("Connect your YouTube account to refresh analytics for this session."):Je(t instanceof Error?function(e){return e.message.startsWith("NEEDS_AUTH:")?e.message.substring(11):e.message}(t):"Failed to refresh YouTube analytics")}finally{Ke(!1)}}},Rn=e=>{let{label:t,value:n}=e;return(0,u.jsxs)("div",{className:"rounded-2xl border p-3 ".concat(y?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] ".concat(y?"text-gray-400":"text-gray-500"),children:t}),(0,u.jsx)("div",{className:"mt-2 text-base font-semibold",children:n})]})};return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"fixed inset-0 z-50 bg-black/55 backdrop-blur-sm",onClick:f}),(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex ".concat(he?"items-stretch justify-stretch p-0":"items-center justify-center p-4"),style:he?{paddingTop:"var(--app-mobile-top-offset)",paddingBottom:"var(--app-mobile-bottom-offset)",paddingLeft:"env(safe-area-inset-left, 0px)",paddingRight:"env(safe-area-inset-right, 0px)"}:void 0,children:(0,u.jsxs)("div",{className:"flex w-full overflow-hidden shadow-2xl ".concat(un," ").concat(he?"h-full rounded-none border-0":"h-[88vh] max-w-6xl rounded-[28px] border"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("aside",{className:"hidden w-72 flex-col border-r px-5 py-5 md:flex ".concat(y?"border-white/10 bg-[radial-gradient(circle_at_14%_12%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_86%_14%,rgba(111,137,
2182,0.07),transparent_22%),linear-gradient(180deg,rgba(8,15,27,0.32),rgba(8,15,27,0.28))] backdrop-blur-[36px]":"border-[#e5ebf2] bg-[radial-gradient(circle_at_14%_12%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_86%_14%,rgba(111,137,182,0.06),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.46),rgba(255,255,255,0.4))] backdrop-blur-[34px]"),children:[(0,u.jsxs)("div",{className:"mb-6 flex items-start gap-3",children:[(0,u.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl ".concat(y?"bg-white/8 backdrop-blur-xl":"bg-[rgba(255,255,255,0.6)] shadow-sm backdrop-blur-[24px]"),children:(0,u.jsx)(DA,{className:"h-5 w-5 text-primary-600"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-lg font-semibold",children:"Session Settings"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"One place for title, sharing, speakers, playback, and production controls."})]})]}),(0,u.jsx)("div",{className:"space-y-2",children:aT.map(e=>(0,u.jsxs)("button",{type:"button",onClick:()=>de(e.id),className:"w-full rounded-2xl border px-4 py-3 text-left transition-colors ".concat(ce===e.id?y?"border-primary-500/40 bg-primary-500/10 backdrop-blur-[30px]":"border-primary-300 bg-primary-50/78 backdrop-blur-[26px]":y?"border-transparent hover:border-white/10 hover:bg-white/8 backdrop-blur-[28px]":"border-transparent hover:border-[#e5ebf2] hover:bg-[rgba(255,255,255,0.56)] backdrop-blur-[28px]"),children:[(0,u.jsx)("div",{className:"text-sm font-semibold",children:e.title}),(0,u.jsx)("div",{className:"mt-1 text-xs leading-5 ".concat(y?"text-gray-400":"text-gray-500"),children:e.description})]},e.id))})]}),(0,u.jsxs)("section",{className:"flex min-w-0 flex-1 flex-col",children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-4 border-b px-4 py-4 md:px-7 md:py-5 ".concat(y?"border-white/10":"border-[#e5ebf2]"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-sm font-semibold uppercase tracking-[0.18em] text-primary-600",children:"Session"}),(0,u.jsx)("h3",{className:"mt-2 text-xl font-semibold md:text-2xl",children:w||"Untitled Session"}),(0,u.jsx)("p",{className:"mt-2 max-w-2xl text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:null===(r=aT.find(e=>e.id===ce))||void 0===r?void 0:r.description})]}),(0,u.jsx)("button",{type:"button",onClick:f,className:"rounded-2xl border p-2 transition-colors ".concat(y?"border-white/10 bg-white/8 hover:border-white/16":"border-[#d6dce4] bg-[rgba(255,255,255,0.72)] hover:border-[#c6d0dd] backdrop-blur-lg"),title:"Close settings",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]}),he&&(0,u.jsx)("div",{className:"border-b px-4 py-3 ".concat(y?"border-white/10 bg-[rgba(8,15,27,0.24)] backdrop-blur-[28px]":"border-[#e5ebf2] bg-[rgba(255,255,255,0.42)] backdrop-blur-[26px]"),children:(0,u.jsx)("div",{className:"scrollbar-hide overflow-x-auto pb-1",children:(0,u.jsx)("div",{className:"flex min-w-max gap-2",children:aT.map(e=>(0,u.jsx)("button",{type:"button",onClick:()=>de(e.id),className:"whitespace-nowrap rounded-full px-4 py-2 text-sm font-medium transition-colors ".concat(ce===e.id?y?"bg-primary-600/85 text-white backdrop-blur-xl":"bg-primary-100/80 text-primary-700 backdrop-blur-[24px]":y?"bg-white/8 text-gray-300 backdrop-blur-xl":"bg-[rgba(255,255,255,0.52)] text-gray-700 backdrop-blur-[24px]"),children:e.title},e.id))})})}),(0,u.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4 md:px-7 md:py-5",children:["title"===ce&&(0,u.jsxs)("div",{className:"space-y-5",children:[(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(_w,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Session Title"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Keep the session title editorially clean, or seed it from the transcript/YouTube title."})]})]}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsx)("input",{type:"text",value:ge,onChange:e=>xe(e.target.value),className:dn,placeholder:"Session title"}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:async()=>
2{if(k&&ge.trim()){be(!0),Ne(null);try{const e=await Om.updateTitle(v,ge.trim(),k);null===j||void 0===j||j(e.title),await(null===D||void 0===D?void 0:D())}catch(e){Ne(e.message||"Failed to save title")}finally{be(!1)}}},disabled:fe||!ge.trim(),className:"inline-flex items-center gap-2 rounded-xl bg-primary-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-700 disabled:opacity-50",children:[fe&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}),"Save Title"]}),(0,u.jsxs)("button",{type:"button",onClick:async()=>{if(k){ve(!0),Ne(null);try{const e=await Jh({sessionId:v},k);window.dispatchEvent(new CustomEvent("navigate-to-agent",{detail:{agentSessionId:e.agentSessionId}}))}catch(e){Ne(e.message||"Failed to start title generation")}finally{ve(!1)}}},disabled:ye,className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-gray-600 hover:border-gray-500 hover:bg-gray-700":"border-gray-300 hover:border-gray-400 hover:bg-gray-50"," disabled:opacity-50"),children:[ye?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(CA,{className:"h-4 w-4"}),"Start Title Agent"]})]})]})]}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(Au,{className:"h-5 w-5 text-red-500"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"YouTube Title Sync"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Pull the current title from the linked YouTube video and optionally keep checking with backoff."})]})]}),C?(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"rounded-2xl border p-4 text-sm ".concat(y?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Linked video:"})," ",C]}),(0,u.jsxs)("div",{className:"mt-2",children:[(0,u.jsx)("span",{className:"font-medium",children:"Last fetched title:"})," ",N||"Not fetched yet"]}),(0,u.jsxs)("div",{className:"mt-1 text-xs text-gray-500",children:["Last sync: ",$A(F)]}),(0,u.jsxs)("div",{className:"mt-1 text-xs text-gray-500",children:["Next check: ",$A(null===S||void 0===S?void 0:S.nextAttemptAt)]}),(null===S||void 0===S?void 0:S.lastError)&&(0,u.jsxs)("div",{className:"mt-2 text-xs text-red-500",children:["Last error: ",S.lastError]})]}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:async()=>{if(k){ke(!0),Ne(null);try{const e=await Om.syncTitleFromYouTube(v,{applyToSessionTitle:!0},k);e.sessionTitleChanged&&(xe(e.youtubeTitle),null===j||void 0===j||j(e.youtubeTitle)),Se(e.syncState.enabled),await(null===D||void 0===D?void 0:D())}catch(e){Ne(e.message||"Failed to sync title from YouTube")}finally{ke(!1)}}},disabled:we,className:"inline-flex items-center gap-2 rounded-xl bg-red-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-700 disabled:opacity-50",children:[we?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(vp,{className:"h-4 w-4"}),"Sync from YouTube"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async e=>{if(k){De(!0),Ne(null);try{const t=await Om.updateYoutubeTitleSync(v,e,k);Se(t.youtubeTitleSync.enabled),await(null===D||void 0===D?void 0:D())}catch(t){Ne(t.message||"Failed to update YouTube title sync")}finally{De(!1)}}})(!Fe)},disabled:je,className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(Fe?y?"border-brand-yellow bg-brand-yellow/15 text-brand-yellow":"border-[#d8c9a3] bg-[#fff3d6] text-[#7a560c]":y?"border-gray-600 hover:border-gray-500 hover:bg-gray-700":"border-gray-300 hover:border-gray-400 hover:bg-gray-50"," disabled:opacity-50"),children:[je?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):Fe?(0,u.jsx)(Ej,{className:"h-4 w-4"}):(0,u.jsx)(vp,{className:"h-4 w-4"}),Fe?"Disable Auto Sync":"Enable Auto Sync"]})]})]}):(0,u.jsx)("div",{className:"rounded-2xl border p-4 text-sm ".concat(y?"border-brand-yellow/40 bg-brand-yellow/10 text-brand-yellow":"border-[#e7c
2572] bg-[#fff6e5] text-[#7a560c]"),children:"Add a YouTube link in the Playback section before syncing the title."})]}),Ce&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:Ce})]}),"share"===ce&&(0,u.jsxs)("div",{className:"space-y-5",children:[(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(bj,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Homepage Visibility"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Control whether this session appears on the public homepage and /shows listing."})]})]}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("div",{className:"flex h-8 w-8 items-center justify-center rounded-full ".concat(oe?y?"bg-brand-yellow/20 text-brand-yellow":"bg-[#FFF4D9] text-[#C98A00]":y?"bg-gray-700 text-gray-400":"bg-gray-100 text-gray-400"),children:(0,u.jsx)(bj,{className:"h-4 w-4 ".concat(oe?"":"opacity-50")})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"text-sm font-medium",children:oe?"Published":"Not published"}),(0,u.jsx)("p",{className:"text-xs ".concat(y?"text-gray-500":"text-gray-400"),children:oe?"Visible on the public homepage and /shows page":"Hidden from the public homepage and /shows page"})]})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{if(k){qt(!0),Yt(null);try{const e=!oe;await Om.toggleHomepagePublish(v,e,k),null===le||void 0===le||le(e)}catch(e){Yt(e.message||"Failed to update publish status")}finally{qt(!1)}}})()},disabled:Ht,className:"relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary-500/30 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-wait ".concat(oe?y?"bg-brand-yellow":"bg-[#C98A00]":y?"bg-gray-600":"bg-gray-200"," ").concat(y?"focus:ring-offset-gray-800":"focus:ring-offset-white"),role:"switch","aria-checked":oe,"aria-label":oe?"Unpublish from homepage":"Publish to homepage",children:[(0,u.jsx)("span",{className:"pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out ".concat(oe?"translate-x-5":"translate-x-0")}),Ht&&(0,u.jsx)("span",{className:"absolute inset-0 flex items-center justify-center",children:(0,u.jsx)(Lo,{className:"h-3 w-3 animate-spin text-white"})})]})]}),Wt&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:Wt})]})]}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(gj,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Share Controls"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Manage public links, permissions, and access from here instead of opening a second dialog."})]})]}),(0,u.jsx)(qA,{isOpen:!0,embedded:!0,onClose:()=>{},sessionId:v,sessionTitle:w})]})]}),"speakers"===ce&&(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(xA,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Speaker Naming"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Rename diarized speakers inline and save without leaving settings."})]})]}),(0,u.jsx)(WA,{isOpen:!0,embedded:!0,onClose:()=>{},sessionId:v,speakers:R,speakerSegments:z,currentLabels:O,onSave:U||(async()=>{}),transcriptionChecksum:V,isYouTubeMode:q})]}),"transcript"===ce&&(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(_w,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Hesitation Transcript"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Generate an optional Deepgram pass with filler words preserved. It stays separate from the readable transcript and is intended for precision editing, gap analysis, and micro-cut decisions."})]})]}),(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-white/10 bg-white/[0.04] text-gray-300":"border-[rgba(214,220,228,0.84)] bg-white/70 text-gray-600"),children:bn?"A hesitation-preserving transcript is already stored for this session. Use the Transcript tab to switch into hesitation view and run hesitation-aware gap analysis.":"This is generated on demand because it is materially more expensive. Request it when you need to inspect filler sounds, evaluate micro-edits, or tighten delivery conservatively."}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{pn()},disabled:ht,className:"inline-flex items-center gap-2 rounded-2xl px-4 py-2 text-sm font-medium transition-colors disabled:cursor-wait disabled:opacity-70 ".concat(y?"bg-[#FFB52B] text-[#232E3F] hover:bg-[#f6c15e]":"bg-[#232E3F] text-white hover:bg-[#2f3c51]"),children:[ht?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(CA,{className:"h-4 w-4"}),(0,u.jsx)("span",{children:bn?"Regenerate hesitation transcript":"Generate hesitation transcript"})]}),bn&&H&&(0,u.jsxs)("span",{className:"rounded-full px-3 py-1 text-xs font-semibold ".concat(y?"bg-emerald-500/15 text-emerald-200":"bg-emerald-50 text-emerald-700"),children:["Stored checksum: ",H.slice(0,12),"\u2026"]})]}),gt&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-emerald-800 bg-emerald-900/20 text-emerald-200":"border-emerald-200 bg-emerald-50 text-emerald-700"),children:gt}),ft&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:ft})]}),"playback"===ce&&(0,u.jsxs)("div",{className:"space-y-5",children:[(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(gA,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Explicit YouTube Link"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Link a canonical YouTube video for synced playback. When empty, the player falls back to the hosted AWS source."})]})]}),(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsx)("input",{type:"url",value:Ee,onChange:e=>{const t=e.target.value;Ae(t),Me(JA(t)),Pe(null)},placeholder:"https://www.youtube.com/watch?v=...",className:dn}),Ee&&"youtube"===Te&&(0,u.jsx)("div",{className:"text-xs ".concat(y?"text-gray-400":"text-gray-500"),children:"YouTube URL detected."}),Ee&&"youtube"!==Te&&(0,u.jsx)("div",{className:"text-xs ".concat(y?"text-red-300":"text-red-600"),children:"Only YouTube URLs belong here."}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{Bn()},disabled:_e||""!==Ee.trim()&&"youtube"!==Te,className:"inline-flex items-center gap-2 rounded-xl bg-primary-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-700 disabled:opacity-50",children:[_e&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}),"Save Playback Link"]}),C&&(0,u.jsx)("button",{type:"button",onClick:()=>{Ae(""),Me(null),Bn("")},className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-red-700 text-red-300 hover:bg-red-900/20":"border-red-300 text-red-700 hover:bg-red-50"),children:"Remove Link"})]})]})]}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(Au,{className:"h-5 w-5 text-red-500"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Current Video Panel Source"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"The left panel now collapses into a slim reopen rail instead of a generic hide state."})]})]}),(0,u.jsxs)("div",{className:"rounded-2xl border p-4 text-sm ".concat(y?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Playing from:"})," ",xn]}),E&&(0,u.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,u.jsx)("span",{className:"font-medium",children:"URL:"}),(0,u.jsxs)("a",{href:E,target:"_blank",rel:"noreferrer",title:E,className:"inline-flex items-center gap-1 underline-offset-4 hover:underline ".concat(y?"text-brand-yellow":"text-brand-navy"),children:[(0,u.jsx)("span",{children:ZA(E)||"Open source URL"}),(0,u.jsx)(Ep,{className:"h-4 w-4"})]})]})]})]}),Ie&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:Ie})]}),"thumbnail"===ce&&(0,u.jsxs)("div",{className:"space-y-5",children:[(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(Ty,{
2className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Current Share Thumbnail"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"This image is used for homepage cards and public/share unfurls. YouTube stays the default until you explicitly save a hosted-video frame."})]})]}),(0,u.jsxs)("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,340px)_1fr]",children:[(0,u.jsx)("div",{className:"overflow-hidden rounded-2xl border ".concat(y?"border-gray-700 bg-gray-900/60":"border-gray-200 bg-gray-50"),children:(0,u.jsx)("div",{className:"aspect-[16/10] overflow-hidden",children:kn?(0,u.jsx)("img",{src:kn,alt:"Current session thumbnail",className:"h-full w-full object-cover"}):(0,u.jsx)("div",{className:"flex h-full w-full items-center justify-center text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"No thumbnail yet"})})}),(0,u.jsxs)("div",{className:"rounded-2xl border p-4 text-sm ".concat(y?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Source:"})," ",jn]}),null!=Xt&&(0,u.jsxs)("div",{className:"mt-1",children:[(0,u.jsx)("span",{className:"font-medium",children:"Captured at:"})," ",tT(Xt)]}),vn?(0,u.jsx)("div",{className:"mt-3 rounded-xl border px-3 py-2 text-xs ".concat(y?"border-brand-yellow/35 bg-brand-yellow/10 text-brand-yellow":"border-[#e7c572] bg-[#fff6e5] text-[#7a560c]"),children:"Hosted playback is available, so you can save a durable frame-based thumbnail below."}):(0,u.jsx)("div",{className:"mt-3 rounded-xl border px-3 py-2 text-xs ".concat(y?"border-gray-700 bg-gray-950/40 text-gray-400":"border-gray-200 bg-white text-gray-500"),children:"Attach or prepare a hosted AWS video if you want to capture a custom frame here."}),Gt&&(0,u.jsx)("div",{className:"mt-4",children:(0,u.jsxs)("button",{type:"button",onClick:()=>{_n()},disabled:tn,className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-red-700 text-red-300 hover:bg-red-900/20":"border-red-300 text-red-700 hover:bg-red-50"," disabled:opacity-50"),children:[tn?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(kp,{className:"h-4 w-4"}),"Clear Custom Thumbnail"]})})]})]})]}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(uj,{className:"h-5 w-5 text-brand-yellow"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Capture Hosted Video Frame"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Scrub through the hosted AWS video, preview the frame, and save it as the session thumbnail."})]})]}),vn?(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsx)("div",{className:"overflow-hidden rounded-2xl border ".concat(y?"border-gray-700 bg-black":"border-gray-200 bg-gray-100"),children:(0,u.jsx)("video",{ref:ln,src:vn,preload:"metadata",muted:!0,playsInline:!0,controls:!1,className:"aspect-video w-full object-contain",onLoadedMetadata:e=>{const t=Number.isFinite(e.currentTarget.duration)?e.currentTarget.duration:wn,n=Math.min($t,t||$t);Qt(n),An(n)},onSeeked:()=>on(!0)})}),(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,u.jsx)("span",{className:y?"text-gray-400":"text-gray-500",children:"Preview position"}),(0,u.jsxs)("span",{className:"font-medium",children:[tT($t),wn>0?" / ".concat(tT(wn)):""]})]}),(0,u.jsx)("input",{type:"range",min:0,max:wn>0?wn:0,step:.25,value:Math.min($t,wn>0?wn:$t),onChange:Tn,className:"w-full accent-primary-600"})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{Mn()},disabled:Zt||!sn,className:"inline-flex items-center gap-2 rounded-xl bg-primary-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-700 disabled:opacity-50",children:[Zt?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}
2):(0,u.jsx)(Ty,{className:"h-4 w-4"}),"Save This Frame"]}),!sn&&(0,u.jsx)("span",{className:"text-xs ".concat(y?"text-gray-400":"text-gray-500"),children:"Seeking preview frame\u2026"})]})]}):(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-brand-yellow/40 bg-brand-yellow/10 text-brand-yellow":"border-[#e7c572] bg-[#fff6e5] text-[#7a560c]"),children:"Prepare or attach a hosted AWS video first. Once the session has hosted playback, this section becomes a frame picker."})]}),an&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:an})]}),"youtube"===ce&&(0,u.jsxs)("div",{className:"space-y-5",children:[(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(Au,{className:"h-5 w-5 text-red-500"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"YouTube Connector"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Connect or reconnect YouTube for analytics fetches, retention sync, and publish-time operations."})]})]}),(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,u.jsx)(Rn,{label:"Connection",value:ze?"Loading\u2026":null!==Le&&void 0!==Le&&Le.authenticated?"Connected":"Disconnected"}),(0,u.jsx)(Rn,{label:"Token expiry",value:null!==Le&&void 0!==Le&&Le.tokenExpiry?nT(Le.tokenExpiry):"Unknown"}),(0,u.jsx)(Rn,{label:"Read metadata",value:null!==Le&&void 0!==Le&&Le.canReadVideoMetadata?"Enabled":"Unavailable"}),(0,u.jsx)(Rn,{label:"Edit videos",value:null!==Le&&void 0!==Le&&Le.canEditVideos?"Enabled":"Unavailable"})]}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{In()},disabled:Ue||!k,className:"inline-flex items-center gap-2 rounded-xl bg-red-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-700 disabled:opacity-50",children:[Ue?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Au,{className:"h-4 w-4"}),null!==Le&&void 0!==Le&&Le.authenticated?"Reconnect YouTube":"Connect YouTube"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{Pn()},disabled:Ue||!(null!==Le&&void 0!==Le&&Le.authenticated),className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-red-700 text-red-300 hover:bg-red-900/20":"border-red-300 text-red-700 hover:bg-red-50"," disabled:opacity-50"),children:[Ue?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Pu,{className:"h-4 w-4"}),"Disconnect"]})]}),We&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-emerald-700/60 bg-emerald-900/20 text-emerald-200":"border-emerald-200 bg-emerald-50 text-emerald-700"),children:We}),He&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:He})]}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(YE,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Session Analytics"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Refresh the linked video\u2019s YouTube stats and retention context. The retention graph updates elsewhere in the session view."})]})]}),C?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"mb-4 rounded-2xl border p-4 text-sm ".concat(y?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Linked video:"})," ",C]}),(0,u.jsxs)("div",{className:"mt-1",children:[(0,u.jsx)("span",{className:"font-medium",children:"Last analytics fetch:"})," ",P?$A(P):"Never"]}),(null===B||void 0===B?void 0:B.videoTitle)&&(0,u.jsxs)("div",{className:"mt-1",children:[(0,u.jsx)("span",{className:"font-medium",children:"Video title:"})," ",B.videoTitle]})]}),(0,u.jsx)("div",{className:"mb-4 flex flex-wrap gap-3",children:(0,u.jsxs)("button",{type:"button",onClick:()=>{Ln(!0)},disabled:Ge||!k,className:"inline-flex items-center gap-2 rounded-xl bg-primary-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-700 disabled:opacity-50",children:[Ge?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(vp,{className:"h-4 w-4"}),B?"Refresh YouTube Data":"Fetch YouTube Data"]})}),B?(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[(0,u.jsx)(Rn,{label:"Views",value:eT(B.views)}),(0,u.jsx)(Rn,{label:"Likes",value:eT(B.likes)}),(0,u.jsx)(Rn,{label:"Comments",value:eT(B.comments)}),(0,u.jsx)(Rn,{label:"Shares",value:eT(B.shares)}),(0,u.jsx)(Rn,{label:"Net subscribers",value:eT((B.subscribersGained||0)-(B.subscribersLost||0))}),(0,u.jsx)(Rn,{label:"Watch time",value:null!=B.estimatedMinutesWatched?"".concat(eT(Math.round(B.estimatedMinutesWatched))," min"):"-"}),(0,u.jsx)(Rn,{label:"Avg view duration",value:tT(B.averageViewDuration)}),(0,u.jsx)(Rn,{label:"Avg % viewed",value:null!=B.averageViewPercentage?"".concat(B.averageViewPercentage.toFixed(1),"%"):"-"}),(0,u.jsx)(Rn,{label:"Video length",value:tT(I)}
2),(0,u.jsx)(Rn,{label:"Published",value:B.videoPublishedAt?new Date(B.videoPublishedAt).toLocaleDateString():"-"})]}):(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-gray-700 bg-gray-900/50 text-gray-300":"border-gray-200 bg-gray-50 text-gray-600"),children:"No cached YouTube analytics yet. Fetch the data once the connector is authenticated."})]}):(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-brand-yellow/40 bg-brand-yellow/10 text-brand-yellow":"border-[#e7c572] bg-[#fff6e5] text-[#7a560c]"),children:"Add a YouTube link in Playback before pulling stats or retention data."}),Xe&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:Xe})]})]}),"production"===ce&&(0,u.jsxs)("div",{className:"space-y-5",children:[(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(uj,{className:"h-5 w-5 text-brand-yellow"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Production Metadata"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Keep Dropbox, timeline, DRP, and local source metadata off the title strip and in one dedicated pane."})]})]}),(0,u.jsx)(oh,{values:{dropboxVideoUrl:$e,videoFilename:Ze,dropboxDrpUrl:tt,timelineName:at,localVideoPath:st,productionNotes:ot,autoPrepareVideoSource:!0},onChange:e=>{void 0!==e.dropboxVideoUrl&&Qe(e.dropboxVideoUrl),void 0!==e.videoFilename&&et(e.videoFilename),void 0!==e.dropboxDrpUrl&&nt(e.dropboxDrpUrl),void 0!==e.timelineName&&rt(e.timelineName),void 0!==e.localVideoPath&&it(e.localVideoPath),void 0!==e.productionNotes&<(e.productionNotes)},isDarkMode:y,compact:!0}),(0,u.jsx)("div",{className:"mt-4 flex flex-wrap gap-3",children:(0,u.jsxs)("button",{type:"button",onClick:()=>{En(!1)},disabled:ct,className:"inline-flex items-center gap-2 rounded-xl bg-brand-yellow px-4 py-2 text-sm font-medium text-brand-navy transition-colors hover:bg-[#f0a91a] disabled:opacity-50",children:[ct&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}),"Save Production Metadata"]})})]}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(uj,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Final Cut Pro XML"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Multicam timeline attachment for conform exports."})]})]}),(0,u.jsx)("div",{className:"rounded-2xl border p-4 text-sm ".concat(y?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:Tt?(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}),"Loading FCPXML status"]}):null!==Ft&&void 0!==Ft&&Ft.available?(0,u.jsxs)("div",{className:"space-y-1",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"File:"})," ",Ft.filename||"timeline.fcpxml"]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Timeline:"})," ",Ft.timelineName||"Untitled"]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Duration:"})," ",tT(Ft.durationSeconds)," (",null!==(s=Ft.durationFrames)&&void 0!==s?s:"-"," frames)"]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Size:"})," ",QA(Ft.fileSize)]}),null!=Ft.detectedFrameRate&&(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Frame rate:"})," ",Ft.detectedFrameRate," fps"]}),null!==(i=Ft.validation)&&void 0!==i&&null!==(o=i.warnings)&&void 0!==o&&o.length?(0,u.jsxs)("div",{className:y?"text-amber-300":"text-amber-700",children:[Ft.validation.warnings.length," validation warning",1===Ft.validation.warnings.length?"":"s"]}):null]}):(0,u.jsx)("div",{className:y?"text-gray-400":"text-gray-500",children:"No FCPXML attachment stored for this session."})}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3",children:[(0,u.jsx)("input",{ref:Ut,type:"file",accept:".fcpxml,.fcpxmld,.xml,application/xml,text/xml,application/octet-stream",onChange:e=>{var t;return At((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)},disabled:_t||!k,className:"max-w-full text-sm ".concat(y?"text-gray-300 file:bg-gray-800 file:text-gray-200":"text-gray-600 file:bg-white file:text-gray-700"," file:mr-3 file:rounded-xl file:border file:border-gray-300 file:px-3 file:py-2 file:text-sm file:font-medium")}),(0,u.jsx)("input",{ref:e=>{Vt.current=e,e&&(e.setAttribute("webkitdirectory",""),e.setAttribute("directory",""))},type:"file",multiple:!0,onChange:e=>{Sn(e)},disabled:_t||!k,className:"hidden"}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{v&&k&&Et&&await Fn(Et)})()},disabled:!Et||_t||!k,className:"inline-flex items-center gap-2 rounded-xl bg-primary-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-700 disabled:opacity-50",children:[_t?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Eu,{className:"h-4 w-4"}),"Upload File"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{var e;Ot(null);const t=window.showDirectoryPicker;if("function"===typeof t)try{const e=await t({mode:"read"}),n=await Nn(e);return n?void await Fn(n):void Ot("No Info.fcpxml file was found inside the selected .fcpxmld package.")}catch(n){if("AbortError"===(null===n||void 0===n?void 0:n.name))return;return void Ot((null===n||void 0===n?void 0:n.message)||"Failed to read the selected .fcpxmld package.")}null===(e=Vt.current)||void 0===e||e.click()})()},disabled:_t||!k,className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-gray-600 hover:border-gray-500 hover:bg-gray-700":"border-gray-300 hover:border-gray-400 hover:bg-gray-50"," disabled:opacity-50"),children:[_t?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Eu,{className:"h-4 w-4"}),"Upload Package"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>
2{if(v&&k&&null!==Ft&&void 0!==Ft&&Ft.available){Pt(!0),Ot(null);try{const{blob:e,filename:t}=await Om.downloadSessionFcpxml(v,k),n=URL.createObjectURL(e),a=document.createElement("a");a.href=n,a.download=t,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(n)}catch(e){Ot(e.message||"Failed to download FCPXML")}finally{Pt(!1)}}})()},disabled:!(null!==Ft&&void 0!==Ft&&Ft.available)||It||!k,className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-gray-600 hover:border-gray-500 hover:bg-gray-700":"border-gray-300 hover:border-gray-400 hover:bg-gray-50"," disabled:opacity-50"),children:[It?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Sp,{className:"h-4 w-4"}),"Download"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{if(v&&k&&null!==Ft&&void 0!==Ft&&Ft.available&&window.confirm("Delete the stored Final Cut Pro XML attachment for this session?")){Rt(!0),Ot(null);try{const e=await Om.deleteSessionFcpxml(v,k);St(e.status),await(null===D||void 0===D?void 0:D())}catch(e){Ot(e.message||"Failed to delete FCPXML")}finally{Rt(!1)}}})()},disabled:!(null!==Ft&&void 0!==Ft&&Ft.available)||Lt||!k,className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-red-700 text-red-300 hover:bg-red-900/20":"border-red-300 text-red-700 hover:bg-red-50"," disabled:cursor-not-allowed disabled:opacity-50"),children:[Lt?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(kp,{className:"h-4 w-4"}),"Delete"]})]}),null!==Ft&&void 0!==Ft&&null!==(l=Ft.validation)&&void 0!==l&&null!==(c=l.durationChecks)&&void 0!==c&&c.length?(0,u.jsx)("div",{className:"mt-4 grid gap-2 text-xs ".concat(y?"text-gray-400":"text-gray-500"),children:Ft.validation.durationChecks.map(e=>(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[(0,u.jsxs)("span",{className:"font-medium",children:[e.label.replace(/_/g," "),":"]}),(0,u.jsx)("span",{children:e.skipped?"not checked":e.valid?"matched":"mismatch"}),null!=e.deltaSeconds&&(0,u.jsxs)("span",{children:["delta ",e.deltaSeconds.toFixed(3),"s"]})]},e.label))}):null,zt&&(0,u.jsx)("div",{className:"mt-4 rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:zt})]}),(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(qE,{className:"h-5 w-5 text-brand-yellow"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"AWS Video Source"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Prepare or refresh the hosted playback source that the collapsed video rail reopens."})]})]}),(0,u.jsxs)("div",{className:"mb-4 flex flex-wrap gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{Dn()},disabled:wt||!k,className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-gray-600 hover:border-gray-500 hover:bg-gray-700":"border-gray-300 hover:border-gray-400 hover:bg-gray-50"," disabled:opacity-50"),children:[wt?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(vp,{className:"h-4 w-4"}),"Refresh Status"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{if(v&&k){Dt(!0),mt(null);try{hn&&await En(!1);const e=await Om.prepareVideoSource(v,{proxyMode:"fast"},k);e.videoSourceStatus?(vt(e.videoSourceStatus),null===ie||void 0===ie||ie(e.videoSourceStatus)):await Dn(),await(null===_||void 0===_?void 0:_()),await(null===D||void 0===D?void 0:D())}catch(e){mt(e.message||"Failed to queue AWS video preparation")}finally{Dt(!1)}}})()},disabled:jt||!k||!($e||W||null!==yt&&void 0!==yt&&yt.sourceAvailable)||gn,className:"inline-flex items-center gap-2 rounded-xl bg-primary-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-700 disabled:opacity-50",children:[jt?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(qE,{className:"h-4 w-4"}),"Prepare In AWS"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>{var e,t;if(v&&k&&(null!==yt&&void 0!==yt&&null!==(e=yt.proxy)&&void 0!==e&&e.s3Key||null!==yt&&void 0!==yt&&null!==(t=yt.proxy)&&void 0!==t&&t.ready)&&window.confirm("Delete the prepared AWS proxy for this session? The original source metadata will remain.")){Nt(!0),mt(null);try{const e=await Om.deleteVideoSourceProxy(v,k);e.videoSourceStatus?(vt(e.videoSourceStatus),null===ie||void 0===ie||ie(e.videoSourceStatus)):await Dn(),await(null===_||void 0===_?void 0:_()),await(null===D||void 0===D?void 0:D())}catch(n){mt(n.message||"Failed to delete AWS proxy")}finally{Nt(!1)}}})()},disabled:Ct||!k||!(null!==yt&&void 0!==yt&&null!==(d=yt.proxy)&&void 0!==d&&d.s3Key)&&!(null!==yt&&void 0!==yt&&null!==(m=yt.proxy)&&void 0!==m&&m.ready),className:"inline-flex items-center gap-2 rounded-xl border px-4 py-2 text-sm font-medium transition-colors ".concat(y?"border-red-700 text-red-300 hover:bg-red-900/20":"border-red-300 text-red-700 hover:bg-red-50"," disabled:cursor-not-allowed disabled:opacity-50"),children:[Ct?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(kp,{className:"h-4 w-4"}),"Delete Proxy"]})]}),yt&&(0,u.jsxs)("div",{className:"rounded-2xl border p-4 text-sm ".concat(y?"border-gray-700 bg-gray-900/50":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Source:"})," ",yt.s3Source.exists?"Uploaded to S3":yt.dropboxVideoUrl?"Dropbox URL only":"Missing"]}),(0,u.jsxs)("div",{className:"mt-1",children:[(0,u.jsx)("span",{className:"font-medium",children:"Proxy:"})," ",yt.proxy.ready?"Ready":yt.proxy.notNeeded?"Not needed":yt.proxy.status]}),null!=yt.proxy.fileSize&&(0,u.jsxs)("div",{className:"mt-1",children:[(0,u.jsx)("span",{className:"font-medium",children:"Proxy size:"})," ",QA(yt.proxy.fileSize)]}),yt.playbackKind&&(0,u.jsxs)("div",{className:"mt-1",children:[(0,u.jsx)("span",{className:"font-medium",children:"Playback:"})," ",yt.playbackKind]}),yt.proxy.errorMessage&&(0,u.jsx)("div",{className:"mt-1 text-red-500",children:yt.proxy.errorMessage})]})]}),($||Q||Z||ee||te||(null===yt||void 0===yt?void 0:yt.videoMetadata.fileSize)||(null===yt||void 0===yt?void 0:yt.videoMetadata.duration)||(null===yt||void 0===yt?void 0:yt.videoMetadata.width)||(null===yt||void 0===yt?void 0:yt.videoMetadata.codec))&&(0,u.jsxs)("div",{className:"rounded-3xl border p-5 ".concat(un),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)(Np,{className:"h-5 w-5 text-primary-600"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-base font-semibold",children:"Video Source Info"}),(0,u.jsx)("p",{className:"text-sm ".concat(y?"text-gray-400":"text-gray-500"),children:"Low-level source metadata for sanity checks."})]})]}),(0,u.jsxs)("div",{className:"rounded-2xl border p-4 text-xs font-mono ".concat(y?"border-gray-700 bg-gray-900/60 text-gray-300":"border-gray-200 bg-gray-50 text-gray-700"),children:[$&&(0,u.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,u.jsxs)("span",{children:["Source hash: ",$.substring(0,16),"...",$.substring($.length-8)]}),(0,u.jsx)("button",{type:"button",onClick:()=>{navigator.clipboard.writeText($)},className:"rounded p-1 transition-colors ".concat(y?"hover:bg-gray-800":"hover:bg-white"),title:"Copy full source hash",children:(0,u.jsx)(Np,{className:"h-3 w-3"})})]}),null!=(null!==Q&&void 0!==Q?Q:null===yt||void 0===yt?void 0:yt.videoMetadata.fileSize)&&(0,u.jsxs)("div",{children:["Size: ",((null!==(h=null!==Q&&void 0!==Q?Q:null===yt||void 0===yt?void 0:yt.videoMetadata.fileSize)&&void 0!==h?h:0)/1073741824).toFixed(2)," GB"]}),null!=(null!==Z&&void 0!==Z?Z:null===yt||void 0===yt?void 0:yt.videoMetadata.frameRate)&&(0,u.jsxs)("div",{className:"mt-1",children:["FPS: ",null!==Z&&void 0!==Z?Z:null===yt||void 0===yt?void 0:yt.videoMetadata.frameRate]}),((null===yt||void 0===yt?void 0:yt.videoMetadata.width)||(null===yt||void 0===yt?void 0:yt.videoMetadata.height))&&(0,u.jsxs)("div",{className:"mt-1",children:["Resolution: ",null!==(p=null===yt||void 0===yt?void 0:yt.videoMetadata.width)&&void 0!==p?p:"?","x",null!==(g=null===yt||void 0===yt?void 0:yt.videoMetadata.height)&&void 0!==g?g:"?"]}),(null===yt||void 0===yt?void 0:yt.videoMetadata.codec)&&(0,u.jsxs)("div",{className:"mt-1",children:["Codec: ",yt.videoMetadata.codec]}),null!=(null!==ee&&void 0!==ee?ee:null===yt||void 0===yt?void 0:yt.videoMetadata.duration)&&null!=te&&(0,u.jsxs)("div",{className:"mt-1",children:["Duration: ",Math.floor((null!==ee&&void 0!==ee?ee:null===yt||void 0===yt?void 0:yt.videoMetadata.duration)/60),":",String(Math.floor((null!==ee&&void 0!==ee?ee:null===yt||void 0===yt?void 0:yt.videoMetadata.duration)%60)).padStart(2,"0")," / ",Math.floor(te/60),":",String(Math.floor(te%60)).padStart(2,"0")]})]})]}),ut&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(y?"border-red-800 bg-red-900/20 text-red-200":"border-red-200 bg-red-50 text-red-700"),children:ut})]})]})]})]})})]})},sT=e=>{var t;let{isDarkMode:n,toggleDarkMode:r,userName:s,userEmail:i,userPicture:o,onLogout:l,onHome:c,onToggleUpload:d,uploadVisible:m,sessionId:h,sessionTitle:p,sessionShowSlug:g,sessionShowTitle:x,sessionFamily:f,token:b,onTitleUpdate:y,onSessionRefresh:v,activeTabId:w,onTabChange:k,availableTabIds:j,selectedTtmlName:D,youtubeUrl:C,youtubeTitle:N,youtubeTitleUpdatedAt:F,youtubeTitleSync:S,onYoutubeUrlChange:E,videoUrl:A,videoSource:T,onVideoUrlChange:M,onRefreshVideoSource:_,onToggleYoutubePlayer:B,isYoutubePlayerVisible:I,videoStats:P,videoDurationSeconds:L,fetchedAt:R,onRetentionDataUpdate:z,speakerIds:O,speakerSegments:U,speakerLabels:V,onSaveSpeakerLabels:H,transcriptionChecksum:q,hesitationTranscriptChecksum:W,isYouTubeMode:Y,dropboxVideoUrl:G,videoFilename:K,dropboxDrpUrl:X,timelineName:J,localVideoPath:$,productionNotes:Q,videoFileHash:Z,videoFileSize:ee,videoFrameRate:te,videoDuration:ne,audioDuration:ae,videoSourceStatus:re,customThumbnailUrl:se,customThumbnailTimeSeconds:ie,onProductionMetadataUpdate:oe,onVideoSourceStatusUpdate:le,publishedToHomepage:ce,onPublishChange:de,isOfflineAvailable:ue=!1,isOfflineMode:me=!1,isOfflineActionPending:he=!1,offlineActionStatusLabel:pe,onToggleOfflineAvailability:ge,onCopyOfflineDiagnostics:xe,onNavigateToFamilyMember:fe}=e;const be=oc(),{permissions:ye,metadata:ve}=Hp(),{isCompactTouchLayout:we}=Ww(),[ke,je]=(0,a.useState)(!1),[De,Ce]=(0,a.useState)(!1),[Ne,Fe]=(0,a.useState)(!1),[Se,Ee]=(0,a.useState)(!1),[Ae,Te]=(0,a.useState)(!1),[Me,_e]=(0,a.useState)(!1),[Be,Ie]=(0,a.useState)("title"),[Pe,Le]=(0,a.useState)(!1),[Re,ze]=(0,a.useState)(!1),[Oe,Ue]=(0,a.useState)(!1),Ve=a.useRef(null),He=!!ye,qe=!!h,We=!!h&&!He&&!!b,Ye=He?"Shared Review":qe?"MLST Session":"MLST Workspace",Ge=me&&qe?"ReScript (Offline)":"ReScript",Ke=n?"border-white/10 bg-[rgba(27,36,50,0.54)] text-[#F4F4F4] backdrop-blur-[32px]":"border-[rgba(214,220,228,0.86)] bg-[rgba(244,244,244,0.52)] text-[#232E3F] backdrop-blur-[32px]",Xe=n?"border-white/10 bg-[rgba(16,25,37,0.36)] text-[#D7DDE5] backdrop-blur-[30px]":"border-[rgba(214,220,228,0.84)] bg-[rgba(255,255,255,0.46)] text-[#566377] backdrop-blur-[30px]",Je=n?"text-[#C6CDD8]":"text-[#566377]",$e=n?"border-[#FFB52B]/20 bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.12),transparent_24%),radial-gradient(circle_at_86%_14%,rgba(151,174,214,0.08),transparent_22%),radial-gradient(circle_at_24%_84%,rgba(86,121,181,0.08),transparent_26%),radial-gradient(circle_at_92%_82%,rgba(248,113,113,0.06),transparent_20%),linear-gradient(180deg,rgba(35,46,63,0.78),rgba(28,38,52,0.8))] text-[#F4F4F4] shadow-[0_24px_40px_-28px_rgba(10,14,20,0.72)]":"border-[#D6DCE4] bg-[radial-gradient(circle_at_10%_16%,rgba(255,181,43,0.12),transparent_22%),radial-gradient(circle_at_88%_12%,rgba(95,125,175,0.08),transparent_22%),radial-gradient(circle_at_22%_84%,rgba(121,146,188,0.08),transparent_24%),radial-gradient(circle_at_92%_80%,rgba(255,137,137,0.05),transparent_18%),linear-gradient(180deg,rgba(255,255,255,0.92),rgba(244,244,244,0.9))] text-[#232E3F] shadow-[0_22px_44px_-34px_rgba(35,46,63,0.28)]",Qe=n?"inline-flex min-h-[44px] min-w-[44px] items-center justify-center gap-2 rounded-full border border-white/[0.12] bg-white/[0.06] px-2.5 py-2 font-headlines text-sm font-semibold text-[#F4F4F4] shadow-[0_14px_24px_-20px_rgba(0,0,0,0.7)] transition-all hover:border-[#FFB52B]/[0.45] hover:bg-[#FFB52B] hover:text-[#232E3F] sm:min-w-0 sm:px-4":"inline-flex min-h-[44px] min-w-[44px] items-center justify-center gap-2 rounded-full border border-[#D6DCE4] bg-white/[0.92] px-2.5 py-2 font-headlines text-sm font-semibold text-[#2A3649] shadow-[0_14px_24px_-20px_rgba(35,46,63,0.24)] transition-all hover:border-[#FFB52B]/[0.5] hover:bg-[#FFB52B] hover:text-[#232E3F] sm:min-w-0 sm:px-4",Ze=we?"h-8 w-8":"h-11 w-11",et="inline-flex ".concat(Ze,n?" items-center justify-center rounded-full border border-white/[0.12] bg-white/[0.06] text-[#F4F4F4] shadow-[0_14px_24px_-20px_rgba(0,0,0,0.7)] transition-all hover:border-[#FFB52B]/[0.45] hover:bg-[#FFB52B] hover:text-[#232E3F]":" items-center justify-center rounded-full border border-[#D6DCE4] bg-white/[0.92] text-[#2A3649] shadow-[0_14px_24px_-20px_rgba(35,46,63,0.24)] transition-all hover:border-[#FFB52B]/[0.5] hover:bg-[#FFB52B] hover:text-[#232E3F]"),tt=n?"text-[#FFB52B]/80":"text-[#A36A00]",nt=n?"text-[#F4F4F4]":"text-[#232E3F]",at=n?"text-[#F4F4F4]":"text-[#232E3F]",rt=n?"text-[#D5D9E0]":"text-[#5B687C]",st=n?"border-white/10":"border-[#D6DCE4]",it=n?"border border-[#FFB52B]/20 bg-[#FFB52B]/[0.12] text-[#FFE3A1]":"border border-[#FFB52B]/35 bg-[#FFF5DE] text-[#8A6100]",ot=n?"rounded-full border border-white/[0.12] bg-white/[0.08] px-3 py-1.5 text-xs font-semibold text-[#F4F4F4]":"rounded-full border border-[#D6DCE4] bg-white/[0.92] px-3 py-1.5 text-xs font-semibold text-[#2A3649]",lt=qe&&we&&Oe,ct=qe&&"readable"===w&&!we;(0,a.useEffect)(()=>{we?qe&&Ue(!0):Ue(!1)},[we,qe,h]),(0,a.useEffect)(()=>
2{if("undefined"===typeof window||!We)return;const e=new URLSearchParams(window.location.search).get("session_settings");e&&["title","share","speakers","playback","youtube","production"].includes(e)&&(Ie(e),_e(!0))},[We,h]),(0,a.useEffect)(()=>{if(!Re)return;const e=e=>{var t;null!==(t=Ve.current)&&void 0!==t&&t.contains(e.target)||ze(!1)},t=e=>{"Escape"===e.key&&ze(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[Re]);const dt=!He&&!!x&&"mlst"!==g&&"Machine Learning Street Talk"!==x,ut=!He&&!!f;return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("header",{className:"relative z-50 flex-shrink-0 border-b backdrop-blur-xl ".concat($e),children:lt?(0,u.jsx)("div",{className:"px-3 py-1.5",children:(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.28em] ".concat(tt),children:Ye}),(0,u.jsx)("span",{className:"block truncate font-headlines text-sm font-bold ".concat(at),children:p||"Session"})]}),(0,u.jsx)("div",{className:"flex min-w-0 shrink items-center gap-2",children:(0,u.jsx)("button",{type:"button",onClick:()=>Ue(!1),className:et,title:"Expand header",children:(0,u.jsx)(wd,{className:"h-5 w-5"})})})]})}):(0,u.jsxs)("div",{className:"".concat(we?"px-3 py-2":"px-4 py-4"," md:px-6"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:c,className:"flex min-w-0 items-center transition-opacity hover:opacity-85 ".concat(we?"gap-1.5":"gap-2 md:gap-3"," ").concat(we?"shrink":"shrink-0"),title:"Go to home",children:[(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"ReScript",className:"".concat(we?"h-7":"h-9 md:h-11"," w-auto shrink-0")}),(0,u.jsxs)("div",{className:"min-w-0 text-left",children:[(0,u.jsx)("p",{className:"truncate font-headlines font-semibold uppercase ".concat(we?"text-[8px] tracking-[0.12em]":"text-[10px] tracking-[0.16em] md:tracking-[0.28em]"," ").concat(tt),children:Ye}),(0,u.jsx)("span",{className:"block truncate font-headlines font-bold ".concat(we?"text-sm leading-tight":"text-lg md:text-xl"," ").concat(nt),children:Ge})]})]}),ct&&(0,u.jsx)("div",{className:"flex min-w-0 flex-1 items-center justify-center",children:(0,u.jsx)("div",{id:"readable-transcript-header-toolbar-slot",className:"flex w-full max-w-[58rem] min-w-0 items-center justify-center"})}),(0,u.jsx)("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:qe?(0,u.jsx)(u.Fragment,{children:we?(0,u.jsx)("div",{className:"flex",children:(0,u.jsxs)("div",{className:"flex min-w-0 items-center gap-2 whitespace-nowrap",children:[(0,u.jsx)("button",{type:"button",onClick:()=>Le(!0),className:et,title:"Open session menu",children:(0,u.jsx)(WE,{className:"h-5 w-5"})}),(0,u.jsx)("button",{type:"button",onClick:()=>He?Te(!0):Ee(!0),className:et,title:He?"Share information":"About ReScript",children:(0,u.jsx)(jp,{className:"h-5 w-5"})})]})}):(0,u.jsx)("div",{className:"flex",children:(0,u.jsxs)("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[ge&&(0,u.jsxs)("button",{type:"button",onClick:()=>{ge()},disabled:he,className:"".concat(Qe," ").concat(he?"cursor-wait opacity-70":""),title:ue?"Remove offline copy":"Make available offline",children:[he?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):ue?(0,u.jsx)(HE,{className:"h-4 w-4"}):(0,u.jsx)(qE,{className:"h-4 w-4"}),(0,u.jsx)("span",{className:"hidden sm:inline",children:he?"Updating":ue?"Offline Saved":"Save Offline"})]}),(0,u.jsx)("button",{type:"button",onClick:()=>He?Te(!0):Ee(!0),className:et,title:He?"Share information and About ReScript":"About ReScript",children:(0,u.jsx)(jp,{className:"h-5 w-5"})}),We&&(0,u.jsx)("button",{type:"button",onClick:()=>{Ie("title"),_e(!0)},className:et,title:"Session settings",children:(0,u.jsx)(MN,{className:"h-5 w-5"})}),(0,u.jsx)("button",{type:"button",onClick:r,className:et,title:n?"Switch to light mode":"Switch to dark mode",children:n?(0,u.jsx)(LE,{className:"h-5 w-5"}):(0,u.jsx)(RE,{className:"h-5 w-5"})}),(0,u.jsx)(kA,{}),!He&&(0,u.jsx)(wA,{isDarkMode:n,name:s,email:i,picture:o,onLogout:l})]})})}):(0,u.jsx)(u.Fragment,{children:we&&He?(0,u.jsxs)("div",{className:"relative flex items-center gap-2",ref:Ve,children:[!He&&(0,u.jsx)("button",{type:"button",onClick:()=>ze(e=>!e),className:et,title:Re?"Close menu":"Open menu",children:Re?(0,u.jsx)(Pu,{className:"h-5 w-5"}):(0,u.jsx)(WE,{className:"h-5 w-5"})}),!He&&(0,u.jsx)(wA,{isDarkMode:n,name:s,email:i,picture:o,onLogout:l}),Re&&(0,u.jsx)("div",{className:"absolute right-0 top-full z-50 mt-2 w-64 roun
2ded-2xl border shadow-2xl ".concat(n?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900"),children:(0,u.jsxs)("nav",{className:"flex flex-col p-2 gap-1",children:[!qe&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{Ce(!0),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[(0,u.jsx)(zE,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:"Questions"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{Fe(!0),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[(0,u.jsx)(OE,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:"Cleanup"})]})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{window.open("/pinboard/","_blank","noopener"),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[(0,u.jsx)(UE,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:"Pinboard"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{be("/schedules"),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[(0,u.jsx)(mj,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:"Agent Schedules"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{je(!0),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[(0,u.jsx)(VE,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:"Prompts"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{be("/settings"),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[(0,u.jsx)(MN,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:"Settings"})]}),(0,u.jsx)("div",{className:"my-1 border-t ".concat(n?"border-gray-700":"border-gray-200")}),(0,u.jsxs)("button",{type:"button",onClick:()=>{r(),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[n?(0,u.jsx)(LE,{className:"h-5 w-5 flex-shrink-0"}):(0,u.jsx)(RE,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:n?"Light Mode":"Dark Mode"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{Ee(!0),ze(!1)},className:"flex items-center gap-3 rounded-xl px-4 py-3 text-sm transition-colors ".concat(n?"hover:bg-gray-800 text-gray-200":"hover:bg-gray-100 text-gray-700"),children:[(0,u.jsx)(jp,{className:"h-5 w-5 flex-shrink-0"}),(0,u.jsx)("span",{children:"About ReScript"})]})]})})]}):(0,u.jsx)("div",{className:"flex items-center gap-1 sm:gap-2",children:He?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("button",{type:"button",onClick:c,className:Qe,title:"All videos",children:[(0,u.jsx)(Io,{className:"h-4 w-4"}),(0,u.jsx)("span",{className:"hidden sm:inline",children:"All Videos"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>Te(!0),className:Qe,title:"Share information and About ReScript",children:[(0,u.jsx)(jp,{className:"h-4 w-4"}),(0,u.jsx)("span",{className:"hidden sm:inline",children:"Share Info"})]}),(0,u.jsx)("button",{type:"button",onClick:r,className:Qe,title:n?"Switch to light mode":"Switch to dark mode",children:n?(0,u.jsx)(LE,{className:"h-4 w-4"}):(0,u.jsx)(RE,{className:"h-4 w-4"})})]}):(0,u.jsx)(wA,{isDarkMode:n,name:s,email:i,picture:o,onLogout:l,actions:[...d?[{label:m?"Hide upload":"Upload media",icon:(0,u.jsx)(Eu,{size:16}),onClick:d}]:[],{label:"Questions",icon:(0,u.jsx)(zE,{size:16}),onClick:()=>Ce(!0)},{label:"Storage cleanup",icon:(0,u.jsx)(OE,{size:16}),onClick:()=>Fe(!0)},{label:"Pinboard",icon:(0,u.jsx)(UE,{size:16}),onClick:()=>{window.open("/pinboard/","_blank","noopener")}},{label:"Agents",icon:(0,u.jsx)(wy,{size:16}),onClick:()=>be("/agents")},{label:"Schedules",icon:(0,u.jsx)(mj,{size:16}),onClick:()=>be("/schedules")},{label:"Prompts",icon:(0,u.jsx)(VE,{size:16}),onClick:()=>je(!0)},{label:"Settings",icon:(0,u.jsx)(MN,{size:16}),onClick:()=>be("/settings")},{label:n?"Light mode":"Dark mode",icon:n?(0,u.jsx)(LE,{size:16}):(0,u.jsx)(RE,{size:16}),onClick:r},{label:"About ReScript",icon:(0,u.jsx)(jp,{size:16}),onClick:()=>Ee(!0)}]})})})})]}),qe&&p&&(0,u.jsxs)("div",{className:"flex flex-col border-t md:flex-row md:items-end md:justify-between ".concat(st," ").concat(we?"mt-2 gap-1 pt-2":"mt-4 gap-2 pt-4"),children:[(0,u.jsx)("div",{className:"min-w-0 flex-1",children:(0,u.jsxs)("div",{className:"flex items-start ".concat(we?"gap-2":"gap-3"),children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsx)("h1",{className:"truncate font-headlines font-bold ".concat(at," ").concat(we?"text-[0.95rem] leading-tight":"text-lg md:text-[1.45rem] md:leading-snug"),children:p}),D&&(0,u.jsxs)("p",{className:"font-body ".concat(rt," ").concat(we?"mt-0.5 text-xs leading-tight":"mt-1 text-sm"),children:["Active metadata: ",D.replace(/\.ttml$/i,"")]}),(dt||ut)&&(0,u.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2 ".concat(rt),children:[dt&&(0,u.jsxs)("span",{className:"inline-flex items-center rounded-full ".concat(it," ").concat(we?"px-2.5 py-1 text-[10px]":"px-3 py-1.5 text-[11px]"),children:[x,g?" \xb7 ".concat(g):""]}),ut&&f&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"inline-flex items-center rounded-full ".concat(it," ").concat(we?"px-2.5 py-1 text-[10px]":"px-3 py-1.5 text-[11px]"),children:f.title||"Episode family"}),null!=f.versionNumber&&(0,u.jsxs)("span",{className:"font-headlines text-[11px] font-semibold uppercase tracking-[0.16em]",children:["v",f.versionNumber," of ",f.versionCount]}),(null===(t=f.members)||void 0===t?void 0:t.length)>1&&fe&&(0,u.jsx)("select",{className:ot,value:h||"",onChange:e=>{e.target.value&&fe(e.target.value)},children:f.members.map(e=>{var t;return(0,u.jsxs)("option",{value:e.sessionId,children:["v",null!==(t=e.versionNumber)&&void 0!==t?t:"?",e.isCurrent?" \u2022 Current":""," \u2022 ",e.title]},e.sessionId)})})]})]})]}),we&&(0,u.jsx)("button",{type:"button",onClick:()=>Ue(!0),className:"inline-flex items-center justify-center rounded-full border transition-all ".concat(n?"border-white/[0.12] bg-white/[0.06] text-[#F4F4F4] hover:border-[#FFB52B]/[0.45] hover:bg-[#FFB52B] hover:text-[#232E3F]":"border-[#D6DCE4] bg-white/[0.92] text-[#2A3649] hover:border-[#FFB52B]/[0.5] hover:bg-[#FFB52B] hover:text-[#232E3F]"," h-9 w-9"),title:"Collapse header",children:(0,u.jsx)(Tu,{className:"h-4 w-4"})})]})}),D&&(0,u.jsxs)("div",{className:"inline-flex max-w-full items-center gap-2 self
2-start rounded-full md:self-auto ".concat(it," ").concat(we?"px-3 py-1.5 text-[11px]":"px-4 py-2 text-xs"),children:[(0,u.jsx)(YE,{className:"h-3.5 w-3.5 flex-shrink-0"}),(0,u.jsx)("span",{className:"font-headlines font-semibold uppercase tracking-[0.18em]",children:"Metadata"})]})]})]})}),Me&&h&&!He&&(0,u.jsx)(rT,{isOpen:Me,onClose:()=>_e(!1),initialSection:Be,isDarkMode:n,sessionId:h,sessionTitle:p,token:b,onTitleUpdate:y,onSessionRefresh:v,youtubeUrl:C,youtubeTitle:N,youtubeTitleUpdatedAt:F,youtubeTitleSync:S,videoUrl:A,videoSource:T,onYoutubeUrlChange:E,onVideoUrlChange:M,onRefreshVideoSource:_,videoStats:P,videoDurationSeconds:L,fetchedAt:R,onRetentionDataUpdate:z,speakerIds:O,speakerSegments:U,speakerLabels:V,onSaveSpeakerLabels:H,transcriptionChecksum:q,hesitationTranscriptChecksum:W,isYouTubeMode:Y,dropboxVideoUrl:G,videoFilename:K,dropboxDrpUrl:X,timelineName:J,localVideoPath:$,productionNotes:Q,videoFileHash:Z,videoFileSize:ee,videoFrameRate:te,videoDuration:ne,audioDuration:ae,videoSourceStatus:re,customThumbnailUrl:se,customThumbnailTimeSeconds:ie,onProductionMetadataUpdate:oe,onVideoSourceStatusUpdate:le,publishedToHomepage:ce,onPublishChange:de}),(0,u.jsx)(yA,{isOpen:Pe,onClose:()=>Le(!1),isDarkMode:n,toggleDarkMode:r,userName:s,onLogout:l,onHome:c,sessionTitle:p,sharePermissions:ye,shareMetadata:ve,activeTabId:w,onTabChange:k,availableTabIds:j,selectedTtmlName:D,hasVideoUrl:!!A,isYoutubePlayerVisible:I,onToggleYoutubePlayer:B,hasSpeakers:((null===O||void 0===O?void 0:O.length)||0)>0,onOpenSettings:We?()=>{Ie("title"),_e(!0)}:void 0,isOfflineAvailable:ue,isOfflineMode:me,isOfflineActionPending:he,offlineActionStatusLabel:pe,onToggleOfflineAvailability:ge,onCopyOfflineDiagnostics:xe}),Ae&&ye&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[#111826]/[0.72] p-4 backdrop-blur-sm",onClick:()=>Te(!1),children:(0,u.jsxs)("div",{className:"w-full max-w-md rounded-[28px] border p-6 shadow-[0_32px_72px_-32px_rgba(10,14,20,0.9)] ".concat(Ke),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,u.jsxs)("h2",{className:"flex items-center gap-2 font-headlines text-lg font-bold",children:[(0,u.jsx)(jp,{className:"h-5 w-5 text-brand-yellow"}),(0,u.jsx)("span",{children:"Share Link Information"})]}),(0,u.jsx)("button",{type:"button",onClick:()=>Te(!1),className:"rounded-full border border-transparent p-1 transition-colors hover:border-[#FFB52B]/30 hover:bg-[#FFB52B]/10",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]}),(null===ve||void 0===ve?void 0:ve.label)&&(0,u.jsxs)("div",{className:"mb-4 rounded-2xl border p-3 text-sm ".concat(Xe),children:[(0,u.jsx)("span",{className:"font-headlines font-semibold text-[#232E3F] dark:text-[#F4F4F4]",children:"Label:"})," ",ve.label]}),(0,u.jsxs)("div",{className:"space-y-3",children:[(null===ve||void 0===ve?void 0:ve.maxViewers)&&(0,u.jsxs)("div",{className:"flex items-start gap-3 rounded-2xl border p-3 ".concat(Xe),children:[(0,u.jsx)(fh,{className:"mt-0.5 h-5 w-5 text-brand-yellow"}),(0,u.jsxs)("div",{className:"text-sm",children:[(0,u.jsx)("div",{className:"font-headlines font-semibold text-[#232E3F] dark:text-[#F4F4F4]",children:"Viewer Limit"}),(0,u.jsxs)("div",{children:[ve.currentViewers||0," / ",ve.maxViewers," unique IPs used"]})]})]}),(null===ve||void 0===ve?void 0:ve.maxTotalViews)&&(0,u.jsxs)("div",{className:"flex items-start gap-3 rounded-2xl border p-3 ".concat(Xe),children:[(0,u.jsx)(Cp,{className:"mt-0.5 h-5 w-5 text-brand-yellow"}),(0,u.jsxs)("div",{className:"text-sm",children:[(0,u.jsx)("div",{className:"font-headlines font-semibold text-[#232E3F] dark:text-[#F4F4F4]",children:"Total Views"}),(0,u.jsxs)("div",{children:[ve.totalViews||0," / ",ve.maxTotalViews," views used"]})]})]}),(null===ve||void 0===ve?void 0:ve.expiresAt)&&(0,u.jsxs)("div",{className:"flex items-start gap-3 rounded-2xl border p-3 ".concat(Xe),children:[(0,u.jsx)(wp,{className:"mt-0.5 h-5 w-5 text-brand-yellow"}),(0,u.jsxs)("div",{className:"text-sm",children:[(0,u.jsx)("div",{className:"font-headlines font-semibold text-[#232E3F] dark:text-[#F4F4F4]",children:"Expires"}
2),(0,u.jsx)("div",{children:new Date(ve.expiresAt).toLocaleString()})]})]})]}),(0,u.jsxs)("div",{className:"mt-5 grid grid-cols-2 gap-2 text-sm",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-2xl border p-3 ".concat(Xe),children:[(0,u.jsx)(gp,{className:"h-4 w-4 text-brand-yellow"}),(0,u.jsx)("span",{children:"Transcript"}),ye.transcriptsEnabled&&(0,u.jsx)(Wm,{className:"ml-auto h-4 w-4 text-brand-yellow"})]}),ye.rankingEnabled&&(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-2xl border p-3 ".concat(Xe),children:[(0,u.jsx)(YE,{className:"h-4 w-4 text-brand-yellow"}),(0,u.jsx)("span",{children:"Topic Map"}),(0,u.jsx)(Wm,{className:"ml-auto h-4 w-4 text-brand-yellow"})]}),ye.questionsEnabled&&(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-2xl border p-3 ".concat(Xe),children:[(0,u.jsx)(zE,{className:"h-4 w-4 text-brand-yellow"}),(0,u.jsx)("span",{children:"Questions"}),(0,u.jsx)(Wm,{className:"ml-auto h-4 w-4 text-brand-yellow"})]})]}),(0,u.jsxs)("div",{className:"mt-5 rounded-[24px] border p-4 ".concat(Xe),children:[(0,u.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"ReScript",className:"h-7 w-auto"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.22em] text-[#C98A00] dark:text-[#FFB52B]/80",children:"MLST"}),(0,u.jsx)("div",{className:"font-headlines text-base font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:"About ReScript"})]})]}),(0,u.jsxs)("div",{className:"space-y-3 text-sm ".concat(Je),children:[(0,u.jsx)("p",{children:"ReScript is MLST's content management system, review app, and editing software for podcasts, video editing, shares, search, captions, and agentic production workflows."}),(0,u.jsx)("p",{children:"It combines transcript authoring, metadata generation, context-file handling, search, public shares, video-linked review, and autonomous editing workflows in one system."}),(0,u.jsxs)("p",{children:["For licensing or collaboration enquiries, contact"," ",(0,u.jsx)("a",{href:"mailto:[email protected]",className:"font-headlines font-semibold text-[#C98A00] underline decoration-[#FFB52B]/60 underline-offset-4 hover:opacity-80 dark:text-brand-yellow",children:"Tim Scarfe"}),"."]})]})]})]})}),Se&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[#111826]/[0.72] p-4 backdrop-blur-sm",onClick:()=>Ee(!1),children:(0,u.jsxs)("div",{className:"w-full max-w-md rounded-[28px] border p-6 shadow-[0_32px_72px_-32px_rgba(10,14,20,0.9)] ".concat(Ke),onClick:e=>e.stopPropagation(),children:[(0,u.jsx)("button",{type:"button",onClick:()=>Ee(!1),className:"absolute right-8 top-8 rounded-full border border-transparent p-1 transition-colors hover:border-[#FFB52B]/30 hover:bg-[#FFB52B]/10",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})}),(0,u.jsxs)("div",{className:"mb-4 flex items-center gap-3",children:[(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"ReScript",className:"h-10 w-auto"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.28em] text-[#C98A00] dark:text-[#FFB52B]/80",children:"MLST"}),(0,u.jsx)("h2",{className:"font-headlines text-xl font-bold",children:"About ReScript"})]})]}),(0,u.jsxs)("div",{className:"space-y-4 font-body text-sm ".concat(Je),children:[(0,u.jsx)("p",{children:"ReScript is MLST's content management system, review app, and editing software for podcasts, video editing, shares, search, captions, and agentic production workflows."}),(0,u.jsx)("p",{children:"It combines transcript authoring, metadata generation, context-file handling, search, public shares, video-linked review, and autonomous editing workflows in one system."}),(0,u.jsxs)("p",{children:["For licensing or collaboration enquiries, contact"," ",(0,u.jsx)("a",{href:"mailto:[email protected]",className:"font-headlines font-semibold text-[#C98A00] underline decoration-[#FFB52B]/60 underline-offset-4 hover:opacity-80 dark:text-brand-yellow",children:"Tim Scarfe"}),"."]})]})]})}),(0,u.jsx)(lA,{isOpen:ke,onClose:()=>je(!1),token:b||"",isDarkMode:n}),(0,u.jsx)(dA,{isOpen:De,onClose:()=>Ce(!1),token:b||"",isDarkMode:n}),(0,u.jsx)(uA,{isOpen:Ne,onClose:()=>Fe(!1),token:b||"",isDarkMode:n})]})},iT=e=>{let{tabs:t,isDarkMode:n,defaultTab:r="ttml",activeTab:s,onTabChange:i,hideNavigation:o=!1}=e;const{isCompactTouchLayout:l}=Ww(),[c,m]=(0,a.useState)(r),[h,p]=(0,a.useState)(!1),[g,x]=(0,a.useState)(!1),f=(0,a.useRef)(null),b=(0,a.useRef)({}),y=s||c,v=n?"border-[#FFB52B]/20 bg-[#232E3F]/[0.94] shadow-[0_22px_40px_-30px_rgba(10,14,20,0.68)]":"border-[#D6DCE4] bg-[linear-gradient(180deg,rgba(255,255,255,0.94),rgba(244,244,244,0.96))] shadow-[0_20px_36px_-30px_rgba(35,46,63,0.22)]",w=n?"absolute z-10 -translate-y-1/2 roun
2ded-full border border-white/[0.12] bg-white/[0.06] p-2 text-[#F4F4F4] shadow-[0_12px_28px_-18px_rgba(10,14,20,0.9)] transition-all hover:border-[#FFB52B]/40 hover:bg-[#FFB52B] hover:text-[#232E3F]":"absolute z-10 -translate-y-1/2 rounded-full border border-[#D6DCE4] bg-white/[0.94] p-2 text-[#2A3649] shadow-[0_12px_28px_-20px_rgba(35,46,63,0.26)] transition-all hover:border-[#FFB52B]/45 hover:bg-[#FFB52B] hover:text-[#232E3F]",k=n?"bg-gradient-to-r from-[#232E3F] via-[#232E3F]/90 to-transparent":"bg-gradient-to-r from-[#F4F4F4] via-[#F4F4F4]/92 to-transparent",j=n?"bg-gradient-to-l from-[#232E3F] via-[#232E3F]/90 to-transparent":"bg-gradient-to-l from-[#F4F4F4] via-[#F4F4F4]/92 to-transparent",D=n?"text-[#D1D8E0] hover:bg-white/[0.08] hover:text-[#F4F4F4]":"text-[#485568] hover:bg-[#232E3F]/[0.06] hover:text-[#232E3F]",C=(0,a.useCallback)(()=>{const e=f.current;if(!e)return p(!1),void x(!1);const t=e.scrollWidth-e.clientWidth;p(e.scrollLeft>8),x(t-e.scrollLeft>8)},[]);(0,a.useEffect)(()=>{if(o)return p(!1),void x(!1);const e=f.current;if(!e)return;C();const t=()=>C();return e.addEventListener("scroll",C,{passive:!0}),window.addEventListener("resize",t),()=>{e.removeEventListener("scroll",C),window.removeEventListener("resize",t)}},[o,t,C]),(0,a.useEffect)(()=>{const e=b.current[y];null===e||void 0===e||e.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});const t=window.requestAnimationFrame(C);return()=>window.cancelAnimationFrame(t)},[y,C]);const N=e=>{const t=f.current;if(!t)return;const n=Math.max(.45*t.clientWidth,180);t.scrollBy({left:"left"===e?-n:n,behavior:"smooth"})};return(0,u.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[!o&&!l&&(0,u.jsxs)("div",{className:"relative min-w-0 flex-shrink-0 border-b ".concat(v),children:[h&&(0,u.jsx)("button",{type:"button",onClick:()=>N("left"),className:"left-3 top-1/2 ".concat(w),"aria-label":"Scroll tabs left",children:(0,u.jsx)(dk,{size:16})}),(0,u.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-0 w-20 ".concat(k)}),(0,u.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 w-20 ".concat(j)}),(0,u.jsx)("div",{ref:f,className:"flex min-w-0 gap-2 overflow-x-auto scrollbar-hide scroll-smooth px-14 py-3",children:t.map(e=>(0,u.jsxs)("button",{ref:t=>{b.current[e.id]=t},onClick:()=>{i?i(e.id):m(e.id)},className:"relative flex flex-shrink-0 items-center gap-2 whitespace-nowrap rounded-full px-4 py-2.5 font-headlines text-sm font-semibold transition-all md:px-5 ".concat(y===e.id?"bg-[#FFB52B] text-[#232E3F] shadow-[0_18px_34px_-22px_rgba(255,181,43,0.9)]":D),children:[e.icon,(0,u.jsx)("span",{className:"text-sm md:text-[0.95rem]",children:e.title})]},e.id))}),g&&(0,u.jsx)("button",{type:"button",onClick:()=>N("right"),className:"right-3 top-1/2 ".concat(w),"aria-label":"Scroll tabs right",children:(0,u.jsx)(bp,{size:16})})]}),(0,u.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden ".concat(n?"bg-[#16202C]/[0.92]":"bg-[#F8F8F7]/[0.86]"),children:(e=>{const n=null!==(e=t.find(e=>e.id===y))&&void 0!==e?e:t[0];if(!n)return null;const a=n.component;return(0,u.jsx)("div",{className:"h-full overflow-y-auto",children:(0,u.jsx)(a,d(d({},n.props||{}),{},{isActiveTab:!0}))},n.id)})()})]})},oT=Mo("move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]),lT=Mo("pin-off",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]),cT=1920,dT=1080,uT="/api",mT=e=>{const t=Number.isFinite(e)?Math.max(0,e):0,n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=Math.floor(t%60);return"".concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"))},hT=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:180;const n=(e=>String(e||"").replace(/<br\s*\/?>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())(e);return n?n.length>t?"".concat(n.slice(0,t-3),"..."):n:""},pT=e=>{const t="string"===typeof e?Number(e):e;return Number.isFinite(t)?Number(t):null},gT=e=>hT(e.displayName||e.userName||e.userEmail||"Comment",48),xT=e=>(null===e||void 0===e?void 0:e.url)||(null===e||void 0===e?void 0:e.playbackUrl)||(null===e||void 0===e?void 0:e.originalUrl)||null,fT=e=>Number.isFinite(e.layoutX)&&Number.isFinite(e.layoutY)&&Number.isFinite(e.layoutWidth)&&Number.isFinite(e.layoutHeight)?{left:"".concat(Number(e.layoutX)/cT*100,"%"),top:"".concat(Number(e.layoutY)/dT*100,"%"),width:"".concat(Number(e.layoutWidth)/cT*100,"%"),height:"".concat(Number(e.layoutHeight)/dT*100,"%")}:{left:"22%",top:"6%",width:"56%",height:"18%"};let bT=null;let yT=0;const vT=e=>{var t;let{youtubeUrl:n,sessionId:r=null,sessionVisuals:s=null,selectedTtmlChecksum:i=null,token:o,isVisible:l,onClose:c,onTimeUpdate:m,onDurationChange:h,onPlayStateChange:p,onReady:g,currentTime:x,mediaSeekRequestId:f=0,mediaSeekRequestTime:b=null,isPlaying:y,volume:v=1,playbackRate:w=1,isDarkMode:k,isMinimized:j=!1,onToggleMinimize:D,onFloating
2Change:C,isMobile:N=!1,mobileTopicTitle:F=null}=e;const{permissions:S,shareToken:E}=Hp(),A=(0,a.useRef)(null);null===A.current&&(yT+=1,A.current="youtube-player-".concat(yT));const T=A.current,M=(0,a.useRef)(null),_=(0,a.useRef)(null),B=(0,a.useRef)(null),I=(0,a.useRef)(null),[P,L]=(0,a.useState)(!1),[R,z]=(0,a.useState)(!1),[O,U]=(0,a.useState)(null),[V,H]=(0,a.useState)(!1),[q,W]=(0,a.useState)(!1),[Y,G]=(0,a.useState)({width:0,height:0}),[K,X]=(0,a.useState)([]),[J,$]=(0,a.useState)([]),[Q,Z]=(0,a.useState)([]),[ee,te]=(0,a.useState)([]),ne=(0,a.useRef)(0),ae=(0,a.useRef)(0),re=(0,a.useRef)(!1),se=Number.isFinite(x)?Number(x):0,ie=!0===(null===S||void 0===S?void 0:S.isPublicShare)&&Boolean(E),oe=!ie||null===(t=null===S||void 0===S?void 0:S.commentsRead)||void 0===t||t,le=(0,a.useRef)(m),ce=(0,a.useRef)(h),de=(0,a.useRef)(p),ue=(0,a.useRef)(g);(0,a.useEffect)(()=>{le.current=m},[m]),(0,a.useEffect)(()=>{ce.current=h},[h]),(0,a.useEffect)(()=>{de.current=p},[p]),(0,a.useEffect)(()=>{ue.current=g},[g]);const[me,he]=(0,a.useState)(!1),[pe,ge]=(0,a.useState)({x:20,y:100}),[xe,fe]=(0,a.useState)({width:400,height:225}),[be,ye]=(0,a.useState)(!1),[ve,we]=(0,a.useState)(!1),ke=(0,a.useRef)({x:0,y:0}),je=(0,a.useRef)({x:0,y:0}),De=(0,a.useRef)({width:0,height:0});(0,a.useEffect)(()=>{N&&he(!1)},[N]),(0,a.useEffect)(()=>{null===C||void 0===C||C(me)},[me,C]);const Ce=(0,a.useMemo)(()=>(e=>{const t=[/(?:youtube\.com\/watch\?v=)([a-zA-Z0-9_-]{11})/,/(?:youtu\.be\/)([a-zA-Z0-9_-]{11})/,/(?:youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,/(?:youtube\.com\/v\/)([a-zA-Z0-9_-]{11})/];for(const n of t){const t=e.match(n);if(t)return t[1]}return null})(n),[n]);(0,a.useEffect)(()=>{const e=()=>{H(document.fullscreenElement===_.current)};return document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]),(0,a.useEffect)(()=>{const e=_.current;if(!e||"undefined"===typeof ResizeObserver)return;const t=new ResizeObserver(e=>{const t=e[0];t&&G({width:t.contentRect.width,height:t.contentRect.height})});return t.observe(e),()=>t.disconnect()},[]),(0,a.useEffect)(()=>{if(!l||!r||!i)return X([]),$([]),void Z([]);let e=!1;return(async()=>{try{const t=ie&&E?await UN.getPublicStructure(E,i):await UN.getStructure(r,i,o);if(e)return;X(t.topics||[]),$(t.references||[]),Z(t.edits||[])}catch(t){console.warn("[YouTubePlayer] Failed to load structured overlay data:",t),e||(X([]),$([]),Z([]))}})(),()=>{e=!0}},[ie,l,i,r,E,o]),(0,a.useEffect)(()=>{if(!l||!r||!oe)return void te([]);const e=new AbortController;let t=!1;return(async()=>{try{let n=null;if(ie&&E?n=await fetch("".concat(uT,"/public/share/").concat(encodeURIComponent(E),"/comments"),{credentials:"omit",signal:e.signal}):o&&(n=await fetch("".concat(uT,"/sessions/").concat(r,"/comments"),{headers:{Authorization:"Bearer ".concat(o)},signal:e.signal})),!n)return void(t||te([]));if(!n.ok)throw new Error("Failed to load comments (".concat(n.status,")"));const a=await n.json();if(t)return;const s=Array.isArray(null===a||void 0===a?void 0:a.comments)?a.comments.map(e=>(e=>{var t;if(!e||"object"!==typeof e)return null;const n=e.id||e.commentId||e.comment_id;return n?{id:String(n),content:"string"===typeof e.content?e.content:"",timestampSeconds:pT(null!==(t=e.timestampSeconds)&&void 0!==t?t:e.timestamp_seconds),userEmail:"string"===typeof e.userEmail?e.userEmail:"string"===typeof e.user_email?e.user_email:"",userName:"string"===typeof e.userName?e.userName:"string"===typeof e.user_name?e.user_name:"",displayName:"string"===typeof e.displayName?e.displayName:"string"===typeof e.display_name?e.display_name:void 0,parentCommentId:"string"===typeof e.parentCommentId?e.parentCommentId:"string"===typeof e.parent_comment_id?e.parent_comment_id:void 0}:null})(e)).filter(e=>Boolean(e)):[];te(s)}catch(n){e.signal.aborted||console.warn("[YouTubePlayer] Failed to load overlay comments:",n),t||te([])}})(),()=>{t=!0,e.abort()}},[oe,ie,l,r,E,o]);const Ne=(0,a.useMemo)(()=>K.find(e=>se>=e.startTime&&se<=e.endTime)||null,[se,K]),Fe=(0,a.useMemo)(()=>{const e=J.filter(e=>se>=e.startTime&&se<=e.endTime).sort((e,t)=>
2e.startTime-t.startTime);return 0===e.length?null:{reference:e[0],extraCount:e.length-1}},[se,J]),Se=(0,a.useMemo)(()=>Q.find(e=>se>=e.startTime&&se<=e.endTime)||null,[se,Q]),Ee=(0,a.useMemo)(()=>ee.filter(e=>!e.parentCommentId&&null!==e.timestampSeconds&&se>=e.timestampSeconds&&se<e.timestampSeconds+10).sort((e,t)=>(t.timestampSeconds||0)-(e.timestampSeconds||0)).slice(0,V?2:1),[V,se,ee]),Ae=(0,a.useMemo)(()=>((null===s||void 0===s?void 0:s.placements)||[]).find(e=>se>=e.displayStart&&se<=e.displayEnd)||null,[se,s]),Te=(0,a.useMemo)(()=>((null===s||void 0===s?void 0:s.titles)||[]).filter(e=>se>=e.displayStart&&se<=e.displayEnd),[se,s]),Me=!N&&(V||q),_e=(0,a.useMemo)(()=>{const e=Y.width||(V?1280:me?xe.width:720),t=!V&&e>0&&e<520;return{topPaddingClass:V?"p-4":t?"p-2.5":"p-3",infoCardClass:V?"rounded-2xl px-4 py-3":t?"rounded-xl px-3 py-2.5":"rounded-2xl px-3.5 py-3",infoLabelClass:V?"text-[10px]":t?"text-[8px]":"text-[9px]",infoTitleClass:V?"text-sm":t?"text-[11px]":"text-xs",bodyTextClass:V?"text-sm":t?"text-[11px]":"text-xs",metaTextClass:V?"text-xs":t?"text-[10px]":"text-[11px]",timerClass:V?"px-3 py-1.5 text-xs":t?"px-2 py-1 text-[10px]":"px-3 py-1.5 text-[11px]",cueCardClass:V?"rounded-2xl px-3.5 py-3":t?"rounded-xl px-2.5 py-2":"rounded-xl px-3 py-2.5",cueLabelClass:V?"text-[9px]":t?"text-[8px]":"text-[9px]",cueTitleClass:V?"text-sm":t?"text-[11px]":"text-xs",cueBodyClass:V?"text-xs":t?"text-[10px]":"text-[11px]",infoMaxWidth:Math.max(220,Math.min(e*(V?.34:t?.82:.58),440)),cueMaxWidth:Math.max(220,Math.min(e*(V?.28:t?.86:.38),340))}},[xe.width,me,V,Y.width]),Be=(0,a.useMemo)(()=>{const e=[];return Fe&&e.push({id:"reference:".concat(Fe.reference.index,":").concat(Fe.reference.startTime),kind:"reference",label:"Reference",title:hT(Fe.reference.name||Fe.reference.linkText||"Reference",72),body:hT(Fe.reference.context,V?160:110)||void 0,meta:[Fe.reference.category?hT(Fe.reference.category,30):null,Fe.extraCount>0?"+".concat(Fe.extraCount," more active"):null].filter(Boolean).join(" \u2022 ")||void 0}),Se&&e.push({id:"edit:".concat(Se.index,":").concat(Se.startTime),kind:"edit",label:"Edit Note",title:hT(Se.title||Se.priority||"Edit span",72),body:hT(Se.suggestion||Se.improvement,V?170:120)||void 0,meta:Se.priority?hT(Se.priority,24):void 0}),Ee.forEach(t=>{e.push({id:"comment:".concat(t.id),kind:"comment",label:"Comment",title:gT(t),body:hT(t.content,V?160:110)||"Open comment",meta:null!==t.timestampSeconds?mT(t.timestampSeconds):void 0})}),e},[Ee,Se,Fe,V]),Ie=(0,a.useMemo)(()=>xT(Ae),[Ae]);(0,a.useEffect)(()=>{const e=I.current;if(!e||!Ae||!String(Ae.mimeType||"").startsWith("video/"))return;const t=Number.isFinite(Ae.sourceStart)?Number(Ae.sourceStart):0,n=Number.isFinite(Ae.sourceEnd)?Number(Ae.sourceEnd):null,a=()=>{e.currentTime=t,e.play().catch(()=>{})},r=()=>{null!=n&&e.currentTime>=n-.05&&(e.currentTime=t)};return e.addEventListener("loadedmetadata",a),e.addEventListener("timeupdate",r),(()=>{const a=t+Math.max(0,se-Ae.displayStart);Number.isFinite(a)&&Math.abs(e.currentTime-a)>.4&&(e.currentTime=a),null!=n&&e.currentTime>=n-.05&&(e.currentTime=t)})(),e.play().catch(()=>{}),()=>{e.removeEventListener("loadedmetadata",a),e.removeEventListener("timeupdate",r)}},[Ae,se]);const Pe=(0,a.useCallback)(async()=>{const e=_.current;if(e)try{document.fullscreenElement===e?await document.exitFullscreen():document.fullscreenElement||await e.requestFullscreen()}catch(t){console.warn("[YouTubePlayer] Failed to toggle fullscreen:",t)}},[]);(0,a.useEffect)(()=>{(bT||(window.YT&&window.YT.Player?Promise.resolve():(bT=new Promise(e=>{var t;const n=document.createElement("script");n.src="https://www.youtube.com/iframe_api",n.async=!0,window.onYouTubeIframeAPIReady=()=>{e()};const a=document.getElementsByTagName("script")[0];null===(t=a.parentNode)||void 0===t||t.insertBefore(n,a)}),bT))).then(()=>{L(!0)}).catch(e=>{console.error("[YouTubePlayer] Failed to load YouTube API:",e),U("Failed to load YouTube player")})},[]),(0,a.useEffect)(()=>{if(!P||!Ce||!l||j)return;if(M.current)return;const e=setTimeout(()=>
2{if(document.getElementById(T))try{M.current=new window.YT.Player(T,{videoId:Ce,playerVars:{autoplay:0,controls:1,modestbranding:1,rel:0},events:{onReady:e=>{z(!0);const t=e.target.getDuration();t>0&&ce.current(t),ue.current()},onStateChange:e=>{const t=e.data;t===window.YT.PlayerState.PLAYING?de.current(!0):t!==window.YT.PlayerState.PAUSED&&t!==window.YT.PlayerState.ENDED||de.current(!1)},onError:e=>{console.error("[YouTubePlayer] Error:",e.data),U("Video unavailable or restricted")}}})}catch(e){console.error("[YouTubePlayer] Failed to create player:",e),U("Failed to initialize YouTube player")}else console.error("[YouTubePlayer] Player element not found:",T)},100);return()=>{clearTimeout(e)}},[P,Ce,l,j,T]),(0,a.useEffect)(()=>()=>{if(B.current&&(clearInterval(B.current),B.current=null),M.current){try{M.current.destroy()}catch(BH){}M.current=null,z(!1)}},[Ce]),(0,a.useEffect)(()=>{if(!R||!M.current||!l||!y)return;const e=N?500:250;return B.current=window.setInterval(()=>{if(M.current&&!re.current)try{const e=M.current.getCurrentTime();Date.now()-ne.current>150&&le.current(e)}catch(BH){}},e),()=>{B.current&&(clearInterval(B.current),B.current=null)}},[R,N,y,l]),(0,a.useEffect)(()=>{if(R&&M.current)try{const e=M.current.getPlayerState()===window.YT.PlayerState.PLAYING;y&&!e?M.current.playVideo():!y&&e&&M.current.pauseVideo()}catch(BH){}},[y,R]),(0,a.useEffect)(()=>{if(!R||!M.current||void 0===x)return;const e=Date.now();if(!(e-ne.current<75))try{const t=M.current.getCurrentTime();Math.abs(t-x)>1&&(re.current=!0,ne.current=e,M.current.seekTo(x,!0),setTimeout(()=>{re.current=!1},150))}catch(BH){}},[x,R]),(0,a.useEffect)(()=>{if(!R||!M.current||null===b||0===f)return;if(ae.current===f)return;ae.current=f;const e=Date.now();try{re.current=!0,ne.current=e,M.current.seekTo(b,!0),setTimeout(()=>{re.current=!1},150)}catch(BH){}},[x,R,f,b]),(0,a.useEffect)(()=>{if(R&&M.current)try{M.current.setVolume(100*v)}catch(BH){}},[v,R]),(0,a.useEffect)(()=>{if(R&&M.current)try{M.current.setPlaybackRate(w)}catch(BH){}},[w,R]);const Le=(0,a.useCallback)(e=>{me&&(e.preventDefault(),ye(!0),ke.current={x:e.clientX,y:e.clientY},je.current=d({},pe))},[me,pe]);(0,a.useEffect)(()=>{if(!be)return;const e=e=>{const t=e.clientX-ke.current.x,n=e.clientY-ke.current.y;ge({x:Math.max(0,Math.min(window.innerWidth-320,je.current.x+t)),y:Math.max(0,Math.min(window.innerHeight-200,je.current.y+n))})},t=()=>{ye(!1)};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[be]);const Re=(0,a.useCallback)(e=>{me&&(e.preventDefault(),e.stopPropagation(),we(!0),ke.current={x:e.clientX,y:e.clientY},De.current=d({},xe))},[me,xe]);if((0,a.useEffect)(()=>{if(!ve)return;const e=e=>{const t=e.clientX-ke.current.x,n=Math.max(280,Math.min(800,De.current.width+t));fe({width:n,height:n*(9/16)})},t=()=>{we(!1)};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[ve]),!l||!Ce)return null;if(N)return(0,u.jsxs)("div",{className:"w-full ".concat(k?"bg-gray-900":"bg-white"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b ".concat(k?"border-gray-700 bg-gray-800":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,u.jsx)(Au,{size:16,className:"text-red-600"}),(0,u.jsx)("span",{className:"shrink-0 text-sm font-medium ".concat(k?"text-gray-200":"text-gray-700"),children:"Video"}),F&&(0,u.jsx)("span",{className:"truncate text-xs ".concat(k?"text-gray-300":"text-gray-600"),children:F})]}),(0,u.jsx)("button",{onClick:c,className:"p-1.5 rounded-lg ".concat(k?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-500"),children:(0,u.jsx)(Pu,{size:18})})]}),(0,u.jsx)("div",{className:"relative w-full",style:{paddingBottom:"56.25%"},children:O?(0,u.jsx)("div",{className:"absolute inset-0 flex items-center justify-center ".concat(k?"text-red-400":"text-red-600"),children:(0,u.jsx)("span",{className:"text-sm",children:O})}):(0,u.jsx)("div",{id:T,className:"absolute inset-0 w-full h-full"})})]});const ze=me?{position:"fixed",left:pe.x,top:pe.y,width:j?"200px":"".concat(xe.width,"px"),zIndex:1e3,boxShadow:"0 10px 40px rgba(0,0,0,0.3)",borderRadius:"8px",overflow:"hidden"}:{},Oe=me?{}:{width:"100%",maxWidth:j?"200px":void 0,height:j?"auto":"fit-content"},Ue=V?{width:"100%",height:"100%",maxWidth:"none"}:{};return(0,u.jsxs)("div",{ref:_,style:d(d(d({},ze),Oe),Ue),className:"flex flex-col relative ".concat(k?"bg-gray-900 border-gray-700":"bg-white border-gray-200"," ").concat(V?"border-0":me?"border-2":"border-r"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b ".concat(k?"border-gray-700 bg-gray-800":"border-gray-200 bg-gray-50"," ").concat(me?"cursor-move":""),onMouseDown:Le,children:[(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[me&&(0,u.jsx)(oT,{size:12,className:"text-gray-400"}),(0,u.jsx)(Au,{size:14,className:"text-red-600"}),(0,u.jsx)("span",{className:"text-xs font-medium ".concat(k?"text-gray-200":"text-gray-700"),children:"YouTube"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-0.5",children:[!N&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:()=>he(!me),className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(k?"text-gray-400":"text-gray-500"),title:me?"Dock to sidebar":"Float window",children:me?(0,u.jsx)(Ey,{size:12}):(0,u.jsx)(lT,{size:12})}),(0,u.jsx)("button",{onClick:()=>W(e=>!e),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 transition-colors ".concat(k?"text-gray-400 hover:bg-gray-700":"text-gray-500 hover:bg-gray-200"),title:V?"Overlay is always enabled in fullscreen":q?"Hide metadata overlay":"Show metadata overlay",disabled:V,children:q||V?(0,u.jsx)(Cp,{size:12}):(0,u.jsx)(Fy,{size:12})}),(0,u.jsx)("button",{onClick:()=>{Pe()},className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(k?"text-gray-400":"text-gray-500"),title:V?"Exit player fullscreen":"Enter player fullscreen",children:(0,u.jsx)(zj,{size:12})}),(0,u.jsx)("a",{href:(()=>{let e=0;try{M.current&&(e=Math.floor(M.current.getCurrentTime()))}catch(BH){}const t=new URL(n);return e>0&&t.searchParams.set("t","".concat(e,"s")),t.toString()})(),target:"_blank",rel:"noopener noreferrer",className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(k?"text-gray-400":"text-gray-500"),title:"Open in YouTube at current time",children:(0,u.jsx)(Ep,{size:12})}),D&&(0,u.jsx)("button",{onClick:D,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(k?"text-gray-400":"text-gray-500"),title:j?"Expand":"Minimize",children:j?(0,u.jsx)(zj,{size:12}):(0,u.jsx)(Rj,{size:12})})]}),(0,u.jsx)("button",{onClick:c,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(k?"text-gray-400":"text-gray-500"),title:"Close YouTube player",children:(0,u.jsx)(Pu,{size:12})})]})]}),!j&&(0,u.jsx)("div",{className:"relative bg-black",style:{paddingBottom:V?void 0:"56.25%",height:V?"100%":0,overflow:"hidden",flex:V?"1 1 auto":void 0},children:O?(0,u.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,u.jsxs)("div",{className:"text-center text-red-500",children:[(0,u.jsx)(Au,{size:32,className:"mx-auto mb-2 opacity-50"}),(0,u.jsx)("p",{className:"text-xs",children:O})]})}):P?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{id:T,className:"absolute inset-0",style:{width:"100%",height:"100%"}}),Me&&(0,u.jsxs)(u.Fragment,{children:[(Ae||Te.length>0)&&(0,u.jsxs)("div",{className:"pointer-events-none absolute inset-0 z-20",children:[Ae&&Ie&&(0,u.jsx)("div",{className:"absolute overflow-hidden rounded-2xl border border-white/15 bg-black/28 shadow-[0_24px_48px_-28px_rgba(0,0,0,0.88)] backdrop-blur-[2px]",style:(Ve=Ae,"pip"===Ve.layoutMode&&Number.isFinite(Ve.layoutX)&&Number.isFinite(Ve.layoutY)&&Number.isFinite(Ve.layoutWidth)&&Number.isFinite(Ve.layoutHeight)?{left:"".concat(Number(Ve.layoutX)/cT*100,"%"),top:"".concat(Number(Ve.layoutY)/dT*100,"%"),width:"".concat(Number(Ve.layoutWidth)/cT*100,"%"),height:"".concat(Number(Ve.layoutHeight)/dT*100,"%")}:{left:"10%",top:"16%",width:"80%",height:"60%"}),children:String(Ae.mimeType||"").startsWith("video/")?(0,u.jsx)("video",{ref:I,src:Ie,className:"h-full w-full object-cover",muted:!0,playsInl
2ine:!0,autoPlay:!0,preload:"auto"},"".concat(Ae.id,":").concat(Ie)):(0,u.jsx)("img",{src:Ie,alt:Ae.description||Ae.label||"Session visual",className:"h-full w-full object-contain",loading:"lazy"})}),Te.map(e=>{const t=xT(e);return t?(0,u.jsx)("div",{className:"absolute",style:fT(e),children:(0,u.jsx)("img",{src:t,alt:e.text||"Session title",className:"h-full w-full object-contain drop-shadow-[0_18px_24px_rgba(0,0,0,0.5)]",loading:"lazy"})},e.id):null})]}),(0,u.jsxs)("div",{className:"pointer-events-none absolute inset-x-0 top-0 flex items-start justify-between gap-3 ".concat(_e.topPaddingClass),children:[(0,u.jsxs)("div",{className:"border border-white/15 bg-[#0B1320]/70 text-[#F4F4F4] shadow-[0_24px_48px_-30px_rgba(0,0,0,0.72)] backdrop-blur-md ".concat(_e.infoCardClass),style:{maxWidth:"".concat(_e.infoMaxWidth,"px")},children:[(0,u.jsx)("div",{className:"font-body font-semibold uppercase tracking-[0.22em] text-[#FFB52B]/80 ".concat(_e.infoLabelClass),children:"Video Overlay"}),(0,u.jsx)("div",{className:"mt-1 font-medium text-white ".concat(_e.infoTitleClass),children:hT((null===Ne||void 0===Ne?void 0:Ne.title)||"Playback metadata",80)}),(null===Ne||void 0===Ne?void 0:Ne.justification)&&(0,u.jsx)("div",{className:"mt-1 leading-snug text-[#CBD2DB] ".concat(_e.bodyTextClass),children:hT(Ne.justification,V?170:110)})]}),(0,u.jsxs)("div",{className:"flex max-w-full flex-col items-end gap-2",children:[(0,u.jsx)("div",{className:"rounded-full border border-white/15 bg-[#0B1320]/70 font-mono text-white shadow-[0_16px_32px_-24px_rgba(0,0,0,0.72)] backdrop-blur-md ".concat(_e.timerClass),children:mT(se)}),Be.length>0&&(0,u.jsx)("div",{className:"flex w-full flex-col items-end gap-2",children:Be.map(e=>{const t="comment"===e.kind?"text-[#9fe2c4]":"edit"===e.kind?"text-[#f7b6d9]":"text-[#9cc7ff]";return(0,u.jsxs)("div",{className:"w-full border border-white/12 bg-[#0B1320]/64 text-white shadow-[0_18px_36px_-26px_rgba(0,0,0,0.78)] backdrop-blur-md ".concat(_e.cueCardClass),style:{maxWidth:"".concat(_e.cueMaxWidth,"px")},children:[(0,u.jsx)("div",{className:"font-body font-semibold uppercase tracking-[0.2em] ".concat(t," ").concat(_e.cueLabelClass),children:e.label}),(0,u.jsx)("div",{className:"mt-1 font-medium leading-snug text-white ".concat(_e.cueTitleClass),children:e.title}),e.body&&(0,u.jsx)("div",{className:"mt-1 leading-snug text-[#D5D9E0] ".concat(_e.cueBodyClass),children:e.body}),e.meta&&(0,u.jsx)("div",{className:"mt-1 text-[#A8B1BE] ".concat(_e.metaTextClass),children:e.meta})]},e.id)})})]})]})]})]}):(0,u.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,u.jsxs)("div",{className:"text-center text-gray-500",children:[(0,u.jsx)("div",{className:"animate-spin w-6 h-6 border-2 border-gray-300 border-t-red-600 rounded-full mx-auto mb-2"}),(0,u.jsx)("p",{className:"text-xs",children:"Loading..."})]})})}),j&&(0,u.jsx)("div",{className:"px-2 py-1 text-xs ".concat(k?"text-gray-400":"text-gray-600"),onClick:D,style:{cursor:"pointer"},children:"Click to expand"}),me&&!j&&(0,u.jsx)("div",{onMouseDown:Re,className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize",style:{background:"linear-gradient(135deg, transparent 50%, rgba(128,128,128,0.5) 50%)"},title:"Drag to resize"})]});var Ve},wT="/api",kT=e=>{const t=Number.isFinite(e)?Math.max(0,e):0,n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=Math.floor(t%60);return"".concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"))},jT=e=>String(e||"").replace(/<br\s*\/?>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim(),DT=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:180;const n=jT(e);return n?n.length>t?"".concat(n.slice(0,t-3),"..."):n:""},CT=e=>{const t="string"===typeof e?Number(e):e;return Number.isFinite(t)?Number(t):null},NT=e=>DT(e.displayName||e.userName||e.userEmail||"Comment",48),FT=e=>{const t=String(e||"").trim().match(/(\d+):(\d+):(\d+),(\d+)/);if(!t)return 0;const[,n,a,r,s]=t;return 3600*Number(n)+60*Number(a)+Number(r)+Number(s)/1e3},ST=e=>{var t,n,r,s,i,o;let{videoUrl:l,sessionId:c=null,sessionVisuals:m=null,selectedTtmlChecksum:h=null,selectedTranscriptChecksum:p=null,totalDuration:g,token:x,speakerSegments:f,speakerLabels:b,isVisible:y,onClose:v,onTimeUpdate:w,onDurationChange:k,onPlayStateChange:j,onReady:D,currentTime:C,mediaSeekRequestId:N=0,mediaSeekRequestTime:F=null,isPlaying:S,volume:E=1,playbackRate:A=1,isDarkMode:T,isMinimized:M=!1,onToggleMinimize:_,onFloating
2Change:B,isMobile:I=!1,mobileTopicTitle:P=null,useExternalAudioSync:L=!1}=e;const{permissions:R,shareToken:z}=Hp(),O=(0,a.useRef)(0),U=(0,a.useRef)(null),V=(0,a.useRef)(null),H=(0,a.useRef)(null),[q,W]=(0,a.useState)(!1),[Y,G]=(0,a.useState)(null),[K,X]=(0,a.useState)(!0),[J,$]=(0,a.useState)(!1),[Q,Z]=(0,a.useState)(!1),[ee,te]=(0,a.useState)(!1),[ne,ae]=(0,a.useState)(null),[re,se]=(0,a.useState)({width:0,height:0}),[ie,oe]=(0,a.useState)([]),[le,ce]=(0,a.useState)([]),[de,ue]=(0,a.useState)([]),[me,he]=(0,a.useState)([]),[pe,ge]=(0,a.useState)([]),[xe,fe]=(0,a.useState)([]),[be,ye]=(0,a.useState)([]),ve=(0,a.useRef)(null),we=(0,a.useRef)(null),ke=(0,a.useRef)(null),je=(0,a.useRef)(0),De=(0,a.useRef)(0),Ce=(0,a.useRef)(0),Ne=(0,a.useRef)(!1),Fe=(0,a.useRef)(!1),Se=(0,a.useRef)(null),Ee=(0,a.useRef)(!1),Ae=(0,a.useRef)(null),Te=l.includes("dropbox.com"),Me=!Te,_e=(e=>{if(!e)return"";if(!e.includes("dropbox.com"))return e;let t=e;return t.includes("dl=0")?t=t.replace("dl=0","dl=1"):t.includes("dl=1")||(t=t.includes("?")?"".concat(t,"&dl=1"):"".concat(t,"?dl=1")),zw("[HOSTED-VIDEO] Normalized Dropbox URL:",t),t})(l),Be=Number.isFinite(C)?Number(C):0,Ie=!0===(null===R||void 0===R?void 0:R.isPublicShare)&&Boolean(z),Pe=!Ie||null===(t=null===R||void 0===R?void 0:R.commentsRead)||void 0===t||t,Le=(0,a.useRef)(!1),Re=(0,a.useRef)(w),ze=(0,a.useRef)(k),Oe=(0,a.useRef)(j),Ue=(0,a.useRef)(D);(0,a.useEffect)(()=>{Re.current=w},[w]),(0,a.useEffect)(()=>{ze.current=k},[k]),(0,a.useEffect)(()=>{Oe.current=j},[j]),(0,a.useEffect)(()=>{Ue.current=D},[D]);const Ve=(0,a.useCallback)(()=>{null!==Ae.current&&(window.clearTimeout(Ae.current),Ae.current=null)},[]),He=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1200;L?null===Ae.current&&(Ae.current=window.setTimeout(()=>{Ae.current=null,X(!0)},e)):X(!0)},[L]);(0,a.useEffect)(()=>{var e,t;if(Le.current||Ie||!Me)return;Boolean((null===m||void 0===m||null===(e=m.placements)||void 0===e?void 0:e.length)||(null===m||void 0===m||null===(t=m.titles)||void 0===t?void 0:t.length))&&(Z(!0),Le.current=!0)},[Ie,m,Me]);const[qe,We]=(0,a.useState)(!1),[Ye,Ge]=(0,a.useState)({x:20,y:100}),[Ke,Xe]=(0,a.useState)({width:400,height:225}),[Je,$e]=(0,a.useState)(!1),[Qe,Ze]=(0,a.useState)(!1),et=(0,a.useRef)({x:0,y:0}),tt=(0,a.useRef)({x:0,y:0}),nt=(0,a.useRef)({width:0,height:0});(0,a.useEffect)(()=>{I&&We(!1)},[I]),(0,a.useEffect)(()=>{null===B||void 0===B||B(qe)},[qe,B]),(0,a.useEffect)(()=>{if(!y||!Me||!c)return;const e=new AbortController;let t=!1;return(async()=>{const n={};x&&(n.Authorization="Bearer ".concat(x));const a=new URLSearchParams;p&&a.set("revision",p);const[r,s,i]=await Promise.all([h?(Ie?UN.getPublicStructure(z,h):UN.getStructure(c,h,x)).catch(e=>(console.warn("[HOSTED-VIDEO] Failed to load structured TTML overlay data:",e),null)):Promise.resolve(null),(Ie?null!==R&&void 0!==R&&R.questionsEnabled?fm(z):Promise.resolve({questions:[]}):xm(c,x)).then(e=>e.questions).catch(e=>(console.warn("[HOSTED-VIDEO] Failed to load session questions for overlay:",e),[])),fetch("".concat(Ie?"".concat(wT,"/public/share/").concat(encodeURIComponent(z),"/transcript/srt"):"".concat("/api/v1","/episodes/").concat(c,"/transcript/srt")).concat(a.toString()?"?".concat(a.toString()):""),{headers:Ie?void 0:n,credentials:Ie?"omit":void 0,signal:e.signal}).then(async e=>{if(!e.ok)throw new Error("Failed to load SRT (".concat(e.status,")"));return e.text()}).catch(t=>(e.signal.aborted||console.warn("[HOSTED-VIDEO] Failed to load SRT captions for overlay:",t),""))]);t||(oe((null===r||void 0===r?void 0:r.topics)||[]),ce((null===r||void 0===r?void 0:r.clips)||[]),ue((null===r||void 0===r?void 0:r.edits)||[]),he((null===r||void 0===r?void 0:r.references)||[]),ge([...s].filter(e=>Number.isFinite(e.timestampSeconds)).sort((e,t)=>(e.timestampSeconds||0)-(t.timestampSeconds||0))),ye((e=>String(e||"").split(/\r?\n\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{const t=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean),n=t.findIndex(e=>e.includes("--\x3e"));if(-1===n)return null;const[a,r]=t[n].split("--\x3e").map(e=>e.trim()),s=t.slice(n+1).map(e=>
2jT(e)).filter(Boolean);return a&&r&&0!==s.length?{start:FT(a),end:FT(r),lines:s,text:s.join(" ")}:null}).filter(e=>Boolean(e)))(i)))})(),()=>{t=!0,e.abort()}},[Ie,y,h,p,c,null===R||void 0===R?void 0:R.questionsEnabled,z,Me,x]),(0,a.useEffect)(()=>{if(!y||!Me||!c||!Pe)return void fe([]);const e=new AbortController;let t=!1;return(async()=>{try{let n=null;if(Ie&&z?n=await fetch("".concat(wT,"/public/share/").concat(encodeURIComponent(z),"/comments"),{credentials:"omit",signal:e.signal}):x&&(n=await fetch("".concat(wT,"/sessions/").concat(c,"/comments"),{headers:{Authorization:"Bearer ".concat(x)},signal:e.signal})),!n)return void(t||fe([]));if(!n.ok)throw new Error("Failed to load comments (".concat(n.status,")"));const a=await n.json();if(t)return;const r=Array.isArray(null===a||void 0===a?void 0:a.comments)?a.comments.map(e=>(e=>{var t;if(!e||"object"!==typeof e)return null;const n=e.id||e.commentId||e.comment_id;return n?{id:String(n),content:"string"===typeof e.content?e.content:"",timestampSeconds:CT(null!==(t=e.timestampSeconds)&&void 0!==t?t:e.timestamp_seconds),userEmail:"string"===typeof e.userEmail?e.userEmail:"string"===typeof e.user_email?e.user_email:"",userName:"string"===typeof e.userName?e.userName:"string"===typeof e.user_name?e.user_name:"",displayName:"string"===typeof e.displayName?e.displayName:"string"===typeof e.display_name?e.display_name:void 0,avatarColor:"string"===typeof e.avatarColor?e.avatarColor:"string"===typeof e.avatar_color?e.avatar_color:void 0,parentCommentId:"string"===typeof e.parentCommentId?e.parentCommentId:"string"===typeof e.parent_comment_id?e.parent_comment_id:void 0}:null})(e)).filter(e=>Boolean(e)):[];fe(r)}catch(Y){e.signal.aborted||console.warn("[HOSTED-VIDEO] Failed to load session comments for overlay:",Y),t||fe([])}})(),()=>{t=!0,e.abort()}},[Pe,Ie,y,c,z,Me,x]),(0,a.useEffect)(()=>{const e=()=>{$(document.fullscreenElement===H.current)};return document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[]);const at=(0,a.useCallback)(()=>{const e=[U.current,H.current,V.current].filter(e=>Boolean(e)),t=e.map(e=>e.getBoundingClientRect()).find(e=>e.width>0&&e.height>0)||e.map(e=>e.getBoundingClientRect()).find(e=>e.width>0)||null,n=Math.round((null===t||void 0===t?void 0:t.width)||0),a=Math.round((null===t||void 0===t?void 0:t.height)||0);se(e=>e.width===n&&e.height===a?e:{width:n,height:a})},[]);(0,a.useEffect)(()=>{if(!y||M)return void at();let e=0;const t=()=>{cancelAnimationFrame(e),e=window.requestAnimationFrame(()=>{at()})};t();const n=window.setTimeout(t,140);if("undefined"===typeof ResizeObserver)return window.addEventListener("resize",t),document.addEventListener("fullscreenchange",t),()=>{cancelAnimationFrame(e),window.clearTimeout(n),window.removeEventListener("resize",t),document.removeEventListener("fullscreenchange",t)};const a=new ResizeObserver(()=>{t()});return[V.current,H.current,U.current].filter(e=>Boolean(e)).forEach(e=>{a.observe(e)}),window.addEventListener("resize",t),document.addEventListener("fullscreenchange",t),()=>{cancelAnimationFrame(e),window.clearTimeout(n),a.disconnect(),window.removeEventListener("resize",t),document.removeEventListener("fullscreenchange",t)}},[qe,J,M,y,at,_e]);const rt=(0,a.useCallback)(async()=>{if(!Me)return;const e=H.current;if(e)try{document.fullscreenElement===e?await document.exitFullscreen():await e.requestFullscreen()}catch(t){console.error("[HOSTED-VIDEO] Failed to toggle fullscreen:",t)}},[Me]);(0,a.useEffect)(()=>{if(!y||!Me||I)return;const e=e=>{var t;e.defaultPrevented||e.repeat||(t=e.target,t instanceof HTMLElement&&t.closest('input, textarea, select, [contenteditable="true"], [role="textbox"]'))||"f"===e.key.toLowerCase()&&(e.preventDefault(),rt())};return window.addEventListener("keydown",e,!0),()=>{window.removeEventListener("keydown",e,!0)}},[I,y,Me,rt]);const st=Number.isFinite(g)&&Number(g)>0?Number(g):Number.isFinite(null===(n=U.current)||void 0===n?void 0:n.duration)?Number(null===(r=U.current)||void 0===r?void 0:r.duration):0,it=(0,a.useMemo)(()=>{const e=((e,t)=>{if(!e||0===e.size||!Number.isFinite(t))return null;const n=Array.from(e.entries()).flatMap(e=>{let[t,n]=e;return Array.isArray(n)?n.filter(e=>Number.isFinite(null===e||void 0===e?void 0:e.start)&&Number.isFinite(null===e||void 0===e?void 0:e.end)).map(e=>({speakerId:Number(t),segmentStart:Number(e.start),segmentEnd:Number(e.end)})):[]}).sort((e,t)=>
2e.segmentStart-t.segmentStart),a=n.find(e=>t>=e.segmentStart&&t<e.segmentEnd);if(a)return a;let r=null,s=null;for(const i of n)if(i.segmentEnd<=t)r=i;else if(i.segmentStart>t){s=i;break}return r&&s&&t>=r.segmentEnd&&t<s.segmentStart&&s.segmentStart-r.segmentEnd<=2?r:null})(f,Be);return e?{id:e.speakerId,label:(null===b||void 0===b?void 0:b[e.speakerId])||"Speaker ".concat(e.speakerId),color:mp(e.speakerId,T)}:null},[T,Be,b,f]),ot=(0,a.useMemo)(()=>ie.find(e=>Be>=e.startTime&&Be<=e.endTime)||null,[Be,ie]),lt=(0,a.useMemo)(()=>jT((null===ot||void 0===ot?void 0:ot.justification)||null),[ot]),ct=(0,a.useMemo)(()=>le.find(e=>Be>=e.startTime&&Be<=e.endTime)||null,[Be,le]),dt=(0,a.useMemo)(()=>{for(let e=0;e<pe.length;e+=1){const t=pe[e],n=Number(t.timestampSeconds),a=e<pe.length-1?Number(pe[e+1].timestampSeconds):Number.POSITIVE_INFINITY;if(Be>=n&&Be<a)return t}return null},[Be,pe]),ut=(0,a.useMemo)(()=>be.find(e=>Be>=e.start&&Be<=e.end)||null,[Be,be]),mt=(0,a.useMemo)(()=>((null===m||void 0===m?void 0:m.placements)||[]).filter(e=>Be>=e.displayStart&&Be<=e.displayEnd).sort((e,t)=>{const n=Number.isFinite(e.displayOrder)?Number(e.displayOrder):0,a=Number.isFinite(t.displayOrder)?Number(t.displayOrder):0;return n!==a?n-a:e.displayStart-t.displayStart}),[Be,m]),ht=(0,a.useMemo)(()=>((null===m||void 0===m?void 0:m.titles)||[]).filter(e=>Be>=e.displayStart&&Be<=e.displayEnd),[Be,m]),pt=(0,a.useMemo)(()=>Tm(me.map(e=>({title:e.name||e.linkText||"",start:e.startTime,end:e.endTime})),m),[m,me]),gt=(0,a.useMemo)(()=>{const e=me.map((e,t)=>{var n;const a=Em({title:e.name||e.linkText||"",start:e.startTime,end:e.endTime},t);return{reference:e,assetCount:(null===(n=pt.get(a))||void 0===n?void 0:n.assetCount)||0}}).filter(e=>{let{reference:t}=e;return Be>=t.startTime&&Be<=t.endTime}).sort((e,t)=>e.assetCount!==t.assetCount?t.assetCount-e.assetCount:e.reference.startTime-t.reference.startTime);if(0===e.length)return null;const[t]=e,n=Em({title:t.reference.name||t.reference.linkText||"",start:t.reference.startTime,end:t.reference.endTime},t.reference.index),a=e.length-1;return{reference:t.reference,assetCount:t.assetCount,binding:pt.get(n)||null,extraCount:a}},[Be,pt,me]),xt=(0,a.useMemo)(()=>de.find(e=>Be>=e.startTime&&Be<=e.endTime)||null,[Be,de]),ft=(0,a.useMemo)(()=>xe.filter(e=>!e.parentCommentId&&null!==e.timestampSeconds&&Be>=e.timestampSeconds&&Be<e.timestampSeconds+10).sort((e,t)=>(t.timestampSeconds||0)-(e.timestampSeconds||0)).slice(0,J?2:1),[J,Be,xe]),bt=Me&&(J||Q),yt=re.width||(J?1280:Ke.width),vt=(0,a.useMemo)(()=>{const e=yt,t=!J&&e>0&&e<520,n=!J&&e>0&&e<760;return{compact:t,narrow:n,topPaddingClass:J?"p-4":t?"p-2":n?"p-3":"p-4",bottomRailClass:J?"right-5 bottom-5 gap-3":t?"right-2.5 bottom-2.5 gap-2":n?"right-3.5 bottom-3.5 gap-2.5":"right-4 bottom-4 gap-3",infoCardClass:J?"rounded-2xl px-4 py-3":t?"rounded-xl px-2.5 py-2":n?"rounded-xl px-3 py-2.5":"rounded-2xl px-4 py-3",infoLabelClass:J?"text-[10px]":t?"text-[8px]":"text-[9px]",infoTitleClass:J?"text-sm":t?"text-[11px]":n?"text-xs":"text-sm",bodyTextClass:J?"text-sm":t?"text-[11px]":"text-xs",metaTextClass:J?"text-xs":t?"text-[10px]":"text-[11px]",timerClass:J?"px-3.5 py-1.5 text-xs":t?"px-2.5 py-1 text-[10px]":"px-3.5 py-1.5 text-xs",cueCardClass:J?"rounded-2xl px-4 py-3.5":t?"rounded-xl px-3 py-2.5":"rounded-xl px-3.5 py-3",cueLabelClass:J?"text-[10px]":t?"text-[8px]":"text-[9px]",cueTitleClass:J?"text-[15px]":t?"text-[11px]":"text-sm",cueBodyClass:J?"text-sm":t?"text-[10px]":"text-xs",cueMaxWidth:Math.max(250,Math.min(e*(J?.32:t?.9:.46),420)
2),subtitleWrapperClass:J?"bottom-6 px-6":t?"bottom-2 px-2":n?"bottom-3 px-3":"bottom-4 px-4",subtitleCardClass:J?"rounded-2xl px-5 py-3 text-lg":t?"rounded-xl px-3 py-1.5 text-[11px]":n?"rounded-xl px-3.5 py-2 text-xs":"rounded-2xl px-4 py-2.5 text-sm",infoMaxWidth:Math.max(220,Math.min(e*(J?.34:t?.78:n?.68:.58),440)),subtitleMaxWidth:Math.max(240,Math.min(e*(J?.82:t?.94:.9),J?980:720))}},[J,yt]);(0,a.useEffect)(()=>{mt.length?ne&&mt.some(e=>e.id===ne)||ae(mt[0].id):ae(null)},[mt,ne]);const wt=(0,a.useMemo)(()=>mt.length?mt.find(e=>e.id===ne)||mt[0]:null,[mt,ne]),kt=(0,a.useMemo)(()=>mt.length?mt:(null===m||void 0===m?void 0:m.placements)||[],[mt,m]),jt=(0,a.useMemo)(()=>{const e=[];return gt&&e.push({id:"reference:".concat(gt.reference.index,":").concat(gt.reference.startTime),kind:"reference",label:"Reference",title:DT(gt.reference.name||gt.reference.linkText||"Reference",72),body:DT(gt.reference.context,J?160:110)||void 0,meta:[gt.reference.category?DT(gt.reference.category,30):null,gt.assetCount>0?"".concat(gt.assetCount," asset").concat(1===gt.assetCount?"":"s"):null,gt.extraCount>0?"+".concat(gt.extraCount," more active"):null].filter(Boolean).join(" \u2022 ")||void 0}),xt&&e.push({id:"edit:".concat(xt.index,":").concat(xt.startTime),kind:"edit",label:"Edit Note",title:DT(xt.title||xt.priority||"Edit span",72),body:DT(xt.suggestion||xt.improvement,J?170:120)||void 0,meta:xt.priority?DT(xt.priority,24):void 0}),ft.forEach(t=>{e.push({id:"comment:".concat(t.id),kind:"comment",label:"Comment",title:NT(t),body:DT(t.content,J?160:110)||"Open comment",meta:null!==t.timestampSeconds?kT(t.timestampSeconds):void 0})}),e},[ft,xt,gt,J]),Dt=Boolean(it||ot||lt||(null===dt||void 0===dt?void 0:dt.questionText)||ct),Ct=bt&&(J||yt>=700),Nt=Ct&&Dt,Ft=Cm(wt),St=Nm(wt),Et=(0,a.useMemo)(()=>mt.length?wt?[wt,...mt.filter(e=>e.id!==wt.id)]:mt:[],[wt,mt]),At=Et.slice(0,4),Tt=Math.max(0,Et.length-At.length),Mt=Me&&ht.length>0&&(J||yt>=700),_t=Math.round(Math.max(J?250:185,Math.min(yt*(J?.27:vt.compact?.38:.31),J?420:320))),Bt=Math.round(_t*(J?.66:.62)),It=J?26:vt.compact?12:18,Pt=J?18:vt.compact?8:12,Lt=J?88:vt.compact?66:78,Rt=_t+Math.max(At.length-1,0)*It,zt=Bt+Math.max(At.length-1,0)*Pt,Ot=J?"left-6 bottom-6":vt.compact?"left-3 bottom-3":"left-4 bottom-4";(0,a.useEffect)(()=>{const e=ve.current;if(!e||!wt||!String(wt.mimeType||"").startsWith("video/"))return;const t=Number.isFinite(wt.sourceStart)?Number(wt.sourceStart):0,n=Number.isFinite(wt.sourceEnd)?Number(wt.sourceEnd):null,a=()=>{e.currentTime=t,e.play().catch(()=>{})},r=()=>{null!=n&&e.currentTime>=n-.05&&(e.currentTime=t)};return e.addEventListener("loadedmetadata",a),e.addEventListener("timeupdate",r),(()=>{const a=t+Math.max(0,Be-wt.displayStart);Number.isFinite(a)&&Math.abs(e.currentTime-a)>.4&&(e.currentTime=a),null!=n&&e.currentTime>=n-.05&&(e.currentTime=t)})(),e.play().catch(()=>{}),()=>{e.removeEventListener("loadedmetadata",a),e.removeEventListener("timeupdate",r)}},[wt,Be]);const Ut=(0,a.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=U.current;if(Se.current=e,!n||!q)return;(t.force||!L||Ee.current&&n.readyState>=HTMLMediaElement.HAVE_FUTURE_DATA)&&(we.current=e,ke.current=e,je.current=Date.now(),Ne.current=!0,n.currentTime=e)},[q,L]),Vt=(0,a.useCallback)(()=>{const e=U.current;if(!e||!q||!L)return;if(!Fe.current)return void(e.paused||(De.current=Date.now(),e.pause()));if(e.readyState<HTMLMediaElement.HAVE_FUTURE_DATA)return void He();const t=Se.current,n=null===t?0:Math.abs(e.currentTime-t);if(null!==t&&n>.55){const e=Date.now();if(!Ee.current||e-je.current<400)return;return void Ut(t,{force:!0})}e.paused&&(De.current=Date.now(),e.play().catch(e=>{console.error("[HOSTED-VIDEO] Failed to play passive video:",e)}))},[q,Ut,He,L]);(0,a.useEffect)(()=>{const e=U.current;if(!e)return;const t=()=>{if(zw("[HOSTED-VIDEO] Video metadata loaded, duration:",e.duration),Ve(),L&&Number.isFinite(C)&&(C||0)>.05){const t=Math.max(0,C);Math.abs(e.currentTime-t)>.25&&Ut(t)}W(!0),X(!1),G(null),ze.current(e.duration),Ue.current()},n=()=>{const t=Date.now();ke.current=e.currentTime,!L&&!Ne.current&&t-je.current>150&&Re.current(e.currentTime)},a=()=>{Ne.current=!0},r=()=>{const t=Date.now()-je.current<500;Ne.current=!1,ke.current=e.currentTime,L||t||Re.current(e.currentTime),L&&window.setTimeout(()=>{Vt()},0)},s=()=>{zw("[HOSTED-VIDEO] Video playing"),L||Oe.current(!0)},i=()=>{zw("[HOSTED-VIDEO] Video paused"),L||Oe.current(!1)},o=()=>{zw("[HOSTED-VIDEO] Video ended"),L||Oe.current(!1)},l=e=>{const t=e.target,n=(null===t||void 0===t?void 0:t.getAttribute("src"))||"";if(/\/api\/public\/share\/[^/]+\/video/.test(n)&&Date.now()-O.current>6e4){O.current=Date.now();const e=t.currentTime||0,n=()=>{t.removeEventListener("loadedmetadata",n);try{t.currentTime=e}catch(_H){}};return t.addEventListener("loadedmetadata",n),void t.load()}console.error("[HOSTED-VIDEO] Video error:",e),Ve(),G("Failed to load hosted video."),X(!1)},c=()=>
2{if(L)return Ee.current=!1,void He();X(!0)},d=()=>{Ee.current=!0,Ve(),X(!1),L&&Vt()},u=()=>{Ve(),L&&Vt()},m=()=>{Ee.current=!0,Ve(),X(!1)};return e.addEventListener("loadedmetadata",t),e.addEventListener("loadeddata",u),e.addEventListener("timeupdate",n),e.addEventListener("seeking",a),e.addEventListener("seeked",r),e.addEventListener("play",s),e.addEventListener("pause",i),e.addEventListener("ended",o),e.addEventListener("error",l),e.addEventListener("waiting",c),e.addEventListener("canplay",d),e.addEventListener("playing",m),()=>{e.removeEventListener("loadedmetadata",t),e.removeEventListener("loadeddata",u),e.removeEventListener("timeupdate",n),e.removeEventListener("seeking",a),e.removeEventListener("seeked",r),e.removeEventListener("play",s),e.removeEventListener("pause",i),e.removeEventListener("ended",o),e.removeEventListener("error",l),e.removeEventListener("waiting",c),e.removeEventListener("canplay",d),e.removeEventListener("playing",m),Ve()}},[Ve,C,Ut,_e,He,Vt,L]),(0,a.useEffect)(()=>{const e=U.current;if(e&&q){if(Fe.current=Boolean(S),L)return S?(Number.isFinite(C)&&(Se.current=C),void Vt()):void(e.paused||(De.current=Date.now(),e.pause()));S&&e.paused?(De.current=Date.now(),e.play().catch(e=>{console.error("[HOSTED-VIDEO] Failed to play:",e)})):S||e.paused||(De.current=Date.now(),e.pause())}},[C,S,q,Vt,L]),(0,a.useEffect)(()=>{const e=U.current;if(!e||!q||void 0===C)return;const t=ke.current;L&&(Se.current=C);const n=Math.abs(e.currentTime-C),a=!L&&null!==t&&Math.abs(C-t)<.35,r=null!==we.current&&Math.abs(we.current-C)<.05;n<=(L?S?.22:.08:S?.75:.12)||a&&!r||r&&n<=(L?.14:.25)||(zw("[HOSTED-VIDEO] Seeking to:",C),Ut(C,{force:L&&n>.65}),L&&Fe.current&&Vt())},[C,S,q,Ut,Vt,L]),(0,a.useEffect)(()=>{U.current&&q&&null!==F&&0!==N&&Ce.current!==N&&(Ce.current=N,Ut(F,{force:!0}),L&&Fe.current&&Vt())},[C,q,N,F,Ut,Vt,L]),(0,a.useEffect)(()=>{const e=U.current;e&&(e.muted=L,e.volume=E)},[L,E]),(0,a.useEffect)(()=>{const e=U.current;e&&(e.playbackRate=A)},[A]);const Ht=(0,a.useCallback)(e=>{qe&&(e.preventDefault(),$e(!0),et.current={x:e.clientX,y:e.clientY},tt.current=d({},Ye))},[qe,Ye]);(0,a.useEffect)(()=>{if(!Je)return;const e=e=>{const t=e.clientX-et.current.x,n=e.clientY-et.current.y;Ge({x:Math.max(0,Math.min(window.innerWidth-320,tt.current.x+t)),y:Math.max(0,Math.min(window.innerHeight-200,tt.current.y+n))})},t=()=>{$e(!1)};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[Je]);const qt=(0,a.useCallback)(e=>{qe&&(e.preventDefault(),e.stopPropagation(),Ze(!0),et.current={x:e.clientX,y:e.clientY},nt.current=d({},Ke))},[qe,Ke]);if((0,a.useEffect)(()=>{if(!Qe)return;const e=e=>{const t=e.clientX-et.current.x,n=Math.max(280,Math.min(800,nt.current.width+t));Xe({width:n,height:n*(9/16)})},t=()=>{Ze(!1)};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[Qe]),!y||!l)return null;const Wt=qe?{position:"fixed",left:Ye.x,top:Ye.y,width:M?"200px":"".concat(Ke.width,"px"),zIndex:1e3,boxShadow:"0 10px 40px rgba(0,0,0,0.3)",borderRadius:"8px",overflow:"hidden"}:{},Yt=qe?{}:{width:"100%",maxWidth:M?"200px":void 0,height:M?"auto":"fit-content"};return(0,u.jsxs)("div",{ref:V,style:d(d({},Wt),Yt),className:"flex flex-col relative ".concat(T?"bg-gray-900 border-gray-700":"bg-white border-gray-200"," ").concat(qe?"border-2":"border-r"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b ".concat(T?"border-gray-700 bg-gray-800":"border-gray-200 bg-gray-50"," ").concat(qe?"cursor-move":""),onMouseDown:Ht,children:[(0,u.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[qe&&(0,u.jsx)(oT,{size:12,className:"text-gray-400"}),Te&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Hm,{size:14,className:"text-blue-500"}),(0,u.jsx)("span",{className:"shrink-0 text-xs font-medium ".concat(T?"text-gray-200":"text-gray-700"),children:"Dropbox Video"})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-0.5",children:[Me&&(0,u.jsxs)("button",{onClick:()=>Z(e=>!e),className:"inline-flex items-center gap-1 rounded px-2 py-1 transition-colors ".concat(T?"text-gray-300 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),title:J?"Overlay is always enabled in fullscreen":Q?"Hide metadata overlay":"Show metadata overlay",disabled:J,children:[Q||J?(0,u.jsx)(Cp,{size:12}):(0,u.jsx)(Fy,{size:12}),(0,u.jsx)("span",{className:"hidden text-[11px] font-medium sm:inline",children:Q||J?"Overlay on":"Overlay off"})]}),!I&&(0,u.jsxs)(u.Fragment,{children:[Me&&(0,u.jsxs)("button",{onClick:()=>{rt()},className:"inline-flex items-center gap-1 rounded px-2 py-1 transition-colors ".concat(T?"text-gray-300 hover:bg-gray-700":"text-gray-600 hover:bg-gray-200"),title:J?"Exit fullscreen (F)":"Enter fullscreen (F)",children:[J?(0,u.jsx)(Rj,{size:12}):(0,u.jsx)(zj,{size:12}),(0,u.jsx)("span",{className:"hidden text-[11px] font-medium sm:inline",children:J?"Exit fullscreen":"Fullscreen"}),(0,u.jsx)("span",{className:"rounded px-1 py-0.5 text-[10px] font-mono ".concat(T?"bg-white/10 text-gray-200":"bg-black/[0.06] text-gray-700"),children:"F"})]}),(0,u.jsx)("button",{onClick:()=>We(!qe),className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(T?"text-gray-400":"text-gray-500"),title:qe?"Dock to sidebar":"Float window",children:qe?(0,u.jsx)(Ey,{size:12}):(0,u.jsx)(lT,{size:12})}),_&&(0,u.jsx)("button",{onClick:_,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(T?"text-gray-400":"text-gray-500"),title:M?"Expand":"Minimize",children:M?(0,u.jsx)(zj,{size:12}):(0,u.jsx)(Rj,{size:12})})]}),(0,u.jsx)("button",{onClick:v,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors ".concat(T?"text-gray-400":"text-gray-500"),title:"Close video player",children:(0,u.jsx)(Pu,{size:12})})]})]}),!M&&(0,u.jsx)("div",{ref:H,className:"relative bg-black",style:J?{width:"100%",height:"100%",overflow:"hidden"}:{paddingBottom:"56.25%",height:0,overflow:"hidden"},children:Y?(0,u.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,u.jsxs)("div",{className:"text-center text-red-500 px-4",children:[Te?(0,u.jsx)(Hm,{size:32,className:"mx-auto mb-2 opacity-50"}):(0,u.jsx)(uj,{size:32,className:"mx-auto mb-2 opacity-50"}),(0,u.jsx)("p",{className:"text-xs",children:Y})]})}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("video",{ref:U,src:_e,className:"absolute inset-0 pointer-events-none select-none ".concat(J?"h-full w-full object-contain":"h-full w-full"),playsInl
2ine:!0,muted:L,controls:!1,controlsList:"nodownload nofullscreen noplaybackrate noremoteplayback",disablePictureInPicture:!0,tabIndex:-1,onContextMenu:e=>e.preventDefault(),preload:"auto"}),K&&(0,u.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-black bg-opacity-50",children:(0,u.jsxs)("div",{className:"text-center text-white",children:[(0,u.jsx)("div",{className:"animate-spin w-6 h-6 border-2 border-gray-300 border-t-blue-500 rounded-full mx-auto mb-2"}),(0,u.jsx)("p",{className:"text-xs",children:L?"Syncing video\u2026 audio stays live":"Loading\u2026"})]})}),bt&&(0,u.jsxs)(u.Fragment,{children:[(mt.length>0||ht.length>0)&&(0,u.jsxs)("div",{className:"pointer-events-none absolute inset-0 z-20",children:[wt&&(St||Ft)&&(0,u.jsx)("div",{className:"pointer-events-none absolute ".concat(Ot),style:{width:"".concat(Rt,"px"),height:"".concat(zt,"px")},children:[...At].reverse().map((e,t)=>{const n=At.length-1-t,a=0===n,r=a?Cm(e):Dm(e),s=Nm(e),i=String(e.mimeType||"").startsWith("video/"),o=Math.max(.78,1-.06*n),l=a?1:Math.max(.44,.9-.16*n),c="translate(".concat(n*It,"px, ").concat(n*Pt,"px) scale(").concat(o,")");return(0,u.jsxs)("div",{className:"absolute left-0 top-0 overflow-hidden rounded-[24px] border text-left transition-transform duration-150 ".concat(a?"border-[#FFCF74]/70 shadow-[0_28px_64px_-34px_rgba(0,0,0,0.88)]":"border-white/14 shadow-[0_18px_40px_-28px_rgba(0,0,0,0.82)] hover:border-white/28"),style:{width:"".concat(_t,"px"),height:"".concat(Math.max(Bt,Lt),"px"),transform:c,transformOrigin:"bottom left",opacity:l,zIndex:At.length-n,backdropFilter:"blur(8px)",background:"rgba(5, 10, 18, 0.42)"},"aria-hidden":"true",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black/22"}),i&&s?a?(0,u.jsx)("video",{ref:ve,src:s,className:"relative h-full w-full object-cover bg-black/88",muted:!0,playsInline:!0,autoPlay:!0,preload:"auto"},"".concat(e.id,":").concat(s)):(0,u.jsx)("video",{src:r||s,className:"relative h-full w-full object-cover bg-black/88",muted:!0,playsInline:!0,loop:!0,autoPlay:!0,preload:"metadata"}):(0,u.jsx)("img",{src:r||s||"",alt:e.altText||e.label||"Session visual",className:"relative h-full w-full object-cover bg-black/82",loading:"lazy"}),(0,u.jsx)("div",{className:a?"absolute inset-0 bg-gradient-to-t from-black/82 via-black/20 to-transparent":"absolute inset-0 bg-gradient-to-t from-black/72 via-black/10 to-transparent"}),a&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"absolute right-3 top-3 inline-flex rounded-full border border-white/14 bg-black/36 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.16em] text-[#FFCF74] backdrop-blur-md",children:Et.length>1?"".concat(Et.findIndex(t=>t.id===e.id)+1," of ").concat(Et.length):"Active visual"}),(0,u.jsxs)("div",{className:"absolute inset-x-0 bottom-0 px-4 py-3.5 text-white",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-[#FFCF74]",children:"Session Visual"}),(0,u.jsx)("div",{className:"mt-1 text-sm font-medium leading-snug sm:text-[15px]",children:jT(e.referenceTitle||e.label||e.description||e.filename||"Visual overlay")})]})]}),!a&&(0,u.jsx)("div",{className:"absolute left-3 top-3 inline-flex rounded-full border border-white/12 bg-black/40 px-2 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-white/84",children:i?"Video":"Image"}),Tt>0&&n===At.length-1&&(0,u.jsxs)("div",{className:"absolute bottom-3 right-3 inline-flex rounded-full border border-white/12 bg-black/45 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.14em] text-white",children:["+",Tt]})]},e.id)})}),Mt&&ht.map(e=>{const t=jT(e.text||""),n=jT(e.subtitle||""),a=(null===(r=e)||void 0===r?void 0:r.url)||(null===r||void 0===r?void 0:r.playbackUrl)||(null===r||void 0===r?void 0:r.originalUrl)||null;var r;return t||n||a?(0,u.jsx)("div",{className:"absolute z-30 px-4",style:{right:"3.25%",top:"5%",width:"min(38%, 640px)"},children:(0,u.jsxs)("div",{className:"ml-auto flex w-full max-w-full flex-col items-start gap-2 rounded-[24px] border border-white/12 bg-[rgba(11,19,32,0.58)] px-5 py-3 text-left text-white shadow-[0_22px_56px_-30px_rgba(0,0,0,0.9)] backdrop-blur-xl",children:[t?(0,u.jsx)("div",{className:"w-full font-semibold leading-tight tracking-[-0.02em] text-white ".concat(J?"text-[clamp(22px,2.7vw,42px)]":"text-[clamp(18px,2vw,30px)]"),style:{fontFamily:"Inter, sans-serif"},children:t}):null,n?(0,u.jsx)("div",{className:"w-full font-medium leading-snug text-white/82 ".concat(J?"text-[clamp(13px,1.2vw,18px)]":"text-[clamp(11px,1vw,14px)]"),style:{fontFamily:"Inter, sans-serif"},children:n}):null,t||n||!a?null:(0,u.jsx)("img",{src:a,alt:e.text||"Session title",className:"max-h-[18vh
2] w-full object-contain drop-shadow-[0_18px_24px_rgba(0,0,0,0.5)]",loading:"lazy"})]})},e.id):null})]}),Nt&&(0,u.jsx)("div",{className:"pointer-events-none absolute left-0 top-0 z-30 ".concat(vt.topPaddingClass),children:(0,u.jsxs)("div",{className:"border border-white/15 bg-[#0B1320]/70 text-[#F4F4F4] shadow-[0_24px_48px_-30px_rgba(0,0,0,0.72)] backdrop-blur-md ".concat(vt.infoCardClass),style:{maxWidth:"".concat(vt.infoMaxWidth,"px")},children:[it&&(0,u.jsxs)("div",{className:"mb-2",children:[(0,u.jsx)("div",{className:"font-body font-semibold uppercase tracking-[0.22em] text-[#FFB52B]/80 ".concat(vt.infoLabelClass),children:"Active Speaker"}),(0,u.jsxs)("div",{className:"mt-1 inline-flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-2.5 py-1 font-medium text-white ".concat(vt.metaTextClass),children:[(0,u.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:it.color}}),(0,u.jsx)("span",{children:it.label})]})]}),ot&&(0,u.jsx)("div",{className:"mb-2 flex items-center gap-2",children:(0,u.jsxs)("span",{className:"inline-flex rounded-full border px-2 py-0.5 font-semibold ".concat(vt.infoLabelClass," ").concat(aF(null!==(s=ot.score)&&void 0!==s?s:5)),children:["Topic ",null!==(i=ot.segmentNumber)&&void 0!==i?i:"?"," \xb7 ",null!==(o=ot.score)&&void 0!==o?o:"?"," / 10"]})}),(null===ot||void 0===ot?void 0:ot.title)&&(0,u.jsx)("div",{className:"font-headlines font-semibold leading-tight text-white ".concat(vt.infoTitleClass),children:jT(ot.title)}),lt&&(0,u.jsx)("div",{className:"mt-1 leading-snug text-[#CBD2DB] ".concat(vt.bodyTextClass),children:lt}),(null===dt||void 0===dt?void 0:dt.questionText)&&(0,u.jsxs)("div",{className:"mt-2",children:[(0,u.jsx)("div",{className:"font-body font-semibold uppercase tracking-[0.22em] text-[#FFB52B]/80 ".concat(vt.infoLabelClass),children:"Current Question"}),(0,u.jsx)("div",{className:"mt-1 leading-snug text-[#F4F4F4] ".concat(vt.bodyTextClass),children:jT(dt.questionText)})]}),ct&&(0,u.jsxs)("div",{className:"mt-2 border-t border-white/10 pt-2",children:[(0,u.jsx)("div",{className:"font-body font-semibold uppercase tracking-[0.22em] text-[#FFB52B]/80 ".concat(vt.infoLabelClass),children:"Current Clip"}),(0,u.jsx)("div",{className:"mt-1 font-medium text-white ".concat(vt.bodyTextClass),children:jT(ct.title)||"Untitled clip"}),ct.clipType&&(0,u.jsx)("div",{className:"mt-0.5 text-[#D5D9E0] ".concat(vt.metaTextClass),children:jT(ct.clipType)}),ct.description&&(0,u.jsx)("div",{className:"mt-1 leading-snug text-[#CBD2DB] ".concat(vt.metaTextClass),children:jT(ct.description)})]})]})}),Ct&&(0,u.jsxs)("div",{className:"pointer-events-none absolute z-30 flex max-w-full flex-col items-end ".concat(vt.bottomRailClass),children:[(0,u.jsxs)("div",{className:"rounded-full border border-white/15 bg-[#0B1320]/70 font-mono text-white shadow-[0_16px_32px_-24px_rgba(0,0,0,0.72)] backdrop-blur-md ".concat(vt.timerClass),children:[kT(Be)," / ",kT(st)]}),jt.length>0&&(0,u.jsx)("div",{className:"flex flex-col items-end gap-2",children:jt.map(e=>{const t="comment"===e.kind?"text-[#9fe2c4]":"edit"===e.kind?"text-[#f7b6d9]":"text-[#9cc7ff]";return(0,u.jsxs)("div",{className:"border border-white/12 bg-[#0B1320]/64 text-white shadow-[0_18px_36px_-26px_rgba(0,0,0,0.78)] backdrop-blur-md ".concat(vt.cueCardClass),style:{maxWidth:"".concat(vt.cueMaxWidth,"px")},children:[(0,u.jsx)("div",{className:"font-body font-semibold uppercase tracking-[0.2em] ".concat(t," ").concat(vt.cueLabelClass),children:e.label}),(0,u.jsx)("div",{className:"mt-1 font-medium leading-snug text-white ".concat(vt.cueTitleClass),children:e.title}),e.body&&(0,u.jsx)("div",{className:"mt-1 leading-snug text-[#D5D9E0] ".concat(vt.cueBodyClass),children:e.body}),e.meta&&(0,u.jsx)("div",{className:"mt-1 text-[#A8B1BE] ".concat(vt.metaTextClass),children:e.meta})]},e.id)})})]}),ut&&(0,u.jsx)("div",{className:"pointer-events-none absolute inset-x-0 flex justify-center ".concat(vt.subtitleWrapperClass),children:(0,u.jsx)("div",{className:"border border-white/10 bg-black/58 text-center font-medium leading-snug text-white shadow-[0_24px_48px_-32px_rgba(0,0,0,0.82)] backdrop-blur-md ".concat(vt.subtitleCardClass),style:{maxWidth:"".concat(vt.subtitleMaxWidth,"px")}
2,children:ut.lines.map((e,t)=>(0,u.jsx)("div",{children:e},"".concat(ut.start,"-").concat(t)))})})]})]})}),ee&&kt.length>0&&(0,u.jsx)("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-black/78 p-4 backdrop-blur-sm",children:(0,u.jsxs)("div",{className:"relative w-full max-w-5xl rounded-[28px] border shadow-[0_28px_80px_-38px_rgba(0,0,0,0.92)] ".concat(T?"border-white/10 bg-[#08111d]/96 text-white":"border-[#d7dee9] bg-[rgba(255,255,255,0.97)] text-[#1f2937]"),children:[(0,u.jsx)("button",{type:"button",onClick:()=>te(!1),className:"absolute right-4 top-4 z-10 inline-flex h-10 w-10 items-center justify-center rounded-full transition-colors ".concat(T?"bg-white/8 text-gray-200 hover:bg-white/14":"bg-[#f3f6fb] text-[#455468] hover:bg-[#e7ecf5]"),"aria-label":"Close session visuals browser",children:(0,u.jsx)(Pu,{size:16})}),(0,u.jsx)("div",{className:"p-5 pt-14",children:(0,u.jsx)(vS,{placements:kt,isDarkMode:T,initialPlacementId:(null===wt||void 0===wt?void 0:wt.id)||ne,onSeek:e=>{te(!1),Ut(e.displayStart,{force:!0})}})})]})}),M&&(0,u.jsx)("div",{className:"px-2 py-1 text-xs ".concat(T?"text-gray-400":"text-gray-600"),onClick:_,style:{cursor:"pointer"},children:"Click to expand"}),qe&&!M&&(0,u.jsx)("div",{onMouseDown:qt,className:"absolute bottom-0 right-0 w-4 h-4 cursor-se-resize",style:{background:"linear-gradient(135deg, transparent 50%, rgba(128,128,128,0.5) 50%)"},title:"Drag to resize"})]})},ET=["videoUrl","videoSource"],AT=e=>{let{videoUrl:t,videoSource:n}=e,a=T(e,ET);return t&&n?"youtube"===n?(0,u.jsx)(vT,d({youtubeUrl:t},a)):"file"===n?(0,u.jsx)(ST,d({videoUrl:t},a)):"dropbox"===n?(console.warn("[VideoPlayer] Dropbox playback is disabled. Prepare the source in AWS first."),null):(console.warn("[VideoPlayer] Unknown video source:",n),null):null},TT=e=>{let{text:t,className:n=""}=e;const r=(0,a.useRef)(null),s=(0,a.useRef)(null),[i,o]=(0,a.useState)(!1),[l,c]=(0,a.useState)(0);return(0,a.useEffect)(()=>{const e=()=>{if(r.current&&s.current){const e=r.current.offsetWidth,t=s.current.scrollWidth;o(t>e),c(e)}};e(),window.addEventListener("resize",e);const t=setTimeout(e,100);return()=>{window.removeEventListener("resize",e),clearTimeout(t)}},[t]),(0,u.jsx)("div",{ref:r,className:"overflow-bounce-container ".concat(n),style:i?{"--container-width":"".concat(l,"px")}:void 0,children:(0,u.jsx)("span",{ref:s,className:i?"animate-bounce-text":"",children:t})})},MT=(0,a.createContext)(void 0),_T=e=>{let{children:t}=e;const[n,r]=(0,a.useState)(()=>{const e=localStorage.getItem("autoScrollEnabled");return null===e||JSON.parse(e)});(0,a.useEffect)(()=>{localStorage.setItem("autoScrollEnabled",JSON.stringify(n))},[n]);const s={autoScrollEnabled:n,setAutoScrollEnabled:r};return(0,u.jsx)(MT.Provider,{value:s,children:t})};function BT(e){return e.clipCode||e.clipId.slice(0,8)}function IT(){const e=qF(),{buildClipItems:t,buildEmptySpaceItems:n}=GF(),[r,s]=(0,a.useState)(null),i=(0,a.useRef)({overlay:e,buildClipItems:t,buildEmptySpaceItems:n});(0,a.useLayoutEffect)(()=>{i.current={overlay:e,buildClipItems:t,buildEmptySpaceItems:n}});const o=(0,a.useCallback)((e,t,n,a)=>{var r;const o=i.current;if(null===(r=o.overlay)||void 0===r||!r.enabled||!o.overlay.detail)return;if(e.preventDefault(),a.length>0){const n=o.overlay.detail.arrangement.title,r=a.length>1,i=[],l=[];for(const e of a){const n=BT(e),a=o.overlay.clipsById.get(e.clipId),s=a?a.startTime:e.start,c=a?a.endTime:e.end,u=r?"".concat(n," \xb7 ").concat(MF(s),"\u2013").concat(MF(c)).concat(e.title?" \xb7 ".concat(e.title):""):void 0;for(const l of o.buildClipItems(e.clipId,{atTime:t}))i.push(r?d(d({},l),{},{id:"".concat(e.clipId,"-").concat(l.id),section:u}):l);const m=o.overlay.deleteImpactFor(e.clipId);for(const e of(null===m||void 0===m?void 0:m.warnings)||[])l.push(r?"".concat(n,": ").concat(e):e)}const c=a[0],u=o.overlay.clipsById.get(c.clipId);return void s({x:e.clientX,y:e.clientY,title:r?"".concat(a.length," clips overlap here"):"".concat(BT(c)," \xb7 ").concat(MF(u?u.startTime:c.start))+"\u2013".concat(MF(u?u.endTime:c.end)),subtitle:r?n:c.title,warnings:l,items:i})}const l={start:t,end:Math.max(n,t+1)};s({x:e.clientX,y:e.clientY,title:"".concat(MF(l.start),"\u2013").concat(MF(l.end)),subtitle:o.overlay.detail.arrangement.title,items:o.buildEmptySpaceItems(l,{label:"Make this passage a clip"}),warnings:[]})},[]),l=(0,a.useCallback)(e=>{var t;
2const n=i.current;null!==(t=n.overlay)&&void 0!==t&&t.enabled&&n.overlay.setHoveredClipId(e?e.clipId:null)},[]);return{menu:r,closeMenu:(0,a.useCallback)(()=>s(null),[]),handleSegmentContextMenu:o,handleArrangementClipHover:l}}const PT=[],LT=(e,t,n)=>Math.min(Math.max(e,t),n);function RT(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=0,r=-1/0;return e.map((e,s)=>e.segments.map((e,i)=>{var o;const l=e.timestampSeconds,c=e.endTimestampSeconds;for(l<r&&(a=0),r=l;a<t.length&&t[a].end<=l;)a+=1;let d=PT;for(let n=a;n<t.length;n+=1){const e=t[n];if(e.start>=c)break;e.end<=l||(d===PT&&(d=[]),d.push(e))}const u=null===(o=n[s])||void 0===o?void 0:o[i];return u&&function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1/0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1){const s=e[r],i=t[r];if(s.clipId!==i.clipId||s.placed!==i.placed||s.clipCode!==i.clipCode||s.title!==i.title||LT(s.start,n,a)!==LT(i.start,n,a)||LT(s.end,n,a)!==LT(i.end,n,a))return!1}return!0}(u,d,l,c)?u:d}))}const zT=["className","children"],OT=e=>{let{comments:t,position:n,onClose:r,onReply:s,onReact:i,onDelete:o,onAddComment:l,sessionId:c,token:m,timestampSeconds:h,readOnly:p=!1}=e;const{isDarkMode:g}=zu(),{user:x}=am(),{seekTo:f}=Kw(),b=(0,a.useRef)(f);(0,a.useEffect)(()=>{b.current=f},[f]);const y=(0,a.useRef)(null),[v,w]=(0,a.useState)(new Set),[k,j]=(0,a.useState)(null),[D,C]=(0,a.useState)(""),[N,F]=(0,a.useState)({}),[E,A]=(0,a.useState)(!1),[M,_]=(0,a.useState)(""),B=!p&&!!s,I=!p&&!!i,P=!p&&!!l;(0,a.useEffect)(()=>{(async()=>{if(c&&m)try{const e=await fetch("".concat("","/api/sessions/").concat(c,"/reactions"),{headers:{Authorization:"Bearer ".concat(m)}});if(e.ok){const t=await e.json();F(t.reactions||{})}}catch(e){console.error("Failed to load reactions:",e)}})()},[c,m]),(0,a.useEffect)(()=>{const e=e=>{y.current&&!y.current.contains(e.target)&&r()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]);const L=async e=>{D.trim()&&s&&(await s(e,D),C(""),j(null))},R=e=>!!x&&e.userEmail===x.email,z=e=>{const t=["bg-[#232E3F]","bg-[#435065]","bg-[#8B5B00]","bg-[#B56A5D]","bg-[#FFB52B]","bg-[#5C6675]","bg-[#6B5130]","bg-[#A48757]"];return t[e.split("").reduce((e,t)=>e+t.charCodeAt(0),0)%t.length]},O=e=>{const t="string"===typeof e?new Date(e):e;if(Number.isNaN(t.getTime()))return"";const n=(new Date).getTime()-t.getTime(),a=Math.floor(n/6e4),r=Math.floor(a/60),s=Math.floor(r/24);return s>0?"".concat(s,"d ago"):r>0?"".concat(r,"h ago"):a>0?"".concat(a,"m ago"):"Just now"},U=g?"border-white/10 bg-[rgba(17,27,42,0.54)] text-[#F4F4F4] shadow-[0_28px_72px_-36px_rgba(0,0,0,0.72)] backdrop-blur-[32px]":"border-[rgba(215,222,233,0.86)] bg-[rgba(255,255,255,0.52)] text-[#172033] shadow-[0_24px_60px_-34px_rgba(15,23,42,0.18)] backdrop-blur-[30px]",V=g?"bg-[rgba(17,27,42,0.42)] border border-white/10 backdrop-blur-[26px]":"bg-[rgba(255,255,255,0.44)] border border-[rgba(215,222,233,0.82)] backdrop-blur-[24px]",H=g?"text-[#c9d3e3]":"text-[#5a6a80]",q=g?"bg-[rgba(10,17,27,0.48)] border-white/10 text-gray-200 backdrop-blur-[24px]":"bg-[rgba(255,255,255,0.54)] border-[rgba(215,222,233,0.82)] text-gray-900 backdrop-blur-[22px]",W=e=>{let{comment:t,depth:n}=e;const a=t.replies&&t.replies.length>0,r=v.has(t.id),s=t.userEmail||"Anonymous",l=t.userName||"Anonymous",c=t.timestamp||t.createdAt||t.updatedAt,m=N[t.id]||t.reactions||[];return(0,u.jsxs)("div",{className:"".concat(n>0?"ml-6 mt-2":""),children:[(0,u.jsx)("div",{className:"".concat(V," rounded-xl p-3"),children:(0,u.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,u.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-xs font-medium text-white ".concat(z(s)),children:s.includes("@")&&"Anonymous"!==s?(h=s,"Anonymous"===h?"AN":h.split("@")[0].substring(0,2).toUpperCase()):(0,u.jsx)(vh,{size:14})}),(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("span",{className:"truncate text-sm font-medium font-headlines",children:l}),null!==t.timestampSeconds&&void 0!==t.timestampSeconds&&(0,u.jsx)("button",{onClick:()=>{return e=t.timestampSeconds,void(b.current&&b.current(e));var e},className:"font-mono text-xs text-[#B57700] hover:text-[#8B5B00]",children:Iw(t.timestampSeconds)}),c&&(0,u.jsx)("span",{className:"text-xs ".concat(H),children:O(c)})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1",children:[B&&(0,u.jsx)("button",{onClick:()=>j(t.id),className:"p-1 rounded transition-colors ".concat(g?"text-gray-400 hover:text-gray-200 hover:bg-white/8":"text-gray-400 hover:text-gray-600 hover:bg-[rgba(255,255,255,0.42)]"),title:"Reply",children:(0,u.jsx)(Nw,{size:14})}),R(t)&&o&&(0,u.jsx)("button",{onClick:()=>o(t.id),className:"text-gray-400 hover:text-red-500 transition-colors p-1 rounded",title:"Delete comment",children:(0,u.jsx)(kp,{size:14})})]})]}),(0,u.jsx)("div",{className:"text-sm ".concat(g?"text-gray-200":"text-gray-700"," prose prose-sm ").concat(g?"prose-invert":""," max-w-none"),children:(0,u.jsx)(my,{remarkPlugins:[Cw],components:{p:e=>{let{children:t}=e;return(0,u.jsx)("p",{className:"mb-2 last:mb-0 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},ul:e=>{let{children:t}=e;return(0,u.jsx)("ul",{className:"list-disc list-inside mb-2 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},ol:e=>{let{children:t}=e;return(0,u.jsx)("ol",{className:"list-decimal list-inside mb-2 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},li:e=>{let{children:t}=e;return(0,u.jsx)("li",{className:"mb-1 ".concat(g?"text-gray-200":"text-gray-700"),children:t})},h1:e=>{let{children:t}=e;return(0,u.jsx)("h1",{className:"text-base font-bold mb-2 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},h2:e=>{let{children:t}=e;return(0,u.jsx)("h2",{className:"text-sm font-bold mb-2 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},h3:e=>{let{children:t}=e;return(0,u.jsx)("h3",{className:"text-sm font-semibold mb-1 ".concat(g?"text-gray-100":"text-gray-800"),children:t})},strong:e=>{let{children:t}=e;return(0,u.jsx)("strong",{className:"font-semibold ".concat(g?"text-gray-100":"text-gray-800"),children:t})},em:e=>{let{children:t}=e;return(0,u.jsx)("em",{className:"italic ".concat(g?"text-gray-200":"text-gray-700"),children:t})},blockquote:e=>{let{children:t}=e;return(0,u.jsx)("blockquote",{className:"border-l-4 ".concat(g?"border-gray-500 text-gray-300":"border-gray-300 text-gray-700"," pl-4 italic mb-2"),children:t})},code:e=>{let{className:t,children:n}=e,a=T(e,zT);const r=!t?"".concat(g?"bg-white/10 text-gray-200":"bg-[rgba(255,255,255,0.46)] text-gray-800"," px-1 py-0.5 rounded text-xs backdrop-blur-xl"):"block ".concat(g?"bg-white/10 text-gray-200":"bg-[rgba(255,255,255,0.46)] text-gray-800"," p-2 rounded text-xs overflow-x-auto backdrop-blur-xl");return(0,u.jsx)("code",d(d({className:r},a),{},{children:n}))},a:e=>{let{children:t,href:n}=e;return(0,u.jsx)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"text-[#B57700] hover:text-[#8B5B00] underline",children:t})}},children:t.content})}),(m.length>0||I)&&(0,u.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[m.map((e,n)=>{var a;const r=null===(a=e.users)||void 0===a?void 0:a.split(",").map(e=>{const t=e.split("@")[0];return t.charAt(0).toUpperCase()+t.slice(1)}).join(", ");return(0,u.jsxs)("button",{onClick:()=>{i&&i(t.id,e.emoji)},disabled:!I,className:"relative group flex items-center gap-1 px-2 py-1 rounded-full text-xs transition-colors ".concat(e.userReacted?g?"border border-[#445166] bg-[#232E3F] text-[#F4F4F4] hover:bg-[#2F3B4E]":"border border-[#
2E7B14C]/45 bg-[#FFF4D8] text-[#8B5B00] hover:bg-[#FFE7AD]":g?"bg-white/8 text-gray-300 hover:bg-white/12":"bg-[rgba(255,255,255,0.42)] text-gray-700 hover:bg-[rgba(255,255,255,0.58)]"),title:r||"No users",children:[(0,u.jsx)("span",{children:e.emoji}),(0,u.jsx)("span",{children:e.count})]},n)}),I&&(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsx)("button",{onClick:()=>{i&&i(t.id,"\ud83d\udc4d")},className:"p-1.5 rounded-full transition-colors ".concat(g?"hover:bg-white/8 text-gray-400 hover:text-gray-200":"hover:bg-[rgba(255,255,255,0.42)] text-gray-500 hover:text-gray-700"),children:(0,u.jsx)(Fw,{size:14})}),(0,u.jsx)("button",{onClick:()=>{i&&i(t.id,"\u2764\ufe0f")},className:"p-1.5 rounded-full transition-colors ".concat(g?"hover:bg-white/8 text-gray-400 hover:text-gray-200":"hover:bg-[rgba(255,255,255,0.42)] text-gray-500 hover:text-gray-700"),children:(0,u.jsx)(Sw,{size:14})}),(0,u.jsx)("button",{onClick:()=>{i&&i(t.id,"\ud83d\ude0a")},className:"p-1.5 rounded-full transition-colors ".concat(g?"hover:bg-white/8 text-gray-400 hover:text-gray-200":"hover:bg-[rgba(255,255,255,0.42)] text-gray-500 hover:text-gray-700"),children:(0,u.jsx)(Ew,{size:14})})]})]}),B&&k===t.id&&(0,u.jsxs)("div",{className:"mt-2 flex items-end gap-2",children:[(0,u.jsx)("input",{type:"text",value:D,onChange:e=>C(e.target.value),onKeyPress:e=>{"Enter"===e.key&&L(t.id)},placeholder:"Write a reply...",className:"flex-1 px-3 py-1 text-sm rounded-lg border ".concat(q," focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/35"),autoFocus:!0}),(0,u.jsx)("button",{onClick:()=>L(t.id),className:"rounded-lg bg-[#FFB52B] p-1.5 text-[#232E3F] transition-colors hover:bg-[#FFC54D]",children:(0,u.jsx)(My,{size:14})})]}),a&&(0,u.jsxs)("button",{onClick:()=>{return e=t.id,void w(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e},className:"flex items-center gap-1 mt-2 text-xs ".concat(g?"text-gray-400 hover:text-gray-200":"text-gray-600 hover:text-gray-800"),children:[r?(0,u.jsx)(wd,{size:14}):(0,u.jsx)(bp,{size:14}),(0,u.jsxs)("span",{children:[t.replies.length," ",1===t.replies.length?"reply":"replies"]})]})]})]})}),a&&r&&(0,u.jsx)("div",{className:"mt-2",children:t.replies.map(e=>(0,u.jsx)(W,{comment:e,depth:n+1},e.id))})]});var h},Y=12,G=Math.min(384,window.innerWidth-24),K=Math.min(500,window.innerHeight-24),X={width:"".concat(G,"px"),maxHeight:"".concat(K,"px"),left:Math.max(Y,Math.min(n.x,window.innerWidth-G-Y)),top:Math.max(Y,Math.min(n.y,window.innerHeight-K-Y))};return(0,u.jsx)(S,{children:(0,u.jsxs)(Do.div,{ref:y,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"fixed z-50 overflow-y-auto rounded-lg shadow-2xl ".concat(U),style:X,children:[(0,u.jsxs)("div",{className:"sticky top-0 flex items-center justify-between border-b p-3 bg-inherit ".concat(g?"border-white/10":"border-[#e5ebf2]"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(ky,{size:18,className:"text-[#B57700] dark:text-[#FFCF74]"}),(0,u.jsx)("span",{className:"font-medium font-headlines",children:"Comments"})]}),(0,u.jsx)("button",{onClick:r,className:"rounded p-1 transition-colors ".concat(g?"hover:bg-white/8":"hover:bg-[rgba(255,255,255,0.42)]"),children:(0,u.jsx)(Pu,{size:18})})]}),p&&(0,u.jsx)("div",{className:"border-b px-3 py-2 text-xs ".concat(g?"border-white/10 bg-[rgba(10,17,27,0.34)] text-gray-400 backdrop-blur-xl":"border-[#e5ebf2] bg-[rgba(255,255,255,0.42)] text-gray-500 backdrop-blur-[22px]"),children:"Offline and public-share comments are read-only in this view."}),(0,u.jsxs)("div",{className:"p-3 space-y-3",children:[0===t.length?(0,u.jsxs)("div",{className:"text-center py-4",children:[(0,u.jsx)("p",{className:"text-gray-500 mb-4",children:"No comments yet"}),P&&(0,u.jsx)("button",{onClick:()=>A(!0),className:"rounded-lg bg-[#FFB52B] px-4 py-2 text-sm text-[#232E3F] transition-colors hover:bg-[#FFC54D]",children:"Add the first comment"})]}):(0,u.jsxs)(u.Fragment,{children:[t.map(e=>(0,u.jsx)(W,{comment:e,depth:0},e.id)),P&&(0,u.jsx)("button",{onClick:()=>A(!0),className:"w-full px-3 py-2 text-sm rounded-lg transition-colors ".concat(g?"bg-white/8 hover:bg-white/12 text-gray-300 backdrop-blur-xl":"bg-[rgba(255,255,255,0.42)] hover:bg-[rgba(255,255,255,0.58)] text-gray-700 backdrop-blur-[22px]"),children:"Add a comment"})]}),E&&P&&l&&(0,u.jsx)("div",{className:"border-t pt-3 ".concat(g?"border-white/10":"border-[#e5ebf2]"),children:(0,u.jsxs)("div",{className:"flex items-end gap-2",children:[(0,u.jsx)("input",{type:"text",value:M,onChange:e=>_(e.target.value),onKeyPress:async e=>{"Enter"===e.key&&M.trim()&&(await l(M,h),_(""),A(!1))},placeholder:"Write a comment...",className:"flex-1 rounded-lg border px-3 py-2 text-sm ".concat(q," focus:outline-none focus:ring-2 focus:ring-[#FFB52B]/35"),autoFocus:!0}),(0,u.jsx)("button",{onClick:async()=>{M.trim()&&(await l(M,h),_(""),A(!1))},className:"rounded-lg bg-[#FFB52B] p-2 text-[#232E3F] transition-colors hover:bg-[#FFC54D]",children:(0,u.jsx)(My,{size:16})}),(0,u.jsx)("button",{onClick:()=>{A(!1),_("")},className:"p-2 rounded-lg transition-colors ".concat(g?"text-gray-400 hover:text-gray-200 hover:bg-white/8":"text-gray-500 hover:text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),children:(0,u.jsx)(Pu,{size:16})})]})})]})]})})},UT="ReadableTranscriptView_wordHighlight__hCtTn",VT="ReadableTranscriptView_clickableWord__bmaZW",HT
2="ReadableTranscriptView_current__wd7fT",qT="ReadableTranscriptView_searchHighlight__Lwi8j",WT="ReadableTranscriptView_lightsaberSimple__GFSYr",YT="ReadableTranscriptView_selectionHighlight__1hcrx";const GT=(0,a.memo)(e=>{let{text:t,startTime:n,endTime:r,currentWordIndex:s,segmentWords:i,wordIndex:o,isActive:l,isPlaying:c,className:m,searchQuery:h,selectedWordKeys:p=[],clipRanges:g=[],editRanges:x=[],arrangementRanges:f=[],arrangementHighlighted:b=!1,presenceCursors:y=[],isDarkMode:v=!1,onWordClick:w}=e;const k=(0,a.useMemo)(()=>{if(!l||!c||0===i.length)return-1;const e=o[s];return e?i.findIndex(t=>{var n;return t&&"number"===typeof t.start&&"number"===typeof t.end&&t.start===e.start&&t.end===e.end&&t.utteranceIndex===e.utteranceIndex&&(null!==(n=t.wordIndex)&&void 0!==n?n:t.sourceWordIndex)===e.wordIndex}):-1},[s,l,c,i,o]),j=(0,a.useMemo)(()=>i.map(e=>{if(!e||"number"!==typeof e.start||"number"!==typeof e.end)return{isClip:!1,isEdit:!1};const t=t=>t.some(t=>e.start<t.end&&e.end>t.start);return{isClip:t(g),isEdit:t(x)}}),[g,x,i]),D=(0,a.useMemo)(()=>function(e,t){const n=e.map(()=>null);if(!Array.isArray(t)||0===t.length)return n;const a=t=>{const n=e[t];return n&&"number"===typeof n.start&&"number"===typeof n.end?n:null};let r=1/0,s=-1/0;for(let o=0;o<e.length;o+=1){const e=a(o);e&&(r=Math.min(r,e.start),s=Math.max(s,e.end))}const i=e.map(()=>[]);for(const o of t){let t=-1,n=-1;for(let r=0;r<e.length;r+=1){const e=a(r);e&&e.start<o.end&&e.end>o.start&&(-1===t&&(t=r),n=r,i[r].push({range:o,opensHere:!1,closesHere:!1,cutsWord:!1}))}if(-1===t)continue;const l=a(t),c=a(n),d=o.start>=r,u=o.end<=s,m=e=>i[e][i[e].length-1];if(d){const e=m(t);e.opensHere=!0,e.cutsWord=e.cutsWord||!!l&&o.start>l.start}if(u){const e=i[n].find(e=>e.range===o)||m(n);e.closesHere=!0,e.cutsWord=e.cutsWord||!!c&&o.end<c.end}}for(let o=0;o<i.length;o+=1){const e=i[o];0!==e.length&&(n[o]={clips:e,opensHere:e.some(e=>e.opensHere),closesHere:e.some(e=>e.closesHere),cutsWord:e.some(e=>e.cutsWord)})}return n}(i,f),[f,i]),C=(0,a.useMemo)(()=>{const e={boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone",backgroundColor:b?v?"rgba(255,181,43,0.10)":"rgba(255,181,43,0.14)":void 0};return t=>{const n=t.slice(0,3).map((e,t)=>"inset 0 -".concat(2*(t+1),"px 0 0 ").concat(e.range.placed?v?"rgba(255,181,43,0.55)":"rgba(198,133,12,0.45)":v?"rgba(148,163,184,0.45)":"rgba(100,116,139,0.35)"));return{shared:e,shadows:n}}},[b,v]),N=(0,a.useMemo)(()=>{const e=e=>e?v?"rgba(255,181,43,0.85)":"rgba(198,133,12,0.75)":v?"rgba(148,163,184,0.7)":"rgba(100,116,139,0.6)";return D.map(t=>{if(!t)return null;const{shared:n,shadows:a}=C(t.clips),r=[...a],s=t.clips.find(e=>e.opensHere),i=t.clips.find(e=>e.closesHere);s&&r.push("inset ".concat(2,"px 0 0 0 ").concat(e(s.range.placed))),i&&r.push("inset -".concat(2,"px 0 0 0 ").concat(e(i.range.placed)));const o=t.clips.filter(e=>e.opensHere||e.closesHere).map(e=>"".concat(e.range.label," ").concat(e.opensHere?"starts":"ends"," ").concat(e.cutsWord?"part-way through this word":"at this word")),l=t.clips.length>1?"In ".concat(t.clips.length," clips: ").concat(t.clips.map(e=>e.range.label).join(", ")):null;return{style:d(d({},n),{},{boxShadow:r.join(", ")}),clipIds:t.clips.map(e=>e.range.clipId),boundaryNote:[l,...o].filter(Boolean).join(" \xb7 ")||null}})},[C,D,v]),F=(0,a.useMemo)(()=>{const e=new Map;if(!Array.isArray(x)||0===x.length||!Array.isArray(i)||i.length<2)return e;const t=e=>i.some(t=>!(!t||"number"!==typeof t.start||"number"!==typeof t.end)&&(t.start<e.end&&t.end>e.start));for(const n of x){if(!n||!Number.isFinite(n.start)||!Number.isFinite(n.end)||n.end<=n.start)continue;if(t(n))continue;const a=(n.start+n.end)/2;for(let t=0;t<i.length-1;t+=1){const r=i[t],s=i[t+1];if(r&&s&&"number"===typeof r.end&&"number"===typeof s.start&&!(s.start<=r.end)&&(a>=r.end-.02&&a<=s.start+.02)){const a=e.get(t)||[];a.push({start:n.start,end:n.end,duration:n.end-n.start}),e.set(t,a);break}}}return e},[x,i]),S=(0,a.useMemo)(()=>new Set(p),[p]),E=(0,a.useMemo)(()=>{const e=t.split(/(\s+)/);let n=0;const a=e.map((e,t)=>{var a,r;if(t%2===1)return{kind:"space",key:t,text:e,arrangementIndex:n-1};const s=n;n+=1;const o=i[s],d=j[s]||{isClip:!1,isEdit:!1};return{kind:"word",key:t,text:e,actualWordIndex:s,timedWord:o,annotationStyle:d,arrangementStyle:N[s]||null,isCurrentWord:l&&c&&s===k,isSelectionHighlighted:S.has("".concat(null===o||void 0===o?void 0:o.start,"|").concat(null===o||void 0===o?void 0:o.end,"|").concat(null===o||void 0===o?void 0:o.utteranceIndex,"|").concat(null!==(a=null!==(r=null===o||void 0===o?void 0:o.wordIndex)&&void 0!==r?r:null===o||void 0===o?void 0:o.sourceWordIndex)&&void 0!==a?a:s)),presenceCursors:y.filter(e=>{return t=e.time,!!((n=o)&&Number.isFinite(n.start)&&Number.isFinite(n.end))&&t>=Number(n.start)&&t<Number(n.end);var t,n}),clickable:!!w&&"number"===typeof(null===o||void 0===o?void 0:o.start)}}),r={display:"inline",background:v?"rgba(255,181,43,0.18)":"rgba(255,214,102,0.42)",color:v?"#F6E8BE":"#6
2B4A00",fontWeight:600,paddingTop:"0.08em",paddingBottom:"0.08em",paddingLeft:"0.18em",paddingRight:"0.18em",marginLeft:"0.02em",marginRight:"0.02em",borderRadius:"0.44em",boxShadow:v?"inset 0 0 0 1px rgba(255,181,43,0.24), inset 0 -1px 0 rgba(255,225,145,0.16), 0 0 0 1px rgba(255,181,43,0.05)":"inset 0 0 0 1px rgba(201,138,0,0.18), inset 0 -1px 0 rgba(255,255,255,0.46), 0 1px 4px rgba(201,138,0,0.10)",boxDecorationBreak:"clone",WebkitBoxDecorationBreak:"clone"},s={display:"inline-flex",alignItems:"center",gap:"0.22rem",padding:"0.08rem 0.38rem",marginLeft:"0.14rem",marginRight:"0.14rem",borderRadius:"999px",verticalAlign:"baseline",whiteSpace:"nowrap",background:v?"rgba(127,29,29,0.34)":"rgba(254,226,226,0.92)",color:v?"#fecaca":"#991b1b",boxShadow:v?"inset 0 0 0 1px rgba(248,113,113,0.28)":"inset 0 0 0 1px rgba(239,68,68,0.16)",fontSize:"0.72em",fontWeight:700,letterSpacing:"0.01em"},o=e=>{if(h&&""!==h.trim()){const t=h.toLowerCase(),n=e.text.toLowerCase();if(n.includes(t)){const a=n.indexOf(t),r=e.text.slice(0,a),s=e.text.slice(a,a+h.length),i=e.text.slice(a+h.length);return(0,u.jsxs)(u.Fragment,{children:[r,(0,u.jsx)("span",{className:qT,children:s}),i]})}}return e.text},m=function(e,t){var n,a,r,s,i,l,c,m,h,p,g,x;let f=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const b=e.isSelectionHighlighted?v?"#ffcf5a":"#8a5200":void 0,y=d(d({},(null===(n=e.arrangementStyle)||void 0===n?void 0:n.style)||{}),{},{backgroundImage:e.presenceCursors.length>0?"linear-gradient(180deg, transparent 12%, ".concat(e.presenceCursors[0].color,"2b 12%, ").concat(e.presenceCursors[0].color,"2b 92%, transparent 92%)"):void 0,borderRadius:e.presenceCursors.length>0?"0.22em":void 0,color:null!==b&&void 0!==b?b:e.annotationStyle.isEdit?v?"#fca5a5":"#b91c1c":void 0,fontWeight:e.isSelectionHighlighted?750:!f&&e.annotationStyle.isClip?600:void 0,textShadow:e.isSelectionHighlighted?v?"0 0 12px rgba(255,181,43,0.34), 0 1px 2px rgba(0,0,0,0.46)":"0 1px 0 rgba(255,255,255,0.74), 0 0 8px rgba(255,181,43,0.20)":void 0}),k=t=>{e.clickable&&(t.stopPropagation(),null===w||void 0===w||w(e.timedWord.start))};return(0,u.jsxs)("span",{className:"".concat(UT," ").concat(e.isCurrentWord?HT:""," ").concat(e.isSelectionHighlighted?YT:""," ").concat(e.clickable?VT:""),"data-word-index":e.actualWordIndex,"data-current-word":e.isCurrentWord?"true":void 0,"data-transcript-word":"true","data-word-key":"".concat(null===(a=e.timedWord)||void 0===a?void 0:a.start,"|").concat(null===(r=e.timedWord)||void 0===r?void 0:r.end,"|").concat(null===(s=e.timedWord)||void 0===s?void 0:s.utteranceIndex,"|").concat(null!==(i=null!==(l=null===(c=e.timedWord)||void 0===c?void 0:c.wordIndex)&&void 0!==l?l:null===(m=e.timedWord)||void 0===m?void 0:m.sourceWordIndex)&&void 0!==i?i:e.actualWordIndex),"data-word-start":"number"===typeof(null===(h=e.timedWord)||void 0===h?void 0:h.start)?e.timedWord.start:void 0,"data-word-end":"number"===typeof(null===(p=e.timedWord)||void 0===p?void 0:p.end)?e.timedWord.end:void 0,"data-word-text":e.text,"data-
2presence-participants":e.presenceCursors.length>0?e.presenceCursors.map(e=>e.id).join(" "):void 0,"data-arrangement-clip":e.arrangementStyle?"true":void 0,"data-arrangement-clip-count":e.arrangementStyle?e.arrangementStyle.clipIds.length:void 0,"data-arrangement-clip-ids":e.arrangementStyle?e.arrangementStyle.clipIds.join(" "):void 0,"data-arrangement-boundary":null!==(g=e.arrangementStyle)&&void 0!==g&&g.boundaryNote?"true":void 0,role:e.clickable?"button":void 0,tabIndex:e.clickable?0:void 0,style:y,onClick:e.clickable?k:void 0,onKeyDown:e.clickable?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),k(e))}:void 0,title:[e.clickable?"Play from this word":null,(null===(x=e.arrangementStyle)||void 0===x?void 0:x.boundaryNote)||null,...e.presenceCursors.map(e=>"".concat(e.label," is ").concat(e.isPlaying?"playing here":"paused here"))].filter(Boolean).join(" \xb7 ")||void 0,children:[o(e),e.presenceCursors.map((e,t)=>(0,u.jsx)("span",{className:"pointer-events-none absolute top-0 w-px",style:{left:"".concat(Math.min(92,12+14*t),"%"),height:"100%",backgroundColor:e.color,opacity:e.isPlaying?.92:.55,boxShadow:"0 0 5px ".concat(e.color)},"aria-hidden":"true"},e.id)),e.isCurrentWord&&(0,u.jsx)("span",{className:WT})]},t)},p=(e,t)=>{const n=(e=>{const t=D[e.arrangementIndex],n=D[e.arrangementIndex+1];if(!t||!n)return;const a=new Set(n.clips.filter(e=>e.opensHere).map(e=>e.range.clipId)),r=new Set(n.clips.filter(e=>!e.opensHere).map(e=>e.range.clipId)),s=t.clips.filter(e=>!e.closesHere&&r.has(e.range.clipId)&&!a.has(e.range.clipId));if(0===s.length)return;const{shared:i,shadows:o}=C(s);return d(d({},i),{},{boxShadow:o.join(", ")})})(e);return(0,u.jsx)("span",{style:n?d(d({},n),{},{display:"inline-block",whiteSpace:"pre"}):void 0,children:e.text},t)},g=[];for(let t=0;t<a.length;t+=1){const e=a[t];
2if("space"===e.kind){g.push(p(e,"space-".concat(e.key)));continue}if(!e.annotationStyle.isClip){g.push(m(e,"word-".concat(e.actualWordIndex)));const t=F.get(e.actualWordIndex)||[];t.length>0&&g.push((0,u.jsx)("span",{style:{display:"inline-flex",alignItems:"center",flexWrap:"wrap",gap:"0.22rem"},children:t.map((t,n)=>(0,u.jsxs)("span",{style:s,title:"Generated pause trim: ".concat(t.duration.toFixed(2),"s"),children:[(0,u.jsx)("span",{"aria-hidden":"true",children:"\u2702"}),(0,u.jsxs)("span",{children:[t.duration.toFixed(1),"s"]})]},"gap-marker-".concat(e.actualWordIndex,"-").concat(n)))},"gap-markers-".concat(e.actualWordIndex)));continue}const n=[e];let i=t+1;for(;i<a.length;){const e=a[i];if("word"===e.kind&&!e.annotationStyle.isClip)break;n.push(e),i+=1}for(;n.length>0&&"space"===n[n.length-1].kind;)n.pop();g.push((0,u.jsx)("span",{style:r,children:n.map(e=>"space"===e.kind?p(e,"clip-space-".concat(e.key)):m(e,"clip-word-".concat(e.actualWordIndex),!0))},"clip-".concat(e.actualWordIndex)));const o=F.get(e.actualWordIndex)||[];o.length>0&&g.push((0,u.jsx)("span",{style:{display:"inline-flex",alignItems:"center",flexWrap:"wrap",gap:"0.22rem"},children:o.map((t,n)=>(0,u.jsxs)("span",{style:s,title:"Generated pause trim: ".concat(t.duration.toFixed(2),"s"),children:[(0,u.jsx)("span",{"aria-hidden":"true",children:"\u2702"}),(0,u.jsxs)("span",{children:[t.duration.toFixed(1),"s"]})]},"clip-gap-marker-".concat(e.actualWordIndex,"-").concat(n)))},"clip-gap-markers-".concat(e.actualWordIndex))),t=i-1}return g},[t,k,l,c,h,i,S,j,C,D,N,F,v,w,y]);return(0,u.jsx)("div",{className:m,style:{position:"relative",display:"inline-block",width:"100%",lineHeight:"inherit",paddingBottom:"8px"},children:E})},(e,t)=>{const n=e.isActive||t.isActive;return e.text===t.text&&e.isActive===t.isActive&&(!n||e.isPlaying===t.isPlaying)&&e.searchQuery===t.searchQuery&&(!n||e.currentWordIndex===t.currentWordIndex)&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.segmentWords===t.segmentWords&&e.clipRanges===t.clipRanges&&e.editRanges===t.editRanges&&e.arrangementRanges===t.arrangementRanges&&e.arrangementHighlighted===t.arrangementHighlighted&&e.presenceCursors===t.presenceCursors&&e.isDarkMode===t.isDarkMode&&e.selectedWordKeys===t.selectedWordKeys&&Boolean(e.onWordClick)===Boolean(t.onWordClick)}),KT={clips:[],references:[],edits:[],clipRanges:[],editRanges:[],hasAnnotations:!1},XT=[],JT=(e,t)=>{const n=e.trim(),a=Math.max(0,Math.min(1,t));if(n.startsWith("#")){const t=n.slice(1),r=3===t.length?t.split("").map(e=>e+e).join(""):t,s=parseInt(r.slice(0,2),16),i=parseInt(r.slice(2,4),16),o=parseInt(r.slice(4,6),16);return[s,i,o].some(e=>Number.isNaN(e))?e:"rgba(".concat(s,", ").concat(i,", ").concat(o,", ").concat(a,")")}const r=n.match(/^rgb\(\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\s*\)$/i);if(r){const[,e,t,n]=r;return"rgba(".concat(e,", ").concat(t,", ").concat(n,", ").concat(a,")")}const s=n.match(/^rgba\(\s*([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*[\d.]+\s*\)$/i);if(s){const[,e,t,n]=s;return"rgba(".concat(e,", ").concat(t,", ").concat(n,", ").concat(a,")")}return e},$T=(0,a.memo)(e=>{let{groupIndex:t,segmentIndex:n,segment:r,annotations:s,arrangementMarks:i,segmentComments:o,presenceCursors:l=[],isSegmentActive:c,currentWordIndex:m,wordIndex:h,isPlaybackActive:p,searchQuery:g,selectedWordKeys:x,isDarkMode:f,typographyConfig:b,speakerChipFontSize:y,speakerChipDotSize:v,isCompactTouchLayout:w=!1,getSpeakerColor:k,getReferenceVisualBinding:j,registerSegmentRef:D,registerSearchMatchRef:C,onShowAnnotationPopup:N,onShowCommentPopup:F,onPlaySegment:S,onWordClick:E,onArrangementContextMenu:A,onArrangementClipHover:T,arrangementHoveredClipId:M}=e;const _=(0,a.useMemo)(()=>k(r.speaker),[k,r.speaker]),B=i.length>0,I=i.some(e=>e.placed),P=Boolean(M&&i.some(e=>e.clipId===M)),L=(0,a.useMemo)(()=>i.map(e=>({clipId:e.clipId,label:e.clipCode||e.title||"This clip",start:e.start,end:e.end,placed:e.placed})),[i]),R="".concat(t,"-").concat(n),z="segment-".concat(t,"-").concat(n),O=o.length,U=(0,a.useMemo)(()=>s.references.map(e=>j(e)).filter(Boolean),[s.references,j]),V=U.length,H=U[0],q=l[0]||null,W=(0,a.useCallback)(e=>{D(R,e),C(z,e)},[C,D,z,R]),Y=(0,a.useCallback)(()=>{T&&T(1===i.length?i[0]:null)},[i,T]);return(0,u.jsxs)("div",{ref:W,"data-testid":"transcript-segment-".concat(t,"-").concat(n),className:"relative overflow-hidden ".concat(w?"rounded-xl px-2 py-2":"rounded-2xl px-3 py-3"," ").concat(f?"bg-[#111b2a
2]":"bg-[rgba(255,255,255,0.96)]"," ").concat(c?"shadow-[0_0_0_1px_rgba(255,181,43,0.16),0_14px_28px_-26px_rgba(255,181,43,0.24)]":""),style:d({backgroundImage:q?"linear-gradient(90deg, ".concat(JT(q.color,f?.16:.11),", transparent 34%)"):"none",backdropFilter:"none",contain:"paint"},B?{boxShadow:"inset 2px 0 0 0 ".concat(I?f?"rgba(255,181,43,0.55)":"rgba(198,133,12,0.45)":f?"rgba(148,163,184,0.45)":"rgba(100,116,139,0.35)")}:{}),onContextMenu:A?e=>A(e,r.timestampSeconds,r.endTimestampSeconds,i):void 0,onMouseEnter:T?Y:void 0,onMouseLeave:T?()=>T(null):void 0,children:[l.map((e,t)=>(0,u.jsx)("span",{className:"pointer-events-none absolute inset-y-0 z-10 w-0.5",style:{left:"".concat(2*t,"px"),backgroundColor:e.color,opacity:e.isPlaying?.9:.5},title:"".concat(e.label," \xb7 ").concat(e.isPlaying?"playing":"paused")},e.id)),(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsx)("div",{className:"min-w-0 flex-1",children:(0,u.jsxs)("div",{className:"inline-flex items-center rounded-full border font-semibold uppercase ".concat(w?"gap-1 px-1.5 py-0.5 tracking-[0.09em]":"gap-2 px-2.5 py-1 text-[11px] tracking-[0.14em]"," ").concat(f?"text-[#F4F4F4]":""),style:{color:f?"#F4F4F4":_,backgroundColor:JT(_,f?.24:.12),borderColor:JT(_,f?.45:.28),fontSize:"".concat(y,"px")},children:[(0,u.jsx)("span",{className:"rounded-full",style:{backgroundColor:_,width:"".concat(v,"px"),height:"".concat(v,"px")}}),(0,u.jsx)("span",{className:"truncate",children:r.speaker})]})}),(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[l.length>0&&(0,u.jsx)("div",{className:"flex -space-x-1","data-testid":"transcript-presence-cursors","aria-label":"".concat(l.length," collaborator").concat(1===l.length?"":"s"," at this segment"),children:l.slice(0,4).map(e=>(0,u.jsx)(rE,{glyph:e.glyph,color:e.color,label:"".concat(e.label," \xb7 ").concat(e.isPlaying?"playing":"paused"),picture:e.picture,isAnonymous:e.isAnonymous,initials:e.initials,size:24,isPlaying:e.isPlaying,isFollowing:e.isFollowing,className:e.isPlaying?"":"opacity-70"},e.id))}),s.references.length>0&&(0,u.jsxs)("button",{onClick:()=>{N(t,n,"references")},className:"group relative inline-flex items-center gap-1 rounded-full px-2 py-1 text-[11px] font-medium transition-colors ".concat(V>0?f?"bg-[#4b3913]/60 text-[#ffe09b] hover:bg-[#5a4417]":"bg-[#fff1cc] text-[#6e4d0e] hover:bg-[#ffe4a3]":f?"bg-slate-700 text-slate-200 hover:bg-slate-600":"bg-slate-100 text-slate-700 hover:bg-slate-200"),title:"".concat(s.references.length," reference").concat(s.references.length>1?"s":""),children:[V>0&&(0,u.jsx)(Cp,{size:11}),s.references.length," ref",(null===H||void 0===H?void 0:H.previewImageUrl)&&(0,u.jsxs)("div",{className:"pointer-events-none absolute right-0 top-full z-20 mt-2 hidden w-44 overflow-hidden rounded-2xl border border-[rgba(215,222,233,0.82)] bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.08),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.42),rgba(255,255,255,0.4))] shadow-[0_18px_40px_-28px_rgba(15,23,36,0.32)] backdrop-blur-[24px] group-hover:block dark:border-white/10 dark:bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.08),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.44),rgba(17,27,42,0.42))] dark:shadow-[0_18px_40px_-28px_rgba(0,0,0,0.82)] dark:backdrop-blur-[28px]",children:[(0,u.jsx)("img",{src:H.previewImageUrl,alt:H.attachmentLabel||"Attached session visual preview",className:"h-24 w-full object-cover",loading:"lazy"}),(0,u.jsxs)("div",{className:"px-2.5 py-2 text-left text-[10px] font-semibold uppercase tracking-[0.16em] text-[#8a6115] dark:text-[#ffcf74]",children:[H.assetCount," attached asset",1===H.assetCount?"":"s"]})]})]}),O>0&&(0,u.jsxs)("button",{onClick:e=>{F(o,e.currentTarget,r.timestampSeconds)},className:"inline-flex items-center gap-1 rounded-full bg-[#fff1cc] px-2 py-1 text-[11px] font-medium text-[#6e4d0e] transition-colors hover:bg-[#ffe4a3] dark:bg-[#4b3913]/60 dark:text-[#ffe09b] dark:hover:bg-[#5a4417]",title:"".concat(O," comment").concat(O>1?"s":""),children:[(0,u.jsx)(ky,{size:11}),O]}),B&&(0,u.jsx)("span",{"data-testid":"transcript-arrangement-marks","data-clip-count":i.length,className:"inline-flex items-center gap-1",title:i.length>1?"".concat(i.length," clips of this cut overlap here. ")+"Overlaps are allowed \u2014 the intro montage is made of them. Right-click for the options of each.":void 0,children:i.map(e=>(0,u.jsxs)("span",{"data-testid":"transcript-arrangement-mark-".concat(e.clipId),title:"".concat(e.title," \u2014 ").concat(e.placed?"in the cut":"associated but not placed",". ")+"The underlined words are the part of it that falls in this segment. Right-click for clip options.",onMouseEnter:T?()=>T(e):void 0,className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium tracking-[0.06em] ".concat(e.placed?f?"text-[#ffd88a]/70":"text-[#8a6115]/75":f?"text-gray-500":"text-gray-400"),children:[(0,u.jsx)("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:e.placed?f?"rgba(255,181,43,0.7)":"rgba(198,133,12,0.6)":"transparent",border:e.placed?"none":"1px solid ".concat(f?"rgba(148,163,184,0.6)":"rgba(100,116,139,0.5)")}
2}),e.clipCode||"clip"]},e.clipId))}),r.timestamp&&(0,u.jsxs)("button",{onClick:()=>{S(t,n,r.timestampSeconds,r.endTimestampSeconds)},className:"inline-flex items-center gap-1 rounded-full font-medium transition-colors ".concat(w?"px-1.5 py-0.5 text-[9px]":"px-2 py-1 text-[11px]"," ").concat(f?"bg-gray-800 text-gray-300 hover:bg-gray-700":"bg-white/80 text-gray-600 hover:bg-white"),title:"Play from segment start",children:[(0,u.jsx)(wp,{size:11}),r.timestamp]})]})]}),(0,u.jsx)("div",{className:"text-gray-700 dark:text-gray-200",style:{fontSize:"".concat(b.fontSize,"px"),lineHeight:b.lineHeight,textAlign:b.textAlign},children:(0,u.jsx)(GT,{text:r.text,startTime:r.timestampSeconds,endTime:r.endTimestampSeconds,currentWordIndex:m,segmentWords:r.words||[],wordIndex:h,isActive:c,isPlaying:p,className:"mt-2 block",searchQuery:g,selectedWordKeys:x,clipRanges:s.clipRanges,editRanges:s.editRanges,arrangementRanges:L,arrangementHighlighted:P,presenceCursors:l,isDarkMode:f,onWordClick:E})})]})},(e,t)=>{const n=e.isSegmentActive||t.isSegmentActive,a=e.presenceCursors||[],r=t.presenceCursors||[],s=a.length===r.length&&a.every((e,t)=>{const n=r[t];return n&&e.id===n.id&&e.time===n.time&&e.isPlaying===n.isPlaying&&e.isFollowing===n.isFollowing});return e.segment===t.segment&&e.annotations===t.annotations&&e.arrangementMarks===t.arrangementMarks&&e.segmentComments===t.segmentComments&&s&&e.isSegmentActive===t.isSegmentActive&&(!n||e.currentWordIndex===t.currentWordIndex)&&(!n||e.isPlaybackActive===t.isPlaybackActive)&&e.searchQuery===t.searchQuery&&e.selectedWordKeys===t.selectedWordKeys&&e.isDarkMode===t.isDarkMode&&e.typographyConfig===t.typographyConfig&&e.speakerChipFontSize===t.speakerChipFontSize&&e.speakerChipDotSize===t.speakerChipDotSize&&e.isCompactTouchLayout===t.isCompactTouchLayout&&(0===e.arrangementMarks.length&&0===t.arrangementMarks.length||e.arrangementHoveredClipId===t.arrangementHoveredClipId)}),QT=Mo("align-left",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]),ZT=Mo("align-justify",[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]),eM={fontFamily:"inter",fontSize:16,lineHeight:1.7,textAlign:"left",maxWidth:"wide"},tM={system:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',inter:'Inter, "Helvetica Neue", Helvetica, Arial, sans-serif',merriweather:'"Merriweather", Georgia, Cambria, "Times New Roman", Times, serif',serif:'"Merriweather", Georgia, Cambria, "Times New Roman", Times, serif',sans:'Inter, "Helvetica Neue", Helvetica, Arial, sans-serif',mono:'"SF Mono", "Fira Code", Consolas, Monaco, monospace'},nM={narrow:"580px",medium:"720px",wide:"900px",full:"100%"},aM="rescript-typography-settings",rM=()=>{try{const e=localStorage.getItem(aM);if(e)return d(d({},eM),JSON.parse(e))}catch(BH){console.warn("[Typography] Failed to load settings:",BH)}return eM},sM=e=>{try{localStorage.setItem(aM,JSON.stringify(e))}catch(BH){console.warn("[Typography] Failed to save settings:",BH)}},iM=e=>{let{config:t,onChange:n,isOpen:r,onClose:s,anchorRef:i}=e;const{isDarkMode:o}=zu(),[l,c]=(0,a.useState)(t.fontSize),[m,h]=(0,a.useState)(t.lineHeight);(0,a.useEffect)(()=>{c(t.fontSize)},[t.fontSize]),(0,a.useEffect)(()=>{h(t.lineHeight)},[t.lineHeight]);const p=(0,a.useCallback)(e=>{const a=d(d({},t),e);n(a),sM(a)},[t,n]),g=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l;e!==t.fontSize&&p({fontSize:e})},[t.fontSize,l,p]),x=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;e!==t.lineHeight&&p({lineHeight:e})},[t.lineHeight,m,p]);if(!r)return null;return(0,u.jsxs)(CD,{isOpen:r,onClose:s,anchorRef:i||{current:null},align:"end",offset:8,className:"w-80 rounded-xl shadow-2xl border overflow-hidden ".concat(o?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b ".concat(o?"border-gray-700":"border-gray-100"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(_w,{size:18,className:o?"text-gray-300":"text-gray-600"}),(0,u.jsx)("span",{className:"font-medium ".concat(o?"text-gray-200":"text-gray-800"),children:"Reading Settings"})]}),(0,u.jsx)("button",{onClick:s,className:"p-1 rounded-lg transition-colors ".concat(o?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-500"),children:(0,u.jsx)(Pu,{size:16})})]}),(0,u.jsxs)("div",{className:"p-4 space-y-5",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium mb-2 uppercase tracking-wide ".concat(o?"text-gray-400":"text-gray-500"),children:"Font"}),(0,u.jsx)("div",{className:"grid grid-cols-4 gap-2",children:[{value:"system",label:"System",preview:"Aa"},{value:"inter",label:"Inter",preview:"Aa"},{value:"merriweather",label:"Merri",preview:"Aa"},{value:"mono",label:"Mono",preview:"Aa"}].map(e=>(0,u.jsxs)("button",{onClick:()=>p({fontFamily:e.value}),className:"flex flex-col items-center py-2 px-1 rounded-lg border transition-all ".concat(t.fontFamily===e.value?o?"border-blue-500 bg-blue-500/10 text-blue-400":"border-blue-500 bg-blue-50 text-blue-600":o?"border-gray-700 hover:border-gray-600 text-gray-400":"border-gray-200 hover:border-gray-300 text-gray-600"),children:[(0,u.jsx)("span",{className:"text-lg font-medium mb-0.5",style:{fontFamily:tM[e.value]},children:e.preview}),(0,u.jsx)("span",{className:"text-[10px]",children:e.label})]},e.value))})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide ".concat(o?"text-gray-400":"text-gray-500"),children:"Size"}),(0,u.jsxs)("span",{className:"text-xs ".concat(o?"text-gray-500":"text-gray-400"),children:[l,"px"]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("button",{onClick:()=>{const e=Math.max(12,l-1);c(e),g(e)},disabled:l<=12,className:"p-2 rounded-lg transition-colors ".concat(l<=12?"opacity-40 cursor-not-allowed":o?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-600"),children:(0,u.jsx)(JE,{size:16})}),(0,u.jsx)("div",{className:"flex-1 relative",children:(0,u.jsx)("input",{type:"range",min:12,max:24,value:l,onCh
2ange:e=>c(parseInt(e.target.value,10)),onMouseUp:()=>g(),onTouchEnd:()=>g(),onKeyUp:()=>g(),onBlur:()=>g(),className:"w-full h-2 rounded-full appearance-none cursor-pointer accent-blue-500",style:{background:o?"linear-gradient(to right, #3b82f6 0%, #3b82f6 ".concat((l-12)/12*100,"%, #374151 ").concat((l-12)/12*100,"%, #374151 100%)"):"linear-gradient(to right, #3b82f6 0%, #3b82f6 ".concat((l-12)/12*100,"%, #e5e7eb ").concat((l-12)/12*100,"%, #e5e7eb 100%)")}})}),(0,u.jsx)("button",{onClick:()=>{const e=Math.min(24,l+1);c(e),g(e)},disabled:l>=24,className:"p-2 rounded-lg transition-colors ".concat(l>=24?"opacity-40 cursor-not-allowed":o?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-600"),children:(0,u.jsx)(ik,{size:16})})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsx)("label",{className:"text-xs font-medium uppercase tracking-wide ".concat(o?"text-gray-400":"text-gray-500"),children:"Line Spacing"}),(0,u.jsx)("span",{className:"text-xs ".concat(o?"text-gray-500":"text-gray-400"),children:m.toFixed(1)})]}),(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("button",{onClick:()=>{const e=Math.max(1.2,+(m-.1).toFixed(1));h(e),x(e)},disabled:m<=1.2,className:"p-2 rounded-lg transition-colors ".concat(m<=1.2?"opacity-40 cursor-not-allowed":o?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-600"),children:(0,u.jsx)(JE,{size:16})}),(0,u.jsx)("div",{className:"flex-1 relative",children:(0,u.jsx)("input",{type:"range",min:1.2,max:2.4,step:.1,value:m,onChange:e=>h(parseFloat(e.target.value)),onMouseUp:()=>x(),onTouchEnd:()=>x(),onKeyUp:()=>x(),onBlur:()=>x(),className:"w-full h-2 rounded-full appearance-none cursor-pointer accent-blue-500",style:{background:o?"linear-gradient(to right, #3b82f6 0%, #3b82f6 ".concat((m-1.2)/1.2*100,"%, #374151 ").concat((m-1.2)/1.2*100,"%, #374151 100%)"):"linear-gradient(to right, #3b82f6 0%, #3b82f6 ".concat((m-1.2)/1.2*100,"%, #e5e7eb ").concat((m-1.2)/1.2*100,"%, #e5e7eb 100%)")}})}),(0,u.jsx)("button",{onClick:()=>{const e=Math.min(2.4,+(m+.1).toFixed(1));h(e),x(e)},disabled:m>=2.4,className:"p-2 rounded-lg transition-colors ".concat(m>=2.4?"opacity-40 cursor-not-allowed":o?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-600"),children:(0,u.jsx)(ik,{size:16})})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium mb-2 uppercase tracking-wide ".concat(o?"text-gray-400":"text-gray-500"),children:"Width"}),(0,u.jsx)("div",{className:"grid grid-cols-4 gap-2",children:[{value:"narrow",label:"Narrow"},{value:"medium",label:"Medium"},{value:"wide",label:"Wide"},{value:"full",label:"Full"}].map(e=>(0,u.jsx)("button",{onClick:()=>p({maxWidth:e.value}),className:"py-2 px-1 rounded-lg border text-xs transition-all ".concat(t.maxWidth===e.value?o?"border-blue-500 bg-blue-500/10 text-blue-400":"border-blue-500 bg-blue-50 text-blue-600":o?"border-gray-700 hover:border-gray-600 text-gray-400":"border-gray-200 hover:border-gray-300 text-gray-600"),children:e.label},e.value))})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-medium mb-2 uppercase tracking-wide ".concat(o?"text-gray-400":"text-gray-500"),children:"Alignment"}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,u.jsxs)("button",{onClick:()=>p({textAlign:"left"}),className:"flex items-center justify-center gap-2 py-2 rounded-lg border transition-all ".concat("left"===t.textAlign?o?"border-blue-500 bg-blue-500/10 text-blue-400":"border-blue-500 bg-blue-50 text-blue-600":o?"border-gray-700 hover:border-gray-600 text-gray-400":"border-gray-200 hover:border-gray-300 text-gray-600"),children:[(0,u.jsx)(QT,{size:16}),(0,u.jsx)("span",{className:"text-xs",children:"Left"})]}),(0,u.jsxs)("button",{onClick:()=>p({textAlign:"justify"}),className:"flex items-center justify-center gap-2 py-2 rounded-lg border transition-all ".concat("justify"===t.textAlign?o?"border-blue-500 bg-blue-500/10 text-blue-400":"border-blue-500 bg-blue-50 text-blue-600":o?"border-gray-700 hover:border-gray-600 text-gray-400":"border-gray-200 hover:border-gray-300 text-gray-600"),children:[(0,u.jsx)(ZT,{size:16}),(0,u.jsx)("span",{className:"text-xs",children:"Justify"})]})]})]}),(0,u.jsx)("button",{onClick:()=>{n(eM),sM(eM)},className:"w-full py-2 text-xs rounded-lg transition-colors ".concat(o?"text-gray-400 hover:bg-gray-700":"text-gray-500 hover:bg-gray-100"),children:"Reset to defaults"})]}),(0,u.jsx)("style",{children:'\n @keyframes fadeIn {\n from { opacity: 0; transform: translateY(-8px); }\n to { opacity: 1; transform: translateY(0); }\n }\n input[type="range"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n width: 16px;\n height: 16px;\n border-radius: 50%;\n background: #3b82f6;\n cursor: pointer;\n border: 2px solid white;\n box-shadow: 0 1px 3px rgba(0,0,0,0.2);\n }\n input[type="range"]::-moz-range-thumb {\n width: 16px;\n height: 16px;\n border-radius: 50%;\n background: #3b82f6;\n cursor: pointer;\n border: 2px solid white;\n box-shadow: 0 1px 3px rgba(0,0,0,0.2);\n }\n '})]})}
2,oM={category:/^category:\s*/i,context:/^context:\s*/i,visual:/^visual(?:\s+suggestion)?:\s*/i};function lM(e){const t=String(e||"").replace(/<br\s*\/?>/gi,"\n"),n=gE(t,!0).split("\n").map(e=>e.trim()).filter(Boolean);if(0===n.length)return{title:gE(e).substring(0,50)};const a=n[0],r=a.match(/\[REF\]\s*([^|\n]+?)(?:\s*\|\s*([^|\n]+?)\s*\|\s*(https?:\/\/[^\s<>\n]+))?$/);let s,i,o=a.replace(/^\[REF\]\s*/i,"").trim();var l,c;r&&(o=r[1].trim(),i=null===(l=r[2])||void 0===l?void 0:l.trim(),s=null===(c=r[3])||void 0===c?void 0:c.trim());const d=t.match(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/);var u,m;!s&&d&&(i=(null===(u=d[1])||void 0===u?void 0:u.trim())||i,s=null===(m=d[2])||void 0===m?void 0:m.trim());if(!s){const e=t.match(/https?:\/\/[^\s<>\n]+/);var h;if(e)s=null===(h=e[0])||void 0===h?void 0:h.trim()}const p=n.find(e=>oM.category.test(e)),g=n.find(e=>oM.context.test(e)),x=n.find(e=>oM.visual.test(e)),f=n.slice(1).filter(e=>!oM.category.test(e)&&!oM.context.test(e)&&!oM.visual.test(e)&&!/^https?:\/\//i.test(e)&&!/^\[[^\]]+\]\(https?:\/\/[^)]+\)$/i.test(e));return{title:o,category:p?p.replace(oM.category,"").trim()||void 0:f[0]||void 0,context:g?g.replace(oM.context,"").trim()||void 0:f[1]||void 0,url:s,linkText:i,visualSuggestion:x?x.replace(oM.visual,"").trim()||void 0:f[2]||void 0}}const cM="";function dM(e){return"".concat(e.start,"|").concat(e.end,"|").concat(e.utteranceIndex,"|").concat(e.wordIndex)}function uM(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:84;const a=e.replace(/\s+/g," ").trim();if(!a)return"";const r=a.split(" ").slice(0,t).join(" ");return r.length<=n?r:"".concat(r.slice(0,Math.max(0,n-1)).trim(),"\u2026")}function mM(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:88;const a=e.replace(/\s+/g," ").trim();if(!a)return"";const r=a.split(" ");if(r.length<=2*t)return uM(a,r.length,n);const s=r.slice(0,t).join(" "),i=r.slice(-t).join(" "),o="".concat(s," \u2026 ").concat(i);return o.length<=n?o:"".concat(o.slice(0,Math.max(0,n-1)).trim(),"\u2026")}function hM(e){var t,n;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("undefined"===typeof window)return{left:e.left,top:e.bottom};const r=null!==(t=a.width)&&void 0!==t?t:320,s=null!==(n=a.height)&&void 0!==n?n:360,i=16;let o=e.left+e.width/2-r/2,l=e.bottom+12;return o<i?o=i:o+r>window.innerWidth-i&&(o=Math.max(i,window.innerWidth-r-i)),l+s>window.innerHeight-i&&(l=e.top-s-12),l<i&&(l=Math.max(i,Math.min(e.bottom+12,window.innerHeight-s-i))),{left:o,top:l}}const pM=e=>{var t,n,r,s;let{ttmlContent:i,transcript:o,filename:l,transcriptionData:c,speakerLabels:m,sessionVisuals:h=null,audioFile:p,transcriptionChecksum:g,sessionId:x,isModal:f=!1,onClose:b,onPlaySegment:y,onPauseSegment:v,showChat:w=!0,comments:k=[],isFullscreenTab:j=!1,selectedTtmlId:D=null,searchQuery:C="",searchMatches:N=[],currentMatchIndex:F=0,onSearchUpdate:E,shouldNavigateToMatch:A=!1,onNavigationComplete:T,onCurrentTopicChange:M,onTtmlRevisionCreated:_,showVideoPanel:B=!1,typographyConfig:I=eM,transcriptChromeCollapsed:P=!1,onTranscriptChromeCollapsedChange:L}=e;const{token:R}=am(),{permissions:z,shareToken:O}=Hp(),{currentTime:U,isPlaying:V,seekTo:H,play:q}=Jw(),{transcriptCursors:W,setActiveArea:Y}=nE(),{isDarkMode:G}=zu(),{autoScrollEnabled:K}=(()=>{const e=(0,a.useContext)(MT);if(!e)throw new Error("useAutoScroll must be used within an AutoScrollProvider");return e})(),{timelineViewportRange:X,setTranscriptSelectionRange:J,cursorSyncEnabled:$,setCursorSyncEnabled:Q,syncRequestId:Z,syncRequestTargetTime:ee,requestCursorSync:te}=wk(),ne=!1,ae=null;(0,a.useEffect)(()=>(Y("readable-transcript"),()=>Y("session")),[Y]);const re=Ww(),se=!!z,ie="undefined"===typeof navigator||navigator.onLine,oe=!!x&&!!O&&!(null===z||void 0===z||!z.commentsWrite)&&ie,le=!!x&&(!!R&&!se||oe),ce=Boolean(x&&D&&R&&!se),de=Boolean(x&&D&&R&&!se),ue=P,[me,he]=(0,a.useState)(()=>"undefined"!==typeof window?window.innerWidth:1440),pe=re.isMobile||me<770,ge=pe||ue;(0,a.useEffect)(()=>
2{if("undefined"===typeof window)return;const e=()=>{var e;const t=null===(e=Ee.current)||void 0===e?void 0:e.clientWidth;he(t||window.innerWidth)};e();const t="undefined"!==typeof ResizeObserver?new ResizeObserver(()=>e()):null;return t&&Ee.current&&t.observe(Ee.current),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),null===t||void 0===t||t.disconnect()}},[]);const[xe,fe]=(0,a.useState)(new Set),[be,ye]=(0,a.useState)(null),[ve,we]=(0,a.useState)(null),[ke,je]=(0,a.useState)(null),[De,Ce]=(0,a.useState)(0),[Ne,Fe]=(0,a.useState)(!1),Se=(0,a.useRef)({}),Ee=(0,a.useRef)(null),Ae=(0,a.useRef)(!1),[Te,Me]=(0,a.useState)(void 0),_e=(0,a.useRef)(null),Be=(0,a.useRef)(null),Ie=(0,a.useRef)(!1),Pe=(0,a.useRef)(0),Le=(0,a.useRef)(0),Re=(0,a.useRef)(0),ze=(0,a.useRef)(null),[Oe,Ue]=(0,a.useState)(null),[Ve,He]=(0,a.useState)(null),[qe,We]=(0,a.useState)([]),[Ye,Ge]=(0,a.useState)(null),[Ke,Xe]=(0,a.useState)(null),[Je,$e]=(0,a.useState)(!1),[Qe,Ze]=(0,a.useState)({title:"",clipType:"Key Insight",description:"",visual:""}),[et,tt]=(0,a.useState)({title:"",suggestion:"",improvement:"",priority:"medium"}),[nt,at]=(0,a.useState)(!1),[rt,st]=(0,a.useState)({title:"",description:""}),[it,ot]=(0,a.useState)(null),[lt,ct]=(0,a.useState)(!1),[dt,ut]=(0,a.useState)(!1),[mt,ht]=(0,a.useState)(null),[pt,gt]=(0,a.useState)(!1),[,xt]=(0,a.useState)(""),[ft,bt]=(0,a.useState)({available:!1,isBlob:!1}),yt=(0,a.useRef)({}),[vt,wt]=(0,a.useState)(null),[kt,jt]=(0,a.useState)(!1),[Dt,Ct]=(0,a.useState)(null),Nt=!1,Ft=(0,a.useRef)(0),St=(0,a.useRef)(null),Et=(0,a.useRef)(E);Et.current=E;const[At,Tt]=(0,a.useState)(i);(0,a.useEffect)(()=>{Tt(i)},[i]);const[Mt,_t]=(0,a.useState)(!1),[Bt,It]=(0,a.useState)([]),[Pt,Lt]=(0,a.useState)(""),[Rt,zt]=(0,a.useState)(null),[Ot,Ut]=(0,a.useState)([]),[Vt,Ht]=(0,a.useState)(!0),qt=(0,a.useRef)({}),[Wt,Yt]=(0,a.useState)([]),Gt=(0,a.useCallback)(e=>{const t=new Map,n=[];return e.forEach(e=>{var n,a;const r=d(d({},e),{},{userEmail:e.userEmail||e.user_email||"Anonymous",userName:e.userName||e.user_name||e.displayName||"Anonymous",timestamp:e.timestamp||e.createdAt||e.created_at||e.updatedAt||e.updated_at||(new Date).toISOString(),timestampSeconds:null!==(n=e.timestampSeconds)&&void 0!==n?n:e.timestamp_seconds,parentCommentId:null!==(a=e.parentCommentId)&&void 0!==a?a:e.parent_comment_id,replies:[]});t.set(r.id,r)}),e.forEach(e=>{var a;const r=t.get(e.id),s=null!==(a=e.parentCommentId)&&void 0!==a?a:e.parent_comment_id;if(s&&t.has(s)){const e=t.get(s);e&&(e.replies=e.replies||[],e.replies.push(r))}else n.push(r)}),n},[]);(0,a.useEffect)(()=>{(async()=>{if(x&&R&&!se)try{const e=await fetch("".concat(cM,"/api/sessions/").concat(x,"/comments"),{headers:{Authorization:"Bearer ".concat(R)}});if(e.ok){const t=await e.json(),n=Gt(t.comments||[]);Ut(n)}}catch(e){console.error("Failed to load comments:",e)}})()},[se,x,R,Gt]),(0,a.useEffect)(()=>{const e=Gt(k||[]);Ut(e)},[k,Gt]);const Kt=(0,a.useCallback)(()=>{if("undefined"===typeof window)return null;let e=window.localStorage.getItem("anonymousSessionId");return e||(e="".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,11)),window.localStorage.setItem("anonymousSessionId",e)),e},[]),Xt=(0,a.useCallback)(async()=>{if(!x)return null;let e=null;if(se&&O?e=await fetch("".concat(cM,"/api/public/share/").concat(O,"/comments")):R&&(e=await fetch("".concat(cM,"/api/sessions/").concat(x,"/comments"),{headers:{Authorization:"Bearer ".concat(R)}})),!e||!e.ok)throw new Error("Failed to refresh comments");const t=await e.json(),n=Gt(t.comments||[]);return Ut(n),n},[se,Gt,x,O,R]);(0,a.useEffect)(()=>{R&&Mt&&(async()=>{try{const e=(await Op.getOpenRouterModels(R)).models.map(e=>e.id);if(It(e),e.length>0){const t=Rp.getSelectedModel();if(t&&e.includes(t))Lt(t);else{const t=e.find(e=>"anthropic/claude-sonnet-4"===e)||e[0];Lt(t)}}}catch(e){console.error("Failed to load supported models for chat:",e);try{const e=await Op.getSupportedModels(R);if(It(e),e.length>0){const t=Rp.getSelectedModel();if(t&&e.includes(t))Lt(t);else{const t=e.find(e=>"anthropic/claude-sonnet-4"===e)||e[0];Lt(t)}}}catch(t){console.error("Failed to load models from fallback endpoint:",t)}}})()},[R,Mt]),(0,a.useEffect)(()=>{Pt&&Rp.setSelectedModel(Pt)},[Pt]);const Jt=(0,a.useCallback)(e=>{if(!e)return 0;const t=e.split(/[:.]/);if(t.length<3||t.length>4)return 0;return 3600*(parseInt(t[0],10)||0)+60*(parseInt(t[1],10)||0)+(parseInt(t[2],10)||0)+(4===t.length&&parseInt(t[3],10)||0)/1e3},[]),$t=(0,a.useCallback)(e=>{try{const t=(new DOMParser).parseFromString(e,"application/xml"),n=(e,t)=>{let n=e.querySelectorAll(t);if(0===n.length){const n=e.getElementsByTagNameNS("*",t);return Array.from(n)}return Array.from(n)};
2let a=Array.from(t.querySelectorAll('div[region="r_summary"] p'));if(zw("TTML-PARSE","Found paragraphs with region selector:",a.length),0===a.length){const e=n(t,"div");zw("TTML-PARSE","Found",e.length,"div elements, checking for d_summary");let r=null;for(const t of e){if("d_summary"===t.getAttribute("xml:id")){r=t;break}}zw("TTML-PARSE","Found summary div with getAttribute:",!!r),r&&(a=n(r,"p"),zw("TTML-PARSE","Found paragraphs in summary div:",a.length))}const r=[];return a.forEach((e,t)=>{const n=e.getAttribute("begin")||"",a=e.getAttribute("end")||"";let s=e.innerHTML;const i=document.createElement("div");i.innerHTML=s;const o=i.textContent||"";zw("TTML-PARSE","Paragraph ".concat(t,":"),{begin:n,end:a,htmlContentSample:s.substring(0,100),decodedContentSample:o.substring(0,100)});const l=s.match(/\[(\d+):\s*(\d+|\?)\/(\d+)\]\s*(?:&gt;&gt;|>>|>>)\s*\[([^\]]+)\]/)||o.match(/\[(\d+):\s*(\d+|\?)\/(\d+)\]\s*>>\s*\[([^\]]+)\]/),c=l?null:s.match(/\[(\d+)\/(\d+)\]\s*(?:&gt;&gt;|>>|>>)\s*\[([^\]]+)\]/)||o.match(/\[(\d+)\/(\d+)\]\s*>>\s*\[([^\]]+)\]/);if(l||c){const e=l||c;zw("TTML-PARSE","Found ".concat(l?"standard":"fallback"," match for paragraph ").concat(t,":"),e[0]);const i=l?parseInt(l[1],10):t+1,d=l?parseInt(l[2],10)||0:parseInt(c[1],10),u=l?parseInt(l[3],10)||0:parseInt(c[2],10),m=l?l[4].trim():c[3].trim();let h=5,p=10;const g=o.match(/Score:\s*\[(\d+)\/(\d+)\]/)||o.match(/Score:\s*(\d+)\/(\d+)/);g&&(h=parseInt(g[1],10),p=parseInt(g[2],10)),r.push({start:n,end:a,segmentNumber:i,rank:h,total:p,title:gE(m),content:gE(s.replace(/<br\s*\/?>/gi,"\n")),ranking:Math.min(10,Math.max(1,Math.ceil(h/p*10))),positionRank:d,positionTotal:u})}}),r.sort((e,t)=>Jt(e.start)-Jt(t.start)),r}catch(t){return console.error("Error parsing TTML content:",t),[]}},[Jt]),Qt=e=>lM(e),Zt=e=>{let t=gE(e.replace(/<br\s*\/?>/gi,"\n"),!0).replace(/\[EDIT\]\s*/g,"").trim();if(t.includes("|")){const e=t.split("|").map(e=>e.trim());return{title:e[0]||void 0,priority:e[1]||void 0,suggestion:e[2]||"",improvement:e[3]||void 0}}t=t.replace(/(?=Suggestion:|Improvement:|Priority:|Note:)/g,"\n");const n=t.split("\n").map(e=>e.trim()).filter(e=>e.length>0);if(0===n.length)return{suggestion:t.trim()};let a,r,s,i,o="";for(const l of n)if(l.startsWith("Suggestion:")){const e=l.replace("Suggestion:","").trim();o?r||(r=e):o=e}else l.startsWith("Improvement:")?r=l.replace("Improvement:","").trim():l.startsWith("Priority:")?s=l.replace("Priority:","").trim():l.startsWith("Note:")?i=l.replace("Note:","").trim():a||o?o||(o=l):a=l;return!o&&a&&(o=a,a=void 0),{title:a,suggestion:o,improvement:r,priority:s,note:i}},en=(0,a.useCallback)(e=>{const t=e.split(":").map(parseFloat);return 3===t.length?3600*t[0]+60*t[1]+t[2]:2===t.length?60*t[0]+t[1]:parseFloat(e)||0},[]),tn=(0,a.useMemo)(()=>$t(At),[At,$t]),{clips:nn,references:an,edits:rn}=(0,a.useMemo)(()=>(e=>{const t=[],n=[],a=[];try{const r=(new DOMParser).parseFromString(e,"application/xml");
2let s=r.querySelectorAll('div[region="r_clip"] p, div[region="r_clips"] p');if(0===s.length){const e=r.querySelector('div[xml\\:id="d_clip"], div[id="d_clip"]');e&&(s=e.querySelectorAll("p"))}s.forEach(e=>{const n=e.textContent||e.innerHTML,a=e.getAttribute("begin"),r=e.getAttribute("end");if(n&&n.includes("[CLIP]")&&a&&r){const e=n.match(/\[CLIP\]\s*(.+)$/);e&&t.push({start:a,end:r,title:e[1].trim(),content:n})}});let i=r.querySelectorAll('div[region="r_references"] p, div[region="r_reference"] p');if(0===i.length){const e=r.querySelector('div[xml\\:id="d_references"], div[id="d_references"]');e&&(i=e.querySelectorAll("p"))}i.forEach(e=>{const t=e.textContent||e.innerHTML,a=e.getAttribute("begin"),r=e.getAttribute("end");if(t&&t.includes("[REF]")&&a&&r){const e=t.match(/\[REF\]\s*(.+)$/);e&&n.push({start:a,end:r,title:e[1].trim(),content:t})}});let o=r.querySelectorAll('div[region="r_edit"] p, div[region="r_edits"] p');if(0===o.length){const e=r.querySelector('div[xml\\:id="d_edit"], div[id="d_edit"]');e&&(o=e.querySelectorAll("p"))}if(o.forEach(e=>{const t=e.textContent||e.innerHTML,n=e.getAttribute("begin"),r=e.getAttribute("end");if(t&&t.includes("[EDIT]")&&n&&r){const e=t.match(/\[EDIT\]\s*(.+)$/);e&&a.push({start:n,end:r,title:e[1].trim(),content:t})}}),0===t.length){const n=e.match(/<p[^>]*begin="([^"]*)"[^>]*end="([^"]*)"[^>]*>[^<]*\[CLIP\][^<]*<\/p>/g);n&&n.forEach(e=>{const n=e.match(/begin="([^"]*)"/),a=e.match(/end="([^"]*)"/),r=e.match(/\[CLIP\]\s*([^<]*)/);n&&a&&r&&t.push({start:n[1],end:a[1],title:r[1].trim(),content:e})})}if(0===n.length){const t=e.match(/<p[^>]*begin="([^"]*)"[^>]*end="([^"]*)"[^>]*>[^<]*\[REF\][^<]*<\/p>/g);t&&t.forEach(e=>{const t=e.match(/begin="([^"]*)"/),a=e.match(/end="([^"]*)"/),r=e.match(/\[REF\]\s*([^<]*)/);t&&a&&r&&n.push({start:t[1],end:a[1],title:r[1].trim(),content:e})})}if(0===a.length){const t=e.match(/<p[^>]*begin="([^"]*)"[^>]*end="([^"]*)"[^>]*>[^<]*\[EDIT\][^<]*<\/p>/g);t&&t.forEach(e=>{const t=e.match(/begin="([^"]*)"/),n=e.match(/end="([^"]*)"/),r=e.match(/\[EDIT\]\s*([^<]*)/);t&&n&&r&&a.push({start:t[1],end:n[1],title:r[1].trim(),content:e})})}}catch(r){console.error("Error extracting TTML annotations:",r)}return{clips:t,references:n,edits:a}})(At),[At]),sn=(0,a.useMemo)(()=>tn.map(e=>d(d({},e),{},{startSeconds:Jt(e.start),endSeconds:Jt(e.end)})),[Jt,tn]),on=(0,a.useMemo)(()=>nn.map(e=>d(d({},e),{},{startSeconds:Jt(e.start),endSeconds:Jt(e.end)})),[nn,Jt]),ln=(0,a.useMemo)(()=>an.map(e=>d(d({},e),{},{startSeconds:Jt(e.start)})),[an,Jt]),cn=(0,a.useMemo)(()=>rn.map(e=>d(d({},e),{},{startSeconds:Jt(e.start),endSeconds:Jt(e.end)})),[rn,Jt]),dn=(0,a.useMemo)(()=>{var e,t,n,a;if(null===c||void 0===c||!c.results)return[];if(Array.isArray(c.results.utterances)&&c.results.utterances.length>0)return c.results.utterances.flatMap((e,t)=>(e.words||[]).filter(e=>{var t;return"number"===typeof e.start&&"number"===typeof e.end&&!(null===(t=e.word)||void 0===t||!t.trim())}).map((n,a)=>({word:n.punctuated_word||n.word,start:n.start,end:n.end,speaker:"number"===typeof n.speaker?n.speaker:"number"===typeof e.speaker?e.speaker:0,utteranceIndex:t,wordIndex:a})));return((null===(e=c.results.channels)||void 0===e||null===(t=e[0])||void 0===t||null===(n=t.alternatives)||void 0===n||null===(a=n[0])||void 0===a?void 0:a.words)||[]).filter(e=>{var t;return"number"===typeof e.start&&"number"===typeof e.end&&!(null===(t=e.word)||void 0===t||!t.trim())}).map((e,t)=>({word:e.punctuated_word||e.word,start:e.start,end:e.end,speaker:"number"===typeof e.speaker?e.speaker:0,utteranceIndex:0,wordIndex:t}))},[c]),un=dn,mn=qF(),{menu:hn,closeMenu:pn,handleSegmentContextMenu:gn,handleArrangementClipHover:xn}=IT(),fn=null!==(t=null===mn||void 0===mn?void 0:mn.enabled)&&void 0!==t&&t,bn=null!==(n=null===mn||void 0===mn?void 0:mn.detail)&&void 0!==n?n:null,yn=null===mn||void 0===mn?void 0:mn.clips,vn=null!==(r=null===mn||void 0===mn?void 0:mn.trimDraft)&&void 0!==r?r:null,wn=(0,a.useMemo)(()=>fn&&bn&&yn?yn.map(e=>{const t=(null===vn||void 0===vn?void 0:vn.clipId)===e.id?vn:null;return{clipId:e.id,clipCode:e.clipCode,title:e.title||e.speaker,placed:e.placed,start:t?t.start:e.startTime,end:t?t.end:e.endTime}}).sort((e,t)=>
2e.start-t.start||e.end-t.end):PT,[yn,bn,fn,vn]),kn=(0,a.useCallback)((e,t)=>{const n=on.filter(n=>e<n.endSeconds&&t>n.startSeconds),a=ln.filter(n=>e<=n.startSeconds&&t>=n.startSeconds),r=cn.filter(n=>e<n.endSeconds&&t>n.startSeconds),s=n.map(e=>({start:e.startSeconds,end:e.endSeconds})),i=r.map(e=>({start:e.startSeconds,end:e.endSeconds}));return{clips:n,references:a,edits:r,clipRanges:s,editRanges:i,hasAnnotations:n.length>0||a.length>0||r.length>0}},[on,cn,ln]),jn=(0,a.useCallback)(e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return"".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"))},[]),Dn=(0,a.useCallback)(()=>{var e;(He(null),We([]),Ge(null),Xe(null),$e(!1),"undefined"!==typeof window)&&(null===(e=window.getSelection())||void 0===e||e.removeAllRanges())},[]),Cn=(0,a.useCallback)(()=>{var e;if(!de||"undefined"===typeof window)return He(null),We([]),Ge(null),void Xe(null);const t=window.getSelection(),n=Ee.current;if(!t||0===t.rangeCount||t.isCollapsed||!n)return He(null),We([]),Ge(null),void Xe(null);const a=t.getRangeAt(0);if(!n.contains(a.commonAncestorContainer))return He(null),We([]),Ge(null),void Xe(null);const r=Array.from(n.querySelectorAll('[data-transcript-word="true"][data-word-start][data-word-end]')).filter(e=>{try{return a.intersectsNode(e)}catch(_H){return!1}});if(!r.length)return He(null),Ge(null),void Xe(null);const s=r.map(e=>({start:Number(e.dataset.wordStart),end:Number(e.dataset.wordEnd),key:String(e.dataset.wordKey||""),text:String(e.dataset.wordText||e.textContent||"").trim()})).filter(e=>Number.isFinite(e.start)&&Number.isFinite(e.end)&&e.text);if(!s.length)return He(null),We([]),Ge(null),void Xe(null);const i=a.getBoundingClientRect(),o=uM(s.map(e=>e.text).join(" ")),l=s.map(e=>e.text).join(" ").replace(/\s+/g," ").trim(),c=s.map(e=>e.key).filter(Boolean);He({text:l,previewText:mM(l),selectedWordKeys:c,startTime:s[0].start,endTime:s[s.length-1].end,position:hM(i)}),We(c),Ge(null),Xe(null),Ze({title:o||"Selected clip",clipType:"Key Insight",description:l,visual:""}),tt({title:o?"Tighten: ".concat(o):"Transcript edit",suggestion:l,improvement:"",priority:"medium"}),null===(e=window.getSelection())||void 0===e||e.removeAllRanges()},[de]);(0,a.useEffect)(()=>{J(Ve?{start:Ve.startTime,end:Ve.endTime}:null)},[Ve,J]),(0,a.useEffect)(()=>{if(!Ve)return;const e=e=>{var t;const n=e.target instanceof Node?e.target:null;n&&null!==(t=St.current)&&void 0!==t&&t.contains(n)||(He(null),We([]),Ge(null),Xe(null))},t=e=>{"Escape"!==e.key||Je||Dn()},n=Ee.current,a=()=>{He(null),We([]),Ge(null),Xe(null)};return window.addEventListener("pointerdown",e),window.addEventListener("keydown",t),null===n||void 0===n||n.addEventListener("scroll",a,{passive:!0}),()=>{window.removeEventListener("pointerdown",e),window.removeEventListener("keydown",t),null===n||void 0===n||n.removeEventListener("scroll",a)}},[Dn,Je,Ve]);const Nn=(0,a.useCallback)(()=>{if(0===dn.length)return[];const e=[];let t=null;for(const a of dn){var n;if(void 0===a.speaker||null===(n=a.word)||void 0===n||!n.trim())continue;const r=a.word,s=(a.start+a.end)/2,i=sn.findIndex(e=>s>=e.startSeconds&&s<=e.endSeconds),o=!t||t.speaker!==a.speaker||t.topicIndex!==i;if(t&&!o)t.words.push(r),t.timedWords.push(a),t.end=a.end;else{if(t&&t.words.length>0){const n=(null===m||void 0===m?void 0:m[t.speaker])||"Speaker ".concat(t.speaker),a=jn(t.start);e.push({speaker:n,text:t.words.join(" "),timestamp:a,timestampSeconds:t.start,endTimestampSeconds:t.end,words:t.timedWords})}t={speaker:a.speaker,words:[r],timedWords:[a],topicIndex:i,start:a.start,end:a.end}}}if(t&&t.words.length>0){const n=(null===m||void 0===m?void 0:m[t.speaker])||"Speaker ".concat(t.speaker),a=jn(t.start);e.push({speaker:n,text:t.words.join(" "),timestamp:a,timestampSeconds:t.start,endTimestampSeconds:t.end,words:t.timedWords})}return e},[jn,m,sn,dn]),Fn=(0,a.useMemo)(()=>{let e=Ne?De:U;if(!(V||Ne)||!e||0===un.length)return-1;let t=0,n=un.length-1,a=-1;for(;t<=n;){const r=Math.floor((t+n)/2),s=un[r];if(e>=s.start&&e<=s.end){a=r;break}e<s.start?n=r-1:t=r+1}return-1===a&&(a=t<=0?-1:t>=un.length?un.length-1:t-1),a},[U,V,un,Ne,De,ne,ae]);function Sn(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return t>0?"".concat(t,"h ").concat(n,"m ").concat(a,"s"):n>0?"".concat(n,"m ").concat(a,"s"):"".concat(a,"s")}const En=e=>{const t=Number.isFinite(e)?Math.max(0,e):0,n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=M
2ath.floor(t%60);return n>0?"".concat(n,":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0")):"".concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"))},An=(0,a.useCallback)(e=>function(e){const t=String(e||"").replace(/<br\s*\/?>/gi,"\n"),n=t.match(/Justification:\s*([\s\S]*?)(?:\n(?:Optimal Placement:|Continuity:|Score:)|Optimal Placement:|Continuity:|$)/i),a=n?n[1]:t;return gE(String(a||"").replace(/Optimal Placement:.*$/i,"").replace(/Continuity:.*$/i,""))||null}(e.content),[]),Tn=(0,a.useCallback)(e=>{H(e),te(e)},[te,H]),Mn=async(e,t,n,a)=>{if(y){if((null===be||void 0===be?void 0:be.groupIndex)===e&&(null===be||void 0===be?void 0:be.segmentIndex)===t)return ye(null),void(v&&v());y(n,a),ye({groupIndex:e,segmentIndex:t});return void setTimeout(()=>{ye(null)},1e3*(a-n))}try{if(ve&&(ve.pause(),ve.currentTime=0),(null===be||void 0===be?void 0:be.groupIndex)===e&&(null===be||void 0===be?void 0:be.segmentIndex)===t)return ye(null),we(null),Fe(!1),void Ce(0);if(!p&&!g)return;let r;if(!g)return zw("[AUDIO] No transcription checksum available for audio playback"),void bt({available:!1,isBlob:!1,error:"No audio source available"});zw("[AUDIO] Using direct audio URL for checksum: ".concat(g)),r="/api/audio/".concat(g,"/original"),bt({available:!0,isBlob:!1,url:r});const s=new Audio(r);s.currentTime=n,ye({groupIndex:e,segmentIndex:t}),we(s),Fe(!0),s.addEventListener("loadeddata",()=>{s.play(),Fe(!0)}),s.addEventListener("error",async e=>{if(console.error("[AUDIO] Error playing audio",e),g&&!p)try{const t=await fetch("".concat(cM,"/api/audio/").concat(g,"/original"),{method:"HEAD",headers:R?{Authorization:"Bearer ".concat(R)}:{}});if(!t.ok&&404===t.status)try{const e=await fetch("".concat(cM,"/api/audio/").concat(g,"/original"),{headers:R?{Authorization:"Bearer ".concat(R)}:{}});if((await e.json().catch(()=>({}))).isOrphan)return gt(!0),xt("Audio file is missing from this session. Please upload the original audio file to enable playback."),bt(e=>d(d({},e),{},{error:"Audio file missing - orphan session detected"})),ye(null),void we(null)}catch(e){zw("[AUDIO] Could not check orphan status")}}catch(e){zw("[AUDIO] Could not test audio URL")}bt(e=>d(d({},e),{},{error:"Audio playback failed"})),ye(null),we(null),r.startsWith("blob:")&&URL.revokeObjectURL(r)}),s.addEventListener("ended",()=>{ye(null),we(null),Fe(!1),Ce(0),r.startsWith("blob:")&&URL.revokeObjectURL(r)}),s.addEventListener("timeupdate",()=>{Ce(s.currentTime),s.currentTime>=a&&(s.pause(),ye(null),we(null),Fe(!1),Ce(0),URL.revokeObjectURL(r))})}catch(r){console.error("Error playing audio segment:",r),ye(null),we(null)}},_n=(0,a.useMemo)(()=>Nn(),[Nn]),Bn=(0,a.useCallback)(()=>{const e=[];if(0===tn.length)return e.push({topic:{start:"00:00:00",end:"99:99:99",rank:1,total:1,segmentNumber:1,title:"Full Transcript",content:"",ranking:5},segments:_n}),e;for(const t of tn)e.push({topic:t,segments:[]});for(const t of _n){if(!t.timestamp)continue;const n=t.timestampSeconds,a=t.endTimestampSeconds,r=(n+a)/2;let s=-1,i=-1;for(let e=0;e<sn.length;e++){const t=sn[e],o=t.startSeconds,l=t.endSeconds,c=Math.max(n,o),d=Math.min(a,l),u=Math.max(0,d-c),m=a-n,h=m>0?u/m:0,p=Math.abs(r-o),g=Math.abs(r-l),x=Math.min(p,g),f=30;let b=0;b=h>0?1e3+100*h:r>=o-f&&r<=l+f?500-x:100-x,b>i&&(i=b,s=e)}s>=0?e[s].segments.push(t):e[0].segments.push(t)}return e},[sn,tn,_n]),{showGradient:In,mode:Pn,retentionMode:Ln,retentionData:Rn}=tF(),zn=(0,a.useCallback)(e=>{let t=e.rank||0,n=e.total||10;if("overall"===Pn)t=e.rank||0,n=e.total||10;else if("substance"===Pn){const a=e.content.match(/S:\s*(\d+)\/(\d+)/);a&&(t=parseInt(a[1]),n=parseInt(a[2]))}else if("resonance"===Pn){const a=e.content.match(/R:\s*(\d+)\/(\d+)/);a&&(t=parseInt(a[1]),n=parseInt(a[2]))}else if("clarity"===Pn){const a=e.content.match(/C:\s*(\d+)\/(\d+)/);a&&(t=parseInt(a[1]),n=parseInt(a[2]))}else if("production"===Pn){const a=e.content.match(/P:\s*(\d+)\/(\d+)/);a&&(t=parseInt(a[1]),n=parseInt(a[2]))}else if("creative_risk"===Pn){const a=e.content.match(/CR:\s*(\d+)\/(\d+)/);a&&(t=parseInt(a[1]),n=parseInt(a[2]))}return{score:t,maxScore:n,ratio:n>0?t/n:0}},[Pn]),On=(0,a.useMemo)(()=>{var e;const t=Number(null===c||void 0===c||null===(e=c.metadata)||void 0===e?void 0:e.duration);return Number.isFinite(t)&&t>0?t:tn.reduce((e,t)=>
2{const n=Jt(t.end);return n>e?n:e},0)},[c,Jt,tn]),Un=(0,a.useCallback)(e=>{var t;if(null===Rn||void 0===Rn||null===(t=Rn.retentionData)||void 0===t||!t.length)return null;if("off"===Ln||"drops"===Ln)return null;const n=(Jt(e.start)+Jt(e.end))/2,a=Rn.videoDurationSeconds||On;if(0===a)return null;let r=Rn.retentionData[0],s=1/0;for(const i of Rn.retentionData){const e=void 0!==i.timestampSeconds?i.timestampSeconds:i.ratio*a,t=Math.abs(e-n);t<s&&(s=t,r=i)}switch(Ln){case"absolute":return r.absoluteRetention/100;case"adjusted":return r.relativeRetention*Math.sqrt(r.absoluteRetention/100);default:return r.relativeRetention}},[Rn,Ln,Jt,On]),Vn=(0,a.useCallback)(e=>{var t;const n=e=>Math.max(0,Math.min(1,e));if(null===Rn||void 0===Rn||null===(t=Rn.retentionData)||void 0===t||!t.length)return n(e);const a=Rn.retentionData;if("relative"===Ln){const t=.5,n=a.map(e=>{var t;return null!==(t=e.relativeRetention)&&void 0!==t?t:.5}),r=Math.min(...n),s=Math.max(...n);if(e>=t){const n=s-t;return n>.001?.4+(e-t)/n*.6:.5}{const n=t-r;return n>.001?(e-r)/n*.4:.3}}if("adjusted"===Ln){const t=a.reduce((e,t)=>{var n;return e+(null!==(n=t.absoluteRetention)&&void 0!==n?n:50)/100},0)/a.length,n=.5*Math.sqrt(t),r=a.map(e=>{var t,n;const a=null!==(t=e.relativeRetention)&&void 0!==t?t:.5,r=(null!==(n=e.absoluteRetention)&&void 0!==n?n:50)/100;return a*Math.sqrt(r)}),s=Math.min(...r),i=Math.max(...r);if(e>=n){const t=i-n;return t>.001?.4+(e-n)/t*.6:.5}{const t=n-s;return t>.001?(e-s)/t*.4:.3}}{const t=a.map(e=>{var t;return(null!==(t=e.absoluteRetention)&&void 0!==t?t:50)/100}),r=Math.min(...t),s=Math.max(...t)-r;return s>.001?n((e-r)/s):.5}},[Ln,Rn]),Hn=(0,a.useCallback)(function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("off"!==Ln&&"drops"!==Ln&&null!==Rn&&void 0!==Rn&&null!==(t=Rn.retentionData)&&void 0!==t&&t.length){const t=Un(e);if(null!==t)return function(e){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return arguments.length>
21&&void 0!==arguments[1]&&!arguments[1]?e>=.67?t?"bg-green-100 dark:bg-green-900 border-green-300 dark:border-green-700 text-green-800 dark:text-green-200":"bg-green-100 dark:bg-green-900/30 border-green-300 dark:border-green-700/50 text-green-800 dark:text-green-200":e>=.33?t?"bg-yellow-100 dark:bg-yellow-900 border-yellow-300 dark:border-yellow-700 text-yellow-800 dark:text-yellow-200":"bg-yellow-100 dark:bg-yellow-900/30 border-yellow-300 dark:border-yellow-700/50 text-yellow-800 dark:text-yellow-200":t?"bg-red-100 dark:bg-red-900 border-red-300 dark:border-red-700 text-red-800 dark:text-red-200":"bg-red-100 dark:bg-red-900/30 border-red-300 dark:border-red-700/50 text-red-800 dark:text-red-200":e>=.8?t?"bg-green-100 dark:bg-green-900 border-green-300 dark:border-green-700 text-green-800 dark:text-green-200":"bg-green-100 dark:bg-green-900/30 border-green-300 dark:border-green-700/50 text-green-800 dark:text-green-200":e>=.6?t?"bg-lime-100 dark:bg-lime-900 border-lime-300 dark:border-lime-700 text-lime-800 dark:text-lime-200":"bg-lime-100 dark:bg-lime-900/30 border-lime-300 dark:border-lime-700/50 text-lime-800 dark:text-lime-200":e>=.4?t?"bg-yellow-100 dark:bg-yellow-900 border-yellow-300 dark:border-yellow-700 text-yellow-800 dark:text-yellow-200":"bg-yellow-100 dark:bg-yellow-900/30 border-yellow-300 dark:border-yellow-700/50 text-yellow-800 dark:text-yellow-200":e>=.2?t?"bg-orange-100 dark:bg-orange-900 border-orange-300 dark:border-orange-700 text-orange-800 dark:text-orange-200":"bg-orange-100 dark:bg-orange-900/30 border-orange-300 dark:border-orange-700/50 text-orange-800 dark:text-orange-200":t?"bg-red-100 dark:bg-red-900 border-red-300 dark:border-red-700 text-red-800 dark:text-red-200":"bg-red-100 dark:bg-red-900/30 border-red-300 dark:border-red-700/50 text-red-800 dark:text-red-200"}(Vn(t),In,n)}const{ratio:a}=zn(e);let r="";return r=In?a>=.8?n?"bg-[rgba(232,237,242,0.46)] dark:bg-[#232E3F]/40 border-[#b7c4d3]/60 dark:border-[#41526a]/70 text-[#232E3F] dark:text-[#F4F4F4]":"bg-[#e8edf2] dark:bg-[#232E3F]/40 border-[#b7c4d3] dark:border-[#41526a]/60 text-[#232E3F] dark:text-[#F4F4F4]":a>=.6?n?"bg-[rgba(255,243,214,0.44)] dark:bg-[#4b3913]/40 border-[#f0cf85]/68 dark:border-[#8a6115]/78 text-[#7a560c] dark:text-[#ffe09b]":"bg-[#fff3d6] dark:bg-[#4b3913]/35 border-[#f0cf85] dark:border-[#8a6115]/70 text-[#7a560c] dark:text-[#ffe09b]":a>=.4?n?"bg-[rgba(254,249,195,0.42)] dark:bg-yellow-900/42 border-yellow-300/62 dark:border-yellow-700/82 text-yellow-800 dark:text-yellow-200":"bg-yellow-100 dark:bg-yellow-900/30 border-yellow-300 dark:border-yellow-700/50 text-yellow-800 dark:text-yellow-200":a>=.2?n?"bg-[rgba(255,237,213,0.44)] dark:bg-orange-900/42 border-orange-300/64 dark:border-orange-700/82 text-orange-800 dark:text-orange-200":"bg-orange-100 dark:bg-orange-900/30 border-orange-300 dark:border-orange-700/50 text-orange-800 dark:text-orange-200":n?"bg-[rgba(254,226,226,0.44)] dark:bg-red-900/40 border-red-300/64 dark:border-red-700/82 text-red-800 dark:text-red-200":"bg-red-100 dark:bg-red-900/30 border-red-300 dark:border-red-700/50 text-red-800 dark:text-red-200":a>=.67?n?"bg-[rgba(232,237,242,0.46)] dark:bg-[#232E3F]/40 border-[#b7c4d3]/60 dark:border-[#41526a]/70 text-[#232E3F] dark:text-[#F4F4F4]":"bg-[#e8edf2] dark:bg-[#232E3F]/40 border-[#b7c4d3] dark:border-[#41526a]/60 text-[#232E3F] dark:text-[#F4F4F4]":a>=.33?n?"bg-[rgba(254,249,195,0.42)] dark:bg-yellow-900/42 border-yellow-300/62 dark:border-yellow-700/82 text-yellow-800 dark:text-yellow-200":"bg-yellow-100 dark:bg-yellow-900/30 border-yellow-300 dark:border-yellow-700/50 text-yellow-800 dark:text-yellow-200":n?"bg-[rgba(254,226,226,0.44)] dark:bg-red-900/40 border-red-300/64 dark:border-red-700/82 text-red-800 dark:text-red-200":"bg-red-100 dark:bg-red-900/30 border-red-300 dark:border-red-700/50 text-red-800 dark:text-red-200",r},[In,Ln,Rn,Un,Vn,zn]),qn="".concat(Pn,"-").concat(Ln,"-").concat(In),Wn=(0,a.useCallback)(e=>{let t;if(m)for(const[n,a]of Object.entries(m))if(a===e){t=parseInt(n);break}if(void 0===t){const n=e.match(/Speaker (\d+)/);if(n)t=parseInt(n[1]);else{let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n&=n;t=Math.abs(n)}}return mp(t,G)},[G,m]),Yn=(0,a.useCallback)(e=>{fe(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Gn=(0,a.useMemo)(()=>Bn(),[Bn]),Kn=K&&$,Xn=(0,a.useMemo)(()=>Gn,[Gn,ne,Jt,ae]),Jn=(0,a.useMemo)(()=>{const e=new Map;return Xn.forEach((t,n)=>
2{t.segments.forEach((t,a)=>{(t.words||[]).forEach(t=>{e.set(dM(t),{groupIndex:n,segmentIndex:a})})})}),e},[Xn]),$n=(0,a.useCallback)(()=>{const e=Ee.current;if(!e||0===Xn.length)return void wt(null);const t=re.isMobile?72:48,n=e.scrollTop;let a=0;for(let r=0;r<Xn.length;r+=1){const e=yt.current[r];if(e){if(!(e.offsetTop-n<=t))break;a=r}}wt(e=>e===a?e:a)},[Xn,re.isMobile]),Qn=(0,a.useMemo)(()=>{if(Kn&&ke)return ke.groupIndex;if(null!==vt)return vt;const e=Ne?De:U;if(!Number.isFinite(e)||0===Xn.length)return null;for(let t=0;t<Xn.length;t+=1){const n=Xn[t].topic,a=Jt(n.start),r=Jt(n.end);if(e>=a&&e<=r)return t}return null},[ke,U,Xn,Ne,De,Kn,Jt,vt]),Zn=null!==Qn?Xn[Qn]:null,ea=Zn?gE(Zn.topic.title)||"Untitled topic":null,ta=Zn?An(Zn.topic):null,na=Boolean(Zn&&(re.isMobile||kt))?Zn:null,aa=na?Math.max(0,Math.min(10,Math.round(na.topic.rank||0))):0,ra=null!==mt&&void 0!==mt?mt:aa,sa=(0,a.useCallback)(()=>{null===L||void 0===L||L(!ue)},[ue,L]),ia=(0,a.useCallback)(async(e,t)=>{if(!R||!_)return;let n="";try{const t=await Op.downloadCachedTTML(e.checksum,R);n=await t.text()}catch(a){console.warn("[ReadableTranscriptView] Failed to fetch TTML content for new revision:",a)}_({checksum:e.checksum,version:e.version,parentChecksum:e.parentChecksum,rootChecksum:e.rootChecksum,generatedAt:(new Date).toISOString(),model:"manual-edit",revisionNotes:t,editedBy:"user",content:n})},[_,R]),oa=(0,a.useCallback)(async()=>{if(Ve&&Ye&&de&&x&&D&&!Je)try{if(Xe(null),$e(!0),"clip"===Ye){const e=Qe.title.trim();if(!e)return void Xe("Clip title is required");const t="Added clip from transcript selection at ".concat(jn(Ve.startTime),"-").concat(jn(Ve.endTime)),n=await UN.mutateClips(x,D,[{op:"add",data:{title:e,clipType:Qe.clipType.trim()||void 0,description:Qe.description.trim()||void 0,visual:Qe.visual.trim()||void 0,startTime:Ve.startTime,endTime:Ve.endTime}}],t,R||void 0);await ia(n,t)}else{const e=et.title.trim(),t=et.suggestion.trim();if(!e)return void Xe("Edit title is required");if(!t)return void Xe("Edit suggestion is required");const n="Added edit from transcript selection at ".concat(jn(Ve.startTime),"-").concat(jn(Ve.endTime)),a=await UN.mutateEdits(x,D,[{op:"add",data:{title:e,suggestion:t,improvement:et.improvement.trim()||void 0,priority:et.priority.trim()||void 0,startTime:Ve.startTime,endTime:Ve.endTime}}],n,R||void 0);await ia(a,n)}Dn()}catch(e){console.error("[ReadableTranscriptView] Failed to create selection metadata:",e),Xe(e instanceof Error?e.message:"Failed to save selection metadata")}finally{$e(!1)}},[de,Dn,ia,jn,Je,D,Ye,Qe.clipType,Qe.description,Qe.title,Qe.visual,et.improvement,et.priority,et.suggestion,et.title,Ve,x,R]),la=(0,a.useCallback)(()=>{na&&(ot(null),st({title:ea||"",description:ta||""}),at(!0))},[ta,ea,na]),ca=(0,a.useCallback)(async e=>{var t;if(!ce||!x||!D||null===Qn||dt)return;const n=Math.max(1,Math.min(10,Math.round(e))),a="Updated topic ".concat(null!==(t=null===na||void 0===na?void 0:na.topic.segmentNumber)&&void 0!==t?t:Qn+1," rating to ").concat(n,"/10 from transcript sticky header");try{ot(null),ut(!0);const e=await UN.setTopicRatings(x,D,[{index:Qn,score:n}],a,R||void 0);await ia(e,a),ht(null)}catch(r){console.error("[ReadableTranscriptView] Failed to update topic rating:",r),ot(r instanceof Error?r.message:"Failed to update topic rating")}finally{ut(!1)}},[ce,Qn,ia,dt,D,x,na,R]),da=(0,a.useCallback)(async()=>{var e;if(!ce||!x||!D||null===Qn||lt)return;const t=rt.title.trim(),n=rt.description.trim();if(!t)return void ot("Topic title is required");const a="Edited topic ".concat(null!==(e=null===na||void 0===na?void 0:na.topic.segmentNumber)&&void 0!==e?e:Qn+1," from transcript sticky header");try{ot(null),ct(!0);const e=await UN.mutateTopics(x,D,[{op:"update",index:Qn,data:{title:t,justification:n}}],a,R||void 0);await ia(e,a),at(!1)}catch(r){console.error("[ReadableTranscriptView] Failed to edit topic:",r),ot(r instanceof Error?r.message:"Failed to update topic")}finally{ct(!1)}},[ce,Qn,ia,lt,D,x,na,R,rt.description,rt.title]);(0,a.useEffect)(()=>{ht(null),ot(null)},[Qn]);const ua=(0,a.useCallback)((e,t)=>{const n="".concat(e,"-").concat(t),a=Se.current[n];if(!a)return null;return a.querySelector('[data-current-word="true"]')||a},[]),ma=(0,a.useCallback)(e=>{const t=e.getBoundingClientRect();let n=t.top,a=t.bottom;if(re.isCompactTouchLayout&&B){const e=document.querySelector('[data-session-video-panel="true"]');if(e){const a=e.getBoundingClientRect();Math.min(t.right,a.right)-Math.max(t.left,a.left)>48&&(n=Math.max(n,a.bottom+8))}}const r=e.querySelector('[data-sticky-current-topic="true"]');return r&&(n=Math.max(n,r.getBoundingClientRect().bottom+6)),a-n<80?{top:t.top,bottom:t.bottom}:{top:n,bottom:a}},[re.isCompactTouchLayout,B]),ha=(0,a.useCallback)((e,t)=>{const n=Ee.current,a=ua(e,t);if(!n||!a)return!1;const{top:r,bottom:s}=ma(n),i=a.getBoundingClientRect(),o=re.isCompactTouchLayout?18:28,l=r+o,c=l+(Math.max(l+1,s-o)-l)*(re.isCompactTouchLayout?.42:.46),d=n.scrollTop+(i.top-r)+i.height/2-(c-r),u=Math.max(0,n.scrollHeight-n.clientHeight),m=re.isCompactTouchLayout?2600:re.isMobile?2200:re.useSmoothScroll?1400:300;return Pe.current=Date.now()+m,n.scrollTo({top:Math.max(0,Math.min(d,u)),behavior:re.useSmoothScroll?"smooth":"auto"}),!0},[ua,ma,re.isCompactTouchLayout,re.isMobile,re.useSmoothScroll]),pa=(0,a.useCallback)(()=>{Ct(null)},[Xn,Nt,ma]),ga=(0,a.useCallback)((e,t)=>{const n=Ee.current,a=ua(e,t);if(!n||!a)return!1;const{top:r,bottom:s}=ma(n),i=a.getBoundingClientRect(),o=re.isCompactTouchLayout?18:28,l=r+o,c=Math.max(l+1,s-o)-l,d=i.top+i.height/2,u=l+c*(re.isCompactTouchLayout?.24:.28),m=l+c*(re.isCompactTouchLayout?.72:.68);return d<u||d>m},[ua,ma,re.isCompactTouchLayout]);(0,a.useEffect)(()=>{null===M||void 0===M||M(ea)},[ea,M]),(0,a.useEffect)(()=>()=>{null===M||void 0===M||M(null)},[M]);const xa=(0,a.useMemo)(()=>Xn.map(e=>e.segments.map(e=>kn(e.timestampSeconds,e.endTimestampSeconds))),[Xn,kn]),fa=(0,a.useRef)([]),ba=(0,a.useMemo)(()=>{const e=RT(Xn,wn,fa.current);return fa.current=e,e}
2,[wn,Xn]),ya=(0,a.useMemo)(()=>{const e=xa.flatMap(e=>e.flatMap(e=>e.references.map(e=>({id:Em({title:e.title,start:en(e.start),end:en(e.end)}),title:e.title,start:en(e.start),end:en(e.end)}))));return Tm(e,h)},[xa,h,en]),va=(0,a.useCallback)(e=>{var t,n;return ya.get(Em({title:null===e||void 0===e?void 0:e.title,start:null!==(t=null===e||void 0===e?void 0:e.startSeconds)&&void 0!==t?t:en(null===e||void 0===e?void 0:e.start),end:null!==(n=null===e||void 0===e?void 0:e.endSeconds)&&void 0!==n?n:en(null===e||void 0===e?void 0:e.end)}))},[ya,en]),wa=(0,a.useMemo)(()=>{let e=0;for(const t of Xn)e+=t.segments.length;return e},[Xn]),ka=(0,a.useMemo)(()=>wa>900?1:wa>450?2:wa>220?4:Xn.length,[Xn.length,wa]);(0,a.useEffect)(()=>{fe(e=>{const t=new Set;if(e.forEach(e=>{e<Xn.length&&t.add(e)}),t.size>0)return t.size===e.size?e:t;const n=new Set,a=Math.min(Xn.length,ka);for(let r=0;r<a;r+=1)n.add(r);return n})},[ka,Xn]);const ja=(0,a.useCallback)(e=>{if(void 0===e)return"";const t="string"===typeof e?parseInt(e,10):e;return(null===m||void 0===m?void 0:m[t])||"Speaker ".concat(e)},[m]),Da=(0,a.useMemo)(()=>o,[ne,Xn,o,ja]);(0,a.useEffect)(()=>{if(!C||""===C.trim())return Yt([]),Et.current&&Et.current([]),void(ke&&Kn&&setTimeout(()=>{const e="".concat(ke.groupIndex,"-").concat(ke.segmentIndex),t=Se.current[e];t&&(xe.has(ke.groupIndex)?t.scrollIntoView({behavior:"smooth",block:"center"}):(fe(e=>new Set(e).add(ke.groupIndex)),setTimeout(()=>{t.scrollIntoView({behavior:"smooth",block:"center"})},300)))},100));const e=[],t=C.toLowerCase();Xn.forEach((n,a)=>{n.segments.forEach((r,s)=>{const i=r.text.toLowerCase().indexOf(t);if(-1!==i){const o=Math.max(0,i-100),l=Math.min(r.text.length,i+t.length+100),c=r.text.substring(o,l);e.push({groupIndex:a,segmentIndex:s,text:r.text,contextText:c,contextStart:o,matchIndex:i-o,matchLength:t.length,speaker:r.speaker,timestamp:r.timestamp,timestampSeconds:r.timestampSeconds,endTimestampSeconds:r.endTimestampSeconds,topic:n.topic,speakerColor:Wn(r.speaker)})}})}),Yt(e),Et.current&&Et.current(e)},[C,Xn,ke,xe,Wn,Kn]);const Ca=(0,a.useCallback)(()=>{if(!N||0===N.length||F<0)return;const e=N[F];if(!e)return;const t=e.groupIndex;if(xe.has(t)){const t="segment-".concat(e.groupIndex,"-").concat(e.segmentIndex),n=qt.current[t];if(n){const e=-200,t=n.getBoundingClientRect().top+window.pageYOffset+e;window.scrollTo({top:t,behavior:"smooth"}),n.classList.add("search-highlight-animation"),setTimeout(()=>{n.classList.remove("search-highlight-animation")},2e3)}}else fe(e=>new Set(e).add(t)),setTimeout(()=>{const t="segment-".concat(e.groupIndex,"-").concat(e.segmentIndex),n=qt.current[t];if(n){const e=-200,t=n.getBoundingClientRect().top+window.pageYOffset+e;window.scrollTo({top:t,behavior:"smooth"}),n.classList.add("search-highlight-animation"),setTimeout(()=>{n.classList.remove("search-highlight-animation")},2e3)}},300)},[N,F,xe]);(0,a.useEffect)(()=>{A&&N&&N.length>0&&(Ca(),T&&T())},[A,Ca,T,N]);const[Na,Fa]=(0,a.useState)(!1),Sa=(0,a.useCallback)((e,t)=>Ot.filter(n=>!!n.timestampSeconds&&(n.timestampSeconds>=e&&n.timestampSeconds<=t)),[Ot]),Ea=(0,a.useMemo)(()=>Xn.map(e=>Sa(Jt(e.topic.start),Jt(e.topic.end))),[Xn,Sa,Jt]),Aa=(0,a.useMemo)(()=>Xn.map(e=>e.segments.map(e=>Sa(e.timestampSeconds,e.endTimestampSeconds))),[Xn,Sa]);(0,a.useEffect)(()=>{const e=()=>{if(f||j)return void Fa(!0);const e=document.querySelector('[data-tab-id="readable"]'),t=document.querySelector(".readable-transcript-container"),n=(null===e||void 0===e?void 0:e.classList.contains("data-[state=active]"))||"active"===(null===e||void 0===e?void 0:e.getAttribute("data-state"))||t&&null!==t.offsetParent;Fa(n||!1)};e();const t=new MutationObserver(e),n=document.querySelector('[data-tab-id="readable"]');return n&&t.observe(n,{attributes:!0,attributeFilter:["class","data-state"]}),document.addEventListener("visibilitychange",e),()=>{t.disconnect(),document.removeEventListener("visibilitychange",e)}},[f,j]),(0,a.useEffect)(()=>{const e=window.requestAnimationFrame(()=>{const e=Ee.current;if(e){const t=e.scrollTop;Re.current=t,jt(t>12)}$n()});return()=>{window.cancelAnimationFrame(e)}},[ke,Xn,Nt,xe,$n,pa]),(0,a.useEffect)(()=>{const e=Ee.current;if(!e)return;const t=()=>{Kn&&(Pe.current=0,_e.current=null,Ie.current=!1,Q(!1))},n=e=>{Math.abs(e.deltaY)<2&&Math.abs(e.deltaX)<2||(Le.current=Date.now(),t())};let a=null;const r=e=>{var t,n;a=null!==(t=null===(n=e.touches[0])||void 0===n?void 0:n.clientY)&&void 0!==t?t:null},s=e=>{var n,r;const s=null!==(n=null===(r=e.touches[0])||void 0===r?void 0:r.clientY)&&void 0!==n?n:null;null!==a&&null!==s&&Math.abs(s-a)<4||(Le.current=Date.now(),t(),a=s)},i=t=>{t.target instanceof Node&&e.contains(t.target)&&(Le.current=Date.now())},o=()=>{const t=e.scrollTop,n=Math.abs(t-Re.current),a=Date.now()-Le.current<=900;Re.current=t,jt(t>12),$n(),!Ie.current&&Kn&&(Date.now()<Pe.current&&!a||!a&&n<20||(Pe.current=0,_e.current=null,Q(!1)))};return e.addEventListener("wheel",n,{passive:!0}),e.addEventListener("touchstart",r,{passive:!0}),e.addEventListener("touchmove",s,{passive:!0}),e.addEventListener("pointerdown",i,{passive:!0}),e.addEventListener("scroll",o,{passive:!0}),()=>{e.removeEventListener("wheel",n),e.removeEventListener("touchstart",r),e.removeEventListener("touchmove",s),e.removeEventListener("pointerdown",i),e.removeEventListener("scroll",o)}},[Nt,Q,Kn,$n,pa]);const Ta=(0,a.useMemo)(()=>null,[Nt,se,X,R,Dt]);(0,a.useDeferredValue)(Ta);(0,a.useEffect)(()=>{Ae.current=V},[V]),(0,a.useEffect)(()=>{V?Me(U):(Me(void 0),_e.current=null)},[U,V]);const Ma=(0,a.useCallback)(e=>{if(!Number.isFinite(e))return null;const t=Number(e),n=(e,n)=>{if(e>=Xn.length)return!1;const a=Xn[e];if(n>=a.segments.length)return!1;const r=a.segments[n];return t>=r.timestampSeconds&&t<=r.endTimestampSeconds},a=(e,t)=>{if(e>=Xn.length)return null;const n=Xn[e];return t>=n.segments.length?null:n.segments[t]||null};let r=null;const s=ze.current;if(s)if(n(s.groupIndex,s.segmentIndex))r=s;else{const e=(i=s.groupIndex,(o=s.segmentIndex)+1<Xn[i].segments.length?{groupIndex:i,segmentIndex:o+1}:i+1<Xn.length?{groupIndex:i+1,segmentIndex:0}:null);if(e&&n(e.groupIndex,e.segmentIndex))r=e;else if(e){const n=a(s.groupIndex,s.segmentIndex),i=a(e.groupIndex,e.segmentIndex);n&&i&&t>=n.endTimestampSeconds&&t<i.timestampSeconds&&i.timestampSeconds-n.endTimestampSeconds<=2&&(r=s)}}var i,o;if(!r){let e=null,s=null;for(let i=0;i<Xn.length;i++){const o=Xn[i],l=Jt(o.topic.start),c=Jt(o.topic.end);if(t>=l&&t<=c){for(let a=0;a<o.segments.length;a++){if(n(i,a)){r={groupIndex:i,segmentIndex:a};break}const l=o.segments[a];if(l.endTimestampSeconds<=t)e={groupIndex:i,segmentIndex:a};else if(!s&&l.timestampSeconds>t){s={groupIndex:i,segmentIndex:a};break}}if(r)break;
2if(!r&&e&&s){const n=a(e.groupIndex,e.segmentIndex),i=a(s.groupIndex,s.segmentIndex);if(n&&i&&t>=n.endTimestampSeconds&&t<i.timestampSeconds&&i.timestampSeconds-n.endTimestampSeconds<=2){r=e;break}}}}}return r},[Xn,Jt]);(0,a.useEffect)(()=>{if(!V)return;if(void 0===Te||!Na)return;const e=Fn>=0?un[Fn]:null,t=e&&Jn.get(dM(e))||null||Ma(Te);if(t){ze.current=t;if(!ke||ke.groupIndex!==t.groupIndex||ke.segmentIndex!==t.segmentIndex){je(t);const{groupIndex:e}=t;xe.has(e)||fe(t=>new Set(t).add(e))}}else ze.current=null,ke&&je(null)},[Te,V,ke,Fn,xe,Ma,Na,Kn,un,Jn]),(0,a.useEffect)(()=>{if(Be.current&&(clearInterval(Be.current),Be.current=null),!V)return void(Ie.current=!1);if(!Kn||!ke||!Na)return;const e=re.isMobile?1400:re.useSmoothScroll?1e3:250,t=re.isCompactTouchLayout?650:450,n=t=>{var n,a;if(!V||!ke||!Kn||Ie.current)return;const r=(null===(n=_e.current)||void 0===n?void 0:n.groupIndex)===ke.groupIndex&&(null===(a=_e.current)||void 0===a?void 0:a.segmentIndex)===ke.segmentIndex;if(!t&&r)return;if(t&&!ga(ke.groupIndex,ke.segmentIndex))return;const s="".concat(ke.groupIndex,"-").concat(ke.segmentIndex);Se.current[s]&&(Ie.current=!0,window.requestAnimationFrame(()=>{V&&Kn&&(ha(ke.groupIndex,ke.segmentIndex),_e.current=ke),window.setTimeout(()=>{Ie.current=!1},e)}))},a=window.setTimeout(()=>{n(!1)},300);return Be.current=setInterval(()=>{n(!0)},t),()=>{window.clearTimeout(a),Be.current&&(clearInterval(Be.current),Be.current=null)}},[ke,Na,V,re.isCompactTouchLayout,re.isMobile,re.useSmoothScroll,ha,Kn,ga]),(0,a.useEffect)(()=>{if(!Z||Ft.current===Z)return;Ft.current=Z,_e.current=null;const e=Ma(null!==ee&&void 0!==ee?ee:U);if(!e)return;ze.current=e,je(t=>(null===t||void 0===t?void 0:t.groupIndex)===e.groupIndex&&(null===t||void 0===t?void 0:t.segmentIndex)===e.segmentIndex?t:e),fe(t=>{if(t.has(e.groupIndex))return t;const n=new Set(t);return n.add(e.groupIndex),n}),Ie.current=!0;const t=window.requestAnimationFrame(()=>{ha(e.groupIndex,e.segmentIndex)}),n=window.setTimeout(()=>{Ie.current=!1},re.isMobile?1400:re.useSmoothScroll?1e3:250);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n),Ie.current=!1}},[U,Ma,re.isMobile,re.useSmoothScroll,ha,Z,ee]);const _a=re.isMobile?Math.max(9,Math.min(11,Math.round(.55*I.fontSize))):Math.max(11,Math.min(16,Math.round(.72*I.fontSize))),Ba=re.isMobile?Math.max(5,Math.min(7,Math.round(.1*I.fontSize))):Math.max(7,Math.min(10,Math.round(.13*I.fontSize))),Ia=(0,a.useCallback)((e,t)=>{t?Se.current[e]=t:delete Se.current[e]},[]),Pa=(0,a.useCallback)((e,t)=>{t?qt.current[e]=t:delete qt.current[e]},[]),La=(0,a.useCallback)((e,t,n)=>{Ue({groupIndex:e,segmentIndex:t,type:n})},[]),Ra=(0,a.useCallback)((e,t,n)=>{const a=t.getBoundingClientRect();zt({comments:e,position:{x:a.left,y:a.bottom+5},timestampSeconds:n})},[]),za=(0,a.useCallback)(async e=>{H(e),te(e),await q()},[q,te,H]),Oa=(0,a.useCallback)((e,t,n,a)=>{"number"===typeof a&&Mn(e,t,n,a)},[Mn]),Ua=(0,u.jsx)(u.Fragment,{children:(0,u.jsxs)("div",{className:"readable-transcript-container ".concat(f?"":"h-full"," flex overflow-hidden"),children:[w&&(0,u.jsx)(S,{children:Mt&&(0,u.jsx)(Do.div,{initial:{width:0,opacity:0},animate:{width:"400px",opacity:1},exit:{width:0,opacity:0},transition:{duration:.3},className:"border-r border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 rounded-l-xl overflow-hidden",children:(0,u.jsxs)("div",{className:"h-full flex flex-col",children:[(0,u.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)(ky,{size:20,className:"text-[#FFB52B]"}),(0,u.jsx)("h4",{className:"font-medium text-gray-900 dark:text-gray-100",children:"TTML Chat"})]}),(0,u.jsx)("button",{onClick:()=>_t(!1),className:"p-1 text-gray-500 hover:text-gray-700 rounded",children:(0,u.jsx)(dk,{size:18})})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-2 text-sm",children:[(0,u.jsx)("input",{type:"checkbox",id:"include-ttml",checked:Vt,onChange:e=>
2Ht(e.target.checked),className:"w-4 h-4 text-[#232E3F] bg-gray-100 border-gray-300 rounded focus:ring-[#ffcf74] dark:focus:ring-[#ffcf74] dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),(0,u.jsxs)("label",{htmlFor:"include-ttml",className:"text-gray-700 dark:text-gray-300",children:["Include TTML (",l,") in context"]})]})]}),(0,u.jsx)("div",{className:"flex-1 min-h-0",children:Bt.length>0&&Pt?(0,u.jsx)(Pk,{transcript:Da,model:Pt,onModelChange:Lt,supportedModels:Bt,currentTtmlFiles:Vt?[{name:l,content:At}]:[],sessionId:x}):(0,u.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,u.jsx)(Lo,{className:"animate-spin text-gray-400",size:24})})})]})})}),(0,u.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[f&&(ft.error||ft.isBlob||pt)&&(0,u.jsx)("div",{className:"p-4 border-b border-gray-200 bg-amber-50",children:(0,u.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,u.jsx)("div",{className:"flex-shrink-0",children:ft.available?(0,u.jsx)("div",{className:"w-3 h-3 bg-yellow-500 rounded-full"}):(0,u.jsx)("div",{className:"w-3 h-3 bg-red-500 rounded-full"})}),(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsx)("h4",{className:"text-sm font-medium text-amber-800",children:"Audio Status"}),ft.url&&(0,u.jsx)("a",{href:ft.url,download:"audio.m4a",className:"text-xs bg-amber-600 text-white px-2 py-1 rounded hover:bg-amber-700 transition-colors",children:"Download Blob"})]}),(0,u.jsxs)("div",{className:"text-xs text-amber-700 space-y-1",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Available:"})," ",ft.available?"Yes":"No"]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-medium",children:"Type:"})," ",ft.isBlob?"Blob URL (may have range request issues)":p?"Direct File":"None"]}),ft.error&&(0,u.jsxs)("div",{className:"text-red-700",children:[(0,u.jsx)("span",{className:"font-medium",children:"Error:"})," ",ft.error]})]}),((null===(s=ft.error)||void 0===s?void 0:s.includes("range request"))||ft.isBlob)&&!pt&&(0,u.jsx)("div",{className:"mt-2 text-xs text-amber-600",children:"\u26a0\ufe0f Blob URLs don't fully support range requests needed for audio scrubbing. Consider uploading the original audio file for better playback."}),!pt&&x&&g&&l&&(0,u.jsx)("button",{onClick:()=>gt(!0),className:"mt-2 text-xs bg-amber-600 text-white px-3 py-1 rounded hover:bg-amber-700 transition-colors",children:"Upload Original Audio"})]})]})}),f&&pt&&x&&g&&l&&(0,u.jsx)("div",{className:"p-6 border-b border-gray-200 bg-yellow-50",children:(0,u.jsx)(dj,{sessionId:x,filename:l,transcriptionChecksum:g,onRecoverySuccess:()=>{gt(!1),xt(""),bt({available:!1,isBlob:!1}),window.location.reload()},className:"max-w-none"})}),(0,u.jsxs)("div",{ref:Ee,className:"flex-1 overflow-y-auto relative ".concat(re.isMobile?"px-0 pt-0 pb-6":"px-6 pt-0 pb-6"),style:{fontFamily:tM[I.fontFamily],fontSize:"".concat(I.fontSize,"px"),lineHeight:I.lineHeight,textAlign:I.textAlign},onMouseUpCapture:()=>{de&&"undefined"!==typeof window&&window.requestAnimationFrame(()=>{Cn()})},onKeyUpCapture:()=>{de&&"undefined"!==typeof window&&window.requestAnimationFrame(()=>{Cn()})},children:[na&&(0,u.jsx)("div",{className:"sticky top-0 z-30 mb-3 shadow-[0_18px_42px_-30px_rgba(15,23,42,0.22)] backdrop-blur-[32px] ".concat(re.isMobile?"":"-mx-6"," ").concat(Hn(na.topic,!0)),"data-sticky-current-topic":"true",children:(0,u.jsxs)("div",{className:"".concat(pe?"px-3 py-1.5":re.isMobile?"px-3 py-2":"px-6 py-3"," ").concat(j?"pr-24 sm:pr-28 lg:pr-32":""),children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[!ge&&(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] opacity-70",children:"Current Topic"}),(0,u.jsx)("div",{className:"".concat(ge?"truncate text-sm font-semibold leading-tight sm:text-[15px]":"mt-0.5 text-xl font-semibold sm:text-2xl"),children:ea}),!ge&&ta&&(0,u.jsx)("div",{className:"mt-1 line-clamp-2 text-xs leading-snug text-[#5B687C] dark:text-[#CBD2DB]",children:ta})]}),!pe&&!ue&&(0,u.jsx)("div",{className:"flex items-start gap-2 ".concat(j?"mr-2 sm:mr-3":""),children:(0,u.jsxs)("div",{className:"flex max-w-[24rem] items-center justify-end gap-1.5",children:[(0,u.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full border border-current/15 bg-white/40 px-1 py-0.5 dark:bg-[#182130]/45 ".concat(ue?"":"shadow-sm"),children:[(0,u.jsxs)("div",{className:"px-1 text-[10px] font-semibold opacity-85",children:[ra,"/10"]}),(0,u.jsx)("div",{className:"flex items-center gap-0.5",children:Array.from({length:10},(e,t)=>
2{const n=t+1,a=n<=ra,r=dt||lt;return(0,u.jsx)("button",{type:"button",onClick:()=>{ce&&!r&&ca(n)},onMouseEnter:()=>{ce&&!r&&ht(n)},onMouseLeave:()=>{ce&&!r&&ht(null)},disabled:r,className:"inline-flex ".concat("h-5 w-5"," items-center justify-center rounded-full transition ").concat(ce&&!r?"cursor-pointer hover:bg-white/55 dark:hover:bg-[#182130]/50":"cursor-default"," ").concat(r?"opacity-60":""),title:ce?"Set topic rating to ".concat(n,"/10"):"Topic rating ".concat(n,"/10"),"aria-label":ce?"Set topic rating to ".concat(n,"/10"):"Topic rating ".concat(n,"/10"),children:(0,u.jsx)(Dp,{size:12,className:a?"fill-[#FFB52B] text-[#FFB52B]":"fill-transparent text-current/35",strokeWidth:1.9})},"sticky-topic-rating-".concat(n))})})]}),ce&&(0,u.jsx)("button",{type:"button",onClick:la,disabled:lt||dt,className:"inline-flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full border border-current/15 bg-white/50 text-current transition hover:bg-white/80 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-[#182130]/45 dark:hover:bg-[#182130]/70",title:"Edit current topic","aria-label":"Edit current topic",children:(0,u.jsx)(Ro,{size:14})}),!ue&&!j&&(0,u.jsx)("button",{type:"button",onClick:sa,className:"inline-flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-full border border-current/15 bg-white/50 text-current transition hover:bg-white/80 dark:bg-[#182130]/45 dark:hover:bg-[#182130]/70",title:"Collapse transcript chrome","aria-label":"Collapse transcript chrome",children:(0,u.jsx)(wd,{size:15,className:"rotate-180"})})]})}),ue&&!j&&(0,u.jsx)("div",{className:"flex flex-shrink-0 items-start",children:(0,u.jsx)("button",{type:"button",onClick:sa,className:"inline-flex items-center gap-1 rounded-full border border-current/15 bg-white/40 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.16em] opacity-85 transition hover:bg-white/70 dark:bg-[#182130]/45 dark:hover:bg-[#182130]/70",title:"Expand transcript chrome","aria-label":"Expand transcript chrome",children:(0,u.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,u.jsx)("span",{className:"h-0.5 w-3 rounded-full bg-current/60"}),(0,u.jsx)("span",{className:"h-0.5 w-3 rounded-full bg-current/60"})]})})})]}),!ge&&dt&&(0,u.jsxs)("div",{className:"mt-2 inline-flex items-center gap-1 text-[11px] opacity-80",children:[(0,u.jsx)(Lo,{size:12,className:"animate-spin"}),(0,u.jsx)("span",{children:"Saving rating\u2026"})]}),!ge&&it&&ce&&(0,u.jsx)("div",{className:"mt-2 text-[11px] font-medium text-red-700 dark:text-red-300",children:it}),!ge&&!ce&&!se&&!R&&(0,u.jsx)("div",{className:"mt-2 text-[11px] opacity-70",children:"Log in to rerate or edit this topic."})]})}),(0,u.jsxs)("div",{className:"fixed top-4 right-4 flex items-center space-x-2 z-20",children:[w&&!Mt&&(0,u.jsx)("button",{onClick:()=>_t(!0),className:"p-2 bg-white dark:bg-gray-800 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-lg shadow-lg transition-colors",title:"Open TTML Chat",children:(0,u.jsx)(ky,{size:20})}),f&&b&&(0,u.jsx)("button",{onClick:b,className:"p-2 bg-white dark:bg-gray-800 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-lg shadow-lg transition-colors",children:(0,u.jsx)(Pu,{size:20})})]}),!1,(0,u.jsx)("div",{className:re.isMobile?"w-full":"mx-auto w-full",style:{maxWidth:re.isMobile?"100%":nM[I.maxWidth]},children:C&&""!==C.trim()?(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsx)("div",{className:"mb-6 flex items-center justify-between",children:(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)(Mu,{size:20,className:"text-gray-600 dark:text-gray-400"}),(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Search Results"})]}),(0,u.jsxs)("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:["Found ",Wt.length," match",1!==Wt.length?"es":"",' for "',C,'"']})]})}),0===Wt.length?(0,u.jsxs)("div",{className:"text-center py-12 text-gray-500 dark:text-gray-400",children:['No matches found for "',C,'"']}):(0,u.jsx)("div",{className:"space-y-4",children:Wt.map((e,t)=>{const n=e.speakerColor,a=Hn(e.topic,!1);return(0,u.jsxs)("div",{className:"group rounded-lg p-4 shadow-sm transition-all duration-300 cursor-pointer\n hover:shadow-lg bg-white dark:bg-gray-800 relative overflow-hidden",style:{borderColor:G?"rgba(57, 70, 90, 1)":"rgba(216, 222, 231, 1)",borderWidth:"1px",borderStyle:"solid"},onClick:()=>{y&&y(e.timestampSeconds,e.endTimestampSeconds)},children:[(0,u.jsx)("div",{className:"absolute inset-0 opacity-0 group-hover:opacity-5 transition-opacity duration-300",style:{backgroundColor:n}}),(0,u.jsxs)("div",{className:"relative z-10",children:[(0,u.jsx)("div",{className:"-mx-4 -mt-4 mb-3 px-4 py-2 ".concat(a," rounded-t-lg"),children:(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("span",{className:"text-xs font-medium hidden md:inline",children:["Segment ",e.topic.segmentNumber]}),(0,u.jsx)("span",{className:"text-xs truncate",children:gE(e.topic.title)})]})}),(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white font-semibold text-sm",style:{backgroundColor:n},children:e.speaker.charAt(0)}),(0,u.jsx)("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.speaker})]}),(0,u.jsx)("span",{className:"hidden md:inline text-sm text-gray-500 dark:text-gray-400",children:e.timestamp})]}),(0,u.jsxs)("div",{className:"text-gray-700 dark:text-gray-300",style:{fontSize:"".concat(I.fontSize,"px"),lineHeight:I.lineHeight,textAlign:I.textAlign},children:[e.contextStart>0&&(0,u.jsx)("span",{className:"text-gray-500",children:"..."}),e.contextText.substring(0,e.matchIndex),(0,u.jsx)("span",{className:"bg-yellow-300 dark:bg-yellow-600 px-1 rounded font-semibold",children:e.contextText.substring(e.matchIndex,e.matchIndex+e.matchLength)}),e.contextText.substring(e.matchIndex+e.matchLength),e.contextStart+e.contextText.length<e.text.length&&(0,u.jsx)("span",{className:"text-gray-500",children:"..."})]}),(0,u.jsx)("div",{className:"absolute top-0 right-0 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,u.jsx)("div",{className:"bg-[#FFB52B] text-[#232E3F] p-2 rounded-bl-lg rounded-tr-lg shadow-lg",children:(0,u.jsx)(kh,{size:16,fill:"currentColor"})})})]})]},t)})},qn)]}):(0,u.jsx)("div",{className:"space-y-4",children:Xn.map((e,t)=>(0,u.jsxs)("div",{ref:e=>{e&&(yt.current[t]=e)},className:"relative overflow-hidden rounded-xl border ".concat(Hn(e.topic,!1)),style:{contentVisibility:"auto",containIntrinsicSize:"auto",backgroundImage:"none"},children:[(0,u.jsx)("div",{className:"relative z-10 border-b ".concat(Hn(e.topic,!0)),style:{backgroundImage:"none"},children:(0,u.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2",children:[(0,u.jsxs)("button",{onClick:()=>Yn(t),className:"min-w-0 flex-1 text-left transition-colors hover:opacity-80",children:[(0,u.jsx)("div",{className:"hidden truncate text-sm font-semibold leading-tight md:block md:text-base",children:gE(e.topic.title)||"Untitled topic"}),(0,u.jsx)("div",{className:"block md:hidden",children:(0,u.jsx)(TT,{text:gE(e.topic.title)||"Untitled topic",className:"w-full"})}),An(e.topic)&&(0,u.jsx)("div",{className:"mt-1 text-xs leading-snug text-[#5B687C] dark:text-[#CBD2DB] md:text-sm",children:An(e.topic)}),(0,u.jsx)("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-xs text-gray-500 dark:text-gray-400",children:(()=>{const t=(e=>{const t=Jt(e.start),n=Jt(e.end),a=n-t;return{startTime:En(t),endTime:En(n),duration:Sn(a),startSeconds:t,endSeconds:n}})(e.topic);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,u.jsx)(wp,{size:12}),(0,u.jsxs)("span",{children:[t.startTime," - ",t.endTime]})]}),(0,u.jsx)("span",{className:"font-medium",children:t.duration})]})})()})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(()=>{const e=Ea[t]||XT,n=e.length;return n>0?(0,u.jsxs)("button",{onClick:t=>{t.stopPropagation(),Ra(e,t.currentTarget)},className:"text-xs px-2 py-1 rounded-full bg-[#fff1cc] dark:bg-[#4b3913]/60 text-[#6e4d0e] dar
2k:text-[#ffe09b] hover:bg-[#ffe4a3] dark:hover:bg-[#5a4417] transition-colors flex items-center gap-1",children:[(0,u.jsx)(ky,{size:12}),n]}):null})(),(0,u.jsx)("button",{onClick:()=>Yn(t),className:"rounded-lg p-1 text-gray-600 transition-colors hover:bg-black/5 dark:text-gray-400",title:xe.has(t)?"Collapse topic":"Expand topic",children:xe.has(t)?(0,u.jsx)(wd,{size:18,className:"text-gray-600 dark:text-gray-400"}):(0,u.jsx)(bp,{size:18,className:"text-gray-600 dark:text-gray-400"})})]})]})}),(0,u.jsx)(S,{children:xe.has(t)&&(0,u.jsx)(Do.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"border-t border-gray-200/70 dark:border-gray-700/70",children:(0,u.jsxs)("div",{className:"divide-y divide-gray-200/70 px-4 py-2 dark:divide-gray-700/70",children:[e.segments.map((e,n)=>{var a,r,s,i;const o=(null===(a=xa[t])||void 0===a?void 0:a[n])||KT,l=(null===(r=ba[t])||void 0===r?void 0:r[n])||PT,c=(null===(s=Aa[t])||void 0===s?void 0:s[n])||XT,d=(null===be||void 0===be?void 0:be.groupIndex)===t&&(null===be||void 0===be?void 0:be.segmentIndex)===n||(null===ke||void 0===ke?void 0:ke.groupIndex)===t&&(null===ke||void 0===ke?void 0:ke.segmentIndex)===n;return(0,u.jsx)($T,{groupIndex:t,segmentIndex:n,segment:e,annotations:o,arrangementMarks:l,segmentComments:c,presenceCursors:re.isMobile?[]:W.filter(t=>t.time>=e.timestampSeconds&&t.time<=e.endTimestampSeconds),isSegmentActive:d,currentWordIndex:Fn,wordIndex:un,isPlaybackActive:Ne||V,searchQuery:C,selectedWordKeys:qe,isDarkMode:G,typographyConfig:I,speakerChipFontSize:_a,speakerChipDotSize:Ba,isCompactTouchLayout:re.isCompactTouchLayout,getSpeakerColor:Wn,getReferenceVisualBinding:va,registerSegmentRef:Ia,registerSearchMatchRef:Pa,onShowAnnotationPopup:La,onShowCommentPopup:Ra,onPlaySegment:Oa,onWordClick:za,onArrangementContextMenu:gn,onArrangementClipHover:xn,arrangementHoveredClipId:null!==(i=null===mn||void 0===mn?void 0:mn.hoveredClipId)&&void 0!==i?i:null},n)}),0===e.segments.length&&(0,u.jsx)("div",{className:"py-4 text-center text-sm text-gray-500",children:"No transcript segments found for this topic"})]})})})]},t))},qn)})]})]})," "]})});return f?(0,u.jsxs)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-black bg-opacity-50 flex items-center justify-center p-4",onClick:b,children:[(0,u.jsx)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-7xl w-full max-h-[90vh] flex",onClick:e=>e.stopPropagation(),children:Ua}),(0,u.jsx)(S,{children:Oe&&(0,u.jsx)(Do.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[60] bg-black bg-opacity-50 flex items-center justify-center p-4",onClick:()=>Ue(null),children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center space-x-2",children:"clips"===Oe.type?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{children:"\ud83c\udfac"}),(0,u.jsx)("span",{children:"Clips"})]}):"references"===Oe.type?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{children:"\ud83d\udcda"}),(0,u.jsx)("span",{children:"References"})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{children:"\u2702\ufe0f"}),(0,u.jsx)("span",{children:"Edits"})]})}),(0,u.jsx)("button",{onClick:()=>Ue(null),className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-lg transition-colors",children:(0,u.jsx)(Pu,{size:20})})]}),(0,u.jsx)("div",{className:"p-6 overflow-y-auto max-h-[60vh]",children:(()=>{const e=Gn[Oe.groupIndex].segments[Oe.segmentIndex],t=kn(e.timestampSeconds,e.endTimestampSeconds),n="clips"===Oe.type?t.clips:"references"===Oe.type?t.references:t.edits;return 0===n.length?(0,u.jsxs)("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:["No ",Oe.type," found for this segment."]}):(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:[(0,u.jsx)("strong",{children:"Segment:"})," ",e.speaker," at ",e.timestamp]}),n.map((e,t)=>{if("references"===Oe.type){var n;const a=Qt(e.content),r=en(e.start),s=ya.get(Em({title:e.title||a.title,start:en(e.start),end:en(e.end)}));return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-4 bg-gray-50 dark:bg-gray-700 space-y-3",children:[(0,u.jsx)("div",{className:"flex items-start justify-between gap-2",children:(0,u.jsxs)("h4",{className:"font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[a.url&&(0,u.jsx)(pF,{size:16,className:"text-[#FFB52B] flex-shrink-0"}),a.title]})}),a.category&&(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-[#edf0f4] dark:bg-[#314159] text-[#455468] dark:text-[#d9e2f1]",children:a.category}),s&&(0,u.jsxs)("span",{className:"ml-2 inline-flex items-center gap-1 rounded-full bg-[#fff1cc] px-2 py-0.5 text-xs text-[#6e4d0e] dark:bg-[#4b3913]/60 dark:text-[#ffe09b]",children:[(0,u.jsx)(Cp,{size:11}),s.assetCount," asset",1===s.assetCount?"":"s"]})]}),a.context&&(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:a.context}),null!==s&&void 0!==s&&null!==(n=s.placements)&&void 0!==n&&n.length?(0,u.jsx)(vS,{placements:s.placements,isDarkMode:G,compact:!0,onSeek:()=>{Tn(r),Ue(null)}}):!se&&a.visualSuggestion?(0,u.jsx)(fS,{kind:"reference",title:a.title,description:a.context,visualSuggestion:a.visualSuggestion,meta:a.category,linkHref:a.url,previewImageUrl:Cm(null===s||void 0===s?void 0:s.primaryPlacement),seekLabel:e.start,onSeek:()=>{Tn(r),Ue(null)},isDarkMode:G,compact:!0}):null,a.url&&(0,u.jsxs)("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#fff1cc] dark:bg-[#4b3913]/45 text-[#6e4d0e] dark:text-[#ffe09b] hover:bg-[#ffe4a3] dark:hover:bg-[#5a4417] transition-colors text-sm",children:[(0,u.jsx)(Ep,{size:14}),(0,u.jsx)("span",{className:"truncate",children:a.linkText||a.url})]}),(0,u.jsxs)("button",{onClick:()=>{Tn(r),Ue(null)},className:"flex items-center gap-1.5 px-2 py-1 text-xs rounded bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-500 transition-colors",children:[(0,u.jsx)(wp,{size:12}),e.start]})]},t)}if("edits"===Oe.type){const n=Zt(e.content),a=en(e.start);return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-4 bg-gray-50 dark:bg-gray-700 space-y-3",children:[n.title&&(0,u.jsx)("h4",{className:"font-semibold text-gray-900 dark:text-gray-100",children:n.title}),n.priority&&(0,u.jsx)("div",{children:(0,u.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(n.priority.toLowerCase().includes("high")?"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300":n.priority.toLowerCase().includes("medium")?"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300":"bg-[#edf0f4] dark:bg-[#314159] text-[#455468] dark:text-[#d9e2f1]"),children:["Pri
2ority: ",n.priority]})}),(0,u.jsxs)("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[(0,u.jsx)("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Suggestion: "}),n.suggestion]}),n.improvement&&(0,u.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400 pl-3 border-l-2 border-[#FFB52B] dark:border-[#d5a145]",children:[(0,u.jsx)("span",{className:"font-medium text-[#8a6115] dark:text-[#ffcf74]",children:"Improvement: "}),n.improvement]}),n.note&&(0,u.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-500 italic",children:["Note: ",n.note]}),(0,u.jsxs)("button",{onClick:()=>{Tn(a),Ue(null)},className:"flex items-center gap-1.5 px-2 py-1 text-xs rounded bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-500 transition-colors",children:[(0,u.jsx)(wp,{size:12}),e.start]})]},t)}return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-4 bg-gray-50 dark:bg-gray-700",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsxs)("h4",{className:"font-medium text-gray-900 dark:text-gray-100",children:["Clip ",t+1]}),(0,u.jsxs)("button",{onClick:()=>{Tn(en(e.start)),Ue(null)},className:"flex items-center gap-1.5 px-2 py-1 text-xs rounded bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-500 transition-colors",children:[(0,u.jsx)(wp,{size:12}),e.start]})]}),(0,u.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:e.title||e.content.replace(/\[CLIP\]\s*/g,"").trim()})]},t)})]})})()}),(0,u.jsx)("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4 bg-gray-50 dark:bg-gray-800",children:(0,u.jsx)("button",{onClick:()=>Ue(null),className:"w-full py-2 px-4 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors",children:"Close"})})]})})})]}):(0,u.jsxs)(u.Fragment,{children:[Ua,(0,u.jsx)(S,{children:Oe&&(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[60] bg-black bg-opacity-50 flex items-center justify-center p-4",onClick:()=>Ue(null),children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center space-x-2",children:"clips"===Oe.type?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{children:"\ud83c\udfac"}),(0,u.jsx)("span",{children:"Clips"})]}):"references"===Oe.type?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{children:"\ud83d\udcda"}),(0,u.jsx)("span",{children:"References"})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{children:"\u2702\ufe0f"}),(0,u.jsx)("span",{children:"Edits"})]})}),(0,u.jsx)("button",{onClick:()=>Ue(null),className:"p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 rounded-lg transition-colors",children:(0,u.jsx)(Pu,{size:20})})]}),(0,u.jsx)("div",{className:"p-6 overflow-y-auto max-h-[60vh]",children:(()=>{const e=Gn[Oe.groupIndex].segments[Oe.segmentIndex],t=kn(e.timestampSeconds,e.endTimestampSeconds),n="clips"===Oe.type?t.clips:"references"===Oe.type?t.references:t.edits;return 0===n.length?(0,u.jsxs)("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:["No ",Oe.type," found for this segment."]}):(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:[(0,u.jsx)("strong",{children:"Segment:"})," ",e.speaker," at ",e.timestamp]}),n.map((e,t)=>{if("references"===Oe.type){var n;const a=Qt(e.content),r=en(e.start),s=ya.get(Em({title:e.title||a.title,start:en(e.start),end:en(e.end)}));return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-4 bg-gray-50 dark:bg-gray-700 space-y-3",children:[(0,u.jsx)("div",{className:"flex items-start justify-between gap-2",children:(0,u.jsxs)("h4",{className:"font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[a.url&&(0,u.jsx)(pF,{size:16,className:"text-[#FFB52B] flex-shrink-0"}),a.title]})}),a.category&&(0,u.jsx)("div",{children:(0,u.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full bg-[#edf0f4] dark:bg-[#314159] text-[#455468] dark:text-[#d9e2f1]",children:a.category})}),a.context&&(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:a.context}),null!==s&&void 0!==s&&null!==(n=s.placements)&&void 0!==n&&n.length?(0,u.jsx)(vS,{placements:s.placements,isDarkMode:G,compact:!0,onSeek:()=>{Tn(r),Ue(null)}}):!se&&a.visualSuggestion?(0,u.jsx)(fS,{kind:"reference",title:a.title,description:a.context,visualSuggestion:a.visualSuggestion,meta:a.category,linkHref:a.url,previewImageUrl:Cm(null===s||void 0===s?void 0:s.primaryPlacement),seekLabel:e.start,onSeek:()=>{Tn(r),Ue(null)},isDarkMode:G,compact:!0}):null,a.url&&(0,u.jsxs)("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#fff1cc] dark:bg-[#4b3913]/45 text-[#6e4d0e] dark:text-[#ffe09b] hover:bg-[#ffe4a3] dark:hover:bg-[#5a4417] transition-colors text-sm",children:[(0,u.jsx)(Ep,{size:14}),(0,u.jsx)("span",{className:"truncate",children:a.linkText||a.url})]}),(0,u.jsxs)("button",{onClick:()=>{Tn(r),Ue(null)},className:"flex items-center gap-1.5 px-2 py-1 text-xs rounded bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-500 transition-colors",children:[(0,u.jsx)(wp,{size:12}),e.start]})]},t)}if("edits"===Oe.type){const n=Zt(e.content),a=en(e.start);return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-4 bg-gray-50 dark:bg-gray-700 space-y-3",children:[n.title&&(0,u.jsx)("h4",{className:"font-semibold text-gray-900 dark:text-gray-100",children:n.title}),n.priority&&(0,u.jsx)("div",{children:(0,u.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(n.priority.toLowerCase().includes("high")?"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300":n.priority.toLowerCase().includes("medium")?"bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300":"bg-[#edf0f4] dark:bg-[#314159] text-[#455468] dark:text-[#d9e2f1]"),children:["Pri
2ority: ",n.priority]})}),(0,u.jsxs)("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[(0,u.jsx)("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Suggestion: "}),n.suggestion]}),n.improvement&&(0,u.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400 pl-3 border-l-2 border-[#FFB52B] dark:border-[#d5a145]",children:[(0,u.jsx)("span",{className:"font-medium text-[#8a6115] dark:text-[#ffcf74]",children:"Improvement: "}),n.improvement]}),n.note&&(0,u.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-500 italic",children:["Note: ",n.note]}),(0,u.jsxs)("button",{onClick:()=>{Tn(a),Ue(null)},className:"flex items-center gap-1.5 px-2 py-1 text-xs rounded bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-500 transition-colors",children:[(0,u.jsx)(wp,{size:12}),e.start]})]},t)}return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-600 rounded-lg p-4 bg-gray-50 dark:bg-gray-700",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsxs)("h4",{className:"font-medium text-gray-900 dark:text-gray-100",children:["Clip ",t+1]}),(0,u.jsxs)("button",{onClick:()=>{Tn(en(e.start)),Ue(null)},className:"flex items-center gap-1.5 px-2 py-1 text-xs rounded bg-gray-200 dark:bg-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-500 transition-colors",children:[(0,u.jsx)(wp,{size:12}),e.start]})]}),(0,u.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:e.title||e.content.replace(/\[CLIP\]\s*/g,"").trim()})]},t)})]})})()}),(0,u.jsx)("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4 bg-gray-50 dark:bg-gray-800",children:(0,u.jsx)("button",{onClick:()=>Ue(null),className:"w-full py-2 px-4 bg-gray-600 hover:bg-gray-700 text-white rounded-lg transition-colors",children:"Close"})})]})})}),hn&&(0,u.jsx)(KF,{x:hn.x,y:hn.y,title:hn.title,subtitle:hn.subtitle,warnings:hn.warnings,items:hn.items,isDarkMode:G,onClose:pn}),Rt&&(Rt.comments.length>0||le)&&(0,u.jsx)(OT,{comments:Rt.comments,position:Rt.position,onClose:()=>zt(null),onReply:le?async(e,t)=>{try{let n;if(se&&O){const a={"Content-Type":"application/json"},r=Kt(),s="undefined"===typeof window?"":window.localStorage.getItem("anonymousName")||"";r&&(a["X-Anonymous-Session-ID"]=r),n=await fetch("".concat(cM,"/api/public/share/").concat(O,"/comments"),{method:"POST",headers:a,body:JSON.stringify({content:t,parentCommentId:e,type:"comment",anonName:s.trim()||void 0})})}else n=await fetch("".concat(cM,"/api/sessions/").concat(x,"/comments"),{method:"POST",headers:{Authorization:"Bearer ".concat(R),"Content-Type":"application/json"},body:JSON.stringify({content:t,parentCommentId:e})});if(n.ok){const e=await Xt();if(e){const t=new Set(Rt.comments.map(e=>e.id)),n=e.filter(e=>{if(t.has(e.id))return!0;return Rt.comments.some(t=>!(!e.timestampSeconds||!t.timestampSeconds)&&Math.abs(e.timestampSeconds-t.timestampSeconds)<.1)});zt(d(d({},Rt),{},{comments:n}))}}}catch(n){console.error("Failed to reply:",n)}}:void 0,onReact:!se&&le?async(e,t)=>{try{if((await fetch("".concat(cM,"/api/sessions/").concat(x,"/comments/").concat(e,"/reactions"),{method:"POST",headers:{Authorization:"Bearer ".concat(R),"Content-Type":"application/json"},body:JSON.stringify({emoji:t})})).ok){const e=await fetch("".concat(cM,"/api/sessions/").concat(x,"/reactions"),{headers:{Authorization:"Bearer ".concat(R)}});if(e.ok){await e.json();const t=[...Rt.comments];zt(d(d({},Rt),{},{comments:t}))}}}catch(n){console.error("Failed to react:",n)}}:void 0,onDelete:!se&&le?async e=>{try{if((await fetch("".concat(cM,"/api/sessions/").concat(x,"/comments/").concat(e),{method:"DELETE",headers:{Authorization:"Bearer ".concat(R)}})).ok){const t=Rt.comments.filter(t=>{const n=t=>t.id===e||(t.replies&&(t.replies=t.replies.filter(e=>!n(e))),!1);return!n(t)});0===t.length?zt(null):zt(d(d({},Rt),{},{comments:t}));const n=await fetch("".concat(cM,"/api/sessions/").concat(x,"/comments"),{headers:{Authorization:"Bearer ".concat(R)}});if(n.ok){const e=await n.json(),t=Gt(e.comments||[]);Ut(t)}}}catch(t){console.error("Failed to delete:",t)}}:void 0,onAddComment:le?async(e,t)=>{try{let n;if(se&&O){const a={"Content-Type":"application/json"},r=Kt(),s="undefined"===typeof window?"":window.localStorage.getItem("anonymousName")||"";r&&(a["X-Anonymous-Session-ID"]=r),n=await fetch("".concat(cM,"/api/public/share/").concat(O,"/comments"),{method:"POST",headers:a,body:JSON.stringify({content:e,type:"comment",anonName:s.trim()||void 0,timestampSeconds:t||Rt.t
2imestampSeconds})})}else n=await fetch("".concat(cM,"/api/sessions/").concat(x,"/comments"),{method:"POST",headers:{Authorization:"Bearer ".concat(R),"Content-Type":"application/json"},body:JSON.stringify({content:e,timestampSeconds:t||Rt.timestampSeconds})});if(n.ok){if(await Xt()){const e=Sa(t||Rt.timestampSeconds||0,t||Rt.timestampSeconds||0);zt(d(d({},Rt),{},{comments:e}))}}}catch(n){console.error("Failed to add comment:",n)}}:void 0,sessionId:!se&&le?x:void 0,token:!se&&le&&R||void 0,readOnly:!le}),nt&&ce&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/45 px-4 py-8 backdrop-blur-sm",children:(0,u.jsxs)("div",{className:"w-full max-w-xl rounded-3xl border p-5 shadow-2xl ".concat(G?"border-[#3A4658] bg-[#182130] text-[#F4F4F4]":"border-[#D8DEE7] bg-white text-[#232E3F]"),children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] opacity-70",children:"Edit Topic"}),(0,u.jsx)("div",{className:"mt-1 text-lg font-semibold",children:"Update current topic metadata"})]}),(0,u.jsx)("button",{type:"button",onClick:()=>{lt||(at(!1),ot(null))},className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-current/15 transition hover:bg-black/5 dark:hover:bg-white/5","aria-label":"Close topic editor",children:(0,u.jsx)(Pu,{size:16})})]}),(0,u.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-2 text-xs font-semibold uppercase tracking-[0.16em] opacity-70",children:"Topic Title"}),(0,u.jsx)("input",{type:"text",value:rt.title,onChange:e=>st(t=>d(d({},t),{},{title:e.target.value})),disabled:lt,className:"w-full rounded-2xl border px-4 py-3 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),placeholder:"Topic title"})]}),(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-2 text-xs font-semibold uppercase tracking-[0.16em] opacity-70",children:"Topic Description"}),(0,u.jsx)("textarea",{value:rt.description,onChange:e=>st(t=>d(d({},t),{},{description:e.target.value})),disabled:lt,rows:5,className:"w-full rounded-2xl border px-4 py-3 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),placeholder:"Short explanation or justification for this topic"})]}),it&&(0,u.jsx)("div",{className:"text-sm font-medium text-red-700 dark:text-red-300",children:it})]}),(0,u.jsxs)("div",{className:"mt-5 flex items-center justify-end gap-3",children:[(0,u.jsx)("button",{type:"button",onClick:()=>{lt||(at(!1),ot(null))},disabled:lt,className:"rounded-full border px-4 py-2 text-sm font-semibold transition ".concat(G?"border-[#3A4658] text-[#D6DEE9] hover:bg-[#202B3B]":"border-[#D8DEE7] text-[#445166] hover:bg-[#F4F6F8]"," disabled:cursor-not-allowed disabled:opacity-50"),children:"Cancel"}),(0,u.jsxs)("button",{type:"button",onClick:()=>{da()},disabled:lt,className:"inline-flex items-center gap-2 rounded-full bg-[#232E3F] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#2F3B4E] disabled:cursor-not-allowed disabled:opacity-50",children:[lt&&(0,u.jsx)(Lo,{size:14,className:"animate-spin"}),(0,u.jsx)("span",{children:lt?"Saving\u2026":"Save Topic"})]})]})]})}),(0,u.jsx)(S,{children:Ve&&de&&(0,u.jsxs)(Do.div,{ref:St,initial:{opacity:0,scale:.96,y:8},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.96,y:8},transition:{duration:.14,ease:"easeOut"},className:"fixed z-[70] w-[min(20rem,calc(100vw-2rem))] rounded-3xl border p-4 shadow-[0_28px_70px_-34px_rgba(15,23,42,0.42)] ".concat(G?"border-white/10 bg-[linear-gradient(180deg,rgba(17,27,42,0.76),rgba(17,27,42,0.72))] text-[#F4F4F4] backdrop-blur-[24px]":"border-[rgba(215,222,233,0.82)] bg-[linear-gradient(180deg,rgba(255,255,255,0.76),rgba(255,255,255,0.7))] text-[#232E3F] backdrop-blur-[22px]"),style:{left:Ve.position.left,top:Ve.position.top},onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.16em] opacity-70",children:"Transcript Selection"}),(0,u.jsxs)("div",{className:"mt-1 text-[11px] font-medium opacity-70",children:[jn(Ve.startTime)," - ",jn(Ve.endTime)]})]}),(0,u.jsx)("button",{type:"button",onClick:Dn,className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-current/15 transition hover:bg-black/5 dark:hover:bg-white/5","aria-label":"Close selection actions",disabled:Je,children:(0,u.jsx)(Pu,{size:14})})]}),(0,u.jsx)("div",{className:"mt-3 rounded-2xl border border-current/10 bg-black/[0.03] px-3 py-2 text-sm leading-relaxed dark:bg-white/[0.04]",children:Ve.previewText}),Ke&&(0,u.jsx)("div",{className:"mt-3 text-xs font-medium text-red-700 dark:text-red-300",children:Ke}),Ye?(0,u.jsxs)("div",{className:"mt-4 space-y-3",children:["clip"===Ye?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-70",children:"Clip Title"}),(0,u.jsx)("input",{type:"text",value:Qe.title,onChange:e=>Ze(t=>d(d({},t),{},{title:e.target.value})),disabled:Je,className:"w-full rounded-2xl border px-3 py-2 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focu
2s:border-[#FFB52B]"),placeholder:"Clip title"})]}),(0,u.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_8.5rem]",children:[(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-70",children:"Description"}),(0,u.jsx)("textarea",{value:Qe.description,onChange:e=>Ze(t=>d(d({},t),{},{description:e.target.value})),disabled:Je,rows:3,className:"w-full rounded-2xl border px-3 py-2 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),placeholder:"Why this clip matters"})]}),(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-70",children:"Type"}),(0,u.jsxs)("select",{value:Qe.clipType,onChange:e=>Ze(t=>d(d({},t),{},{clipType:e.target.value})),disabled:Je,className:"w-full rounded-2xl border px-3 py-2 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),children:[(0,u.jsx)("option",{value:"Key Insight",children:"Key Insight"}),(0,u.jsx)("option",{value:"Educational Nugget",children:"Educational Nugget"}),(0,u.jsx)("option",{value:"Quotable Moment",children:"Quotable Moment"}),(0,u.jsx)("option",{value:"Technical Deep Dive",children:"Technical Deep Dive"}),(0,u.jsx)("option",{value:"Viral Hook",children:"Viral Hook"})]})]})]})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-70",children:"Edit Title"}),(0,u.jsx)("input",{type:"text",value:et.title,onChange:e=>tt(t=>d(d({},t),{},{title:e.target.value})),disabled:Je,className:"w-full rounded-2xl border px-3 py-2 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),placeholder:"Edit title"})]}),(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-70",children:"Suggestion"}),(0,u.jsx)("textarea",{value:et.suggestion,onChange:e=>tt(t=>d(d({},t),{},{suggestion:e.target.value})),disabled:Je,rows:3,className:"w-full rounded-2xl border px-3 py-2 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),placeholder:"What should change here"})]}),(0,u.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-[minmax(0,1fr)_8.5rem]",children:[(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-70",children:"Improvement"}),(0,u.jsx)("input",{type:"text",value:et.improvement,onChange:e=>tt(t=>d(d({},t),{},{improvement:e.target.value})),disabled:Je,className:"w-full rounded-2xl border px-3 py-2 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),placeholder:"Expected improvement"})]}),(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-70",children:"Priority"}),(0,u.jsxs)("select",{value:et.priority,onChange:e=>tt(t=>d(d({},t),{},{priority:e.target.value})),disabled:Je,className:"w-full rounded-2xl border px-3 py-2 text-sm outline-none transition ".concat(G?"border-[#3A4658] bg-[#101925] text-[#F4F4F4] focus:border-[#FFB52B]":"border-[#D8DEE7] bg-[#FAFBFC] text-[#232E3F] focus:border-[#FFB52B]"),children:[(0,u.jsx)("option",{value:"low",children:"Low"}),(0,u.jsx)("option",{value:"medium",children:"Medium"}),(0,u.jsx)("option",{value:"high",children:"High"})]})]})]})]}),(0,u.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-1",children:[(0,u.jsx)("button",{type:"button",onClick:Dn,disabled:Je,className:"rounded-full border px-4 py-2 text-sm font-semibold transition ".concat(G?"border-[#3A4658] text-[#D6DEE9] hover:bg-[#202B3B]":"border-[#D8DEE7] text-[#445166] hover:bg-[#F4F6F8]"," disabled:cursor-not-allowed disabled:opacity-50"),children:"Cancel"}),(0,u.jsxs)("button",{type:"button",onClick:()=>{oa()},disabled:Je,className:"inline-flex items-center gap-2 rounded-full bg-[#232E3F] px-4 py-2 text-sm font-semibold text-white transition hover:bg-[#2F3B4E] disabled:cursor-not-allowed disabled:opacity-50",children:[Je&&(0,u.jsx)(Lo,{size:14,className:"animate-spin"}),(0,u.jsx)("span",{children:Je?"Saving\u2026":"clip"===Ye?"Save Clip":"Save Edit"})]})]})]}):(0,u.jsxs)("div",{className:"mt-4 flex items-center gap-2",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{Ge("clip"),Xe(null)},className:"inline-flex flex-1 items-center justify-center gap-2 rounded-full bg-[#232E3F] px-3 py-2 text-sm font-semibold text-white transition hover:bg-[#2F3B4E]",children:[(0,u.jsx)(uj,{size:14}),(0,u.jsx)("span",{children:"Add Clip"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{Ge("edit"),Xe(null)},className:"inline-flex flex-1 items-center justify-center gap-2 rounded-full border px-3 py-2 text-sm font-semibold transition ".concat(G?"border-[#3A4658] text-[#D6DEE9] hover:bg-[#202B3B]":"border-[#D8DEE7] text-[#445166] hover:bg-[#F4F6F8]"),children:[(0,u.jsx)(yj,{size:14}),(0,u.jsx)("span",{children:"Add Edit"})]})]})]})})]})},gM=Mo("file-search",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]),xM=Mo("git-compare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}
2]]),fM=Mo("captions",[["rect",{width:"18",height:"14",x:"3",y:"5",rx:"2",ry:"2",key:"12ruh7"}],["path",{d:"M7 15h4M15 15h2M7 11h2M13 11h4",key:"1ueiar"}]]),bM=/^https?:\/\//i;function yM(e){return e.replace(/\/+$/,"")}function vM(e,t){return new URL(t,"".concat(yM(e),"/")).toString()}function wM(e,t){const n=yM(t);return"".concat(n,"/sessions/").concat(e,"/pdf/download")}function kM(e,t,n){const a="".concat(yM(t),"/public/share/").concat(e,"/pdf");return bM.test(a)?a:vM(n,a)}const jM=e=>{var t,n;let{isOpen:r,onClose:s,transcript:i,filename:o,speakerLabels:l}=e;const{isDarkMode:c}=zu(),[m,h]=(0,a.useState)(4),[p,g]=(0,a.useState)(50),[x,f]=(0,a.useState)(!1),b=new Set(["the","be","to","of","and","a","in","that","have","i","it","for","not","on","with","he","as","you","do","at","this","but","his","by","from","they","we","say","her","she","or","an","will","my","one","all","would","there","their","what","so","up","out","if","about","who","get","which","go","me","when","make","can","like","time","no","just","him","know","take","people","into","year","your","good","some","could","them","see","other","than","then","now","look","only","come","its","over","think","also","back","after","use","two","how","our","work","first","well","way","even","new","want","because","any","these","give","day","most","us","is","was","are","been","has","had","were","said","did","get","may","very","made","find","where","much","too","very","still","being","going","why","yeah","yes","okay","ok","um","uh","ah","oh","really","right","mean","thing","things","something","anything","nothing","everything","somewhere","here","there","maybe","probably","actually","basically","literally"]),y=(0,a.useMemo)(()=>{const e=new Set;if(l){Object.values(l).forEach(t=>{"string"===typeof t&&(e.add(t.toLowerCase()),t.split(" ").forEach(t=>{t.length>0&&e.add(t.toLowerCase())}))});for(let t=0;t<=20;t++)e.add("speaker".concat(t)),e.add("speaker")}const t=i.toLowerCase().replace(/[^\w\s]/g," ").replace(/\s+/g," ").split(" ").filter(t=>t.length>=m&&!b.has(t)&&!e.has(t)),n={};t.forEach(e=>{n[e]=(n[e]||0)+1});const a=Object.entries(n).map(e=>{let[t,n]=e;return{text:t,count:n}}).sort((e,t)=>t.count-e.count).slice(0,p);if(0===a.length)return[];const r=a[0].count,s=a[a.length-1].count,o=r-s||1;return a.map(e=>d(d({},e),{},{size:14+(e.count-s)/o*36}))},[i,m,p,l]),[v,w]=(0,a.useState)([]);(0,a.useEffect)(()=>{const e=y.map(()=>({x:80*Math.random()+10,y:80*Math.random()+10,rotation:30*Math.random()-15}));w(e)},[y]);const k=e=>{const t=c?["#60A5FA","#34D399","#F59E0B","#EF4444","#A78BFA","#EC4899","#10B981","#3B82F6"]:["#2563EB","#059669","#D97706","#DC2626","#7C3AED","#DB2777","#047857","#1D4ED8"];return t[e%t.length]};return r?(0,u.jsx)(S,{children:(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 bg-black bg-opacity-50 flex items-center justify-center p-4",onClick:s,children:(0,u.jsxs)(Do.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},className:"".concat(c?"bg-gray-800":"bg-white"," rounded-xl shadow-2xl max-w-4xl w-full max-h-[90vh] flex flex-col"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-b ".concat(c?"border-gray-700":"border-gray-200"),children:[(0,u.jsx)("h2",{className:"text-xl font-semibold ".concat(c?"text-white":"text-gray-900"),children:"Word Cloud"}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("button",{onClick:()=>f(!x),className:"p-2 rounded-lg transition-colors ".concat(c?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-100 text-gray-600"),title:"Filter options",children:(0,u.jsx)(hj,{size:20})}),(0,u.jsx)("button",{onClick:()=>{const e=document.getElementById("word-cloud-svg");if(!e)return;const t=(new XMLSerializer).serializeToString(e),n=new Blob([t],{type:"image/svg+xml"}),a=URL.createObjectURL(n),r=document.createElement("a");r.href=a,r.download="".concat(o.replace(/\.[^/.]+$/,""),"_wordcloud.svg"),r.click(),URL.revokeObjectURL(a)},className:"p-2 rounded-lg transition-colors ".concat(c?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-100 text-gray-600"),title:"Download as SVG",children:(0,u.jsx)(Sp,{size:20})}),(0,u.jsx)("button",{onClick:s,className:"p-2 rounded-lg transition-colors ".concat(c?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-100 text-gray-600"),children:(0,u.jsx)(Pu,{size:20})})]})]}),x&&(0,u.jsx)("div",{className:"p-4 border-b ".concat(c?"border-gray-700":"border-gray-200"),children:(0,u.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"text-sm ".concat(c?"text-gray-300":"text-gray-600"),children:"Min Word Length"}),(0,u.jsx)("input",{type:"number",value:m,onChange:e=>h(Math.max(1,parseInt(e.target.value)||1)),className:"ml-2 w-16 px-2 py-1 rounded border ".concat(c?"bg-gray-700 border-gray-600 text-white":"bg-white border-gray-300 text-gray-900"),min:"1",max:"10"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"text-sm ".concat(c?"text-gray-300":"text-gray-600"),children:"Max Words"}),(0,u.jsx)("input",{type:"number",value:p,onChange:e=>g(Math.max(10,parseInt(e.target.value)||10)),className:"ml-2 w-20 px-2 py-1 rounded border ".concat(c?"bg-gray-700 border-gray-600 text-white":"bg-white border-gray-300 text-gray-900"),min:"10",max:"200"})]})]})}),(0,u.jsx)("div",{className:"flex-1 p-4 overflow-hidden",children:(0,u.jsx)("div",{className:"w-full h-full rounded-lg ".concat(c?"bg-gray-900":"bg-gray-50"," relative"),children:(0,u.jsx)("svg",{id:"word-cloud-svg",width:"100%",height:"100%",viewBox:"0 0 800 600",preserveAspectRatio:"xMidYMid meet",children:y.map((e,t)=>{const n=v[t];return n?(0,u.jsxs)(Do.text,{x:"".concat(n.x,"%"),y:"".concat(n.y,"%"),initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},transition:{delay:.02*t},style:{fontSize:"".concat(e.size,"px"),fill:k(t),fontWeight:e.size>30?"bold":"normal",transform:"rotate(".concat(n.rotation,"deg)"),transformOrigin:"center",cursor:"default"},className:"select-none",children:[e.text,(0,u.jsx)("title",{children:"".concat(e.text,": ").concat(e.count," occurrences")})]},e.text):null})})})}),(0,u.jsx)("div",{className:"p-4 border-t ".concat(c?"border-gray-700":"border-gray-200"),children:(0,u.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,u.jsxs)("span",{className:c?"text-gray-400":"text-gray-600",children:["Total unique words: ",y.length]}),(0,u.jsxs)("span",{className:c?"text-gray-400":"text-gray-600",children:["Most frequent: ",null===(t=y[0])||void 0===t?void 0:t.text," (",null===(n=y[0])||void 0===n?void 0:n.count," times)"]})]})})]})})}):null},DM=Mo("circle-help",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function CM(e){return e+.5|0}const NM=(e,t,n)=>Math.max(Math.min(e,n),t);function FM(e){return NM(CM(2.55*e),0,255)}function SM(e){return NM(CM(255*e),0,255)}function EM(e){return NM(CM(e/2.55)/100,0,1)}function AM(e){return NM(CM(100*e),0,100)}const TM={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},MM=[..."0123456789ABCDEF"],_M=e=>MM[15&e],BM=e=>MM[(240&e)>>4]+MM[15&e],IM=e=>(240&e)>>4===(15&e);function PM(e){var t=(e=>IM(e.r)&&IM(e.g)&&IM(e.b)&&IM(e.a))(e)?_M:BM;return e?"#"+t(e.r)+t(e.g)+t(e.b)+((e,t)=>e<255?t(e):"")(e.a,t):void 0}const LM=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;
vendor: 4,240 bytes, line 2
2function RM(e,t,n){const a=t*Math.min(n,1-n),r=function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(t+e/30)%12;return n-a*Math.max(Math.min(r-3,9-r,1),-1)};return[r(0),r(8),r(4)]}function zM(e,t,n){const a=function(a){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:(a+e/60)%6;return n-n*t*Math.max(Math.min(r,4-r,1),0)};return[a(5),a(3),a(1)]}function OM(e,t,n){const a=RM(e,1,.5);let r;for(t+n>1&&(r=1/(t+n),t*=r,n*=r),r=0;r<3;r++)a[r]*=1-t-n,a[r]+=t;return a}function UM(e){const t=e.r/255,n=e.g/255,a=e.b/255,r=Math.max(t,n,a),s=Math.min(t,n,a),i=(r+s)/2;let o,l,c;return r!==s&&(c=r-s,l=i>.5?c/(2-r-s):c/(r+s),o=function(e,t,n,a,r){return e===r?(t-n)/a+(t<n?6:0):t===r?(n-e)/a+2:(e-t)/a+4}(t,n,a,c,r),o=60*o+.5),[0|o,l||0,i]}function VM(e,t,n,a){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,a)).map(SM)}function HM(e,t,n){return VM(RM,e,t,n)}function qM(e){return(e%360+360)%360}function WM(e){const t=LM.exec(e);let n,a=255;if(!t)return;t[5]!==n&&(a=t[6]?FM(+t[5]):SM(+t[5]));const r=qM(+t[2]),s=+t[3]/100,i=+t[4]/100;return n="hwb"===t[1]?function(e,t,n){return VM(OM,e,t,n)}(r,s,i):"hsv"===t[1]?function(e,t,n){return VM(zM,e,t,n)}(r,s,i):HM(r,s,i),{r:n[0],g:n[1],b:n[2],a:a}}const YM={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},GM={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};let KM;function XM(e){KM||(KM=function(){const e={},t=Object.keys(GM),n=Object.keys(YM);let a,r,s,i,o;for(a=0;a<t.length;a++){for(i=o=t[a],r=0;r<n.length;r++)s=n[r],o=o.replace(s,YM[s]);s=parseInt(GM[i],16),e[o]=[s>>16&255,s>>8&255,255&s]}return e}(),KM.transparent=[0,0,0,0]);const t=KM[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:4===t.length?t[3]:255}}const JM=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const $M=e=>
vendor: 6,910 bytes, line 2
2e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055,QM=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function ZM(e,t,n){if(e){let a=UM(e);a[t]=Math.max(0,Math.min(a[t]+a[t]*n,0===t?360:1)),a=HM(a),e.r=a[0],e.g=a[1],e.b=a[2]}}function e_(e,t){return e?Object.assign(t||{},e):e}function t_(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=SM(e[3]))):(t=e_(e,{r:0,g:0,b:0,a:1})).a=SM(t.a),t}function n_(e){return"r"===e.charAt(0)?function(e){const t=JM.exec(e);let n,a,r,s=255;if(t){if(t[7]!==n){const e=+t[7];s=t[8]?FM(e):NM(255*e,0,255)}return n=+t[1],a=+t[3],r=+t[5],n=255&(t[2]?FM(n):NM(n,0,255)),a=255&(t[4]?FM(a):NM(a,0,255)),r=255&(t[6]?FM(r):NM(r,0,255)),{r:n,g:a,b:r,a:s}}}(e):WM(e)}class a_{constructor(e){if(e instanceof a_)return e;const t=typeof e;let n;"object"===t?n=t_(e):"string"===t&&(n=function(e){var t,n=e.length;return"#"===e[0]&&(4===n||5===n?t={r:255&17*TM[e[1]],g:255&17*TM[e[2]],b:255&17*TM[e[3]],a:5===n?17*TM[e[4]]:255}:7!==n&&9!==n||(t={r:TM[e[1]]<<4|TM[e[2]],g:TM[e[3]]<<4|TM[e[4]],b:TM[e[5]]<<4|TM[e[6]],a:9===n?TM[e[7]]<<4|TM[e[8]]:255})),t}(e)||XM(e)||n_(e)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var e=e_(this._rgb);return e&&(e.a=EM(e.a)),e}set rgb(e){this._rgb=t_(e)}rgbString(){return this._valid?(e=this._rgb)&&(e.a<255?"rgba(".concat(e.r,", ").concat(e.g,", ").concat(e.b,", ").concat(EM(e.a),")"):"rgb(".concat(e.r,", ").concat(e.g,", ").concat(e.b,")")):void 0;var e}hexString(){return this._valid?PM(this._rgb):void 0}hslString(){return this._valid?function(e){if(!e)return;const t=UM(e),n=t[0],a=AM(t[1]),r=AM(t[2]);return e.a<255?"hsla(".concat(n,", ").concat(a,"%, ").concat(r,"%, ").concat(EM(e.a),")"):"hsl(".concat(n,", ").concat(a,"%, ").concat(r,"%)")}(this._rgb):void 0}mix(e,t){if(e){const n=this.rgb,a=e.rgb;let r;const s=t===r?.5:t,i=2*s-1,o=n.a-a.a,l=((i*o===-1?i:(i+o)/(1+i*o))+1)/2;r=1-l,n.r=255&l*n.r+r*a.r+.5,n.g=255&l*n.g+r*a.g+.5,n.b=255&l*n.b+r*a.b+.5,n.a=s*n.a+(1-s)*a.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=function(e,t,n){const a=QM(EM(e.r)),r=QM(EM(e.g)),s=QM(EM(e.b));return{r:SM($M(a+n*(QM(EM(t.r))-a))),g:SM($M(r+n*(QM(EM(t.g))-r))),b:SM($M(s+n*(QM(EM(t.b))-s))),a:e.a+n*(t.a-e.a)}}(this._rgb,e._rgb,t)),this}clone(){return new a_(this.rgb)}alpha(e){return this._rgb.a=SM(e),this}clearer(e){return this._rgb.a*=1-e,this}greyscale(){const e=this._rgb,t=CM(.3*e.r+.59*e.g+.11*e.b);return e.r=e.g=e.b=t,this}opaquer(e){return this._rgb.a*=1+e,this}negate(){const e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return ZM(this._rgb,2,e),this}darken(e){return ZM(this._rgb,2,-e),this}saturate(e){return ZM(this._rgb,1,e),this}desaturate(e){return ZM(this._rgb,1,-e),this}rotate(e){return function(e,t){var n=UM(e);n[0]=qM(n[0]+t),n=HM(n),e.r=n[0],e.g=n[1],e.b=n[2]}(this._rgb,e),this}}function r_(){}const s_=(()=>{let e=0;return()=>e++})();function i_(e){return null===e||void 0===e}function o_(e){if(Array.isArray&&Array.isArray(e))return!0;const t=Object.prototype.toString.call(e);return"[object"===t.slice(0,7)&&"Array]"===t.slice(-6)}function l_(e){return null!==e&&"[object Object]"===Object.prototype.toString.call(e)}function c_(e){return("number"===typeof e||e instanceof Number)&&isFinite(+e)}function d_(e,t){return c_(e)?e:t}function u_(e,t){return"undefined"===typeof e?t:e}const m_=(e,t)=>"string"===typeof e&&e.endsWith("%")?parseFloat(e)/100*t:+e;function h_(e,t,n){if(e&&"function"===typeof e.call)return e.apply(n,t)}function p_(e,t,n,a){let r,s,i;if(o_(e))if(s=e.length,a)for(r=s-1;r>=0;r--)t.call(n,e[r],r);else for(r=0;r<s;r++)t.call(n,e[r],r);else if(l_(e))for(i=Object.keys(e),s=i.length,r=0;r<s;r++)t.call(n,e[i[r]],i[r])}function g_(e,t){let n,a,r,s;if(!e||!t||e.length!==t.length)return!1;for(n=0,a=e.length;n<a;++n)if(r=e[n],s=t[n],r.datasetIndex!==s.datasetIndex||r.index!==s.index)return!1;return!0}function x_(e){if(o_(e))return e.map(x_);if(l_(e)){const t=Object.create(null),n=Object.keys(e),a=n.length;let r=0;for(;r<a;++r)t[n[r]]=x_(e[n[r]]);return t}return e}function f_(e){return-1===["__proto__","prototype","constructor"].indexOf(e)}function b_(e,t,n,a){if(!f_(e))return;const r=t[e],s=n[e];l_(r)&&l_(s)?y_(r,s,a):t[e]=x_(s)}function y_(e,t,n){const a=o_(t)?t:[t],r=a.length;if(!l_(e))return e;const s=(n=n||{}).merger||b_;let i;for(let o=0;o<r;++o){if(i=a[o],!l_(i))continue;const t=Object.keys(i);for(let a=0,r=t.length;a<r;++a)s(t[a],e,i,n)}return e}function v_(e,t){return y_(e,t,{merger:w_})}function w_(e,t,n){if(!f_(e))return;const a=t[e],r=n[e];l_(a)&&l_(r)?v_(a,r):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=x_(r))}const k_={"":e=>e,x:e=>e.x,y:e=>e.y};function j_(e,t){const n=k_[t]||(k_[t]=function(e){const t=function(e){const t=e.split("."),n=[];let a="";for(const r of t)a+=r,a.endsWith("\\")?a=a.slice(0,-1)+".":(n.push(a),a="");return n}(e);return e=>{for(const n of t){if(""===n)break;e=e&&e[n]}return e}}(t));return n(e)}function D_(e){return e.charAt(0).toUpperCase()+e.slice(1)}const C_=e=>"undefined"!==typeof e,N_=e=>"function"===typeof e,F_=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};const S_=Math.PI,E_=2*S_,A_=E_+S_,T_=Number.POSITIVE_INFINITY,M_=S_/180,__=S_/2,B_=S_/4,I_=2*S_/3,P_=Math.log10,L_=Math.sign;function R_(e,t,n){return Math.abs(e-t)<n}function z_(e){const t=Math.round(e);e=R_(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(P_(e))),a=e/n;return(a<=1?1:a<=2?2:a<=5?5:10)*n}function O_(e){return!function(e){return"symbol"===typeof e||"object"===typeof e&&null!==e&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function U_(e,t,n){let a,r,s;for(a=0,r=e.length;a<r;a++)s=e[a][n],isNaN(s)||(t.min=Math.min(t.min,s),t.max=Math.max(t.max,s))}function V_(e){return e*(S_/180)}function H_(e){return e*(180/S_)}function q_(e){if(!c_(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function W_(e,t){const n=t.x-e.x,a=t.y-e.y,r=Math.sqrt(n*n+a*a);let s=Math.atan2(a,n);return s<-.5*S_&&(s+=E_),{angle:s,distance:r}}function Y_(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function G_(e,t){return(e-t+A_)%E_-S_}function K_(e){return(e%E_+E_)%E_}function X_(e,t,n,a){const r=K_(e),s=K_(t),i=K_(n),o=K_(s-r),l=K_(i-r),c=K_(r-s),d=K_(r-i);return r===s||r===i||a&&s===i||o>l&&c<d}function J_(e,t,n){return Math.max(t,Math.min(n,e))}function $_(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e-6;return e>=Math.min(t,n)-a&&e<=Math.max(t,n)+a}function Q_(e,t,n){n=n||(n=>e[n]<t);let a,r=e.length-1,s=0;for(;r-s>1;)a=s+r>>1,n(a)?s=a:r=a;return{lo:s,hi:r}}const Z_=(e,t,n,a)=>Q_(e,n,a?a=>{const r=e[a][t];return r<n||r===n&&e[a+1][t]===n}:a=>e[a][t]<n),eB=(e,t,n)=>Q_(e,n,a=>e[a][t]>=n);const tB=["push","pop","shift","splice","unshift"];function nB(e,t){const n=e._chartjs;if(!n)return;
vendor: 5,110 bytes, line 2
2const a=n.listeners,r=a.indexOf(t);-1!==r&&a.splice(r,1),a.length>0||(tB.forEach(t=>{delete e[t]}),delete e._chartjs)}function aB(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const rB="undefined"===typeof window?function(e){return e()}:window.requestAnimationFrame;function sB(e,t){let n=[],a=!1;return function(){for(var r=arguments.length,s=new Array(r),i=0;i<r;i++)s[i]=arguments[i];n=s,a||(a=!0,rB.call(window,()=>{a=!1,e.apply(t,n)}))}}const iB=e=>"start"===e?"left":"end"===e?"right":"center",oB=(e,t,n)=>"start"===e?t:"end"===e?n:(t+n)/2;function lB(e,t,n){const a=t.length;let r=0,s=a;if(e._sorted){const{iScale:i,vScale:o,_parsed:l}=e,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,d=i.axis,{min:u,max:m,minDefined:h,maxDefined:p}=i.getUserBounds();if(h){if(r=Math.min(Z_(l,d,u).lo,n?a:Z_(t,d,i.getPixelForValue(u)).lo),c){const e=l.slice(0,r+1).reverse().findIndex(e=>!i_(e[o.axis]));r-=Math.max(0,e)}r=J_(r,0,a-1)}if(p){let e=Math.max(Z_(l,i.axis,m,!0).hi+1,n?0:Z_(t,d,i.getPixelForValue(m),!0).hi+1);if(c){const t=l.slice(e-1).findIndex(e=>!i_(e[o.axis]));e+=Math.max(0,t)}s=J_(e,r,a)-r}else s=a-r}return{start:r,count:s}}function cB(e){const{xScale:t,yScale:n,_scaleRanges:a}=e,r={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!a)return e._scaleRanges=r,!0;const s=a.xmin!==t.min||a.xmax!==t.max||a.ymin!==n.min||a.ymax!==n.max;return Object.assign(a,r),s}const dB=e=>0===e||1===e,uB=(e,t,n)=>-Math.pow(2,10*(e-=1))*Math.sin((e-t)*E_/n),mB=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*E_/n)+1,hB={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>1-Math.cos(e*__),easeOutSine:e=>Math.sin(e*__),easeInOutSine:e=>-.5*(Math.cos(S_*e)-1),easeInExpo:e=>0===e?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>1===e?1:1-Math.pow(2,-10*e),easeInOutExpo:e=>dB(e)?e:e<.5?.5*Math.pow(2,10*(2*e-1)):.5*(2-Math.pow(2,-10*(2*e-1))),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>dB(e)?e:uB(e,.075,.3),easeOutElastic:e=>dB(e)?e:mB(e,.075,.3),easeInOutElastic(e){const t=.1125;return dB(e)?e:e<.5?.5*uB(2*e,t,.45):.5+.5*mB(2*e-1,t,.45)},easeInBack(e){const t=1.70158;return e*e*((t+1)*e-t)},easeOutBack(e){const t=1.70158;return(e-=1)*e*((t+1)*e+t)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?e*e*((1+(t*=1.525))*e-t)*.5:.5*((e-=2)*e*((1+(t*=1.525))*e+t)+2)},easeInBounce:e=>1-hB.easeOutBounce(1-e),easeOutBounce(e){const t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?.5*hB.easeInBounce(2*e):.5*hB.easeOutBounce(2*e-1)+.5};function pB(e){if(e&&"object"===typeof e){const t=e.toString();return"[object CanvasPattern]"===t||"[object CanvasGradient]"===t}return!1}function gB(e){return pB(e)?e:new a_(e)}function xB(e){return pB(e)?e:new a_(e).saturate(.5).darken(.1).hexString()}const fB=["x","y","borderWidth","radius","tension"],bB=["color","borderColor","backgroundColor"];const yB=new Map;function vB(e,t,n){return function(e,t){t=t||{};const n=e+JSON.stringify(t);let a=yB.get(n);return a||(a=new Intl.NumberFormat(e,t),yB.set(n,a)),a}(t,n).format(e)}const wB={values:e=>o_(e)?e:""+e,numeric(e,t,n){if(0===e)return"0";const a=this.chart.options.locale;let r,s=e;if(n.length>1){const t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>1e15)&&(r="scientific"),s=function(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e));return n}(e,n)}const i=P_(Math.abs(s)),o=isNaN(i)?1:Math.max(Math.min(-1*Math.floor(i),20),0),l={notation:r,minimumFractionDigits:o,maximumFractionDigits:o};return Object.assign(l,this.options.ticks.format),vB(e,a,l)},logarithmic(e,t,n){if(0===e)return"0";const a=n[t].significand||e/Math.pow(10,Math.floor(P_(e)));return[1,2,3,5,10,15].includes(a)||t>.8*n.length?wB.numeric.call(this,e,t,n):""}};var kB={formatters:wB};const jB=Object.create(null),DB=Object.create(null);function CB(e,t){if(!t)return e;const n=t.split(".");for(let a=0,r=n.length;a<r;++a){const t=n[a];e=e[t]||(e[t]=Object.create(null))}return e}function NB(e,t,n){return"string"===typeof t?y_(CB(e,t),n):y_(CB(e,""),t)}class FB{constructor(e,t){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=e=>e.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={}
vendor: 4,099 bytes, line 2
2,this.hoverBackgroundColor=(e,t)=>xB(t.backgroundColor),this.hoverBorderColor=(e,t)=>xB(t.borderColor),this.hoverColor=(e,t)=>xB(t.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return NB(this,e,t)}get(e){return CB(this,e)}describe(e,t){return NB(DB,e,t)}override(e,t){return NB(jB,e,t)}route(e,t,n,a){const r=CB(this,e),s=CB(this,n),i="_"+t;Object.defineProperties(r,{[i]:{value:r[t],writable:!0},[t]:{enumerable:!0,get(){const e=this[i],t=s[a];return l_(e)?Object.assign({},t,e):u_(e,t)},set(e){this[i]=e}}})}apply(e){e.forEach(e=>e(this))}}var SB=new FB({_scriptable:e=>!e.startsWith("on"),_indexable:e=>"events"!==e,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(e){e.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:e=>"onProgress"!==e&&"onComplete"!==e&&"fn"!==e}),e.set("animations",{colors:{type:"color",properties:bB},numbers:{type:"number",properties:fB}}),e.describe("animations",{_fallback:"animation"}),e.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:e=>0|e}}}})},function(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(e){e.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:kB.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),e.route("scale.ticks","color","","color"),e.route("scale.grid","color","","borderColor"),e.route("scale.border","color","","borderColor"),e.route("scale.title","color","","color"),e.describe("scale",{_fallback:!1,_scriptable:e=>!e.startsWith("before")&&!e.startsWith("after")&&"callback"!==e&&"parser"!==e,_indexable:e=>"borderDash"!==e&&"tickBorderDash"!==e&&"dash"!==e}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:e=>"backdropPadding"!==e&&"callback"!==e,_indexable:e=>"backdropPadding"!==e})}]);function EB(e,t,n,a,r){let s=t[r];return s||(s=t[r]=e.measureText(r).width,n.push(r)),s>a&&(a=s),a}function AB(e,t,n,a){let r=(a=a||{}).data=a.data||{},s=a.garbageCollect=a.garbageCollect||[];a.font!==t&&(r=a.data={},s=a.garbageCollect=[],a.font=t),e.save(),e.font=t;let i=0;const o=n.length;let l,c,d,u,m;for(l=0;l<o;l++)if(u=n[l],void 0===u||null===u||o_(u)){if(o_(u))for(c=0,d=u.length;c<d;c++)m=u[c],void 0===m||null===m||o_(m)||(i=EB(e,r,s,i,m))}else i=EB(e,r,s,i,u);e.restore();const h=s.length/2;if(h>n.length){for(l=0;l<h;l++)delete r[s[l]];s.splice(0,h)}return i}function TB(e,t,n){const a=e.currentDevicePixelRatio,r=0!==n?Math.max(n/2,.5):0;return Math.round((t-r)*a)/a+r}function MB(e,t){(t||e)&&((t=t||e.getContext("2d")).save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function _B(e,t,n,a){BB(e,t,n,a,null)}function BB(e,t,n,a,r){let s,i,o,l,c,d,u,m;const h=t.pointStyle,p=t.rotation,g=t.radius;let x=(p||0)*M_;if(h&&"object"===typeof h&&(s=h.toString(),"[object HTMLImageElement]"===s||"[object HTMLCanvasElement]"===s))return e.save(),e.translate(n,a),e.rotate(x),e.drawImage(h,-h.width/2,-h.height/2,h.width,h.height),void e.restore(
vendor: 4,542 bytes, line 2
2);if(!(isNaN(g)||g<=0)){switch(e.beginPath(),h){default:r?e.ellipse(n,a,r/2,g,0,0,E_):e.arc(n,a,g,0,E_),e.closePath();break;case"triangle":d=r?r/2:g,e.moveTo(n+Math.sin(x)*d,a-Math.cos(x)*g),x+=I_,e.lineTo(n+Math.sin(x)*d,a-Math.cos(x)*g),x+=I_,e.lineTo(n+Math.sin(x)*d,a-Math.cos(x)*g),e.closePath();break;case"rectRounded":c=.516*g,l=g-c,i=Math.cos(x+B_)*l,u=Math.cos(x+B_)*(r?r/2-c:l),o=Math.sin(x+B_)*l,m=Math.sin(x+B_)*(r?r/2-c:l),e.arc(n-u,a-o,c,x-S_,x-__),e.arc(n+m,a-i,c,x-__,x),e.arc(n+u,a+o,c,x,x+__),e.arc(n-m,a+i,c,x+__,x+S_),e.closePath();break;case"rect":if(!p){l=Math.SQRT1_2*g,d=r?r/2:l,e.rect(n-d,a-l,2*d,2*l);break}x+=B_;case"rectRot":u=Math.cos(x)*(r?r/2:g),i=Math.cos(x)*g,o=Math.sin(x)*g,m=Math.sin(x)*(r?r/2:g),e.moveTo(n-u,a-o),e.lineTo(n+m,a-i),e.lineTo(n+u,a+o),e.lineTo(n-m,a+i),e.closePath();break;case"crossRot":x+=B_;case"cross":u=Math.cos(x)*(r?r/2:g),i=Math.cos(x)*g,o=Math.sin(x)*g,m=Math.sin(x)*(r?r/2:g),e.moveTo(n-u,a-o),e.lineTo(n+u,a+o),e.moveTo(n+m,a-i),e.lineTo(n-m,a+i);break;case"star":u=Math.cos(x)*(r?r/2:g),i=Math.cos(x)*g,o=Math.sin(x)*g,m=Math.sin(x)*(r?r/2:g),e.moveTo(n-u,a-o),e.lineTo(n+u,a+o),e.moveTo(n+m,a-i),e.lineTo(n-m,a+i),x+=B_,u=Math.cos(x)*(r?r/2:g),i=Math.cos(x)*g,o=Math.sin(x)*g,m=Math.sin(x)*(r?r/2:g),e.moveTo(n-u,a-o),e.lineTo(n+u,a+o),e.moveTo(n+m,a-i),e.lineTo(n-m,a+i);break;case"line":i=r?r/2:Math.cos(x)*g,o=Math.sin(x)*g,e.moveTo(n-i,a-o),e.lineTo(n+i,a+o);break;case"dash":e.moveTo(n,a),e.lineTo(n+Math.cos(x)*(r?r/2:g),a+Math.sin(x)*g);break;case!1:e.closePath()}e.fill(),t.borderWidth>0&&e.stroke()}}function IB(e,t,n){return n=n||.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function PB(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function LB(e){e.restore()}function RB(e,t,n,a,r){if(!t)return e.lineTo(n.x,n.y);if("middle"===r){const a=(t.x+n.x)/2;e.lineTo(a,t.y),e.lineTo(a,n.y)}else"after"===r!==!!a?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function zB(e,t,n,a){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(a?t.cp1x:t.cp2x,a?t.cp1y:t.cp2y,a?n.cp2x:n.cp1x,a?n.cp2y:n.cp1y,n.x,n.y)}function OB(e,t,n,a,r){if(r.strikethrough||r.underline){const s=e.measureText(a),i=t-s.actualBoundingBoxLeft,o=t+s.actualBoundingBoxRight,l=n-s.actualBoundingBoxAscent,c=n+s.actualBoundingBoxDescent,d=r.strikethrough?(l+c)/2:c;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=r.decorationWidth||2,e.moveTo(i,d),e.lineTo(o,d),e.stroke()}}function UB(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function VB(e,t,n,a,r){let s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const i=o_(t)?t:[t],o=s.strokeWidth>0&&""!==s.strokeColor;let l,c;for(e.save(),e.font=r.string,function(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),i_(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}(e,s),l=0;l<i.length;++l)c=i[l],s.backdrop&&UB(e,s.backdrop),o&&(s.strokeColor&&(e.strokeStyle=s.strokeColor),i_(s.strokeWidth)||(e.lineWidth=s.strokeWidth),e.strokeText(c,n,a,s.maxWidth)),e.fillText(c,n,a,s.maxWidth),OB(e,n,a,c,s),a+=Number(r.lineHeight);e.restore()}function HB(e,t){const{x:n,y:a,w:r,h:s,radius:i}=t;e.arc(n+i.topLeft,a+i.topLeft,i.topLeft,1.5*S_,S_,!0),e.lineTo(n,a+s-i.bottomLeft),e.arc(n+i.bottomLeft,a+s-i.bottomLeft,i.bottomLeft,S_,__,!0),e.lineTo(n+r-i.bottomRight,a+s),e.arc(n+r-i.bottomRight,a+s-i.bottomRight,i.bottomRight,__,0,!0),e.lineTo(n+r,a+i.topRight),e.arc(n+r-i.topRight,a+i.topRight,i.topRight,0,-__,!0),e.lineTo(n+i.topLeft,a)}const qB=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,WB=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function YB(e,t){const n=(""+e).match(qB);if(!n||"normal"===n[1])return 1.2*t;switch(e=+n[2],n[3]){case"px":return e;case"%":e/=100}return t*e}const GB=e=>+e||0;function KB(e,t){const n={},a=l_(t),r=a?Object.keys(t):t,s=l_(e)?a?n=>u_(e[n],e[t[n]]):t=>e[t]:()=>e;for(const i of r)n[i]=GB(s(i));return n}function XB(e){return KB(e,{top:"y",right:"x",bottom:"y",left:"x"})}function JB(e){return KB(e,["topLeft","topRight","bottomLeft","bottomRight"])}function $B(e){const t=XB(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function QB(e,t){e=e||{},t=t||SB.font;let n=u_(e.size,t.size);"string"===typeof n&&(n=parseInt(n,10));let a=u_(e.style,t.style);a&&!(""+a).match(WB)&&(console.warn('Invalid font style specified: "'+a+'"'),a=void 0);
2const r={family:u_(e.family,t.family),lineHeight:YB(u_(e.lineHeight,t.lineHeight),n),size:n,style:a,weight:u_(e.weight,t.weight),string:""};return r.string=function(e){return!e||i_(e.size)||i_(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}(r),r}function ZB(e,t,n,a){let r,s,i,o=!0;for(r=0,s=e.length;r<s;++r)if(i=e[r],void 0!==i&&(void 0!==t&&"function"===typeof i&&(i=i(t),o=!1),void 0!==n&&o_(i)&&(i=i[n%i.length],o=!1),void 0!==i))return a&&!o&&(a.cacheable=!1),i}function eI(e,t){return Object.assign(Object.create(e),t)}function tI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[""],n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:()=>e[0];const r=(arguments.length>2?arguments[2]:void 0)||e;"undefined"===typeof n&&(n=mI("_fallback",e));const s={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:r,_fallback:n,_getTarget:a,override:a=>tI([a,...e],t,r,n)};return new Proxy(s,{deleteProperty:(t,n)=>(delete t[n],delete t._keys,delete e[0][n],!0),get:(n,a)=>iI(n,a,()=>function(e,t,n,a){let r;for(const s of t)if(r=mI(rI(s,e),n),"undefined"!==typeof r)return sI(e,r)?dI(n,a,e,r):r}(a,t,e,n)),getOwnPropertyDescriptor:(e,t)=>Reflect.getOwnPropertyDescriptor(e._scopes[0],t),getPrototypeOf:()=>Reflect.getPrototypeOf(e[0]),has:(e,t)=>hI(e).includes(t),ownKeys:e=>hI(e),set(e,t,n){const r=e._storage||(e._storage=a());return e[t]=r[t]=n,delete e._keys,!0}})}function nI(e,t,n,a){const r={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:aI(e,a),setContext:t=>nI(e,t,n,a),override:r=>nI(e.override(r),t,n,a)};return new Proxy(r,{deleteProperty:(t,n)=>(delete t[n],delete e[n],!0),get:(e,t,n)=>iI(e,t,()=>function(e,t,n){const{_proxy:a,_context:r,_subProxy:s,_descriptors:i}=e;let o=a[t];N_(o)&&i.isScriptable(t)&&(o=function(e,t,n,a){const{_proxy:r,_context:s,_subProxy:i,_stack:o}=n;if(o.has(e))throw new Error("Recursion detected: "+Array.from(o).join("->")+"->"+e);o.add(e);let l=t(s,i||a);o.delete(e),sI(e,l)&&(l=dI(r._scopes,r,e,l));return l}(t,o,e,n));o_(o)&&o.length&&(o=function(e,t,n,a){const{_proxy:r,_context:s,_subProxy:i,_descriptors:o}=n;if("undefined"!==typeof s.index&&a(e))return t[s.index%t.length];if(l_(t[0])){const n=t,a=r._scopes.filter(e=>e!==n);t=[];for(const l of n){const n=dI(a,r,e,l);t.push(nI(n,s,i&&i[e],o))}}return t}(t,o,e,i.isIndexable));sI(t,o)&&(o=nI(o,r,s&&s[t],i));return o}(e,t,n)),getOwnPropertyDescriptor:(t,n)=>t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n),getPrototypeOf:()=>Reflect.getPrototypeOf(e),has:(t,n)=>Reflect.has(e,n),ownKeys:()=>Reflect.ownKeys(e),set:(t,n,a)=>(e[n]=a,delete t[n],!0)})}function aI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{scriptable:!0,indexable:!0};const{_scriptable:n=t.scriptable,_indexable:a=t.indexable,_allKeys:r=t.allKeys}=e;return{allKeys:r,scriptable:n,indexable:a,isScriptable:N_(n)?n:()=>n,isIndexable:N_(a)?a:()=>a}}const rI=(e,t)=>e?e+D_(t):t,sI=(e,t)=>l_(t)&&"adapters"!==e&&(null===Object.getPrototypeOf(t)||t.constructor===Object);function iI(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||"constructor"===t)return e[t];const a=n();return e[t]=a,a}function oI(e,t,n){return N_(e)?e(t,n):e}const lI=(e,t)=>!0===e?t:"string"===typeof e?j_(t,e):void 0;function cI(e,t,n,a,r){for(const s of t){const t=lI(n,s);if(t){e.add(t);const s=oI(t._fallback,n,r);if("undefined"!==typeof s&&s!==n&&s!==a)return s}else if(!1===t&&"undefined"!==typeof a&&n!==a)return null}return!1}function dI(e,t,n,a){const r=t._rootScopes,s=oI(t._fallback,n,a),i=[...e,...r],o=new Set;o.add(a);let l=uI(o,i,n,s||n,a);return null!==l&&(("undefined"===typeof s||s===n||(l=uI(o,i,s,l,a),null!==l))&&tI(Array.from(o),[""],r,s,()=>function(e,t,n){const a=e._getTarget();t in a||(a[t]={});const r=a[t];if(o_(r)&&l_(n))return n;return r||{}}(t,n,a)))}function uI(e,t,n,a,r){for(;n;)n=cI(e,t,n,a,r);return n}function mI(e,t){for(const n of t){if(!n)continue;const t=n[e];if("undefined"!==typeof t)return t}}function hI(e){let t=e._keys;return t||(t=e._keys=function(e){const t=new Set;for(const n of e)for(const e of Object.keys(n).filter(e=>!e.startsWith("_")))t.add(e);return Array.from(t)}(e._scopes)),t}function pI(e,t,n,a){const{iScale:r}=e,{key:s="r"}=this._parsing,i=new Array(a);let o,l,c,d;for(o=0,l=a;o<l;++o)c=o+n,d=t[c],i[o]={r:r.parse(j_(d,s),c)};return i}const gI=Number.EPSILON||1e-14,xI=(e,t)=>t<e.length&&!e[t].skip&&e[t],fI=e=>"x"===e?"y":"x";function bI(e,t,n,a){const r=e.skip?t:e,s=t,i=n.skip?t:n,o=Y_(s,r),l=Y_(i,s);let c=o/(o+l),d=l/(o+l);c=isNaN(c)?0:c,d=isNaN(d)?0:d;const u=a*c,m=a*d;return{previous:{x:s.x-u*(i.x-r.x),y:s.y-u*(i.y-r.y)},next:{x:s.x+m*(i.x-r.x),y:s.y+m*(i.y-r.y)}}}function yI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"x";const n=fI(t),a=e.length,r=Array(a).fill(0),s=Array(a);let i,o,l,c=xI(e,0);for(i=0;i<a;++i)if(o=l,l=c,c=xI(e,i+1),l){if(c){const e=c[t]-l[t];r[i]=0!==e?(c[n]-l[n])/e:0}s[i]=o?c?L_(r[i-1])!==L_(r[i])?0:(r[i-1]+r[i])/2:r[i-1]:r[i]}!function(e,t,n){const a=e.length;let r,s,i,o,l,c=xI(e,0);for(let d=0;d<a-1;++d)l=c,c=xI(e,d+1),l&&c&&(R_(t[d],0,gI)?n[d]=n[d+1]=0:(r=n[d]/t[d],s=n[d+1]/t[d],o=Math.pow(r,2)+Math.pow(s,2),o<=9||(i=3/Math.sqrt(o),n[d]=r*i*t[d],n[d+1]=s*i*t[d])))}(e,r,s),function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"x";const a=fI(n),r=e.length;let s,i,o,l=xI(e,0);for(let c=0;c<r;++c){if(i=o,o=l,l=xI(e,c+1),!o)continue;const r=o[n],d=o[a];i&&(s=(r-i[n])/3,o["cp1".concat(n)]=r-s,o["cp1".concat(a)]=d-s*t[c]),l&&(s=(l[n]-r)/3,o["cp2".concat(n)]=r+s,o["cp2".concat(a)]=d+s*t[c])}}(e,s,t)}function vI(e,t,n){return Math.max(Math.min(e,n),t)}function wI(e,t,n,a,r){let s,i,o,l;if(t.spanGaps&&(e=e.filter(e=>!e.skip)),"monotone"===t.cubicInterpolationMode)yI(e,r);else{let n=a?e[e.length-1]:e[0];for(s=0,i=e.length;s<i;++s)o=e[s],l=bI(n,o,e[Math.min(s+1,i-(a?0:1))%i],t.tension),o.cp1x=l.previous.x,o.cp1y=l.previous.y,o.cp2x=l.next.x,o.cp2y=l.next.y,n=o}t.capBezierPoints&&function(e,t){let n,a,r,s,i,o=IB(e[0],t);for(n=0,a=e.length;n<a;++n)i=s,s=o,o=n<a-1&&IB(e[n+1],t),s&&(r=e[n],i&&(r.cp1x=vI(r.cp1x,t.left,t.right),r.cp1y=vI(r.cp1y,t.top,t.bottom)),o&&(r.cp2x=vI(r.cp2x,t.left,t.right),r.cp2y=vI(r.cp2y,t.top,t.bottom)))}
vendor: 11,091 bytes, line 2
2(e,n)}function kI(){return"undefined"!==typeof window&&"undefined"!==typeof document}function jI(e){let t=e.parentNode;return t&&"[object ShadowRoot]"===t.toString()&&(t=t.host),t}function DI(e,t,n){let a;return"string"===typeof e?(a=parseInt(e,10),-1!==e.indexOf("%")&&(a=a/100*t.parentNode[n])):a=e,a}const CI=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);const NI=["top","right","bottom","left"];function FI(e,t,n){const a={};n=n?"-"+n:"";for(let r=0;r<4;r++){const s=NI[r];a[s]=parseFloat(e[t+"-"+s+n])||0}return a.width=a.left+a.right,a.height=a.top+a.bottom,a}function SI(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:a}=t,r=CI(n),s="border-box"===r.boxSizing,i=FI(r,"padding"),o=FI(r,"border","width"),{x:l,y:c,box:d}=function(e,t){const n=e.touches,a=n&&n.length?n[0]:e,{offsetX:r,offsetY:s}=a;let i,o,l=!1;if(((e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot))(r,s,e.target))i=r,o=s;else{const e=t.getBoundingClientRect();i=a.clientX-e.left,o=a.clientY-e.top,l=!0}return{x:i,y:o,box:l}}(e,n),u=i.left+(d&&o.left),m=i.top+(d&&o.top);let{width:h,height:p}=t;return s&&(h-=i.width+o.width,p-=i.height+o.height),{x:Math.round((l-u)/h*n.width/a),y:Math.round((c-m)/p*n.height/a)}}const EI=e=>Math.round(10*e)/10;function AI(e,t,n,a){const r=CI(e),s=FI(r,"margin"),i=DI(r.maxWidth,e,"clientWidth")||T_,o=DI(r.maxHeight,e,"clientHeight")||T_,l=function(e,t,n){let a,r;if(void 0===t||void 0===n){const s=e&&jI(e);if(s){const e=s.getBoundingClientRect(),i=CI(s),o=FI(i,"border","width"),l=FI(i,"padding");t=e.width-l.width-o.width,n=e.height-l.height-o.height,a=DI(i.maxWidth,s,"clientWidth"),r=DI(i.maxHeight,s,"clientHeight")}else t=e.clientWidth,n=e.clientHeight}return{width:t,height:n,maxWidth:a||T_,maxHeight:r||T_}}(e,t,n);let{width:c,height:d}=l;if("content-box"===r.boxSizing){const e=FI(r,"border","width"),t=FI(r,"padding");c-=t.width+e.width,d-=t.height+e.height}c=Math.max(0,c-s.width),d=Math.max(0,a?c/a:d-s.height),c=EI(Math.min(c,i,l.maxWidth)),d=EI(Math.min(d,o,l.maxHeight)),c&&!d&&(d=EI(c/2));return(void 0!==t||void 0!==n)&&a&&l.height&&d>l.height&&(d=l.height,c=EI(Math.floor(d*a))),{width:c,height:d}}function TI(e,t,n){const a=t||1,r=Math.floor(e.height*a),s=Math.floor(e.width*a);e.height=Math.floor(e.height),e.width=Math.floor(e.width);const i=e.canvas;return i.style&&(n||!i.style.height&&!i.style.width)&&(i.style.height="".concat(e.height,"px"),i.style.width="".concat(e.width,"px")),(e.currentDevicePixelRatio!==a||i.height!==r||i.width!==s)&&(e.currentDevicePixelRatio=a,i.height=r,i.width=s,e.ctx.setTransform(a,0,0,a,0,0),!0)}const MI=function(){let e=!1;try{const t={get passive(){return e=!0,!1}};kI()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch(BH){}return e}();function _I(e,t){const n=function(e,t){return CI(e).getPropertyValue(t)}(e,t),a=n&&n.match(/^(\d+)(\.\d+)?px$/);return a?+a[1]:void 0}function BI(e,t,n,a){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function II(e,t,n,a){return{x:e.x+n*(t.x-e.x),y:"middle"===a?n<.5?e.y:t.y:"after"===a?n<1?e.y:t.y:n>0?t.y:e.y}}function PI(e,t,n,a){const r={x:e.cp2x,y:e.cp2y},s={x:t.cp1x,y:t.cp1y},i=BI(e,r,n),o=BI(r,s,n),l=BI(s,t,n),c=BI(i,o,n),d=BI(o,l,n);return BI(c,d,n)}function LI(e,t,n){return e?function(e,t){return{x:n=>e+e+t-n,setWidth(e){t=e},textAlign:e=>"center"===e?e:"right"===e?"left":"right",xPlus:(e,t)=>e-t,leftForLtr:(e,t)=>e-t}}(t,n):{x:e=>e,setWidth(e){},textAlign:e=>e,xPlus:(e,t)=>e+t,leftForLtr:(e,t)=>e}}function RI(e,t){let n,a;"ltr"!==t&&"rtl"!==t||(n=e.canvas.style,a=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=a)}function zI(e,t){void 0!==t&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function OI(e){return"angle"===e?{between:X_,compare:G_,normalize:K_}:{between:$_,compare:(e,t)=>e-t,normalize:e=>e}}function UI(e){let{start:t,end:n,count:a,loop:r,style:s}=e;return{start:t%a,end:n%a,loop:r&&(n-t+1)%a===0,style:s}}function VI(e,t,n){if(!n)return[e];const{property:a,start:r,end:s}=n,i=t.length,{compare:o,between:l,normalize:c}=OI(a),{start:d,end:u,loop:m,style:h}=function(e,t,n){const{property:a,start:r,end:s}=n,{between:i,normalize:o}=OI(a),l=t.length;let c,d,{start:u,end:m,loop:h}=e;if(h){for(u+=l,m+=l,c=0,d=l;c<d&&i(o(t[u%l][a]),r,s);++c)u--,m--;u%=l,m%=l}return m<u&&(m+=l),{start:u,end:m,loop:h,style:e.style}}(e,t,n),p=[];let g,x,f,b=!1,y=null;const v=()=>b||l(r,f,g)&&0!==o(r,f),w=()=>!b||0===o(s,g)||l(s,f,g);for(let k=d,j=d;k<=u;++k)x=t[k%i],x.skip||(g=c(x[a]),g!==f&&(b=l(g,r,s),null===y&&v()&&(y=0===o(g,r)?k:j),null!==y&&w()&&(p.push(UI({start:y,end:k,loop:m,count:i,style:h})),y=null),j=k,f=g));return null!==y&&p.push(UI({start:y,end:u,loop:m,count:i,style:h})),p}function HI(e,t){const n=[],a=e.segments;for(let r=0;r<a.length;r++){const s=VI(a[r],e.points,t);s.length&&n.push(...s)}return n}function qI(e,t,n,a){return a&&a.setContext&&n?function(e,t,n,a){const r=e._chart.getContext(),s=WI(e.options),{_datasetIndex:i,options:{spanGaps:o}}=e,l=n.length,c=[];let d=s,u=t[0].start,m=u;function h(e,t,a,r){const s=o?-1:1;if(e!==t){for(e+=l;n[e%l].skip;)e-=s;for(;n[t%l].skip;)t+=s;e%l!==t%l&&(c.push({start:e%l,end:t%l,loop:a,style:r}),d=r,u=t%l)}}for(const p of t){u=o?u:p.start;let e,t=n[u%l];for(m=u+1;m<=p.end;m++){const s=n[m%l];e=WI(a.setContext(eI(r,{type:"segment",p0:t,p1:s,p0DataIndex:(m-1)%l,p1DataIndex:m%l,datasetIndex:i}))),YI(e,d)&&h(u,m-1,p.loop,d),t=s,d=e}u<m-1&&h(u,m-1,p.loop,d)}return c}(e,t,n,a):t}function WI(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function YI(e,t){if(!t)return!1;const n=[],a=function(e,t){return pB(t)?(n.includes(t)||n.push(t),n.indexOf(t)):t};return JSON.stringify(e,a)!==JSON.stringify(t,a)}function GI(e,t,n){return e.options.clip?e[n]:t[n]}function KI(e,t){const n=t._clip;if(n.disabled)return!1;const a=function(e,t){const{xScale:n,yScale:a}=e;return n&&a?{left:GI(n,t,"left"),right:GI(n,t,"right"),top:GI(a,t,"top"),bottom:GI(a,t,"bottom")}:t}(t,e.chartArea);return{left:!1===n.left?0:a.left-(!0===n.left?0:n.left),right:!1===n.right?e.width:a.right+(!0===n.right?0:n.right),top:!1===n.top?0:a.top-(!0===n.top?0:n.top),bottom:!1===n.bottom?e.height:a.bottom+(!0===n.bottom?0:n.bottom)}}class XI{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(e,t,n,a){const r=t.listeners[a],s=t.duration;r.forEach(a=>a({chart:e,initial:t.initial,numSteps:s,currentStep:Math.min(n-t.start,s)}))}_refresh(){this._request||(this._running=!0,this._request=rB.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Date.now(),t=0;this._charts.forEach((n,a)=>{if(!n.running||!n.items.length)return;const r=n.items;let s,i=r.length-1,o=!1;for(;i>=0;--i)s=r[i],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(r[i]=r[r.length-1],r.pop());o&&(a.draw(),this._notify(a,n,e,"progress")),r.length||(n.running=!1,this._notify(a,n,e,"complete"),n.initial=!1),t+=r.length}),this._lastDate=e,0===t&&(this._running=!1)}_getAnims(e){const t=this._charts;let n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){t&&t.length&&this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){const t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;const t=this._charts.get(e);return!!(t&&t.running&&t.items.length)}stop(e){const t=this._charts.get(e);if(!t||!t.items.length)return;const n=t.items;let a=n.length-1;for(;a>=0;--a)n[a].cancel();t.items=[],this._notify(e,t,Date.now(),"complete")}remove(e){return this._charts.delete(e)}}var JI=new XI;const $I="transparent",QI={boolean:(e,t,n)=>n>.5?t:e,color(e,t,n){const a=gB(e||$I),r=a.valid&&gB(t||$I);return r&&r.valid?r.mix(a,n).hexString():t},number:(e,t,n)=>e+(t-e)*n};class ZI{constructor(e,t,n,a){const r=t[n];a=ZB([e.to,a,r,e.from]);const s=ZB([e.from,r,a]);this._active=!0,this._fn=e.fn||QI[e.type||typeof s],this._easing=hB[e.easing]||hB.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=s,this._to=a,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);const a=this._target[this._prop],r=n-this._start,s=this._duration-r;this._start=n,this._duration=Math.floor(Math.max(s,e.duration)),this._total+=r,this._loop=!!e.loop,this._to=ZB([e.to,t,a,e.from]),this._from=ZB([e.from,a,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){const t=e-this._start,n=this._duration,a=this._prop,r=this._from,s=this._loop,i=this._to;let o;if(this._active=r!==i&&(s||t<n),!this._active)return this._target[a]=i,void this._notify(!0);t<0?this._target[a]=r:(o=t/n%2,o=s&&o>1?2-o:o,o=this._easing(Math.min(1,Math.max(0,o))),this._target[a]=this._fn(r,i,o))}wait(){const e=this._promises||(this._promises=[]);return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){const t=e?"res":"rej",n=this._promises||[];for(let a=0;a<n.length;a++)n[a][t]()}}class eP{constructor(e,t){this._chart=e,this._properties=new Map,this.configure(t)}configure(e){if(!l_(e))return;const t=Object.keys(SB.animation),n=this._properties;Object.getOwnPropertyNames(e).forEach(a=>{const r=e[a];if(!l_(r))return;const s={};for(const e of t)s[e]=r[e];(o_(r.properties)&&r.properties||[a]).forEach(e=>{e!==a&&n.has(e)||n.set(e,s)})})}_animateOptions(e,t){const n=t.options,a=function(e,t){if(!t)return;let n=e.options;if(!n)return void(e.options=t);n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}}));return n}(e,n);if(!a)return[];const r=this._createAnimations(a,n);return n.$shared&&function(e,t){const n=[],a=Object.keys(t);for(let r=0;r<a.length;r++){const t=e[a[r]];t&&t.active()&&n.push(t.wait())}return Promise.all(n)}(e.options.$animations,n).then(()=>{e.options=n},()=>{}),r}_createAnimations(e,t){const n=this._properties,a=[],r=e.$animations||(e.$animations={}),s=Object.keys(t),i=Date.now();let o;for(o=s.length-1;o>=0;--o){const l=s[o];if("$"===l.charAt(0))continue;if("options"===l){a.push(...this._animateOptions(e,t));continue}const c=t[l];let d=r[l];const u=n.get(l);if(d){if(u&&d.active()){d.update(u,c,i);continue}d.cancel()}u&&u.duration?(r[l]=d=new ZI(u,e,l,c),a.push(d)):e[l]=c}return a}update(e,t){if(0===this._properties.size)return void Object.assign(e,t);const n=this._createAnimations(e,t);return n.length?(JI.add(this._chart,n),!0):void 0}}function tP(e,t){const n=e&&e.options||{},a=n.reverse,r=void 0===n.min?t:0,s=void 0===n.max?t:0;return{start:a?s:r,end:a?r:s}}
2function nP(e,t){const n=[],a=e._getSortedDatasetMetas(t);let r,s;for(r=0,s=a.length;r<s;++r)n.push(a[r].index);return n}function aP(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=e.keys,s="single"===a.mode;let i,o,l,c;if(null===t)return;let d=!1;for(i=0,o=r.length;i<o;++i){if(l=+r[i],l===n){if(d=!0,a.all)continue;break}c=e.values[l],c_(c)&&(s||0===t||L_(t)===L_(c))&&(t+=c)}return d||a.all?t:0}function rP(e,t){const n=e&&e.options.stacked;return n||void 0===n&&void 0!==t.stack}function sP(e,t,n){const a=e[t]||(e[t]={});return a[n]||(a[n]={})}function iP(e,t,n,a){for(const r of t.getMatchingVisibleMetas(a).reverse()){const t=e[r.index];if(n&&t>0||!n&&t<0)return r.index}return null}function oP(e,t){const{chart:n,_cachedMeta:a}=e,r=n._stacks||(n._stacks={}),{iScale:s,vScale:i,index:o}=a,l=s.axis,c=i.axis,d=function(e,t,n){return"".concat(e.id,".").concat(t.id,".").concat(n.stack||n.type)}(s,i,a),u=t.length;let m;for(let h=0;h<u;++h){const e=t[h],{[l]:n,[c]:s}=e;m=(e._stacks||(e._stacks={}))[c]=sP(r,d,n),m[o]=s,m._top=iP(m,i,!0,a.type),m._bottom=iP(m,i,!1,a.type);(m._visualValues||(m._visualValues={}))[o]=s}}function lP(e,t){const n=e.scales;return Object.keys(n).filter(e=>n[e].axis===t).shift()}function cP(e,t){const n=e.controller.index,a=e.vScale&&e.vScale.axis;if(a){t=t||e._parsed;for(const e of t){const t=e._stacks;if(!t||void 0===t[a]||void 0===t[a][n])return;delete t[a][n],void 0!==t[a]._visualValues&&void 0!==t[a]._visualValues[n]&&delete t[a]._visualValues[n]}}}const dP=e=>"reset"===e||"none"===e,uP=(e,t)=>t?e:Object.assign({},e);class mP{constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=rP(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(e){this.index!==e&&cP(this._cachedMeta),this.index=e}linkScales(){const e=this.chart,t=this._cachedMeta,n=this.getDataset(),a=(e,t,n,a)=>"x"===e?t:"r"===e?a:n,r=t.xAxisID=u_(n.xAxisID,lP(e,"x")),s=t.yAxisID=u_(n.yAxisID,lP(e,"y")),i=t.rAxisID=u_(n.rAxisID,lP(e,"r")),o=t.indexAxis,l=t.iAxisID=a(o,r,s,i),c=t.vAxisID=a(o,s,r,i);t.xScale=this.getScaleForId(r),t.yScale=this.getScaleForId(s),t.rScale=this.getScaleForId(i),t.iScale=this.getScaleForId(l),t.vScale=this.getScaleForId(c)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){const t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update("reset")}_destroy(){const e=this._cachedMeta;this._data&&nB(this._data,this),e._stacked&&cP(e)}_dataCheck(){const e=this.getDataset(),t=e.data||(e.data=[]),n=this._data;if(l_(t)){const e=this._cachedMeta;this._data=function(e,t){const{iScale:n,vScale:a}=t,r="x"===n.axis?"x":"y",s="x"===a.axis?"x":"y",i=Object.keys(e),o=new Array(i.length);let l,c,d;for(l=0,c=i.length;l<c;++l)d=i[l],o[l]={[r]:d,[s]:e[d]};return o}(t,e)}else if(n!==t){if(n){nB(n,this);const e=this._cachedMeta;cP(e),e._parsed=[]}t&&Object.isExtensible(t)&&(r=this,(a=t)._chartjs?a._chartjs.listeners.push(r):(Object.defineProperty(a,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[r]}}),tB.forEach(e=>{const t="_onData"+D_(e),n=a[e];Object.defineProperty(a,e,{configurable:!0,enumerable:!1,value(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];const i=n.apply(this,r);
2return a._chartjs.listeners.forEach(e=>{"function"===typeof e[t]&&e[t](...r)}),i}})}))),this._syncList=[],this._data=t}var a,r}addElements(){const e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){const t=this._cachedMeta,n=this.getDataset();let a=!1;this._dataCheck();const r=t._stacked;t._stacked=rP(t.vScale,t),t.stack!==n.stack&&(a=!0,cP(t),t.stack=n.stack),this._resyncElements(e),(a||r!==t._stacked)&&(oP(this,t._parsed),t._stacked=rP(t.vScale,t))}configure(){const e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){const{_cachedMeta:n,_data:a}=this,{iScale:r,_stacked:s}=n,i=r.axis;let o,l,c,d=0===e&&t===a.length||n._sorted,u=e>0&&n._parsed[e-1];if(!1===this._parsing)n._parsed=a,n._sorted=!0,c=a;else{c=o_(a[e])?this.parseArrayData(n,a,e,t):l_(a[e])?this.parseObjectData(n,a,e,t):this.parsePrimitiveData(n,a,e,t);const r=()=>null===l[i]||u&&l[i]<u[i];for(o=0;o<t;
vendor: 10,953 bytes, line 2
2++o)n._parsed[o+e]=l=c[o],d&&(r()&&(d=!1),u=l);n._sorted=d}s&&oP(this,c)}parsePrimitiveData(e,t,n,a){const{iScale:r,vScale:s}=e,i=r.axis,o=s.axis,l=r.getLabels(),c=r===s,d=new Array(a);let u,m,h;for(u=0,m=a;u<m;++u)h=u+n,d[u]={[i]:c||r.parse(l[h],h),[o]:s.parse(t[h],h)};return d}parseArrayData(e,t,n,a){const{xScale:r,yScale:s}=e,i=new Array(a);let o,l,c,d;for(o=0,l=a;o<l;++o)c=o+n,d=t[c],i[o]={x:r.parse(d[0],c),y:s.parse(d[1],c)};return i}parseObjectData(e,t,n,a){const{xScale:r,yScale:s}=e,{xAxisKey:i="x",yAxisKey:o="y"}=this._parsing,l=new Array(a);let c,d,u,m;for(c=0,d=a;c<d;++c)u=c+n,m=t[u],l[c]={x:r.parse(j_(m,i),u),y:s.parse(j_(m,o),u)};return l}getParsed(e){return this._cachedMeta._parsed[e]}getDataElement(e){return this._cachedMeta.data[e]}applyStack(e,t,n){const a=this.chart,r=this._cachedMeta,s=t[e.axis];return aP({keys:nP(a,!0),values:t._stacks[e.axis]._visualValues},s,r.index,{mode:n})}updateRangeFromParsed(e,t,n,a){const r=n[t.axis];let s=null===r?NaN:r;const i=a&&n._stacks[t.axis];a&&i&&(a.values=i,s=aP(a,r,this._cachedMeta.index)),e.min=Math.min(e.min,s),e.max=Math.max(e.max,s)}getMinMax(e,t){const n=this._cachedMeta,a=n._parsed,r=n._sorted&&e===n.iScale,s=a.length,i=this._getOtherScale(e),o=((e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:nP(n,!0),values:null})(t,n,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:c,max:d}=function(e){const{min:t,max:n,minDefined:a,maxDefined:r}=e.getUserBounds();return{min:a?t:Number.NEGATIVE_INFINITY,max:r?n:Number.POSITIVE_INFINITY}}(i);let u,m;function h(){m=a[u];const t=m[i.axis];return!c_(m[e.axis])||c>t||d<t}for(u=0;u<s&&(h()||(this.updateRangeFromParsed(l,e,m,o),!r));++u);if(r)for(u=s-1;u>=0;--u)if(!h()){this.updateRangeFromParsed(l,e,m,o);break}return l}getAllParsedValues(e){const t=this._cachedMeta._parsed,n=[];let a,r,s;for(a=0,r=t.length;a<r;++a)s=t[a][e.axis],c_(s)&&n.push(s);return n}getMaxOverflow(){return!1}getLabelAndValue(e){const t=this._cachedMeta,n=t.iScale,a=t.vScale,r=this.getParsed(e);return{label:n?""+n.getLabelForValue(r[n.axis]):"",value:a?""+a.getLabelForValue(r[a.axis]):""}}_update(e){const t=this._cachedMeta;this.update(e||"default"),t._clip=function(e){let t,n,a,r;return l_(e)?(t=e.top,n=e.right,a=e.bottom,r=e.left):t=n=a=r=e,{top:t,right:n,bottom:a,left:r,disabled:!1===e}}(u_(this.options.clip,function(e,t,n){if(!1===n)return!1;const a=tP(e,n),r=tP(t,n);return{top:r.end,right:a.end,bottom:r.start,left:a.start}}(t.xScale,t.yScale,this.getMaxOverflow())))}update(e){}draw(){const e=this._ctx,t=this.chart,n=this._cachedMeta,a=n.data||[],r=t.chartArea,s=[],i=this._drawStart||0,o=this._drawCount||a.length-i,l=this.options.drawActiveElementsOnTop;let c;for(n.dataset&&n.dataset.draw(e,r,i,o),c=i;c<i+o;++c){const t=a[c];t.hidden||(t.active&&l?s.push(t):t.draw(e,r))}for(c=0;c<s.length;++c)s[c].draw(e,r)}getStyle(e,t){const n=t?"active":"default";return void 0===e&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(n):this.resolveDataElementOptions(e||0,n)}getContext(e,t,n){const a=this.getDataset();let r;if(e>=0&&e<this._cachedMeta.data.length){const t=this._cachedMeta.data[e];r=t.$context||(t.$context=function(e,t,n){return eI(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}(this.getContext(),e,t)),r.parsed=this.getParsed(e),r.raw=a.data[e],r.index=r.dataIndex=e}else r=this.$context||(this.$context=function(e,t){return eI(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}(this.chart.getContext(),this.index)),r.dataset=a,r.index=r.datasetIndex=this.index;return r.active=!!t,r.mode=n,r}resolveDatasetElementOptions(e){return this._resolveElementOptions(this.datasetElementType.id,e)}resolveDataElementOptions(e,t){return this._resolveElementOptions(this.dataElementType.id,t,e)}_resolveElementOptions(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default",n=arguments.length>2?arguments[2]:void 0;const a="active"===t,r=this._cachedDataOpts,s=e+"-"+t,i=r[s],o=this.enableOptionSharing&&C_(n);if(i)return uP(i,o);const l=this.chart.config,c=l.datasetElementScopeKeys(this._type,e),d=a?["".concat(e,"Hover"),"hover",e,""]:[e,""],u=l.getOptionScopes(this.getDataset(),c),m=Object.keys(SB.elements[e]),h=l.resolveNamedOptions(u,m,()=>this.getContext(n,a,t),d);return h.$shared&&(h.$shared=o,r[s]=Object.freeze(uP(h,o))),h}_resolveAnimations(e,t,n){const a=this.chart,r=this._cachedDataOpts,s="animation-".concat(t),i=r[s];if(i)return i;let o;if(!1!==a.options.animation){const a=this.chart.config,r=a.datasetAnimationScopeKeys(this._type,t),s=a.getOptionScopes(this.getDataset(),r);o=a.createResolver(s,this.getContext(e,n,t))}const l=new eP(a,o&&o.animations);return o&&o._cacheable&&(r[s]=Object.freeze(l)),l}getSharedOptions(e){if(e.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},e))}includeOptions(e,t){return!t||dP(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){const n=this.resolveDataElementOptions(e,t),a=this._sharedOptions,r=this.getSharedOptions(n),s=this.includeOptions(t,r)||r!==a;return this.updateSharedOptions(r,t,n),{sharedOptions:r,includeOptions:s}}updateElement(e,t,n,a){dP(a)?Object.assign(e,n):this._resolveAnimations(t,a).update(e,n)}updateSharedOptions(e,t,n){e&&!dP(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,a){e.active=a;const r=this.getStyle(t,a);this._resolveAnimations(t,n,a).update(e,{options:!a&&this.getSharedOptions(r)||r})}removeHoverStyle(e,t,n){this._setStyle(e,n,"active",!1)}setHoverStyle(e,t,n){this._setStyle(e,n,"active",!0)}_removeDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!1)}_setDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!0)}_resyncElements(e){const t=this._data,n=this._cachedMeta.data;for(const[i,o,l]of this._syncList)this[i](o,l);this._syncList=[];const a=n.length,r=t.length,s=Math.min(r,a);s&&this.parse(0,s),r>a?this._insertElements(a,r-a,e):r<a&&this._removeElements(r,a-r)}_insertElements(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const a=this._cachedMeta,r=a.data,s=e+t;let i;const o=e=>{for(e.length+=t,i=e.length-1;i>=s;i--)e[i]=e[i-t]};for(o(r),i=e;i<s;++i)r[i]=new this.dataElementType;this._parsing&&o(a._parsed),this.parse(e,t),n&&this.updateElements(r,e,t,"reset")}updateElements(e,t,n,a){}_removeElements(e,t){const n=this._cachedMeta;if(this._parsing){const a=n._parsed.splice(e,t);n._stacked&&cP(n,a)}n.data.splice(e,t)}_sync(e){if(this._parsing)this._syncList.push(e);else{const[t,n,a]=e;this[t](n,a)}this.chart._dataChanges.push([this.index,...e])}_onDataPush(){const e=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-e,e])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(e,t){t&&this._sync(["_removeElements",e,t]);const n=arguments.length-2;n&&this._sync(["_insertElements",e,n])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function hP(e){const t=e.iScale,n=function(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let a=[];for(let t=0,r=n.length;t<r;t++)a=a.concat(n[t].controller.getAllParsedValues(e));e._cache.$bar=aB(a.sort((e,t)=>e-t))}return e._cache.$bar}(t,e.type);let a,r,s,i,o=t._length;const l=()=>{32767!==s&&-32768!==s&&(C_(i)&&(o=Math.min(o,Math.abs(s-i)||o)),i=s)};for(a=0,r=n.length;a<r;++a)s=t.getPixelForValue(n[a]),l();for(i=void 0,a=0,r=t.ticks.length;a<r;++a)s=t.getPixelForTick(a),l();return o}function pP(e,t,n,a){return o_(e)?function(e,t,n,a){const r=n.parse(e[0],a),s=n.parse(e[1],a),i=Math.min(r,s),o=Math.max(r,s);let l=i,c=o;Math.abs(i)>Math.abs(o)&&(l=o,c=i),t[n.axis]=c,t._custom={barStart:l,barEnd:c,start:r,end:s,min:i,max:o}}(e,t,n,a):t[n.axis]=n.parse(e,a),t}function gP(e,t,n,a){const r=e.iScale,s=e.vScale,i=r.getLabels(),o=r===s,l=[];let c,d,u,m;for(c=n,d=n+a;c<d;++c)m=t[c],u={},u[r.axis]=o||r.parse(i[c],c),l.push(pP(m,u,s,c));return l}function xP(e){return e&&void 0!==e.barStart&&void 0!==e.barEnd}function fP(e,t,n,a){let r=t.borderSkipped;const s={};if(!r)return void(e.borderSkipped=s);if(!0===r)return void(e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0});const{start:i,end:o,reverse:l,top:c,bottom:d}=function(e){let t,n,a,r,s;return e.horizontal?(t=e.base>e.x,n="left",a="right"):(t=e.base<e.y,n="bottom",a="top"),t?(r="end",s="start"):(r="start",s="end"),{start:n,end:a,reverse:t,top:r,bottom:s}}(e);"middle"===r&&n&&(e.enableBorderRadius=!0,(n._top||0)===a?r=c:(n._bottom||0)===a?r=d:(s[bP(d,i,o,l)]=!0,r=c)),s[bP(r,i,o,l)]=!0,e.borderSkipped=s}function bP(e,t,n,a){var r,s,i;return a?(i=n,e=yP(e=(r=e)===(s=t)?i:r===i?s:r,n,t)):e=yP(e,t,n),e}function yP(e,t,n){return"start"===e?t:"end"===e?n:e}function vP(e,t,n){let{inflateAmount:a}=t;e.inflateAmount="auto"===a?1===n?.33:0:a}l(mP,"defaults",{}),l(mP,"datasetElementType",null),l(mP,"dataElementType",null);class wP extends mP{parsePrimitiveData(e,t,n,a){return gP(e,t,n,a)}parseArrayData(e,t,n,a){return gP(e,t,n,a)}parseObjectData(e,t,n,a){const{iScale:r,vScale:s}=e,{xAxisKey:i="x",yAxisKey:o="y"}=this._parsing,l="x"===r.axis?i:o,c="x"===s.axis?i:o,d=[];let u,m,h,p;for(u=n,m=n+a;u<m;++u)p=t[u],h={},h[r.axis]=r.parse(j_(p,l),u),d.push(pP(j_(p,c),h,s,u));return d}updateRangeFromParsed(e,t,n,a){super.updateRangeFromParsed(e,t,n,a);const r=n._custom;r&&t===this._cachedMeta.vScale&&(e.min=Math.min(e.min,r.min),e.max=Math.max(e.max,r.max))}getMaxOverflow(){return 0}getLabelAndValue(e){const t=this._cachedMeta,{iScale:n,vScale:a}=t,r=this.getParsed(e),s=r._custom,i=xP(s)?"["+s.start+", "+s.end+"]":""+a.getLabelForValue(r[a.axis]);return{label:""+n.getLabelForValue(r[n.axis]),value:i}}initialize(){this.enableOptionSharing=!0,super.initialize();this._cachedMeta.stack=this.getDataset().stack}update(e){const t=this._cachedMeta;this.updateElements(t.data,0,t.data.length,e)}updateElements(e,t,n,a){const r="reset"===a,{index:s,_cachedMeta:{vScale:i}}=this,o=i.getBasePixel(),l=i.isHorizontal(),c=this._getRuler(),{sharedOptions:d,includeOptions:u}=this._getSharedOptions(t,a);for(let m=t;m<t+n;m++){const t=this.getParsed(m),n=r||i_(t[i.axis])?{base:o,head:o}:this._calculateBarValuePixels(m),h=this._calculateBarIndexPixels(m,c),p=(t._stacks||{})[i.axis],g={horizontal:l,base:n.base,enableBorderRadius:!p||xP(t._custom)||s===p._top||s===p._bottom,x:l?n.head:h.center,y:l?h.center:n.head,height:l?h.size:Math.abs(n.size),width:l?Math.abs(n.size):h.size};u&&(g.options=d||this.resolveDataElementOptions(m,e[m].active?"active":a));const x=g.options||e[m].options;fP(g,x,p,s),vP(g,x,c.ratio),this.updateElement(e[m],m,g,a)}}_getStacks(e,t){const{iScale:n}=this._cachedMeta,a=n.getMatchingVisibleMetas(this._type).filter(e=>e.controller.options.grouped),r=n.options.stacked,s=[],i=this._cachedMeta.controller.getParsed(t),o=i&&i[n.axis],l=e=>{const t=e._parsed.find(e=>
vendor: 5,362 bytes, line 2
2e[n.axis]===o),a=t&&t[e.vScale.axis];if(i_(a)||isNaN(a))return!0};for(const c of a)if((void 0===t||!l(c))&&((!1===r||-1===s.indexOf(c.stack)||void 0===r&&void 0===c.stack)&&s.push(c.stack),c.index===e))break;return s.length||s.push(void 0),s}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){const e={},t=this.getFirstScaleIdForIndexAxis();for(const n of this.chart.data.datasets)e[u_("x"===this.chart.options.indexAxis?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){const a=this._getStacks(e,n),r=void 0!==t?a.indexOf(t):-1;return-1===r?a.length-1:r}_getRuler(){const e=this.options,t=this._cachedMeta,n=t.iScale,a=[];let r,s;for(r=0,s=t.data.length;r<s;++r)a.push(n.getPixelForValue(this.getParsed(r)[n.axis],r));const i=e.barThickness;return{min:i||hP(t),pixels:a,start:n._startPixel,end:n._endPixel,stackCount:this._getStackCount(),scale:n,grouped:e.grouped,ratio:i?1:e.categoryPercentage*e.barPercentage}}_calculateBarValuePixels(e){const{_cachedMeta:{vScale:t,_stacked:n,index:a},options:{base:r,minBarLength:s}}=this,i=r||0,o=this.getParsed(e),l=o._custom,c=xP(l);let d,u,m=o[t.axis],h=0,p=n?this.applyStack(t,o,n):m;p!==m&&(h=p-m,p=m),c&&(m=l.barStart,p=l.barEnd-l.barStart,0!==m&&L_(m)!==L_(l.barEnd)&&(h=0),h+=m);const g=i_(r)||c?h:r;let x=t.getPixelForValue(g);if(d=this.chart.getDataVisibility(e)?t.getPixelForValue(h+p):x,u=d-x,Math.abs(u)<s){u=function(e,t,n){return 0!==e?L_(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}(u,t,i)*s,m===i&&(x-=u/2);const e=t.getPixelForDecimal(0),r=t.getPixelForDecimal(1),l=Math.min(e,r),h=Math.max(e,r);x=Math.max(Math.min(x,h),l),d=x+u,n&&!c&&(o._stacks[t.axis]._visualValues[a]=t.getValueForPixel(d)-t.getValueForPixel(x))}if(x===t.getPixelForValue(i)){const e=L_(u)*t.getLineWidthForValue(i)/2;x+=e,u-=e}return{size:u,base:x,head:d,center:d+u/2}}_calculateBarIndexPixels(e,t){const n=t.scale,a=this.options,r=a.skipNull,s=u_(a.maxBarThickness,1/0);let i,o;const l=this._getAxisCount();if(t.grouped){const n=r?this._getStackCount(e):t.stackCount,c="flex"===a.barThickness?function(e,t,n,a){const r=t.pixels,s=r[e];let i=e>0?r[e-1]:null,o=e<r.length-1?r[e+1]:null;const l=n.categoryPercentage;null===i&&(i=s-(null===o?t.end-t.start:o-s)),null===o&&(o=s+s-i);const c=s-(s-Math.min(i,o))/2*l;return{chunk:Math.abs(o-i)/2*l/a,ratio:n.barPercentage,start:c}}(e,t,a,n*l):function(e,t,n,a){const r=n.barThickness;let s,i;return i_(r)?(s=t.min*n.categoryPercentage,i=n.barPercentage):(s=r*a,i=1),{chunk:s/a,ratio:i,start:t.pixels[e]-s/2}}(e,t,a,n*l),d="x"===this.chart.options.indexAxis?this.getDataset().xAxisID:this.getDataset().yAxisID,u=this._getAxis().indexOf(u_(d,this.getFirstScaleIdForIndexAxis())),m=this._getStackIndex(this.index,this._cachedMeta.stack,r?e:void 0)+u;i=c.start+c.chunk*m+c.chunk/2,o=Math.min(s,c.chunk*c.ratio)}else i=n.getPixelForValue(this.getParsed(e)[n.axis],e),o=Math.min(s,t.min*t.ratio);return{base:i-o/2,head:i+o/2,center:i,size:o}}draw(){const e=this._cachedMeta,t=e.vScale,n=e.data,a=n.length;let r=0;for(;r<a;++r)null===this.getParsed(r)[t.axis]||n[r].hidden||n[r].draw(this._ctx)}}l(wP,"id","bar"),l(wP,"defaults",{datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}}),l(wP,"overrides",{scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}});class kP extends mP{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(e,t,n,a){const r=super.parsePrimitiveData(e,t,n,a);for(let s=0;s<r.length;s++)r[s]._custom=this.resolveDataElementOptions(s+n).radius;return r}parseArrayData(e,t,n,a){const r=super.parseArrayData(e,t,n,a);for(let s=0;s<r.length;s++){const e=t[n+s];r[s]._custom=u_(e[2],this.resolveDataElementOptions(s+n).radius)}return r}parseObjectData(e,t,n,a){const r=super.parseObjectData(e,t,n,a);for(let s=0;s<r.length;s++){const e=t[n+s];r[s]._custom=u_(e&&e.r&&+e.r,this.resolveDataElementOptions(s+n).radius)}return r}getMaxOverflow(){const e=this._cachedMeta.data;let t=0;for(let n=e.length-1;n>=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){const t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:a,yScale:r}=t,s=this.getParsed(e),i=a.getLabelForValue(s.x),o=r.getLabelForValue(s.y),l=s._custom;return{label:n[e]||"",value:"("+i+", "+o+(l?", "+l:"")+")"}}update(e){const t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,a){const r="reset"===a,{iScale:s,vScale:i}=this._cachedMeta,{sharedOptions:o,includeOptions:l}=this._getSharedOptions(t,a),c=s.axis,d=i.axis;for(let u=t;u<t+n;u++){const t=e[u],n=!r&&this.getParsed(u),m={},h=m[c]=r?s.getPixelForDecimal(.5):s.getPixelForValue(n[c]),p=m[d]=r?i.getBasePixel():i.getPixelForValue(n[d]);m.skip=isNaN(h)||isNaN(p),l&&(m.options=o||this.resolveDataElementOptions(u,t.active?"active":a),r&&(m.options.radius=0)),this.updateElement(t,u,m,a)}}resolveDataElementOptions(e,t){const n=this.getParsed(e);let a=super.resolveDataElementOptions(e,t);a.$shared&&(a=Object.assign({},a,{$shared:!1}));const r=a.radius;
vendor: 3,447 bytes, line 2
2return"active"!==t&&(a.radius=0),a.radius+=u_(n&&n._custom,r),a}}l(kP,"id","bubble"),l(kP,"defaults",{datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}}),l(kP,"overrides",{scales:{x:{type:"linear"},y:{type:"linear"}}});class jP extends mP{constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){const n=this.getDataset().data,a=this._cachedMeta;if(!1===this._parsing)a._parsed=n;else{let r,s,i=e=>+n[e];if(l_(n[e])){const{key:e="value"}=this._parsing;i=t=>+j_(n[t],e)}for(r=e,s=e+t;r<s;++r)a._parsed[r]=i(r)}}_getRotation(){return V_(this.options.rotation-90)}_getCircumference(){return V_(this.options.circumference)}_getRotationExtents(){let e=E_,t=-E_;for(let n=0;n<this.chart.data.datasets.length;++n)if(this.chart.isDatasetVisible(n)&&this.chart.getDatasetMeta(n).type===this._type){const a=this.chart.getDatasetMeta(n).controller,r=a._getRotation(),s=a._getCircumference();e=Math.min(e,r),t=Math.max(t,r+s)}return{rotation:e,circumference:t-e}}update(e){const t=this.chart,{chartArea:n}=t,a=this._cachedMeta,r=a.data,s=this.getMaxBorderWidth()+this.getMaxOffset(r)+this.options.spacing,i=Math.max((Math.min(n.width,n.height)-s)/2,0),o=Math.min((l=this.options.cutout,c=i,"string"===typeof l&&l.endsWith("%")?parseFloat(l)/100:+l/c),1);var l,c;const d=this._getRingWeight(this.index),{circumference:u,rotation:m}=this._getRotationExtents(),{ratioX:h,ratioY:p,offsetX:g,offsetY:x}=function(e,t,n){let a=1,r=1,s=0,i=0;if(t<E_){const o=e,l=o+t,c=Math.cos(o),d=Math.sin(o),u=Math.cos(l),m=Math.sin(l),h=(e,t,a)=>X_(e,o,l,!0)?1:Math.max(t,t*n,a,a*n),p=(e,t,a)=>X_(e,o,l,!0)?-1:Math.min(t,t*n,a,a*n),g=h(0,c,u),x=h(__,d,m),f=p(S_,c,u),b=p(S_+__,d,m);a=(g-f)/2,r=(x-b)/2,s=-(g+f)/2,i=-(x+b)/2}return{ratioX:a,ratioY:r,offsetX:s,offsetY:i}}(m,u,o),f=(n.width-s)/h,b=(n.height-s)/p,y=Math.max(Math.min(f,b)/2,0),v=m_(this.options.radius,y),w=(v-Math.max(v*o,0))/this._getVisibleDatasetWeightTotal();this.offsetX=g*v,this.offsetY=x*v,a.total=this.calculateTotal(),this.outerRadius=v-w*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-w*d,0),this.updateElements(r,0,r.length,e)}_circumference(e,t){const n=this.options,a=this._cachedMeta,r=this._getCircumference();return t&&n.animation.animateRotate||!this.chart.getDataVisibility(e)||null===a._parsed[e]||a.data[e].hidden?0:this.calculateCircumference(a._parsed[e]*r/E_)}updateElements(e,t,n,a){const r="reset"===a,s=this.chart,i=s.chartArea,o=s.options.animation,l=(i.left+i.right)/2,c=(i.top+i.bottom)/2,d=r&&o.animateScale,u=d?0:this.innerRadius,m=d?0:this.outerRadius,{sharedOptions:h,includeOptions:p}=this._getSharedOptions(t,a);let g,x=this._getRotation();for(g=0;g<t;++g)x+=this._circumference(g,r);for(g=t;g<t+n;++g){const t=this._circumference(g,r),n=e[g],s={x:l+this.offsetX,y:c+this.offsetY,startAngle:x,endAngle:x+t,circumference:t,outerRadius:m,innerRadius:u};p&&(s.options=h||this.resolveDataElementOptions(g,n.active?"active":a)),x+=t,this.updateElement(n,g,s,a)}}calculateTotal(){const e=this._cachedMeta,t=e.data;let n,a=0;for(n=0;n<t.length;n++){const r=e._parsed[n];null===r||isNaN(r)||!this.chart.getDataVisibility(n)||t[n].hidden||(a+=Math.abs(r))}return a}calculateCircumference(e){const t=this._cachedMeta.total;return t>0&&!isNaN(e)?E_*(Math.abs(e)/t):0}
vendor: 9,401 bytes, line 2
2getLabelAndValue(e){const t=this._cachedMeta,n=this.chart,a=n.data.labels||[],r=vB(t._parsed[e],n.options.locale);return{label:a[e]||"",value:r}}getMaxBorderWidth(e){let t=0;const n=this.chart;let a,r,s,i,o;if(!e)for(a=0,r=n.data.datasets.length;a<r;++a)if(n.isDatasetVisible(a)){s=n.getDatasetMeta(a),e=s.data,i=s.controller;break}if(!e)return 0;for(a=0,r=e.length;a<r;++a)o=i.resolveDataElementOptions(a),"inner"!==o.borderAlign&&(t=Math.max(t,o.borderWidth||0,o.hoverBorderWidth||0));return t}getMaxOffset(e){let t=0;for(let n=0,a=e.length;n<a;++n){const e=this.resolveDataElementOptions(n);t=Math.max(t,e.offset||0,e.hoverOffset||0)}return t}_getRingWeightOffset(e){let t=0;for(let n=0;n<e;++n)this.chart.isDatasetVisible(n)&&(t+=this._getRingWeight(n));return t}_getRingWeight(e){return Math.max(u_(this.chart.data.datasets[e].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}l(jP,"id","doughnut"),l(jP,"defaults",{datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"}),l(jP,"descriptors",{_scriptable:e=>"spacing"!==e,_indexable:e=>"spacing"!==e&&!e.startsWith("borderDash")&&!e.startsWith("hoverBorderDash")}),l(jP,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){const t=e.data;if(t.labels.length&&t.datasets.length){const{labels:{pointStyle:n,color:a}}=e.legend.options;return t.labels.map((t,r)=>{const s=e.getDatasetMeta(0).controller.getStyle(r);return{text:t,fillStyle:s.backgroundColor,strokeStyle:s.borderColor,fontColor:a,lineWidth:s.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(r),index:r}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}});class DP extends mP{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(e){const t=this._cachedMeta,{dataset:n,data:a=[],_dataset:r}=t,s=this.chart._animationsDisabled;let{start:i,count:o}=lB(t,a,s);this._drawStart=i,this._drawCount=o,cB(t)&&(i=0,o=a.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!r._decimated,n.points=a;const l=this.resolveDatasetElementOptions(e);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(n,void 0,{animated:!s,options:l},e),this.updateElements(a,i,o,e)}updateElements(e,t,n,a){const r="reset"===a,{iScale:s,vScale:i,_stacked:o,_dataset:l}=this._cachedMeta,{sharedOptions:c,includeOptions:d}=this._getSharedOptions(t,a),u=s.axis,m=i.axis,{spanGaps:h,segment:p}=this.options,g=O_(h)?h:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||r||"none"===a,f=t+n,b=e.length;let y=t>0&&this.getParsed(t-1);for(let v=0;v<b;++v){const n=e[v],h=x?n:{};if(v<t||v>=f){h.skip=!0;continue}const b=this.getParsed(v),w=i_(b[m]),k=h[u]=s.getPixelForValue(b[u],v),j=h[m]=r||w?i.getBasePixel():i.getPixelForValue(o?this.applyStack(i,b,o):b[m],v);h.skip=isNaN(k)||isNaN(j)||w,h.stop=v>0&&Math.abs(b[u]-y[u])>g,p&&(h.parsed=b,h.raw=l.data[v]),d&&(h.options=c||this.resolveDataElementOptions(v,n.active?"active":a)),x||this.updateElement(n,v,h,a),y=b}}getMaxOverflow(){const e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,a=e.data||[];if(!a.length)return n;const r=a[0].size(this.resolveDataElementOptions(0)),s=a[a.length-1].size(this.resolveDataElementOptions(a.length-1));return Math.max(n,r,s)/2}draw(){const e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}}l(DP,"id","line"),l(DP,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),l(DP,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class CP extends mP{constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){const t=this._cachedMeta,n=this.chart,a=n.data.labels||[],r=vB(t._parsed[e].r,n.options.locale);return{label:a[e]||"",value:r}}parseObjectData(e,t,n,a){return pI.bind(this)(e,t,n,a)}update(e){const t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){const e=this._cachedMeta,t={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return e.data.forEach((e,n)=>{const a=this.getParsed(n).r;!isNaN(a)&&this.chart.getDataVisibility(n)&&(a<t.min&&(t.min=a),a>t.max&&(t.max=a))}),t}_updateRadius(){const e=this.chart,t=e.chartArea,n=e.options,a=Math.min(t.right-t.left,t.bottom-t.top),r=Math.max(a/2,0),s=(r-Math.max(n.cutoutPercentage?r/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=r-s*this.index,this.innerRadius=this.outerRadius-s}updateElements(e,t,n,a){const r="reset"===a,s=this.chart,i=s.options.animation,o=this._cachedMeta.rScale,l=o.xCenter,c=o.yCenter,d=o.getIndexAngle(0)-.5*S_;let u,m=d;const h=360/this.countVisibleElements();for(u=0;u<t;++u)m+=this._computeAngle(u,a,h);for(u=t;u<t+n;u++){const t=e[u];let n=m,p=m+this._computeAngle(u,a,h),g=s.getDataVisibility(u)?o.getDistanceFromCenterForValue(this.getParsed(u).r):0;m=p,r&&(i.animateScale&&(g=0),i.animateRotate&&(n=p=d));const x={x:l,y:c,innerRadius:0,outerRadius:g,startAngle:n,endAngle:p,options:this.resolveDataElementOptions(u,t.active?"active":a)};this.updateElement(t,u,x,a)}}countVisibleElements(){const e=this._cachedMeta;let t=0;return e.data.forEach((e,n)=>{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?V_(this.resolveDataElementOptions(e,t).angle||n):0}}l(CP,"id","polarArea"),l(CP,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),l(CP,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){const t=e.data;if(t.labels.length&&t.datasets.length){const{labels:{pointStyle:n,color:a}}=e.legend.options;return t.labels.map((t,r)=>{const s=e.getDatasetMeta(0).controller.getStyle(r);return{text:t,fillStyle:s.backgroundColor,strokeStyle:s.borderColor,fontColor:a,lineWidth:s.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(r),index:r}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class NP extends jP{}l(NP,"id","pie"),l(NP,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class FP extends mP{getLabelAndValue(e){const t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:""+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,a){return pI.bind(this)(e,t,n,a)}update(e){const t=this._cachedMeta,n=t.dataset,a=t.data||[],r=t.iScale.getLabels();if(n.points=a,"resize"!==e){const t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);const s={_loop:!0,_fullLoop:r.length===a.length,options:t};this.updateElement(n,void 0,s,e)}this.updateElements(a,0,a.length,e)}updateElements(e,t,n,a){const r=this._cachedMeta.rScale,s="reset"===a;for(let i=t;i<t+n;i++){const t=e[i],n=this.resolveDataElementOptions(i,t.active?"active":a),o=r.getPointPositionForValue(i,this.getParsed(i).r),l=s?r.xCenter:o.x,c=s?r.yCenter:o.y,d={x:l,y:c,angle:o.angle,skip:isNaN(l)||isNaN(c),options:n};this.updateElement(t,i,d,a)}}}l(FP,"id","radar"),l(FP,"defaults",{datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}}),l(FP,"overrides",{aspectRatio:1,scales:{r:{type:"radialLinear"}}});class SP extends mP{getLabelAndValue(e){const t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:a,yScale:r}=t,s=this.getParsed(e),i=a.getLabelForValue(s.x),o=r.getLabelForValue(s.y);return{label:n[e]||"",value:"("+i+", "+o+")"}}update(e){const t=this._cachedMeta,{data:n=[]}=t,a=this.chart._animationsDisabled;let{start:r,count:s}=lB(t,n,a);if(this._drawStart=r,this._drawCount=s,cB(t)&&(r=0,s=n.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:r,_dataset:s}=t;r._chart=this.chart,r._datasetIndex=this.index,r._decimated=!!s._decimated,r.points=n;const i=this.resolveDatasetElementOptions(e);i.segment=this.options.segment,this.updateElement(r,void 0,{animated:!a,options:i},e)}else this.datasetElementType&&(delete t.dataset,this.datasetElementType=!1);this.updateElements(n,r,s,e)}addElements(){const{showLine:e}=this.options;!this.datasetElementType&&e&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(e,t,n,a){const r="reset"===a,{iScale:s,vScale:i,_stacked:o,_dataset:l}=this._cachedMeta,c=this.resolveDataElementOptions(t,a),d=this.getSharedOptions(c),u=this.includeOptions(a,d),m=s.axis,h=i.axis,{spanGaps:p,segment:g}=this.options,x=O_(p)?p:Number.POSITIVE_INFINITY,f=this.chart._animationsDisabled||r||"none"===a;let b=t>0&&this.getParsed(t-1);for(let y=t;y<t+n;++y){const t=e[y],n=this.getParsed(y),c=f?t:{},p=i_(n[h]),v=c[m]=s.getPixelForValue(n[m],y),w=c[h]=r||p?i.getBasePixel():i.getPixelForValue(o?this.applyStack(i,n,o):n[h],y);c.skip=isNaN(v)||isNaN(w)||p,c.stop=y>0&&Math.abs(n[m]-b[m])>
2x,g&&(c.parsed=n,c.raw=l.data[y]),u&&(c.options=d||this.resolveDataElementOptions(y,t.active?"active":a)),f||this.updateElement(t,y,c,a),b=n}this.updateSharedOptions(d,a,c)}getMaxOverflow(){const e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}const n=e.dataset,a=n.options&&n.options.borderWidth||0;if(!t.length)return a;const r=t[0].size(this.resolveDataElementOptions(0)),s=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(a,r,s)/2}}l(SP,"id","scatter"),l(SP,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),l(SP,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});function EP(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class AP{static override(e){Object.assign(AP.prototype,e)}constructor(e){l(this,"options",void 0),this.options=e||{}}init(){}formats(){return EP()}parse(){return EP()}format(){return EP()}add(){return EP()}diff(){return EP()}startOf(){return EP()}endOf(){return EP()}}var TP=AP;function MP(e,t,n,a){const{controller:r,data:s,_sorted:i}=e,o=r._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(o&&t===o.axis&&"r"!==t&&i&&s.length){const i=o._reversePixels?eB:Z_;if(!a){const a=i(s,t,n);if(l){const{vScale:t}=r._cachedMeta,{_parsed:n}=e,s=n.slice(0,a.lo+1).reverse().findIndex(e=>!i_(e[t.axis]));a.lo-=Math.max(0,s);const i=n.slice(a.hi).findIndex(e=>!i_(e[t.axis]));a.hi+=Math.max(0,i)}return a}if(r._sharedOptions){const e=s[0],a="function"===typeof e.getRange&&e.getRange(t);if(a){const e=i(s,t,n-a),r=i(s,t,n+a);return{lo:e.lo,hi:r.hi}}}}return{lo:0,hi:s.length-1}}function _P(e,t,n,a,r){const s=e.getSortedVisibleDatasetMetas(),i=n[t];for(let o=0,l=s.length;o<l;++o){const{index:e,data:n}=s[o],{lo:l,hi:c}=MP(s[o],t,i,r);for(let t=l;t<=c;++t){const r=n[t];r.skip||a(r,e,t)}}}function BP(e,t,n,a,r){const s=[];if(!r&&!e.isPointInArea(t))return s;return _P(e,n,t,function(n,i,o){(r||IB(n,e.chartArea,0))&&n.inRange(t.x,t.y,a)&&s.push({element:n,datasetIndex:i,index:o})},!0),s}function IP(e,t,n,a,r,s){let i=[];const o=function(e){const t=-1!==e.indexOf("x"),n=-1!==e.indexOf("y");return function(e,a){const r=t?Math.abs(e.x-a.x):0,s=n?Math.abs(e.y-a.y):0;return Math.sqrt(Math.pow(r,2)+Math.pow(s,2))}}(n);let l=Number.POSITIVE_INFINITY;return _P(e,n,t,function(n,c,d){const u=n.inRange(t.x,t.y,r);if(a&&!u)return;const m=n.getCenterPoint(r);if(!(!!s||e.isPointInArea(m))&&!u)return;const h=o(t,m);h<l?(i=[{element:n,datasetIndex:c,index:d}],l=h):h===l&&i.push({element:n,datasetIndex:c,index:d})}),i}function PP(e,t,n,a,r,s){return s||e.isPointInArea(t)?"r"!==n||a?IP(e,t,n,a,r,s):function(e,t,n,a){let r=[];return _P(e,n,t,function(e,n,s){const{startAngle:i,endAngle:o}=e.getProps(["startAngle","endAngle"],a),{angle:l}=W_(e,{x:t.x,y:t.y});X_(l,i,o)&&r.push({element:e,datasetIndex:n,index:s})}),r}(e,t,n,r):[]}function LP(e,t,n,a,r){const s=[],i="x"===n?"inXRange":"inYRange";let o=!1;return _P(e,n,t,(e,a,l)=>{e[i]&&e[i](t[n],r)&&(s.push({element:e,datasetIndex:a,index:l}),o=o||e.inRange(t.x,t.y,r))}),a&&!o?[]:s}var RP={evaluateInteractionItems:_P,modes:{index(e,t,n,a){const r=SI(t,e),s=n.axis||"x",i=n.includeInvisible||!1,o=n.intersect?BP(e,r,s,a,i):PP(e,r,s,!1,a,i),l=[];return o.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{const t=o[0].index,n=e.data[t];n&&!n.skip&&l.push({element:n,datasetIndex:e.index,index:t})}),l):[]},dataset(e,t,n,a){const r=SI(t,e),s=n.axis||"xy",i=n.includeInvisible||!1;let o=n.intersect?BP(e,r,s,a,i):PP(e,r,s,!1,a,i);if(o.length>0){const t=o[0].datasetIndex,n=e.getDatasetMeta(t).data;o=[];for(let e=0;e<n.length;++e)o.push({element:n[e],datasetIndex:t,index:e})}return o},point:(e,t,n,a)=>BP(e,SI(t,e),n.axis||"xy",a,n.includeInvisible||!1),nearest(e,t,n,a){const r=SI(t,e),s=n.axis||"xy",i=n.includeInvisible||!1;return PP(e,r,s,n.intersect,a,i)},x:(e,t,n,a)=>LP(e,SI(t,e),"x",n.intersect,a),y:(e,t,n,a)=>LP(e,SI(t,e),"y",n.intersect,a)}};const zP=["left","top","right","bottom"];function OP(e,t){return e.filter(e=>e.pos===t)}function UP(e,t){return e.filter(e=>-1===zP.indexOf(e.pos)&&e.box.axis===t)}function VP(e,t){return e.sort((e,n)=>{const a=t?n:e,r=t?e:n;
vendor: 23,143 bytes, line 2
2return a.weight===r.weight?a.index-r.index:a.weight-r.weight})}function HP(e,t){const n=function(e){const t={};for(const n of e){const{stack:e,pos:a,stackWeight:r}=n;if(!e||!zP.includes(a))continue;const s=t[e]||(t[e]={count:0,placed:0,weight:0,size:0});s.count++,s.weight+=r}return t}(e),{vBoxMaxWidth:a,hBoxMaxHeight:r}=t;let s,i,o;for(s=0,i=e.length;s<i;++s){o=e[s];const{fullSize:i}=o.box,l=n[o.stack],c=l&&o.stackWeight/l.weight;o.horizontal?(o.width=c?c*a:i&&t.availableWidth,o.height=r):(o.width=a,o.height=c?c*r:i&&t.availableHeight)}return n}function qP(e,t,n,a){return Math.max(e[n],t[n])+Math.max(e[a],t[a])}function WP(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function YP(e,t,n,a){const{pos:r,box:s}=n,i=e.maxPadding;if(!l_(r)){n.size&&(e[r]-=n.size);const t=a[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?s.height:s.width),n.size=t.size/t.count,e[r]+=n.size}s.getPadding&&WP(i,s.getPadding());const o=Math.max(0,t.outerWidth-qP(i,e,"left","right")),l=Math.max(0,t.outerHeight-qP(i,e,"top","bottom")),c=o!==e.w,d=l!==e.h;return e.w=o,e.h=l,n.horizontal?{same:c,other:d}:{same:d,other:c}}function GP(e,t){const n=t.maxPadding;function a(e){const a={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{a[e]=Math.max(t[e],n[e])}),a}return a(e?["left","right"]:["top","bottom"])}function KP(e,t,n,a){const r=[];let s,i,o,l,c,d;for(s=0,i=e.length,c=0;s<i;++s){o=e[s],l=o.box,l.update(o.width||t.w,o.height||t.h,GP(o.horizontal,t));const{same:i,other:u}=YP(t,n,o,a);c|=i&&r.length,d=d||u,l.fullSize||r.push(o)}return c&&KP(r,t,n,a)||d}function XP(e,t,n,a,r){e.top=n,e.left=t,e.right=t+a,e.bottom=n+r,e.width=a,e.height=r}function JP(e,t,n,a){const r=n.padding;let{x:s,y:i}=t;for(const o of e){const e=o.box,l=a[o.stack]||{count:1,placed:0,weight:1},c=o.stackWeight/l.weight||1;if(o.horizontal){const a=t.w*c,s=l.size||e.height;C_(l.start)&&(i=l.start),e.fullSize?XP(e,r.left,i,n.outerWidth-r.right-r.left,s):XP(e,t.left+l.placed,i,a,s),l.start=i,l.placed+=a,i=e.bottom}else{const a=t.h*c,i=l.size||e.width;C_(l.start)&&(s=l.start),e.fullSize?XP(e,s,r.top,i,n.outerHeight-r.bottom-r.top):XP(e,s,t.top+l.placed,i,a),l.start=s,l.placed+=a,s=e.right}}t.x=s,t.y=i}var $P={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(e){t.draw(e)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;-1!==n&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,a){if(!e)return;const r=$B(e.options.layout.padding),s=Math.max(t-r.width,0),i=Math.max(n-r.height,0),o=function(e){const t=function(e){const t=[];let n,a,r,s,i,o;for(n=0,a=(e||[]).length;n<a;++n)r=e[n],({position:s,options:{stack:i,stackWeight:o=1}}=r),t.push({index:n,box:r,pos:s,horizontal:r.isHorizontal(),weight:r.weight,stack:i&&s+i,stackWeight:o});return t}(e),n=VP(t.filter(e=>e.box.fullSize),!0),a=VP(OP(t,"left"),!0),r=VP(OP(t,"right")),s=VP(OP(t,"top"),!0),i=VP(OP(t,"bottom")),o=UP(t,"x"),l=UP(t,"y");return{fullSize:n,leftAndTop:a.concat(s),rightAndBottom:r.concat(l).concat(i).concat(o),chartArea:OP(t,"chartArea"),vertical:a.concat(r).concat(l),horizontal:s.concat(i).concat(o)}}(e.boxes),l=o.vertical,c=o.horizontal;p_(e.boxes,e=>{"function"===typeof e.beforeLayout&&e.beforeLayout()});const d=l.reduce((e,t)=>t.box.options&&!1===t.box.options.display?e:e+1,0)||1,u=Object.freeze({outerWidth:t,outerHeight:n,padding:r,availableWidth:s,availableHeight:i,vBoxMaxWidth:s/2/d,hBoxMaxHeight:i/2}),m=Object.assign({},r);WP(m,$B(a));const h=Object.assign({maxPadding:m,w:s,h:i,x:r.left,y:r.top},r),p=HP(l.concat(c),u);KP(o.fullSize,h,u,p),KP(l,h,u,p),KP(c,h,u,p)&&KP(l,h,u,p),function(e){const t=e.maxPadding;function n(n){const a=Math.max(t[n]-e[n],0);return e[n]+=a,a}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}(h),JP(o.leftAndTop,h,u,p),h.x+=h.w,h.y+=h.h,JP(o.rightAndBottom,h,u,p),e.chartArea={left:h.left,top:h.top,right:h.left+h.w,bottom:h.top+h.h,height:h.h,width:h.w},p_(o.chartArea,t=>{const n=t.box;Object.assign(n,e.chartArea),n.update(h.w,h.h,{left:0,top:0,right:0,bottom:0})})}};class QP{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,a){return t=Math.max(0,t||e.width),n=n||e.height,{width:t,height:Math.max(0,a?Math.floor(t/a):n)}}isAttached(e){return!0}updateConfig(e){}}class ZP extends QP{acquireContext(e){return e&&e.getContext&&e.getContext("2d")||null}updateConfig(e){e.options.animation=!1}}const eL="$chartjs",tL={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},nL=e=>null===e||""===e;const aL=!!MI&&{passive:!0};function rL(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,aL)}function sL(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function iL(e,t,n){const a=e.canvas,r=new MutationObserver(e=>{let t=!1;for(const n of e)t=t||sL(n.addedNodes,a),t=t&&!sL(n.removedNodes,a);t&&n()});return r.observe(document,{childList:!0,subtree:!0}),r}function oL(e,t,n){const a=e.canvas,r=new MutationObserver(e=>{let t=!1;for(const n of e)t=t||sL(n.removedNodes,a),t=t&&!sL(n.addedNodes,a);t&&n()});return r.observe(document,{childList:!0,subtree:!0}),r}const lL=new Map;let cL=0;function dL(){const e=window.devicePixelRatio;e!==cL&&(cL=e,lL.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function uL(e,t,n){const a=e.canvas,r=a&&jI(a);if(!r)return;const s=sB((e,t)=>{const a=r.clientWidth;n(e,t),a<r.clientWidth&&n()},window),i=new ResizeObserver(e=>{const t=e[0],n=t.contentRect.width,a=t.contentRect.height;0===n&&0===a||s(n,a)});return i.observe(r),function(e,t){lL.size||window.addEventListener("resize",dL),lL.set(e,t)}(e,s),i}function mL(e,t,n){n&&n.disconnect(),"resize"===t&&function(e){lL.delete(e),lL.size||window.removeEventListener("resize",dL)}(e)}function hL(e,t,n){const a=e.canvas,r=sB(t=>{null!==e.ctx&&n(function(e,t){const n=tL[e.type]||e.type,{x:a,y:r}=SI(e,t);return{type:n,chart:t,native:e,x:void 0!==a?a:null,y:void 0!==r?r:null}}(t,e))},e);return function(e,t,n){e&&e.addEventListener(t,n,aL)}(a,t,r),r}class pL extends QP{acquireContext(e,t){const n=e&&e.getContext&&e.getContext("2d");return n&&n.canvas===e?(function(e,t){const n=e.style,a=e.getAttribute("height"),r=e.getAttribute("width");if(e[eL]={initial:{height:a,width:r,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",nL(r)){const t=_I(e,"width");void 0!==t&&(e.width=t)}if(nL(a))if(""===e.style.height)e.height=e.width/(t||2);else{const t=_I(e,"height");void 0!==t&&(e.height=t)}}(e,t),n):null}releaseContext(e){const t=e.canvas;if(!t[eL])return!1;const n=t[eL].initial;["height","width"].forEach(e=>{const a=n[e];i_(a)?t.removeAttribute(e):t.setAttribute(e,a)});const a=n.style||{};return Object.keys(a).forEach(e=>{t.style[e]=a[e]}),t.width=t.width,delete t[eL],!0}addEventListener(e,t,n){this.removeEventListener(e,t);const a=e.$proxies||(e.$proxies={}),r={attach:iL,detach:oL,resize:uL}[t]||hL;a[t]=r(e,t,n)}removeEventListener(e,t){const n=e.$proxies||(e.$proxies={}),a=n[t];if(!a)return;({attach:mL,detach:mL,resize:mL}[t]||rL)(e,t,a),n[t]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,a){return AI(e,t,n,a)}isAttached(e){const t=e&&jI(e);return!(!t||!t.isConnected)}}class gL{constructor(){l(this,"x",void 0),l(this,"y",void 0),l(this,"active",!1),l(this,"options",void 0),l(this,"$animations",void 0)}tooltipPosition(e){const{x:t,y:n}=this.getProps(["x","y"],e);return{x:t,y:n}}hasValue(){return O_(this.x)&&O_(this.y)}getProps(e,t){const n=this.$animations;if(!t||!n)return this;const a={};return e.forEach(e=>{a[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),a}}function xL(e,t){const n=e.options.ticks,a=function(e){const t=e.options.offset,n=e._tickSize(),a=e._length/n+(t?0:1),r=e._maxLength/n;return Math.floor(Math.min(a,r))}(e),r=Math.min(n.maxTicksLimit||a,a),s=n.major.enabled?function(e){const t=[];let n,a;for(n=0,a=e.length;n<a;n++)e[n].major&&t.push(n);return t}(t):[],i=s.length,o=s[0],l=s[i-1],c=[];if(i>r)return function(e,t,n,a){let r,s=0,i=n[0];for(a=Math.ceil(a),r=0;r<e.length;r++)r===i&&(t.push(e[r]),s++,i=n[s*a])}(t,c,s,i/r),c;const d=function(e,t,n){const a=function(e){const t=e.length;let n,a;if(t<2)return!1;for(a=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==a)return!1;return a}(e),r=t.length/n;if(!a)return Math.max(r,1);const s=function(e){const t=[],n=Math.sqrt(e);let a;for(a=1;a<n;a++)e%a===0&&(t.push(a),t.push(e/a));return n===(0|n)&&t.push(n),t.sort((e,t)=>e-t).pop(),t}(a);for(let i=0,o=s.length-1;i<o;i++){const e=s[i];if(e>r)return e}return Math.max(r,1)}(s,t,r);if(i>0){let e,n;const a=i>1?Math.round((l-o)/(i-1)):null;for(fL(t,c,d,i_(a)?0:o-a,o),e=0,n=i-1;e<n;e++)fL(t,c,d,s[e],s[e+1]);return fL(t,c,d,l,i_(a)?t.length:l+a),c}return fL(t,c,d),c}function fL(e,t,n,a,r){const s=u_(a,0),i=Math.min(u_(r,e.length),e.length);let o,l,c,d=0;for(n=Math.ceil(n),r&&(o=r-a,n=o/Math.floor(o/n)),c=s;c<0;)d++,c=Math.round(s+d*n);for(l=Math.max(s,0);l<i;l++)l===c&&(t.push(e[l]),d++,c=Math.round(s+d*n))}l(gL,"defaults",{}),l(gL,"defaultRoutes",void 0);const bL=(e,t,n)=>"top"===t||"left"===t?e[t]+n:e[t]-n,yL=(e,t)=>Math.min(t||e,e);function vL(e,t){const n=[],a=e.length/t,r=e.length;let s=0;for(;s<r;s+=a)n.push(e[Math.floor(s)]);return n}function wL(e,t,n){const a=e.ticks.length,r=Math.min(t,a-1),s=e._startPixel,i=e._endPixel,o=1e-6;let l,c=e.getPixelForTick(r);if(!(n&&(l=1===a?Math.max(c-s,i-c):0===t?(e.getPixelForTick(1)-c)/2:(c-e.getPixelForTick(r-1))/2,c+=r<t?l:-l,c<s-o||c>i+o)))return c}function kL(e){return e.drawTicks?e.tickLength:0}function jL(e,t){if(!e.display)return 0;const n=QB(e.font,t),a=$B(e.padding);return(o_(e.text)?e.text.length:1)*n.lineHeight+a.height}function DL(e,t,n){let a=iB(e);return(n&&"right"!==t||!n&&"right"===t)&&(a=(e=>"left"===e?"right":"right"===e?"left":e)(a)),a}class CL extends gL{constructor(e){super(),this.id=e.id,this.type=e.type,this.options=void 0,this.ctx=e.ctx,this.chart=e.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(e){this.options=e.setContext(this.getContext()),this.axis=e.axis,this._userMin=this.parse(e.min),this._userMax=this.parse(e.max),this._suggestedMin=this.parse(e.suggestedMin),this._suggestedMax=this.parse(e.suggestedMax)}parse(e,t){return e}getUserBounds(){let{_userMin:e,_userMax:t,_suggestedMin:n,_suggestedMax:a}=this;return e=d_(e,Number.POSITIVE_INFINITY),t=d_(t,Number.NEGATIVE_INFINITY),n=d_(n,Number.POSITIVE_INFINITY),a=d_(a,Number.NEGATIVE_INFINITY),{min:d_(e,n),max:d_(t,a),minDefined:c_(e),maxDefined:c_(t)}}getMinMax(e){let t,{min:n,max:a,minDefined:r,maxDefined:s}=this.getUserBounds();if(r&&s)return{min:n,max:a};const i=this.getMatchingVisibleMetas();for(let o=0,l=i.length;o<l;++o)t=i[o].controller.getMinMax(this,e),r||(n=Math.min(n,t.min)),s||(a=Math.max(a,t.max));return n=s&&n>a?a:n,a=r&&n>a?n:a,{min:d_(n,d_(a,n)),max:d_(a,d_(n,a))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.chart.chartArea;return this._labelItems||(this._labelItems=this._computeLabelItems(e))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){h_(this.options.beforeUpdate,[this])}update(e,t,n){const{beginAtZero:a,grace:r,ticks:s}=this.options,i=s.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=function(e,t,n){const{min:a,max:r}=e,s=m_(t,(r-a)/2),i=(e,t)=>n&&0===e?0:e+t;return{min:i(a,-Math.abs(s)),max:i(r,s)}}(this,r,a),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const o=i<this.ticks.length;this._convertTicksToLabels(o?vL(this.ticks,i):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),s.display&&(s.autoSkip||"auto"===s.source)&&(this.ticks=xL(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),o&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let e,t,n=this.options.reverse;this.isHorizontal()?(e=this.left,t=this.right):(e=this.top,t=this.bottom,n=!n),this._startPixel=e,this._endPixel=t,this._reversePixels=n,this._length=t-e,this._alignToPixels=this.options.alignToPixels}afterUpdate(){h_(this.options.afterUpdate,[this])}beforeSetDimensions(){h_(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){h_(this.options.afterSetDimensions,[this])}_callHooks(e){this.chart.notifyPlugins(e,this.getContext()),h_(this.options[e],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){h_(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(e){const t=this.options.ticks;let n,a,r;for(n=0,a=e.length;n<a;n++)r=e[n],r.label=h_(t.callback,[r.value,n,e],this)}afterTickToLabelConversion(){h_(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){h_(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const e=this.options,t=e.ticks,n=yL(this.ticks.length,e.ticks.maxTicksLimit),a=t.minRotation||0,r=t.maxRotation;let s,i,o,l=a;if(!this._isVisible()||!t.display||a>=r||n<=1||!this.isHorizontal())return void(this.labelRotation=a);const c=this._getLabelSizes(),d=c.widest.width,u=c.highest.height,m=J_(this.chart.width-d,0,this.maxWidth);s=e.offset?this.maxWidth/n:m/(n-1),d+6>s&&(s=m/(n-(e.offset?.5:1)),i=this.maxHeight-kL(e.grid)-t.padding-jL(e.title,this.chart.options.font),o=Math.sqrt(d*d+u*u),l=H_(Math.min(Math.asin(J_((c.highest.height+6)/s,-1,1)),Math.asin(J_(i/o,-1,1))-Math.asin(J_(u/o,-1,1)))),l=Math.max(a,Math.min(r,l))),this.labelRotation=l}afterCalculateLabelRotation(){h_(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){h_(this.options.beforeFit,[this])}fit(){const e={width:0,height:0},{chart:t,options:{ticks:n,title:a,grid:r}}=this,s=this._isVisible(),i=this.isHorizontal();if(s){const s=jL(a,t.options.font);if(i?(e.width=this.maxWidth,e.height=kL(r)+s):(e.height=this.maxHeight,e.width=kL(r)+s),n.display&&this.ticks.length){const{first:t,last:a,widest:r,highest:s}=this._getLabelSizes(),o=2*n.padding,l=V_(this.labelRotation),c=Math.cos(l),d=Math.sin(l);if(i){const t=n.mirror?0:d*r.width+c*s.height;e.height=Math.min(this.maxHeight,e.height+t+o)}else{const t=n.mirror?0:c*r.width+d*s.height;e.width=Math.min(this.maxWidth,e.width+t+o)}this._calculatePadding(t,a,d,c)}}this._handleMargins(),i?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,a){const{ticks:{align:r,padding:s},position:i}=this.options,o=0!==this.labelRotation,l="top"!==i&&"x"===this.axis;if(this.isHorizontal()){const i=this.getPixelForTick(0)-this.left,c=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,u=0;o?l?(d=a*e.width,u=n*t.height):(d=n*e.height,u=a*t.width):"start"===r?u=t.width:"end"===r?d=e.width:"inner"!==r&&(d=e.width/2,u=t.width/2),this.paddingLeft=Math.max((d-i+s)*this.width/(this.width-i),0),this.paddingRight=Math.max((u-c+s)*this.width/(this.width-c),0)}else{let n=t.height/2,a=e.height/2;"start"===r?(n=0,a=e.height):"end"===r&&(n=t.height,a=0),this.paddingTop=n+s,this.paddingBottom=a+s}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){h_(this.options.afterFit,[this])}isHorizontal(){const{axis:e,position:t}=this.options;return"top"===t||"bottom"===t||"x"===e}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){let t,n;for(this.beforeTickToLabelConversion(),this.generateTickLabels(e),t=0,n=e.length;t<n;t++)i_(e[t].label)&&(e.splice(t,1),n--,t--);this.afterTickToLabelConversion()}_getLabelSizes(){let e=this._labelSizes;if(!e){const t=this.options.ticks.sampleSize;let n=this.ticks;t<n.length&&(n=vL(n,t)),this._labelSizes=e=this._computeLabelSizes(n,n.length,this.options.ticks.maxTicksLimit)}return e}_computeLabelSizes(e,t,n){const{ctx:a,_longestTextCache:r}=this,s=[],i=[],o=Math.floor(t/yL(t,n));let l,c,d,u,m,h,p,g,x,f,b,y=0,v=0;for(l=0;l<t;l+=o){if(u=e[l].label,m=this._resolveTickFontOptions(l),a.font=h=m.string,p=r[h]=r[h]||{data:{},gc:[]},g=m.lineHeight,x=f=0,i_(u)||o_(u)){if(o_(u))for(c=0,d=u.length;c<d;++c)b=u[c],i_(b)||o_(b)||(x=EB(a,p.data,p.gc,x,b),f+=g)}else x=EB(a,p.data,p.gc,x,u),f=g;s.push(x),i.push(f),y=Math.max(x,y),v=Math.max(f,v)}!function(e,t){p_(e,e=>{const n=e.gc,a=n.length/2;let r;if(a>t){for(r=0;r<a;++r)delete e.data[n[r]];n.splice(0,a)}})}(r,t);const w=s.indexOf(y),k=i.indexOf(v),j=e=>({width:s[e]||0,height:i[e]||0});return{first:j(0),last:j(t-1),widest:j(w),highest:j(k),widths:s,heights:i}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){const t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);const t=this._startPixel+e*this._length;return J_(this._alignToPixels?TB(this.chart,t,0):t,-32768,32767)}getDecimalForPixel(e){const t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){const t=this.ticks||[];if(e>=0&&e<t.length){const n=t[e];return n.$context||(n.$context=function(e,t,n){return eI(e,{tick:n,index:t,type:"tick"})}(this.getContext(),e,n))}return this.$context||(this.$context=function(e,t){return eI(e,{scale:t,type:"scale"})}(this.chart.getContext(),this))}_tickSize(){const e=this.options.ticks,t=V_(this.labelRotation),n=Math.abs(Math.cos(t)),a=Math.abs(Math.sin(t)),r=this._getLabelSizes(),s=e.autoSkipPadding||0,i=r?r.widest.width+s:0,o=r?r.highest.height+s:0;return this.isHorizontal()?o*n>i*a?i/n:o/a:o*a<i*n?o/n:i/a}_isVisible(){const e=this.options.display;return"auto"!==e?!!e:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(e){const t=this.axis,n=this.chart,a=this.options,{grid:r,position:s,border:i}=a,o=r.offset,l=this.isHorizontal(),c=this.ticks.length+(o?1:0),d=kL(r),u=[],m=i.setContext(this.getContext()),h=m.display?m.width:0,p=h/2,g=function(e){return TB(n,e,h)};let x,f,b,y,v,w,k,j,D,C,N,F;if("top"===s)x=g(this.bottom),w=this.bottom-d,j=x-p,C=g(e.top)+p,F=e.bottom;else if("bottom"===s)x=g(this.top),C=e.top,F=g(e.bottom)-p,w=x+p,j=this.top+d;else if("left"===s)x=g(this.right),v=this.right-d,k=x-p,D=g(e.left)+p,N=e.right;else if("right"===s)x=g(this.left),D=e.left,N=g(e.right)-p,v=x+p,k=this.left+d;else if("x"===t){if("center"===s)x=g((e.top+e.bottom)/2+.5);else if(l_(s)){const e=Object.keys(s)[0],t=s[e];x=g(this.chart.scales[e].getPixelForValue(t))}C=e.top,F=e.bottom,w=x+p,j=w+d}else if("y"===t){if("center"===s)x=g((e.left+e.right)/2);else if(l_(s)){const e=Object.keys(s)[0],t=s[e];x=g(this.chart.scales[e].getPixelForValue(t))}v=x-p,k=v-d,D=e.left,N=e.right}const S=u_(a.ticks.maxTicksLimit,c),E=Math.max(1,Math.ceil(c/S));for(f=0;f<c;f+=E){const e=this.getContext(f),t=r.setContext(e),a=i.setContext(e),s=t.lineWidth,c=t.color,d=a.dash||[],m=a.dashOffset,h=t.tickWidth,p=t.tickColor,g=t.tickBorderDash||[],x=t.tickBorderDashOffset;b=wL(this,f,o),void 0!==b&&(y=TB(n,b,s),l?v=k=D=N=y:w=j=C=F=y,u.push({tx1:v,ty1:w,tx2:k,ty2:j,x1:D,y1:C,x2:N,y2:F,width:s,color:c,borderDash:d,borderDashOffset:m,tickWidth:h,tickColor:p,tickBorderDash:g,tickBorderDashOffset:x}))}return this._ticksLength=c,this._borderValue=x,u}_computeLabelItems(e){const t=this.axis,n=this.options,{position:a,ticks:r}=n,s=this.isHorizontal(),i=this.ticks,{align:o,crossAlign:l,padding:c,mirror:d}=r,u=kL(n.grid),m=u+c,h=d?-c:m,p=-V_(this.labelRotation),g=[];let x,f,b,y,v,w,k,j,D,C,N,F,S="middle";if("top"===a)w=this.bottom-h,k=this._getXAxisLabelAlignment();else if("bottom"===a)w=this.top+h,k=this._getXAxisLabelAlignment();else if("left"===a){const e=this._getYAxisLabelAlignment(u);k=e.textAlign,v=e.x}else if("right"===a){const e=this._getYAxisLabelAlignment(u);k=e.textAlign,v=e.x}else if("x"===t){if("center"===a)w=(e.top+e.bottom)/2+m;else if(l_(a)){const e=Object.keys(a)[0],t=a[e];w=this.chart.scales[e].getPixelForValue(t)+m}k=this._getXAxisLabelAlignment()}else if("y"===t){if("center"===a)v=(e.left+e.right)/2-m;else if(l_(a)){const e=Object.keys(a)[0],t=a[e];v=this.chart.scales[e].getPixelForValue(t)}k=this._getYAxisLabelAlignment(u).textAlign}"y"===t&&("start"===o?S="top":"end"===o&&(S="bottom"));const E=this._getLabelSizes();for(x=0,f=i.length;x<f;++x){b=i[x],y=b.label;const e=r.setContext(this.getContext(x));j=this.getPixelForTick(x)+r.labelOffset,D=this._resolveTickFontOptions(x),C=D.lineHeight,N=o_(y)?y.length:1;const t=N/2,n=e.color,o=e.textStrokeColor,c=e.textStrokeWidth;let u,m=k;
vendor: 1,855 bytes, line 2
2if(s?(v=j,"inner"===k&&(m=x===f-1?this.options.reverse?"left":"right":0===x?this.options.reverse?"right":"left":"center"),F="top"===a?"near"===l||0!==p?-N*C+C/2:"center"===l?-E.highest.height/2-t*C+C:-E.highest.height+C/2:"near"===l||0!==p?C/2:"center"===l?E.highest.height/2-t*C:E.highest.height-N*C,d&&(F*=-1),0===p||e.showLabelBackdrop||(v+=C/2*Math.sin(p))):(w=j,F=(1-N)*C/2),e.showLabelBackdrop){const t=$B(e.backdropPadding),n=E.heights[x],a=E.widths[x];let r=F-t.top,s=0-t.left;switch(S){case"middle":r-=n/2;break;case"bottom":r-=n}switch(k){case"center":s-=a/2;break;case"right":s-=a;break;case"inner":x===f-1?s-=a:x>0&&(s-=a/2)}u={left:s,top:r,width:a+t.width,height:n+t.height,color:e.backdropColor}}g.push({label:y,font:D,textOffset:F,options:{rotation:p,color:n,strokeColor:o,strokeWidth:c,textAlign:m,textBaseline:S,translation:[v,w],backdrop:u}})}return g}_getXAxisLabelAlignment(){const{position:e,ticks:t}=this.options;if(-V_(this.labelRotation))return"top"===e?"left":"right";let n="center";return"start"===t.align?n="left":"end"===t.align?n="right":"inner"===t.align&&(n="inner"),n}_getYAxisLabelAlignment(e){const{position:t,ticks:{crossAlign:n,mirror:a,padding:r}}=this.options,s=e+r,i=this._getLabelSizes().widest.width;let o,l;return"left"===t?a?(l=this.right+r,"near"===n?o="left":"center"===n?(o="center",l+=i/2):(o="right",l+=i)):(l=this.right-s,"near"===n?o="right":"center"===n?(o="center",l-=i/2):(o="left",l=this.left)):"right"===t?a?(l=this.left+r,"near"===n?o="right":"center"===n?(o="center",l-=i/2):(o="left",l-=i)):(l=this.left+s,"near"===n?o="left":"center"===n?(o="center",l+=i/2):(o="right",l=this.right)):o="right",{textAlign:o,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;const e=this.chart,t=this.options.position;return"left"===t||"right"===t?{top:0,left:this.left,bottom:e.height,right:this.right}
vendor: 26,265 bytes, line 2
2:"top"===t||"bottom"===t?{top:this.top,left:0,bottom:this.bottom,right:e.width}:void 0}drawBackground(){const{ctx:e,options:{backgroundColor:t},left:n,top:a,width:r,height:s}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,a,r,s),e.restore())}getLineWidthForValue(e){const t=this.options.grid;if(!this._isVisible()||!t.display)return 0;const n=this.ticks.findIndex(t=>t.value===e);if(n>=0){return t.setContext(this.getContext(n)).lineWidth}return 0}drawGrid(e){const t=this.options.grid,n=this.ctx,a=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(e));let r,s;const i=(e,t,a)=>{a.width&&a.color&&(n.save(),n.lineWidth=a.width,n.strokeStyle=a.color,n.setLineDash(a.borderDash||[]),n.lineDashOffset=a.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(r=0,s=a.length;r<s;++r){const e=a[r];t.drawOnChartArea&&i({x:e.x1,y:e.y1},{x:e.x2,y:e.y2},e),t.drawTicks&&i({x:e.tx1,y:e.ty1},{x:e.tx2,y:e.ty2},{color:e.tickColor,width:e.tickWidth,borderDash:e.tickBorderDash,borderDashOffset:e.tickBorderDashOffset})}}drawBorder(){const{chart:e,ctx:t,options:{border:n,grid:a}}=this,r=n.setContext(this.getContext()),s=n.display?r.width:0;if(!s)return;const i=a.setContext(this.getContext(0)).lineWidth,o=this._borderValue;let l,c,d,u;this.isHorizontal()?(l=TB(e,this.left,s)-s/2,c=TB(e,this.right,i)+i/2,d=u=o):(d=TB(e,this.top,s)-s/2,u=TB(e,this.bottom,i)+i/2,l=c=o),t.save(),t.lineWidth=r.width,t.strokeStyle=r.color,t.beginPath(),t.moveTo(l,d),t.lineTo(c,u),t.stroke(),t.restore()}drawLabels(e){if(!this.options.ticks.display)return;const t=this.ctx,n=this._computeLabelArea();n&&PB(t,n);const a=this.getLabelItems(e);for(const r of a){const e=r.options,n=r.font;VB(t,r.label,0,r.textOffset,n,e)}n&&LB(t)}drawTitle(){const{ctx:e,options:{position:t,title:n,reverse:a}}=this;if(!n.display)return;const r=QB(n.font),s=$B(n.padding),i=n.align;let o=r.lineHeight/2;"bottom"===t||"center"===t||l_(t)?(o+=s.bottom,o_(n.text)&&(o+=r.lineHeight*(n.text.length-1))):o+=s.top;const{titleX:l,titleY:c,maxWidth:d,rotation:u}=function(e,t,n,a){const{top:r,left:s,bottom:i,right:o,chart:l}=e,{chartArea:c,scales:d}=l;let u,m,h,p=0;const g=i-r,x=o-s;if(e.isHorizontal()){if(m=oB(a,s,o),l_(n)){const e=Object.keys(n)[0],a=n[e];h=d[e].getPixelForValue(a)+g-t}else h="center"===n?(c.bottom+c.top)/2+g-t:bL(e,n,t);u=o-s}else{if(l_(n)){const e=Object.keys(n)[0],a=n[e];m=d[e].getPixelForValue(a)-x+t}else m="center"===n?(c.left+c.right)/2-x+t:bL(e,n,t);h=oB(a,i,r),p="left"===n?-__:__}return{titleX:m,titleY:h,maxWidth:u,rotation:p}}(this,o,t,i);VB(e,n.text,0,0,r,{color:n.color,maxWidth:d,rotation:u,textAlign:DL(i,t,a),textBaseline:"middle",translation:[l,c]})}draw(e){this._isVisible()&&(this.drawBackground(),this.drawGrid(e),this.drawBorder(),this.drawTitle(),this.drawLabels(e))}_layers(){const e=this.options,t=e.ticks&&e.ticks.z||0,n=u_(e.grid&&e.grid.z,-1),a=u_(e.border&&e.border.z,0);return this._isVisible()&&this.draw===CL.prototype.draw?[{z:n,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:a,draw:()=>{this.drawBorder()}},{z:t,draw:e=>{this.drawLabels(e)}}]:[{z:t,draw:e=>{this.draw(e)}}]}getMatchingVisibleMetas(e){const t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",a=[];let r,s;for(r=0,s=t.length;r<s;++r){const s=t[r];s[n]!==this.id||e&&s.type!==e||a.push(s)}return a}_resolveTickFontOptions(e){return QB(this.options.ticks.setContext(this.getContext(e)).font)}_maxDigits(){const e=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/e}}class NL{constructor(e,t,n){this.type=e,this.scope=t,this.override=n,this.items=Object.create(null)}isForType(e){return Object.prototype.isPrototypeOf.call(this.type.prototype,e.prototype)}register(e){const t=Object.getPrototypeOf(e);let n;(function(e){return"id"in e&&"defaults"in e})(t)&&(n=this.register(t));const a=this.items,r=e.id,s=this.scope+"."+r;if(!r)throw new Error("class does not have id: "+e);return r in a||(a[r]=e,function(e,t,n){const a=y_(Object.create(null),[n?SB.get(n):{},SB.get(t),e.defaults]);SB.set(t,a),e.defaultRoutes&&function(e,t){Object.keys(t).forEach(n=>{const a=n.split("."),r=a.pop(),s=[e].concat(a).join("."),i=t[n].split("."),o=i.pop(),l=i.join(".");SB.route(s,r,l,o)})}(t,e.defaultRoutes);e.descriptors&&SB.describe(t,e.descriptors)}(e,s,n),this.override&&SB.override(e.id,e.overrides)),s}get(e){return this.items[e]}unregister(e){const t=this.items,n=e.id,a=this.scope;n in t&&delete t[n],a&&n in SB[a]&&(delete SB[a][n],this.override&&delete jB[n])}}class FL{constructor(){this.controllers=new NL(mP,"datasets",!0),this.elements=new NL(gL,"elements"),this.plugins=new NL(Object,"plugins"),this.scales=new NL(CL,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("register",t)}remove(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("unregister",t)}addControllers(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("register",t,this.controllers)}addElements(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("register",t,this.elements)}addPlugins(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("register",t,this.plugins)}addScales(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("register",t,this.scales)}getController(e){return this._get(e,this.controllers,"controller")}getElement(e){return this._get(e,this.elements,"element")}getPlugin(e){return this._get(e,this.plugins,"plugin")}getScale(e){return this._get(e,this.scales,"scale")}removeControllers(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("unregister",t,this.controllers)}removeElements(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("unregister",t,this.elements)}removePlugins(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("unregister",t,this.plugins)}removeScales(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._each("unregister",t,this.scales)}_each(e,t,n){[...t].forEach(t=>{const a=n||this._getRegistryForType(t);n||a.isForType(t)||a===this.plugins&&t.id?this._exec(e,a,t):p_(t,t=>{const a=n||this._getRegistryForType(t);this._exec(e,a,t)})})}_exec(e,t,n){const a=D_(e);h_(n["before"+a],[],n),t[e](n),h_(n["after"+a],[],n)}_getRegistryForType(e){for(let t=0;t<this._typedRegistries.length;t++){const n=this._typedRegistries[t];if(n.isForType(e))return n}return this.plugins}_get(e,t,n){const a=t.get(e);if(void 0===a)throw new Error('"'+e+'" is not a registered '+n+".");return a}}var SL=new FL;class EL{constructor(){this._init=[]}notify(e,t,n,a){"beforeInit"===t&&(this._init=this._createDescriptors(e,!0),this._notify(this._init,e,"install"));const r=a?this._descriptors(e).filter(a):this._descriptors(e),s=this._notify(r,e,t,n);return"afterDestroy"===t&&(this._notify(r,e,"stop"),this._notify(this._init,e,"uninstall")),s}_notify(e,t,n,a){a=a||{};for(const r of e){const e=r.plugin;if(!1===h_(e[n],[t,a,r.options],e)&&a.cancelable)return!1}return!0}invalidate(){i_(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(e){if(this._cache)return this._cache;const t=this._cache=this._createDescriptors(e);return this._notifyStateChanges(e),t}_createDescriptors(e,t){const n=e&&e.config,a=u_(n.options&&n.options.plugins,{}),r=function(e){const t={},n=[],a=Object.keys(SL.plugins.items);for(let s=0;s<a.length;s++)n.push(SL.getPlugin(a[s]));const r=e.plugins||[];for(let s=0;s<r.length;s++){const e=r[s];-1===n.indexOf(e)&&(n.push(e),t[e.id]=!0)}return{plugins:n,localIds:t}}(n);return!1!==a||t?function(e,t,n,a){let{plugins:r,localIds:s}=t;const i=[],o=e.getContext();for(const l of r){const t=l.id,r=AL(n[t],a);null!==r&&i.push({plugin:l,options:TL(e.config,{plugin:l,local:s[t]},r,o)})}return i}(e,r,a,t):[]}_notifyStateChanges(e){const t=this._oldCache||[],n=this._cache,a=(e,t)=>e.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(a(t,n),e,"stop"),this._notify(a(n,t),e,"start")}}function AL(e,t){return t||!1!==e?!0===e?{}:e:null}function TL(e,t,n,a){let{plugin:r,local:s}=t;const i=e.pluginScopeKeys(r),o=e.getOptionScopes(n,i);return s&&r.defaults&&o.push(r.defaults),e.createResolver(o,a,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function ML(e,t){const n=SB.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function _L(e){if("x"===e||"y"===e||"r"===e)return e}function BL(e){return"top"===e||"bottom"===e?"x":"left"===e||"right"===e?"y":void 0}function IL(e){if(_L(e))return e;for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];for(const r of n){const t=r.axis||BL(r.position)||e.length>1&&_L(e[0].toLowerCase());if(t)return t}throw new Error("Cannot determine type of '".concat(e,"' axis. Please provide 'axis' or 'position' option."))}function PL(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function LL(e,t){const n=jB[e.type]||{scales:{}},a=t.scales||{},r=ML(e.type,t),s=Object.create(null);return Object.keys(a).forEach(t=>{const i=a[t];if(!l_(i))return console.error("Invalid scale configuration for scale: ".concat(t));if(i._proxy)return console.warn("Ignoring resolver passed as options for scale: ".concat(t));const o=IL(t,i,function(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return PL(e,"x",n[0])||PL(e,"y",n[0])}return{}}(t,e),SB.scales[i.type]),l=function(e,t){return e===t?"_index_":"_value_"}(o,r),c=n.scales||{};s[t]=v_(Object.create(null),[{axis:o},i,c[o],c[l]])}),e.data.datasets.forEach(n=>{const r=n.type||e.type,i=n.indexAxis||ML(r,t),o=(jB[r]||{}).scales||{};Object.keys(o).forEach(e=>{const t=function(e,t){let n=e;return"_index_"===e?n=t:"_value_"===e&&(n="x"===t?"y":"x"),n}(e,i),r=n[t+"AxisID"]||t;s[r]=s[r]||Object.create(null),v_(s[r],[{axis:t},a[r],o[e]])})}),Object.keys(s).forEach(e=>{const t=s[e];v_(t,[SB.scales[t.type],SB.scale])}),s}function RL(e){const t=e.options||(e.options={});t.plugins=u_(t.plugins,{}),t.scales=LL(e,t)}function zL(e){return(e=e||{}).datasets=e.datasets||[],e.labels=e.labels||[],e}const OL=new Map,UL=new Set;function VL(e,t){let n=OL.get(e);return n||(n=t(),OL.set(e,n),UL.add(n)),n}const HL=(e,t,n)=>{const a=j_(t,n);void 0!==a&&e.add(a)};class qL{constructor(e){this._config=function(e){return(e=e||{}).data=zL(e.data),RL(e),e}(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=zL(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){const e=this._config;this.clearCache(),RL(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return VL(e,()=>[["datasets.".concat(e),""]])}datasetAnimationScopeKeys(e,t){return VL("".concat(e,".transition.").concat(t),()=>[["datasets.".concat(e,".transitions.").concat(t),"transitions.".concat(t)],["datasets.".concat(e),""]])}datasetElementScopeKeys(e,t){return VL("".concat(e,"-").concat(t),()=>[["datasets.".concat(e,".elements.").concat(t),"datasets.".concat(e),"elements.".concat(t),""]])}pluginScopeKeys(e){const t=e.id,n=this.type;return VL("".concat(n,"-plugin-").concat(t),()=>[["plugins.".concat(t),...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){const n=this._scopeCache;let a=n.get(e);return a&&!t||(a=new Map,n.set(e,a)),a}getOptionScopes(e,t,n){const{options:a,type:r}=this,s=this._cachedScopes(e,n),i=s.get(t);if(i)return i;const o=new Set;t.forEach(t=>{e&&(o.add(e),t.forEach(t=>HL(o,e,t))),t.forEach(e=>HL(o,a,e)),t.forEach(e=>HL(o,jB[r]||{},e)),t.forEach(e=>HL(o,SB,e)),t.forEach(e=>HL(o,DB,e))});const l=Array.from(o);return 0===l.length&&l.push(Object.create(null)),UL.has(t)&&s.set(t,l),l}chartOptionScopes(){const{options:e,type:t}=this;return[e,jB[t]||{},SB.datasets[t]||{},{type:t},SB,DB]}resolveNamedOptions(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[""];const r={$shared:!0},{resolver:s,subPrefixes:i}=WL(this._resolverCache,e,a);let o=s;if(function(e,t){const{isScriptable:n,isIndexable:a}=aI(e);for(const r of t){const t=n(r),s=a(r),i=(s||t)&&e[r];if(t&&(N_(i)||YL(i))||s&&o_(i))return!0}return!1}(s,t)){r.$shared=!1;o=nI(s,n=N_(n)?n():n,this.createResolver(e,n,i))}for(const l of t)r[l]=o[l];return r}createResolver(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[""],a=arguments.length>3?arguments[3]:void 0;const{resolver:r}=WL(this._resolverCache,e,n);return l_(t)?nI(r,t,void 0,a):r}}function WL(e,t,n){let a=e.get(t);a||(a=new Map,e.set(t,a));const r=n.join();let s=a.get(r);if(!s){s={resolver:tI(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes("hover"))},a.set(r,s)}return s}const YL=e=>l_(e)&&Object.getOwnPropertyNames(e).some(t=>N_(e[t]));const GL=["top","bottom","left","right","chartArea"];function KL(e,t){return"top"===e||"bottom"===e||-1===GL.indexOf(e)&&"x"===t}function XL(e,t){return function(n,a){return n[e]===a[e]?n[t]-a[t]:n[e]-a[e]}}function JL(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),h_(n&&n.onComplete,[e],t)}function $L(e){const t=e.chart,n=t.options.animation;h_(n&&n.onProgress,[e],t)}function QL(e){return kI()&&"string"===typeof e?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const ZL={},eR=e=>{const t=QL(e);return Object.values(ZL).filter(e=>e.canvas===t).pop()};function tR(e,t,n){const a=Object.keys(e);for(const r of a){const a=+r;if(a>=t){const s=e[r];delete e[r],(n>0||a>t)&&(e[a+n]=s)}}}class nR{static register(){SL.add(...arguments),aR()}static unregister(){SL.remove(...arguments),aR()}constructor(e,t){const n=this.config=new qL(t),a=QL(e),r=eR(a);if(r)throw new Error("Canvas is already in use. Chart with ID '"+r.id+"' must be destroyed before the canvas with ID '"+r.canvas.id+"' can be reused.");const s=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||function(e){return!kI()||"undefined"!==typeof OffscreenCanvas&&e instanceof OffscreenCanvas?ZP:pL}(a)),this.platform.updateConfig(n);const i=this.platform.acquireContext(a,s.aspectRatio),o=i&&i.canvas,l=o&&o.height,c=o&&o.width;this.id=s_(),this.ctx=i,this.canvas=o,this.width=c,this.height=l,this._options=s,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new EL,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=function(e,t){let n;return function(){for(var a=arguments.length,r=new Array(a),s=0;s<a;s++)r[s]=arguments[s];return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}(e=>this.update(e),s.resizeDelay||0),this._dataChanges=[],ZL[this.id]=this,i&&o?(JI.listen(this,"complete",JL),JI.listen(this,"progress",$L),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:a,_aspectRatio:r}=this;return i_(e)?t&&r?r:a?n/a:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return SL}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():TI(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return MB(this.canvas,this.ctx),this}stop(){return JI.stop(this),this}resize(e,t){JI.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){const n=this.options,a=this.canvas,r=n.maintainAspectRatio&&this.aspectRatio,s=this.platform.getMaximumSize(a,e,t,r),i=n.devicePixelRatio||this.platform.getDevicePixelRatio(),o=this.width?"resize":"attach";this.width=s.width,this.height=s.height,this._aspectRatio=this.aspectRatio,TI(this,i,!0)&&(this.notifyPlugins("resize",{size:s}),h_(n.onResize,[this,s],this),this.attached&&this._doResize(o)&&this.render())}ensureScalesHaveIDs(){p_(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){const e=this.options,t=e.scales,n=this.scales,a=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{});let r=[];t&&(r=r.concat(Object.keys(t).map(e=>{const n=t[e],a=IL(e,n),r="r"===a,s="x"===a;return{options:n,dposition:r?"chartArea":s?"bottom":"left",dtype:r?"radialLinear":s?"category":"linear"}}))),p_(r,t=>{const r=t.options,s=r.id,i=IL(s,r),o=u_(r.type,t.dtype);void 0!==r.position&&KL(r.position,i)===KL(t.dposition)||(r.position=t.dposition),a[s]=!0;let l=null;if(s in n&&n[s].type===o)l=n[s];else{l=new(SL.getScale(o))({id:s,type:o,ctx:this.ctx,chart:this}),n[l.id]=l}l.init(r,e)}),p_(a,(e,t)=>{e||delete n[t]}),p_(n,e=>{$P.configure(this,e,e.options),$P.addBox(this,e)})}_updateMetasets(){const e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;e<n;++e)this._destroyDatasetMeta(e);e.splice(t,n-t)}this._sortedMetasets=e.slice(0).sort(XL("order","index"))}_removeUnreferencedMetasets(){const{_metasets:e,data:{datasets:t}}=this;e.length>t.length&&delete this._stacks,e.forEach((e,n)=>{0===t.filter(t=>t===e._dataset).length&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){const e=[],t=this.data.datasets;let n,a;for(this._removeUnreferencedMetasets(),n=0,a=t.length;n<a;n++){const a=t[n];let r=this.getDatasetMeta(n);const s=a.type||this.config.type;if(r.type&&r.type!==s&&(this._destroyDatasetMeta(n),r=this.getDatasetMeta(n)),r.type=s,r.indexAxis=a.indexAxis||ML(s,this.options),r.order=a.order||0,r.index=n,r.label=""+a.label,r.visible=this.isDatasetVisible(n),r.controller)r.controller.updateIndex(n),r.controller.linkScales();else{const t=SL.getController(s),{datasetElementType:a,dataElementType:i}=SB.datasets[s];Object.assign(t,{dataElementType:SL.getElement(i),datasetElementType:a&&SL.getElement(a)}),r.controller=new t(this,n),e.push(r.controller)}}return this._updateMetasets(),e}_resetElements(){p_(this.data.datasets,(e,t)=>{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(e){const t=this.config;t.update();const n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),a=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:e,cancelable:!0}))return;const r=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let s=0;for(let l=0,c=this.data.datasets.length;l<c;l++){const{controller:e}=this.getDatasetMeta(l),t=!a&&-1===r.indexOf(e);e.buildOrUpdateElements(t),s=Math.max(+e.getMaxOverflow(),s)}s=this._minPadding=n.layout.autoPadding?s:0,this._updateLayout(s),a||p_(r,e=>{e.reset()}),this._updateDatasets(e),this.notifyPlugins("afterUpdate",{mode:e}),this._layers.sort(XL("z","_idx"));const{_active:i,_lastEvent:o}=this;o?this._eventHandler(o,!0):i.length&&this._updateHoverStyles(i,i,!0),this.render()}_updateScales(){p_(this.scales,e=>{$P.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const e=this.options,t=new Set(Object.keys(this._listeners)),n=new Set(e.events);F_(t,n)&&!!this._responsiveListeners===e.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(const{method:n,start:a,count:r}of t){tR(e,a,"_removeElements"===n?-r:r)}}_getUniformDataChanges(){const e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];const t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+","+e.splice(1).join(","))),a=n(0);for(let r=1;r<t;r++)if(!F_(a,n(r)))return;return Array.from(a).map(e=>e.split(",")).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;$P.update(this,this.width,this.height,e);const t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],p_(this.boxes,e=>{n&&"chartArea"===e.position||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins("afterLayout")}_updateDatasets(e){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:e,cancelable:!0})){for(let e=0,t=this.data.datasets.length;e<t;++e)this.getDatasetMeta(e).controller.configure();for(let t=0,n=this.data.datasets.length;t<n;++t)this._updateDataset(t,N_(e)?e({datasetIndex:t}):e);this.notifyPlugins("afterDatasetsUpdate",{mode:e})}}_updateDataset(e,t){const n=this.getDatasetMeta(e),a={meta:n,index:e,mode:t,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetUpdate",a)&&(n.controller._update(t),a.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",a))}render(){!1!==this.notifyPlugins("beforeRender",{cancelable:!0})&&(JI.has(this)?this.attached&&!JI.running(this)&&JI.start(this):(this.draw(),JL({chart:this})))}draw(){let e;if(this._resizeBeforeDraw){const{width:e,height:t}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(e,t)}if(this.clear(),this.width<=0||this.height<=0)return;if(!1===this.notifyPlugins("beforeDraw",{cancelable:!0}))return;const t=this._layers;for(e=0;e<t.length&&t[e].z<=0;++e)t[e].draw(this.chartArea);for(this._drawDatasets();e<t.length;++e)t[e].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(e){const t=this._sortedMetasets,n=[];let a,r;for(a=0,r=t.length;a<r;++a){const r=t[a];e&&!r.visible||n.push(r)}return n}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(!1===this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0}))return;const e=this.getSortedVisibleDatasetMetas();for(let t=e.length-1;t>=0;--t)this._drawDataset(e[t]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(e){const t=this.ctx,n={meta:e,index:e.index,cancelable:!0},a=KI(this,e);!1!==this.notifyPlugins("beforeDatasetDraw",n)&&(a&&PB(t,a),e.controller.draw(),a&&LB(t),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(e){return IB(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,a){const r=RP.modes[t];return"function"===typeof r?r(this,e,n,a):[]}getDatasetMeta(e){const t=this.data.datasets[e],n=this._metasets;let a=n.filter(e=>e&&e._dataset===t).pop();return a||(a={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(a)),a}getContext(){return this.$context||(this.$context=eI(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){const t=this.data.datasets[e];if(!t)return!1;const n=this.getDatasetMeta(e);return"boolean"===typeof n.hidden?!n.hidden:!t.hidden}setDatasetVisibility(e,t){this.getDatasetMeta(e).hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){const a=n?"show":"hide",r=this.getDatasetMeta(e),s=r.controller._resolveAnimations(void 0,a);C_(t)?(r.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),s.update(r,{visible:n}),this.update(t=>t.datasetIndex===e?a:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){const t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),JI.remove(this),e=0,t=this.data.datasets.length;e<t;++e)this._destroyDatasetMeta(e)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:e,ctx:t}=this;this._stop(),this.config.clearCache(),e&&(this.unbindEvents(),MB(e,t),this.platform.releaseContext(t),this.canvas=null,this.ctx=null),delete ZL[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(){return this.canvas.toDataURL(...arguments)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const e=this._listeners,t=this.platform,n=(n,a)=>{t.addEventListener(this,n,a),e[n]=a},a=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};p_(this.options.events,e=>n(e,a))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const e=this._responsiveListeners,t=this.platform,n=(n,a)=>{t.addEventListener(this,n,a),e[n]=a},a=(n,a)=>{e[n]&&(t.removeEventListener(this,n,a),delete e[n])},r=(e,t)=>{this.canvas&&this.resize(e,t)};let s;const i=()=>{a("attach",i),this.attached=!0,this.resize(),n("resize",r),n("detach",s)};s=()=>{this.attached=!1,a("resize",r),this._stop(),this._resize(0,0),n("attach",i)},t.isAttached(this.canvas)?i():s()}unbindEvents(){p_(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},p_(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){const a=n?"set":"remove";let r,s,i,o;for("dataset"===t&&(r=this.getDatasetMeta(e[0].datasetIndex),r.controller["_"+a+"DatasetHoverStyle"]()),i=0,o=e.length;i<o;++i){s=e[i];const t=s&&this.getDatasetMeta(s.datasetIndex).controller;t&&t[a+"HoverStyle"](s.element,s.datasetIndex,s.index)}}getActiveElements(){return this._active||[]}setActiveElements(e){const t=this._active||[],n=e.map(e=>{let{datasetIndex:t,index:n}=e;const a=this.getDatasetMeta(t);if(!a)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:a.data[n],index:n}});!g_(n,t)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return 1===this._plugins._cache.filter(t=>t.plugin.id===e).length}
vendor: 5,859 bytes, line 2
2_updateHoverStyles(e,t,n){const a=this.options.hover,r=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),s=r(t,e),i=n?e:r(e,t);s.length&&this.updateHoverStyle(s,a.mode,!1),i.length&&a.mode&&this.updateHoverStyle(i,a.mode,!0)}_eventHandler(e,t){const n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},a=t=>(t.options.events||this.options.events).includes(e.native.type);if(!1===this.notifyPlugins("beforeEvent",n,a))return;const r=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,a),(r||n.changed)&&this.render(),this}_handleEvent(e,t,n){const{_active:a=[],options:r}=this,s=t,i=this._getActiveElements(e,a,n,s),o=function(e){return"mouseup"===e.type||"click"===e.type||"contextmenu"===e.type}(e),l=function(e,t,n,a){return n&&"mouseout"!==e.type?a?t:e:null}(e,this._lastEvent,n,o);n&&(this._lastEvent=null,h_(r.onHover,[e,i,this],this),o&&h_(r.onClick,[e,i,this],this));const c=!g_(i,a);return(c||t)&&(this._active=i,this._updateHoverStyles(i,a,t)),this._lastEvent=l,c}_getActiveElements(e,t,n,a){if("mouseout"===e.type)return[];if(!n)return t;const r=this.options.hover;return this.getElementsAtEventForMode(e,r.mode,r,a)}}function aR(){return p_(nR.instances,e=>e._plugins.invalidate())}function rR(e,t,n,a){const r=KB(e.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const s=(n-t)/2,i=Math.min(s,a*t/2),o=e=>{const t=(n-Math.min(s,e))*a/2;return J_(e,0,Math.min(s,t))};return{outerStart:o(r.outerStart),outerEnd:o(r.outerEnd),innerStart:J_(r.innerStart,0,i),innerEnd:J_(r.innerEnd,0,i)}}function sR(e,t,n,a){return{x:n+e*Math.cos(t),y:a+e*Math.sin(t)}}function iR(e,t,n,a,r,s){const{x:i,y:o,startAngle:l,pixelMargin:c,innerRadius:d}=t,u=Math.max(t.outerRadius+a+n-c,0),m=d>0?d+a+n+c:0;let h=0;const p=r-l;if(a){const e=((d>0?d-a:0)+(u>0?u-a:0))/2;h=(p-(0!==e?p*e/(e+a):p))/2}const g=(p-Math.max(.001,p*u-n/S_)/u)/2,x=l+g+h,f=r-g-h,{outerStart:b,outerEnd:y,innerStart:v,innerEnd:w}=rR(t,m,u,f-x),k=u-b,j=u-y,D=x+b/k,C=f-y/j,N=m+v,F=m+w,S=x+v/N,E=f-w/F;if(e.beginPath(),s){const t=(D+C)/2;if(e.arc(i,o,u,D,t),e.arc(i,o,u,t,C),y>0){const t=sR(j,C,i,o);e.arc(t.x,t.y,y,C,f+__)}const n=sR(F,f,i,o);if(e.lineTo(n.x,n.y),w>0){const t=sR(F,E,i,o);e.arc(t.x,t.y,w,f+__,E+Math.PI)}const a=(f-w/m+(x+v/m))/2;if(e.arc(i,o,m,f-w/m,a,!0),e.arc(i,o,m,a,x+v/m,!0),v>0){const t=sR(N,S,i,o);e.arc(t.x,t.y,v,S+Math.PI,x-__)}const r=sR(k,x,i,o);if(e.lineTo(r.x,r.y),b>0){const t=sR(k,D,i,o);e.arc(t.x,t.y,b,x-__,D)}}else{e.moveTo(i,o);const t=Math.cos(D)*u+i,n=Math.sin(D)*u+o;e.lineTo(t,n);const a=Math.cos(C)*u+i,r=Math.sin(C)*u+o;e.lineTo(a,r)}e.closePath()}function oR(e,t,n,a,r){const{fullCircles:s,startAngle:i,circumference:o,options:l}=t,{borderWidth:c,borderJoinStyle:d,borderDash:u,borderDashOffset:m,borderRadius:h}=l,p="inner"===l.borderAlign;if(!c)return;e.setLineDash(u||[]),e.lineDashOffset=m,p?(e.lineWidth=2*c,e.lineJoin=d||"round"):(e.lineWidth=c,e.lineJoin=d||"bevel");let g=t.endAngle;if(s){iR(e,t,n,a,g,r);for(let t=0;t<s;++t)e.stroke();isNaN(o)||(g=i+(o%E_||E_))}p&&function(e,t,n){const{startAngle:a,pixelMargin:r,x:s,y:i,outerRadius:o,innerRadius:l}=t;let c=r/o;e.beginPath(),e.arc(s,i,o,a-c,n+c),l>r?(c=r/l,e.arc(s,i,l,n+c,a-c,!0)):e.arc(s,i,r,n+__,a-__),e.closePath(),e.clip()}(e,t,g),l.selfJoin&&g-i>=S_&&0===h&&"miter"!==d&&function(e,t,n){const{startAngle:a,x:r,y:s,outerRadius:i,innerRadius:o,options:l}=t,{borderWidth:c,borderJoinStyle:d}=l,u=Math.min(c/i,K_(a-n));if(e.beginPath(),e.arc(r,s,i-c/2,a+u/2,n-u/2),o>0){const t=Math.min(c/o,K_(a-n));e.arc(r,s,o+c/2,n-t/2,a+t/2,!0)}else{const t=Math.min(c/2,i*K_(a-n));if("round"===d)e.arc(r,s,t,n-S_/2,a+S_/2,!0);else if("bevel"===d){const i=2*t*t,o=-i*Math.cos(n+S_/2)+r,l=-i*Math.sin(n+S_/2)+s,c=i*Math.cos(a+S_/2)+r,d=i*Math.sin(a+S_/2)+s;e.lineTo(o,l),e.lineTo(c,d)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip("evenodd")}(e,t,g),s||(iR(e,t,n,a,g,r),e.stroke())}l(nR,"defaults",SB),l(nR,"instances",ZL),l(nR,"overrides",jB),l(nR,"registry",SL),l(nR,"version","4.5.0"),l(nR,"getChart",eR);class lR extends gL{constructor(e){super(),l(this,"circumference",void 0),l(this,"endAngle",void 0),l(this,"fullCircles",void 0),l(this,"innerRadius",void 0),l(this,"outerRadius",void 0),l(this,"pixelMargin",void 0),l(this,"startAngle",void 0),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){const a=this.getProps(["x","y"],n),{angle:r,distance:s}=W_(a,{x:e,y:t}),{startAngle:i,endAngle:o,innerRadius:l,outerRadius:c,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],n),u=(this.options.spacing+this.options.borderWidth)/2,m=u_(d,o-i),h=X_(r,i,o)&&i!==o,p=m>=E_||h,g=$_(s,l+u,c+u);return p&&g}getCenterPoint(e){const{x:t,y:n,startAngle:a,endAngle:r,innerRadius:s,outerRadius:i}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],e),{offset:o,spacing:l}=this.options,c=(a+r)/2,d=(s+i+l+o)/2;return{x:t+Math.cos(c)*d,y:n+Math.sin(c)*d}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){const{options:t,circumference:n}=this,a=(t.offset||0)/4,r=(t.spacing||0)/2,s=t.circular;if(this.pixelMargin="inner"===t.borderAlign?.33:0,this.fullCircles=n>E_?Math.floor(n/E_):0,0===n||this.innerRadius<0||this.outerRadius<0)return;e.save();const i=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(i)*a,Math.sin(i)*a);const o=a*(1-Math.sin(Math.min(S_,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,function(e,t,n,a,r){const{fullCircles:s,startAngle:i,circumference:o}=t;let l=t.endAngle;if(s){iR(e,t,n,a,l,r);for(let t=0;t<s;++t)e.fill();isNaN(o)||(l=i+(o%E_||E_))}iR(e,t,n,a,l,r),e.fill()}
vendor: 4,636 bytes, line 2
2(e,this,o,r,s),oR(e,this,o,r,s),e.restore()}}function cR(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;e.lineCap=u_(n.borderCapStyle,t.borderCapStyle),e.setLineDash(u_(n.borderDash,t.borderDash)),e.lineDashOffset=u_(n.borderDashOffset,t.borderDashOffset),e.lineJoin=u_(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=u_(n.borderWidth,t.borderWidth),e.strokeStyle=u_(n.borderColor,t.borderColor)}function dR(e,t,n){e.lineTo(n.x,n.y)}function uR(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=e.length,{start:r=0,end:s=a-1}=n,{start:i,end:o}=t,l=Math.max(r,i),c=Math.min(s,o),d=r<i&&s<i||r>o&&s>o;return{count:a,start:l,loop:t.loop,ilen:c<l&&!d?a+c-l:c-l}}function mR(e,t,n,a){const{points:r,options:s}=t,{count:i,start:o,loop:l,ilen:c}=uR(r,n,a),d=function(e){return e.stepped?RB:e.tension||"monotone"===e.cubicInterpolationMode?zB:dR}(s);let u,m,h,{move:p=!0,reverse:g}=a||{};for(u=0;u<=c;++u)m=r[(o+(g?c-u:u))%i],m.skip||(p?(e.moveTo(m.x,m.y),p=!1):d(e,h,m,g,s.stepped),h=m);return l&&(m=r[(o+(g?c:0))%i],d(e,h,m,g,s.stepped)),!!l}function hR(e,t,n,a){const r=t.points,{count:s,start:i,ilen:o}=uR(r,n,a),{move:l=!0,reverse:c}=a||{};let d,u,m,h,p,g,x=0,f=0;const b=e=>(i+(c?o-e:e))%s,y=()=>{h!==p&&(e.lineTo(x,p),e.lineTo(x,h),e.lineTo(x,g))};for(l&&(u=r[b(0)],e.moveTo(u.x,u.y)),d=0;d<=o;++d){if(u=r[b(d)],u.skip)continue;const t=u.x,n=u.y,a=0|t;a===m?(n<h?h=n:n>p&&(p=n),x=(f*x+t)/++f):(y(),e.lineTo(t,n),m=a,f=0,h=p=n),g=n}y()}function pR(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&"monotone"!==t.cubicInterpolationMode&&!t.stepped&&!n?hR:mR}l(lR,"id","arc"),l(lR,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1}),l(lR,"defaultRoutes",{backgroundColor:"backgroundColor"}),l(lR,"descriptors",{_scriptable:!0,_indexable:e=>"borderDash"!==e});const gR="function"===typeof Path2D;function xR(e,t,n,a){gR&&!t.options.segment?function(e,t,n,a){let r=t._path;r||(r=t._path=new Path2D,t.path(r,n,a)&&r.closePath()),cR(e,t.options),e.stroke(r)}(e,t,n,a):function(e,t,n,a){const{segments:r,options:s}=t,i=pR(t);for(const o of r)cR(e,s,o.style),e.beginPath(),i(e,t,o,{start:n,end:n+a-1})&&e.closePath(),e.stroke()}(e,t,n,a)}class fR extends gL{constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){const n=this.options;if((n.tension||"monotone"===n.cubicInterpolationMode)&&!n.stepped&&!this._pointsUpdated){const a=n.spanGaps?this._loop:this._fullLoop;wI(this._points,n,e,a,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=function(e,t){const n=e.points,a=e.options.spanGaps,r=n.length;if(!r)return[];const s=!!e._loop,{start:i,end:o}=function(e,t,n,a){let r=0,s=t-1;if(n&&!a)for(;r<t&&!e[r].skip;)r++;for(;r<t&&e[r].skip;)r++;for(r%=t,n&&(s+=r);s>r&&e[s%t].skip;)s--;return s%=t,{start:r,end:s}}(n,r,s,a);return qI(e,!0===a?[{start:i,end:o,loop:s}]:function(e,t,n,a){const r=e.length,s=[];let i,o=t,l=e[t];for(i=t+1;i<=n;++i){const n=e[i%r];n.skip||n.stop?l.skip||(a=!1,s.push({start:t%r,end:(i-1)%r,loop:a}),t=o=n.stop?i:null):(o=i,l.skip&&(t=i)),l=n}return null!==o&&s.push({start:t%r,end:o%r,loop:a}),s}(n,i,o<i?o+r:o,!!e._fullLoop&&0===i&&o===r-1),n,t)}(this,this.options.segment))}first(){const e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){const e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){const n=this.options,a=e[t],r=this.points,s=HI(this,{property:t,start:a,end:a});if(!s.length)return;const i=[],o=function(e){return e.stepped?II:e.tension||"monotone"===e.cubicInterpolationMode?PI:BI}(n);let l,c;for(l=0,c=s.length;l<c;++l){const{start:c,end:d}=s[l],u=r[c],m=r[d];if(u===m){i.push(u);continue}const h=o(u,m,Math.abs((a-u[t])/(m[t]-u[t])),n.stepped);h[t]=e[t],i.push(h)}return 1===i.length?i[0]:i}pathSegment(e,t,n){return pR(this)(e,this,t,n)}path(e,t,n){const a=this.segments,r=pR(this);let s=this._loop;t=t||0,n=n||this.points.length-t;for(const i of a)s&=r(e,this,i,{start:t,end:t+n-1});return!!s}draw(e,t,n,a){const r=this.options||{};(this.points||[]).length&&r.borderWidth&&(e.save(),xR(e,this,n,a),e.restore(
2)),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function bR(e,t,n,a){const r=e.options,{[n]:s}=e.getProps([n],a);return Math.abs(t-s)<r.radius+r.hitRadius}l(fR,"id","line"),l(fR,"defaults",{borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0}),l(fR,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"}),l(fR,"descriptors",{_scriptable:!0,_indexable:e=>"borderDash"!==e&&"fill"!==e});class yR extends gL{constructor(e){super(),l(this,"parsed",void 0),l(this,"skip",void 0),l(this,"stop",void 0),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,e&&Object.assign(this,e)}inRange(e,t,n){const a=this.options,{x:r,y:s}=this.getProps(["x","y"],n);return Math.pow(e-r,2)+Math.pow(t-s,2)<Math.pow(a.hitRadius+a.radius,2)}inXRange(e,t){return bR(this,e,"x",t)}inYRange(e,t){return bR(this,e,"y",t)}getCenterPoint(e){const{x:t,y:n}=this.getProps(["x","y"],e);return{x:t,y:n}}size(e){let t=(e=e||this.options||{}).radius||0;t=Math.max(t,t&&e.hoverRadius||0);return 2*(t+(t&&e.borderWidth||0))}draw(e,t){const n=this.options;this.skip||n.radius<.1||!IB(this,t,this.size(n)/2)||(e.strokeStyle=n.borderColor,e.lineWidth=n.borderWidth,e.fillStyle=n.backgroundColor,_B(e,n,this.x,this.y))}getRange(){const e=this.options||{};return e.radius+e.hitRadius}}function vR(e,t){const{x:n,y:a,base:r,width:s,height:i}=e.getProps(["x","y","base","width","height"],t);let o,l,c,d,u;return e.horizontal?(u=i/2,o=Math.min(n,r),l=Math.max(n,r),c=a-u,d=a+u):(u=s/2,o=n-u,l=n+u,c=Math.min(a,r),d=Math.max(a,r)),{left:o,top:c,right:l,bottom:d}}function wR(e,t,n,a){return e?0:J_(t,n,a)}function kR(e){const t=vR(e),n=t.right-t.left,a=t.bottom-t.top,r=function(e,t,n){const a=e.options.borderWidth,r=e.borderSkipped,s=XB(a);return{t:wR(r.top,s.top,0,n),r:wR(r.right,s.right,0,t),b:wR(r.bottom,s.bottom,0,n),l:wR(r.left,s.left,0,t)}}(e,n/2,a/2),s=function(e,t,n){const{enableBorderRadius:a}=e.getProps(["enableBorderRadius"]),r=e.options.borderRadius,s=JB(r),i=Math.min(t,n),o=e.borderSkipped,l=a||l_(r);return{topLeft:wR(!l||o.top||o.left,s.topLeft,0,i),topRight:wR(!l||o.top||o.right,s.topRight,0,i),bottomLeft:wR(!l||o.bottom||o.left,s.bottomLeft,0,i),bottomRight:wR(!l||o.bottom||o.right,s.bottomRight,0,i)}}(e,n/2,a/2);return{outer:{x:t.left,y:t.top,w:n,h:a,radius:s},inner:{x:t.left+r.l,y:t.top+r.t,w:n-r.l-r.r,h:a-r.t-r.b,radius:{topLeft:Math.max(0,s.topLeft-Math.max(r.t,r.l)),topRight:Math.max(0,s.topRight-Math.max(r.t,r.r)),bottomLeft:Math.max(0,s.bottomLeft-Math.max(r.b,r.l)),bottomRight:Math.max(0,s.bottomRight-Math.max(r.b,r.r))}}}}function jR(e,t,n,a){const r=null===t,s=null===n,i=e&&!(r&&s)&&vR(e,a);return i&&(r||$_(t,i.left,i.right))&&(s||$_(n,i.top,i.bottom))}function DR(e,t){e.rect(t.x,t.y,t.w,t.h)}function CR(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=e.x!==n.x?-t:0,r=e.y!==n.y?-t:0,s=(e.x+e.w!==n.x+n.w?t:0)-a,i=(e.y+e.h!==n.y+n.h?t:0)-r;return{x:e.x+a,y:e.y+r,w:e.w+s,h:e.h+i,radius:e.radius}}l(yR,"id","point"),l(yR,"defaults",{borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0}),l(yR,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});class NR extends gL{constructor(e){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,e&&Object.assign(this,e)}draw(e){const{inflateAmount:t,options:{borderColor:n,backgroundColor:a}}=this,{inner:r,outer:s}=kR(this),i=(o=s.radius).topLeft||o.topRight||o.bottomLeft||o.bottomRight?HB:DR;var o;e.save(),s.w===r.w&&s.h===r.h||(e.beginPath(),i(e,CR(s,t,r)),e.clip(),i(e,CR(r,-t,s)),e.fillStyle=n,e.fill("evenodd")),e.beginPath(),i(e,CR(r,t)),e.fillStyle=a,e.fill(),e.restore()}inRange(e,t,n){return jR(this,e,t,n)}inXRange(e,t){return jR(this,e,null,t)}inYRange(e,t){return jR(this,null,e,t)}getCenterPoint(e){const{x:t,y:n,base:a,horizontal:r}=this.getProps(["x","y","base","horizontal"],e);return{x:r?(t+a)/2:t,y:r?n:(n+a)/2}}getRange(e){return"x"===e?this.width/2:this.height/2}}l(NR,"id","bar"),l(NR,"defaults",{borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmou
vendor: 9,031 bytes, line 2
2nt:"auto",pointStyle:void 0}),l(NR,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});function FR(e,t,n,a){if(a)return;let r=t[e],s=n[e];return"angle"===e&&(r=K_(r),s=K_(s)),{property:e,start:r,end:s}}function SR(e,t,n){for(;t>e;t--){const e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function ER(e,t,n,a){return e&&t?a(e[n],t[n]):e?e[n]:t?t[n]:0}function AR(e,t){let n=[],a=!1;return o_(e)?(a=!0,n=e):n=function(e,t){const{x:n=null,y:a=null}=e||{},r=t.points,s=[];return t.segments.forEach(e=>{let{start:t,end:i}=e;i=SR(t,i,r);const o=r[t],l=r[i];null!==a?(s.push({x:o.x,y:a}),s.push({x:l.x,y:a})):null!==n&&(s.push({x:n,y:o.y}),s.push({x:n,y:l.y}))}),s}(e,t),n.length?new fR({points:n,options:{tension:0},_loop:a,_fullLoop:a}):null}function TR(e){return e&&!1!==e.fill}function MR(e,t,n){let a=e[t].fill;const r=[t];let s;if(!n)return a;for(;!1!==a&&-1===r.indexOf(a);){if(!c_(a))return a;if(s=e[a],!s)return!1;if(s.visible)return a;r.push(a),a=s.fill}return!1}function _R(e,t,n){const a=function(e){const t=e.options,n=t.fill;let a=u_(n&&n.target,n);void 0===a&&(a=!!t.backgroundColor);if(!1===a||null===a)return!1;if(!0===a)return"origin";return a}(e);if(l_(a))return!isNaN(a.value)&&a;let r=parseFloat(a);return c_(r)&&Math.floor(r)===r?function(e,t,n,a){"-"!==e&&"+"!==e||(n=t+n);if(n===t||n<0||n>=a)return!1;return n}(a[0],t,r,n):["origin","start","end","stack","shape"].indexOf(a)>=0&&a}function BR(e,t,n){const a=[];for(let r=0;r<n.length;r++){const s=n[r],{first:i,last:o,point:l}=IR(s,t,"x");if(!(!l||i&&o))if(i)a.unshift(l);else if(e.push(l),!o)break}e.push(...a)}function IR(e,t,n){const a=e.interpolate(t,n);if(!a)return{};const r=a[n],s=e.segments,i=e.points;let o=!1,l=!1;for(let c=0;c<s.length;c++){const e=s[c],t=i[e.start][n],a=i[e.end][n];if($_(r,t,a)){o=r===t,l=r===a;break}}return{first:o,last:l,point:a}}class PR{constructor(e){this.x=e.x,this.y=e.y,this.radius=e.radius}pathSegment(e,t,n){const{x:a,y:r,radius:s}=this;return t=t||{start:0,end:E_},e.arc(a,r,s,t.end,t.start,!0),!n.bounds}interpolate(e){const{x:t,y:n,radius:a}=this,r=e.angle;return{x:t+Math.cos(r)*a,y:n+Math.sin(r)*a,angle:r}}}function LR(e){const{chart:t,fill:n,line:a}=e;if(c_(n))return function(e,t){const n=e.getDatasetMeta(t),a=n&&e.isDatasetVisible(t);return a?n.dataset:null}(t,n);if("stack"===n)return function(e){const{scale:t,index:n,line:a}=e,r=[],s=a.segments,i=a.points,o=function(e,t){const n=[],a=e.getMatchingVisibleMetas("line");for(let r=0;r<a.length;r++){const e=a[r];if(e.index===t)break;e.hidden||n.unshift(e.dataset)}return n}(t,n);o.push(AR({x:null,y:t.bottom},a));for(let l=0;l<s.length;l++){const e=s[l];for(let t=e.start;t<=e.end;t++)BR(r,i[t],o)}return new fR({points:r,options:{}})}(e);if("shape"===n)return!0;const r=function(e){const t=e.scale||{};if(t.getPointPositionForValue)return function(e){const{scale:t,fill:n}=e,a=t.options,r=t.getLabels().length,s=a.reverse?t.max:t.min,i=function(e,t,n){let a;return a="start"===e?n:"end"===e?t.options.reverse?t.min:t.max:l_(e)?e.value:t.getBaseValue(),a}(n,t,s),o=[];if(a.grid.circular){const e=t.getPointPositionForValue(0,s);return new PR({x:e.x,y:e.y,radius:t.getDistanceFromCenterForValue(i)})}for(let l=0;l<r;++l)o.push(t.getPointPositionForValue(l,i));return o}(e);return function(e){const{scale:t={},fill:n}=e,a=function(e,t){let n=null;return"start"===e?n=t.bottom:"end"===e?n=t.top:l_(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}(n,t);if(c_(a)){const e=t.isHorizontal();return{x:e?a:null,y:e?null:a}}return null}(e)}(e);return r instanceof PR?r:AR(r,a)}function RR(e,t,n){const a=LR(t),{chart:r,index:s,line:i,scale:o,axis:l}=t,c=i.options,d=c.fill,u=c.backgroundColor,{above:m=u,below:h=u}=d||{},p=r.getDatasetMeta(s),g=KI(r,p);a&&i.points.length&&(PB(e,n),function(e,t){const{line:n,target:a,above:r,below:s,area:i,scale:o,clip:l}=t,c=n._loop?"angle":t.axis;e.save();let d=s;s!==r&&("x"===c?(zR(e,a,i.top),UR(e,{line:n,target:a,color:r,scale:o,property:c,clip:l}),e.restore(),e.save(),zR(e,a,i.bottom)):"y"===c&&(OR(e,a,i.left),UR(e,{line:n,target:a,color:s,scale:o,property:c,clip:l}),e.restore(),e.save(),OR(e,a,i.right),d=r));UR(e,{line:n,target:a,color:d,scale:o,property:c,clip:l}),e.restore()}(e,{line:i,target:a,above:m,below:h,area:n,scale:o,axis:l,clip:g}),LB(e))}function zR(e,t,n){const{segments:a,points:r}=t;let s=!0,i=!1;e.beginPath();for(const o of a){const{start:a,end:l}=o,c=r[a],d=r[SR(a,l,r)];s?(e.moveTo(c.x,c.y),s=!1):(e.lineTo(c.x,n),e.lineTo(c.x,c.y)),i=!!t.pathSegment(e,o,{move:i}),i?e.closePath():e.lineTo(d.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function OR(e,t,n){const{segments:a,points:r}=t;let s=!0,i=!1;e.beginPath();for(const o of a){const{start:a,end:l}=o,c=r[a],d=r[SR(a,l,r)];s?(e.moveTo(c.x,c.y),s=!1):(e.lineTo(n,c.y),e.lineTo(c.x,c.y)),i=!!t.pathSegment(e,o,{move:i}),i?e.closePath():e.lineTo(n,d.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function UR(e,t){const{line:n,target:a,property:r,color:s,scale:i,clip:o}=t,l=function(e,t,n){const a=e.segments,r=e.points,s=t.points,i=[];for(const o of a){let{start:e,end:a}=o;a=SR(e,a,r);const l=FR(n,r[e],r[a],o.loop);if(!t.segments){i.push({source:o,target:l,start:r[e],end:r[a]});continue}const c=HI(t,l);for(const t of c){const e=FR(n,s[t.start],s[t.end],t.loop),a=VI(o,r,e);for(const r of a)i.push({source:r,target:t,start:{[n]:ER(l,e,"start",Math.max)},end:{[n]:ER(l,e,"end",Math.min)}})}}return i}(n,a,r);for(const{source:c,target:d,start:u,end:m}of l){const{style:{backgroundColor:t=s}={}}=c,l=!0!==a;e.save(),e.fillStyle=t,VR(e,i,o,l&&FR(r,u,m)),e.beginPath();const h=!!n.pathSegment(e,c);let p;if(l){h?e.closePath():HR(e,a,m,r);const t=!!a.pathSegment(e,d,{move:h,reverse:!0});p=h&&t,p||HR(e,a,u,r)}e.closePath(),e.fill(p?"evenodd":"nonzero"),e.restore()}}function VR(e,t,n,a){const r=t.chart.chartArea,{property:s,start:i,end:o}=a||{};if("x"===s||"y"===s){let t,a,l,c;"x"===s?(t=i,a=r.top,l=o,c=r.bottom):(t=r.left,a=i,l=r.right,c=o),e.beginPath(),n&&(t=Math.max(t,n.left),l=Math.min(l,n.right),a=Math.max(a,n.top),c=Math.min(c,n.bottom)),e.rect(t,a,l-t,c-a),e.clip()}}function HR(e,t,n,a){const r=t.interpolate(n,a);r&&e.lineTo(r.x,r.y)}var qR={id:"filler",afterDatasetsUpdate(e,t,n){const a=(e.data.datasets||[]).length,r=[];let s,i,o,l;for(i=0;i<a;++i)s=e.getDatasetMeta(i),o=s.dataset,l=null,o&&o.options&&o instanceof fR&&(l={visible:e.isDatasetVisible(i),index:i,fill:_R(o,i,a),chart:e,axis:s.controller.options.indexAxis,scale:s.vScale,line:o}),s.$filler=l,r.push(l);for(i=0;i<a;++i)l=r[i],l&&!1!==l.fill&&(l.fill=MR(r,i,n.propagate))},beforeDraw(e,t,n){const a="beforeDraw"===n.drawTime,r=e.getSortedVisibleDatasetMetas(),s=e.chartArea;for(let i=r.length-1;i>=0;--i){const t=r[i].$filler;t&&(t.line.updateControlPoints(s,t.axis),a&&t.fill&&RR(e.ctx,t,s))}},beforeDatasetsDraw(e,t,n){if("beforeDatasetsDraw"!==n.drawTime)return;const a=e.getSortedVisibleDatasetMetas();for(let r=a.length-1;r>=0;--r){const t=a[r].$filler;TR(t)&&RR(e.ctx,t,e.chartArea)}},beforeDatasetDraw(e,t,n){const a=t.meta.$filler;TR(a)&&"beforeDatasetDraw"===n.drawTime&&RR(e.ctx,a,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const WR=(e,t)=>{let{boxHeight:n=t,boxWidth:a=t}=e;return e.usePointStyle&&(n=Math.min(n,t),a=e.pointStyleWidth||Math.min(a,t)),{boxWidth:a,boxHeight:n,itemHeight:Math.max(t,n)}};class YR extends gL{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const e=this.options.labels||{};let t=h_(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){const{options:e,ctx:t}=this;if(!e.display)return void(this.width=this.height=0);const n=e.labels,a=QB(n.font),r=a.size,s=this._computeTitleHeight(),{boxWidth:i,itemHeight:o}=WR(n,r);let l,c;t.font=a.string,this.isHorizontal()?(l=this.maxWidth,c=this._fitRows(s,r,i,o)+10):(c=this.maxHeight,l=this._fitCols(s,a,i,o)+10),this.width=Math.min(l,e.maxWidth||this.maxWidth),this.height=Math.min(c,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,a){const{ctx:r,maxWidth:s,options:{labels:{padding:i}}}=this,o=this.legendHitBoxes=[],l=this.lineWidths=[0],c=a+i;let d=e;r.textAlign="left",r.textBaseline="middle";let u=-1,m=-c;
vendor: 44,497 bytes, line 2
2return this.legendItems.forEach((e,h)=>{const p=n+t/2+r.measureText(e.text).width;(0===h||l[l.length-1]+p+2*i>s)&&(d+=c,l[l.length-(h>0?0:1)]=0,m+=c,u++),o[h]={left:0,top:m,row:u,width:p,height:a},l[l.length-1]+=p+i}),d}_fitCols(e,t,n,a){const{ctx:r,maxHeight:s,options:{labels:{padding:i}}}=this,o=this.legendHitBoxes=[],l=this.columnSizes=[],c=s-e;let d=i,u=0,m=0,h=0,p=0;return this.legendItems.forEach((e,s)=>{const{itemWidth:g,itemHeight:x}=function(e,t,n,a,r){const s=function(e,t,n,a){let r=e.text;r&&"string"!==typeof r&&(r=r.reduce((e,t)=>e.length>t.length?e:t));return t+n.size/2+a.measureText(r).width}(a,e,t,n),i=function(e,t,n){let a=e;"string"!==typeof t.text&&(a=GR(t,n));return a}(r,a,t.lineHeight);return{itemWidth:s,itemHeight:i}}(n,t,r,e,a);s>0&&m+x+2*i>c&&(d+=u+i,l.push({width:u,height:m}),h+=u+i,p++,u=m=0),o[s]={left:h,top:m,col:p,width:g,height:x},u=Math.max(u,g),m+=x+i}),d+=u,l.push({width:u,height:m}),d}adjustHitBoxes(){if(!this.options.display)return;const e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:a},rtl:r}}=this,s=LI(r,this.left,this.width);if(this.isHorizontal()){let r=0,i=oB(n,this.left+a,this.right-this.lineWidths[r]);for(const o of t)r!==o.row&&(r=o.row,i=oB(n,this.left+a,this.right-this.lineWidths[r])),o.top+=this.top+e+a,o.left=s.leftForLtr(s.x(i),o.width),i+=o.width+a}else{let r=0,i=oB(n,this.top+e+a,this.bottom-this.columnSizes[r].height);for(const o of t)o.col!==r&&(r=o.col,i=oB(n,this.top+e+a,this.bottom-this.columnSizes[r].height)),o.top=i,o.left+=this.left+a,o.left=s.leftForLtr(s.x(o.left),o.width),i+=o.height+a}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const e=this.ctx;PB(e,this),this._draw(),LB(e)}}_draw(){const{options:e,columnSizes:t,lineWidths:n,ctx:a}=this,{align:r,labels:s}=e,i=SB.color,o=LI(e.rtl,this.left,this.width),l=QB(s.font),{padding:c}=s,d=l.size,u=d/2;let m;this.drawTitle(),a.textAlign=o.textAlign("left"),a.textBaseline="middle",a.lineWidth=.5,a.font=l.string;const{boxWidth:h,boxHeight:p,itemHeight:g}=WR(s,d),x=this.isHorizontal(),f=this._computeTitleHeight();m=x?{x:oB(r,this.left+c,this.right-n[0]),y:this.top+c+f,line:0}:{x:this.left+c,y:oB(r,this.top+f+c,this.bottom-t[0].height),line:0},RI(this.ctx,e.textDirection);const b=g+c;this.legendItems.forEach((y,v)=>{a.strokeStyle=y.fontColor,a.fillStyle=y.fontColor;const w=a.measureText(y.text).width,k=o.textAlign(y.textAlign||(y.textAlign=s.textAlign)),j=h+u+w;let D=m.x,C=m.y;o.setWidth(this.width),x?v>0&&D+j+c>this.right&&(C=m.y+=b,m.line++,D=m.x=oB(r,this.left+c,this.right-n[m.line])):v>0&&C+b>this.bottom&&(D=m.x=D+t[m.line].width+c,m.line++,C=m.y=oB(r,this.top+f+c,this.bottom-t[m.line].height));if(function(e,t,n){if(isNaN(h)||h<=0||isNaN(p)||p<0)return;a.save();const r=u_(n.lineWidth,1);if(a.fillStyle=u_(n.fillStyle,i),a.lineCap=u_(n.lineCap,"butt"),a.lineDashOffset=u_(n.lineDashOffset,0),a.lineJoin=u_(n.lineJoin,"miter"),a.lineWidth=r,a.strokeStyle=u_(n.strokeStyle,i),a.setLineDash(u_(n.lineDash,[])),s.usePointStyle){const i={radius:p*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:r},l=o.xPlus(e,h/2);BB(a,i,l,t+u,s.pointStyleWidth&&h)}else{const s=t+Math.max((d-p)/2,0),i=o.leftForLtr(e,h),l=JB(n.borderRadius);a.beginPath(),Object.values(l).some(e=>0!==e)?HB(a,{x:i,y:s,w:h,h:p,radius:l}):a.rect(i,s,h,p),a.fill(),0!==r&&a.stroke()}a.restore()}(o.x(D),C,y),D=((e,t,n,a)=>e===(a?"left":"right")?n:"center"===e?(t+n)/2:t)(k,D+h+u,x?D+j:this.right,e.rtl),function(e,t,n){VB(a,n.text,e,t+g/2,l,{strikethrough:n.hidden,textAlign:o.textAlign(n.textAlign)})}(o.x(D),C,y),x)m.x+=j+c;else if("string"!==typeof y.text){const e=l.lineHeight;m.y+=GR(y,e)+c}else m.y+=b}),zI(this.ctx,e.textDirection)}drawTitle(){const e=this.options,t=e.title,n=QB(t.font),a=$B(t.padding);if(!t.display)return;const r=LI(e.rtl,this.left,this.width),s=this.ctx,i=t.position,o=n.size/2,l=a.top+o;let c,d=this.left,u=this.width;if(this.isHorizontal())u=Math.max(...this.lineWidths),c=this.top+l,d=oB(e.align,d,this.right-u);else{const t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);c=l+oB(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}const m=oB(i,d,d+u);s.textAlign=r.textAlign(iB(i)),s.textBaseline="middle",s.strokeStyle=t.color,s.fillStyle=t.color,s.font=n.string,VB(s,t.text,m,c,n)}_computeTitleHeight(){const e=this.options.title,t=QB(e.font),n=$B(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,a,r;if($_(e,this.left,this.right)&&$_(t,this.top,this.bottom))for(r=this.legendHitBoxes,n=0;n<r.length;++n)if(a=r[n],$_(e,a.left,a.left+a.width)&&$_(t,a.top,a.top+a.height))return this.legendItems[n];return null}handleEvent(e){const t=this.options;if(!function(e,t){if(("mousemove"===e||"mouseout"===e)&&(t.onHover||t.onLeave))return!0;if(t.onClick&&("click"===e||"mouseup"===e))return!0;return!1}(e.type,t))return;const n=this._getLegendItemAt(e.x,e.y);if("mousemove"===e.type||"mouseout"===e.type){const s=this._hoveredItem,i=(r=n,null!==(a=s)&&null!==r&&a.datasetIndex===r.datasetIndex&&a.index===r.index);s&&!i&&h_(t.onLeave,[e,s,this],this),this._hoveredItem=n,n&&!i&&h_(t.onHover,[e,n,this],this)}else n&&h_(t.onClick,[e,n,this],this);var a,r}}function GR(e,t){return t*(e.text?e.text.length:0)}var KR={id:"legend",_element:YR,start(e,t,n){const a=e.legend=new YR({ctx:e.ctx,options:n,chart:e});$P.configure(e,a,n),$P.addBox(e,a)},stop(e){$P.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const a=e.legend;$P.configure(e,a,n),a.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const a=t.datasetIndex,r=n.chart;r.isDatasetVisible(a)?(r.hide(a),t.hidden=!0):(r.show(a),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:a,textAlign:r,color:s,useBorderRadius:i,borderRadius:o}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{const l=e.controller.getStyle(n?0:void 0),c=$B(l.borderWidth);return{text:t[e.index].label,fillStyle:l.backgroundColor,fontColor:s,hidden:!e.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(c.width+c.height)/4,strokeStyle:l.borderColor,pointStyle:a||l.pointStyle,rotation:l.rotation,textAlign:r||l.textAlign,borderRadius:i&&(o||l.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};class XR extends gL{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){const n=this.options;if(this.left=0,this.top=0,!n.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=e,this.height=this.bottom=t;const a=o_(n.text)?n.text.length:1;this._padding=$B(n.padding);const r=a*QB(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=r:this.width=r}isHorizontal(){const e=this.options.position;return"top"===e||"bottom"===e}_drawArgs(e){const{top:t,left:n,bottom:a,right:r,options:s}=this,i=s.align;let o,l,c,d=0;return this.isHorizontal()?(l=oB(i,n,r),c=t+e,o=r-n):("left"===s.position?(l=n+e,c=oB(i,a,t),d=-.5*S_):(l=r-e,c=oB(i,t,a),d=.5*S_),o=a-t),{titleX:l,titleY:c,maxWidth:o,rotation:d}}draw(){const e=this.ctx,t=this.options;if(!t.display)return;const n=QB(t.font),a=n.lineHeight/2+this._padding.top,{titleX:r,titleY:s,maxWidth:i,rotation:o}=this._drawArgs(a);VB(e,t.text,0,0,n,{color:t.color,maxWidth:i,rotation:o,textAlign:iB(t.align),textBaseline:"middle",translation:[r,s]})}}var JR={id:"title",_element:XR,start(e,t,n){!function(e,t){const n=new XR({ctx:e.ctx,options:t,chart:e});$P.configure(e,n,t),$P.addBox(e,n),e.titleBlock=n}(e,n)},stop(e){const t=e.titleBlock;$P.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const a=e.titleBlock;$P.configure(e,a,n),a.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};new WeakMap;const $R={average(e){if(!e.length)return!1;let t,n,a=new Set,r=0,s=0;for(t=0,n=e.length;t<n;++t){const n=e[t].element;if(n&&n.hasValue()){const e=n.tooltipPosition();a.add(e.x),r+=e.y,++s}}if(0===s||0===a.size)return!1;return{x:[...a].reduce((e,t)=>e+t)/a.size,y:r/s}},nearest(e,t){if(!e.length)return!1;let n,a,r,s=t.x,i=t.y,o=Number.POSITIVE_INFINITY;for(n=0,a=e.length;n<a;++n){const a=e[n].element;if(a&&a.hasValue()){const e=Y_(t,a.getCenterPoint());e<o&&(o=e,r=a)}}if(r){const e=r.tooltipPosition();s=e.x,i=e.y}return{x:s,y:i}}};function QR(e,t){return t&&(o_(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function ZR(e){return("string"===typeof e||e instanceof String)&&e.indexOf("\n")>-1?e.split("\n"):e}function ez(e,t){const{element:n,datasetIndex:a,index:r}=t,s=e.getDatasetMeta(a).controller,{label:i,value:o}=s.getLabelAndValue(r);return{chart:e,label:i,parsed:s.getParsed(r),raw:e.data.datasets[a].data[r],formattedValue:o,dataset:s.getDataset(),dataIndex:r,datasetIndex:a,element:n}}function tz(e,t){const n=e.chart.ctx,{body:a,footer:r,title:s}=e,{boxWidth:i,boxHeight:o}=t,l=QB(t.bodyFont),c=QB(t.titleFont),d=QB(t.footerFont),u=s.length,m=r.length,h=a.length,p=$B(t.padding);let g=p.height,x=0,f=a.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(f+=e.beforeBody.length+e.afterBody.length,u&&(g+=u*c.lineHeight+(u-1)*t.titleSpacing+t.titleMarginBottom),f){g+=h*(t.displayColors?Math.max(o,l.lineHeight):l.lineHeight)+(f-h)*l.lineHeight+(f-1)*t.bodySpacing}m&&(g+=t.footerMarginTop+m*d.lineHeight+(m-1)*t.footerSpacing);let b=0;const y=function(e){x=Math.max(x,n.measureText(e).width+b)};return n.save(),n.font=c.string,p_(e.title,y),n.font=l.string,p_(e.beforeBody.concat(e.afterBody),y),b=t.displayColors?i+2+t.boxPadding:0,p_(a,e=>{p_(e.before,y),p_(e.lines,y),p_(e.after,y)}),b=0,n.font=d.string,p_(e.footer,y),n.restore(),x+=p.width,{width:x,height:g}}function nz(e,t,n,a){const{x:r,width:s}=n,{width:i,chartArea:{left:o,right:l}}=e;let c="center";return"center"===a?c=r<=(o+l)/2?"left":"right":r<=s/2?c="left":r>=i-s/2&&(c="right"),function(e,t,n,a){const{x:r,width:s}=a,i=n.caretSize+n.caretPadding;return"left"===e&&r+s+i>t.width||"right"===e&&r-s-i<0||void 0}(c,e,t,n)&&(c="center"),c}function az(e,t,n){const a=n.yAlign||t.yAlign||function(e,t){const{y:n,height:a}=t;return n<a/2?"top":n>e.height-a/2?"bottom":"center"}(e,n);return{xAlign:n.xAlign||t.xAlign||nz(e,t,n,a),yAlign:a}}function rz(e,t,n,a){const{caretSize:r,caretPadding:s,cornerRadius:i}=e,{xAlign:o,yAlign:l}=n,c=r+s,{topLeft:d,topRight:u,bottomLeft:m,bottomRight:h}=JB(i);let p=function(e,t){let{x:n,width:a}=e;return"right"===t?n-=a:"center"===t&&(n-=a/2),n}(t,o);const g=function(e,t,n){let{y:a,height:r}=e;return"top"===t?a+=n:a-="bottom"===t?r+n:r/2,a}(t,l,c);return"center"===l?"left"===o?p+=c:"right"===o&&(p-=c):"left"===o?p-=Math.max(d,m)+r:"right"===o&&(p+=Math.max(u,h)+r),{x:J_(p,0,a.width-t.width),y:J_(g,0,a.height-t.height)}}function sz(e,t,n){const a=$B(n.padding);return"center"===t?e.x+e.width/2:"right"===t?e.x+e.width-a.right:e.x+a.left}function iz(e){return QR([],ZR(e))}function oz(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const lz={beforeTitle:r_,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,a=n?n.length:0;if(this&&this.options&&"dataset"===this.options.mode)return t.dataset.label||"";if(t.label)return t.label;if(a>0&&t.dataIndex<a)return n[t.dataIndex]}return""},afterTitle:r_,beforeBody:r_,beforeLabel:r_,label(e){if(this&&this.options&&"dataset"===this.options.mode)return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return i_(n)||(t+=n),t},labelColor(e){const t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:t.borderColor,backgroundColor:t.backgroundColor,borderWidth:t.borderWidth,borderDash:t.borderDash,borderDashOffset:t.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const t=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:t.pointStyle,rotation:t.rotation}},afterLabel:r_,afterBody:r_,beforeFooter:r_,footer:r_,afterFooter:r_};function cz(e,t,n,a){const r=e[t].call(n,a);return"undefined"===typeof r?lz[t].call(n,a):r}class dz extends gL{constructor(e){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=e.chart,this.options=e.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const e=this._cachedAnimations;if(e)return e;const t=this.chart,n=this.options.setContext(this.getContext()),a=n.enabled&&t.options.animation&&n.animations,r=new eP(this.chart,a);return a._cacheable&&(this._cachedAnimations=Object.freeze(r)),r}getContext(){return this.$context||(this.$context=(e=this.chart.getContext(),t=this,n=this._tooltipItems,eI(e,{tooltip:t,tooltipItems:n,type:"tooltip"})));var e,t,n}getTitle(e,t){const{callbacks:n}=t,a=cz(n,"beforeTitle",this,e),r=cz(n,"title",this,e),s=cz(n,"afterTitle",this,e);let i=[];return i=QR(i,ZR(a)),i=QR(i,ZR(r)),i=QR(i,ZR(s)),i}getBeforeBody(e,t){return iz(cz(t.callbacks,"beforeBody",this,e))}getBody(e,t){const{callbacks:n}=t,a=[];return p_(e,e=>{const t={before:[],lines:[],after:[]},r=oz(n,e);QR(t.before,ZR(cz(r,"beforeLabel",this,e))),QR(t.lines,cz(r,"label",this,e)),QR(t.after,ZR(cz(r,"afterLabel",this,e))),a.push(t)}),a}getAfterBody(e,t){return iz(cz(t.callbacks,"afterBody",this,e))}getFooter(e,t){const{callbacks:n}=t,a=cz(n,"beforeFooter",this,e),r=cz(n,"footer",this,e),s=cz(n,"afterFooter",this,e);let i=[];return i=QR(i,ZR(a)),i=QR(i,ZR(r)),i=QR(i,ZR(s)),i}_createItems(e){const t=this._active,n=this.chart.data,a=[],r=[],s=[];let i,o,l=[];for(i=0,o=t.length;i<o;++i)l.push(ez(this.chart,t[i]));return e.filter&&(l=l.filter((t,a,r)=>e.filter(t,a,r,n))),e.itemSort&&(l=l.sort((t,a)=>e.itemSort(t,a,n))),p_(l,t=>{const n=oz(e.callbacks,t);a.push(cz(n,"labelColor",this,t)),r.push(cz(n,"labelPointStyle",this,t)),s.push(cz(n,"labelTextColor",this,t))}),this.labelColors=a,this.labelPointStyles=r,this.labelTextColors=s,this.dataPoints=l,l}update(e,t){const n=this.options.setContext(this.getContext()),a=this._active;let r,s=[];if(a.length){const e=$R[n.position].call(this,a,this._eventPosition);s=this._createItems(n),this.title=this.getTitle(s,n),this.beforeBody=this.getBeforeBody(s,n),this.body=this.getBody(s,n),this.afterBody=this.getAfterBody(s,n),this.footer=this.getFooter(s,n);const t=this._size=tz(this,n),i=Object.assign({},e,t),o=az(this.chart,n,i),l=rz(n,i,o,this.chart);this.xAlign=o.xAlign,this.yAlign=o.yAlign,r={opacity:1,x:l.x,y:l.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}else 0!==this.opacity&&(r={opacity:0});this._tooltipItems=s,this.$context=void 0,r&&this._resolveAnimations().update(this,r),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,a){const r=this.getCaretPosition(e,n,a);t.lineTo(r.x1,r.y1),t.lineTo(r.x2,r.y2),t.lineTo(r.x3,r.y3)}getCaretPosition(e,t,n){const{xAlign:a,yAlign:r}=this,{caretSize:s,cornerRadius:i}=n,{topLeft:o,topRight:l,bottomLeft:c,bottomRight:d}=JB(i),{x:u,y:m}=e,{width:h,height:p}=t;let g,x,f,b,y,v;return"center"===r?(y=m+p/2,"left"===a?(g=u,x=g-s,b=y+s,v=y-s):(g=u+h,x=g+s,b=y-s,v=y+s),f=g):(x="left"===a?u+Math.max(o,c)+s:"right"===a?u+h-Math.max(l,d)-s:this.caretX,"top"===r?(b=m,y=b-s,g=x-s,f=x+s):(b=m+p,y=b+s,g=x+s,f=x-s),v=b),{x1:g,x2:x,x3:f,y1:b,y2:y,y3:v}}drawTitle(e,t,n){const a=this.title,r=a.length;let s,i,o;if(r){const l=LI(n.rtl,this.x,this.width);for(e.x=sz(this,n.titleAlign,n),t.textAlign=l.textAlign(n.titleAlign),t.textBaseline="middle",s=QB(n.titleFont),i=n.titleSpacing,t.fillStyle=n.titleColor,t.font=s.string,o=0;o<r;++o)t.fillText(a[o],l.x(e.x),e.y+s.lineHeight/2),e.y+=s.lineHeight+i,o+1===r&&(e.y+=n.titleMarginBottom-i)}}_drawColorBox(e,t,n,a,r){const s=this.labelColors[n],i=this.labelPointStyles[n],{boxHeight:o,boxWidth:l}=r,c=QB(r.bodyFont),d=sz(this,"left",r),u=a.x(d),m=o<c.lineHeight?(c.lineHeight-o)/2:0,h=t.y+m;if(r.usePointStyle){const t={radius:Math.min(l,o)/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:1},n=a.leftForLtr(u,l)+l/2,c=h+o/2;e.strokeStyle=r.multiKeyBackground,e.fillStyle=r.multiKeyBackground,_B(e,t,n,c),e.strokeStyle=s.borderColor,e.fillStyle=s.backgroundColor,_B(e,t,n,c)}else{e.lineWidth=l_(s.borderWidth)?Math.max(...Object.values(s.borderWidth)):s.borderWidth||1,e.strokeStyle=s.borderColor,e.setLineDash(s.borderDash||[]),e.lineDashOffset=s.borderDashOffset||0;const t=a.leftForLtr(u,l),n=a.leftForLtr(a.xPlus(u,1),l-2),i=JB(s.borderRadius);Object.values(i).some(e=>0!==e)?(e.beginPath(),e.fillStyle=r.multiKeyBackground,HB(e,{x:t,y:h,w:l,h:o,radius:i}),e.fill(),e.stroke(),e.fillStyle=s.backgroundColor,e.beginPath(),HB(e,{x:n,y:h+1,w:l-2,h:o-2,radius:i}),e.fill()):(e.fillStyle=r.multiKeyBackground,e.fillRect(t,h,l,o),e.strokeRect(t,h,l,o),e.fillStyle=s.backgroundColor,e.fillRect(n,h+1,l-2,o-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){const{body:a}=this,{bodySpacing:r,bodyAlign:s,displayColors:i,boxHeight:o,boxWidth:l,boxPadding:c}=n,d=QB(n.bodyFont);let u=d.lineHeight,m=0;const h=LI(n.rtl,this.x,this.width),p=function(n){t.fillText(n,h.x(e.x+m),e.y+u/2),e.y+=u+r},g=h.textAlign(s);let x,f,b,y,v,w,k;for(t.textAlign=s,t.textBaseline="middle",t.font=d.string,e.x=sz(this,g,n),t.fillStyle=n.bodyColor,p_(this.beforeBody,p),m=i&&"right"!==g?"center"===s?l/2+c:l+2+c:0,y=0,w=a.length;y<w;++y){for(x=a[y],f=this.labelTextColors[y],t.fillStyle=f,p_(x.before,p),b=x.lines,i&&b.length&&(this._drawColorBox(t,e,y,h,n),u=Math.max(d.lineHeight,o)),v=0,k=b.length;v<k;++v)p(b[v]),u=d.lineHeight;p_(x.after,p)}m=0,u=d.lineHeight,p_(this.afterBody,p),e.y-=r}drawFooter(e,t,n){const a=this.footer,r=a.length;let s,i;if(r){const o=LI(n.rtl,this.x,this.width);for(e.x=sz(this,n.footerAlign,n),e.y+=n.footerMarginTop,t.textAlign=o.textAlign(n.footerAlign),t.textBaseline="middle",s=QB(n.footerFont),t.fillStyle=n.footerColor,t.font=s.string,i=0;i<r;++i)t.fillText(a[i],o.x(e.x),e.y+s.lineHeight/2),e.y+=s.lineHeight+n.footerSpacing}}drawBackground(e,t,n,a){const{xAlign:r,yAlign:s}=this,{x:i,y:o}=e,{width:l,height:c}=n,{topLeft:d,topRight:u,bottomLeft:m,bottomRight:h}=JB(a.cornerRadius);t.fillStyle=a.backgroundColor,t.strokeStyle=a.borderColor,t.lineWidth=a.borderWidth,t.beginPath(),t.moveTo(i+d,o),"top"===s&&this.drawCaret(e,t,n,a),t.lineTo(i+l-u,o),t.quadraticCurveTo(i+l,o,i+l,o+u),"center"===s&&"right"===r&&this.drawCaret(e,t,n,a),t.lineTo(i+l,o+c-h),t.quadraticCurveTo(i+l,o+c,i+l-h,o+c),"bottom"===s&&this.drawCaret(e,t,n,a),t.lineTo(i+m,o+c),t.quadraticCurveTo(i,o+c,i,o+c-m),"center"===s&&"left"===r&&this.drawCaret(e,t,n,a),t.lineTo(i,o+d),t.quadraticCurveTo(i,o,i+d,o),t.closePath(),t.fill(),a.borderWidth>0&&t.stroke()}_updateAnimationTarget(e){const t=this.chart,n=this.$animations,a=n&&n.x,r=n&&n.y;if(a||r){const n=$R[e.position].call(this,this._active,this._eventPosition);if(!n)return;const s=this._size=tz(this,e),i=Object.assign({},n,this._size),o=az(t,e,i),l=rz(e,i,o,t);a._to===l.x&&r._to===l.y||(this.xAlign=o.xAlign,this.yAlign=o.yAlign,this.width=s.width,this.height=s.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(e){const t=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(t);const a={width:this.width,height:this.height},r={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const s=$B(t.padding),i=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&i&&(e.save(),e.globalAlpha=n,this.drawBackground(r,e,a,t),RI(e,t.textDirection),r.y+=s.top,this.drawTitle(r,e,t),this.drawBody(r,e,t),this.drawFooter(r,e,t),zI(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){const n=this._active,a=e.map(e=>{let{datasetIndex:t,index:n}=e;const a=this.chart.getDatasetMeta(t);if(!a)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:a.data[n],index:n}}),r=!g_(n,a),s=this._positionChanged(a,t);(r||s)&&(this._active=a,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const a=this.options,r=this._active||[],s=this._getActiveElements(e,r,t,n),i=this._positionChanged(s,e),o=t||!g_(s,r)||i;return o&&(this._active=s,(a.enabled||a.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),o}_getActiveElements(e,t,n,a){const r=this.options;if("mouseout"===e.type)return[];if(!a)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&void 0!==this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index));const s=this.chart.getElementsAtEventForMode(e,r.mode,r,n);return r.reverse&&s.reverse(),s}_positionChanged(e,t){const{caretX:n,caretY:a,options:r}=this,s=$R[r.position].call(this,e,t);return!1!==s&&(n!==s.x||a!==s.y)}}l(dz,"positioners",$R);var uz={id:"tooltip",_element:dz,positioners:$R,afterInit(e,t,n){n&&(e.tooltip=new dz({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(!1===e.notifyPlugins("beforeTooltipDraw",d(d({},n),{},{cancelable:!0})))return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:lz},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>"filter"!==e&&"itemSort"!==e&&"external"!==e,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};function mz(e,t,n,a){const r=e.indexOf(t);if(-1===r)return((e,t,n,a)=>("string"===typeof t?(n=e.push(t)-1,a.unshift({index:n,label:t})):isNaN(t)&&(n=null),n))(e,t,n,a);return r!==e.lastIndexOf(t)?n:r}function hz(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class pz extends CL{constructor(e){super(e),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(e){const t=this._addedLabels;if(t.length){const e=this.getLabels();for(const{index:n,label:a}of t)e[n]===a&&e.splice(n,1);this._addedLabels=[]}super.init(e)}parse(e,t){if(i_(e))return null;const n=this.getLabels();return((e,t)=>null===e?null:J_(Math.round(e),0,t))(t=isFinite(t)&&n[t]===e?t:mz(n,e,u_(t,e),this._addedLabels),n.length-1)}determineDataLimits(){const{minDefined:e,maxDefined:t}=this.getUserBounds();let{min:n,max:a}=this.getMinMax(!0);"ticks"===this.options.bounds&&(e||(n=0),t||(a=this.getLabels().length-1)),this.min=n,this.max=a}buildTicks(){const e=this.min,t=this.max,n=this.options.offset,a=[];let r=this.getLabels();r=0===e&&t===r.length-1?r:r.slice(e,t+1),this._valueRange=Math.max(r.length-(n?0:1),1),this._startValue=this.min-(n?.5:0);for(let s=e;s<=t;s++)a.push({value:s});return a}getLabelForValue(e){return hz.call(this,e)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(e){return"number"!==typeof e&&(e=this.parse(e)),null===e?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getPixelForTick(e){const t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}}function gz(e,t){const n=[],{bounds:a,step:r,min:s,max:i,precision:o,count:l,maxTicks:c,maxDigits:d,includeBounds:u}=e,m=r||1,h=c-1,{min:p,max:g}=t,x=!i_(s),f=!i_(i),b=!i_(l),y=(g-p)/(d+1);let v,w,k,j,D=z_((g-p)/h/m)*m;if(D<1e-14&&!x&&!f)return[{value:p},{value:g}];j=Math.ceil(g/D)-Math.floor(p/D),j>h&&(D=z_(j*D/h/m)*m),i_(o)||(v=Math.pow(10,o),D=Math.ceil(D*v)/v),"ticks"===a?(w=Math.floor(p/D)*D,k=Math.ceil(g/D)*D):(w=p,k=g),x&&f&&r&&function(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}((i-s)/r,D/1e3)?(j=Math.round(Math.min((i-s)/D,c)),D=(i-s)/j,w=s,k=i):b?(w=x?s:w,k=f?i:k,j=l-1,D=(k-w)/j):(j=(k-w)/D,j=R_(j,Math.round(j),D/1e3)?Math.round(j):Math.ceil(j));const C=Math.max(q_(D),q_(w));v=Math.pow(10,i_(o)?C:o),w=Math.round(w*v)/v,k=Math.round(k*v)/v;let N=0;for(x&&(u&&w!==s?(n.push({value:s}),w<s&&N++,R_(Math.round((w+N*D)*v)/v,s,xz(s,y,e))&&N++):w<s&&N++);N<j;++N){const e=Math.round((w+N*D)*v)/v;if(f&&e>i)break;n.push({value:e})}return f&&u&&k!==i?n.length&&R_(n[n.length-1].value,i,xz(i,y,e))?n[n.length-1].value=i:n.push({value:i}):f&&k!==i||n.push({value:k}),n}function xz(e,t,n){let{horizontal:a,minRotation:r}=n;const s=V_(r),i=(a?Math.sin(s):Math.cos(s))||.001,o=.75*t*(""+e).length;return Math.min(t/i,o)}l(pz,"id","category"),l(pz,"defaults",{ticks:{callback:hz}});class fz extends CL{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return i_(e)||("number"===typeof e||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){const{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:a,max:r}=this;const s=e=>a=t?a:e,i=e=>r=n?r:e;if(e){const e=L_(a),t=L_(r);e<0&&t<0?i(0):e>0&&t>0&&s(0)}if(a===r){let t=0===r?1:Math.abs(.05*r);i(r+t),e||s(a-t)}this.min=a,this.max=r}getTickLimit(){const e=this.options.ticks;let t,{maxTicksLimit:n,stepSize:a}=e;return a?(t=Math.ceil(this.max/a)-Math.floor(this.min/a)+1,t>1e3&&(console.warn("scales.".concat(this.id,".ticks.stepSize: ").concat(a," would result generating up to ").concat(t," ticks. Limiting to 1000.")),t=1e3)):(t=this.computeTickLimit(),n=n||11),n&&(t=Math.min(n,t)),t}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const e=this.options,t=e.ticks;let n=this.getTickLimit();n=Math.max(2,n);const a=gz({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:!1!==t.includeBounds},this._range||this);return"ticks"===e.bounds&&U_(a,this,"value"),e.reverse?(a.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),a}configure(){const e=this.ticks;let t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){const a=(n-t)/Math.max(e.length-1,1)/2;t-=a,n+=a}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return vB(e,this.chart.options.locale,this.options.ticks.format)}}class bz extends fz{determineDataLimits(){const{min:e,max:t}=this.getMinMax(!0);this.min=c_(e)?e:0,this.max=c_(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){const e=this.isHorizontal(),t=e?this.width:this.height,n=V_(this.options.ticks.minRotation),a=(e?Math.sin(n):Math.cos(n))||.001,r=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,r.lineHeight/a))}getPixelForValue(e){return null===e?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}}l(bz,"id","linear"),l(bz,"defaults",{ticks:{callback:kB.formatters.numeric}});const yz=e=>Math.floor(P_(e)),vz=(e,t)=>Math.pow(10,yz(e)+t);function wz(e){return 1===e/Math.pow(10,yz(e))}function kz(e,t,n){const a=Math.pow(10,n),r=Math.floor(e/a);return Math.ceil(t/a)-r}function jz(e,t){let{min:n,max:a}=t;n=d_(e.min,n);const r=[],s=yz(n);let i=function(e,t){let n=yz(t-e);for(;kz(e,t,n)>10;)n++;for(;kz(e,t,n)<10;)n--;return Math.min(n,yz(e))}(n,a),o=i<0?Math.pow(10,Math.abs(i)):1;const l=Math.pow(10,i),c=s>i?Math.pow(10,s):0,d=Math.round((n-c)*o)/o,u=Math.floor((n-c)/l/10)*l*10;let m=Math.floor((d-u)/Math.pow(10,i)),h=d_(e.min,Math.round((c+u+m*Math.pow(10,i))*o)/o);for(;h<a;)r.push({value:h,major:wz(h),significand:m}),m>=10?m=m<15?15:20:m++,m>=20&&(i++,m=2,o=i>=0?1:o),h=Math.round((c+u+m*Math.pow(10,i))*o)/o;const p=d_(e.max,h);return r.push({value:p,major:wz(p),significand:m}),r}class Dz extends CL{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){const n=fz.prototype.parse.apply(this,[e,t]);if(0!==n)return c_(n)&&n>0?n:null;this._zero=!0}determineDataLimits(){const{min:e,max:t}=this.getMinMax(!0);this.min=c_(e)?Math.max(0,e):null,this.max=c_(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!c_(this._userMin)&&(this.min=e===vz(this.min,0)?vz(this.min,-1):vz(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:e,maxDefined:t}=this.getUserBounds();let n=this.min,a=this.max;const r=t=>n=e?n:t,s=e=>a=t?a:e;n===a&&(n<=0?(r(1),s(10)):(r(vz(n,-1)),s(vz(a,1)))),n<=0&&r(vz(a,-1)),a<=0&&s(vz(n,1)),this.min=n,this.max=a}buildTicks(){const e=this.options,t=jz({min:this._userMin,max:this._userMax},this);return"ticks"===e.bounds&&U_(t,this,"value"),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return void 0===e?"0":vB(e,this.chart.options.locale,this.options.ticks.format)}configure(){const e=this.min;super.configure(),this._startValue=P_(e),this._valueRange=P_(this.max)-P_(e)}getPixelForValue(e){return void 0!==e&&0!==e||(e=this.min),null===e||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(P_(e)-this._startValue)/this._valueRange)}getValueForPixel(e){const t=this.getDecimalForPixel(e);return Math.pow(10,this._startValue+t*this._valueRange)}}function Cz(e){const t=e.ticks;if(t.display&&e.display){const e=$B(t.backdropPadding);return u_(t.font&&t.font.size,SB.font.size)+e.height}return 0}function Nz(e,t,n){return n=o_(n)?n:[n],{w:AB(e,t.string,n),h:n.length*t.lineHeight}}function Fz(e,t,n,a,r){return e===a||e===r?{start:t-n/2,end:t+n/2}:e<a||e>r?{start:t-n,end:t}:{start:t,end:t+n}}function Sz(e){const t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),a=[],r=[],s=e._pointLabels.length,i=e.options.pointLabels,o=i.centerPointLabels?S_/s:0;for(let l=0;l<s;l++){const s=i.setContext(e.getPointLabelContext(l));r[l]=s.padding;const c=e.getPointPosition(l,e.drawingArea+r[l],o),d=QB(s.font),u=Nz(e.ctx,d,e._pointLabels[l]);a[l]=u;const m=K_(e.getIndexAngle(l)+o),h=Math.round(H_(m));Ez(n,t,m,Fz(h,c.x,u.w,0,180),Fz(h,c.y,u.h,90,270))}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=function(e,t,n){const a=[],r=e._pointLabels.length,s=e.options,{centerPointLabels:i,display:o}=s.pointLabels,l={extra:Cz(s)/2,additionalAngle:i?S_/r:0};let c;for(let d=0;d<r;d++){l.padding=n[d],l.size=t[d];const r=Az(e,d,l);a.push(r),"auto"===o&&(r.visible=Tz(r,c),r.visible&&(c=r))}return a}(e,a,r)}function Ez(e,t,n,a,r){const s=Math.abs(Math.sin(n)),i=Math.abs(Math.cos(n));let o=0,l=0;a.start<t.l?(o=(t.l-a.start)/s,e.l=Math.min(e.l,t.l-o)):a.end>t.r&&(o=(a.end-t.r)/s,e.r=Math.max(e.r,t.r+o)),r.start<t.t?(l=(t.t-r.start)/i,e.t=Math.min(e.t,t.t-l)):r.end>t.b&&(l=(r.end-t.b)/i,e.b=Math.max(e.b,t.b+l))}function Az(e,t,n){const a=e.drawingArea,{extra:r,additionalAngle:s,padding:i,size:o}=n,l=e.getPointPosition(t,a+r+i,s),c=Math.round(H_(K_(l.angle+__))),d=function(e,t,n){90===n||270===n?e-=t/2:(n>270||n<90)&&(e-=t);return e}(l.y,o.h,c),u=function(e){if(0===e||180===e)return"center";if(e<180)return"left";return"right"}(c),m=function(e,t,n){"right"===n?e-=t:"center"===n&&(e-=t/2);return e}(l.x,o.w,u);return{visible:!0,x:l.x,y:d,textAlign:u,left:m,top:d,right:m+o.w,bottom:d+o.h}}function Tz(e,t){if(!t)return!0;const{left:n,top:a,right:r,bottom:s}=e;return!(IB({x:n,y:a},t)||IB({x:n,y:s},t)||IB({x:r,y:a},t)||IB({x:r,y:s},t))}function Mz(e,t,n){const{left:a,top:r,right:s,bottom:i}=n,{backdropColor:o}=t;if(!i_(o)){const n=JB(t.borderRadius),l=$B(t.backdropPadding);e.fillStyle=o;const c=a-l.left,d=r-l.top,u=s-a+l.width,m=i-r+l.height;Object.values(n).some(e=>0!==e)?(e.beginPath(),HB(e,{x:c,y:d,w:u,h:m,radius:n}),e.fill()):e.fillRect(c,d,u,m)}}function _z(e,t,n,a){const{ctx:r}=e;if(n)r.arc(e.xCenter,e.yCenter,t,0,E_);else{let n=e.getPointPosition(0,t);r.moveTo(n.x,n.y);for(let s=1;s<a;s++)n=e.getPointPosition(s,t),r.lineTo(n.x,n.y)}}l(Dz,"id","logarithmic"),l(Dz,"defaults",{ticks:{callback:kB.formatters.logarithmic,major:{enabled:!0}}});class Bz extends fz{constructor(e){super(e),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const e=this._padding=$B(Cz(this.options)/2),t=this.width=this.maxWidth-e.width,n=this.height=this.maxHeight-e.height;this.xCenter=Math.floor(this.left+t/2+e.left),this.yCenter=Math.floor(this.top+n/2+e.top),this.drawingArea=Math.floor(Math.min(t,n)/2)}determineDataLimits(){const{min:e,max:t}=this.getMinMax(!1);this.min=c_(e)&&!isNaN(e)?e:0,this.max=c_(t)&&!isNaN(t)?t:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Cz(this.options))}generateTickLabels(e){fz.prototype.generateTickLabels.call(this,e),this._pointLabels=this.getLabels().map((e,t)=>{const n=h_(this.options.pointLabels.callback,[e,t],this);return n||0===n?n:""}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){const e=this.options;e.display&&e.pointLabels.display?Sz(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,a){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-a)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,a))}getIndexAngle(e){return K_(e*(E_/(this._pointLabels.length||1))+V_(this.options.startAngle||0))}getDistanceFromCenterForValue(e){if(i_(e))return NaN;const t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(i_(e))return NaN;const t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){const t=this._pointLabels||[];if(e>=0&&e<t.length){const n=t[e];return function(e,t,n){return eI(e,{label:n,index:t,type:"pointLabel"})}(this.getContext(),e,n)}}getPointPosition(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a=this.getIndexAngle(e)-__+n;return{x:Math.cos(a)*t+this.xCenter,y:Math.sin(a)*t+this.yCenter,angle:a}}getPointPositionForValue(e,t){return this.getPointPosition(e,this.getDistanceFromCenterForValue(t))}getBasePosition(e){return this.getPointPositionForValue(e||0,this.getBaseValue())}getPointLabelPosition(e){const{left:t,top:n,right:a,bottom:r}=this._pointLabelItems[e];return{left:t,top:n,right:a,bottom:r}}drawBackground(){const{backgroundColor:e,grid:{circular:t}}=this.options;if(e){const n=this.ctx;n.save(),n.beginPath(),_z(this,this.getDistanceFromCenterForValue(this._endValue),t,this._pointLabels.length),n.closePath(),n.fillStyle=e,n.fill(),n.restore()}}drawGrid(){const e=this.ctx,t=this.options,{angleLines:n,grid:a,border:r}=t,s=this._pointLabels.length;let i,o,l;if(t.pointLabels.display&&function(e,t){const{ctx:n,options:{pointLabels:a}}=e;for(let r=t-1;r>=0;r--){const t=e._pointLabelItems[r];if(!t.visible)continue;const s=a.setContext(e.getPointLabelContext(r));Mz(n,s,t);const i=QB(s.font),{x:o,y:l,textAlign:c}=t;VB(n,e._pointLabels[r],o,l+i.lineHeight/2,i,{color:s.color,textAlign:c,textBaseline:"middle"})}}(this,s),a.display&&this.ticks.forEach((e,t)=>{if(0!==t||0===t&&this.min<0){o=this.getDistanceFromCenterForValue(e.value);const n=this.getContext(t),i=a.setContext(n),l=r.setContext(n);!function(e,t,n,a,r){const s=e.ctx,i=t.circular,{color:o,lineWidth:l}=t;!i&&!a||!o||!l||n<0||(s.save(),s.strokeStyle=o,s.lineWidth=l,s.setLineDash(r.dash||[]),s.lineDashOffset=r.dashOffset,s.beginPath(),_z(e,n,i,a),s.closePath(),s.stroke(),s.restore())}(this,i,o,s,l)}}),n.display){for(e.save(),i=s-1;i>=0;i--){const a=n.setContext(this.getPointLabelContext(i)),{color:r,lineWidth:s}=a;s&&r&&(e.lineWidth=s,e.strokeStyle=r,e.setLineDash(a.borderDash),e.lineDashOffset=a.borderDashOffset,o=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),l=this.getPointPosition(i,o),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(l.x,l.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){const e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;const a=this.getIndexAngle(0);let r,s;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(a),e.textAlign="center",e.textBaseline="middle",this.ticks.forEach((a,i)=>{if(0===i&&this.min>=0&&!t.reverse)return;const o=n.setContext(this.getContext(i)),l=QB(o.font);if(r=this.getDistanceFromCenterForValue(this.ticks[i].value),o.showLabelBackdrop){e.font=l.string,s=e.measureText(a.label).width,e.fillStyle=o.backdropColor;const t=$B(o.backdropPadding);e.fillRect(-s/2-t.left,-r-l.size/2-t.top,s+t.width,l.size+t.height)}VB(e,a.label,0,-r,l,{color:o.color,strokeColor:o.textStrokeColor,strokeWidth:o.textStrokeWidth})}),e.restore()}drawTitle(){}}l(Bz,"id","radialLinear"),l(Bz,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:kB.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback:e=>e,padding:5,centerPointLabels:!1}}),l(Bz,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),l(Bz,"descriptors",{angleLines:{_fallback:"grid"}});const Iz={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Pz=Object.keys(Iz);function Lz(e,t){return e-t}function Rz(e,t){if(i_(t))return null;const n=e._adapter,{parser:a,round:r,isoWeekday:s}=e._parseOpts;let i=t;return"function"===typeof a&&(i=a(i)),c_(i)||(i="string"===typeof a?n.parse(i,a):n.parse(i)),null===i?null:(r&&(i="week"!==r||!O_(s)&&!0!==s?n.startOf(i,r):n.startOf(i,"isoWeek",s)),+i)}function zz(e,t,n,a){const r=Pz.length;for(let s=Pz.indexOf(e);s<r-1;++s){const e=Iz[Pz[s]],r=e.steps?e.steps:Number.MAX_SAFE_INTEGER;if(e.common&&Math.ceil((n-t)/(r*e.size))<=a)return Pz[s]}return Pz[r-1]}function Oz(e,t,n){if(n){if(n.length){const{lo:a,hi:r}=Q_(n,t);e[n[a]>=t?n[a]:n[r]]=!0}}else e[t]=!0}function Uz(e,t,n){const a=[],r={},s=t.length;let i,o;for(i=0;i<s;++i)o=t[i],r[o]=i,a.push({value:o,major:!1});return 0!==s&&n?function(e,t,n,a){const r=e._adapter,s=+r.startOf(t[0].value,a),i=t[t.length-1].value;let o,l;for(o=s;o<=i;o=+r.add(o,1,a))l=n[o],l>=0&&(t[l].major=!0);return t}(e,a,r,n):a}class Vz extends CL{constructor(e){super(e),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=e.time||(e.time={}),a=this._adapter=new TP(e.adapters.date);a.init(t),v_(n.displayFormats,a.formats()),this._parseOpts={parser:n.parser,round:n.round,isoWeekday:n.isoWeekday},super.init(e),this._normalized=t.normalized}parse(e,t){return void 0===e?null:Rz(this,e)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const e=this.options,t=this._adapter,n=e.time.unit||"day";let{min:a,max:r,minDefined:s,maxDefined:i}=this.getUserBounds();function o(e){s||isNaN(e.min)||(a=Math.min(a,e.min)),i||isNaN(e.max)||(r=Math.max(r,e.max))}s&&i||(o(this._getLabelBounds()),"ticks"===e.bounds&&"labels"===e.ticks.source||o(this.getMinMax(!1))),a=c_(a)&&!isNaN(a)?a:+t.startOf(Date.now(),n),r=c_(r)&&!isNaN(r)?r:+t.endOf(Date.now(),n)+1,this.min=Math.min(a,r-1),this.max=Math.max(a+1,r)}_getLabelBounds(){const e=this.getLabelTimestamps();let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;return e.length&&(t=e[0],n=e[e.length-1]),{min:t,max:n}}buildTicks(){const e=this.options,t=e.time,n=e.ticks,a="labels"===n.source?this.getLabelTimestamps():this._generate();"ticks"===e.bounds&&a.length&&(this.min=this._userMin||a[0],this.max=this._userMax||a[a.length-1]);const r=this.min,s=function(e,t,n){let a=0,r=e.length;for(;a<r&&e[a]<t;)a++;for(;r>a&&e[r-1]>n;)r--;return a>0||r<e.length?e.slice(a,r):e}(a,r,this.max);return this._unit=t.unit||(n.autoSkip?zz(t.minUnit,this.min,this.max,this._getLabelCapacity(r)):function(e,t,n,a,r){for(let s=Pz.length-1;s>=Pz.indexOf(n);s--){const n=Pz[s];if(Iz[n].common&&e._adapter.diff(r,a,n)>=t-1)return n}return Pz[n?Pz.indexOf(n):0]}(this,s.length,t.minUnit,this.min,this.max)),this._majorUnit=n.major.enabled&&"year"!==this._unit?function(e){for(let t=Pz.indexOf(e)+1,n=Pz.length;t<n;++t)if(Iz[Pz[t]].common)return Pz[t]}(this._unit):void 0,this.initOffsets(a),e.reverse&&s.reverse(),Uz(this,s,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(e=>+e.value))}initOffsets(){let e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=0,r=0;this.options.offset&&n.length&&(e=this.getDecimalForValue(n[0]),a=1===n.length?1-e:(this.getDecimalForValue(n[1])-e)/2,t=this.getDecimalForValue(n[n.length-1]),r=1===n.length?t:(t-this.getDecimalForValue(n[n.length-2]))/2);const s=n.length<3?.5:.25;a=J_(a,0,s),r=J_(r,0,s),this._offsets={start:a,end:r,factor:1/(a+1+r)}}_generate(){const e=this._adapter,t=this.min,n=this.max,a=this.options,r=a.time,s=r.unit||zz(r.minUnit,t,n,this._getLabelCapacity(t)),i=u_(a.ticks.stepSize,1),o="week"===s&&r.isoWeekday,l=O_(o)||!0===o,c={};let d,u,m=t;if(l&&(m=+e.startOf(m,"isoWeek",o)),m=+e.startOf(m,l?"day":s),e.diff(n,t,s)>1e5*i)throw new Error(t+" and "+n+" are too far apart with stepSize of "+i+" "+s);const h="data"===a.ticks.source&&this.getDataTimestamps();for(d=m,u=0;d<n;d=+e.add(d,i,s),u++)Oz(c,d,h);return d!==n&&"ticks"!==a.bounds&&1!==u||Oz(c,d,h),Object.keys(c).sort(Lz).map(e=>+e)}getLabelForValue(e){const t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){const n=this.options.time.displayFormats,a=this._unit,r=t||n[a];return this._adapter.format(e,r)}_tickFormatFunction(e,t,n,a){const r=this.options,s=r.ticks.callback;if(s)return h_(s,[e,t,n],this);const i=r.time.displayFormats,o=this._unit,l=this._majorUnit,c=o&&i[o],d=l&&i[l],u=n[t],m=l&&d&&u&&u.major;return this._adapter.format(e,a||(m?d:c))}generateTickLabels(e){let t,n,a;for(t=0,n=e.length;t<n;
2++t)a=e[t],a.label=this._tickFormatFunction(a.value,t,e)}getDecimalForValue(e){return null===e?NaN:(e-this.min)/(this.max-this.min)}getPixelForValue(e){const t=this._offsets,n=this.getDecimalForValue(e);return this.getPixelForDecimal((t.start+n)*t.factor)}getValueForPixel(e){const t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return this.min+n*(this.max-this.min)}_getLabelSize(e){const t=this.options.ticks,n=this.ctx.measureText(e).width,a=V_(this.isHorizontal()?t.maxRotation:t.minRotation),r=Math.cos(a),s=Math.sin(a),i=this._resolveTickFontOptions(0).size;return{w:n*r+i*s,h:n*s+i*r}}_getLabelCapacity(e){const t=this.options.time,n=t.displayFormats,a=n[t.unit]||n.millisecond,r=this._tickFormatFunction(e,0,Uz(this,[e],this._majorUnit),a),s=this._getLabelSize(r),i=Math.floor(this.isHorizontal()?this.width/s.w:this.height/s.h)-1;return i>0?i:1}getDataTimestamps(){let e,t,n=this._cache.data||[];if(n.length)return n;const a=this.getMatchingVisibleMetas();if(this._normalized&&a.length)return this._cache.data=a[0].controller.getAllParsedValues(this);for(e=0,t=a.length;e<t;++e)n=n.concat(a[e].controller.getAllParsedValues(this));return this._cache.data=this.normalize(n)}getLabelTimestamps(){const e=this._cache.labels||[];let t,n;if(e.length)return e;const a=this.getLabels();for(t=0,n=a.length;t<n;++t)e.push(Rz(this,a[t]));return this._cache.labels=this._normalized?e:this.normalize(e)}normalize(e){return aB(e.sort(Lz))}}function Hz(e,t,n){let a,r,s,i,o=0,l=e.length-1;n?(t>=e[o].pos&&t<=e[l].pos&&({lo:o,hi:l}=Z_(e,"pos",t)),({pos:a,time:s}=e[o]),({pos:r,time:i}=e[l])):(t>=e[o].time&&t<=e[l].time&&({lo:o,hi:l}=Z_(e,"time",t)),({time:a,pos:s}=e[o]),({time:r,pos:i}=e[l]));const c=r-a;return c?s+(i-s)*(t-a)/c:s}l(Vz,"id","time"),l(Vz,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});class qz extends Vz{constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Hz(t,this.min),this._tableRange=Hz(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){const{min:t,max:n}=this,a=[],r=[];let s,i,o,l,c;for(s=0,i=e.length;s<i;++s)l=e[s],l>=t&&l<=n&&a.push(l);if(a.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(s=0,i=a.length;s<i;++s)c=a[s+1],o=a[s-1],l=a[s],Math.round((c+o)/2)!==l&&r.push({time:l,pos:s/(i-1)});return r}_generate(){const e=this.min,t=this.max;let n=super.getDataTimestamps();return n.includes(e)&&n.length||n.splice(0,0,e),n.includes(t)&&1!==n.length||n.push(t),n.sort((e,t)=>e-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;const t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Hz(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){const t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Hz(this._table,n*this._tableRange+this._minPos,!0)}}l(qz,"id","timeseries"),l(qz,"defaults",Vz.defaults);const Wz=["height","width","redraw","datasetIdKey","type","data","options","plugins","fallbackContent","updateMode"],Yz="label";function Gz(e,t){"function"===typeof e?e(t):e&&(e.current=t)}function Kz(e,t){e.labels=t}function Xz(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Yz;const a=[];e.datasets=t.map(t=>{const r=e.datasets.find(e=>e[n]===t[n]);return r&&t.data&&!a.includes(r)?(a.push(r),Object.assign(r,t),r):d({},t)})}function Jz(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Yz;const n={labels:[],datasets:[]};return Kz(n,e.labels),Xz(n,e.datasets,t),n}function $z(e,t){const{height:n=150,width:r=300,redraw:s=!1,datasetIdKey:i,type:o,data:l,options:c,plugins:u=[],fallbackContent:m,updateMode:h}=e,p=T(e,Wz),g=(0,a.useRef)(null),x=(0,a.useRef)(null),f=()=>{g.current&&(x.current=new nR(g.current,{type:o,data:Jz(l,i),options:c&&d({},c),plugins:u}),Gz(t,x.current))},b=()=>{Gz(t,null),x.current&&(x.current.destroy(),x.current=null)};return(0,a.useEffect)(()=>{!s&&x.current&&c&&function(e,t){const n=e.options;n&&t&&Object.assign(n,t)}(x.current,c)},[s,c]),(0,a.useEffect)(()=>{!s&&x.current&&Kz(x.current.config.data,l.labels)},[s,l.labels]),(0,a.useEffect)(()=>{!s&&x.current&&l.datasets&&Xz(x.current.config.data,l.datasets,i)},[s,l.datasets]),(0,a.useEffect)(()=>{x.current&&(s?(b(),setTimeout(f)):x.current.update(h))},[s,c,l.labels,l.datasets,h]),(0,a.useEffect)(()=>{x.current&&(b(),setTimeout(f))},[o]),(0,a.useEffect)(()=>(f(),()=>b()),[]),a.createElement("canvas",d({ref:g,role:"img",height:n,width:r},p),m)}const Qz=(0,a.forwardRef)($z);function Zz(e,t){return nR.register(t),(0,a.forwardRef)((t,n)=>a.createElement(Qz,d(d({},t),{},{ref:n,type:e})))}const eO=Zz("line",DP),tO=Zz("bar",wP),nO=Zz("scatter",SP);
2nR.register(pz,bz,NR,yR,fR,JR,uz,KR);const aO={high:"#ef4444",medium:"#f59e0b",low:"#22c55e"},rO={high:"\ud83d\udd34",medium:"\ud83d\udfe1",low:"\ud83d\udfe2"},sO={"high-hesitation":"Frequent Pauses","sustained-hesitation":"Sustained Pauses","minor-hesitation":"Minor Pauses","novel-but-rough":"Frequent Pauses","confused-or-uncertain":"Frequent Pauses","hesitant-clear-audio":"Frequent Pauses","hesitant-unclear-audio":"Frequent Pauses","energy-dip":"Sustained Pauses"},iO=[{bg:"rgba(59, 130, 246, 0.7)",border:"rgb(59, 130, 246)",dot:"rgb(59, 130, 246)"},{bg:"rgba(239, 68, 68, 0.7)",border:"rgb(239, 68, 68)",dot:"rgb(239, 68, 68)"},{bg:"rgba(34, 197, 94, 0.7)",border:"rgb(34, 197, 94)",dot:"rgb(34, 197, 94)"},{bg:"rgba(168, 85, 247, 0.7)",border:"rgb(168, 85, 247)",dot:"rgb(168, 85, 247)"}];function oO(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return t>0?"".concat(t,":").concat(String(n).padStart(2,"0"),":").concat(String(a).padStart(2,"0")):"".concat(n,":").concat(String(a).padStart(2,"0"))}function lO(e){var t;let{isOpen:n,onClose:r,sessionId:s,speakerLabels:i,gapAnalysisData:o,ttmlFiles:l,selectedTtmlId:c,transcriptSource:m="selected",hesitationTranscriptAvailable:h=!1,onFilteredClustersChange:p}=e;const g={};if(i)for(const[a,d]of Object.entries(i))g[String(a)]=d;const{token:x}=am(),{seekTo:f}=$w(),[b,y]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)(null),[D,C]=(0,a.useState)(null),[N,F]=(0,a.useState)(!1),[E,A]=(0,a.useState)(!1),[T,M]=(0,a.useState)(null),[_,B]=(0,a.useState)(!1),[I,P]=(0,a.useState)(h),[L,R]=(0,a.useState)(h?"auto":m),z=(0,a.useMemo)(()=>"auto"===L?I?"hesitation":"selected":L,[L,I]),[O,U]=(0,a.useState)(.5),[V,H]=(0,a.useState)(1.5),[q,W]=(0,a.useState)(2),[Y,G]=(0,a.useState)(2.75),K=(0,a.useRef)(null),X=(0,a.useRef)(null),J=(0,a.useRef)(null),$=(0,a.useCallback)(e=>{var t,n,a,r,s,i,o,l,c,d,u,m;if(!e)return!1;if(e.transcriptSource!==z)return!1;const h=Number(null!==(t=null===(n=e.summary)||void 0===n||null===(a=n.thresholds)||void 0===a?void 0:a.minGapSeconds)&&void 0!==t?t:NaN),p=Number(null!==(r=null===(s=e.summary)||void 0===s||null===(i=s.thresholds)||void 0===i?void 0:i.relativeThreshold)&&void 0!==r?r:NaN),g=Number(null!==(o=null===(l=e.summary)||void 0===l||null===(c=l.thresholds)||void 0===c?void 0:c.minIntraPhraseGapSeconds)&&void 0!==o?o:NaN),x=Number(null!==(d=null===(u=e.summary)||void 0===u||null===(m=u.thresholds)||void 0===m?void 0:m.minBoundaryGapSeconds)&&void 0!==d?d:NaN);return Math.abs(h-.1)<.001&&Math.abs(p-.5)<.001&&Math.abs(g-q)<.001&&Math.abs(x-Y)<.001},[Y,q,z]),Q=(0,a.useCallback)(async()=>{y(!0),j(null);try{const e=await zp.analyzeGaps(s,{minGapSeconds:.1,relativeThreshold:.5,clusterMaxGap:30,windowSize:300,transcriptSource:z,minIntraPhraseGapSeconds:q,minBoundaryGapSeconds:Y},x||void 0);M(e)}catch(e){j(e.message||"Failed to analyze gaps")}finally{y(!1)}},[Y,q,z,s,x]);(0,a.useEffect)(()=>{n&&!T&&$(o)&&M(null!==o&&void 0!==o?o:null)},[$,n,o,T]),(0,a.useEffect)(()=>{if(n)return J.current&&clearTimeout(J.current),$(o)?(M(null!==o&&void 0!==o?o:null),void j(null)):(J.current=setTimeout(()=>{Q()},200),()=>{J.current&&clearTimeout(J.current)})},[$,o,n,z,Q]),(0,a.useEffect)(()=>{P(h)},[h]),(0,a.useEffect)(()=>{I||"hesitation"!==L||R("selected")},[L,I]),(0,a.useEffect)(()=>{n&&R(I?"hesitation"===m?"hesitation":"auto":m)},[n,I,s,m]);const Z=(0,a.useCallback)(async()=>{if(x){w(!0);try{const e=await zp.ensureHesitationTranscript(s,x);e.success&&e.checksum&&(P(!0),R("hesitation"),window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:s,scopes:["session","transcript","gaps"]}})))}catch(e){j(e.message||"Failed to generate hesitation transcript")}finally{w(!1)}}},[s,x]),ee=(0,a.useCallback)(async()=>{if(x){F(!0),j(null),C(null);try{const e=await zp.applyGeneratedGapEdits(s,{minGapSeconds:O,relativeThreshold:V,clusterMaxGap:30,minGapsInCluster:2,windowSize:300,transcriptSource:z,minIntraPhraseGapSeconds:q,minBoundaryGapSeconds:Y},x);C(e.message||"Applied ".concat(e.appliedEditCount," generated edits.")),window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:s,scopes:["session","ttml","description","narrative","gaps"]}})),Q()}catch(e){j(e.message||"Failed to apply generated edits")}finally{F(!1)}}},[Y,O,q,z,Q,s,x,V]),te=(0,a.useCallback)(async()=>
2{if(x){A(!0),j(null),C(null);try{const e=await zp.removeGeneratedGapEdits(s,{},x);C(e.message||"Removed ".concat(e.removedGeneratedEditCount," generated edits.")),window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:s,scopes:["session","ttml","description","narrative","gaps"]}})),Q()}catch(e){j(e.message||"Failed to remove generated edits")}finally{A(!1)}}},[Q,s,x]);(0,a.useEffect)(()=>{K.current&&K.current.update(),X.current&&X.current.update()},[O,V]);const ne=(0,a.useMemo)(()=>{if(!T)return[];const e=[];for(const t of T.clusters){if(!t.gaps){t.avgZScore>=V&&e.push(t);continue}const n=t.gaps.filter(e=>e.gapDuration>=O&&e.zScore>=V);if(n.length<2)continue;const a=n.reduce((e,t)=>e+t.zScore,0)/n.length,r=Math.max(...n.map(e=>e.zScore));let s;s=a>=2.5?"high":a>=1.5?"medium":"low",e.push(d(d({},t),{},{gapCount:n.length,avgZScore:Math.round(100*a)/100,maxZScore:Math.round(100*r)/100,severity:s,gaps:n}))}return e.sort((e,t)=>t.avgZScore-e.avgZScore)},[T,O,V]),ae=(0,a.useMemo)(()=>{if(!T)return[];const e=new Set;for(const t of ne)if(t.gaps)for(const n of t.gaps)e.add("".concat(n.startTime,"_").concat(n.speaker));return T.gaps.filter(t=>t.gapDuration>=O&&t.zScore>=V&&!e.has("".concat(t.startTime,"_").concat(t.speaker)))},[T,ne,O,V]),re=(0,a.useRef)(null);(0,a.useEffect)(()=>{if(p)return re.current&&clearTimeout(re.current),re.current=setTimeout(()=>{p(ne,ae)},300),()=>{re.current&&clearTimeout(re.current)}},[ne,ae,p]);const se=(0,a.useMemo)(()=>T?T.gaps.filter(e=>e.gapDuration>=O&&e.zScore>=V).length:0,[T,O,V]),ie=(0,a.useMemo)(()=>null!==T&&void 0!==T&&T.hesitationCandidates?T.hesitationCandidates.filter(e=>{var t,n,a,r;const s=Number(null!==(t=e.combinedGapSeconds)&&void 0!==t?t:0),i=Number(null!==(n=e.maxGapDuration)&&void 0!==n?n:0),o=Number(null!==(a=e.maxGapZScore)&&void 0!==a?a:0),l=Number(null!==(r=e.supportingGapCount)&&void 0!==r?r:0);return!(s<O)&&("explicit-token"===e.inferenceMode?l>0?i>=O&&o>=V:Boolean(e.cleanCut):o>=V)}):[],[T,O,V]),oe=(0,a.useMemo)(()=>ie.filter(e=>"explicit-token"===e.inferenceMode).length,[ie]),le=(0,a.useMemo)(()=>ie.filter(e=>"timing-gap"===e.inferenceMode).length,[ie]),ce=(0,a.useMemo)(()=>{if(!T)return null;const e=Object.values(T.speakerBaselines);return 0===e.length?null:e.reduce((e,t)=>e.meanGap>t.meanGap?e:t)},[T]),de=(0,a.useMemo)(()=>{if(!T||0===T.gaps.length)return 0;const e=T.gaps.filter(e=>e.gapDuration>=O&&e.zScore>=V);return 0===e.length?0:(e.reduce((e,t)=>e+t.zScore,0)/e.length).toFixed(1)},[T,O,V]),ue=(0,a.useMemo)(()=>function(e,t){if(!e||!t)return[];const n=e.find(e=>e.checksum===t);if(!n)return[];const a=n.topics||[];return 0===a.length?[]:a.map((e,t)=>({time:e.startTime||e.start||0,label:e.title||e.name||"Topic ".concat(t+1)})).filter(e=>e.time>0)}(l||[],c||null),[l,c]),me=(0,a.useMemo)(()=>{if(!T)return[];const e=new Set,t=[];function n(n){const a="".concat(n.startTime,"_").concat(n.speaker);e.has(a)||n.gapDuration<O||n.zScore<V||(e.add(a),t.push({startTime:n.startTime,endTime:n.startTime+n.gapDuration,zScore:n.zScore,speaker:String(n.speaker)}))}for(const a of ne)if(a.gaps)for(const e of a.gaps)n(e);for(const a of T.gaps)n(a);return t.sort((e,t)=>e.startTime-t.startTime)},[T,ne,O,V]),he=(0,a.useMemo)(()=>{if(!T)return[];const e=T.summary.totalDuration,t=ne.map(e=>[e.startTime,e.endTime]),n=(e,n)=>!t.some(t=>{let[a,r]=t;return e<r&&n>a}),a=[];for(let r=60;r<e-180&&!(n(r,r+180)&&(a.push({startTime:r,endTime:r+180,label:"Clean segment"}),a.length>=3));r+=300);return a},[T,ne]),pe=(0,a.useMemo)(()=>({summarySegments:ne.length,edits:me.length,clips:he.length+1}),[ne,me,he]),ge=(0,a.useMemo)(()=>{if(!T||!T.histogram.bins)return null;const e=T.histogram.bins,t=new Set;for(const s of e)for(const e of Object.keys(s.bySpeaker))t.add(e);const n=Array.from(t),a=e.findIndex(e=>e.binEnd>=O),r=n.map((t,n)=>{const r=iO[n%iO.length];return{label:t,data:e.map(e=>e.bySpeaker[t]||0),backgroundColor:e.map((e,t)=>t>=a&&a>=0?r.bg.replace("0.7","0.9"):r.bg),borderColor:r.border,borderWidth:1}});return{labels:e.map(e=>e.label),datasets:r}},[T,O]),xe=(0,a.useMemo)(()=>({responsive:!0,maintainAspectRatio:!1,plugins:{legend:{position:"top"},title:{display:!1},tooltip:{callbacks:{label:e=>"".concat(e.dataset.label,": ").concat(e.parsed.y," gaps")}}},scales:{x:{stacked:!0,title:{display:!0,text:"Gap Duration"},ticks:{maxTicksLimit:12}},y:{stacked:!0,title:{display:!0,text:"Count"},beginAtZero:!0}}}),[]),fe=(0,a.useRef)(O);fe.current=O;const be=(0,a.useMemo)(()=>({id:"thresholdLine",afterDraw:e=>{if(!T)return;const t=T.histogram.binWidth;
2if(!t)return;const n=fe.current,a=n/t,r=e.scales.x,s=e.scales.y;if(!r||!s)return;const i=r.getPixelForValue(a),o=e.ctx;o.save(),o.strokeStyle="#f59e0b",o.lineWidth=2,o.setLineDash([5,5]),o.beginPath(),o.moveTo(i,s.top),o.lineTo(i,s.bottom),o.stroke(),o.fillStyle="#f59e0b",o.font="10px sans-serif",o.textAlign="center",o.fillText("".concat(n.toFixed(2),"s"),i,s.top-4),o.restore()}}),[T]),ye=(0,a.useMemo)(()=>{if(!T||!T.gaps)return null;const e=T.gaps.filter(e=>e.gapDuration>=O&&e.zScore>=V);if(0===e.length)return null;const t=new Set;e.forEach(e=>t.add(String(e.speaker)));const n=Array.from(t).map((t,n)=>{var a;const r=iO[n%iO.length],s=e.filter(e=>String(e.speaker)===t);return{label:g[t]||(null===(a=T.speakerBaselines[t])||void 0===a?void 0:a.label)||"Speaker ".concat(t),data:s.map(e=>({x:e.startTime,y:e.zScore})),backgroundColor:r.dot,borderColor:r.border,pointRadius:4,pointHoverRadius:6}});return{datasets:n}},[T,O,V,g]),ve=(0,a.useRef)(f);ve.current=f;const we=(0,a.useMemo)(()=>{var e;return{responsive:!0,maintainAspectRatio:!1,layout:{padding:{bottom:20,left:30}},onClick:(e,t,n)=>{if(t.length>0){const e=t[0],a=n.data.datasets[e.datasetIndex].data[e.index];a&&"number"===typeof a.x&&ve.current(a.x)}},onHover:(e,t)=>{var n;null!==(n=e.native)&&void 0!==n&&n.target&&(e.native.target.style.cursor=t.length>0?"pointer":"default")},plugins:{legend:{position:"top",labels:{boxWidth:8,padding:8}},title:{display:!1},tooltip:{callbacks:{label:e=>{const t=e.raw;return"".concat(e.dataset.label,": z=").concat(t.y.toFixed(1)," at ").concat(oO(t.x)," (click to seek)")}}}},scales:{x:{type:"linear",title:{display:!0,text:"Episode Time"},ticks:{callback:e=>oO(e),maxTicksLimit:10},min:0,max:(null===T||void 0===T||null===(e=T.summary)||void 0===e?void 0:e.totalDuration)||void 0},y:{title:{display:!0,text:"Z-Score"},beginAtZero:!0}}}},[T]),ke=(0,a.useMemo)(()=>({id:"topicBoundaries",afterDraw:e=>{if(!ue.length)return;const t=e.scales.x,n=e.scales.y;if(!t||!n)return;const a=e.ctx;for(const r of ue){const e=t.getPixelForValue(r.time);if(e<t.left||e>t.right)continue;a.save(),a.strokeStyle="rgba(148, 163, 184, 0.5)",a.lineWidth=1,a.setLineDash([3,3]),a.beginPath(),a.moveTo(e,n.top),a.lineTo(e,n.bottom),a.stroke(),a.fillStyle="rgba(148, 163, 184, 0.7)",a.font="9px sans-serif",a.save(),a.translate(e+3,n.top+10),a.rotate(-Math.PI/4);const s=r.label.length>20?r.label.substring(0,18)+"...":r.label;a.fillText(s,0,0),a.restore(),a.restore()}}}),[ue]),je=(0,a.useMemo)(()=>({id:"clusterShading",beforeDatasetsDraw:e=>{if(!ne.length)return;const t=e.scales.x,n=e.scales.y;if(!t||!n)return;const a=e.ctx;for(const r of ne){const e=t.getPixelForValue(r.startTime),s=t.getPixelForValue(r.endTime),i="high"===r.severity?"rgba(239, 68, 68, 0.08)":"medium"===r.severity?"rgba(245, 158, 11, 0.08)":"rgba(234, 179, 8, 0.06)";a.save(),a.fillStyle=i,a.fillRect(e,n.top,s-e,n.bottom-n.top),a.restore()}}}),[ne]);(0,a.useRef)(me).current=me;const De=(0,a.useRef)(he);De.current=he;const Ce=(0,a.useRef)(ne);Ce.current=ne;const Ne=(0,a.useMemo)(()=>({id:"editClipLines",afterDatasetsDraw:e=>{const t=e.scales.x,n=e.scales.y;if(!t||!n)return;const a=e.ctx,r=n.bottom,s=Ce.current;if(s.length>0){for(const e of s){const n=Math.max(t.getPixelForValue(e.startTime),t.left),s=Math.min(t.getPixelForValue(e.endTime),t.right);if(s<=n)continue;const i="high"===e.severity?"rgba(239, 68, 68, 0.8)":"medium"===e.severity?"rgba(245, 158, 11, 0.7)":"rgba(234, 179, 8, 0.6)";a.save(),a.fillStyle=i,a.fillRect(n,r-8,s-n,4),a.restore()}a.save(),a.fillStyle="rgba(239, 68, 68, 0.7)",a.font="9px sans-serif",a.textAlign="right",a.fillText("Edits",t.left-4,r-5),a.restore()}const i=De.current;if(i.length>0){for(const e of i){const n=Math.max(t.getPixelForValue(e.startTime),t.left),s=Math.min(t.getPixelForValue(e.endTime),t.right);s<=n||(a.save(),a.fillStyle="rgba(59, 130, 246, 0.6)",a.fillRect(n,r-16,s-n,4),a.restore())}a.save(),a.fillStyle="rgba(59, 130, 246, 0.7)",a.font="9px sans-serif",a.textAlign="right",a.fillText("Clips",t.left-4,r-13),a.restore()}}}),[]);return n?(0,u.jsx)(S,{children:(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4",onClick:e=>{e.target===e.currentTarget&&r()},children:(0,u.jsxs)(Do.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},className:"bg-white dark:bg-gray-800 rounded-xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[(0,u.jsxs)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center",children:[(0,u.jsx)(yp,{className:"h-5 w-5 mr-2 text-amber-500"}),"Gap Analysis"]}),(0,u.jsx)("button",{onClick:r,className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:(0,u.jsx)(Pu,{className:"h-5 w-5 text-gray-500"})})]}),(0,u.jsxs)("div",{className:"overflow-y-auto flex-1 p-4 space-y-4",children:[(0,u.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-3 space-y-3",children:[(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"flex items-center justify-between text-sm text-gray-700 dark:text-gray-300 mb-1",children:[(0,u.jsx)("span",{children:"Gap Threshold"}),(0,u.jsxs)("span",{className:"font-mono font-semibold",children:[O.toFixed(2),"s"]})]}),(0,u.jsx)("input",{type:"range",min:"0.1",max:"3.0",step:"0.05",value:O,onChange:e=>U(parseFloat(e.target.value)),className:"w-full accent-amber-500"})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"flex items-center justify-between text-sm text-gray-700 dark:text-gray-300 mb-1",children:[(0,u.jsx)("span",{children:"Z-Score Cutoff"}),(0,u.jsx)("span",{className:"font-mono font-semibold",children:V.toFixed(1)})]}),(0,u.jsx)("input",{type:"range",min:"0.5",max:"4.0",step:"0.1",value:V,onChange:e=>H(parseFloat(e.target.value)),className:"w-full accent-amber-500"})]})]}),(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"flex items-center justify-between text-sm text-gray-700 dark:text-gray-300 mb-1",children:[(0,u.jsx)("span",{children:"Pause Inference Floor"}),(0,u.jsxs)("span",{className:"font-mono font-semibold",children:[q.toFixed(2),"s"]})]}),(0,u.jsx)("input",{type:"range",min:"0.5",max:"3.0",step:"0.05",value:q,onChange:e=>W(parseFloat(e.target.value)),className:"w-full accent-sky-500"})]}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{className:"flex items-center justify-between text-sm text-gray-700 dark:text-gray-300 mb-1",children:[(0,u.jsx)("span",{children:"Boundary Pause Floor"}),(0,u.jsxs)("span",{className:"font-mono font-semibold",children:[Y.toFixed(2),"s"]})]}),(0,u.jsx)("input",{type:"range",min:"0.75",max:"3.5",step:"0.05",value:Y,onChange:e=>G(parseFloat(e.target.value)),className:"w-full accent-sky-500"})]})]}),(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"These two controls change how aggressively same-speaker dead-air pauses become hesitation candidates. They expand or shrink the candidate pool itself, unlike the threshold sliders above which only filter the current pool."}),(0,u.jsxs)("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Transcript source"}),(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"`Auto` will use the hesitation transcript when it exists, otherwise it falls back to the readable transcript."})]}),(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:[["auto","Auto"],["selected","Readable"],["original","Original"],["hesitation","Hesitation"]].map(e=>{let[t,n]=e;return(0,u.jsx)("button",{type:"button",onClick:()=>R(t),disabled:"hesitation"===t&&!I,className:"rounded-lg border px-3 py-1.5 text-sm transition-colors ".concat(L===t?"border-amber-500 bg-amber-100 text-amber-900 dark:border-amber-400 dark:bg-amber-500/20 dark:text-amber-200":"border-gray-200 bg-white text-gray-700 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"," disabled:cursor-not-allowed disabled:opacity-50"),children:n},t)})})]}),!I&&!!x&&(0,u.jsx)("div",{className:"flex justify-end",children:(0,u.jsxs)("button",{type:"button",onClick:()=>{Z()},disabled:v,className:"inline-flex items-center gap-2 rounded-lg border border-amber-300 bg-amber-50 px-3 py-1.5 text-sm text-amber-900 transition-colors hover:bg-amber-100 disabled:cursor-wait disabled:opacity-60 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200 dark:hover:bg-amber-500/20",children:[v&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}),(0,u.jsx)("span",{children:v?"Generating\u2026":"Generate hesitation transcript"})]})}),T&&(0,u.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs text-gray-600 dark:text-gray-300",children:[(0,u.jsxs)("span",{className:"rounded-full bg-white px-2.5 py-1 dark:bg-gray-800",children:["Requested: ",L]}),(0,u.jsxs)("span",{className:"rounded-full bg-white px-2.5 py-1 dark:bg-gray-800",children:["Effective: ",T.transcriptSource||z]}),"auto"===L&&!I&&(0,u.jsx)("span",{className:"rounded-full bg-amber-100 px-2.5 py-1 text-amber-800 dark:bg-amber-500/20 dark:text-amber-200",children:"Fell back to readable transcript"}),!(null===(t=T.hesitationCandidates)||void 0===t||!t.length)&&(0,u.jsxs)("span",{className:"rounded-full bg-emerald-100 px-2.5 py-1 text-emerald-800 dark:bg-emerald-500/20 dark:text-emerald-200",children:[ie.length," of ",T.hesitationCandidates.length," hesitation candidates at current thresholds"]}),!!oe&&(0,u.jsxs)("span",{className:"rounded-full bg-amber-100 px-2.5 py-1 text-amber-800 dark:bg-amber-500/20 dark:text-amber-200",children:[oe," explicit hesitation runs"]}),!!le&&(0,u.jsxs)("span",{className:"rounded-full bg-sky-100 px-2.5 py-1 text-sky-800 dark:bg-sky-500/20 dark:text-sky-200",children:[le," inferred from timing gaps"]})]}),!!x&&(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-gray-200 pt-3 dark:border-gray-700",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{ee()},disabled:N||b,className:"inline-flex items-center gap-2 rounded-lg border border-emerald-300 bg-emerald-50 px-3 py-1.5 text-sm text-emerald-900 transition-colors hover:bg-emerald-100 disabled:cursor-wait disabled:opacity-60 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-200 dark:hover:bg-emerald-500/20",children:[N&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}),(0,u.jsx)("span",{children:N?"Applying\u2026":"Apply generated edits"})]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{te()},disabled:E||b,className:"inline-flex items-center gap-2 rounded-lg border border-gray-300 bg-white px-3 py-1.5 text-sm text-gray-700 transition-colors hover:bg-gray-100 disabled:cursor-wait disabled:opacity-60 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700",children:[E&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}),(0,u.jsx)("span",{children:E?"Removing\u2026":"Remove generated edits"})]}),(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"These create a tagged TTML child revision on the selected metadata and can be re-applied with different thresholds."})]}),D&&(0,u.jsx)("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-sm text-emerald-700 dark:border-emerald-800 dark:bg-emerald-900/20 dark:text-emerald-200",children:D})]}),b&&(0,u.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,u.jsx)(Lo,{className:"h-8 w-8 animate-spin text-amber-500 mr-3"}),(0,u.jsx)("span",{className:"text-gray-600 dark:text-gray-300",children:"Analyzing speech gaps..."})]}
2),k&&(0,u.jsxs)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:[(0,u.jsxs)("p",{className:"text-red-700 dark:text-red-300 flex items-center",children:[(0,u.jsx)(fp,{className:"h-4 w-4 mr-2"}),k]}),(0,u.jsx)("button",{onClick:Q,className:"mt-2 text-sm text-red-600 hover:underline",children:"Retry"})]}),T&&!b&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[(0,u.jsx)(cO,{label:"Total Gaps",value:String(T.summary.totalGaps),sub:"".concat(se," above threshold")}),(0,u.jsx)(cO,{label:"Clusters",value:String(ne.length),sub:"of ".concat(T.summary.clusters," total")}),(0,u.jsx)(cO,{label:"Most Gappy",value:(null===ce||void 0===ce?void 0:ce.label)||"-",sub:ce?"".concat(Math.round(1e3*ce.meanGap),"ms avg"):""}),(0,u.jsx)(cO,{label:"Gappiness",value:String(de),sub:"avg z-score"})]}),(0,u.jsxs)("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3",children:[(0,u.jsxs)("button",{onClick:()=>B(!_),className:"flex items-center gap-1.5 text-sm font-medium text-blue-700 dark:text-blue-300 w-full",children:[(0,u.jsx)(DM,{className:"h-4 w-4"}),"What is a Z-score?",(0,u.jsx)("span",{className:"ml-auto text-xs",children:_?"Hide":"Show"})]}),_&&(0,u.jsxs)("div",{className:"mt-2 text-sm text-blue-600 dark:text-blue-400 space-y-1",children:[(0,u.jsxs)("p",{children:["Z-score measures how unusual a gap is ",(0,u.jsx)("strong",{children:"for that specific speaker"}),". It compares each gap against the speaker's own baseline."]}),(0,u.jsxs)("div",{className:"grid grid-cols-3 gap-2 mt-2 text-xs",children:[(0,u.jsxs)("div",{className:"bg-blue-100 dark:bg-blue-900/40 rounded p-1.5 text-center",children:[(0,u.jsx)("div",{className:"font-bold",children:"z = 1.0"}),(0,u.jsx)("div",{children:"Slightly unusual"})]}),(0,u.jsxs)("div",{className:"bg-blue-100 dark:bg-blue-900/40 rounded p-1.5 text-center",children:[(0,u.jsx)("div",{className:"font-bold",children:"z = 2.0"}),(0,u.jsx)("div",{children:"Very unusual"})]}),(0,u.jsxs)("div",{className:"bg-blue-100 dark:bg-blue-900/40 rounded p-1.5 text-center",children:[(0,u.jsx)("div",{className:"font-bold",children:"z = 3.0+"}),(0,u.jsx)("div",{children:"Extreme outlier"})]})]}),(0,u.jsx)("p",{className:"text-xs mt-1",children:"A fast speaker who suddenly pauses for 2 seconds will have a high z-score even if a slow speaker pauses for 2 seconds routinely (low z-score). This is why relative gappiness matters more than absolute gap duration."})]})]}),ge&&(0,u.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4",children:[(0,u.jsx)("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2",children:"Gap Duration Distribution"}),(0,u.jsx)("div",{style:{height:"220px"},children:(0,u.jsx)(tO,{ref:K,data:ge,options:xe,plugins:[be]})})]}),ye&&(0,u.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4",children:[(0,u.jsxs)("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-1",children:["Gap Timeline",(0,u.jsxs)("span",{className:"ml-2 text-xs font-normal text-gray-500",children:["Dots = gaps | Bottom bars: ",(0,u.jsx)("span",{style:{color:"rgb(239, 68, 68)"},children:"edits"})," / ",(0,u.jsx)("span",{style:{color:"rgb(59, 130, 246)"},children:"clips"}),ue.length>0&&" | Dashed = topics"]})]}),(0,u.jsx)("div",{style:{height:"230px"},children:(0,u.jsx)(nO,{ref:X,data:ye,options:we,plugins:[ke,je,Ne]})})]}),(0,u.jsx)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4",children:(0,u.jsxs)("div",{className:"flex items-center gap-4 text-xs text-gray-600 dark:text-gray-400",children:[(0,u.jsx)("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"TTML Preview:"}),(0,u.jsxs)("span",{className:"flex items-center gap-1",children:[(0,u.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"rgba(245, 158, 11, 0.8)"}}
2),pe.summarySegments," ",1===pe.summarySegments?"region":"regions"]}),(0,u.jsxs)("span",{className:"flex items-center gap-1",children:[(0,u.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"rgba(239, 68, 68, 0.8)"}}),pe.edits," ",1===pe.edits?"edit":"edits"]}),(0,u.jsxs)("span",{className:"flex items-center gap-1",children:[(0,u.jsx)("span",{className:"inline-block w-2.5 h-2.5 rounded-sm",style:{backgroundColor:"rgba(59, 130, 246, 0.8)"}}),pe.clips," ",1===pe.clips?"clip":"clips"]}),(0,u.jsxs)("span",{className:"ml-auto text-gray-400 dark:text-gray-500",children:[se," gaps total"]})]})}),(0,u.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4",children:[(0,u.jsx)("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Per-Speaker Breakdown"}),(0,u.jsx)("div",{className:"space-y-3",children:Object.values(T.speakerBaselines).map(e=>{const t=T.gaps.filter(t=>String(t.speaker)===e.speakerId),n=t.filter(e=>e.gapDuration>=O&&e.zScore>=V).length,a=t.length>0?Math.round((t.length-n)/t.length*100):100,r=n>0?(t.filter(e=>e.gapDuration>=O&&e.zScore>=V).reduce((e,t)=>e+t.zScore,0)/n).toFixed(1):"0";return(0,u.jsxs)("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,u.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:e.label}),(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[e.wordsPerMinute," WPM, median ",Math.round(1e3*e.medianGap),"ms"]})]}),(0,u.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400 mb-1",children:[n," gaps above threshold, avg z=",r]}),(0,u.jsx)("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2",children:(0,u.jsx)("div",{className:"h-2 rounded-full transition-all",style:{width:"".concat(a,"%"),backgroundColor:a>=70?"#22c55e":a>=40?"#f59e0b":"#ef4444"}})}),(0,u.jsxs)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:[a,"% of speech is clean"]})]},e.speakerId)})})]}),ne.length>0&&(0,u.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4",children:[(0,u.jsxs)("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:["Gappy Regions (",ne.length,")"]}),(0,u.jsx)("div",{className:"space-y-2",children:ne.map((e,t)=>{const n=e.speakers.map(e=>{var t;return g[e]||(null===(t=T.speakerBaselines[e])||void 0===t?void 0:t.label)||"Speaker ".concat(e)}).join(", ");return(0,u.jsxs)("div",{className:"border-l-4 pl-3 py-2",style:{borderColor:aO[e.severity]||"#94a3b8"},children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[(0,u.jsx)("span",{children:rO[e.severity]||""}),(0,u.jsxs)("span",{children:["[",oO(e.startTime),"-",oO(e.endTime),"]"]}),(0,u.jsxs)("span",{children:[e.gapCount," gaps, z=",e.avgZScore]}),(0,u.jsx)("span",{className:"text-gray-500",children:n})]}),(0,u.jsxs)("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 flex items-center gap-1",children:[(0,u.jsx)("span",{className:"font-semibold uppercase",style:{color:aO[e.severity]},children:sO[e.editorialSignal]||e.editorialSignal}),e.editorialDescription&&(0,u.jsxs)("span",{children:["\u2014 ",e.editorialDescription]})]})]},t)})})]}),0===ne.length&&T.summary.clusters>0&&(0,u.jsxs)("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 text-sm text-green-700 dark:text-green-300 flex items-center",children:[(0,u.jsx)(jp,{className:"h-4 w-4 mr-2 flex-shrink-0"}),"No clusters at current z-score cutoff (",V,"). Try lowering the threshold to see more regions."]}),T.compactSummary&&(0,u.jsxs)("details",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg",children:[(0,u.jsx)("summary",{className:"p-3 text-sm font-semibold text-gray-700 dark:text-gray-300 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg",children:"Prompt Summary (injected into TTML generation)"}),(0,u.jsx)("pre",{className:"p-3 pt-0 text-xs text-gray-600 dark:text-gray-400 whitespace-pre-wrap font-mono overflow-x-auto",children:T.compactSummary})]})]})]}),T&&!b&&(0,u.jsxs)("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4 flex gap-3 flex-shrink-0",children:[(0,u.jsxs)("button",{onClick:()=>{const e=zp.getGapTtmlDownloadUrl(s,{minGapSeconds:O,relativeThreshold:V,transcriptSource:z});fetch(e,{headers:{Authorization:"Bearer ".concat(x)}}).then(e=>e.blob()).then(e=>{const t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download="gap-analysis.ttml",n.click(),URL.revokeObjectURL(t)}).catch(e=>j("Download failed: ".concat(e.message)))},className:"flex items-center px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 transition-colors",children:[(0,u.jsx)(Sp,{className:"h-4 w-4 mr-2"}),"Download TTML"]}),(0,u.jsxs)("button",{onClick:Q,className:"flex items-center px-4 py-2 bg-amber-600 text-white rounded-md hover:bg-amber-700 transition-colors",children:[(0,u.jsx)(yp,{className:"h-4 w-4 mr-2"}),"Re-analyze"]})]})]})})}):null}function cO(e){let{label:t,value:n,sub:a}=e;return(0,u.jsxs)("div",{className:"bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-0.5",children:t}),(0,u.jsx)("div",{className:"text-xl font-bold text-gray-900 dark:text-white",children:n}),a&&(0,u.jsx)("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:a})]})}const dO=e=>{let{revisions:t,selectedChecksum:n,onSelectRevision:r,onViewDiff:s,onDeleteRevision:i,compact:o=!1,canDelete:l=!1}=e;const[c,d]=(0,a.useState)(null),m=(0,a.useRef)(null),h=(0,a.useCallback)((e,t)=>{l&&t&&i&&(m.current=setTimeout(()=>{d(e)},1500))},[l,i]),p=(0,a.useCallback)(()=>{m.current&&(clearTimeout(m.current),m.current=null),d(null)},[]),g=(0,a.useCallback)((e,t)=>{e.stopPropagation(),i&&i(t),d(null)},[i]);if(0===t.length)return null;const x=[...t].sort((e,t)=>
2e.version-t.version);return(0,u.jsxs)("div",{className:"flex items-center gap-1 ".concat(o?"flex-wrap":""),children:[(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-1",children:["v",x.length>0?x[x.length-1].version:1]}),x.map(e=>{const t=e.checksum===n,a=null!==e.parent_checksum,i=x.some(t=>t.parent_checksum===e.checksum),o=x.length>1&&!i,d=c===e.checksum;return(0,u.jsxs)("div",{className:"relative group",onMouseEnter:()=>h(e.checksum,o),onMouseLeave:p,children:[(0,u.jsx)("button",{onClick:()=>r(e.checksum),onContextMenu:t=>{t.preventDefault(),s&&a&&s(e.checksum)},className:"w-4 h-4 rounded-full border-2 transition-all flex items-center justify-center text-[9px] font-medium ".concat(t?"bg-blue-500 border-blue-500 text-white":a?"border-purple-400 dark:border-purple-500 text-purple-600 dark:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-900/30":"border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700"),title:"Version ".concat(e.version).concat(e.revision_notes?": ".concat(e.revision_notes.substring(0,100),"..."):""),children:e.version}),d&&l&&o&&(0,u.jsx)("button",{onClick:t=>g(t,e.checksum),className:"absolute -top-6 left-1/2 transform -translate-x-1/2 p-1 bg-red-500 hover:bg-red-600 text-white rounded-full shadow-lg transition-all z-50",title:"Delete this revision",children:(0,u.jsx)(kp,{size:12})}),(0,u.jsxs)("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 bg-gray-900 dark:bg-gray-700 text-white text-xs rounded transition-opacity pointer-events-none whitespace-nowrap z-50 ".concat(d?"opacity-0":"opacity-0 group-hover:opacity-100"),children:[(0,u.jsxs)("div",{children:["Version ",e.version]}),e.model&&(0,u.jsx)("div",{className:"text-gray-400",children:e.model}),null!==e.cost_usd&&e.cost_usd>0&&(0,u.jsxs)("div",{className:"text-gray-400",children:["$",e.cost_usd.toFixed(2)]}),e.revision_notes&&(0,u.jsx)("div",{className:"text-gray-400 max-w-[200px] truncate",children:e.revision_notes}),l&&o&&(0,u.jsx)("div",{className:"text-gray-500 text-[10px] mt-1",children:"Hold to delete"})]})]},e.checksum)})]})},uO=n.p+"static/media/pdf-file-icon.6279a47b4effd0a7eae7.png",mO=e=>{let{isDarkMode:t,className:n=""}=e;return(0,u.jsx)("img",{src:uO,alt:"","aria-hidden":"true",className:"h-8 w-8 shrink-0 object-contain ".concat(n).trim(),draggable:!1})},hO="/api";async function pO(e,t){const n=await fetch("".concat(hO,"/sessions/").concat(e,"/transcript-revisions"),{headers:{Authorization:"Bearer ".concat(t)}});if(!n.ok)throw new Error("Failed to fetch transcript revisions");const a=await n.json();return{revisions:a.revisions,selectedChecksum:a.selectedChecksum}}async function gO(e,t,n){const a=await fetch("".concat(hO,"/sessions/").concat(e,"/transcript-revisions/").concat(t),{headers:{Authorization:"Bearer ".concat(n)}});if(!a.ok)throw new Error("Failed to fetch transcript revision");const r=await a.json();return{deepgram:r.deepgram,metadata:r.metadata}}const xO=e=>{var t,n,r,s;let{isActiveTab:i=!0,ttmlFiles:o=[],sessionId:l,transcriptionChecksum:c,selectedTranscriptChecksum:d=null,hesitationTranscriptChecksum:m=null,transcript:h,filename:p,transcriptionData:g,speakerLabels:x,speakerSegments:f,sessionVisuals:b=null,youtubeUrl:y,comments:v=[],selectedTtmlId:w,onFullscreenChange:k,onSearchMatchesChange:j,onActiveTranscriptionDataChange:D,onCurrentTopicChange:C,onTtmlRevisionCreated:N,showVideoPanel:F=!1,gapAnalysisData:S,onFilteredGapClustersChange:E}=e;const{isDarkMode:A}=zu(),{pause:T,playSegment:M}=Kw(),{cursorSyncEnabled:_,requestCursorSync:B}=wk(),{token:I}=am(),P=Ww(),L=P.isCompactTouchLayout,{shareToken:R}=Hp(),z=!!R,O=!1,U=!1,V=null,[H,q]=(0,a.useState)(null),[W,Y]=(0,a.useState)(null),[G,K]=(0,a.useState)(!1),[X,J]=(0,a.useState)(!1),[$,Q]=(0,a.useState)(""),[Z,ee]=(0,a.useState)([]),[te,ne]=(0,a.useState)(0),[ae,re]=(0,a.useState)(!1),[se,ie]=(0,a.useState)(!1),[oe,le]=(0,a.useState)(!1),ce=(0,a.useRef)(null),de=(0,a.useRef)(null),ue=(0,a.useRef)(null),[me,he]=(0,a.useState)(!1),[pe,ge]=(0,a.useState)(!1),[xe,fe]=(0,a.useState)(!1),[be,ye]=(0,a.useState)("idle"),[ve,we]=(0,a.useState)(!1),[ke,je]=(0,a.useState)(!1),[De,Ce]=(0,a.useState)(!1),[Ne,Fe]=(0,a.useState)(rM),[Se,Ee]=(0,a.useState)(!1),[Ae,Te]=(0,a.useState)(null),Me=(0,a.useDeferredValue)(Ne);(0,a.useEffect)(()=>{Se&&(je(!1),Ce(!1))},[Se]),(0,a.useEffect)(()=>
2{if("undefined"===typeof document)return;const e=()=>{const e=i?document.getElementById("readable-transcript-header-toolbar-slot"):null;Te(e)};e();const t=window.requestAnimationFrame(e),n=new MutationObserver(()=>e());return n.observe(document.body,{childList:!0,subtree:!0}),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[i,X,L]);const[_e,Be]=(0,a.useState)([]),[Ie,Pe]=(0,a.useState)(null),[Le,Re]=(0,a.useState)(!1),[ze,Oe]=(0,a.useState)("selected"),[Ue,Ve]=(0,a.useState)(void 0),[He,qe]=(0,a.useState)(null),[We,Ye]=(0,a.useState)(null),[Ge,Ke]=(0,a.useState)(!1),[Xe,Je]=(0,a.useState)(!1),[$e,Qe]=(0,a.useState)(!1),[Ze,et]=(0,a.useState)(null),[tt,nt]=(0,a.useState)(!1),[at,rt]=(0,a.useState)(null),[st,it]=(0,a.useState)(void 0),[ot,lt]=(0,a.useState)(!1),[ct,dt]=(0,a.useState)("not-generated"),[ut,mt]=(0,a.useState)(null),[ht,pt]=(0,a.useState)(null),gt=m||We||null,xt="/api",ft=(0,a.useCallback)(e=>{if(void 0===e)return"";return(null===x||void 0===x?void 0:x[e])||"Speaker ".concat(e)},[x]),bt=e=>{const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return"".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"))},yt=(0,a.useCallback)((e,t)=>{if(!e||0===e.length)return"";const n=[];let a=10;const r=[];let s=null;for(const o of e){var i;const e=t(o),n=null!==(i=o.end)&&void 0!==i?i:e+5,a=o.speaker;s&&a===s.speaker||(s={speaker:a,speakerName:void 0!==a?ft(a):"",startTime:e,segments:[]},r.push(s)),s.segments.push({text:o.transcript,startTime:e,endTime:n})}for(const o of r){n.length>0&&(n.push(""),n.push("")),n.push("".concat(o.speakerName," [").concat(bt(o.startTime),"]:"));let e="";for(const t of o.segments){for(;a<=t.startTime;)e.length>0&&(e+=" [".concat(bt(a),"] ")),a+=10;e.length>0&&!e.endsWith(" ")&&(e+=" "),e+=t.text}n.push(e.trim())}return n.join("\n")},[ft]),vt=(0,a.useMemo)(()=>{var e;const t=st||(ot||!l||!I&&!R?g:void 0);return null!==t&&void 0!==t&&null!==(e=t.results)&&void 0!==e&&e.utterances?yt(t.results.utterances,e=>e.start):h},[O,V,U,st,g,h,yt,ot,l,I,R]);(0,a.useMemo)(()=>{var e;const t=ot||!l||!I&&!R||!st&&(null===g||void 0===g||null===(e=g.results)||void 0===e?void 0:e.utterances),n=st||(t?g:void 0);return n},[O,V,U,st,g,ot,l,I,R]);(0,a.useEffect)(()=>{(async()=>{if(!o||0===o.length)return Y(null),void q(null);let e=null;if(w&&(e=o.find(e=>e.checksum===w||(e.filename||e.name)===w)),e||(e=o[0]),!e)return Y(null),void q(null);if(Y(e.filename||e.name),e.content)q(e.content);else if(e.checksum){we(!0);try{let t=null;if(I){const n=await Op.downloadCachedTTML(e.checksum,I);t=await n.text()}else if(R){const n=await fetch("".concat(xt,"/api/public/share/").concat(R,"/ttml-content/").concat(e.checksum));if(!n.ok)throw new Error("Failed to fetch TTML: ".concat(n.status));t=await n.text()}q(t||null)}catch(t){console.error("[ReadableTranscriptTab] Failed to fetch TTML content:",t),q(null)}finally{we(!1)}}else q(null)})()},[o,w,I,R,xt]);const wt=(0,a.useRef)(null),kt=!!l&&(!!I||!!R);(0,a.useEffect)(()=>{if(!l)return void(null!==wt.current&&(dt("not-generated"),mt(null),pt(null),wt.current=null));if(!I)return;const e=w||"__session_pdf__";wt.current!==e&&(dt("not-generated"),mt(null),pt(null),wt.current=e);(async()=>{try{const e=await fetch("".concat(xt,"/sessions/").concat(l,"/pdf/status"),{headers:{Authorization:"Bearer ".concat(I)}});if(!e.ok)return;const t=await e.json();"cached"!==t.status&&"generating"!==t.status||(dt(t.status),t.jobId&&mt(t.jobId))}catch(e){console.error("[PDF] Error checking status:",e)}})()},[l,w,I]),(0,a.useEffect)(()=>{if(!ut||"generating"!==ct||!l||!I)return;const e=setInterval(async()=>{try{const e=await fetch("".concat(xt,"/sessions/").concat(l,"/pdf/jobs/").concat(ut),{headers:{Authorization:"Bearer ".concat(I)}});if(!e.ok)return;const t=await e.json();"completed"===t.status?(dt("cached"),mt(null)):"failed"===t.status&&(dt("error"),pt(t.error||"PDF generation failed"),mt(null))}catch(e){console.error("[PDF] Error polling job status:",e)}},2e3);return()=>clearInterval(e)},[ut,ct,l,I]);const jt=(0,a.useMemo)(()=>l?R&&!I?kM(R,xt,window.location.origin):wM(l,xt):null,[l,R,I,xt]),Dt=async()=>
2{if(l&&(I||R)&&jt)if(!R||I)if("cached"!==ct){if("generating"!==ct){dt("generating"),pt(null);try{const e=await fetch("".concat(xt,"/sessions/").concat(l,"/pdf/generate"),{method:"POST",headers:{Authorization:"Bearer ".concat(I),"Content-Type":"application/json"},body:JSON.stringify({force:!1})});if(!e.ok){const t=await e.json();throw new Error(t.error||"Failed to start PDF generation")}const t=await e.json();"cached"===t.status?(dt("cached"),window.open(jt,"_blank","noopener")):mt(t.jobId)}catch(e){console.error("[PDF] Error generating PDF:",e),dt("error"),pt(e instanceof Error?e.message:"Failed to generate PDF")}}}else window.open(jt,"_blank","noopener");else window.open(jt,"_blank","noopener")},Ct="error"===ct?ht||"PDF export unavailable":"generating"===ct?"Generating PDF transcript...":"cached"===ct?"Download PDF transcript":"Generate PDF transcript",Nt=(0,a.useRef)(0),Ft=(0,a.useCallback)(e=>{const t=Nt.current;Nt.current=e.length,ee(e),0===e.length?ne(0):ne(t=>t>=e.length?e.length-1:t),0===t&&e.length>0&&(he(!0),ge(!0))},[]),St=()=>{const e=new Blob([vt],{type:"text/plain"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t;n.download="".concat(p.replace(/\.[^/.]+$/,"")).concat("_transcript.txt"),n.click(),URL.revokeObjectURL(t)},Et=(0,a.useCallback)(async()=>{if(!l)throw new Error("Session ID is required for SRT export");const e=new URLSearchParams;Ie&&e.set("revision",Ie);const t=z&&R?"".concat(xt,"/public/share/").concat(R,"/transcript/srt").concat(e.toString()?"?".concat(e.toString()):""):"".concat(xt,"/v1/episodes/").concat(l,"/transcript/srt").concat(e.toString()?"?".concat(e.toString()):""),n={};!z&&I&&(n.Authorization="Bearer ".concat(I));const a=await fetch(t,{headers:n,credentials:z?"omit":void 0});if(!a.ok){const e=await a.text().catch(()=>"");throw new Error(e||"Failed to generate SRT (".concat(a.status,")"))}return a.text()},[xt,z,Ie,l,R,I]),At=async()=>{try{if(!l)return void alert("Session ID is required for SRT export");const e=await Et(),t=new Blob([e],{type:"text/plain"}),n=URL.createObjectURL(t),a=document.createElement("a");a.href=n,a.download="".concat(p.replace(/\.[^/.]+$/,""),"_captions.srt"),a.click(),URL.revokeObjectURL(n)}catch(e){console.error("Error generating SRT:",e),alert("Failed to generate SRT file. Please try again.")}},Tt=(0,a.useCallback)(async()=>{if(I&&l)try{fe(!0),ye("idle");const e=await Et(),t="/api",n=await fetch("".concat(t,"/youtube-analytics/captions/").concat(l,"/upload"),{method:"POST",headers:{Authorization:"Bearer ".concat(I),"Content-Type":"application/json"},body:JSON.stringify({srtContent:e,language:"en-US"})}),a=await n.json();if(!n.ok){if(!a.needsAuth)throw new Error(a.error||a.message||"Failed to upload captions");window.confirm("Please connect your YouTube account first. Open Settings > Personal & YouTube now?")&&window.location.assign("/settings?pane=personal");return void ye("error")}ye("success"),setTimeout(()=>ye("idle"),3e3)}catch(e){console.error("Error uploading to YouTube:",e),ye("error"),alert(e instanceof Error?e.message:"Failed to upload captions to YouTube")}finally{fe(!1)}else alert("You must be logged in to upload captions to YouTube.")},[Et,l,I]),Mt=async()=>{await Up(vt)?(K(!0),setTimeout(()=>K(!1),2e3)):alert("Failed to copy transcript to clipboard")},_t=()=>{const e=!X;J(e),k&&k(e)};(0,a.useEffect)(()=>{""===$&&ge(!1)},[$]),(0,a.useEffect)(()=>{if(!L||!ae)return;const e=window.setTimeout(()=>{var e,t;null===(e=ce.current)||void 0===e||e.focus({preventScroll:!0}),null===(t=ce.current)||void 0===t||t.select()},120);return()=>window.clearTimeout(e)},[L,ae]),(0,a.useEffect)(()=>{!L&&ae&&re(!1)},[L,ae]);const Bt=(0,a.useCallback)(()=>{Q(""),ee([]),ne(0),ge(!1)},[]),It=(0,a.useCallback)(()=>{je(!1),Ce(!1)},[]);(0,a.useEffect)(()=>{if(!ke)return;const e=e=>{de.current&&!de.current.contains(e.target)&&It()},t=e=>{"Escape"===e.key&&It()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[ke,It]);const Pt=async()=>
2{if(l&&I){Re(!0);try{const e=await Yh({sessionId:l,enableWebSearch:!0},I);window.dispatchEvent(new CustomEvent("navigate-to-agent",{detail:{agentSessionId:e.agentSessionId}}))}catch(e){console.error("[ReadableTranscriptTab] Failed to start transcript refinement agent:",e)}finally{Re(!1)}}},Lt=(0,a.useCallback)(async e=>{if(l)try{let t;if(R){const n=await async function(e,t){const n=await fetch("".concat(hO,"/public/share/").concat(e,"/transcript-revisions/").concat(t));if(!n.ok)throw new Error("Failed to fetch transcript revision");const a=await n.json();return{deepgram:a.deepgram,metadata:a.metadata}}(R,e);t=n.deepgram}else{if(!I)return;t=(await gO(l,e,I)).deepgram}it(t)}catch(t){console.error("[ReadableTranscriptTab] Failed to load revision data:",t)}},[l,R,I]),Rt=(0,a.useCallback)(async()=>{if(l){if(z){Be([]);const e=d||c||null;return Pe(e),e&&e!==c?await Lt(e):it(g),rt(null),nt(!1),et(null),Qe(!1),void lt(!0)}try{if(!I)return void lt(!0);const{revisions:e,selectedChecksum:t}=await pO(l,I);Be(e),Pe(t),t?await Lt(t):it(void 0),lt(!0)}catch(e){console.error("[ReadableTranscriptTab] Failed to load transcript revisions:",e),lt(!0)}}},[z,Lt,d,l,I,c,g]);(0,a.useEffect)(()=>{Rt()},[Rt]),(0,a.useEffect)(()=>{Oe("selected"),Ve(void 0),qe(null),Ye(null)},[l]),(0,a.useEffect)(()=>{if(!gt)return Ve(void 0),qe(null),void("hesitation"===ze&&Oe("selected"));He&&He!==gt&&(Ve(void 0),qe(null),"hesitation"===ze&&Oe("selected"))},[gt,He,ze]),(0,a.useEffect)(()=>{if(!l||z)return;const e=e=>{const t=e.detail||{};var n;t.sessionId&&t.sessionId!==l||(n=t.scopes,(!Array.isArray(n)||0===n.length||n.map(e=>String(e||"").trim()).some(e=>"session"===e||"transcript"===e||"transcript_revisions"===e||"agent_done"===e))&&Rt())};return window.addEventListener("rescript-session-refresh-needed",e),window.addEventListener("rescript-session-invalidated",e),()=>{window.removeEventListener("rescript-session-refresh-needed",e),window.removeEventListener("rescript-session-invalidated",e)}},[z,Rt,l]);const zt=e=>{const t=_e.find(t=>t.checksum===e);null!==t&&void 0!==t&&t.revision_notes&&(et(t.revision_notes),Qe(!0))},Ot=async e=>{if(l)try{let t;if(R){const n=await async function(e,t){const n=await fetch("".concat(hO,"/
2public/share/").concat(e,"/transcript-revisions/").concat(t,"/diffgram"));if(!n.ok)throw new Error("Failed to fetch diffgram");const a=await n.json();return{diffgram:a.diffgram,revisionNotes:a.revisionNotes}}(R,e);t=n.diffgram}else{if(!I)return;{const n=await async function(e,t,n){const a=await fetch("".concat(hO,"/sessions/").concat(e,"/transcript-revisions/").concat(t,"/diffgram"),{headers:{Authorization:"Bearer ".concat(n)}});if(!a.ok)throw new Error("Failed to fetch diffgram");const r=await a.json();return{diffgram:r.diffgram,revisionNotes:r.revisionNotes}}(l,e,I);t=n.diffgram}}t&&(rt(t),nt(!0))}catch(t){console.error("[ReadableTranscriptTab] Failed to load diffgram:",t)}},Ut=async e=>{if(l)try{R?(Pe(e),await Lt(e)):I&&(await async function(e,t,n){if(!(await fetch("".concat(hO,"/sessions/").concat(e,"/selected-transcript"),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)},body:JSON.stringify({checksum:t})})).ok)throw new Error("Failed to select transcript revision")}(l,e,I),Pe(e),await Lt(e))}catch(t){console.error("[ReadableTranscriptTab] Failed to select revision:",t)}},Vt=async e=>{if(l&&I)try{const t=await async function(e,t,n){const a=await fetch("".concat(hO,"/sessions/").concat(e,"/transcript-revisions/").concat(t),{method:"DELETE",headers:{Authorization:"Bearer ".concat(n)}});if(!a.ok){const e=await a.json().catch(()=>({}));throw new Error(e.error||"Failed to delete transcript revision")}return{newSelectedChecksum:(await a.json()).newSelectedChecksum}}(l,e,I),{revisions:n,selectedChecksum:a}=await pO(l,I);Be(n),e===Ie&&t.newSelectedChecksum?(Pe(t.newSelectedChecksum),await Lt(t.newSelectedChecksum)):a&&Pe(a)}catch(t){console.error("[ReadableTranscriptTab] Failed to delete revision:",t)}},Ht=(0,a.useCallback)(async e=>{if(!l||!I||z)return!1;if(He===e&&Ue)return!0;Ke(!0);try{const t=await gO(l,e,I);return Ve(t.deepgram),qe(e),!0}catch(t){return console.error("[ReadableTranscriptTab] Failed to load hesitation transcript:",t),!1}finally{Ke(!1)}},[Ue,z,He,l,I]),qt=(0,a.useCallback)(async()=>{if(!gt)return;await Ht(gt)&&Oe("hesitation")},[gt,Ht]),Wt=(0,a.useCallback)(async()=>{if(l&&I&&!z){Je(!0);try{const e=(await Op.ensureHesitationTranscript(l,I)).checksum||null;if(!e)return;Ye(e);await Ht(e)&&Oe("hesitation"),window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:l,scopes:["session","transcript"]}}))}catch(e){console.error("[ReadableTranscriptTab] Failed to generate hesitation transcript:",e)}finally{Je(!1)}}},[z,Ht,l,I]);(0,a.useEffect)(()=>{j&&j(Z)},[Z,j]),(0,a.useEffect)(()=>{X&&Ee(!1)},[X]),(0,a.useEffect)(()=>{const e=e=>{X&&"Escape"===e.key&&(J(!1),k&&k(!1))};return X&&document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[X,k]);const Yt=st||(ot?g:void 0),Gt="hesitation"===ze?Ue:Yt,Kt=(0,a.useMemo)(()=>((e,t)=>{var n,a,r,s;if(null===e||void 0===e||!e.results)return t;const i=null===(n=e.results.channels)||void 0===n||null===(a=n[0])||void 0===a||null===(r=a.alternatives)||void 0===r||null===(s=r[0])||void 0===s?void 0:s.transcript;if("string"===typeof i&&i.trim())return i.trim();if(Array.isArray(e.results.utterances)&&e.results.utterances.length>0){const t=e.results.utterances.map(e=>{var t;return null===e||void 0===e||null===(t=e.transcript)||void 0===t?void 0:t.trim()}).filter(Boolean).join("\n\n");if(t)return t}return t})(Gt,h),[Gt,h]),Xt=!(!Gt||!Gt.results),Jt=Xt||Boolean(H),$t=Boolean(l&&I&&!z&&!ot),Qt=Boolean(ve||"hesitation"===ze&&Ge||$t||l&&!ot&&!Jt);if((0,a.useEffect)(()=>{null===D||void 0===D||D(Gt||Yt||g)},[Gt,D,Yt,g]),!Qt&&!H&&0===o.length&&!Xt)return(0,u.jsx)("div",{className:"h-full flex items-center justify-center",children:(0,u.jsx)("div",{className:"text-center",children:(0,u.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:"No metadata revision available. Generate one from the Ranking and Metadata tab first."})})});const Zt=i&&!X&&!L&&!!Ae,en=Zt&&Ae?(0,mk.createPortal)((0,u.jsxs)("div",{className:"flex w-full min-w-0 max-w-[58rem] flex-wrap items-center justify-end gap-2 rounded-[24px] border px-3 py-2 ".concat(A?"border-white/10 bg-[radial-gradient(circle_at_10%_16%,rgba(255,181,43,0.10),transparent_24%),radial-gradient(circle_at_84%_16%,rgba(111,137,
2182,0.08),transparent_22%),linear-gradient(180deg,rgba(17,27,42,0.46),rgba(17,27,42,0.42))] shadow-[0_18px_34px_-26px_rgba(0,0,0,0.74)] backdrop-blur-[28px]":"border-[rgba(215,222,233,0.84)] bg-[radial-gradient(circle_at_10%_16%,rgba(255,181,43,0.10),transparent_24%),radial-gradient(circle_at_84%_16%,rgba(111,137,182,0.06),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.52),rgba(255,255,255,0.42))] shadow-[0_18px_34px_-26px_rgba(35,46,63,0.24)] backdrop-blur-[26px]"),children:[(0,u.jsx)("div",{className:"relative min-w-[11rem] flex-1",children:(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-[18px] border px-3 py-2 ".concat(A?"border-white/10 bg-white/[0.07] backdrop-blur-[20px]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.42)] backdrop-blur-[18px]"),children:[(0,u.jsx)(Mu,{size:14,className:A?"text-gray-400":"text-gray-500"}),(0,u.jsx)("input",{ref:ce,type:"text",value:$,onChange:e=>Q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&""!==$.trim()&&he(!0)},placeholder:"Search transcript...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none ".concat(A?"text-gray-100 placeholder-gray-500":"text-gray-700 placeholder-gray-400")}),Z.length>0&&(0,u.jsxs)("div",{className:"flex items-center gap-1 rounded-full px-2 py-1 text-[11px] ".concat(A?"bg-white/10 text-gray-300":"bg-white/70 text-gray-600"),children:[(0,u.jsxs)("span",{children:[te+1,"/",Z.length]}),(0,u.jsx)("button",{onClick:()=>{ne(e=>(e-1+Z.length)%Z.length),he(!0)},className:"rounded p-0.5 ".concat(A?"hover:bg-white/10":"hover:bg-gray-100"),title:"Previous match",children:(0,u.jsx)(dk,{size:12})}),(0,u.jsx)("button",{onClick:()=>{ne(e=>(e+1)%Z.length),he(!0)},className:"rounded p-0.5 ".concat(A?"hover:bg-white/10":"hover:bg-gray-100"),title:"Next match",children:(0,u.jsx)(bp,{size:12})})]}),$&&(0,u.jsx)("button",{onClick:Bt,className:"rounded p-1 ".concat(A?"hover:bg-white/10 text-gray-400":"hover:bg-gray-200 text-gray-500"),title:"Clear search",children:(0,u.jsx)(Pu,{size:13})})]})}),(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[!P.isMobile&&!_&&(0,u.jsx)("button",{type:"button",onClick:()=>B(),className:"inline-flex h-9 w-9 items-center justify-center rounded-[16px] bg-brand-yellow text-brand-navy shadow-[0_14px_24px_-18px_rgba(255,181,43,0.7)] transition-colors hover:bg-[#f6c15e]",title:"Resync transcript and timeline to the playhead","aria-label":"Resync transcript and timeline to the playhead",children:(0,u.jsx)(PN,{size:15})}),(0,u.jsx)("button",{onClick:Mt,className:"inline-flex h-9 w-9 items-center justify-center rounded-[16px] border text-sm font-medium transition-colors ".concat(A?"border-white/10 bg-white/[0.06] text-gray-100 shadow-[0_12px_22px_-18px_rgba(0,0,0,0.72)] hover:bg-white/[0.12]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.42)] text-gray-700 shadow-[0_12px_22px_-18px_rgba(35,46,63,0.22)] hover:bg-[rgba(255,255,255,0.58)]"),title:G?"Copied transcript to clipboard":"Copy transcript","aria-label":G?"Copied transcript to clipboard":"Copy transcript",children:G?(0,u.jsx)(Wm,{size:15,className:"text-green-500"}):(0,u.jsx)(Np,{size:15})}),(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)("button",{ref:ue,type:"button",onClick:()=>{je(!1),Ce(e=>!e)},className:"inline-flex h-9 w-9 items-center justify-center rounded-[16px] border text-sm font-medium transition-colors ".concat(De?A?"border-white/10 bg-white/[0.12] text-white":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.58)] text-gray-900":A?"border-white/10 bg-white/[0.06] text-gray-200 shadow-[0_12px_22px_-18px_rgba(0,0,0,0.72)] hover:bg-white/[0.12]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.42)] text-gray-700 shadow-[0_12px_22px_-18px_rgba(35,46,63,0.22)] hover:bg-[rgba(255,255,255,0.58)]"),title:"Reading settings","aria-label":"Reading settings",children:(0,u.jsx)(_w,{size:15})}),(0,u.jsx)(iM,{config:Ne,onChange:Fe,isOpen:De,onClose:()=>Ce(!1),anchorRef:ue})]}),kt&&(0,u.jsxs)("button",{type:"button",onClick:Dt,disabled:"generating"===ct,title:Ct,"aria-label":Ct,className:"relative inline-flex h-9 w-9 items-center justify-center rounded-[16px] border text-sm font-medium transition-colors ".concat(A?"border-white/10 bg-white/[0.06] text-gray-200 shadow-[0_12px_22px_-18px_rgba(0,0,0,0.72)] hover:bg-white/[0.12]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.42)] text-gray-700 shadow-[0_12px_22px_-18px_rgba(35,46,63,0.22)] hover:bg-[rgba(255,255,255,0.58)]"," ").concat("generating"===ct?"curs
2or-wait opacity-70":""),children:[(0,u.jsx)(mO,{isDarkMode:A}),"generating"===ct&&(0,u.jsx)(Lo,{size:13,className:"animate-spin"})]}),(0,u.jsx)("button",{type:"button",onClick:_t,className:"inline-flex h-9 w-9 items-center justify-center rounded-[16px] border text-sm font-medium transition-colors ".concat(A?"border-white/10 bg-white/[0.06] text-gray-200 shadow-[0_12px_22px_-18px_rgba(0,0,0,0.72)] hover:bg-white/[0.12]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.42)] text-gray-700 shadow-[0_12px_22px_-18px_rgba(35,46,63,0.22)] hover:bg-[rgba(255,255,255,0.58)]"),title:X?"Exit fullscreen":"Enter fullscreen","aria-label":X?"Exit fullscreen":"Enter fullscreen",children:X?(0,u.jsx)(jy,{size:14}):(0,u.jsx)(Dy,{size:14})}),(0,u.jsxs)("div",{className:"relative",ref:de,children:[(0,u.jsx)("button",{type:"button",onClick:()=>je(e=>!e),className:"inline-flex h-9 w-9 items-center justify-center rounded-[16px] border text-sm font-medium transition-colors ".concat(ke?A?"border-white/10 bg-white/[0.12] text-white":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.58)] text-gray-900":A?"border-white/10 bg-white/[0.06] text-gray-200 shadow-[0_12px_22px_-18px_rgba(0,0,0,0.72)] hover:bg-white/[0.12]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.42)] text-gray-700 shadow-[0_12px_22px_-18px_rgba(35,46,63,0.22)] hover:bg-[rgba(255,255,255,0.58)]"),title:"Transcript controls","aria-label":"Transcript controls",children:(0,u.jsx)(DA,{size:15})}),ke&&(0,u.jsx)("div",{className:"absolute right-0 top-[calc(100%+0.75rem)] z-40 w-[26rem] rounded-2xl border p-4 shadow-2xl ".concat(A?"border-white/10 bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.07),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.78),rgba(17,27,42,0.74))] text-gray-100 backdrop-blur-[46px]":"border-[rgba(215,222,233,0.88)] bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.06),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.78),rgba(255,255,255,0.72))] text-gray-900 backdrop-blur-[38px]"),children:(0,u.jsxs)("div",{className:"space-y-4",children:[!z&&_e.length>0&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"text-xs font-semibold uppercase tracking-[0.16em] ".concat(A?"text-gray-400":"text-gray-500"),children:"Transcript Revisions"}),(0,u.jsx)(dO,{revisions:_e,selectedChecksum:Ie,onSelectRevision:Ut,onViewDiff:Ot,onDeleteRevision:Vt,canDelete:!!I&&!R})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[!z&&I&&l&&(0,u.jsxs)("button",{onClick:()=>{Pt(),It()},disabled:Le,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors disabled:cursor-wait disabled:opacity-70 ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"Start transcript refinement agent",children:[Le?(0,u.jsx)(Lo,{size:15,className:"animate-spin"}):(0,u.jsx)(CA,{size:15}),(0,u.jsx)("span",{children:Le?"Starting Agent\u2026":"Refine"})]}),!z&&Ie&&(null===(t=_e.find(e=>e.checksum===Ie))||void 0===t?void 0:t.revision_notes)&&(0,u.jsxs)("button",{onClick:()=>{zt(Ie),It()},className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"View revision notes",children:[(0,u.jsx)(gM,{size:15}),(0,u.jsx)("span",{children:"Notes"})]}),!z&&Ie&&(null===(n=_e.find(e=>e.checksum===Ie))||void 0===n?void 0:n.parent_checksum)&&(0,u.jsxs)("button",{onClick:()=>{Ot(Ie),It()},className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"View diffgram",children:[(0,u.jsx)(xM,{size:15}),(0,u.jsx)("span",{children:"Diffgram"})]}),(0,u.jsxs)("button",{onClick:()=>{ie(!0),It()},className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"Show word cloud",children:[(0,u.jsx)(qE,{size:15}),(0,u.jsx)("span",{children:"Word Cloud"})]}),I&&(0,u.jsxs)("button",{onClick:()=>{le(!0),It()},disabled:!l||!Gt,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"," disabled:opacity-50"),title:"Analyze speech gaps and pauses",children:[(0,u.jsx)(yp,{size:15}),(0,u.jsx)("span",{children:"Gap Analysis"})]}),(0,u.jsxs)("button",{onClick:St,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"Download TXT",children:[(0,u.jsx)(gp,{size:15}),(0,u.jsx)("span",{children:"TXT"})]}),!z&&(0,u.jsxs)("button",{onClick:At,disabled:!l,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"," disabled:opacity-50"),title:"Download SRT",children:[(0,u.jsx)(fM,{size:15}),(0,u.jsx)("span",{children:"SRT"})]}),!z&&I&&y&&(0,u.jsxs)("button",{onClick:Tt,disabled:xe,className:"inline-flex items-center justify-center gap-2 rounded-xl px-3 py-2 text-sm transition-colors ".concat("success"===be?"bg-green-600 text-white":"error"===be?"bg-red-600 text-white":A?"border border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"," disabled:opacity-50"),title:"success"===be?"Uploaded":"Upload SRT to YouTube",children:[xe?(0,u.jsx)(Lo,{size:15,className:"animate-spin"}):"success"===be?(0,u.jsx)(Wm,{size:15}):(0,u.jsx)(Eu,{size:15}),(0,u.jsx)("span",{children:"YouTube Captions"})]})]})]})})]})]})]}),Ae):null;return(0,u.jsxs)(u.Fragment,{children:[en,(0,u.jsxs)("div",{className:"h-full flex flex-col ".concat(A?"bg-gray-800":"bg-white"),children:[!X&&!L&&!Zt&&(0,u.jsx)("div",{className:"flex-shrink-0 p-4 border-b ".concat(A?"border-gray-700":"border-gray-200"),children:(0,u.jsxs)("div",{className:"flex items-start gap-3",children:[(0,u.jsx)("div",{className:"relative min-w-0 flex-1",children:(0,u.jsxs)("div",{className:"flex items-center gap-2 rounded-xl border px-3 py-2 ".concat(A?"border-gray-700 bg-gray-800/80":"border-gray-200 bg-gray-50"),children:[(0,u.jsx)(Mu,{size:15,className:A?"text-gray-400":"text-gray-500"}),(0,u.jsx)("input",{ref:ce,type:"text",value:$,onChange:e=>Q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&""!==$.trim()&&he(!0)},placeholder:"Search transcript...",className:"min-w-0 flex-1 bg-transparent text-sm outline-none ".concat(A?"text-gray-100 placeholder-gray-500":"text-gray-700 placeholder-gray-400")}),Z.length>0&&(0,u.jsxs)("div",{className:"flex items-center gap-1 rounded-full px-2 py-1 text-xs ".concat(A?"bg-gray-700 text-gray-300":"bg-white text-gray-600"),children:[(0,u.jsxs)("span",{children:[te+1,"/",Z.length]}),(0,u.jsx)("button",{onClick:()=>{ne(e=>(e-1+Z.length)%Z.length),he(!0)},className:"rounded p-0.5 ".concat(A?"hover:bg-gray-600":"hover:bg-gray-100"),title:"Previous match",children:(0,u.jsx)(dk,{size:13})}),(0,u.jsx)("button",{onClick:()=>{ne(e=>(e+1)%Z.length),he(!0)},className:"rounded p-0.5 ".concat(A?"hover:bg-gray-600":"hover:bg-gray-100"),title:"Next match",children:(0,u.jsx)(bp,{size:13})})]}),$&&(0,u.jsx)("button",{onClick:Bt,className:"rounded p-1 ".concat(A?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-500"),title:"Clear search",children:(0,u.jsx)(Pu,{size:14})})]})}),(0,u.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-2",children:[!P.isMobile&&!_&&(0,u.jsx)("button",{type:"button",onClick:()=>B(),className:"inline-flex h-10 w-10 items-center justify-center rounded-xl bg-brand-yellow text-brand-navy transition-colors hover:bg-[#f6c15e]",title:"Resync transcript and timeline to the playhead","aria-label":"Resync transcript and timeline to the playhead",children:(0,u.jsx)(PN,{size:16})}),(0,u.jsx)("button",{onClick:Mt,className:"inline-flex h-10 w-10 items-center justify-center rounded-xl text-sm font-medium transition-colors ".concat(A?"bg-gray-700 text-gray-100 hover:bg-gray-600":"bg-white text-gray-700 border border-gray-200 hover:bg-gray-50"),title:G?"Copied transcript to clipboard":"Copy transcript","aria-label":G?"Copied transcript to clipboard":"Copy transcript",children:G?(0,u.jsx)(Wm,{size:16,className:"text-green-500"}):(0,u.jsx)(Np,{size:16})}),(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)("button",{ref:ue,type:"button",onClick:()=>{je(!1),Ce(e=>!e)},className:"inline-flex h-10 w-10 items-center justify-center rounded-xl text-sm font-medium transition-colors ".concat(De?A?"bg-gray-700 text-white":"bg-gray-200 text-gray-900":A?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),title:"Reading settings","aria-label":"Reading settings",children:(0,u.jsx)(_w,{size:16})}),(0,u.jsx)(iM,{config:Ne,onChange:Fe,isOpen:De,onClose:()=>Ce(!1),anchorRef:ue})]}),kt&&(0,u.jsxs)("button",{type:"button",onClick:Dt,disabled:"generating"===ct,title:Ct,"aria-label":Ct,className:"relative inline-flex h-10 w-10 items-center justify-center rounded-xl text-sm font-medium transition-colors ".concat(A?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"," ").concat("generating"===ct?"curs
2or-wait opacity-70":""),children:[(0,u.jsx)(mO,{isDarkMode:A}),"generating"===ct&&(0,u.jsx)(Lo,{size:14,className:"animate-spin"})]}),(0,u.jsx)("button",{type:"button",onClick:_t,className:"inline-flex h-10 w-10 items-center justify-center rounded-xl text-sm font-medium transition-colors ".concat(A?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),title:X?"Exit fullscreen":"Enter fullscreen","aria-label":X?"Exit fullscreen":"Enter fullscreen",children:X?(0,u.jsx)(jy,{size:15}):(0,u.jsx)(Dy,{size:15})}),(0,u.jsxs)("div",{className:"relative",ref:de,children:[(0,u.jsx)("button",{type:"button",onClick:()=>je(e=>!e),className:"inline-flex h-10 w-10 items-center justify-center rounded-xl border text-sm font-medium transition-colors ".concat(ke?A?"border-white/10 bg-[rgba(255,255,255,0.10)] text-white":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.42)] text-gray-900":A?"border-white/10 bg-[rgba(255,255,255,0.04)] text-gray-200 hover:bg-[rgba(255,255,255,0.08)]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.28)] text-gray-700 hover:bg-[rgba(255,255,255,0.42)]"),title:"Transcript controls","aria-label":"Transcript controls",children:(0,u.jsx)(DA,{size:16})}),ke&&(0,u.jsx)("div",{className:"absolute right-0 top-[calc(100%+0.75rem)] z-40 w-[26rem] rounded-2xl border p-4 shadow-2xl ".concat(A?"border-white/10 bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.07),transparent_24%),linear-gradient(180deg,rgba(17,27,42,0.78),rgba(17,27,42,0.74))] text-gray-100 backdrop-blur-[46px]":"border-[rgba(215,222,233,0.88)] bg-[radial-gradient(circle_at_12%_14%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_18%,rgba(111,137,182,0.06),transparent_24%),linear-gradient(180deg,rgba(255,255,255,0.78),rgba(255,255,255,0.72))] text-gray-900 backdrop-blur-[38px]"),children:(0,u.jsxs)("div",{className:"space-y-4",children:[!z&&_e.length>0&&(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsx)("div",{className:"text-xs font-semibold uppercase tracking-[0.16em] ".concat(A?"text-gray-400":"text-gray-500"),children:"Transcript Revisions"}),(0,u.jsx)(dO,{revisions:_e,selectedChecksum:Ie,onSelectRevision:Ut,onViewDiff:Ot,onDeleteRevision:Vt,canDelete:!!I&&!R})]}),(0,u.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[!z&&I&&l&&(0,u.jsxs)("button",{onClick:()=>{Pt(),It()},disabled:Le,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors disabled:cursor-wait disabled:opacity-70 ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"Start transcript refinement agent",children:[Le?(0,u.jsx)(Lo,{size:15,className:"animate-spin"}):(0,u.jsx)(CA,{size:15}),(0,u.jsx)("span",{children:Le?"Starting Agent\u2026":"Refine"})]}),!z&&Ie&&(null===(r=_e.find(e=>e.checksum===Ie))||void 0===r?void 0:r.revision_notes)&&(0,u.jsxs)("button",{onClick:()=>{zt(Ie),It()},className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"View revision notes",children:[(0,u.jsx)(gM,{size:15}),(0,u.jsx)("span",{children:"Notes"})]}),!z&&Ie&&(null===(s=_e.find(e=>e.checksum===Ie))||void 0===s?void 0:s.parent_checksum)&&(0,u.jsxs)("button",{onClick:()=>{Ot(Ie),It()},className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"View diffgram",children:[(0,u.jsx)(xM,{size:15}),(0,u.jsx)("span",{children:"Diffgram"})]}),(0,u.jsxs)("button",{onClick:()=>{ie(!0),It()},className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"Show word cloud",children:[(0,u.jsx)(qE,{size:15}),(0,u.jsx)("span",{children:"Word Cloud"})]}),I&&(0,u.jsxs)("button",{onClick:()=>{le(!0),It()},disabled:!l||!Gt,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"," disabled:opacity-50"),title:"Analyze speech gaps and pauses",children:[(0,u.jsx)(yp,{size:15}),(0,u.jsx)("span",{children:"Gap Analysis"})]}),(0,u.jsxs)("button",{onClick:St,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"),title:"Download TXT",children:[(0,u.jsx)(gp,{size:15}),(0,u.jsx)("span",{children:"TXT"})]}),!z&&(0,u.jsxs)("button",{onClick:At,disabled:!l,className:"inline-flex items-center justify-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors ".concat(A?"border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"," disabled:opacity-50"),title:"Download SRT",children:[(0,u.jsx)(fM,{size:15}),(0,u.jsx)("span",{children:"SRT"})]}),!z&&I&&y&&(0,u.jsxs)("button",{onClick:Tt,disabled:xe,className:"inline-flex items-center justify-center gap-2 rounded-xl px-3 py-2 text-sm transition-colors ".concat("success"===be?"bg-green-600 text-white":"error"===be?"bg-red-600 text-white":A?"border border-white/10 bg-[rgba(255,255,255,0.04)] hover:bg-[rgba(255,255,255,0.08)] text-gray-200":"border border-[rgba(215,222,233,0.76)] bg-[rgba(255,255,255,0.28)] hover:bg-[rgba(255,255,255,0.42)] text-gray-700"," disabled:opacity-50"),title:"success"===be?"Uploaded":"Upload SRT to YouTube",children:[xe?(0,u.jsx)(Lo,{size:15,className:"animate-spin"}):"success"===be?(0,u.jsx)(Wm,{size:15}):(0,u.jsx)(Eu,{size:15}),(0,u.jsx)("span",{children:"YouTube Captions"})]})]}),Le&&(0,u.jsx)("div",{className:"rounded-xl px-3 py-2 text-xs ".concat(A?"bg-gray-800 text-gray-300":"bg-gray-50 text-gray-600"),children:"Starting transcript refinement in the agent tab..."})]})})]})]})]})}),(0,u.jsxs)("div",{className:"flex-1 overflow-hidden relative",children:[X&&(0,u.jsx)("div",{className:"pointer-events-none fixed right-4 z-50",style:{to
2p:L?"calc(var(--app-mobile-top-offset) + 0.75rem)":"1rem"},children:(0,u.jsx)("button",{type:"button",onClick:_t,className:"pointer-events-auto rounded-full border p-3 shadow-lg backdrop-blur transition-colors ".concat(A?"border-white/10 bg-[#232E3F]/95 text-white hover:border-[#FFB52B]/50 hover:bg-[#2D3A4F]":"border-gray-200 bg-white/95 text-[#232E3F] hover:border-[#FFB52B]/50 hover:bg-[#FFF8EA]"),title:"Exit fullscreen (ESC)","aria-label":"Exit fullscreen",children:(0,u.jsx)(jy,{size:18})})}),!X&&L&&!ae&&(0,u.jsxs)("div",{className:"fixed bottom-32 right-4 z-40 flex flex-col items-end gap-2",children:[(0,u.jsx)("button",{type:"button",onClick:_t,className:"rounded-full p-3 shadow-lg ".concat(A?"bg-[#232E3F] text-white":"bg-white text-[#232E3F]"),title:"Maximize transcript",children:(0,u.jsx)(Dy,{size:20})}),(0,u.jsxs)("button",{onClick:()=>{re(!0)},className:"relative rounded-full p-3 shadow-lg ".concat($.trim()?"bg-brand-yellow text-brand-navy":A?"bg-primary-600 text-white":"bg-primary-500 text-white"),title:"Search transcript",children:[(0,u.jsx)(Mu,{size:20}),Z.length>0&&(0,u.jsx)("span",{className:"absolute -right-1 -top-1 flex h-5 min-w-[1.25rem] items-center justify-center rounded-full bg-[#232E3F] px-1 text-[10px] font-semibold text-white",children:Z.length>99?"99+":Z.length})]})]}),L&&ae&&(0,u.jsxs)("div",{className:"fixed inset-x-0 z-[90] flex flex-col ".concat(A?"bg-[#111826]":"bg-[#f4f4f4]"),"data-allow-touch-scroll":"true",style:{top:"var(--app-mobile-top-offset)",bottom:"var(--app-mobile-bottom-offset)"},children:[(0,u.jsxs)("div",{className:"flex items-center justify-between border-b px-4 py-3 ".concat(A?"border-gray-700 bg-[#16202c]":"border-gray-200 bg-white"),children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] ".concat(A?"text-[#ffcf74]":"text-[#8a6115]"),children:"Search"}),(0,u.jsx)("div",{className:"text-sm font-semibold ".concat(A?"text-white":"text-[#232E3F]"),children:"Transcript search"})]}),(0,u.jsx)("button",{type:"button",onClick:()=>re(!1),className:"rounded-full border p-2 ".concat(A?"border-white/10 bg-white/[0.04] text-gray-300":"border-gray-200 bg-[#f5f7fa] text-[#5b687c]"),"aria-label":"Close search",children:(0,u.jsx)(Pu,{size:16})})]}),(0,u.jsxs)("div",{className:"border-b px-4 py-3 ".concat(A?"border-gray-700 bg-[#16202c]":"border-gray-200 bg-white"),children:[(0,u.jsxs)("div",{className:"flex items-center rounded-2xl px-3 py-2 ".concat(A?"bg-gray-800":"bg-[#eef1f3]"),children:[(0,u.jsx)(Mu,{size:16,className:A?"text-gray-400":"text-gray-500"}),(0,u.jsx)("input",{ref:ce,type:"text",inputMode:"search",autoCapitalize:"none",autoCorrect:"off",enterKeyHint:"search",value:$,onFocus:e=>e.currentTarget.select(),onChange:e=>Q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&""!==$.trim()&&he(!0)},placeholder:"Search transcript...",className:"ml-3 min-w-0 flex-1 bg-transparent text-base outline-none ".concat(A?"text-gray-100 placeholder-gray-500":"text-gray-700 placeholder-gray-400")}),$&&(0,u.jsx)("button",{type:"button",onClick:Bt,className:"ml-2 rounded-full p-1 ".concat(A?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-500"),"aria-label":"Clear search",children:(0,u.jsx)(Pu,{size:14})})]}),Z.length>0&&(0,u.jsxs)("div",{className:"mt-3 flex items-center justify-between text-xs ".concat(A?"text-gray-400":"text-gray-600"),children:[(0,u.jsxs)("span",{children:[te+1," of ",Z.length," matches"]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("button",{type:"button",onClick:()=>{const e=te>0?te-1:Z.length-1;ne(e),he(!0)},className:"rounded-full p-2 ".concat(A?"bg-gray-800 text-gray-300":"bg-[#eef1f3] text-[#4a586e]"),disabled:0===Z.length,"aria-label":"Previous match",children:(0,u.jsx)(dk,{size:14})}),(0,u.jsx)("button",{type:"button",onClick:()=>{const e=te<Z.length-1?te+1:0;ne(e),he(!0)},className:"rounded-full p-2 ".concat(A?"bg-gray-800 text-gray-300":"bg-[#eef1f3] text-[#4a586e]"),disabled:0===Z.length,"aria-label":"Next match",children:(0,u.jsx)(bp,{size:14})})]})]})]}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-4 ".concat(A?"bg-[#111826]":"bg-[#f4f4f4]"),"data-allow-touch-scroll":"true",children:$.trim()?0===Z.length?(0,u.jsxs)("div",{className:"rounded-2xl border px-4 py-5 text-sm ".concat(A?"border-gray-700 bg-[#16202c] text-gray-400":"border-gray-200 bg-white text-gray-600"),children:['No matches found for "',$,'".']}):(0,u.jsx)("div",{className:"space-y-3",children:Z.map((e,t)=>{var n;return(0,u.jsxs)("button",{type:"button",onClick:()=>{ne(t),he(!0),re(!1)},className:"w-full rounded-2xl border px-4 py-3 text-left transition-colors ".concat(t===te?A?"border-[#ffcf74]/60 bg-[#1f2a3b] text-white":"border-[#ffb52b]/70 bg-[#fff6dd] text-[#232E3F]":A?"border-gray-700 bg-[#16202c] text-white":"border-gray-200 bg-white text-[#232E3F]"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs ".concat(A?"text-gray-400":"text-gray-500"),children:[(0,u.jsx)("span",{className:"truncate",children:e.speaker||"Speaker"}),(0,u.jsx)("span",{className:"shrink-0",children:e.timestamp})]}),(0,u.jsx)("div",{className:"mt-2 text-sm font-semibold ".concat(A?"text-white":"text-[#232E3F]"),children:null!==(n=e.topic)&&void 0!==n&&n.title?String(e.topic.title).replace(/<[^>]+>/g,"").trim():"Transcript result"}),(0,u.jsxs)("div",{className:"mt-2 text-sm leading-6 ".concat(A?"text-gray-300":"text-[#4a586e]"),children:[e.contextStart>0&&(0,u.jsx)("span",{className:"opacity-60",children:"..."}),e.contextText.substring(0,e.matchIndex),(0,u.jsx)("span",{className:"rounded px-1 py-0.5 font-semibold ".concat(A?"bg-[#ffcf74]/20 text-[#ffe09b]":"bg-[#ffe2a6] text-[#6e4d0e]"),children:e.contextText.substring(e.matchIndex,e.matchIndex+e.matchLength)}),e.contextText.substring(e.matchIndex+e.matchLength),e.contextStart+e.contextText.length<e.text.length&&(0,u.jsx)("span",{className:"opacity-60",children:"..."})]})]},"".concat(e.groupIndex,"-").concat(e.segmentIndex,"-").concat(t))})}):(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-5 text-sm ".concat(A?"border-gray-700 bg-[#16202c] text-gray-400":"border-gray-200 bg-white text-gray-600"),children:"Enter a query to search the transcript."})})]}),Qt?(0,u.jsx)("div",{className:"flex h-full items-center justify-center px-6",children:(0,u.jsxs)("div",{className:"flex max-w-md items-center gap-3 rounded-2xl border px-5 py-4 shadow-sm ".concat(A?"border-[#39465A] bg-[#182130]/90 text-[#E7ECF2]":"border-[#D8DEE7] bg-white text-[#232E3F]"),children:[(0,u.jsx)(Lo,{className:"h-5 w-5 animate-spin text-brand-yellow"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-sm font-semibold",children:"Loading transcript view"}),(0,u.jsx)("div",{className:"mt-1 text-xs ".concat(A?"text-[#A7B2C4]":"text-[#66758A]"),children:"Preparing transcript revisions and topic metadata before rendering."})]})]})}):Jt&&(0,u.jsxs)(u.Fragment,{children:[!z&&I&&(0,u.jsx)("div",{className:"flex items-center justify-end px-4 pt-4 ".concat(X||Se?"pb-2":""),children:gt?(0,u.jsxs)("div",{className:"inline-flex items-center rounded-full border p-1 ".concat(A?"border-white/10 bg-white/[0.06]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.68)]"),children:[(0,u.jsx)("button",{type:"button",onClick:()=>Oe("selected"),className:"rounded-full px-3 py-1.5 text-xs font-semibold transition-colors ".concat("selected"===ze?A?"bg-white/[0.14] text-white":"bg-[#232E3F] text-white":A?"text-gray-300 hover:bg-white/[0.08]":"text-gray-600 hover:bg-[rgba(35,46,63,0.06)]"),children:"Readable"}),(0,u.jsxs)("button",{type:"button",onClick:()=>{qt()},disabled:Ge,className:"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-xs font-semibold transition-colors disabled:opacity-60 ".concat("hesitation"===ze?A?"bg-[#ffcf74]/16 text-[#ffe09b]":"bg-[#fff2cf] text-[#8a6400]":A?"text-gray-300 hover:bg-white/[0.08]":"text-gray-600 hover:bg-[rgba(35,46,63,0.06)]"),title:"Show the hesitation-preserving transcript",children:[Ge&&(0,u.jsx)(Lo,{size:12,className:"animate-spin"}),(0,u.jsx)("span",{children:"Hesitation"})]})]}):(0,u.jsxs)("button",{type:"button",onClick:()=>{Wt()},disabled:Xe,className:"inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-xs font-semibold transition-colors disabled:opacity-60 ".concat(A?"border-white/10 bg-white/[0.06] text-gray-200 hover:bg-white/[0.10]":"border-[rgba(215,222,233,0.82)] bg-[rgba(255,255,255,0.68)] text-gray-700 hover:bg-white"),title:"Generate the hesitation-preserving transcript for precision editing",children:[Xe?(0,u.jsx)(Lo,{size:12,className:"animate-spin"}):(0,u.jsx)(yp,{size:12}),(0,u.jsx)("span",{children:"Generate Hesitation Transcript"})]})}),(0,u.jsx)(pM,{ttmlContent:H||"",transcript:Kt,filename:W||p,transcriptionData:Gt,speakerLabels:x,speakerSegments:f,sessionVisuals:b,transcriptionChecksum:c,sessionId:l||void 0,isModal:!1,onPlaySegment:async(e,t)=>{B(e),await M(e,t)},onPauseSegment:()=>{T()},showChat:!1,comments:v,isFullscreenTab:X,selectedTtmlId:w,searchQuery:$,searchMatches:Z,currentMatchIndex:te,shouldNavigateToMatch:me,onNavigationComplete:()=>he(!1),onSearchUpdate:Ft,onCurrentTopicChange:C,onTtmlRevisionCreated:N,showVideoPanel:F,typographyConfig:Me,transcriptChromeCollapsed:Se,onTranscriptChromeCollapsedChange:Ee})]})]}),(0,u.jsx)(jM,{isOpen:se,onClose:()=>ie(!1),transcript:h,filename:p,speakerLabels:x}),$e&&Ze&&(0,u.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>Qe(!1)}),(0,u.jsxs)("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-hidden flex flex-col",children:[(0,u.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[(0,u.jsx)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Revision Notes"}),(0,u.jsx)("button",{onClick:()=>Qe(!1),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700",children:(0,u.jsx)(Pu,{size:20,className:"text-gray-500"})})]}),(0,u.jsx)("div",{className:"p-4 overflow-y-auto flex-1",children:(0,u.jsx)("pre",{className:"whitespace-pre-wrap text-sm text-gray-700 dark:text-gray-300 font-mono",children:Ze})})]})]}),tt&&at&&(0,u.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>nt(!1)}),(0,u.jsxs)("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-6xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col",children:[(0,u.jsxs)("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[(0,u.jsxs)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:["Changes in This Revision (",at.edits.length," edits)"]}),(0,u.jsx)("button",{onClick:()=>nt(!1),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700",children:(0,u.jsx)(Pu,{size:20,className:"text-gray-500"})})]}),0===at.edits.length?(0,u.jsx)("div",{className:"p-8 text-center",children:(0,u.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:"No changes recorded in this revision."})}):(0,u.jsxs)("div",{className:"flex-1 overflow-hidden flex",children:[(0,u.jsxs)("div",{className:"w-1/2 border-r border-gray-200 dark:border-gray-700 flex flex-col",children:[(0,u.jsx)("div",{className:"px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:(0,u.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"Changes"})}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:at.edits.map((e,t)=>(0,u.jsxs)("div",{className:"p-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,u.jsxs)("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["#",t+1," \u2022 ",bt(e.timeRange.startTime)]}),(0,u.jsx)("span",{className:"text-xs px-2 py-0.5 rounded ".concat("replace"===e.type?"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300":"insert"===e.type?"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-900 dark:text-red-300"),children:e.type})]}),(0,u.jsxs)("div",{className:"space-y-1.5",children:[(0,u.jsxs)("div",{className:"flex items-start gap-2",children:[(0,u.jsx)("span",{className:"text-xs text-red-500 font-medium shrink-0 mt-0.5",children:"\u2212"}),(0,u.jsx)("span",{className:"text-sm text-red-600 dark:text-red-400 line-through",children:e.original.text})]}),e.replacement&&(0,u.jsxs)("div",{className:"flex items-start gap-2",children:[(0,u.jsx)("span",{className:"text-xs text-green-500 font-medium shrink-0 mt-0.5",children:"+"}),(0,u.jsx)("span",{className:"text-sm text-green-600 dark:text-green-400",children:e.replacement.text})]})]})]},e.id))})]}),(0,u.jsxs)("div",{className:"w-1/2 flex flex-col",children:[(0,u.jsx)("div",{className:"px-4 py-2 bg-gray-50 dark:bg-gray-900 border-b border-gray-200 dark:border-gray-700",children:(0,u.jsx)("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"Reasons"})}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:at.edits.map((e,t)=>{var n,a;return(0,u.jsxs)("div",{className:"p-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:[(0,u.jsx)("div",{className:"mb-2",children:(0,u.jsxs)("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["#",t+1," \u2022 ",e.original.text.substring(0,30),e.original.text.length>30?"...":""," \u2192 ",null===(n=e.replacement)||void 0===n?void 0:n.text.substring(0,30),((null===(a=e.replacement)||void 0===a?void 0:a.text.length)||0)>30?"...":""]})}),e.reason?(0,u.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300 prose prose-sm dark:prose-invert max-w-none",children:(0,u.jsx)(my,{children:e.reason})}):(0,u.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 italic",children:"No reason provided"})]},e.id)})})]})]})]})]}),I&&(0,u.jsx)(lO,{isOpen:oe,onClose:()=>le(!1),sessionId:l||"",speakerLabels:x||{},gapAnalysisData:S,ttmlFiles:o,selectedTtmlId:w,transcriptSource:ze,hesitationTranscriptAvailable:!!gt,onFilteredClustersChange:E})]})]})},fO=Mo("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]),bO=(e,t)=>{const n=e.replace("#","");if(6!==n.length)return"rgba(255, 181, 43, ".concat(t,")");const a=parseInt(n.slice(0,2),16),r=parseInt(n.slice(2,4),16),s=parseInt(n.slice(4,6),16);return"rgba(".concat(a,", ").concat(r,", ").concat(s,", ").concat(t,")")},yO=(e,t)=>
2{if(!e||"object"!==typeof e)return null;const n=(e=>{if(!e||"object"!==typeof e)return 0;let t=0;return Object.values(e).forEach(e=>{e&&"object"===typeof e&&((Array.isArray(e.spans)?e.spans:[]).forEach(e=>{"number"===typeof(null===e||void 0===e?void 0:e.end)&&(t=Math.max(t,e.end))}),(e.topics&&"object"===typeof e.topics?Object.values(e.topics):[]).forEach(e=>{(Array.isArray(null===e||void 0===e?void 0:e.spans)?e.spans:[]).forEach(e=>{"number"===typeof(null===e||void 0===e?void 0:e.end)&&(t=Math.max(t,e.end))})}))}),t})(e),a=(t>0?n>1.5*t:n>360)?1/60:1;return Object.fromEntries(Object.entries(e).map(e=>{let[t,n]=e;const r=Array.isArray(null===n||void 0===n?void 0:n.spans)?n.spans:[],s=null!==n&&void 0!==n&&n.topics&&"object"===typeof n.topics?n.topics:{};return[t,{color:(null===n||void 0===n?void 0:n.color)||"#6366f1",spans:r.map(e=>d(d({},e),{},{start:"number"===typeof(null===e||void 0===e?void 0:e.start)?e.start*a:null===e||void 0===e?void 0:e.start,end:"number"===typeof(null===e||void 0===e?void 0:e.end)?e.end*a:null===e||void 0===e?void 0:e.end})),topics:Object.fromEntries(Object.entries(s).map(e=>{let[t,n]=e;return[t,{spans:(Array.isArray(null===n||void 0===n?void 0:n.spans)?n.spans:[]).map(e=>d(d({},e),{},{start:"number"===typeof(null===e||void 0===e?void 0:e.start)?e.start*a:null===e||void 0===e?void 0:e.start,end:"number"===typeof(null===e||void 0===e?void 0:e.end)?e.end*a:null===e||void 0===e?void 0:e.end}))}]}))}]}))},vO=e=>{var t;let{sessionId:n,transcript:r,ttml:s,maxDuration:i,title:o="Narrative Timeline",className:l="",shareToken:c,model:m="",onModelChange:h,supportedModels:p=[],youtubeUrl:g}=e;zw("[NarrativeTimeline] Props:",{sessionId:n,hasTranscript:!!r,transcriptLength:(null===r||void 0===r?void 0:r.length)||0,hasTtml:!!s,ttmlLength:(null===s||void 0===s?void 0:s.length)||0,maxDuration:i,shareToken:!!c});const[x,f]=(0,a.useState)({}),[b,y]=(0,a.useState)("topics"),[v,w]=(0,a.useState)(null),[k,j]=(0,a.useState)(!1),[D,C]=(0,a.useState)(null),[N,F]=(0,a.useState)("idle"),[S,E]=(0,a.useState)(""),[A,T]=(0,a.useState)([]),[M,_]=(0,a.useState)(null),B=(0,a.useRef)(null),[I,P]=(0,a.useState)(0),[L,R]=(0,a.useState)(20),[z,O]=(0,a.useState)(!1),[U,V]=(0,a.useState)(!0),[H,q]=(0,a.useState)(!1),W=(0,a.useRef)(0),Y=(0,a.useRef)(0),G=(0,a.useRef)(null),K=(0,a.useRef)(null),X=(0,a.useRef)(null),{currentTime:J,seekTo:$,duration:Q}=Jw(),{token:Z}=am(),ee=!1,te=!1,ne=null,ae=Boolean(h&&p.length>0),re=!c&&ae,se=(0,a.useMemo)(()=>(e=>{try{const t=(new DOMParser).parseFromString(e,"application/xml");let n=t.querySelectorAll('div[region="r_summary"] p');if(0===n.length){const e=t.querySelector('div[xml\\:id="d_summary"], div[id="d_summary"]');e&&(n=e.querySelectorAll("p"))}const a=[];return n.forEach((e,t)=>{const n=e.getAttribute("begin")||"",r=e.getAttribute("end")||"",s=e.innerHTML,i=document.createElement("div");i.innerHTML=s;const o=i.textContent||"",l=s.match(/\[(\d+):\s*(\d+|\?)\/(\d+)\]\s*(?:&gt;&gt;|>>|>>)\s*\[([^\]]+)\]/)||o.match(/\[(\d+):\s*(\d+|\?)\/(\d+)\]\s*>>\s*\[([^\]]+)\]/),c=l?null:s.match(/\[(\d+)\/(\d+)\]\s*(?:&gt;&gt;|>>|>>)\s*\[([^\]]+)\]/)||o.match(/\[(\d+)\/(\d+)\]\s*>>\s*\[([^\]]+)\]/);if(l||c){const e=l?parseInt(l[1],10):t+1,s=(l?parseInt(l[2],10):parseInt(c[1],10),l?parseInt(l[3],10):parseInt(c[2],10),l?l[4].trim():c[3].trim()),i=o.match(/Score:\s*\[(\d+)\/(\d+)\]/)||o.match(/Score:\s*(\d+)\/(\d+)/),d=i?parseInt(i[1],10):5,u=i?parseInt(i[2],10):10,m=e=>{const t=e.split(/[:.]/);return t.length<3?0:60*parseInt(t[0])+parseInt(t[1])+parseInt(t[2])/60};a.push({start:m(n),end:m(r),segmentNumber:e,rank:d,total:u,title:s})}}),a.sort((e,t)=>e.start-t.start)}catch(D){return console.error("Error parsing TTML topics:",D),[]}})(s),[s]),ie=(0,a.useMemo)(()=>se,[se,ee,ne,te]),oe=(0,a.useMemo)(()=>Q>0?Q:60*i,[ee,te,ne,Q,i]),le=(0,a.useMemo)(()=>v||null,[v,ee,ne,te]),ce=(0,a.useMemo)(()=>{if(!le)return[];const e=e=>{const t=[...e.spans.map(e=>e.start),...Object.values(e.topics).flatMap(e=>e.spans.map(e=>e.start))].filter(e=>"number"===typeof e&&e>=0);return t.length>0?Math.min(...t):1/0};return Object.entries(le).map(e=>{let[t,n]=e;return[t,d(d({},n),{},{spans:[...n.spans].sort((e,t)=>
2e.start-t.start)})]}).sort((t,n)=>{let[,a]=t,[,r]=n;return e(a)-e(r)})},[le]);(0,a.useEffect)(()=>{if(Q>0){P(J/Q*100)}},[J,Q]),(0,a.useEffect)(()=>{if(v){const e={};Object.keys(v).forEach((t,n)=>{e[n]=!0}),f(e)}},[v]),(0,a.useEffect)(()=>()=>{var e;null===(e=X.current)||void 0===e||e.close(),X.current=null},[]),(0,a.useEffect)(()=>{n&&(de(),ue(),me())},[n,c,Z]),(0,a.useEffect)(()=>{if(!n)return;const e=e=>{const t=e.detail||{};t.sessionId&&t.sessionId!==n||(de(),ue())},t=e=>{const t=e.detail||{};if(t.sessionId!==n)return;const a=Array.isArray(t.scopes)?t.scopes:[];(0===a.length||a.includes("narrative")||a.includes("ttml")||a.includes("session"))&&(de(),ue())};return window.addEventListener("rescript-session-refresh-needed",e),window.addEventListener("rescript-session-invalidated",t),()=>{window.removeEventListener("rescript-session-refresh-needed",e),window.removeEventListener("rescript-session-invalidated",t)}},[n,c,Z]);const de=async()=>{if(n)try{const e=await Vm.getNarrativeData(n,c||Z||void 0);e&&w(yO(e,i))}catch(e){console.error("Error loading cached narrative data:",e)}},ue=async()=>{if(n){if(c)return T([]),void _(null);try{const e=await Vm.getNarrativeVersions(n,Z||void 0);if(e&&e.versions){T(e.versions);const t=e.versions.find(e=>1===e.is_active);t&&_(t.id)}}catch(e){console.error("Error loading narrative versions:",e)}}},me=async()=>{if(n)try{const e=await Vm.getNarrativeGenerationStatus(n,c||Z||void 0),t=(e=>{switch((e||"").toLowerCase()){case"pending":case"queued":case"running":case"generating":return"generating";case"completed":case"complete":return"completed";case"failed":case"error":return"error";default:return"idle"}})(e.status);if(F(t),"generating"===t)return C(null),void(X.current||E(e=>e||"Topic map generation is running on the server..."));if(E(""),"error"===t)return void C(e.error||"Topic map generation failed");C(null),"completed"===t&&(de(),ue())}catch(e){console.error("Error checking topic map generation status:",e)}};(0,a.useEffect)(()=>{if(!n||"generating"!==N||X.current)return;const e=window.setInterval(()=>{me()},5e3);return()=>{window.clearInterval(e)}},[N,n,c,Z]);const he=async()=>{C(null);try{var e;if(!r||0===r.trim().length)throw new Error("Transcript is required to generate a topic map");if(!s||0===s.trim().length)throw new Error("A metadata revision is required to generate a topic map. Please select a metadata revision in the Ranking and Metadata tab first.");zw("[NARRATIVE] Starting agent-based generation"),null===(e=X.current)||void 0===e||e.close(),X.current=null;const t=await Xh({sessionId:n,model:m},Z||void 0);if(zw("[NARRATIVE] Agent generation started:",t),!t.success)throw new Error("Failed to start topic map generation");F("generating"),E("Starting agent...");const a=Hh(t.agentSessionId,e=>{if("text_delta"!==e.type&&"text"!==e.type)if("status"!==e.type){if("tool_start"!==e.type)return"done"===e.type||"complete"===e.type?(a.close(),X.current===a&&(X.current=null),E(""),F("completed"),window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:n,scopes:["narrative"]}})),de(),void ue()):void("error"===e.type&&(a.close(),X.current===a&&(X.current=null),E(""),F("error"),C(e.message||"Topic map generation failed")));E("Calling ".concat(e.toolName||e.tool||"tool","..."))}else E(e.message||"Working...");else E(e.content||e.message||"Working...")},()=>{a.close(),X.current===a&&(X.current=null),E(""),F("error"),C("Topic map generation stream disconnected")},Z||void 0);X.current=a}catch(t){console.error("Error starting narrative generation:",t),C(t instanceof Error?t.message:"Failed to generate topic map"),F("error"),E("")}},pe={context:{bg:"#6366f1",opacity:.3},introduce:{bg:"#6366f1",opacity:.4},reference:{bg:"#6366f1",opacity:.5},continuation:{bg:"#6366f1",opacity:.6},"deep-dive":{bg:"#6366f1",opacity:.8},summary:{bg:"#6366f1",opacity:.7},backref:{bg:"#ef4444",opacity:.7}};(0,a.useEffect)(()=>{const e=e=>{if(!z)return;const t=e.clientX-W.current,n=Y.current+t;R(Math.max(0,Math.min(window.innerWidth-300,n)))},t=()=>{O(!1)};if(z)return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t)}},[z]),(0,a.useEffect)(()=>{const e=G.current,t=K.current;if(!e||!t)return;let n=!1;const a=(e,t)=>{if(n)return;n=!0;const a=e.scrollTop/(e.scrollHeight-e.clientHeight);t.scrollTop=a*(t.scrollHeight-t.clientHeight),setTimeout(()=>{n=!1},10)},r=()=>a(e,t),s=()=>a(t,e);return e.addEventListener("scroll",r),t.addEventListener("scroll",s),()=>{e.removeEventListener("scroll",r),t.removeEventListener("scroll",s)}},[]);const ge=e=>"".concat(60*e/oe*100,"%"),xe=e=>{$(60*e)},fe=(0,a.useMemo)(()=>{const e=oe/60,t=e>120?30:e>60?15:e>30?10:5,n=[];for(let a=0;a<=e;a+=t)n.push(a);return n},[oe]),be=e=>
2{const t=60*e,n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=Math.floor(t%60),s=Math.round(t%1*1e3);return"".concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"),".").concat(s.toString().padStart(3,"0"))},ye=(0,a.useMemo)(()=>{if(!le)return{themes:0,topics:0};return{themes:Object.keys(le).length,topics:Object.values(le).reduce((e,t)=>e+Object.keys(t.topics||{}).length,0)}},[le]);return v?(0,u.jsxs)("div",{className:"relative h-full overflow-hidden rounded-[28px] border border-[#d7dee9] bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_20%,rgba(111,137,182,0.07),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.56),rgba(255,255,255,0.42))] text-gray-900 shadow-[0_32px_80px_-44px_rgba(35,46,63,0.34)] backdrop-blur-[28px] dark:border-white/10 dark:bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.1),transparent_24%),radial-gradient(circle_at_84%_20%,rgba(111,137,182,0.1),transparent_22%),linear-gradient(180deg,rgba(17,27,42,0.46),rgba(17,27,42,0.36))] dark:text-gray-100 ".concat(l),children:[(0,u.jsx)("svg",{width:"0",height:"0",className:"absolute",children:(0,u.jsx)("defs",{children:ce.map((e,t)=>{let[n,a]=e;return(0,u.jsxs)("pattern",{id:"stripes-".concat(t),patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[(0,u.jsx)("rect",{width:"8",height:"8",fill:a.color,fillOpacity:"0.3"}),(0,u.jsx)("path",{d:"M0,8 L8,0",stroke:a.color,strokeWidth:"1",opacity:"0.6"})]},n)})})}),(0,u.jsxs)("div",{className:"relative overflow-y-auto overflow-x-auto h-full",ref:K,children:[(0,u.jsxs)("div",{className:"mb-6 px-6 pt-6",children:[re&&(0,u.jsx)("div",{className:"flex justify-center gap-4 mb-4",children:ae&&(0,u.jsx)("div",{className:"w-full max-w-xs",children:(0,u.jsx)("select",{value:m,onChange:e=>null===h||void 0===h?void 0:h(e.target.value),className:"w-full px-3 py-2 border border-[#cfd5df] dark:border-[#40506a] bg-white dark:bg-[#131a25] text-gray-900 dark:text-gray-100 rounded-lg focus:ring-2 focus:ring-[#ffcf74] focus:border-transparent text-sm",children:p.map(e=>(0,u.jsx)("option",{value:e,children:e},e))})})}),"generating"===N&&(0,u.jsxs)("div",{className:"text-center mb-4",children:[(0,u.jsx)("p",{className:"text-sm text-[#8a6115] dark:text-[#ffcf74]",children:"Topic map generation is running on the server."}),S&&(0,u.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:S})]}),(0,u.jsxs)("div",{className:"flex justify-center gap-2 mb-4",children:[(0,u.jsx)("button",{onClick:()=>y("themes"===b?"topics":"themes"),className:"rounded-full border border-[rgba(215,222,233,0.78)] bg-[rgba(255,255,255,0.34)] px-4 py-2 text-sm text-gray-700 backdrop-blur-[20px] transition-colors hover:bg-[rgba(255,255,255,0.48)] dark:border-white/10 dark:bg-[rgba(255,255,255,0.06)] dark:text-gray-300 dark:hover:bg-[rgba(255,255,255,0.1)]",children:"themes"===b?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(wp,{className:"w-4 h-4 inline mr-2"}),"Show Topics"]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ck,{className:"w-4 h-4 inline mr-2"}),"Themes Only"]})}),(0,u.jsxs)("div",{className:"inline-flex items-center rounded-full border border-[rgba(215,222,233,0.74)] bg-[rgba(255,255,255,0.3)] px-3 py-2 text-xs font-medium text-gray-600 backdrop-blur-[20px] dark:border-white/10 dark:bg-[rgba(255,255,255,0.05)] dark:text-gray-300",children:[ye.themes," themes \xb7 ",ye.topics," topics"]}),!c&&(0,u.jsxs)("button",{onClick:()=>{const e=(()=>{if(!v)return"";const e=Object.entries(v),t=e.length,n=Math.floor(90/(t+1)),a=[];e.forEach(e=>{let[t,n]=e;Object.entries(n.topics).forEach(e=>{let[r,s]=e;s.spans.forEach(e=>{a.push(d(d({},e),{},{themeName:t,topicName:r,themeColor:n.color}))})})});const r={"deep-dive":5,summary:4,continuation:3,reference:2,introduce:1,context:0,backref:0};a.sort((e,t)=>e.start!==t.start?e.start-t.start:(r[t.type]||0)-(r[e.type]||0));const s=[];return a.forEach(e=>{s.some(t=>e.start>=t.start&&e.start<t.end||e.end>t.start&&e.end<=t.end||e.start<=t.start&&e.end>=t.end)||s.push(e)}),'<?xml version="1.0" encoding="UTF-8"?>\n<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:ttm="http://www.w3.org/ns/ttml#metadata" xmlns:tts="http://www.w3.org/ns/ttml#styling" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" xmlns:ittp="http://www.w3.org/ns/ttml/profile/imsc1#parameter" xmlns:itts="http://www.w3.org/ns/ttml/profile/imsc1#styling" ttp:profile="http://www.w3.org/ns/ttml/profile/imsc1/text" ttp:frameRate="24" ttp:frameRateMultiplier="1000 1001" ttp:dropMode="nonDrop" ttp:timeBase="media">\n <head>\n <styling>\n '.concat(e.map((t,n)=>{let[a]=t;return'<style xml:id="style_theme_'.concat(n,'" tts:color="#ffffff" tts:opacity="1" tts:fontSize="100%" tts:fontFamily="proportionalSansSerif" tts:textAlign="center" tts:backgroundColor="').
2concat(e[n][1].color,'" tts:showBackground="whenActive"/>')}).join("\n "),'\n <style xml:id="style_details" tts:color="#ffffff" tts:opacity="1" tts:fontSize="90%" tts:fontFamily="proportionalSansSerif" tts:fontWeight="bold" tts:textOutline="#000000 2px" tts:textAlign="start"/>\n </styling>\n <layout>\n ').concat(e.map((e,t)=>{let[a]=e;return'<region xml:id="r_theme_'.concat(t,'" tts:origin="5% ').concat(5+t*n,'%" tts:extent="90% ').concat(n-2,'%" tts:displayAlign="center" tts:backgroundColor="#000000" tts:opacity="0.60" tts:showBackground="whenActive"/>')}).join("\n "),'\n <region xml:id="r_details" tts:origin="5% ').concat(5+t*n,'%" tts:extent="90% ').concat(n-2,'%" tts:displayAlign="before" tts:backgroundColor="#000000" tts:opacity="0.70" tts:showBackground="whenActive"/>\n </layout>\n </head>\n <body>\n ').concat(e.map((e,t)=>{let[n,a]=e;return'\n <div xml:id="d_theme_'.concat(t,'" region="r_theme_').concat(t,'" style="style_theme_').concat(t,'">\n ').concat(a.spans.map((e,t)=>'<p begin="'.concat(be(e.start),'" end="').concat(be(e.end),'">').concat(n,"<br/>").concat(e.label||"","<br/>Intensity: ").concat(e.intensity,"/3</p>")).join("\n "),"\n </div>")}).join("\n "),'\n \n <div xml:id="d_details" region="r_details" style="style_details">\n ').concat(s.map((e,t)=>'<p begin="'.concat(be(e.start),'" end="').concat(be(e.end),'">[').concat(e.themeName,"] ").concat(e.topicName,"<br/>Type: ").concat(e.type).concat("backref"===e.type?" (reference)":"","</p>")).join("\n "),"\n </div>\n </body>\n</tt>")})();if(!e)return;const t=new Blob([e],{type:"application/ttml+xml"}),a=URL.createObjectURL(t),r=document.createElement("a");r.href=a,r.download="narrative_timeline_".concat(n,".ttml"),document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)},disabled:!v,className:"ml-2 rounded-full border border-[rgba(215,222,233,0.78)] bg-[rgba(255,255,255,0.34)] px-4 py-2 text-sm text-gray-700 backdrop-blur-[20px] transition-colors hover:bg-[rgba(255,255,255,0.48)] disabled:cursor-not-allowed disabled:opacity-50 dark:border-white/10 dark:bg-[rgba(255,255,255,0.06)] dark:text-gray-300 dark:hover:bg-[rgba(255,255,255,0.1)]",children:[(0,u.jsx)(Sp,{className:"w-4 h-4 inline mr-2"}),"Download TTML"]}),!c&&(0,u.jsx)("button",{onClick:he,disabled:"generating"===N,className:"ml-2 px-4 py-2 rounded text-sm transition-all flex items-center inline-flex ".concat("generating"===N?"bg-[#FFB52B] text-[#232E3F] animate-pulse":"rounded-full border border-[rgba(215,222,233,0.78)] bg-[rgba(255,255,255,0.34)] text-gray-700 backdrop-blur-[20px] hover:bg-[rgba(255,255,255,0.48)] dark:border-white/10 dark:bg-[rgba(255,255,255,0.06)] dark:text-gray-300 dark:hover:bg-[rgba(255,255,255,0.1)]"," disabled:cursor-not-allowed"),children:"generating"===N?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"relative mr-2",children:[(0,u.jsx)(Lo,{className:"w-4 h-4 animate-spin"}),(0,u.jsx)("div",{className:"absolute inset-0 w-4 h-4 animate-ping",children:(0,u.jsx)(Lo,{className:"w-4 h-4 opacity-30"})})]}),"Generating topic map..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(fO,{className:"w-4 h-4 mr-2"}),"Regenerate Topic Map"]})})]}),A.length>0&&(0,u.jsxs)("div",{className:"flex justify-center items-center gap-2 mb-4",children:[(0,u.jsx)("div",{className:"flex items-center gap-1",children:A.map((e,t)=>(0,u.jsx)("button",{onClick:()=>(async e=>{try{j(!0),await Vm.activateNarrativeVersion(n,e,Z||void 0),await de(),await ue(),j(!1)}catch(t){console.error("Error switching narrative version:",t),C("Failed to switch version"),j(!1)}})(e.id),disabled:k,className:"w-2.5 h-2.5 rounded-full transition-all ".concat(e.id===M?"bg-[#FFB52B] w-3 h-3":"bg-gray-300 dark:bg-gray-600 hover:bg-gray-400 dark:hover:bg-gray-500"," disabled:opacity-50"),title:"Version ".concat(e.version_number," - ").concat(new Date(e.created_at).toLocaleString()," by ").concat(e.created_by)},e.id))}),(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400 ml-2",children:["v",(null===(t=A.find(e=>
2e.id===M))||void 0===t?void 0:t.version_number)||"?"]})]})]}),(0,u.jsx)("div",{className:"flex",children:(0,u.jsx)("div",{className:"w-full overflow-x-hidden",children:(0,u.jsxs)("div",{className:"relative px-0",ref:B,children:[(0,u.jsxs)("div",{className:"h-24 relative border-b border-gray-300 dark:border-gray-700 mb-4",children:[fe.map(e=>(0,u.jsxs)("div",{className:"absolute",style:{left:ge(e)},children:[(0,u.jsx)("div",{className:"w-px h-3 bg-gray-400 dark:bg-gray-500"}),(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400 absolute -translate-x-1/2 top-4",children:[e,"m"]})]},e)),ie.map((e,t)=>{const n=e.rank/e.total,a=n>=.7?"#10b981":n>=.4?"#f59e0b":"#ef4444";return(0,u.jsxs)("div",{className:"absolute top-8 bottom-0",style:{left:ge(e.start)},children:[(0,u.jsx)("div",{className:"absolute w-px h-full border-l border-dotted",style:{borderColor:a,opacity:.3}}),(0,u.jsx)("div",{className:"absolute -top-2 -translate-x-1/2 text-xs font-medium",style:{color:a},children:e.segmentNumber})]},t)})]}),Q>0&&(0,u.jsx)("div",{className:"absolute top-0 bottom-0 w-0.5 bg-red-500 z-10 pointer-events-none",style:{left:"".concat(I,"%")},children:(0,u.jsx)("div",{className:"absolute -top-1 left-1/2 -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-l-transparent border-r-transparent border-t-red-500"})}),(0,u.jsx)("div",{className:"absolute inset-0 pointer-events-none",style:{opacity:.2},children:ie.map((e,t)=>{const n=parseFloat(ge(e.end))-parseFloat(ge(e.start)),a=e.rank/e.total,r=a>=.7?"#10b981":a>=.4?"#f59e0b":"#ef4444";return(0,u.jsx)("div",{className:"absolute top-0 bottom-0",style:{left:ge(e.start),width:"".concat(n,"%"),background:"radial-gradient(circle_at_12%_18%, ".concat(bO(r,.22),", transparent 26%), radial-gradient(circle_at_84%_20%, rgba(255,181,43,0.12), transparent 24%), radial-gradient(circle_at_56%_82%, ").concat(bO(r,.14),", transparent 34%), linear-gradient(180deg, ").concat(bO(r,.1),", ").concat(bO(r,.03),")")}},t)})}),ce.map((e,t)=>{let[n,a]=e;return(0,u.jsxs)("div",{className:"mb-6 relative",children:[a.spans.length>0&&(()=>{const e=a.spans[0],t=e.start/i*100>80;return(0,u.jsx)("div",{className:"absolute text-sm font-semibold whitespace-nowrap dark:[text-shadow:0_0_3px_rgba(0,0,0,0.8),0_0_6px_rgba(0,0,0,0.5)]",style:{left:t?"calc(100% - 10px)":ge(e.start),top:"-20px",color:a.color,textAlign:t?"right":"left",transform:t?"translateX(-100%)":"none"},children:n})})(),(0,u.jsxs)("div",{className:"relative mb-2",style:{height:"48px"},children:[" ",a.spans.filter(e=>e&&"number"===typeof e.start&&"number"===typeof e.end&&e.start>=0&&e.end>e.start).map((e,n)=>(0,u.jsxs)("div",{className:"absolute cursor-pointer",style:{left:ge(e.start),width:"".concat(parseFloat(ge(e.end))-parseFloat(ge(e.start)),"%")},onClick:()=>xe(e.start),children:[(0,u.jsx)("svg",{className:"absolute",style:{width:"100%",height:"32px",top:"8px",opacity:.4+.3*e.intensity},children:(0,u.jsx)("rect",{width:"100%",height:"32",fill:"url(#stripes-".concat(t,")"),stroke:a.color,strokeWidth:"2",rx:"4",className:"hover:opacity-100 transition-opacity"})}),(0,u.jsx)("div",{className:"absolute text-xs font-medium px-2 py-0.5 rounded shadow-sm",style:{backgroundColor:a.color,color:"#ffffff",top:"0",left:"0",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",zIndex:n===a.spans.length-1||n<a.spans.length-1&&e.end+5<a.spans[n+1].start?3:1},title:e.label,children:e.label})]},n))]}),"themes"!==b&&x[t]&&(0,u.jsx)("div",{className:"relative",children:Object.entries(a.topics).sort((e,t)=>{let[,n]=e,[,a]=t;return(n.spans.length>0?Math.min(...n.spans.map(e=>e.start)):1/0)-(a.spans.length>0?Math.min(...a.spans.map(e=>e.start)):1/0)}).map(e=>{let[t,n]=e;return(0,u.jsxs)("div",{className:"h-6 relative",children:[(0,u.jsx)("div",{className:"absolute left-6 right-0 h-px border-b border-dotted border-gray-300 dark:border-gray-700",style:{to
2p:"50%"}}),n.spans.filter(e=>e&&"number"===typeof e.start&&"number"===typeof e.end&&e.start>=0&&e.end>e.start).map((e,a)=>{const r="backref"===e.type,s=parseFloat(ge(e.start)),i=parseFloat(ge(e.end))-s,o=pe[e.type]||{bg:"#9ca3af"};n.spans.length;return(0,u.jsx)("div",{className:"absolute h-4 rounded transition-opacity hover:opacity-100 cursor-pointer group",style:{left:ge(e.start),width:"".concat(i,"%"),backgroundColor:o.bg,opacity:o.opacity,top:"0.25rem",border:o.border||"none"},title:(()=>{if(r&&void 0!==e.linkedTo&&e.linkedTo<n.spans.length){const a=n.spans[e.linkedTo];if(a&&"number"===typeof a.start)return"".concat(t," (references ").concat(a.start.toFixed(1),"m)")}return t})(),onClick:()=>xe(e.start),children:r&&void 0!==e.linkedTo&&e.linkedTo<n.spans.length&&n.spans[e.linkedTo]&&"number"===typeof n.spans[e.linkedTo].start&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"absolute -top-5 left-0 bg-red-600 text-white text-xs px-1 rounded shadow-sm",style:{fontSize:"10px"},children:["\u2190 ",n.spans[e.linkedTo].start.toFixed(1),"m"]}),(0,u.jsx)("div",{className:"absolute top-2 h-px bg-red-400 opacity-0 group-hover:opacity-60 transition-opacity pointer-events-none",style:{right:"100%",width:"".concat(Math.abs(parseFloat(ge(e.start))-parseFloat(ge(n.spans[e.linkedTo].start))),"%"),transform:n.spans[e.linkedTo].start<e.start?"none":"translateX(-100%)"}})]})},a)}),n.spans.length>0&&(()=>{const e=n.spans[n.spans.length-1],a=parseFloat(ge(e.end))>90,r=n.spans[0],s=n.spans.some(e=>"backref"===e.type)?35:5;return(0,u.jsx)("div",{className:"absolute text-xs text-gray-600 dark:text-gray-400 whitespace-nowrap",style:{left:a?"calc(".concat(ge(r.start)," + 1.5rem - ").concat(s,"px)"):"calc(".concat(ge(e.end)," + ").concat(s,"px + 1.5rem)"),top:"0.25rem",lineHeight:"1rem",textAlign:a?"right":"left",transform:a?"translateX(-100%)":"none"},children:t})})()]},t)})})]},n)})]})})})]})]}):(0,u.jsxs)("div",{className:"rounded-[28px] border border-[#d7dee9] bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.08),transparent_24%),radial-gradient(circle_at_84%_20%,rgba(111,137,182,0.07),transparent_22%),linear-gradient(180deg,rgba(255,255,255,0.56),rgba(255,255,255,0.42))] p-6 text-gray-900 shadow-[0_32px_80px_-44px_rgba(35,46,63,0.34)] backdrop-blur-[28px] dark:border-white/10 dark:bg-[radial-gradient(circle_at_12%_16%,rgba(255,181,43,0.1),transparent_24%),radial-gradient(circle_at_84%_20%,rgba(111,137,182,0.1),transparent_22%),linear-gradient(180deg,rgba(17,27,42,0.46),rgba(17,27,42,0.36))] dark:text-gray-100 ".concat(l),children:[(0,u.jsx)("h2",{className:"text-2xl font-bold mb-6 text-center",children:o}),"generating"===N?(0,u.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,u.jsx)(Lo,{className:"w-8 h-8 animate-spin mb-4"}),(0,u.jsx)("p",{className:"text-gray-600 dark:text-gray-400",children:"Generating topic map..."}),(0,u.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This is running on the server and will continue even if you navigate away"}),S&&(0,u.jsx)("p",{className:"text-xs text-gray-400 dark:text-gray-600 mt-1 max-w-md text-center",children:S})]}):(0,u.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,u.jsx)(Eu,{className:"w-12 h-12 text-gray-500 dark:text-gray-500 mb-4"}),(0,u.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"No topic map available"}),c?(0,u.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-500 text-center max-w-md",children:"This public share only exposes an existing topic map. Nothing has been generated for this episode yet."}):(0,u.jsxs)(u.Fragment,{children:[ae&&(0,u.jsxs)("div",{className:"mb-4 w-full max-w-xs",children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Select AI Model"}),(0,u.jsx)("select",{value:m,onChange:e=>null===h||void 0===h?void 0:h(e.target.value),className:"w-full px-3 py-2 border border-[#cfd5df] dark:border-[#40506a] bg-white dark:bg-[#131a25] text-gray-900 dark:text-gray-100 rounded-lg focus:ring-2 focus:ring-[#ffcf74] focus:border-transparent",children:p.map(e=>(0,u.jsx)("option",{value:e,children:e},e))})]}),(0,u.jsxs)("button",{onClick:he,disabled:!r||!s,className:"flex items-center gap-2 px-6 py-3 bg-[#FFB52B] hover:bg-[#f0a61d] text-[#232E3F] disabled:bg-gray-300 dark:disabled:bg-[#2f3c52] disabled:text-gray-500 disabled:cursor-not-allowed rounded-lg transition-colors",children:[(0,u.jsx)(Eu,{className:"w-4 h-4"}),"Generate Topic Map"]}),(!r||!s)&&(0,u.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"Transcript and metadata revision required"})]})]}),D&&(0,u.jsx)("div",{className:"mt-4 p-4 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-700 rounded-lg",children:(0,u.jsx)("p",{className:"text-red-600 dark:text-red-400 text-sm",children:D})})]})},wO=Mo("file-code-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]),kO=5e3,jO=e=>e?e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,'"').replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(t)).replace(/&#x([0-9a-f]+);/gi,(e,t)=>
2String.fromCharCode(parseInt(t,16))):"",DO=4500,CO=e=>{if(!e)return 0;const t=e.split(":").map(e=>parseInt(e,10));return 3===t.length?3600*t[0]+60*t[1]+t[2]:2===t.length?60*t[0]+t[1]:0},NO=e=>{if(!e)return"00:00:00";const t=e.split(":").map(e=>parseInt(e,10));if(3===t.length){const[e,n,a]=t;return"".concat(e.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"))}if(2===t.length){const[e,n]=t;return"00:".concat(e.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"))}return e},FO=e=>{let{sessionId:t,youtubeDescription:n="",ttmlContent:r="",sessionTitle:s="",linkedYoutubeUrl:i,sessionVisuals:o=null,transcript:l="",onDescriptionChange:c,onSeek:m,forceReadOnly:h=!1}=e;const{isDarkMode:p}=zu(),{permissions:g,shareToken:x}=Hp(),{token:f}=am(),[b,y]=(0,a.useState)(n),[v,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)("idle"),[D,C]=(0,a.useState)("idle"),[N,F]=(0,a.useState)("idle"),[S,E]=(0,a.useState)(!1),[A,T]=(0,a.useState)(!0),[M,_]=(0,a.useState)(!0),[B,I]=(0,a.useState)(!1),[P,L]=(0,a.useState)("base"),[R,z]=(0,a.useState)(!1),[O,U]=(0,a.useState)(!1),[V,H]=(0,a.useState)(!1),[q,W]=(0,a.useState)(null),[Y,G]=(0,a.useState)(null),[K,X]=(0,a.useState)(""),J=(0,a.useRef)(null),$=(0,a.useRef)(null),[Q,Z]=(0,a.useState)("not-generated"),[ee,te]=(0,a.useState)(null),[ne,ae]=(0,a.useState)(null),[re,se]=(0,a.useState)(!1),[ie,oe]=(0,a.useState)(null),le="/api",ce=window.location.origin,{topics:de,references:ue}=(0,a.useMemo)(()=>(e=>{if(!e)return{topics:[],references:[]};const t=[],n=[],a=e.match(/<div[^>]*xml:id="d_summary"[^>]*>([\s\S]*?)<\/div>/);if(a){const e=/<p\s+begin="([^"]+)"\s+end="([^"]+)"[^>]*>([\s\S]*?)<\/p>/g;let n;for(;null!==(n=e.exec(a[1]));){const e=n[3],a=e.match(/\[(\d+):\s*[\d\/?]+\]\s*(?:>>|>>)\s*\[([^\]]+)\]/);let r;if(a){const t=e.substring(e.indexOf(a[0])+a[0].length).replace(/<br\s*\/?>/gi," ").replace(/<[^>]+>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").trim(),n=t.match(/Justification:\s*(.+?)(?:\s*Optimal Placement:|$)/i);r=n?n[1].trim():t.replace(/^Score:\s*[\d\/]+\s*\([^)]+\)\s*/i,"").trim().replace(/\s*Optimal Placement:.*$/i,"").trim(),r||(r=void 0)}t.push({begin:n[1],end:n[2],text:e.replace(/<br\s*\/?>/gi,"\n").replace(/<[^>]+>/g,"").trim(),topicRank:a?a[1]:void 0,topicTitle:a?jO(a[2]):void 0,topicJustification:r})}}const r=e.match(/<div[^>]*xml:id="d_references"[^>]*>([\s\S]*?)<\/div>/);if(r){const e=/<p\s+begin="([^"]+)"\s+end="([^"]+)"[^>]*>([\s\S]*?)<\/p>/g;let t;for(;null!==(t=e.exec(r[1]));){const e=t[3],a=lM(e),r=jO(a.title),s=jO(a.url||""),i=jO(a.linkText||""),o=jO(a.category||""),l=jO(a.category||""),c=jO(a.context||""),d=jO(a.visualSuggestion||"");(s||r)&&n.push({begin:t[1],end:t[2],text:jO(e.replace(/<br\s*\/?>/gi,"\n").replace(/<[^>]+>/g,"").trim()),refName:r,refLinkText:i,refUrl:s,refType:o,refCategory:l,refDescription:c,refVisualSuggestion:d})}}return{topics:t,references:n}})(r),[r]),me=de,he=ue,pe=(0,a.useMemo)(()=>(e=>{if(0===e.length)return"";const t=[];return e.forEach(e=>{if(e.topicTitle){const n=NO(e.begin);t.push("".concat(n," ").concat(jO(e.topicTitle)))}}),t.join("\n")})(me),[me]),ge=(0,a.useMemo)(()=>(e=>{if(0===e.length)return"";const t={};e.forEach(e=>{const n=e.refCategory||"General";t[n]||(t[n]=[]),t[n].push(e)});const n=[];return Object.entries(t).forEach(e=>{let[t,a]=e;n.push("".concat(t,":")),a.forEach(e=>{if(e.refUrl){const t=NO(e.begin);n.push("[".concat(t,"] ").concat(e.refName||e.refLinkText||"Link")),n.push(e.refUrl)}})}),n.join("\n").trim()})(he),[he]),xe=(0,a.useMemo)(()=>{const e={};return he.forEach(t=>{const n=t.refCategory||"General";e[n]||(e[n]=[]),e[n].push(t)}),e},[he]),fe=(0,a.useMemo)(()=>Tm(he.map(e=>({id:Em({title:e.refName||e.refLinkText||"",start:CO(e.begin),end:CO(e.end)}),title:e.refName||e.refLinkText||"",start:CO(e.begin),end:CO(e.end)})),o),[he,o]),be=(0,a.useCallback)(e=>{if(m){const t=CO(e);m(t)}},[m]),[ye,ve]=(0,a.useState)(n||""),[we,ke]=(0,a.useState)(!1);(0,a.useEffect)(()=>()=>{J.current&&(J.current.close(),J.current=null)},[]),(0,a.useEffect)(()=>{we||void 0!==n&&n!==ye&&(y(n),ve(n),E(!1))},[n,ye,we]);const je=!!g||h,De=!!t&&(!!f||!!x),Ce=(0,a.useMemo)(()=>{const e=[];return b.trim()&&e.push(b.trim()),pe&&(e.push("\n---\nTIMESTAMPS:"),e.push(pe)),ge&&(e.push("\n---\nREFERENCES:"),e.push(ge)),e.join("\n").length},[b,pe,ge]),Ne=Ce>kO,Fe=(0,a.useCallback)(async e=>{if(f&&t){w(!0),j("saving");try{await Vm.updateSession({sessionId:t,youtubeDescription:e},f),j("saved"),E(!1),ve(e),ke(!1),setTimeout(()=>j("idle"),2e3)}catch(n){console.error("Failed to autosave description:",n),j("error"),setTimeout(()=>j("idle"),3e3)}finally{w(!1)}}},[f,t]),Se=e=>{const t=e.target.value;ke(!0),y(t),E(!0),null===c||void 0===c||c(t),$.current&&clearTimeout($.current),$.current=setTimeout(()=>{Fe(t)},1500)};(0,a.useEffect)(()=>()=>{$.current&&clearTimeout($.current)},[]),(0,a.useEffect)(()=>{const e=e=>{"Escape"===e.key&&B&&I(!1)};if(B)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[B]);const Ee=(0,a.useRef)(null);(0,a.useEffect)(()=>{(async()=>
2{if(t&&f)try{const e=await fetch("".concat(le,"/sessions/").concat(t,"/share-links"),{headers:{Authorization:"Bearer ".concat(f)}});if(!e.ok)return;const n=(await e.json()).find(e=>{var t;return"mlst"===(null===(t=e.label)||void 0===t?void 0:t.toLowerCase())&&e.isEnabled&&"active"===e.status});null!==n&&void 0!==n&&n.url&&oe(n.url)}catch(e){console.error("[Description] Error fetching share links:",e)}})()},[t,f,le]),(0,a.useEffect)(()=>{if(!t)return void(null!==Ee.current&&(Z("not-generated"),te(null),ae(null),Ee.current=null));if(!f)return;const e="".concat(t,"-").concat(r.length);Ee.current!==e&&(Z("not-generated"),te(null),ae(null),Ee.current=e);(async()=>{try{const e=await fetch("".concat(le,"/sessions/").concat(t,"/pdf/status"),{headers:{Authorization:"Bearer ".concat(f)}});if(!e.ok)return;const n=await e.json();"cached"!==n.status&&"generating"!==n.status||(Z(n.status),n.jobId&&te(n.jobId))}catch(e){console.error("[PDF] Error checking status:",e)}})()},[t,f,r]),(0,a.useEffect)(()=>{if(!ee||"generating"!==Q||!t||!f)return;const e=setInterval(async()=>{try{const e=await fetch("".concat(le,"/sessions/").concat(t,"/pdf/jobs/").concat(ee),{headers:{Authorization:"Bearer ".concat(f)}});if(!e.ok)return;const n=await e.json();"completed"===n.status?(Z("cached"),te(null)):"failed"===n.status&&(Z("error"),ae(n.error||"PDF generation failed"),te(null))}catch(e){console.error("[PDF] Error polling job status:",e)}},2e3);return()=>clearInterval(e)},[ee,Q,t,f]);const Ae=(0,a.useMemo)(()=>t?x&&!f?kM(x,le,ce):wM(t,le):null,[t,x,f,le,ce]),Te=(0,a.useMemo)(()=>t?function(e,t){return vM(t,"/api/public/sessions/".concat(e,"/pdf"))}(t,ce):null,[t,ce]),Me="error"===Q?ne||"PDF export unavailable":"generating"===Q?"Generating PDF transcript...":"cached"===Q?"Download PDF transcript":"Generate PDF transcript",_e=(0,a.useCallback)(()=>{const e=[];b.trim()&&e.push(b.trim()),pe&&(e.push("\n---\nTIMESTAMPS:"),e.push(pe)),ge&&(e.push("\n---\nREFERENCES:"),e.push(ge));const t=[];return(f||x)&&Te&&t.push("Download PDF transcript: ".concat(Te)),ie&&t.push("Full Transcript: ".concat(ie)),t.length>0&&(e.push("\n---\nLINKS:"),e.push(t.join("\n"))),e.join("\n")},[b,pe,ge,Te,ie,x,f]),Be=(0,a.useCallback)(()=>{const e=[];if(b.trim()&&e.push(b.trim()),me.length>0&&(e.push("\n---\n## Timestamps\n"),me.forEach(t=>{if(t.topicTitle){const n=NO(t.begin),a=jO(t.topicTitle);e.push("**".concat(n,"** - ").concat(a)),t.topicJustification&&e.push("> ".concat(jO(t.topicJustification))),e.push("")}})),he.length>0){e.push("\n---\n## References\n");const t={};he.forEach(e=>{const n=e.refCategory||"General";t[n]||(t[n]=[]),t[n].push(e)}),Object.entries(t).forEach(t=>{let[n,a]=t;e.push("### ".concat(n,"\n")),a.forEach(t=>{const n=t.refName||t.refLinkText||"Link",a=NO(t.begin),r=t.refType?" *(".concat(t.refType,")*"):"";t.refUrl?e.push("- **[".concat(a,"]** [").concat(n,"](").concat(t.refUrl,")").concat(r)):e.push("- **[".concat(a,"]** ").concat(n).concat(r)),t.refDescription&&e.push(" > ".concat(t.refDescription))}),e.push("")})}return e.join("\n")},[b,me,he]),Ie=async()=>{if(t&&!R){z(!0),W(null),X("Starting agent...");try{const e=await fetch("".concat(le,"/v1/agent/workflows/description"),{method:"POST",headers:d({"Content-Type":"application/json"},f?{Authorization:"Bearer ".concat(f)}:{}),body:JSON.stringify({sessionId:t})});if(!e.ok){const t=await e.json().catch(()=>({error:"Failed to start agent"}));throw new Error(t.error||"Failed to start description generation")}const n=(await e.json()).agentSessionId;G(n);const a=Hh(n,e=>{"text_delta"===e.type||"text"===e.type?X(e.content||e.message||"Working..."):"tool_start"===e.type?X("Calling ".concat(e.tool||"API","...")):"done"===e.type||"complete"===e.type?(a.close(),J.current=null,X(""),z(!1),window.dispatchEvent(new CustomEvent("rescript-session-refresh-needed",{detail:{sessionId:t,scopes:["description"]}})),fetch("".concat(le,"/sessions/").concat(t),{headers:f?{Authorization:"Bearer ".concat(f)}:{}}).then(e=>e.json()).then(e=>{e.youtube_description&&(y(e.youtube_description),ve(e.youtube_description),E(!1),null===c||void 0===c||c(e.youtube_description))}).catch(()=>{})):"error"===e.type&&(a.close(),J.current=null,X(""),z(!1),W(e.message||"Agent error"))},()=>{a.close(),J.current=null,X(""),z(!1)},f||void 0);J.current=a}catch(e){console.error("Error starting description generation:",e),W(e instanceof Error?e.message:"Failed to start description generation"),X(""),z(!1)}}},Pe=async()=>{const e=_e();if(e.length<=DO)return e;try{const e=await(async()=>{try{const e=await Wh();if(e.opus)return e.opus;if(e.sonnet)return e.sonnet}catch(_H){}return Rp.getRefinementModel()})();if(!e)throw new Error("No compression model is available right now");const n=await async function(e,t){const n=await fetch("".concat(Ch,"/v1/agent/workflows/description-compression"),{method:"POST",credentials:"include",headers:Sh(t),body:JSON.stringify(e)});if(!n.ok)throw new Error(await n.text());return n.json()}
2({sessionId:t,description:b,toc:pe,references:ge,targetLength:DO,model:e},f||void 0);G(n.agentSessionId),X("Starting compression agent...");const a=await new Promise((e,t)=>{let a=!1,r=null;const s=e=>{var n;a||(a=!0,J.current===r&&(J.current=null),null===(n=r)||void 0===n||n.close(),X(""),t(e instanceof Error?e:new Error("Failed to compress description")))};r=Hh(n.agentSessionId,t=>{a||("tool_start"===t.type?X("Running ".concat(t.tool||"tool","...")):"text_delta"===t.type||"text"===t.type?X("Compressing description..."):"done"===t.type||"complete"===t.type?(async()=>{var t;if(!a){a=!0,null===(t=r)||void 0===t||t.close(),J.current===r&&(J.current=null),X("");try{var i,o;const t=(await Ih(n.agentSessionId,f||void 0)).filter(e=>"assistant"===e.role),a=null===(i=t[t.length-1])||void 0===i||null===(o=i.content)||void 0===o?void 0:o.trim();if(!a)throw new Error("Compression agent did not return any output");e(a)}catch(l){s(l)}}})():"error"===t.type&&s(new Error(t.message||"Compression agent failed")))},()=>s(new Error("Compression agent stream disconnected")),f||void 0),J.current=r});return a}catch(n){throw console.error("Error compressing description:",n),n}},Le="inline-flex h-11 w-11 items-center justify-center rounded-xl transition-colors ".concat(p?"bg-[#33435a] text-[#F4F4F4] hover:bg-[#41516d]":"bg-[#232E3F] text-[#F4F4F4] hover:bg-[#1b2433]");return(0,u.jsxs)("div",{className:"h-full flex flex-col overflow-hidden ".concat(p?"bg-[#131a25]":"bg-[#f4f4f4]"),children:[(0,u.jsx)("div",{className:"flex-shrink-0 p-4 border-b ".concat(p?"border-[#334055] bg-[#202b3d]":"border-[#d9dde4] bg-[#faf7ef]"),children:(0,u.jsxs)("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("div",{className:"p-2 rounded-lg ".concat(p?"bg-[#314159]":"bg-[#fff1cc]"),children:(0,u.jsx)(gp,{className:"w-5 h-5 ".concat(p?"text-[#ffcf74]":"text-[#232E3F]")})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-lg font-semibold ".concat(p?"text-white":"text-gray-900"),children:"YouTube Description"}),(0,u.jsx)("p",{className:"hidden text-sm md:block ".concat(p?"text-gray-400":"text-gray-600"),children:je?"View the saved description, timestamps, and references":"Edit the description, timestamps, references, and optional PDF link"})]})]}),!je&&(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2 xl:justify-end",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[Ne&&(0,u.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer text-sm px-2 py-1.5 rounded-lg transition-colors ".concat(V?p?"bg-[#4b3913]/70 text-[#ffe09b]":"bg-[#fff1cc] text-[#6e4d0e]":p?"bg-[#2d3749] text-[#d3d9e4]":"bg-[#edf0f4] text-[#4f5d72]"),title:"When enabled, compresses description to ~".concat(DO," chars before copying"),children:[(0,u.jsx)("input",{type:"checkbox",checked:V,onChange:e=>H(e.target.checked),className:"w-3.5 h-3.5 text-[#232E3F] border-gray-300 rounded focus:ring-[#ffcf74]"}),(0,u.jsx)("span",{children:"Compress"})]}),(0,u.jsx)("button",{onClick:async()=>{let e;if(W(null),V){U(!0);try{const t=await Pe();if(!t)throw new Error("Compression returned empty result");e=t}catch(t){return W(t instanceof Error?t.message:"Failed to compress description"),void U(!1)}U(!1)}else e=_e();await Up(e)&&(C("copied"),setTimeout(()=>C("idle"),2e3))},disabled:O,className:"".concat(Le," ").concat(O?p?"bg-[#4b3913]/70 text-[#ffe09b]":"bg-[#fff1cc] text-[#6e4d0e]":"copied"===D?"bg-[#232E3F] text-[#ffcf74]":""),title:V?"Copy compressed (~".concat(DO," chars) for YouTube"):"Copy plain text for YouTube description","aria-label":V?"Copy compressed (~".concat(DO," chars) for YouTube"):"Copy plain text for YouTube description",children:O?(0,u.jsx)(Lo,{className:"w-5 h-5 animate-spin"}):"copied"===D?(0,u.jsx)(Wm,{className:"w-5 h-5"}):(0,u.jsx)(Np,{className:"w-5 h-5"})})]}),(0,u.jsx)("button",{onClick:async()=>{const e=Be();await Up(e)&&(F("copied"),setTimeout(()=>F("idle"),2e3))},className:"".concat(Le," ").concat("copied"===N?"bg-[#232E3F] text-[#ffcf74]":p?"bg-[#33435a] hover:bg-[#41516d] text-white":"bg-[#232E3F] hover:bg-[#1b2433] text-white"),title:"Copy full markdown with descriptions (not compressed)","aria-label":"Copy full markdown with descriptions",children:"copied"===N?(0,u.jsx)(Wm,{className:"w-5 h-5"}):(0,u.jsx)(wO,{className:"w-5 h-5"})}),De&&(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsxs)("button",{onClick:async()=>
2{if(t&&(f||x)&&Ae)if(!x||f)if("cached"!==Q){if("generating"!==Q){Z("generating"),ae(null);try{const e=await fetch("".concat(le,"/sessions/").concat(t,"/pdf/generate"),{method:"POST",headers:{Authorization:"Bearer ".concat(f),"Content-Type":"application/json"},body:JSON.stringify({force:!1})});if(!e.ok){const t=await e.json();throw new Error(t.error||"Failed to start PDF generation")}const n=await e.json();"cached"===n.status?(Z("cached"),window.open(Ae,"_blank","noopener")):te(n.jobId)}catch(e){console.error("[PDF] Error generating PDF:",e),Z("error"),ae(e instanceof Error?e.message:"Failed to generate PDF")}}}else window.open(Ae,"_blank","noopener");else window.open(Ae,"_blank","noopener")},disabled:"generating"===Q,title:Me,"aria-label":Me,className:"relative inline-flex h-11 w-11 items-center justify-center rounded-xl transition-opacity ".concat("generating"===Q?"cursor-wait opacity-70":"hover:opacity-80"),children:[(0,u.jsx)(mO,{isDarkMode:p}),"generating"===Q&&(0,u.jsx)("span",{className:"absolute -right-1 -top-1 rounded-full p-1 text-white shadow-sm ".concat(p?"bg-gray-800":"bg-gray-900"),children:(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 animate-spin"})})]}),(Te||Ae)&&(0,u.jsx)("button",{onClick:async()=>{const e=Te||Ae;if(!e)return;await Up(e)&&(se(!0),setTimeout(()=>se(!1),2e3))},title:"Copy PDF download link",className:"p-1.5 rounded-lg transition-all ".concat(re?"text-[#ffcf74]":p?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),children:re?(0,u.jsx)(Wm,{className:"w-4 h-4"}):(0,u.jsx)(_u,{className:"w-4 h-4"})})]})]})]})}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,u.jsxs)("div",{className:"max-w-4xl mx-auto space-y-6",children:[(0,u.jsxs)("div",{className:"rounded-xl border ".concat(p?"border-[#334055] bg-[#1d2636]":"border-[#d9dde4] bg-white/95"),children:[(0,u.jsx)("div",{className:"px-4 py-3 border-b ".concat(p?"border-[#334055] bg-[#202b3d]":"border-[#e3e6eb] bg-[#faf7ef]"),children:(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("h3",{className:"font-medium ".concat(p?"text-white":"text-gray-900"),children:"Description"}),!je&&(0,u.jsxs)("div",{className:"flex items-center",children:[(0,u.jsxs)("label",{className:"flex items-center gap-1.5 cursor-pointer text-sm px-3 py-1 rounded-md transition-colors ".concat(M?p?"bg-[#4b3913]/70 text-[#ffe09b]":"bg-[#fff1cc] text-[#6e4d0e]":p?"text-gray-400 hover:bg-[#2d3749]":"text-gray-600 hover:bg-[#edf0f4]"),children:[(0,u.jsx)("input",{type:"checkbox",checked:M,onChange:e=>_(e.target.checked),className:"sr-only"}),(0,u.jsx)(Cp,{className:"w-3.5 h-3.5"}),(0,u.jsx)("span",{children:"Preview"})]}),(0,u.jsxs)("button",{onClick:()=>I(!0),className:"flex items-center gap-1.5 text-sm px-3 py-1 rounded-md transition-colors ml-1 ".concat(p?"text-gray-400 hover:bg-gray-700 hover:text-gray-200":"text-gray-600 hover:bg-gray-100 hover:text-gray-800"),title:"Open fullscreen split editor",children:[(0,u.jsx)(zj,{className:"w-3.5 h-3.5"}),(0,u.jsx)("span",{children:"Fullscreen"})]}),(0,u.jsx)("div",{className:"mx-2 h-5 w-px ".concat(p?"bg-gray-600":"bg-gray-300")}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsxs)("div",{className:"flex flex-col items-end",children:[(0,u.jsxs)("span",{className:"text-xs ".concat(Ne?"text-red-500 font-medium":p?"text-gray-400":"text-gray-500"),children:[Ce.toLocaleString()," / ",kO.toLocaleString()]}),(0,u.jsx)("div",{className:"h-1 w-20 rounded-full overflow-hidden ".concat(p?"bg-gray-700":"bg-gray-200"),children:(0,u.jsx)("div",{className:"h-full transition-all ".concat(Ne?"bg-red-500":Ce/kO>.8?"bg-yellow-500":"bg-[#232E3F]"),style:{width:"".concat(Math.min(100,Ce/kO*100),"%")}})})]}),Ne&&(0,u.jsx)(fp,{className:"w-4 h-4 text-red-500"})]}),(0,u.jsx)("div",{className:"mx-2 h-5 w-px ".concat(p?"bg-gray-600":"bg-gray-300")}),(0,u.jsx)("div",{className:"flex items-center gap-1.5 text-xs px-2 py-1 rounded-md ".concat("saving"===k?p?"bg-[#314159] text-[#d9e2f1]":"bg-[#edf0f4] text-[#455468]":"saved"===k?p?"bg-[#223042] text-[#ffcf74]":"bg-[#232E3F] text-[#ffcf74]":"error"===k?p?"bg-red-900/30 text-red-300":"bg-red-100 text-red-700":S?p?"bg-[#4b3913]/70 text-[#ffe09b]":"bg-[#fff1cc] text-[#6e4d0e]":p?"bg-[#2d3749] text-gray-400":"bg-[#edf0f4] text-gray-500"),children:"saving"===k?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{className:"w-3 h-3 animate-spin"}),(0,u.jsx)("span",{children:"Saving"})]}):"saved"===k?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Saved"})]}):"error"===k?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(HE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Error"})]}):S?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Unsaved"})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Synced"})]})})]})]})}),(0,u.jsxs)("div",{className:"p-4",children:[je||M?(0,u.jsx)("div",{className:"prose prose-sm max-w-none ".concat(p?"prose-invert prose-p:text-gray-300 prose-headings:text-white prose-a:text-[#ffcf74] prose-strong:text-white prose-li:text-gray-300":"prose-p:text-gray-700 prose-headings:text-gray-900 prose-strong:text-gray-900 prose-li:text-gray-700"),children:b?(0,u.jsx)(my,{children:b}):(0,u.jsx)("span",{className:"italic text-gray-500",children:"No description provided"})}):(0,u.jsx)("textarea",{value:b,onChange:Se,placeholder:"Write your YouTube video description here... Tips:\n- Start with a hook to grab attention\n- Include relevant keywords\n- Add links to mentioned resources\n- The TOC and References below will be appended automatically when copying\n- Markdown formatting is supported",className:"w-full h-64 p-3 rounded-lg border resize-none font-mono text-sm ".concat(p?"bg-[#131a25] border-[#40506a] text-gray-200 placeholder-gray-500 focus:border-[#ffcf74]":"bg-[#fbfaf7] border-[#cfd5df] text-gray-800 placeholder-gray-400 focus:border-[#ffcf74]"," focus:outline-none focus:ring-2 focus:ring-[#ffcf74]/20")}),!je&&(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-2",children:[(0,u.jsx)("button",{onClick:Ie,disabled:R,className:"flex items-center gap-2 px-3 py-2 rounded-lg font-medium text-sm transition-colors ".concat(R?p?"bg-[#314159] text-[#d9e2f1]":"bg-[#edf0f4] text-[#455468]":p?"bg-[#FFB52B] hover:bg-[#f0a61d] text-[#232E3F] disabled:bg-[#2d3749] disabled:text-gray-500":"bg-[#FFB52B] hover:bg-[#f0a61d] text-[#232E3F] disabled:bg-gray-200 disabled:text-gray-400"," disabled:cursor-not-allowed"),title:"Generate a YouTube description using the AI agent",children:R?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{className:"w-4 h-4 animate-spin"}),K||"Generating..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Po,{className:"w-4 h-4"}),"Generate Description"]})}),q&&(0,u.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 rounded-lg text-sm ".concat(p?"bg-red-900/30 text-red-300":"bg-red-100 text-red-700"),children:[(0,u.jsx)(fp,{className:"w-4 h-4"}),q,(0,u.jsx)("button",{onClick:()=>W(null),className:"ml-1 hover:opacity-70",children:"\xd7"})]})]})]})]}),me.length>0&&(0,u.jsxs)("div",{className:"rounded-xl border ".concat(p?"border-[#334055] bg-[#1d2636]":"border-[#d9dde4] bg-white/95"),children:[(0,u.jsx)("div",{className:"px-4 py-3 border-b ".concat(p?"border-[#334055] bg-[#202b3d]":"border-[#e3e6eb] bg-[#faf7ef]"),children:(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(wp,{className:"w-4 h-4 ".concat(p?"text-[#ffcf74]":"text-[#8a6115]")}),(0,u.jsx)("h3",{className:"font-medium ".concat(p?"text-white":"text-gray-900"),children:"Timestamps (Auto-generated from TTML)"}),(0,u.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(p?"bg-[#4b3913]/70 text-[#ffe09b]":"bg-[#fff1cc] text-[#6e4d0e]"),children:[me.length," topics"]})]}),(0,u.jsxs)("button",{onClick:()=>T(!A),className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ".concat(p?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-500"),title:A?"Hide justifications":"Show justifications",children:[A?(0,u.jsx)(Fy,{className:"w-3.5 h-3.5"}):(0,u.jsx)(Cp,{className:"w-3.5 h-3.5"}),(0,u.jsx)("span",{children:A?"Hide details":"Show details"})]})]})}),(0,u.jsx)("div",{className:"p-4 space-y-2",children:me.map((e,t)=>e.topicTitle&&(0,u.jsxs)("div",{className:"space-y-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 font-mono text-sm",children:[(0,u.jsx)("button",{onClick:()=>be(e.begin),className:"px-2 py-0.5 rounded font-medium transition-colors ".concat(p?"bg-[#4b3913]/60 text-[#ffe09b] hover:bg-[#5a4417]":"bg-[#fff1cc] text-[#6e4d0e] hover:bg-[#ffe4a3]"),children:NO(e.begin)}),(0,u.jsx)("span",{className:p?"text-gray-300":"text-gray-700",children:jO(e.topicTitle||"")})]}),A&&e.topicJustification&&(0,u.jsx)("p",{className:"text-sm italic ml-[6.5rem] ".concat("text-gray-500"),children:jO(e.topicJustification)})]},t))})]}),he.length>0&&(0,u.jsxs)("div",{className:"rounded-xl border ".concat(p?"border-[#334055] bg-[#1d2636]":"border-[#d9dde4] bg-white/95"),children:[(0,u.jsx)("div",{className:"px-4 py-3 border-b ".concat(p?"border-[#334055] bg-[#202b3d]":"border-[#e3e6eb] bg-[#faf7ef]"),children:(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(_u,{className:"w-4 h-4 ".concat(p?"text-[#ffcf74]":"text-[#8a6115]")}),(0,u.jsx)("h3",{className:"font-medium ".concat(p?"text-white":"text-gray-900"),children:"References (Auto-generated from TTML)"}),(0,u.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(p?"bg-[#314159] text-[#d9e2f1]":"bg-[#edf0f4] text-[#455468]"),children:[he.length," links"]})]})}),(0,u.jsx)("div",{className:"p-4 space-y-4",children:Object.entries(xe).map(e=>{let[t,n]=e;return(0,u.jsxs)("div",{children:[(0,u.jsx)("h4",{className:"text-sm font-semibold mb-2 ".concat(p?"text-gray-400":"text-gray-500"),children:jO(t)}),(0,u.jsx)("div",{className:"space-y-3 ml-2",children:n.map((e,t)=>{var n;const a=e.refDescription||(t=>{const n=null===(t=e.text)||void 0===t?void 0:t.match(/Context:\s*(.+)/i);
2return n?n[1].trim():null})(),r=fe.get(Em({title:e.refName||e.refLinkText||"",start:CO(e.begin),end:CO(e.end)}));return(0,u.jsx)("div",{className:"space-y-1",children:(0,u.jsxs)("div",{className:"flex items-start gap-2",children:[(0,u.jsx)("button",{onClick:()=>be(e.begin),className:"px-1.5 py-0.5 rounded font-mono text-xs font-medium transition-colors flex-shrink-0 ".concat(p?"bg-[#4b3913]/60 text-[#ffe09b] hover:bg-[#5a4417]":"bg-[#fff1cc] text-[#6e4d0e] hover:bg-[#ffe4a3]"),children:NO(e.begin)}),(0,u.jsxs)("div",{className:"flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[e.refUrl?(0,u.jsx)("a",{href:e.refUrl,target:"_blank",rel:"noopener noreferrer",className:"hover:underline ".concat(p?"text-[#ffcf74]":"text-[#8a6115]"),children:e.refName||e.refLinkText||"Link"}):(0,u.jsx)("span",{className:p?"text-gray-300":"text-gray-700",children:e.refName||e.refLinkText||"Reference"}),e.refUrl&&(0,u.jsx)(Ep,{className:"w-3 h-3 flex-shrink-0 ".concat(p?"text-gray-500":"text-gray-400")}),e.refType&&(0,u.jsx)("span",{className:"text-xs px-1.5 py-0.5 rounded ".concat(p?"bg-[#314159] text-[#d9e2f1]":"bg-[#edf0f4] text-[#455468]"),children:e.refType}),r&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded ".concat(p?"bg-[#4b3913]/55 text-[#ffe09b]":"bg-[#fff4d8] text-[#8a6115]"),children:[(0,u.jsx)(Cp,{size:11}),r.assetCount," asset",1===r.assetCount?"":"s"]})]}),a&&(0,u.jsx)("p",{className:"text-sm mt-1 ".concat(p?"text-gray-400":"text-gray-600"),children:a}),null!==r&&void 0!==r&&null!==(n=r.placements)&&void 0!==n&&n.length?(0,u.jsx)("div",{className:"mt-2 max-w-xl",children:(0,u.jsx)(vS,{placements:r.placements,isDarkMode:p,compact:!0,onSeek:()=>be(e.begin)})}):!(null!==g&&void 0!==g&&g.isPublicShare)&&(e.refVisualSuggestion||r)&&(0,u.jsx)("div",{className:"mt-2 max-w-xl",children:(0,u.jsx)(fS,{kind:"reference",title:e.refName||e.refLinkText||"Reference",description:a||void 0,visualSuggestion:e.refVisualSuggestion,meta:e.refType||e.refCategory||void 0,linkHref:e.refUrl||void 0,previewImageUrl:Cm(null===r||void 0===r?void 0:r.primaryPlacement),attachmentLabel:r?"".concat(r.assetCount," attached asset").concat(1===r.assetCount?"":"s"):void 0,seekLabel:NO(e.begin),onSeek:()=>be(e.begin),isDarkMode:p,compact:!0})})]})]})},t)})})]},t)})})]})]})}),B&&(0,u.jsxs)("div",{className:"fixed inset-0 z-50 flex flex-col",children:[(0,u.jsxs)("div",{className:"flex-shrink-0 p-4 border-b flex items-center justify-between ".concat(p?"bg-[#202b3d] border-[#334055]":"bg-[#faf7ef] border-[#d9dde4]"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsx)("div",{className:"p-2 rounded-lg ".concat(p?"bg-[#314159]":"bg-[#fff1cc]"),children:(0,u.jsx)(gp,{className:"w-5 h-5 ".concat(p?"text-[#ffcf74]":"text-[#232E3F]")})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h2",{className:"text-lg font-semibold ".concat(p?"text-white":"text-gray-900"),children:"Split-Screen Editor"}),(0,u.jsx)("p",{className:"text-sm ".concat(p?"text-gray-400":"text-gray-600"),children:"Edit on the left, preview on the right"})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[(0,u.jsx)("button",{onClick:()=>L(e=>{const t=["sm","base","lg","xl"],n=t.indexOf(e);return n>0?t[n-1]:e}),disabled:"sm"===P,className:"p-1.5 rounded transition-colors ".concat("sm"===P?p?"text-gray-600 cursor-not-allowed":"text-gray-300 cursor-not-allowed":p?"text-gray-400 hover:bg-gray-700 hover:text-white":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),title:"Decrease text size",children:(0,u.jsx)(JE,{className:"w-4 h-4"})}),(0,u.jsx)("span",{className:"text-xs px-2 min-w-[2.5rem] text-center ".concat(p?"text-gray-400":"text-gray-500"),children:P.toUpperCase()}),(0,u.jsx)("button",{onClick:()=>L(e=>{const t=["sm","base","lg","xl"],n=t.indexOf(e);return n<t.length-1?t[n+1]:e}),disabled:"xl"===P,className:"p-1.5 rounded transition-colors ".concat("xl"===P?p?"text-gray-600 cursor-not-allowed":"text-gray-300 cursor-not-allowed":p?"text-gray-400 hover:bg-gray-700 hover:text-white":"text-gray-500 hover:bg-gray-100 hover:text-gray-700"),title:"Increase text size",children:(0,u.jsx)(ik,{className:"w-4 h-4"})})]}),(0,u.jsx)("div",{className:"h-5 w-px ".concat(p?"bg-gray-600":"bg-gray-300")}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsxs)("span",{className:"text-sm ".concat(Ne?"text-red-500 font-medium":p?"text-gray-400":"text-gray-500"),children:[Ce.toLocaleStr
2ing()," / ",kO.toLocaleString()]}),Ne&&(0,u.jsx)(fp,{className:"w-4 h-4 text-red-500"})]}),(0,u.jsx)("div",{className:"flex items-center gap-1.5 text-xs px-2 py-1 rounded-md ".concat("saving"===k?p?"bg-[#314159] text-[#d9e2f1]":"bg-[#edf0f4] text-[#455468]":"saved"===k?p?"bg-[#223042] text-[#ffcf74]":"bg-[#232E3F] text-[#ffcf74]":"error"===k?p?"bg-red-900/30 text-red-300":"bg-red-100 text-red-700":S?p?"bg-[#4b3913]/70 text-[#ffe09b]":"bg-[#fff1cc] text-[#6e4d0e]":p?"bg-[#2d3749] text-gray-400":"bg-[#edf0f4] text-gray-500"),children:"saving"===k?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{className:"w-3 h-3 animate-spin"}),(0,u.jsx)("span",{children:"Saving"})]}):"saved"===k?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Saved"})]}):"error"===k?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(HE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Error"})]}):S?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Unsaved"})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(qE,{className:"w-3 h-3"}),(0,u.jsx)("span",{children:"Synced"})]})}),(0,u.jsx)("button",{onClick:()=>I(!1),className:"p-2 rounded-lg transition-colors ".concat(p?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-500 hover:text-gray-700"),title:"Close split editor (Esc)",children:(0,u.jsx)(Pu,{className:"w-5 h-5"})})]})]}),(0,u.jsxs)("div",{className:"flex-shrink-0 px-4 py-2 border-b flex items-center gap-2 flex-wrap ".concat(p?"bg-[#1a2231] border-[#334055]":"bg-[#f4f4f4] border-[#d9dde4]"),children:[(0,u.jsx)("button",{onClick:Ie,disabled:R,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg font-medium text-sm transition-colors ".concat(R?p?"bg-[#314159] text-[#d9e2f1]":"bg-[#edf0f4] text-[#455468]":p?"bg-[#FFB52B] hover:bg-[#f0a61d] text-[#232E3F] disabled:bg-[#2d3749] disabled:text-gray-500":"bg-[#FFB52B] hover:bg-[#f0a61d] text-[#232E3F] disabled:bg-gray-200 disabled:text-gray-400"," disabled:cursor-not-allowed"),title:"Generate a YouTube description using the AI agent",children:R?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{className:"w-4 h-4 animate-spin"}),(0,u.jsx)("span",{children:K||"Generating..."})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Po,{className:"w-4 h-4"}),(0,u.jsx)("span",{children:"Generate Description"})]})}),q&&(0,u.jsxs)("div",{className:"flex items-center gap-2 px-3 py-1 rounded-lg text-sm ".concat(p?"bg-red-900/30 text-red-300":"bg-red-100 text-red-700"),children:[(0,u.jsx)(fp,{className:"w-4 h-4"}),q,(0,u.jsx)("button",{onClick:()=>W(null),className:"ml-1 hover:opacity-70",children:"\xd7"})]})]}),(0,u.jsxs)("div",{className:"flex-1 flex overflow-hidden ".concat(p?"bg-gray-900":"bg-gray-50"),children:[(0,u.jsxs)("div",{className:"w-1/2 flex flex-col border-r ".concat(p?"border-gray-700":"border-gray-300"),children:[(0,u.jsx)("div",{className:"flex-shrink-0 px-4 py-2 border-b ".concat(p?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),children:(0,u.jsx)("span",{className:"text-sm font-medium ".concat(p?"text-gray-300":"text-gray-700"),children:"Editor (Markdown)"})}),(0,u.jsx)("div",{className:"flex-1 p-4 overflow-hidden",children:(0,u.jsx)("textarea",{value:b,onChange:Se,placeholder:"Write your YouTube video description here... Markdown formatting is supported:\n- **bold** or *italic*\n- [links](url)\n- # Headers\n- - bullet lists",className:"w-full h-full p-4 rounded-lg border resize-none font-mono ".concat("sm"===P?"text-sm":"base"===P?"text-base":"lg"===P?"text-lg":"text-xl"," ").concat(p?"bg-[#131a25] border-[#40506a] text-gray-200 placeholder-gray-500 focus:border-[#ffcf74]":"bg-white border-[#cfd5df] text-gray-800 placeholder-gray-400 focus:border-[#ffcf74]"," focus:outline-none focus:ring-2 focus:ring-[#ffcf74]/20"),autoFocus:!0})})]}),(0,u.jsxs)("div",{className:"w-1/2 flex flex-col",children:[(0,u.jsx)("div",{className:"flex-shrink-0 px-4 py-2 border-b ".concat(p?"bg-gray-800 border-gray-700":"bg-gray-100 border-gray-200"),children:(0,u.jsx)("span",{className:"text-sm font-medium ".concat(p?"text-gray-300":"text-gray-700"),children:"Preview"})}),(0,u.jsx)("div",{className:"flex-1 p-4 overflow-auto",children:(0,u.jsx)("div",{className:"prose max-w-none ".concat("sm"===P?"prose-sm":"base"===P?"prose-base":"lg"===P?"prose-lg":"prose-xl"," ").concat(p?"prose-invert prose-p:text-gray-300 prose-headings:text-white prose-a:text-[#ffcf74] prose-strong:text-white prose-li:text-gray-300":"prose-p:text-gray-700 prose-headings:text-gray-900 prose-strong:text-gray-900 prose-li:text-gray-700"),children:b?(0,u.jsx)(my,{children:b}):(0,u.jsx)("span",{className:"italic ".concat(p?"text-gray-500":"text-gray-400"),children:"Start typing to see preview..."})})})]})]})]})]})},SO=Mo("file-code",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",ke
2y:"1mlx9k"}]]),EO=Mo("file-spreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]),AO=Mo("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),TO="/api";async function MO(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=d({},n.headers||{});t&&(a.Authorization="Bearer ".concat(t)),n.body instanceof FormData||a["Content-Type"]||(a["Content-Type"]="application/json");const r=await fetch(e,d(d({},n),{},{headers:a}));if(!r.ok){const e=await r.json().catch(()=>({error:r.statusText}));throw new Error(e.error||e.message||"Request failed: ".concat(r.status))}return r}async function _O(e,t,n){return(await MO("".concat(TO,"/sessions/").concat(e,"/context-files/").concat(t),n)).json()}async function BO(e,t,n){return(await MO("".concat(TO,"/sessions/").concat(e,"/context-files/").concat(t,"/content"),n)).text()}async function IO(e,t,n,a){await MO("".concat(TO,"/sessions/").concat(e,"/context-files/").concat(t),a,{method:"PUT",body:JSON.stringify(n)})}async function PO(e,t){const n=await fetch("".concat(TO,"/public/share/").concat(e,"/context-files/").concat(t,"/download"));if(!n.ok)throw new Error("Failed to get public download URL");return(await n.json()).downloadUrl}function LO(e){return"application/pdf"===e?(0,u.jsx)(gp,{size:20,className:"text-red-500"}):"text/markdown"===e?(0,u.jsx)(SO,{size:20,className:"text-[#232E3F] dark:text-[#FFCF74]"}):"text/plain"===e?(0,u.jsx)(gp,{size:20,className:"text-gray-500 dark:text-gray-400"}):"text/csv"===e?(0,u.jsx)(EO,{size:20,className:"text-[#B57700]"}):"application/json"===e?(0,u.jsx)(SO,{size:20,className:"text-yellow-500"}):"text/xml"===e?(0,u.jsx)(SO,{size:20,className:"text-orange-500"}):e.startsWith("image/")?(0,u.jsx)(Ty,{size:20,className:"text-[#FFB52B]"}):(0,u.jsx)(Iu,{size:20,className:"text-gray-400"})}function RO(e){return e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1024/1024).toFixed(1)," MB")}function zO(e){const t=new Date,n=new Date(e),a=Math.floor((t.getTime()-n.getTime())/1e3);if(a<60)return"just now";const r=Math.floor(a/60);if(r<60)return"".concat(r,"m ago");const s=Math.floor(r/60);if(s<24)return"".concat(s,"h ago");const i=Math.floor(s/24);return i<30?"".concat(i,"d ago"):n.toLocaleDateString()}function OO(e){return"application/pdf"===e?"PDF":"text/markdown"===e?"Markdown":"text/plain"===e?"Text":"text/csv"===e?"CSV":"application/json"===e?"JSON":"text/xml"===e?"XML":"image/jpeg"===e||"image/jpg"===e?"JPEG":"image/png"===e?"PNG":"image/webp"===e?"WebP":"image/gif"===e?"GIF":"File"}const UO=e=>e.stopPropagation(),VO=["text/plain","text/markdown","text/csv","application/json","text/xml"],HO=["image/jpeg","image/jpg","image/png","image/webp","image/gif"],qO=e=>{let{sessionId:t,isPublicView:n=!1,shareToken:r,sharePermissions:s,isDarkMode:i=!1,isActiveTab:o=!0}=e;const[l,c]=(0,a.useState)([]),[m,h]=(0,a.useState)(!0),[p,g]=(0,a.useState)(!1),[x,f]=(0,a.useState)(null),[b,y]=(0,a.useState)(null),[v,w]=(0,a.useState)(null),[k,j]=(0,a.useState)(null),[D,C]=(0,a.useState)(!1),[N,F]=(0,a.useState)(null),[S,E]=(0,a.useState)(""),[A,T]=(0,a.useState)(!1),[M,_]=(0,a.useState)(null),[B,I]=(0,a.useState)(""),[P,L]=(0,a.useState)(null),[R,z]=(0,a.useState)(null),[O,U]=(0,a.useState)(null),[V,H]=(0,a.useState)(new Set),q=(0,a.useRef)(!0),W=(0,a.useRef)(null),Y=void 0,G=e=>{H(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},K=(0,a.useCallback)(async()=>{try{let e;e=n&&r?await async function(e){const t=await fetch("".concat(TO,"/public/share/").concat(e,"/context-files"));if(!t.ok)throw new Error("Failed to list public context files");return(await t.json()).files}(r):await async function(e,t){const n=await MO("".concat(TO,"/sessions/").concat(e,"/context-files"),t);return(await n.json()).files}(t,Y),c(e),f(null),e.length<=5&&H(t=>0===t.size?new Set(e.map(e=>e.id)):t)}catch(e){f(e.message)}finally{h(!1)}},[t,n,r,Y]);(0,a.useEffect)(()=>{o&&K()},[o,K]),(0,a.useEffect)(()=>
2{if(!o)return void(q.current=!1);q.current=!0;const e=l.some(e=>"pending"===e.description_status||"generating"===e.description_status),t=setInterval(()=>{q.current&&K()},e?5e3:15e3);return()=>{q.current=!1,clearInterval(t)}},[l,o,K]),(0,a.useEffect)(()=>{const e=e=>{W.current&&!W.current.contains(e.target)&&U(null)};return O&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[O]);const X=(0,a.useCallback)(async e=>{if(0!==e.length){g(!0),f(null);try{await async function(e,t,n){const a=new FormData;t.forEach(e=>a.append("files",e));const r=await MO("".concat(TO,"/sessions/").concat(e,"/context-files"),n,{method:"POST",body:a});return(await r.json()).files}(t,e,Y),await K()}catch(n){f(n.message)}finally{g(!1)}}},[t,Y,K]),{getRootProps:J,getInputProps:$,isDragActive:Q}=Nu({onDrop:X,accept:{"application/pdf":[".pdf"],"text/plain":[".txt"],"text/markdown":[".md"],"text/csv":[".csv"],"application/json":[".json"],"text/xml":[".xml"],"image/jpeg":[".jpg",".jpeg"],"image/png":[".png"],"image/webp":[".webp"],"image/gif":[".gif"]},maxSize:52428800,disabled:n||p}),Z=async e=>{U(null);try{let a;if(n&&r)a=await PO(r,e.id);else{a=(await _O(t,e.id,Y)).downloadUrl||""}const s=document.createElement("a");s.href=a,s.download=e.filename||e.original_filename,s.click()}catch(a){f(a.message)}},ee=async e=>{U(null);try{let a;if(n&&r)a=await PO(r,e.id);else{a=(await _O(t,e.id,Y)).downloadUrl||""}await navigator.clipboard.writeText(a),z(e.id),setTimeout(()=>z(null),2e3)}catch(a){f(a.message)}},te=async e=>{try{await async function(e,t,n){await MO("".concat(TO,"/sessions/").concat(e,"/context-files/").concat(t),n,{method:"DELETE"})}(t,e,Y),L(null),U(null),K()}catch(n){f(n.message)}},ne=e=>HO.includes(e),ae=e=>Boolean(e.description);return m?(0,u.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,u.jsx)(Lo,{className:"animate-spin mr-2",size:20}),(0,u.jsx)("span",{className:i?"text-gray-400":"text-gray-500",children:"Loading context files..."})]}):(0,u.jsxs)("div",{className:"p-4 md:p-6 space-y-5 max-w-5xl mx-auto",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-lg font-semibold ".concat(i?"text-white":"text-gray-900"),children:"Context Files"}),(0,u.jsx)("p",{className:"hidden text-sm mt-0.5 md:block ".concat(i?"text-gray-400":"text-gray-500"),children:"Reference documents, papers, and images for this episode"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[l.length>1&&l.some(e=>ae(e))&&(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.jsx)("button",{onClick:()=>H(new Set(l.map(e=>e.id))),className:"text-xs px-2 py-1 rounded transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-500"),children:"Expand all"}),(0,u.jsx)("button",{onClick:()=>H(new Set),className:"text-xs px-2 py-1 rounded transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-100 text-gray-500"),children:"Collapse all"})]}),!n&&(0,u.jsxs)("span",{className:"text-sm tabular-nums ".concat(i?"text-gray-500":"text-gray-400"),children:[l.length," file",1!==l.length?"s":""]})]})]}),x&&(0,u.jsxs)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg px-4 py-3 text-sm text-red-700 dark:text-red-300 flex justify-between items-center",children:[(0,u.jsx)("span",{children:x}),(0,u.jsx)("button",{onClick:()=>f(null),className:"ml-3 hover:opacity-70",children:(0,u.jsx)(Pu,{size:14})})]}),!n&&(0,u.jsxs)("div",d(d({},J()),{},{className:"border-2 border-dashed rounded-xl p-8 text-center cursor-pointer transition-all ".concat(Q?"border-[#FFB52B] bg-[#FFF8EA] dark:bg-[#232E3F]/60 scale-[1.01]":i?"border-gray-700 hover:border-gray-500 bg-gray-800/30":"border-gray-200 hover:border-gray-400 bg-gray-50/50"," ").concat(p?"opacity-50 pointer-events-none":""),children:[(0,u.jsx)("input",d({},$())),p?(0,u.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,u.jsx)(Lo,{className:"animate-spin",size:20}),(0,u.jsx)("span",{className:i?"text-gray-300":"text-gray-600",children:"Uploading..."})]}):Q?(0,u.jsxs)("div",{children:[(0,u.jsx)(Eu,{className:"mx-auto mb-2 text-[#FFB52B]",size:28}),(0,u.jsx)("p",{className:"font-medium text-[#B57700] dark:text-[#FFE3A1]",children:"Drop files here..."})]}):(0,u.jsxs)("div",{children:[(0,u.jsx)(Eu,{className:"mx-auto mb-2 ".concat(i?"text-gray-500":"text-gray-400"),size:28}),(0,u.jsx)("p",{className:"font-medium ".concat(i?"text-gray-300":"text-gray-600"),children:"Drag files here or click to browse"}),(0,u.jsx)("p",{className:"text-xs mt-1.5 ".concat(i?"text-gray-500":"text-gray-400"),children:"PDF, Markdown, Text, CSV, JSON, XML, JPEG, PNG, WebP, GIF \u2014 max 50MB"})]})]})),0===l.length&&!m&&(0,u.jsxs)("div",{className:"text-center py-12 ".concat(i?"text-gray-500":"text-gray-400"),children:[(0,u.jsx)(Iu,{className:"mx-auto mb-3 opacity-40",size:40}),(0,u.jsx)("p",{className:"text-sm",children:"No context files uploaded yet"}),!n&&(0,u.jsx)("p",{className:"text-xs mt-1 opacity-70",children:"Upload reference papers, notes, or images to provide context"})]}),(0,u.jsx)("div",{className:"space-y-2",children:l.map(e=>{const a=V.has(e.id),s=ae(e);return(0,u.jsxs)("div",{className:"rounded-xl border transition-colors ".concat(i?"bg-gray-800/60 border-gray-700/80 hover:border-gray-600":"bg-white border-gray-200 hover:border-gray-300 shadow-sm"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[s?(0,u.jsx)("button",{onClick:()=>G(e.id),className:"flex-shrink-0 p-0.5 rounded transition-colors ".concat(i?"text-gray-500 hover:text-gray-300":"text-gray-400 hover:text-gray-600"),children:a?(0,u.jsx)(wd,{size:16}):(0,u.jsx)(bp,{size:16})}):(0,u.jsx)("div",{className:"w-5 flex-shrink-0"}),(0,u.jsx)("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center ".concat(i?"bg-gray-700/60":"bg-gray-100"),children:LO(e.mime_type)}),(0,u.jsxs)("div",{className:"min-w-0 flex-1 cursor-pointer",onClick:()=>s&&G(e.id),children:[(0,u.jsx)("p",{className:"font-medium text-sm truncate ".concat(i?"text-white":"text-gray-900"),children:e.filename}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5 text-xs mt-0.5 flex-wrap ".concat(i?"text-gray-400":"text-gray-500"),children:[(0,u.jsx)("span",{className:"inline-flex px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide ".concat(i?"bg-gray-700 text-gray-300":"bg-gray-100 text-gray-600"),children:OO(e.mime_type)}),(0,u.jsx)("span",{children:RO(e.file_size)}),e.uploader_email&&!n&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"opacity-50",children:"\xb7"}),(0,u.jsx)("span",{children:e.uploader_email})]}),e.created_at&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"opacity-50",children:"\xb7"}),(0,u.jsx)("span",{children:zO(e.created_at)})]}),e.hidden_from_share&&!n&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"opacity-50",children:"\xb7"}),(0,u.jsxs)("span",{className:"text-yellow-500 dark:text-yellow-400 flex items-center gap-0.5",children:[(0,u.jsx)(Fy,{size:10})," Hidden"]})]})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,u.jsx)("button",{onClick:()=>(async e=>{y(e),C(!0),w(null),j(null),U(null);try{if(VO.includes(e.mime_type))if(n&&r){const t=await PO(r,e.id),n=await fetch(t);w(await n.text())}else{const n=await BO(t,e.id,Y);w(n)}else if(n&&r){const t=await PO(r,e.id);j(t)}else{const n=await _O(t,e.id,Y);j(n.downloadUrl||null)}}catch(a){f(a.message),y(null)}finally{C(!1)}})(e),title:"View file",className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-500 hover:text-gray-700"),children:(0,u.jsx)(Cp,{size:16})}),(0,u.jsx)("button",{onClick:()=>Z(e),title:"Download file",className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-500 hover:text-gray-700"),children:(0,u.jsx)(Sp,{size:16})}),(0,u.jsx)("button",{onClick:()=>ee(e),title:"Copy download link",className:"p-2 rounded-lg transition-colors ".concat(R===e.id?"text-[#B57700] dark:text-[#FFCF74]":i?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-500 hover:text-gray-700"),children:R===e.id?(0,u.jsx)(Wm,{size:16}):(0,u.jsx)(pF,{size:16})}),!n&&(0,u.jsxs)("div",{className:"relative",ref:O===e.id?W:void 0,children:[(0,u.jsx)("button",{onClick:()=>U(O===e.id?null:e.id),className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400 hover:text-white":"hover:bg-gray-100 text-gray-500 hover:text-gray-700"),children:(0,u.jsx)(AO,{size:16})}),O===e.id&&(0,u.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-20 w-52 rounded-lg border shadow-lg py-1 ".concat(i?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:[(o=e.mime_type,VO.includes(o)&&(0,u.jsxs)("button",{onClick:()=>(async e=>{U(null),F(e),T(!1);try{const n=await BO(t,e.id,Y);E(n)}catch(n){f(n.message),F(null)}})(e),className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-left transition-colors ".concat(i?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-50 text-gray-700"),children:[(0,u.jsx)(Ro,{size:14,className:"opacity-60"}),"Edit content"]})),(0,u.jsxs)("button",{onClick:()=>{_(e),I(e.description||""),U(null)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-left transition-colors ".concat(i?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-50 text-gray-700"),children:[(0,u.jsx)(jj,{size:14,className:"opacity-60"}),"Edit description"]}),(0,u.jsx)("button",{onClick:()=>(async e=>{U(null);try{await IO(t,e.id,{hiddenFromShare:!e.hidden_from_share},Y),K()}catch(n){f(n.message)}})(e),className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-left transition-colors ".concat(i?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-50 text-gray-700"),children:e.hidden_from_share?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Cp,{size:14,className:"opacity-60"})," Show in shares"]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Fy,{size:14,className:"opacity-60"})," Hide from shares"]})}),(0,u.jsx)("div",{className:"my-1 border-t ".concat(i?"border-gray-700":"border-gray-100")}),P===e.id?(0,u.jsxs)("div",{className:"px-3.5 py-2 space-y-2",children:[(0,u.jsx)("p",{className:"text-xs ".concat(i?"text-gray-400":"text-gray-500"),children:"Delete this file permanently?"}),(0,u.jsxs)("div",{className:"flex gap-2",children:[(0,u.jsx)("button",{onClick:()=>te(e.id),className:"flex-1 px-2 py-1.5 text-xs bg-red-600 text-white rounded-md hover:bg-red-700 font-medium",children:"Delete"}),(0,u.jsx)("button",{onClick:()=>L(null),className:"flex-1 px-2 py-1.5 text-xs rounded-md font-medium ".concat(i?"bg-gray-700 text-gray-300":"bg-gray-100 text-gray-600"),children:"Cancel"})]})]}):(0,u.jsxs)("button",{onClick:()=>L(e.id),className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-left transition-colors text-red-500 ".concat(i?"hover:bg-red-900/20":"hover:bg-red-50"),children:[(0,u.jsx)(kp,{size:14,className:"opacity-60"}),"Delete file"]})]})]})]})]}),a&&s&&(0,u.jsx)("div",{className:"px-4 pb-3 ml-[28px] border-t ".concat(i?"border-gray-700/50":"border-gray-100"),children:(0,u.jsx)("div",{className:"pt-3",children:e.description?(0,u.jsx)("div",{className:"text-sm prose prose-sm max-w-none leading-relaxed ".concat(i?"prose-invert text-gray-300 prose-a:text-[#FFCF74] prose-strong:text-gray-200":"text-gray-600 prose-a:text-[#B57700] prose-strong:text-gray-800"),children:(0,u.jsx)(my,{remarkPlugins:[Cw],children:e.description})}):null})})]},e.id);var o})}),b&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm",onClick:()=>y(null),onKeyDown:UO,children:(0,u.jsxs)("div",{className:"relative flex flex-col rounded-xl shadow-2xl overflow-hidden ".concat(i?"bg-gray-900":"bg-white"," ").concat("application/pdf"===b.mime_type||ne(b.mime_type)?"w-[95vw] h-[95vh] max-w-[1600px]":"w-full max-w-4xl max-h-[90vh] mx-4"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b flex-shrink-0 ".concat(i?"border-gray-700 bg-gray-800/80":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0",children:[LO(b.mime_type),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("h4",{className:"font-medium text-sm truncate ".concat(i?"text-white":"text-gray-900"),children:b.filename}),(0,u.jsxs)("p",{className:"text-xs ".concat(i?"text-gray-400":"text-gray-500"),children:[OO(b.mime_type)," \xb7 ",RO(b.file_size)]})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.jsx)("button",{onClick:()=>Z(b),title:"Download",className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-500"),children:(0,u.jsx)(Sp,{size:16})}),(0,u.jsx)("button",{onClick:()=>ee(b),title:"Copy download link",className:"p-2 rounded-lg transition-colors ".concat(R===b.id?"text-[#B57700] dark:text-[#FFCF74]":i?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-500"),children:R===b.id?(0,u.jsx)(Wm,{size:16}):(0,u.jsx)(pF,{size:16})}),k&&(0,u.jsx)("a",{href:k,target:"_blank",rel:"noopener noreferrer",title:"Open in new tab",className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-400":"hover:bg-gray-200 text-gray-500"),children:(0,u.jsx)(Ep,{size:16})}),(0,u.jsx)("button",{onClick:()=>y(null),className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(Pu,{size:18})})]})]}),(0,u.jsx)("div",{className:"flex-1 overflow-auto",children:D?(0,u.jsxs)("div",{className:"flex items-center justify-center py-20",children:[(0,u.jsx)(Lo,{className:"animate-spin mr-2",size:24}),(0,u.jsx)("span",{className:i?"text-gray-400":"text-gray-500",children:"Loading..."})]}):null!==v?(0,u.jsx)("div",{className:"p-6",children:"text/markdown"===b.mime_type?(0,u.jsx)("div",{className:"prose prose-sm md:prose-base max-w-none ".concat(i?"prose-invert":""),children:(0,u.jsx)(my,{remarkPlugins:[Cw],children:v})}):"application/json"===b.mime_type?(0,u.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap leading-relaxed ".concat(i?"text-gray-300":"text-gray-800"),children:(()=>{try{return JSON.stringify(JSON.parse(v),null,2)}catch(_H){return v}})()}):(0,u.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap leading-relaxed ".concat(i?"text-gray-300":"text-gray-800"),children:v})}):k?"application/pdf"===b.mime_type?(0,u.jsx)("iframe",{src:k,className:"w-full h-full border-0",title:b.filename}):ne(b.mime_type)?(0,u.jsx)("div",{className:"flex items-center justify-center p-6 h-full",children:(0,u.jsx)("img",{src:k,alt:b.filename,className:"max-w-full max-h-full object-contain rounded-lg"})}):(0,u.jsxs)("div",{className:"text-center py-16",children:[(0,u.jsx)(Iu,{className:"mx-auto mb-4 ".concat(i?"text-gray-600":"text-gray-300"),size:48}),(0,u.jsxs)("a",{href:k,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 font-medium text-[#B57700] hover:text-[#8B5B00] dark:text-[#FFCF74] dark:hover:text-[#FFE3A1]",children:[(0,u.jsx)(Ep,{size:16})," Open file in new tab"]})]}):(0,u.jsx)("div",{className:"text-center py-16",children:(0,u.jsx)("p",{className:i?"text-gray-500":"text-gray-400",children:"No content available."})})})]})}),N&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm",onClick:()=>F(null),onKeyDown:UO,children:(0,u.jsxs)("div",{className:"relative w-[95vw] h-[95vh] max-w-[1400px] rounded-xl shadow-2xl overflow-hidden flex flex-col ".concat(i?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b flex-shrink-0 ".concat(i?"border-gray-700 bg-gray-800/80":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2.5",children:[LO(N.mime_type),(0,u.jsxs)("div",{children:[(0,u.jsxs)("h4",{className:"font-medium text-sm ".concat(i?"text-white":"text-gray-900"),ch
2ildren:["Editing: ",N.filename]}),(0,u.jsxs)("p",{className:"text-xs ".concat(i?"text-gray-400":"text-gray-500"),children:[OO(N.mime_type)," \xb7 ",RO(N.file_size)]})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsxs)("button",{onClick:async()=>{if(N){T(!0);try{await async function(e,t,n,a){await MO("".concat(TO,"/sessions/").concat(e,"/context-files/").concat(t,"/content"),a,{method:"PUT",body:JSON.stringify({content:n})})}(t,N.id,S,Y),F(null),K()}catch(e){f(e.message)}finally{T(!1)}}},disabled:A,className:"inline-flex items-center gap-1.5 rounded-lg bg-[#FFB52B] px-4 py-1.5 text-sm font-medium text-[#232E3F] transition-colors hover:bg-[#FFC54D] disabled:opacity-50",children:[A&&(0,u.jsx)(Lo,{className:"animate-spin",size:14}),"Save changes"]}),(0,u.jsx)("button",{onClick:()=>F(null),className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(Pu,{size:18})})]})]}),(0,u.jsx)("textarea",{value:S,onChange:e=>E(e.target.value),onKeyDown:UO,className:"flex-1 w-full p-5 font-mono text-sm leading-relaxed resize-none outline-none ".concat(i?"bg-gray-900 text-gray-200":"bg-white text-gray-800"),spellCheck:!1,autoFocus:!0})]})}),M&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-stretch bg-black/70 backdrop-blur-sm",onClick:()=>_(null),onKeyDown:UO,children:(0,u.jsxs)("div",{className:"relative w-full h-full flex flex-col ".concat(i?"bg-gray-900":"bg-white"),onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-5 py-3 border-b flex-shrink-0 ".concat(i?"border-gray-700 bg-gray-800/80":"border-gray-200 bg-gray-50"),children:[(0,u.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,u.jsx)(jj,{size:16,className:i?"text-gray-400":"text-gray-500"}),(0,u.jsxs)("div",{children:[(0,u.jsxs)("h4",{className:"font-medium text-sm ".concat(i?"text-white":"text-gray-900"),children:["Edit Description \u2014 ",M.filename]}),(0,u.jsx)("p",{className:"text-xs ".concat(i?"text-gray-400":"text-gray-500"),children:"Markdown formatting supported"})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("button",{onClick:async()=>{if(M)try{await IO(t,M.id,{description:B},Y),_(null),K()}catch(e){f(e.message)}},className:"inline-flex items-center gap-1.5 rounded-lg bg-[#FFB52B] px-4 py-1.5 text-sm font-medium text-[#232E3F] transition-colors hover:bg-[#FFC54D]",children:"Save"}),(0,u.jsx)("button",{onClick:()=>_(null),className:"p-2 rounded-lg transition-colors ".concat(i?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-200 text-gray-600"),children:(0,u.jsx)(Pu,{size:18})})]})]}),(0,u.jsxs)("div",{className:"flex-1 flex min-h-0",children:[(0,u.jsxs)("div",{className:"flex-1 flex flex-col border-r ".concat(i?"border-gray-700":"border-gray-200"),children:[(0,u.jsx)("div",{className:"px-4 py-2 text-xs font-medium flex-shrink-0 ".concat(i?"text-gray-400 bg-gray-800/50":"text-gray-500 bg-gray-50"),children:"Markdown Source"}),(0,u.jsx)("textarea",{value:B,onChange:e=>I(e.target.value),onKeyDown:UO,className:"flex-1 w-full p-4 font-mono text-sm leading-relaxed resize-none outline-none ".concat(i?"bg-gray-900 text-gray-200":"bg-white text-gray-800"),placeholder:"Describe this file and its relevance to the episode...",spellCheck:!1,autoFocus:!0})]}),(0,u.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,u.jsx)("div",{className:"px-4 py-2 text-xs font-medium flex-shrink-0 ".concat(i?"text-gray-400 bg-gray-800/50":"text-gray-500 bg-gray-50"),children:"Preview"}),(0,u.jsx)("div",{className:"flex-1 overflow-auto p-4 ".concat(i?"bg-gray-900":"bg-white"),children:B?(0,u.jsx)("div",{className:"text-sm prose prose-sm max-w-none leading-relaxed ".concat(i?"prose-invert text-gray-300 prose-a:text-[#FFCF74] prose-strong:text-gray-200":"text-gray-600 prose-a:text-[#B57700] prose-strong:text-gray-800"),children:(0,u.jsx)(my,{remarkPlugins:[Cw],children:B})}):(0,u.jsx)("p",{className:"text-sm italic ".concat(i?"text-gray-600":"text-gray-400"),children:"Start typing to see a preview..."})})]})]})]})})]})},WO=Mo("message-square-quote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]),YO=Mo("user-round",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}
2],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]),GO=Mo("book-open-text",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);function KO(e){if(null===e||!Number.isFinite(e))return"Untimed";const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?"".concat(n,":").concat(String(a).padStart(2,"0"),":").concat(String(r).padStart(2,"0")):"".concat(a,":").concat(String(r).padStart(2,"0"))}function XO(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function JO(e){return[...e].sort((e,t)=>{const n=e.timestampSeconds,a=t.timestampSeconds;return null!==n&&null!==a&&n!==a?n-a:null!==n&&null===a?-1:null===n&&null!==a?1:e.sortOrder!==t.sortOrder?e.sortOrder-t.sortOrder:e.createdAt!==t.createdAt?e.createdAt.localeCompare(t.createdAt):e.questionText.localeCompare(t.questionText)})}function $O(e){let{question:t,isDarkMode:n,onSeek:a}=e;const r=n?"border-[#39465A] bg-[#182130]/90 text-[#E7ECF2]":"border-[#D8DEE7] bg-white text-[#232E3F]",s=n?"bg-white/8 text-[#D5DEEA]":"bg-[#F3F6FA] text-[#4E5D72]",i=n?"text-[#A7B2C4]":"text-[#66758A]",o=null!==t.timestampSeconds&&Number.isFinite(t.timestampSeconds);return(0,u.jsx)("div",{className:"rounded-2xl border p-4 shadow-sm ".concat(r),children:(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{o&&a&&a(t.timestampSeconds)},disabled:!o||!a,className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-semibold transition ".concat(o&&a?n?"bg-[#FFB52B]/14 text-[#FFE3A1] hover:bg-[#FFB52B]/22":"bg-[#FFF4D9] text-[#8A6100] hover:bg-[#FFE7AD]":"".concat(s," cursor-default")),title:o&&a?"Jump to this question on the timeline":"No timestamp recorded",children:[(0,u.jsx)(SS,{size:12}),t.timecode||KO(t.timestampSeconds)]}),(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs ".concat(s),children:[(0,u.jsx)(WO,{size:12}),"implicit"===t.questionType?"Implicit":"Explicit"]}),t.askedBy&&(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs ".concat(s),children:[(0,u.jsx)(YO,{size:12}),t.askedBy]}),t.topic&&(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 text-xs ".concat(s),children:t.topic})]}),(0,u.jsx)("p",{className:"mt-3 whitespace-pre-wrap text-sm leading-6 sm:text-[15px]",children:t.questionText}),t.answerSummary&&(0,u.jsxs)("div",{className:"mt-3 rounded-xl px-3 py-2 text-xs leading-5 ".concat(n?"bg-[#142033] text-[#E0E7F1]":"bg-[#EEF5FF] text-[#35506C]"),children:[(0,u.jsx)("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-[0.14em] opacity-80",children:"Answer Summary"}),t.answerSummary]}),t.contextText&&(0,u.jsx)("div",{className:"mt-3 rounded-xl px-3 py-2 text-xs leading-5 ".concat(n?"bg-white/6 text-[#CDD6E2]":"bg-[#F5F7FA] text-[#546276]"),children:t.contextText}),t.updatedAt&&(0,u.jsxs)("div",{className:"mt-3 text-xs ".concat(i),children:["Updated ",XO(t.updatedAt)]})]})})}const QO=e=>{let{sessionId:t,isDarkMode:n=!1,onSeek:r}=e;const{token:s}=am(),{permissions:i,shareToken:o}=Hp(),[l,c]=(0,a.useState)([]),[d,m]=(0,a.useState)(!0),[h,p]=(0,a.useState)(null),[g,x]=(0,a.useState)("time"),[f,b]=(0,a.useState)(""),[y,v]=(0,a.useState)("all"),[w,k]=(0,a.useState)("all"),j=(0,a.useCallback)(async()=>{try{m(!0);const e=null!==i&&void 0!==i&&i.isPublicShare&&o?await fm(o):await xm(t,s||void 0);c(JO(e.questions)),p(null)}catch(e){p(e.message||"Failed to load questions")}finally{m(!1)}},[t,null===i||void 0===i?void 0:i.isPublicShare,o,s]);(0,a.useEffect)(()=>{j()},[j]);const D=(0,a.useMemo)(()=>{const e=f.trim().toLowerCase();return JO(l.filter(t=>{if("all"!==y&&(t.topic||"Uncategorized")!==y)return!1;if("all"!==w&&t.questionType!==w)return!1;if(!e)return!0;return[t.questionText,t.askedBy,t.topic,t.contextText,t.answerSummary,t.timeco
2de].filter(Boolean).join(" ").toLowerCase().includes(e)}))},[l,w,f,y]),C=(0,a.useMemo)(()=>function(e){const t=new Map;for(const r of e){var n,a;const e=(null===(n=r.topic)||void 0===n?void 0:n.trim())||"Uncategorized";t.has(e)||t.set(e,[]),null===(a=t.get(e))||void 0===a||a.push(r)}return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0])).map(e=>{let[t,n]=e;return{topic:t,questions:JO(n)}})}(D),[D]),N=(0,a.useMemo)(()=>l.filter(e=>null!==e.timestampSeconds).length,[l]),F=(0,a.useMemo)(()=>[...new Set(l.map(e=>{var t;return(null===(t=e.topic)||void 0===t?void 0:t.trim())||"Uncategorized"}))].sort((e,t)=>e.localeCompare(t)),[l]),S=(0,a.useMemo)(()=>l.filter(e=>"implicit"===e.questionType).length,[l]),E=n?"bg-[#111826] text-[#E7ECF2]":"bg-[#F4F4F4] text-[#232E3F]",A=n?"border-[#39465A] bg-[#182130]/92":"border-[#D8DEE7] bg-white";return(0,u.jsx)("div",{className:"flex h-full flex-col overflow-hidden ".concat(E),children:(0,u.jsx)("div",{className:"overflow-y-auto px-6 py-6",children:(0,u.jsxs)("div",{className:"mx-auto flex max-w-6xl flex-col gap-6",children:[(0,u.jsx)("div",{className:"rounded-[28px] border p-6 shadow-sm ".concat(A),children:(0,u.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row md:items-end md:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("div",{className:"text-xs font-semibold uppercase tracking-[0.22em] ".concat(n?"text-[#AAB7C8]":"text-[#6B7A90]"),children:"Episode Capture"}),(0,u.jsx)("h2",{className:"mt-2 text-2xl font-semibold",children:"Questions Asked"}),(0,u.jsx)("p",{className:"mt-2 max-w-3xl text-sm leading-6 ".concat(n?"text-[#B9C5D6]":"text-[#5E6B7D]"),children:"This is a browse-and-discovery view for questions that were actually asked or implicitly answered in the episode. Records are expected to be created by agents through the CLI or API."})]}),(0,u.jsxs)("div",{className:"grid gap-3 sm:grid-cols-4",children:[(0,u.jsxs)("div",{className:"rounded-2xl px-4 py-3 text-sm ".concat(n?"bg-white/6 text-[#D5DEEA]":"bg-[#F5F7FA] text-[#546276]"),children:[(0,u.jsx)("div",{className:"text-xs uppercase tracking-[0.16em] opacity-75",children:"Total"}),(0,u.jsx)("div",{className:"mt-1 text-lg font-semibold",children:l.length})]}),(0,u.jsxs)("div",{className:"rounded-2xl px-4 py-3 text-sm ".concat(n?"bg-white/6 text-[#D5DEEA]":"bg-[#F5F7FA] text-[#546276]"),children:[(0,u.jsx)("div",{className:"text-xs uppercase tracking-[0.16em] opacity-75",children:"Timed"}),(0,u.jsx)("div",{className:"mt-1 text-lg font-semibold",children:N})]}),(0,u.jsxs)("div",{className:"rounded-2xl px-4 py-3 text-sm ".concat(n?"bg-white/6 text-[#D5DEEA]":"bg-[#F5F7FA] text-[#546276]"),children:[(0,u.jsx)("div",{className:"text-xs uppercase tracking-[0.16em] opacity-75",children:"Topics"}),(0,u.jsx)("div",{className:"mt-1 text-lg font-semibold",children:F.length})]}),(0,u.jsxs)("div",{className:"rounded-2xl px-4 py-3 text-sm ".concat(n?"bg-white/6 text-[#D5DEEA]":"bg-[#F5F7FA] text-[#546276]"),children:[(0,u.jsx)("div",{className:"text-xs uppercase tracking-[0.16em] opacity-75",children:"Implicit"}),(0,u.jsx)("div",{className:"mt-1 text-lg font-semibold",children:S})]})]})]})}),(0,u.jsx)("div",{className:"rounded-[28px] border p-4 shadow-sm ".concat(A),children:(0,u.jsxs)("div",{className:"flex flex-col gap-4 roun
2ded-2xl px-4 py-4 ".concat(n?"bg-white/6 text-[#D5DEEA]":"bg-[#F5F7FA] text-[#546276]"),children:[(0,u.jsxs)("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between",children:[(0,u.jsxs)("div",{className:"inline-flex max-w-full rounded-2xl border p-1 shadow-sm",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>x("time"),className:"inline-flex items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium ".concat("time"===g?"bg-[#FFB52B] text-[#232E3F]":n?"text-[#D5DEEA] hover:bg-white/8":"text-[#546276] hover:bg-white"),children:[(0,u.jsx)(SS,{size:15}),"Time Order"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>x("topic"),className:"inline-flex items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium ".concat("topic"===g?"bg-[#FFB52B] text-[#232E3F]":n?"text-[#D5DEEA] hover:bg-white/8":"text-[#546276] hover:bg-white"),children:[(0,u.jsx)(ck,{size:15}),"Group by Topic"]})]}),(0,u.jsxs)("div",{className:"grid min-w-0 gap-3 md:grid-cols-2 xl:grid-cols-[minmax(260px,1fr)_220px_220px] xl:items-center",children:[(0,u.jsxs)("label",{className:"inline-flex min-w-0 items-center gap-2 rounded-2xl border px-3 py-2 text-sm ".concat(n?"border-[#39465A] bg-[#111826]":"border-[#D8DEE7] bg-white"),children:[(0,u.jsx)(Mu,{size:16,className:"shrink-0"}),(0,u.jsx)("input",{value:f,onChange:e=>b(e.target.value),placeholder:"Search questions, topics, context...",className:"min-w-0 flex-1 bg-transparent outline-none"})]}),(0,u.jsxs)("label",{className:"inline-flex min-w-0 items-center gap-2 rounded-2xl border px-3 py-2 text-sm ".concat(n?"border-[#39465A] bg-[#111826]":"border-[#D8DEE7] bg-white"),children:[(0,u.jsx)(hj,{size:16,className:"shrink-0"}),(0,u.jsxs)("select",{value:y,onChange:e=>v(e.target.value),className:"min-w-0 flex-1 bg-transparent outline-none",children:[(0,u.jsx)("option",{value:"all",children:"All topics"}),F.map(e=>(0,u.jsx)("option",{value:e,children:e},e))]})]}),(0,u.jsxs)("label",{className:"inline-flex min-w-0 items-center gap-2 rounded-2xl border px-3 py-2 text-sm ".concat(n?"border-[#39465A] bg-[#111826]":"border-[#D8DEE7] bg-white"),children:[(0,u.jsx)(GO,{size:16,className:"shrink-0"}),(0,u.jsxs)("select",{value:w,onChange:e=>k(e.target.value),className:"min-w-0 flex-1 bg-transparent outline-none",children:[(0,u.jsx)("option",{value:"all",children:"All question types"}),(0,u.jsx)("option",{value:"explicit",children:"Explicit only"}),(0,u.jsx)("option",{value:"implicit",children:"Implicit only"})]})]})]})]}),(0,u.jsx)("div",{className:"text-sm leading-6",children:"Browse captured questions by time or topic. Implicit questions capture moments where the guest answers a question that was never explicitly asked on air."})]})}),(0,u.jsx)("div",{className:"rounded-[28px] border p-4 shadow-sm ".concat(A),children:d?(0,u.jsx)("div",{className:"flex min-h-[300px] items-center justify-center",children:(0,u.jsxs)("div",{className:"inline-flex items-center gap-3 rounded-2xl px-4 py-3 text-sm ".concat(n?"bg-white/6 text-[#D5DEEA]":"bg-[#F5F7FA] text-[#546276]"),children:[(0,u.jsx)(Lo,{size:18,className:"animate-spin"}),"Loading questions\u2026"]})}):0===D.length?(0,u.jsx)("div",{className:"flex min-h-[300px] items-center justify-center rounded-[24px] border border-dashed text-center ".concat(n?"border-[#39465A] text-[#AAB7C8]":"border-[#D8DEE7] text-[#6B7A90]"),children:(0,u.jsxs)("div",{className:"max-w-sm px-6 py-10",children:[(0,u.jsx)("div",{className:"text-lg font-semibold",children:"No captured questions yet"}),(0,u.jsx)("p",{className:"mt-2 text-sm leading-6",children:"Questions will appear here once an agent populates them through the CLI or API."})]})}):"time"===g?(0,u.jsx)("div",{className:"space-y-3",children:D.map(e=>(0,u.jsx)($O,{question:e,isDarkMode:n,onSeek:r},e.id))}):(0,u.jsx)("div",{className:"space-y-6",children:C.map(e=>(0,u.jsxs)("section",{className:"space-y-3",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,u.jsx)("h3",{className:"text-sm font-semibold uppercase tracking-[0.16em]",children:e.topic}),(0,u.jsxs)("div",{className:"text-xs ".concat(n?"text-[#AAB7C8]":"text-[#6B7A90]"),children:[e.questions.length," question",1===e.questions.length?"":"s"]})]}),(0,u.jsx)("div",{className:"space-y-3",children:e.questions.map(e=>(0,u.jsx)($O,{question:e,isDarkMode:n,onSeek:r},e.id))})]},e.topic))})}),h&&(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(n?"border-[#7A2E2E] bg-[#3A1717] text-[#FFB8B8]":"border-[#
2E0A39A] bg-[#FDEDEA] text-[#8E2F25]"),children:h})]})})})},ZO=e=>{let{inverted:t=!1}=e;return(0,u.jsxs)("div",{className:"flex items-center gap-4",children:[(0,u.jsx)("div",{className:"flex h-14 w-14 shrink-0 items-center justify-center rounded-[1.35rem] shadow-brand ".concat(t?"bg-white/10":"bg-brand-navy"),children:(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"Machine Learning Street Talk",className:"h-8 w-auto"})}),(0,u.jsx)("div",{children:(0,u.jsx)("p",{className:"font-headlines text-2xl font-bold tracking-tight ".concat(t?"text-brand-yellow":"brand-highlight-text"),children:"ReScript"})})]})};const eU=()=>{var e;const t=oc(),[n,r]=fd(),{isDarkMode:s,toggleDarkMode:i}=zu(),[o,l]=(0,a.useState)(""),[c,m]=(0,a.useState)(""),[h,p]=(0,a.useState)(!0),[g,x]=(0,a.useState)(!1),[f,b]=(0,a.useState)(null),[y,v]=(0,a.useState)(null),w=(0,a.useRef)(null),k=(0,a.useRef)(-1),j=n.get("topic")||"",D=n.get("guest")||n.get("person")||""||"all";(0,a.useEffect)(()=>{const e=window.setTimeout(()=>m(o.trim()),250);return()=>window.clearTimeout(e)},[o]);const C=(0,a.useCallback)(function(e){r(t=>{const n=new URLSearchParams(t);return e?n.set("topic",e):n.delete("topic"),n},{replace:arguments.length>1&&void 0!==arguments[1]&&arguments[1]})},[r]),N=(0,a.useCallback)(function(e){r(t=>{const n=new URLSearchParams(t);return n.delete("person"),e&&"all"!==e?n.set("guest",e):n.delete("guest"),n},{replace:arguments.length>1&&void 0!==arguments[1]&&arguments[1]})},[r]),F=0===c.length&&!j,S=(0,a.useCallback)(async function(){let{append:e=!1,offset:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{e?x(!0):p(!0),b(null);const n=await async function(){var e,t,n;let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=await fetch("".concat("","/api/public/homepage-questions").concat(pm({q:a.query,person:a.person,topic:a.topic,discovery:null!==(e=a.discovery)&&void 0!==e&&e,limit:null!==(t=a.limit)&&void 0!==t?t:40,offset:null!==(n=a.offset)&&void 0!==n?n:0})),{cache:"no-store",credentials:"omit"});if(!r.ok){const e=await r.json().catch(()=>({error:r.statusText}));throw new Error(e.error||e.message||"Request failed: ".concat(r.status))}const s=await r.json();return{total:Number(s.total||0),count:Number(s.count||0),questions:Array.isArray(s.questions)?s.questions.map(mm):[],shows:Array.isArray(s.shows)?s.shows.map(hm).filter(e=>Boolean(e)):[],people:Array.isArray(s.people)?s.people.map(hm).filter(e=>Boolean(e)):[],topics:Array.isArray(s.topics)?s.topics.map(hm).filter(e=>Boolean(e)):[],pagination:s.pagination?{limit:Number(s.pagination.limit||0),offset:Number(s.pagination.offset||0),hasMore:Boolean(s.pagination.hasMore)}:void 0}}({query:c,person:"all"===D?void 0:D,topic:c?void 0:j||void 0,discovery:F,limit:F?1:24,offset:t});v(t=>function(e,t,n){if(!n||!e)return t;const a=new Map;return[...e.questions,...t.questions].forEach(e=>{a.set(e.id,e)}),d(d({},t),{},{questions:[...a.values()],count:[...a.values()].length})}(t,n,e))}catch(n){b(n.message||"Failed to load public questions")}finally{p(!1),x(!1)}},[c,F,D,j]);(0,a.useEffect)(()=>{k.current=-1,v(null),S({append:!1,offset:0})},[c,S,D,j]);const E=(0,a.useMemo)(()=>(null===y||void 0===y?void 0:y.people)||[],[y]),A=(0,a.useMemo)(()=>(null===y||void 0===y?void 0:y.questions)||[],[y]),T=(0,a.useMemo)(()=>(null===y||void 0===y?void 0:y.topics)||[],[y]),M=(0,a.useMemo)(()=>function(e){const t=new Map;for(const n of e){const e=(n.topic||"Uncategorized").trim()||"Uncategorized",a=t.get(e);a?a.push(n):t.set(e,[n])}return[...t.entries()].map(e=>{let[t,n]=e;return{topic:t,items:n}}).sort((e,t)=>t.items.length!==e.items.length?t.items.length-e.items.length:e.topic.localeCompare(t.topic))}(A),[A]),_=Boolean(null===y||void 0===y||null===(e=y.pagination)||void 0===e?void 0:e.hasMore),B=s?"text-[#B8C3D0]":"text-[#5B687C]",I=s?"border-white/[0.08] bg-[#162131]/88 text-[#F4F4F4]":"border-[#D6DCE4] bg-white/[0.88] text-[#232E3F]",P=s?"border-white/[0.08] bg-[#162131]/88 text-[#F4F4F4]":"border-[#D6DCE4] bg-white/90 text-[#232E3F]",L=s?"border-white/[0.12] bg-white/[0.08] text-[#F4F4F4]":"border-brand-navy
2/12 bg-white/90 text-brand-navy";(0,a.useEffect)(()=>{c.trim().length>0&&j&&C("",!0)},[c,j,C]),(0,a.useEffect)(()=>{if(F||!_||h||g||!w.current)return;const e=w.current,t=new IntersectionObserver(e=>{const[t]=e;if(null===t||void 0===t||!t.isIntersecting)return;const n=A.length;k.current!==n&&(k.current=n,S({append:!0,offset:n}))},{rootMargin:"480px 0px"});return t.observe(e),()=>t.disconnect()},[F,_,S,h,g,A.length]);const R=e=>{const t=null!=e.timestampSeconds?"?t=".concat(function(e){if(null===e||!Number.isFinite(e))return"";const t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),a=Math.floor(t%3600/60),r=t%60;return n>0?"".concat(n,"h").concat(a,"m").concat(r,"s"):"".concat(a,"m").concat(r,"s")}(e.timestampSeconds)):"";window.location.assign(e.publicUrl||"/share/".concat(e.shareToken||"").concat(t))};return(0,u.jsx)("div",{className:s?"dark":void 0,children:(0,u.jsx)("div",{className:"brand-shell brand-grid bg-[#F4F4F4] text-[#232E3F] dark:bg-[#101722] dark:text-[#F4F4F4]",children:(0,u.jsxs)("div",{className:"relative z-10",children:[(0,u.jsx)("header",{className:"mx-auto max-w-7xl px-4 pt-5 sm:px-6 lg:px-8",children:(0,u.jsx)("div",{className:"brand-card px-5 py-4 backdrop-blur-2xl sm:px-6 ".concat(I),children:(0,u.jsxs)("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between",children:[(0,u.jsx)(ZO,{}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,u.jsxs)("button",{onClick:()=>t("/"),className:"brand-button-secondary",children:[(0,u.jsx)(Yk,{className:"h-4 w-4"}),"Archive"]}),(0,u.jsxs)("button",{onClick:i,className:"brand-button-secondary px-4",title:s?"Switch to light mode":"Switch to dark mode","aria-label":s?"Switch to light mode":"Switch to dark mode","aria-pressed":s,children:[s?(0,u.jsx)(LE,{className:"h-4 w-4"}):(0,u.jsx)(RE,{className:"h-4 w-4"}),(0,u.jsx)("span",{className:"hidden sm:inline",children:s?"Light":"Dark"})]})]})]})})}),(0,u.jsxs)("main",{className:"mx-auto max-w-7xl px-4 pb-16 pt-10 sm:px-6 lg:px-8 lg:pt-14",children:[(0,u.jsxs)("section",{className:"brand-card brand-card-muted px-6 py-8 sm:px-8",children:[(0,u.jsxs)("p",{className:"brand-kicker",children:[(0,u.jsx)(Po,{className:"h-3.5 w-3.5"}),"Question Browser"]}),(0,u.jsx)("h1",{className:"brand-highlight-text mt-6 max-w-4xl font-headlines text-5xl font-bold tracking-tight sm:text-6xl",children:"Explore MLST through the questions that come up on the show."}),(0,u.jsx)("p",{className:"mt-6 max-w-3xl text-lg leading-8 text-brand-navy/72 dark:text-brand-cloud/72 sm:text-xl",children:"Browse recurring MLST questions by topic and jump straight into the public transcript at the exact moment each one is discussed."}),(0,u.jsxs)("div",{className:"mt-8 grid gap-3 lg:grid-cols-[minmax(0,1.55fr)_260px_auto]",children:[(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)(Mu,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-brand-navy/45 dark:text-brand-cloud/55"}),(0,u.jsx)("input",{type:"search",value:o,onChange:e=>l(e.target.value),placeholder:"Search questions, answers, people, topics",className:"w-full rounded-[1.35rem] border px-11 py-3 text-sm shadow-brand-sm outline-none transition focus:border-[#FFB52B]/50 ".concat(L)})]}),(0,u.jsxs)("select",{value:D,onChange:e=>N(e.target.value),className:"rounded-[1.35rem] border px-4 py-3 text-sm shadow-brand-sm outline-none transition focus:border-[#FFB52B]/50 ".concat(L),children:[(0,u.jsx)("option",{value:"all",children:"All people"}),E.map(e=>(0,u.jsxs)("option",{value:e.name,children:[e.name," (",e.count,")"]},e.name))]}),(0,u.jsx)("button",{onClick:()=>{S({append:!1,offset:0})},className:"brand-button-secondary",children:"Refresh"})]}),(0,u.jsxs)("div",{className:"mt-4 flex flex-wrap items-center gap-3 text-xs text-brand-navy/54 dark:text-brand-cloud/60",children:[F?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{children:[T.length," topic",1===T.length?"":"s"," ready to explore"]}),(0,u.jsx)("span",{children:"Pick a topic or start typing to switch into search mode."})]}):h?(0,u.jsx)("span",{children:"Searching..."}):(0,u.jsx)(u.Fragment,{children:0===A.length?(0,u.jsx)("span",{children:"No questions foun
2d for this search."}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("span",{children:["Showing ",A.length,_?"+":""," question",1===A.length?"":"s"]}),_?(0,u.jsx)("span",{children:"Scroll down to load more."}):null]})}),j?(0,u.jsxs)("button",{type:"button",onClick:()=>C(""),className:"rounded-full border border-[#F2D9A6] bg-[#FFF4D9] px-3 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.16em] text-[#8A6100] shadow-[0_10px_22px_-18px_rgba(138,97,0,0.45)] dark:border-[#FFCC66]/70 dark:bg-[#FFCC66] dark:text-[#241600] dark:shadow-[0_16px_30px_-22px_rgba(0,0,0,0.55)]",children:["Topic: ",j]}):null]})]}),(0,u.jsx)("section",{className:"mt-10 space-y-6",children:h?(0,u.jsxs)("div",{className:"brand-card p-10 text-center",children:[(0,u.jsx)(Lo,{className:"mx-auto h-8 w-8 animate-spin text-brand-yellow"}),(0,u.jsx)("p",{className:"mt-4 text-sm leading-7 text-brand-navy/70 dark:text-[#F4F4F4]",children:"Loading MLST questions\u2026"})]}):f?(0,u.jsxs)("div",{className:"brand-card p-10 text-center",children:[(0,u.jsx)("p",{className:"brand-highlight-text font-headlines text-2xl font-bold tracking-tight",children:"The public questions view did not load"}),(0,u.jsx)("p",{className:"mt-3 text-base leading-8 text-brand-navy/65 dark:text-[#C8CFD8]",children:f})]}):F?(0,u.jsxs)("div",{className:"space-y-6",children:[(0,u.jsxs)("div",{className:"brand-card p-8 sm:p-10",children:[(0,u.jsx)("p",{className:"brand-highlight-text font-headlines text-2xl font-bold tracking-tight",children:"Explore by topic"}),(0,u.jsx)("p",{className:"mt-3 max-w-3xl text-sm leading-7 ".concat(B),children:"Start with a topic, then drill into the exact question and jump straight to the public transcript at that moment."})]}),0===T.length?(0,u.jsxs)("div",{className:"brand-card p-10 text-center",children:[(0,u.jsx)(cA,{className:"mx-auto h-10 w-10 text-brand-yellow"}),(0,u.jsx)("p",{className:"brand-highlight-text mt-6 font-headlines text-2xl font-bold tracking-tight",children:"No topics are ready yet"}),(0,u.jsx)("p",{className:"mt-3 text-base leading-8 ".concat(B),children:"Try a different person filter or start a search directly."})]}):(0,u.jsx)("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:T.map(e=>(0,u.jsx)("button",{type:"button",onClick:()=>C(e.name||""),className:"rounded-[24px] border p-5 text-left shadow-brand-sm transition duration-300 hover:-translate-y-0.5 hover:shadow-brand ".concat(P),children:(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"brand-highlight-text font-headlines text-xl font-bold tracking-tight",children:e.name}),(0,u.jsxs)("p",{className:"mt-2 text-xs uppercase tracking-[0.18em] ".concat(B),children:[e.count," question",1===e.count?"":"s"]})]}),(0,u.jsx)("span",{className:"rounded-full px-3 py-1 font-headlines text-[11px] font-semibold uppercase tracking-[0.14em] ".concat(s?"border border-[#BCD7FF]/18 bg-[#213554]/88 text-[#F4F8FF]":"bg-[#EEF3FF] text-[#355E9A]"),children:"Topic"})]})},e.name))})]}):0===M.length?(0,u.jsxs)("div",{className:"brand-card p-10 text-center",children:[(0,u.jsx)(zE,{className:"mx-auto h-10 w-10 text-brand-yellow"}),(0,u.jsx)("p",{className:"brand-highlight-text mt-6 font-headlines text-2xl font-bold tracking-tight",children:"No public questions matched"}),(0,u.jsx)("p",{className:"mt-3 text-base leading-8 text-brand-navy/65 dark:text-[#C8CFD8]",children:"Try a broader search or clear the person filter."})]}):(0,u.jsxs)(u.Fragment,{children:[M.map(e=>(0,u.jsxs)("section",{className:"brand-card brand-card-muted overflow-hidden",children:[(0,u.jsx)("div",{className:"border-b border-brand-navy/10 px-6 py-4 dark:border-white/10",children:(0,u.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"brand-highlight-text font-headlines text-xl font-bold tracking-tight",children:e.topic}),(0,u.jsxs)("p",{className:"mt-1 text-xs uppercase tracking-[0.22em] text-brand-navy/50 dark:text-brand-cloud/56",children:[e.items.length," question",1===e.items.length?"":"s"]})]}),(0,u.jsx)("div",{className:"rounded-full px-3 py-1 text-[11px] font-headlines font-semibold uppercase tracking-[0.16em] ".concat(s?"border border-[#BCD7FF]/18 bg-[#213554]/88 text-[#F4F8FF]":"bg-[#EEF3FF] text-[#355E9A]"),children:"Topic group"})]})}),(0,u.jsx)("div",{className:"grid gap-4 p-5 xl:grid-cols-2",children:e.items.map(e=>(0,u.jsxs)("article",{className:"rounded-[24px] border p-5 shadow-brand-sm transition duration-300 hover:-translate-y-0.5 hover:shadow-brand ".concat(P),children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsx)("span",{className:"rounded-full px-3 py-1 font-headlines text-[0.62rem] font-bold uppercase tracking-[0.22em] ".concat("implicit"===e.questionType?"bg-[#EEF3FF] text-[#355E9A] dark:bg-[#26344A] dark:text-[#BCD7FF]":"bg-[#EAF7EF] text-[#2D7250] dark:bg-[#153526] dark:text-[#A9E2C4]"),children:e.questionType}),e.askedBy?(0,u.jsx)("span",{className:"rounded-full border px-3 py-1 font-headlines text-[0.62rem] font-bold uppercase tracking-[0.22em] ".concat(s?"border-white/12 bg-white/10 text-brand-cloud/76":"border-brand-navy
2/10 bg-white text-brand-navy/74"),children:e.askedBy}):null]}),(0,u.jsx)("h2",{className:"brand-highlight-text mt-5 font-headlines text-2xl font-bold tracking-tight",children:e.questionText}),(0,u.jsx)("p",{className:"mt-2 text-sm uppercase tracking-[0.22em] text-brand-navy/48 dark:text-brand-cloud/56",children:e.sessionTitle}),(0,u.jsx)("p",{className:"mt-4 line-clamp-4 text-sm leading-7 text-brand-navy/68 dark:text-brand-cloud/74",children:e.answerSummary||"Answer summary not yet written for this question."}),(0,u.jsxs)("div",{className:"mt-5 flex flex-wrap items-center gap-3 text-xs text-brand-navy/54 dark:text-brand-cloud/60",children:[e.timecode?(0,u.jsx)("span",{children:e.timecode}):(0,u.jsx)("span",{children:"No timestamp"}),e.publishedAt?(0,u.jsx)("span",{children:new Date(e.publishedAt).toLocaleDateString()}):null]}),(0,u.jsx)("div",{className:"mt-6 flex justify-end",children:(0,u.jsxs)("button",{onClick:()=>R(e),className:"brand-button-primary",disabled:!e.shareToken&&!e.publicUrl,children:["Open public transcript",(0,u.jsx)(Ep,{className:"h-4 w-4"})]})})]},e.id))})]},e.topic)),_?(0,u.jsx)("div",{ref:w,className:"flex justify-center py-4",children:(0,u.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full px-4 py-2 text-sm ".concat(B),children:[(0,u.jsx)(Lo,{className:"h-4 w-4 ".concat(g?"animate-spin":"")}),"Loading more questions as you scroll"]})}):null]})})]})]})})})},tU=Mo("log-in",[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]),nU=Mo("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]),aU={NODE_ENV:"production",PUBLIC_URL:"https://files.rescript.info",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_GOOGLE_CLIENT_ID:"650914284514-arrnrmrkrk8r37chamjmk7ta7tfj5nuk.apps.googleusercontent.com"}.REACT_APP_API_URL||"",rU="Search, read, and export Machine Learning Street Talk interviews through the MLST editorial transcript archive.",sU="https://files.rescript.info/mlst-og-image.png",iU=String.fromCharCode(116,105,109,64,109,108,115,116,46,97,105),oU=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:180;return e?((e,t)=>e.length>t?"".concat(e.slice(0,t).trimEnd(),"..."):e)(e.replace(/!\[[^\]]*\]\([^)]+\)/g," ").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[`*_>#~-]/g," ").replace(/\s+/g," ").trim(),t):"Open the transcript, skim the editorial summary, and pull a PDF edition when you want an offline copy."},lU=(e,t)=>{const n=document.querySelector(e);n&&n.setAttribute("content",t)},cU=e=>{const t=new Date(e.publishedAt||e.createdAt).getTime();return Number.isNaN(t)?0:t},dU=e=>{let{inverted:t=!1}=e;return(0,u.jsxs)("div",{className:"flex items-center gap-4",children:[(0,u.jsx)("div",{className:"flex h-14 w-14 shrink-0 items-center justify-center rounded-[1.35rem] shadow-brand ".concat(t?"bg-white/10":"bg-brand-navy"),children:(0,u.jsx)("img",{src:"/logos/combination_mark_yellow.svg",alt:"Machine Learning Street Talk",className:"h-8 w-auto"})}),(0,u.jsx)("div",{children:(0,u.jsx)("p",{className:"font-headlines text-2xl font-bold tracking-tight ".concat(t?"text-brand-yellow":"brand-highlight-text"),children:"ReScript"})})]})},uU=()=>{var e;const t=oc(),{login:n}=am(),{isDarkMode:r,toggleDarkMode:s}=zu(),i=aj(),[o,l]=(0,a.useState)([]),[c,d]=(0,a.useState)(0),[m,h]=(0,a.useState)(!1),[p,g]=(0,a.useState)(!1),[x,f]=(0,a.useState)([]),[b,y]=(0,a.useState)(!0),[v,w]=(0,a.useState)(!0),[k,j]=(0,a.useState)(()=>"undefined"!==typeof navigator&&!navigator.onLine),[D,C]=(0,a.useState)(null),[N,F]=(0,a.useState)(new Set),[E,A]=(0,a.useState)(!1),[T,M]=(0,a.useState)(null),[_,B]=(0,a.useState)(!1),[I,P]=(0,a.useState)(null),[L,R]=(0,a.useState)(""),[z,O]=(0,a.useState)(""),[U,V]=(0,a.useState)([]),[H,q]=(0,a.useState)(0),[W,Y]=(0,a.useState)(!1),[G,K]=(0,a.useState)(!1),[X,J]=(0,a.useState)(!1),[$,Q]=(0,a.useState)(null),Z=(0,a.useRef)(null);(0,a.useEffect)(()=>{document.title="Machine Learning Street Talk | ReScript Editorial Transcript Archive",lU('meta[name="description"]',"Machine Learning Street Talk ReScript is the editorial transcript archive for long-form AI conversations: searchable transcripts, episode notes, and downloadable PDF editions."),lU('meta[property="og:title"]',"Machine Learning Street Talk | ReScript Archive"),lU('meta[property="og:description"]',rU),lU('meta[property="og:url"]',"https://app.rescript.info"),lU('meta[property="og:image"]',sU),lU('meta[name="twitter:title"]',"Machine Learning Street Talk | ReScript Archive"),lU('meta[name="twitter:description"]',rU),lU('meta[name="twitter:image"]',sU),(e=>{const t=document.querySelector('link[rel="canonical"]');t&&t.setAttribute("href",e)})("https://app.rescript.info")},[]);const ee=(0,a.useCallback)(async()=>{try{w(!0);const e=await NN();f(e)}
2catch(e){console.error("[VIDEO-GALLERY] Error loading offline sessions:",e),f([])}finally{w(!1)}},[]),te=(0,a.useCallback)(async()=>{if(!navigator.onLine)return l([]),d(0),h(!1),C(null),void y(!1);try{var e,t;y(!0),C(null);const n=await fetch("".concat(aU,"/api/public/homepage-videos?limit=").concat(20,"&offset=0"));if(!n.ok)throw new Error("Failed to load videos");const a=await n.json(),r=[...a.videos||[]].sort((e,t)=>cU(t)-cU(e));l(r),d(null!==(e=a.total)&&void 0!==e?e:r.length),h(null!==(t=a.hasMore)&&void 0!==t&&t)}catch(n){console.error("[VIDEO-GALLERY] Error loading videos:",n),C("Failed to load videos")}finally{y(!1)}},[]),ne=(0,a.useCallback)(async()=>{if(!p&&m)try{var e,t;g(!0);const n=o.length,a=await fetch("".concat(aU,"/api/public/homepage-videos?limit=").concat(20,"&offset=").concat(n));if(!a.ok)throw new Error("Failed to load more videos");const r=await a.json(),s=[...r.videos||[]].sort((e,t)=>cU(t)-cU(e));l(e=>[...e,...s]),d(null!==(e=r.total)&&void 0!==e?e:n+s.length),h(null!==(t=r.hasMore)&&void 0!==t&&t)}catch(n){console.error("[VIDEO-GALLERY] Error loading more videos:",n)}finally{g(!1)}},[p,m,o.length]);(0,a.useEffect)(()=>{te(),ee()},[ee,te]),(0,a.useEffect)(()=>{const e=()=>{j(!navigator.onLine),navigator.onLine&&te(),ee()},t=()=>{ee()};return window.addEventListener("online",e),window.addEventListener("offline",e),window.addEventListener("rescript-offline-sessions-updated",t),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",e),window.removeEventListener("rescript-offline-sessions-updated",t)}},[ee,te]),(0,a.useEffect)(()=>{const e=window.setTimeout(()=>{O(L.trim())},500);return()=>window.clearTimeout(e)},[L]),(0,a.useEffect)(()=>{const e=z.trim();if(e.length<2)return V([]),q(0),Y(!1),Q(null),void K(!1);const t=new AbortController;return(async()=>{try{var n;K(!0),Q(null);const a=await fetch("".concat(aU,"/api/public/homepage-search?q=").concat(encodeURIComponent(e),"&limit=").concat(20,"&offset=0"),{signal:t.signal});if(!a.ok){const e=await a.json().catch(()=>null);throw new Error((null===e||void 0===e?void 0:e.error)||(null===e||void 0===e?void 0:e.message)||"Search failed")}const r=await a.json();V(r.videos||[]),q("number"===typeof r.total?r.total:(r.videos||[]).length),Y(null!==(n=r.hasMore)&&void 0!==n&&n)}catch(a){if(t.signal.aborted)return;V([]),q(0),Y(!1),Q(a instanceof Error?a.message:"Search failed")}finally{t.signal.aborted||K(!1)}})(),()=>t.abort()},[z]);const ae=(0,a.useCallback)(async()=>{if(X||!W)return;const e=z.trim();if(!(e.length<2))try{var t;J(!0);const n=U.length,a=await fetch("".concat(aU,"/api/public/homepage-search?q=").concat(encodeURIComponent(e),"&limit=").concat(20,"&offset=").concat(n));if(!a.ok)throw new Error("Failed to load more search results");const r=await a.json();V(e=>[...e,...r.videos||[]]),q("number"===typeof r.total?r.total:n+(r.videos||[]).length),Y(null!==(t=r.hasMore)&&void 0!==t&&t)}catch(n){console.error("[VIDEO-GALLERY] Error loading more search results:",n)}finally{J(!1)}},[X,W,z,U.length]);(0,a.useEffect)(()=>{const e=Z.current;if(!e)return;const t=new IntersectionObserver(e=>{if(!e[0].isIntersecting)return;z.trim().length>=2?ae():ne()},{rootMargin:"400px"});return t.observe(e),()=>t.disconnect()},[z,ne,ae]);const re=e=>{t("/share/".concat(e))},se=e=>{navigator.onLine&&e.shareToken?t("/share/".concat(e.shareToken)):e.shareToken?t("/session/".concat(e.sessionId,"?share=").concat(e.shareToken)):t("/session/".concat(e.sessionId))},ie=e=>new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),oe=e=>ie(e.publishedAt||e.createdAt),le=(e,t)=>
2{const n=(a=t.thumbnailUrl)?a.includes("maxresdefault")?a.replace("maxresdefault","hqdefault"):a.includes("hqdefault")?a.replace("hqdefault","mqdefault"):null:null;var a;const r=e.currentTarget;if(n&&"true"!==r.dataset.fallbackApplied&&r.src!==n)return r.dataset.fallbackApplied="true",void(r.src=n);var s;s=t.shareToken,F(e=>new Set(e).add(s))},ce=o.filter(e=>e.hasPdf).length,de=o.filter(e=>Boolean(e.description)).length,ue=null!==(e=o[0])&&void 0!==e?e:null,me=x.length>0,he=(0,a.useMemo)(()=>new Map(x.map(e=>[e.sessionId,e])),[x]),pe=z.trim(),ge=pe.length>=2,xe=ge?U:o,fe=ge?W:m,be=ge?X:p,ye=k?x.length>0:xe.length>0,ve="brand-shell brand-grid bg-[#F4F4F4] text-[#232E3F] dark:bg-[#101722] dark:text-[#F4F4F4]",we=r?"brand-highlight-text mt-6 max-w-4xl font-headlines text-5xl font-bold tracking-tight sm:text-6xl xl:text-7xl":"mt-6 max-w-4xl font-headlines text-5xl font-bold tracking-tight text-[#232E3F] [text-shadow:0_14px_34px_rgba(35,46,63,0.14)] sm:text-6xl xl:text-7xl",ke=r?"brand-highlight-text mt-6 font-headlines text-3xl font-bold leading-tight":"mt-6 font-headlines text-3xl font-bold leading-tight text-[#232E3F]",je=r?"prose prose-sm prose-invert max-w-none prose-headings:text-brand-yellow prose-p:text-[#FFF5DE] prose-p:opacity-80 prose-strong:text-[#FFF5DE] prose-li:text-[#FFF5DE] prose-li:opacity-80 prose-a:text-brand-yellow prose-blockquote:text-brand-cloud prose-hr:border-white/10":"prose prose-sm max-w-none prose-headings:text-[#232E3F] prose-p:text-[#3E4B5E] prose-strong:text-[#232E3F] prose-li:text-[#3E4B5E] prose-a:text-[#8B5B00] prose-blockquote:text-[#4C586B] prose-hr:border-brand-navy/10",De=[{label:"Public Episodes",value:String(c||o.length).padStart(2,"0")},{label:"PDF Editions",value:String(ce).padStart(2,"0")},{label:"Episode Notes",value:String(de).padStart(2,"0")}];return!b&&!v||me?!D||me||k?(0,u.jsxs)("div",{className:ve,children:[(0,u.jsxs)("div",{className:"relative z-10",children:[(0,u.jsx)("header",{className:"mx-auto max-w-7xl px-4 pt-5 sm:px-6 lg:px-8",children:(0,u.jsx)("div",{className:"brand-card px-5 py-4 sm:px-6",children:(0,u.jsxs)("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-center lg:justify-between",children:[(0,u.jsx)(dU,{}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,u.jsxs)("a",{href:"https://www.mlst.ai/",target:"_blank",rel:"noopener noreferrer",className:"brand-button-secondary",children:[(0,u.jsx)(Ap,{className:"h-4 w-4"}),"Substack"]}),(0,u.jsxs)("button",{onClick:()=>t("/questions"),className:"brand-button-secondary",children:[(0,u.jsx)(ky,{className:"h-4 w-4"}),"Questions"]}),(0,u.jsxs)("button",{onClick:s,className:"brand-button-secondary px-4",title:r?"Switch to light mode":"Switch to dark mode","aria-label":r?"Switch to light mode":"Switch to dark mode","aria-pressed":r,children:[r?(0,u.jsx)(LE,{className:"h-4 w-4"}):(0,u.jsx)(RE,{className:"h-4 w-4"}),(0,u.jsx)("span",{className:"hidden sm:inline",children:r?"Light":"Dark"})]}),(0,u.jsxs)("button",{onClick:()=>A(!0),className:"brand-button-primary",children:[(0,u.jsx)(tU,{className:"h-4 w-4"}),"Sign in"]})]})]})})}),(0,u.jsxs)("main",{className:"mx-auto max-w-7xl px-4 pb-16 pt-10 sm:px-6 lg:px-8 lg:pt-14",children:[(k||me)&&(0,u.jsx)("section",{className:"mb-10",children:(0,u.jsx)("div",{className:"brand-card brand-card-muted p-5 sm:p-6",children:(0,u.jsxs)("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"brand-kicker",children:k?"Offline Access":"Saved On This Device"}),(0,u.jsx)("h2",{className:"brand-highlight-text mt-4 font-headlines text-3xl font-bold tracking-tight sm:text-4xl",children:k?"Showing saved sessions only":"".concat(x.length," saved session").concat(1===x.length?"":"s")}),(0,u.jsx)("p",{className:"mt-3 max-w-3xl text-sm leading-7 text-brand-navy/64 dark:text-brand-cloud/72",children:k?"The archive below is showing only sessions stored on this device. Video is not available offline.":"Saved sessions stay in the normal archive flow. Look for the offline badge on any episode you have stored locally."})]}
2),k&&(0,u.jsx)("p",{className:"max-w-md text-sm leading-7 text-brand-navy/56 dark:text-brand-cloud/64 lg:text-right",children:"Open any saved episode below for transcript, description, comments, and audio access without connectivity."})]})})}),(0,u.jsxs)("section",{className:"grid gap-8 lg:grid-cols-[minmax(0,1.2fr)_380px] lg:items-end",children:[(0,u.jsxs)(Do.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.45},children:[(0,u.jsxs)("p",{className:"brand-kicker",children:[(0,u.jsx)(Po,{className:"h-3.5 w-3.5"}),"Editorial Transcript Archive"]}),(0,u.jsx)("h1",{className:we,children:(0,u.jsx)("span",{className:r?void 0:"rounded-[0.35em] bg-[linear-gradient(180deg,transparent_64%,rgba(255,181,43,0.24)_64%)] px-1 py-1 [box-decoration-break:clone] [-webkit-box-decoration-break:clone]",children:'"The Machine Learning and AI Podcast That Actually Goes Deep."'})}),(0,u.jsx)("p",{className:"mt-6 max-w-3xl text-lg leading-8 text-brand-navy/72 dark:text-brand-cloud/72 sm:text-xl",children:"Browse the best Machine Learning Street Talk interviews through searchable transcripts, rich episode notes, and downloadable PDF editions. Hosted by Dr. Tim Scarfe."}),(0,u.jsxs)("div",{className:"mt-8 flex flex-wrap gap-3",children:[(0,u.jsxs)("a",{href:"https://discord.gg/HNnAwSduud",target:"_blank",rel:"noopener noreferrer",className:"brand-button-primary",children:[(0,u.jsx)(ky,{className:"h-4 w-4"}),"Join Discord"]}),(0,u.jsxs)("a",{href:"https://www.patreon.com/mlst",target:"_blank",rel:"noopener noreferrer",className:"brand-button-secondary",children:[(0,u.jsx)(Sw,{className:"h-4 w-4"}),"Patreon"]}),(0,u.jsxs)("a",{href:"https://www.paypal.com/donate/?hosted_button_id=K2TYRVPBGXVNA",target:"_blank",rel:"noopener noreferrer",className:"brand-button-ghost",children:[(0,u.jsx)(nU,{className:"h-4 w-4"}),"Donate"]}),(0,u.jsxs)("button",{onClick:()=>t("/questions"),className:"brand-button-secondary",children:[(0,u.jsx)(ky,{className:"h-4 w-4"}),"Explore questions"]})]}),(0,u.jsx)("div",{className:"mt-10 grid gap-4 sm:grid-cols-3",children:De.map(e=>(0,u.jsxs)("div",{className:"brand-card brand-card-muted p-5 sm:p-6",children:[(0,u.jsx)("p",{className:"font-headlines text-[0.68rem] font-bold uppercase tracking-[0.28em] text-brand-navy/52 dark:text-brand-cloud/56",children:e.label}),(0,u.jsx)("p",{className:"mt-4 font-headlines text-4xl font-bold tracking-tight text-brand-navy dark:text-[#FFF5DE]",children:e.value})]},e.label))})]}),(0,u.jsxs)(Do.aside,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},transition:{duration:.45,delay:.08},className:"brand-card overflow-hidden bg-[linear-gradient(180deg,rgba(255,255,255,0.98),rgba(255,245,222,0.92))] p-6 text-brand-navy dark:bg-brand-navy dark:text-brand-cloud sm:p-8",children:[(0,u.jsx)("p",{className:"brand-kicker border-[#E4D4AB] bg-[#FFF3D6] text-[#7C5A0C] dark:border-white/15 dark:bg-white/10 dark:text-brand-cloud",children:"Latest Edition"}),ue?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{className:ke,children:ue.title}),(0,u.jsx)("p",{className:"mt-4 text-sm leading-7 text-brand-navy/68 dark:text-brand-cloud/74",children:oU(ue.description,230)}),(0,u.jsxs)("div",{className:"mt-8 grid gap-3 text-sm text-brand-navy/68 dark:text-brand-cloud/74",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-4 rounded-[1.25rem] border border-brand-navy/10 bg-white/86 px-4 py-3 dark:border-white/10 dark:bg-white/[0.08]",children:[(0,u.jsx)("span",{className:"font-headlines text-[0.68rem] font-bold uppercase tracking-[0.24em] text-brand-navy/48 dark:text-brand-cloud/58",children:"Published"}),(0,u.jsx)("span",{children:oe(ue)})]}),he.has(ue.sessionId)&&(0,u.jsxs)("div",{className:"flex items-center justify-between gap-4 rounded-[1.25rem] border border-brand-navy/10 bg-white/86 px-4 py-3 dark:border-white/10 dark:bg-white/[0.08]",children:[(0,u.jsx)("span",{className:"font-headlines text-[0.68rem] font-bold uppercase tracking-[0.24em] text-brand-navy/48 dark:text-brand-cloud/58",children:"Offline"}),(0,u.jsx)("span",{children:"Saved on this device"})]}),(0,u.jsxs)("div",{className:"flex items-center justify-between gap-4 roun
2ded-[1.25rem] border border-brand-navy/10 bg-white/86 px-4 py-3 dark:border-white/10 dark:bg-white/[0.08]",children:[(0,u.jsx)("span",{className:"font-headlines text-[0.68rem] font-bold uppercase tracking-[0.24em] text-brand-navy/48 dark:text-brand-cloud/58",children:"Notes"}),(0,u.jsx)("span",{children:ue.description?"Included":"Transcript only"})]})]}),(0,u.jsxs)("div",{className:"mt-8 flex flex-wrap gap-3",children:[(0,u.jsxs)("button",{onClick:()=>re(ue.shareToken),className:"brand-button-primary",children:["Open transcript",(0,u.jsx)(lj,{className:"h-4 w-4"})]}),(0,u.jsx)("a",{href:"".concat(aU,"/api/public/sessions/").concat(ue.sessionId,"/pdf"),onClick:e=>e.stopPropagation(),className:"inline-flex h-12 w-12 items-center justify-center rounded-full border border-brand-navy/12 bg-white/92 transition duration-200 hover:-translate-y-0.5 hover:border-brand-navy/22 hover:bg-white hover:shadow-brand dark:border-white/12 dark:bg-white/10 dark:hover:border-white/24 dark:hover:bg-white/[0.16]",title:ue.hasPdf?"Download PDF transcript":"Generate and download PDF transcript","aria-label":ue.hasPdf?"Download PDF transcript":"Generate and download PDF transcript",target:"_blank",rel:"noopener noreferrer",children:(0,u.jsx)(mO,{isDarkMode:r,className:"h-8 w-8"})}),ue.description&&(0,u.jsxs)("button",{onClick:()=>P(ue),className:"inline-flex items-center justify-center gap-2 rounded-full border border-brand-navy/12 bg-white/92 px-5 py-3 font-headlines text-sm font-bold uppercase tracking-[0.18em] text-brand-navy transition duration-200 hover:-translate-y-0.5 hover:border-brand-navy/22 hover:bg-white hover:shadow-brand dark:border-white/12 dark:bg-white/10 dark:text-brand-cloud dark:hover:border-white/24 dark:hover:bg-white/[0.16]",children:[(0,u.jsx)(gp,{className:"h-4 w-4"}),"Read note"]})]})]}):(0,u.jsx)("p",{className:"mt-6 text-sm leading-7 text-brand-navy/68 dark:text-brand-cloud/74",children:"No public episode has been published yet. Check back shortly for the first transcript edition."})]})]}),(0,u.jsxs)("section",{className:"mt-16",children:[(0,u.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"brand-kicker",children:k?"Saved Episodes":"Browse The Archive"}),(0,u.jsx)("h2",{className:"brand-highlight-text mt-4 font-headlines text-3xl font-bold tracking-tight sm:text-4xl",children:k?"Saved episodes":"Public episodes"})]}),(0,u.jsx)("p",{className:"max-w-xl text-sm leading-7 text-brand-navy/62 dark:text-brand-cloud/68 sm:text-right",children:k?"Saved episodes use the same archive layout, with an offline badge marking anything available on this device.":"Every card opens a full transcript view. Use the note button and download icon for deeper reading without leaving the archive."})]}),!k&&(0,u.jsxs)("div",{className:"brand-card brand-card-muted mt-8 p-4 sm:p-5",children:[(0,u.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center",children:[(0,u.jsxs)("label",{className:"relative block flex-1",children:[(0,u.jsx)(Mu,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-brand-navy/45 dark:text-brand-cloud/45"}),(0,u.jsx)("input",{type:"search",value:L,onChange:e=>R(e.target.value),placeholder:"Search titles, speakers, transcript moments, and topics",className:"h-12 w-full rounded-full border border-brand-navy/10 bg-white pl-11 pr-12 font-body text-sm text-brand-navy outline-none transition focus:border-brand-yellow focus:ring-2 focus:ring-brand-yellow/35 dark:border-white/12 dark:bg-white/10 dark:text-brand-cloud","aria-label":"Search public episodes"}),(0,u.jsxs)("div",{className:"absolute right-3 top-1/2 flex -translate-y-1/2 items-center gap-1",children:[G&&(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin text-brand-navy/45 dark:text-brand-cloud/45"}),L&&!G&&(0,u.jsx)("button",{type:"button",onClick:()=>R(""),className:"inline-flex h-8 w-8 items-center justify-center rounded-full text-brand-navy/52 transition hover:bg-brand-navy/6 hover:text-brand-navy dark:text-brand-cloud/52 dark:hover:bg-white/10 dark:hover:text-brand-cloud","aria-label":"Clear episode search",children:(0,u.jsx)(Pu,{className:"h-4 w-4"})})]})]}),(0,u.jsxs)("div",{className:"flex flex-col gap-1 text-sm text-brand-navy
2/62 dark:text-brand-cloud/68 lg:max-w-sm lg:text-right",children:[(0,u.jsx)("p",{children:"Search the public archive by title, speaker names, transcript text, and indexed topics."}),(0,u.jsx)("p",{className:"text-xs uppercase tracking-[0.22em] text-brand-navy/45 dark:text-brand-cloud/48",children:ge?"".concat(H," result").concat(1===H?"":"s",' for "').concat(pe,'"'):"Type at least 2 characters"})]})]}),$&&(0,u.jsx)("p",{className:"mt-3 text-sm text-[#9f4b00] dark:text-brand-yellow",children:$})]}),ge&&G?(0,u.jsxs)("div",{className:"brand-card mt-8 p-10 text-center",children:[(0,u.jsx)(Lo,{className:"mx-auto h-8 w-8 animate-spin text-brand-yellow"}),(0,u.jsxs)("p",{className:"mt-4 text-sm leading-7 text-brand-navy/70 dark:text-brand-cloud/72",children:['Searching the archive for "',pe,'"...']})]}):ye?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"mt-8 grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3",children:(0,u.jsx)(S,{children:k?x.map((e,t)=>{return(0,u.jsx)(Do.article,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{delay:.04*t},className:"group h-full",onClick:()=>se(e),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),se(e))},role:"button",tabIndex:0,children:(0,u.jsxs)("div",{className:"brand-card brand-card-muted flex h-full flex-col overflow-hidden transition duration-300 group-hover:-translate-y-1.5 group-hover:shadow-brand-lg",children:[(0,u.jsxs)("div",{className:"relative aspect-[16/10] overflow-hidden bg-brand-navy/10",children:[e.thumbnailUrl?(0,u.jsx)("img",{src:(n=e.sessionId,cN(n)),alt:e.title,className:"h-full w-full object-cover transition duration-500 group-hover:scale-105",loading:"lazy"}):(0,u.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-brand-navy/12",children:(0,u.jsx)(Au,{className:"h-14 w-14 text-brand-navy/32"})}),(0,u.jsx)("div",{className:"absolute inset-0 brand-scrim transition-opacity duration-300 group-hover:opacity-95"}),(0,u.jsx)("div",{className:"absolute inset-0 brand-thumbnail-grain transition-opacity duration-300 group-hover:opacity-100"}),(0,u.jsxs)("div",{className:"absolute left-4 top-4 flex items-center gap-2",children:[(0,u.jsx)("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full bg-brand-yellow text-brand-navy shadow-[0_16px_26px_-22px_rgba(255,181,43,0.95)]",children:(0,u.jsx)(Au,{className:"h-4 w-4"})}),(0,u.jsx)("span",{className:"rounded-full bg-white/92 px-3 py-1 font-headlines text-[0.62rem] font-bold uppercase tracking-[0.22em] text-brand-navy",children:"Saved Offline"})]}
2),(0,u.jsx)("div",{className:"absolute right-4 top-4 rounded-full bg-white/92 px-4 py-2 font-headlines text-[0.68rem] font-bold uppercase tracking-[0.24em] text-brand-navy opacity-0 transition duration-300 group-hover:opacity-100",children:"Open"}),(0,u.jsxs)("div",{className:"absolute inset-x-0 bottom-0 p-5",children:[(0,u.jsx)("h3",{className:"line-clamp-2 font-headlines text-2xl font-bold leading-tight text-brand-cloud",children:e.title}),(0,u.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-[0.7rem] font-headlines uppercase tracking-[0.28em] text-white/72",children:[(0,u.jsx)(mj,{className:"h-3.5 w-3.5"}),ie(e.savedAt)]})]})]}),(0,u.jsxs)("div",{className:"flex flex-1 flex-col p-5 sm:p-6",children:[(0,u.jsx)("p",{className:"line-clamp-4 text-sm leading-7 text-brand-navy/68 dark:text-brand-cloud/74",children:e.descriptionPreview||e.transcriptPreview||"Transcript, description, comments, and audio are available offline on this device."}),(0,u.jsxs)("div",{className:"mt-6 flex items-center justify-between gap-3",children:[(0,u.jsx)("span",{className:"text-xs uppercase tracking-[0.2em] text-brand-navy/45 dark:text-brand-cloud/48",children:e.duration>0?"".concat(Math.round(e.duration/60)," min"):"Transcript only"}),(0,u.jsxs)("span",{className:"inline-flex items-center gap-2 font-headlines text-[0.72rem] font-bold uppercase tracking-[0.24em] text-[#A36A00] dark:text-brand-yellow",children:["Open session",(0,u.jsx)(lj,{className:"h-4 w-4"})]})]})]})]})},e.sessionId);var n}):xe.map((e,t)=>(0,u.jsx)(Do.article,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{delay:t%20*.04},className:"group h-full",onClick:()=>re(e.shareToken),onKeyDown:t=>((e,t)=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),re(t))})(t,e.shareToken),role:"button",tabIndex:0,children:(0,u.jsxs)("div",{className:"brand-card brand-card-muted flex h-full flex-col overflow-hidden transition duration-300 group-hover:-translate-y-1.5 group-hover:shadow-brand-lg",children:[(0,u.jsxs)("div",{className:"relative aspect-[16/10] overflow-hidden bg-brand-navy/10",children:[e.thumbnailUrl&&!N.has(e.shareToken)?(0,u.jsx)("img",{src:e.thumbnailUrl,alt:e.title,className:"h-full w-full object-cover transition duration-500 group-hover:scale-105",loading:"lazy",onError:t=>le(t,e)}):(0,u.jsx)("div",{className:"flex h-full w-full items-center justify-center bg-brand-navy/12",children:(0,u.jsx)(Au,{className:"h-14 w-14 text-brand-navy/32"})}),(0,u.jsx)("div",{className:"absolute inset-0 brand-scrim transition-opacity duration-300 group-hover:opacity-95"}),(0,u.jsx)("div",{className:"absolute inset-0 brand-thumbnail-grain transition-opacity duration-300 group-hover:opacity-100"}),(0,u.jsxs)("div",{className:"absolute left-4 top-4 flex items-center gap-2",children:[(0,u.jsx)("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full bg-brand-yellow text-brand-navy shadow-[0_16px_26px_-22px_rgba(255,181,43,0.95)]",children:e.youtubeUrl?(0,u.jsx)(Au,{className:"h-4 w-4"}):(0,u.jsx)(uj,{className:"h-4 w-4"})}),(0,u.jsx)("span",{className:"rounded-full bg-white/92 px-3 py-1 font-headlines text-[0.62rem] font-bold uppercase tracking-[0.22em] text-brand-navy",children:e.youtubeUrl?"YouTube":"Hosted"}),he.has(e.sessionId)&&(0,u.jsx)("span",{className:"rounded-full bg-white/92 px-3 py-1 font-headlines text-[0.62rem] font-bold uppercase tracking-[0.22em] text-brand-navy",children:"Saved Offline"})]}
2),(0,u.jsx)("div",{className:"absolute right-4 top-4 rounded-full bg-white/92 px-4 py-2 font-headlines text-[0.68rem] font-bold uppercase tracking-[0.24em] text-brand-navy opacity-0 transition duration-300 group-hover:opacity-100",children:"Open"}),(0,u.jsxs)("div",{className:"absolute inset-x-0 bottom-0 p-5",children:[(0,u.jsx)("h3",{className:"line-clamp-2 font-headlines text-2xl font-bold leading-tight text-brand-cloud",children:e.title}),(0,u.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-[0.7rem] font-headlines uppercase tracking-[0.28em] text-white/72",children:[(0,u.jsx)(mj,{className:"h-3.5 w-3.5"}),oe(e)]})]})]}),(0,u.jsxs)("div",{className:"flex flex-1 flex-col p-5 sm:p-6",children:[(0,u.jsx)("p",{className:"line-clamp-3 text-sm leading-7 text-brand-navy/68 dark:text-brand-cloud/74",children:ge&&e.searchPreview||oU(e.description,165)}),(0,u.jsx)("div",{className:"mt-6 flex flex-wrap items-center justify-end gap-2",children:(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("a",{href:"".concat(aU,"/api/public/sessions/").concat(e.sessionId,"/pdf"),onClick:e=>e.stopPropagation(),className:"inline-flex h-11 w-11 items-center justify-center rounded-full border border-brand-navy/10 bg-white px-2 py-2 transition duration-200 hover:-translate-y-0.5 hover:border-brand-navy/20 hover:shadow-brand dark:border-white/12 dark:bg-white/10",title:e.hasPdf?"Download PDF transcript":"Generate and download PDF transcript","aria-label":e.hasPdf?"Download PDF transcript":"Generate and download PDF transcript",target:"_blank",rel:"noopener noreferrer",children:(0,u.jsx)(mO,{isDarkMode:r,className:"h-8 w-8"})}),e.description&&(0,u.jsxs)("button",{onClick:t=>{t.stopPropagation(),P(e)},className:"inline-flex items-center gap-2 rounded-full border border-brand-navy/10 bg-white px-3 py-2 font-headlines text-[0.68rem] font-bold uppercase tracking-[0.24em] text-brand-navy transition duration-200 hover:-translate-y-0.5 hover:border-brand-navy/20 hover:shadow-brand dark:border-white/12 dark:bg-white/10 dark:text-brand-cloud dark:hover:border-white/20",title:"View description",children:[(0,u.jsx)(gp,{className:"h-3.5 w-3.5"}),(0,u.jsx)("span",{className:"hidden sm:inline",children:"Notes"})]})]})}),e.description&&(0,u.jsx)("div",{className:"sr-only","aria-hidden":"false",children:(0,u.jsxs)("section",{children:[(0,u.jsx)("h4",{children:"Description"}),(0,u.jsx)("p",{children:e.description})]})})]})]})},e.shareToken))})}),(0,u.jsx)("div",{ref:Z,className:"h-1","aria-hidden":"true"}),be&&(0,u.jsx)("div",{className:"mt-8 flex justify-center",children:(0,u.jsx)(Lo,{className:"h-7 w-7 animate-spin text-brand-yellow"})}),!fe&&xe.length>0&&!b&&!G&&(0,u.jsx)("p",{className:"mt-8 text-center text-xs uppercase tracking-[0.24em] text-brand-navy/40 dark:text-brand-cloud/40",children:"All episodes loaded"})]}):(0,u.jsxs)("div",{className:"brand-card mt-8 p-10 text-center",children:[(0,u.jsx)(Au,{className:"mx-auto h-12 w-12 text-brand-navy/35"}),(0,u.jsx)("h3",{className:"brand-highlight-text mt-6 font-headlines text-2xl font-bold tracking-tight",children:k?"No sessions saved offline yet":ge?"No public episodes matched":"No public episodes yet"}),(0,u.jsx)("p",{className:"mt-3 text-base leading-8 text-brand-navy/65 dark:text-brand-cloud/72",children:k?"Open a public share while online and use the save offline action to keep its transcript, comments, description, and audio on this device.":ge?'Try a broader query or search for a speaker, transcript phrase, or topic instead of "'.concat(pe,'".'):"The archive is empty for now. Check back soon for the next transcript release."})]})]}),(0,u.jsxs)("footer",{className:"mt-16",children:[(0,u.jsx)("div",{className:"brand-divider"}),(0,u.jsxs)("div",{className:"flex flex-col gap-3 py-8 text-sm text-[#B57700] dark:text-brand-yellow sm:flex-row sm:items-center sm:justify-between",children:[(0,u.jsx)("p",{children:"Interested in licensing ReScript for your podcast or research archive?"}),(0,u.jsx)("a",{href:"mailto:".concat(iU),className:"brand-link font-headlines text-[0.78rem] uppercase tracking-[0.28em] text-[#C98A00] dark:text-brand-yellow",children:iU})]})]})]})]}),E&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[#171d29]/72 p-4 backdrop-blur-sm",children:(0,u.jsx)(Do.div,{initial:{opacity:0,y:16,scale:.98}
2,animate:{opacity:1,y:0,scale:1},className:"brand-card w-full max-w-4xl overflow-hidden",children:(0,u.jsxs)("div",{className:"grid gap-0 md:grid-cols-[0.95fr_1.05fr]",children:[(0,u.jsxs)("div",{className:"bg-brand-navy px-6 py-8 text-brand-cloud sm:px-8 sm:py-10",children:[(0,u.jsx)("button",{onClick:()=>A(!1),className:"ml-auto flex rounded-full border border-white/10 p-2 text-brand-cloud/70 transition duration-200 hover:border-white/20 hover:text-brand-cloud",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})}),(0,u.jsx)("div",{className:"mt-8",children:(0,u.jsx)(dU,{inverted:!0})}),(0,u.jsx)("p",{className:"mt-8 brand-kicker border-white/15 bg-white/10 text-brand-cloud",children:"Member Access"}),(0,u.jsx)("h2",{className:"mt-6 font-headlines text-4xl font-bold tracking-tight text-brand-cloud",children:"Sign in for the full MLST workspace."}),(0,u.jsx)("p",{className:"mt-4 text-base leading-8 text-brand-cloud/72",children:"Google sign-in unlocks the private workflow: organization access, editing tools, and the full ReScript surface beyond the public transcript archive."})]}),(0,u.jsxs)("div",{className:"bg-white p-6 sm:p-8 md:p-10 dark:bg-[#162232]/[0.94]",children:[(0,u.jsx)("p",{className:"brand-kicker",children:"Authentication"}),(0,u.jsx)("h3",{className:"brand-highlight-text mt-6 font-headlines text-3xl font-bold tracking-tight",children:"Continue with Google"}),(0,u.jsx)("p",{className:"mt-4 text-base leading-8 text-brand-navy/68 dark:text-brand-cloud/72",children:"Use the same Google account your organization admin has approved for access."}),T&&(0,u.jsx)("div",{className:"mt-6 rounded-[1.25rem] border border-red-300/70 bg-red-50 px-4 py-3 text-sm text-red-700",children:T}),(0,u.jsx)("div",{className:"mt-8 flex flex-col items-start gap-4",children:_?(0,u.jsxs)("div",{className:"flex items-center gap-3 rounded-full border border-brand-navy/10 bg-white px-5 py-3 text-sm text-brand-navy/70 dark:border-white/12 dark:bg-white/10 dark:text-brand-cloud/76",children:[(0,u.jsx)(Lo,{className:"h-5 w-5 animate-spin"}),"Authenticating..."]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Zk,{onSuccess:async e=>{const a=e.credential;if(a)try{B(!0),M(null);const e=await fetch("".concat(aU,"/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({idToken:a})});if(!e.ok){const t=await e.json();throw new Error(t.error||"Login failed")}const r=await e.json();await n(r.accessProfile||null),A(!1),t("/")}catch(r){M(r instanceof Error?r.message:"Login failed")}finally{B(!1)}else M("No token received from Google")},onError:()=>M("Google authentication failed"),theme:"outline",shape:"pill",size:"large",text:"continue_with",logo_alignment:"left"}),i&&(0,u.jsx)("button",{onClick:async()=>{try{B(!0),M(null);const e=await fetch("".concat(aU,"/api/auth/dev-login"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"});if(!e.ok)throw new Error("Dev login failed");const a=await e.json();await n(a.accessProfile||null),A(!1),t("/")}catch(e){M(e instanceof Error?e.message:"Dev login failed")}finally{B(!1)}},className:"brand-button-secondary",children:"Dev login"})]})})]})]})})}),I&&(0,u.jsx)("div",{className:"fixed inset-0 z-50 flex items-start justify-center overflow-hidden bg-[#232E3F]/38 backdrop-blur-sm dark:bg-[#171d29]/72 sm:items-center",style:{paddingTop:"calc(env(safe-area-inset-top, 0px) + 1rem)",paddingRight:"calc(env(safe-area-inset-right, 0px) + 1rem)",paddingBottom:"calc(env(safe-area-inset-bottom, 0px) + 1rem)",paddingLeft:"calc(env(safe-area-inset-left, 0px) + 1rem)"},onClick:()=>P(null),children:(0,u.jsxs)(Do.div,{initial:{opacity:0,y:16,scale:.98},animate:{opacity:1,y:0,scale:1},className:"brand-card flex max-h-full w-full max-w-3xl flex-col overflow-hidden bg-[linear-gradient(180deg,rgba(255,255,255,0.98),rgba(255,245,222,0.94))] text-brand-navy dark:border-white/10 dark:bg-brand-navy dark:text-brand-cloud",style:{maxHeight:"calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 2rem)"},onClick:e=>e.stopPropagation(),children:[(0,u.jsxs)("div",{className:"flex shrink-0 items-start justify-between gap-4 border-b border-brand-navy
2/10 px-5 py-5 dark:border-white/10 sm:px-8 sm:py-6",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"brand-kicker border-[#E4D4AB] bg-[#FFF3D6] text-[#7C5A0C] dark:border-white/15 dark:bg-white/10 dark:text-brand-cloud",children:"Episode Note"}),(0,u.jsx)("h2",{className:"mt-4 pr-3 font-headlines text-2xl font-bold tracking-tight text-[#232E3F] dark:text-brand-yellow sm:pr-6 sm:text-3xl",children:I.title}),(0,u.jsx)("p",{className:"mt-3 text-sm uppercase tracking-[0.24em] text-brand-navy/48 dark:text-brand-cloud/55",children:oe(I)})]}),(0,u.jsx)("button",{onClick:()=>P(null),className:"rounded-full border border-brand-navy/10 p-2 text-brand-navy/55 transition duration-200 hover:border-brand-navy/20 hover:text-brand-navy dark:border-white/10 dark:text-brand-cloud/70 dark:hover:border-white/20 dark:hover:text-brand-cloud",children:(0,u.jsx)(Pu,{className:"h-5 w-5"})})]}),(0,u.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-5 sm:px-8 sm:py-6",children:I.description?(0,u.jsx)("div",{className:je,children:(0,u.jsx)(my,{children:I.description})}):(0,u.jsx)("p",{className:"py-8 text-center text-brand-navy/55 dark:text-brand-cloud/60",children:"No description available for this episode."})}),(0,u.jsx)("div",{className:"shrink-0 border-t border-brand-navy/10 bg-brand-navy/[0.03] px-5 py-4 dark:border-white/10 dark:bg-white/[0.04] sm:px-8",children:(0,u.jsxs)("button",{onClick:()=>{P(null),re(I.shareToken)},className:"brand-button-primary w-full",children:[(0,u.jsx)(Ep,{className:"h-4 w-4"}),"View full transcript"]})})]})})]}):(0,u.jsx)("div",{className:ve,children:(0,u.jsx)("div",{className:"relative z-10 flex min-h-screen items-center justify-center px-4 py-16 sm:px-6",children:(0,u.jsxs)("div",{className:"brand-card w-full max-w-xl p-8 text-center sm:p-10",children:[(0,u.jsx)("div",{className:"mx-auto mb-8 flex justify-center",children:(0,u.jsx)(dU,{})}),(0,u.jsxs)("p",{className:"brand-kicker",children:[(0,u.jsx)(Po,{className:"h-3.5 w-3.5"}),"Archive Status"]}),(0,u.jsx)("h1",{className:"mt-6 font-headlines text-4xl font-bold tracking-tight text-brand-navy dark:text-brand-cloud sm:text-5xl",children:"The public archive did not load"}),(0,u.jsx)("p",{className:"mt-4 text-base leading-8 text-brand-navy/68 dark:text-brand-cloud/72 sm:text-lg",children:D}),(0,u.jsx)("div",{className:"mt-8 flex justify-center",children:(0,u.jsxs)("button",{onClick:()=>{te()},className:"brand-button-primary",children:["Try again",(0,u.jsx)(lj,{className:"h-4 w-4"})]})})]})})}):(0,u.jsx)("div",{className:ve,children:(0,u.jsx)("div",{className:"relative z-10 flex min-h-screen items-center justify-center px-4 py-16 sm:px-6",children:(0,u.jsxs)("div",{className:"brand-card w-full max-w-xl p-8 text-center sm:p-10",children:[(0,u.jsx)("div",{className:"mx-auto mb-8 flex justify-center",children:(0,u.jsx)(dU,{})}),(0,u.jsx)("div",{className:"mx-auto brand-spinner"}),(0,u.jsx)("h1",{className:"mt-8 font-headlines text-4xl font-bold tracking-tight text-brand-navy dark:text-brand-cloud sm:text-5xl",children:"Loading the archive"}),(0,u.jsx)("p",{className:"mt-4 text-base leading-8 text-brand-navy/68 dark:text-brand-cloud/72 sm:text-lg",children:"Pulling the latest MLST transcript editions and support materials."})]})})})},mU=Mo("user-x",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);nR.register(pz,bz,yR,fR,JR,uz,KR,qR);const hU=e=>{let{comment:t,isDarkMode:n,isBanned:a,formatTimeAgo:r,formatTimestamp:s,onDelete:i,onBan:o,onBanUser:l,onNavigate:c,isNested:d=!1}=e;return(0,u.jsx)("div",{className:"p-4 ".concat(d?"pl-12":""," hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"),children:(0,u.jsxs)("div",{className:"flex items-start justify-between",children:[(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-2 mb-1",children:[(0,u.jsx)("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:t.author_name}),!!t.is_pinned&&(0,u.jsx)("span",{className:"px-1.5 py-0.5 text-xs bg-yellow-100 dark:bg-yellow-900/50 text-yellow-700 dark:text-yellow-300 rounded",children:"Pinned"}),a&&(0,u.jsx)("span",{className:"px-1.5 py-0.5 text-xs bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300 rounded",children:"Banned IP"}),(0,u.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:r(t.created_at)}),t.ip_address&&(0,u.jsx)("span",{className:"text-xs font-mono text-gray-400 dark:text-gray-500",children:t.ip_address})]}),(0,u.jsx)("p",{className:"text-gray-700 dark:text-gray-300 text-sm mb-2",children:t.content}),(0,u.jsxs)("div",{className:"flex items-center space-x-3 text-xs text-gray-500 dark:text-gray-400",children:[(0,u.jsxs)("button",{onClick:c,className:"flex items-center space-x-1 transition-colors hover:text-[#B57700] dark:hover:text-[#FFCF74]",children:[(0,u.jsx)(lj,{size:12}),(0,u.jsx)("span",{className:"truncate max-w-[200px]",children:t.session_title})]}),(0,u.jsxs)("span",{className:"flex items-center space-x-1",children:[(0,u.jsx)(wp,{size:12}),(0,u.jsxs)("span",{children:["@ ",s(t.timestamp_seconds)]})]})]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-1 ml-4",children:[!!t.is_anonymous&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:l,className:"p-1.5 text-gray-400 hover:text-red-600 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",title:"Ban user (delete all c
2omments + ban IPs)",children:(0,u.jsx)(mU,{size:14})}),t.ip_address&&!a&&(0,u.jsx)("button",{onClick:o,className:"p-1.5 text-gray-400 hover:text-orange-600 dark:hover:text-orange-400 hover:bg-orange-50 dark:hover:bg-orange-900/20 rounded transition-colors",title:"Ban this IP only",children:(0,u.jsx)(Tj,{size:14})})]}),(0,u.jsx)("button",{onClick:i,className:"p-1.5 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors",title:"Delete this comment",children:(0,u.jsx)(kp,{size:14})})]})]})})},pU=()=>{const e=oc(),{token:t,user:n,logout:r}=am(),{isDarkMode:s,toggleDarkMode:i}=zu(),[o,l]=(0,a.useState)([]),[c,d]=(0,a.useState)([]),[m,h]=(0,a.useState)([]),[p,g]=(0,a.useState)(!0),[x,f]=(0,a.useState)(!0),[b,y]=(0,a.useState)(null),[v,w]=(0,a.useState)(""),[k,j]=(0,a.useState)("username"),[D,C]=(0,a.useState)("30d"),[N,F]=(0,a.useState)(!1),[E,A]=(0,a.useState)(!1),[T,M]=(0,a.useState)(!1),[_,B]=(0,a.useState)(!1),[I,P]=(0,a.useState)(!1),[L,R]=(0,a.useState)(null),[z,O]=(0,a.useState)(null),[U,V]=(0,a.useState)(null),[H,q]=(0,a.useState)(""),[W,Y]=(0,a.useState)(!1),[G,K]=(0,a.useState)(!1),[X,J]=(0,a.useState)(new Set),$=(0,a.useCallback)(async()=>{if(t)try{g(!0),y(null);const e=new URLSearchParams;v&&e.append("search",v),"all"!==D&&e.append("days",D.replace("d",""));const n=await fetch("".concat("","/api/admin/comments?").concat(e),{headers:{Authorization:"Bearer ".concat(t)}});if(!n.ok)throw new Error("Failed to load comments");const a=await n.json();l(a.comments)}catch(e){y("Failed to load comments"),console.error(e)}finally{g(!1)}},[t,v,D]),Q=(0,a.useCallback)(async()=>{if(t)try{f(!0);const e=new URLSearchParams;"all"!==D&&e.append("days",D.replace("d",""));const n=await fetch("".concat("","/api/admin/comments-stats?").concat(e),{headers:{Authorization:"Bearer ".concat(t)}});if(!n.ok)throw new Error("Failed to load stats");const a=await n.json();d(a.dailyStats)}catch(e){console.error("Failed to load stats:",e)}finally{f(!1)}},[t,D]),Z=(0,a.useCallback)(async()=>
2{if(t)try{const e=await fetch("/api/admin/banned-ips",{headers:{Authorization:"Bearer ".concat(t)}});if(!e.ok)throw new Error("Failed to load banned IPs");const n=await e.json();h(n.bannedIPs)}catch(e){console.error("Failed to load banned IPs:",e)}},[t]);(0,a.useEffect)(()=>{$(),Q(),Z()},[$,Q,Z]);const ee=(0,a.useMemo)(()=>{if("none"===k)return null;const e=new Map;return o.forEach(t=>{let n,a;"username"===k?(n="user_".concat(t.author_name),a=t.author_name):(n="ip_".concat(t.ip_address||"unknown"),a=t.ip_address||"Unknown IP"),e.has(n)||e.set(n,{key:n,type:k,value:a,count:0,comments:[],sessions:new Set,latestComment:t.created_at,expanded:X.has(n)});const r=e.get(n);r.count++,r.comments.push(t),r.sessions.add(t.session_id),new Date(t.created_at)>new Date(r.latestComment)&&(r.latestComment=t.created_at)}),Array.from(e.values()).sort((e,t)=>t.count-e.count)},[o,k,X]),te=e=>{const t=new Date(e),n=(new Date).getTime()-t.getTime(),a=Math.floor(n/6e4),r=Math.floor(a/60),s=Math.floor(r/24);return a<1?"just now":a<60?"".concat(a,"m ago"):r<24?"".concat(r,"h ago"):s<7?"".concat(s,"d ago"):t.toLocaleDateString()},ne=e=>{const t=Math.floor(e/60),n=Math.floor(e%60);return"".concat(t,":").concat(n.toString().padStart(2,"0"))},ae=e=>!!e&&m.some(t=>t.ip_address===e),re=(0,a.useMemo)(()=>({labels:(c||[]).map(e=>new Date(e.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})),datasets:[{label:"Comments",data:(c||[]).map(e=>e.count),fill:!0,borderColor:s?"rgb(147, 51, 234)":"rgb(124, 58, 237)",backgroundColor:s?"rgba(147, 51, 234, 0.1)":"rgba(124, 58, 237, 0.1)",tension:.4,pointRadius:3,pointHoverRadius:6}]}),[c,s]),se={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{backgroundColor:s?"rgb(31, 41, 55)":"rgb(255, 255, 255)",titleColor:s?"rgb(229, 231, 235)":"rgb(17, 24, 39)",bodyColor:s?"rgb(156, 163, 175)":"rgb(107, 114, 128)",borderColor:s?"rgb(55, 65, 81)":"rgb(229, 231, 235)",borderWidth:1}},scales:{x:{grid:{color:s?"rgba(75, 85, 99, 0.3)":"rgba(229, 231, 235, 0.8)"},ticks:{color:s?"rgb(156, 163, 175)":"rgb(107, 114, 128)"}},y:{beginAtZero:!0,grid:{color:s?"rgba(75, 85, 99, 0.3)":"rgba(229, 231, 235, 0.8)"},ticks:{color:s?"rgb(156, 163, 175)":"rgb(107, 114, 128)",stepSize:1}}}};return t&&n?(0,u.jsxs)("div",{className:"h-screen flex flex-col bg-gray-50 dark:bg-gray-900 text-gray-800 dark:text-gray-200 transition-colors",children:[(0,u.jsx)(sT,{isDarkMode:s,toggleDarkMode:i,userName:null===n||void 0===n?void 0:n.name,userEmail:null===n||void 0===n?void 0:n.email,userPicture:null===n||void 0===n?void 0:n.picture,onLogout:()=>{r()},onHome:()=>e("/"),token:t||void 0}),(0,u.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,u.jsxs)("div",{className:"max-w-6xl mx-auto px-4 py-6",children:[(0,u.jsx)(Do.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},className:"mb-6",children:(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"rounded-lg bg-gradient-to-br from-[#EEF1F3] to-[#FFF4D8] p-2 dark:from-[#232E3F] dark:to-[#332A17]",children:(0,u.jsx)(Fp,{size:24,className:"text-[#232E3F] dark:text-[#FFCF74]"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"Comments Explorer"}),(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Manage and monitor public comments across all sessions"})]})]}),(0,u.jsxs)("button",{onClick:()=>e("/"),className:"flex items-center space-x-2 px-4 py-2 bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",children:[(0,u.jsx)(Io,{size:18}),(0,u.jsx)("span",{children:"Back to Home"})]})]})}),(0,u.jsxs)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.1},className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[(0,u.jsx)("div",{className:"p-4 rounded-xl border ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"rounded-lg bg-[#EEF1F3] dark:bg-[#232E3F]/60 p-2",children:(0,u.jsx)(Fp,{size:20,className:"text-[#232E3F] dark:text-[#FFCF74]"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:o.length}),(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Total Comments"})]})]})}),(0,u.jsx)("div",{className:"p-4 rounded-xl border ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"rounded-lg bg-[#FFF4D8] dark:bg-[#332A17] p-2",children:(0,u.jsx)(fh,{size:20,className:"text-[#B57700] dark:text-[#FFE3A1]"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:new Set(o.map(e=>e.author_name)).size}),(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Unique Users"})]})]})}),(0,u.jsx)("div",{className:"p-4 rounded-xl border ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"rounded-lg bg-[#EEF1F3] dark:bg-[#232E3F]/60 p-2",children:(0,u.jsx)(bj,{size:20,className:"text-[#232E3F] dark:text-[#FFCF74]"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:new Set(o.map(e=>
2e.ip_address).filter(Boolean)).size}),(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Unique IPs"})]})]})}),(0,u.jsx)("div",{className:"p-4 rounded-xl border ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"p-2 bg-red-100 dark:bg-red-900/50 rounded-lg",children:(0,u.jsx)(Tj,{size:20,className:"text-red-600 dark:text-red-400"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:m.length}),(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Banned IPs"})]})]})})]}),(0,u.jsxs)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.2},className:"p-6 rounded-xl border mb-6 ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)(YE,{size:20,className:"text-[#B57700] dark:text-[#FFCF74]"}),(0,u.jsx)("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Comments Over Time"})]}),(0,u.jsx)("div",{className:"flex items-center space-x-2",children:["7d","30d","90d","all"].map(e=>(0,u.jsx)("button",{onClick:()=>C(e),className:"px-3 py-1.5 text-sm rounded-lg transition-colors ".concat(D===e?"bg-[#232E3F] text-[#F4F4F4] dark:bg-[#1B2534] dark:text-[#FFE3A1]":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700"),children:"all"===e?"All Time":e},e))})]}),(0,u.jsx)("div",{className:"h-64",children:x?(0,u.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,u.jsx)(Lo,{className:"animate-spin h-8 w-8 text-[#FFB52B]"})}):((null===c||void 0===c?void 0:c.length)||0)>0?(0,u.jsx)(eO,{data:re,options:se}):(0,u.jsx)("div",{className:"flex items-center justify-center h-full text-gray-500 dark:text-gray-400",children:"No data available for the selected period"})})]}),(0,u.jsx)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.3},className:"p-4 rounded-xl border mb-6 ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,u.jsxs)("div",{className:"relative flex-1 min-w-[200px]",children:[(0,u.jsx)(Mu,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,u.jsx)("input",{type:"text",placeholder:"Search comments, users, or sessions...",value:v,onChange:e=>w(e.target.value),className:"w-full pl-10 pr-4 py-2 border rounded-lg ".concat(s?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-500"," focus:ring-2 focus:ring-[#FFB52B]/35 focus:border-[#FFB52B]")})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)(hj,{size:16,className:"text-gray-400"}),(0,u.jsx)("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Group by:"}),(0,u.jsxs)("select",{value:k,onChange:e=>j(e.target.value),className:"px-3 py-2 border rounded-lg ".concat(s?"bg-gray-700 border-gray-600 text-gray-100":"bg-white border-gray-300 text-gray-900"),children:[(0,u.jsx)("option",{value:"username",children:"Username"}),(0,u.jsx)("option",{value:"ip",children:"IP Address"}),(0,u.jsx)("option",{value:"none",children:"No Grouping"})]})]}),(0,u.jsxs)("button",{onClick:()=>{$(),Q()},disabled:p,className:"flex items-center space-x-2 px-4 py-2 rounded-lg transition-colors ".concat(s?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"),children:[(0,u.jsx)(vp,{size:16,className:p?"animate-spin":""}),(0,u.jsx)("span",{children:"Refresh"})]}),(0,u.jsxs)("button",{onClick:()=>F(!N),className:"flex items-center space-x-2 px-4 py-2 rounded-lg transition-colors ".concat(N?"bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300":s?"bg-gray-700 hover:bg-gray-600 text-gray-300":"bg-gray-100 hover:bg-gray-200 text-gray-700"),children:[(0,u.jsx)(FA,{size:16}),(0,u.jsxs)("span",{children:["Banned IPs (",m.length,")"]})]})]})}),(0,u.jsx)(S,{children:N&&m.length>0&&(0,u.jsxs)(Do.div,{initial:{opacity:0,height:0}
2,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"rounded-xl border mb-6 overflow-hidden ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:[(0,u.jsx)("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)(Tj,{size:18,className:"text-red-500"}),(0,u.jsx)("h3",{className:"font-semibold text-gray-900 dark:text-gray-100",children:"Banned IP Addresses"})]})}),(0,u.jsx)("div",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:m.map(e=>(0,u.jsxs)("div",{className:"p-4 flex items-center justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("span",{className:"font-mono text-sm text-gray-900 dark:text-gray-100",children:e.ip_address}),e.reason&&(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:e.reason}),(0,u.jsxs)("p",{className:"text-xs text-gray-500 dark:text-gray-500 mt-1",children:["Banned ",te(e.created_at),e.banned_by&&" by ".concat(e.banned_by)]})]}),(0,u.jsxs)("button",{onClick:()=>{O(e.ip_address),P(!0)},className:"flex items-center space-x-1 rounded-lg px-3 py-1.5 text-sm text-[#B57700] transition-colors hover:bg-[#FFF4D8] dark:text-[#FFCF74] dark:hover:bg-[#332A17]/70",children:[(0,u.jsx)(gh,{size:14}),(0,u.jsx)("span",{children:"Unban"})]})]},e.id))})]})}),(0,u.jsx)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.4},className:"rounded-xl border overflow-hidden ".concat(s?"bg-gray-800 border-gray-700":"bg-white border-gray-200"),children:p?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)(Lo,{className:"animate-spin h-8 w-8 text-[#FFB52B]"})}):b?(0,u.jsxs)("div",{className:"text-center py-12",children:[(0,u.jsx)(fp,{className:"mx-auto h-12 w-12 text-red-500 mb-4"}),(0,u.jsx)("p",{className:"text-red-600 dark:text-red-400",children:b}),(0,u.jsx)("button",{onClick:$,className:"mt-4 px-4 py-2 text-[#B57700] hover:underline dark:text-[#FFCF74]",children:"Try again"})]}):0===o.length?(0,u.jsxs)("div",{className:"text-center py-12",children:[(0,u.jsx)(Fp,{className:"mx-auto h-12 w-12 text-gray-400 mb-4"}),(0,u.jsx)("p",{className:"text-gray-600 dark:text-gray-400",children:"No comments found"})]}):"none"===k?(0,u.jsx)("div",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:o.map(t=>(0,u.jsx)(hU,{comment:t,isDarkMode:s,isBanned:ae(t.ip_address),formatTimeAgo:te,formatTimestamp:ne,onDelete:()=>{R(t),A(!0)},onBan:()=>{O(t.ip_address),M(!0)},onBanUser:()=>{V(t.author_name),B(!0)},onNavigate:()=>e("/session/".concat(t.session_id))},t.id))}):(0,u.jsx)("div",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:null===ee||void 0===ee?void 0:ee.map(t=>(0,u.jsxs)("div",{children:[(0,u.jsxs)("button",{onClick:()=>{return e=t.key,void J(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e},className:"w-full p-4 flex items-center justify-between hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:["username"===t.type?(0,u.jsx)(fh,{size:18,className:"text-gray-400"}):(0,u.jsx)(bj,{size:18,className:"text-gray-400"}),(0,u.jsx)("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:t.value}),"ip"===t.type&&ae("Unknown IP"!==t.value?t.value:null)&&(0,u.jsx)("span",{className:"px-2 py-0.5 text-xs bg-red-100 dark:bg-red-900/50 text-red-700 dark:text-red-300 rounded-full",children:"Banned"}),(0,u.jsxs)("span",{className:"rounded-full bg-[#EEF1F3] px-2 py-0.5 text-xs text-[#232E3F] dark:bg-[#232E3F] dark:text-[#FFE3A1]",children:[t.count," comment",1!==t.count?"s":""]}),(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["across ",t.sessions.size," session",1!==t.sessions.size?"s":""]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsxs)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Latest: ",te(t.latestComment)]}),X.has(t.key)?(0,u.jsx)(Tu,{size:18,className:"text-gray-400"}):(0,u.jsx)(wd,{size:18,className:"text-gray-400"})]})]}),(0,u.jsx)(S,{children:X.has(t.key)&&(0,u.jsx)(Do.div,{initial:{opacity:0,height:0}
2,animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"".concat(s?"bg-gray-900/50":"bg-gray-50"),children:t.comments.map(t=>(0,u.jsx)(hU,{comment:t,isDarkMode:s,isBanned:ae(t.ip_address),formatTimeAgo:te,formatTimestamp:ne,onDelete:()=>{R(t),A(!0)},onBan:()=>{O(t.ip_address),M(!0)},onBanUser:()=>{V(t.author_name),B(!0)},onNavigate:()=>e("/session/".concat(t.session_id)),isNested:!0},t.id))})})]},t.key))})})]})}),(0,u.jsx)(vj,{isOpen:E,onClose:()=>{A(!1),R(null)},onConfirm:async()=>{if(L&&t)try{Y(!0);if(!(await fetch("".concat("","/api/admin/comments/").concat(L.id),{method:"DELETE",headers:{Authorization:"Bearer ".concat(t)}})).ok)throw new Error("Failed to delete comment");l(e=>e.filter(e=>e.id!==L.id)),A(!1),R(null)}catch(e){console.error("Failed to delete comment:",e)}finally{Y(!1)}},title:"Delete Comment",message:'Are you sure you want to delete this comment by "'.concat(null===L||void 0===L?void 0:L.author_name,'"? This action cannot be undone.'),confirmText:"Delete",cancelText:"Cancel",confirmButtonClassName:"bg-red-600 hover:bg-red-700",isLoading:W}),(0,u.jsx)(vj,{isOpen:T,onClose:()=>{M(!1),O(null),q("")},onConfirm:async()=>{if(z&&t)try{K(!0);if(!(await fetch("/api/admin/ban-ip",{method:"POST",headers:{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"},body:JSON.stringify({ip_address:z,reason:H||void 0})})).ok)throw new Error("Failed to ban IP");await Z(),M(!1),O(null),q("")}catch(e){console.error("Failed to ban IP:",e)}finally{K(!1)}},title:"Ban IP Address",message:(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("p",{children:["Are you sure you want to ban the IP address ",(0,u.jsx)("strong",{className:"font-mono",children:z}),"?"]}),(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"This will prevent any future comments from this IP address."}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Reason (optional)"}),(0,u.jsx)("input",{type:"text",value:H,onChange:e=>q(e.target.value),placeholder:"e.g., Spam, Abuse, etc.",className:"w-full px-3 py-2 border rounded-lg ".concat(s?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-500")})]})]}),confirmText:"Ban IP",cancelText:"Cancel",confirmButtonClassName:"bg-red-600 hover:bg-red-700",isLoading:G}),(0,u.jsx)(vj,{isOpen:I,onClose:()=>{P(!1),O(null)},onConfirm:async()=>{if(z&&t)try{K(!0);
2if(!(await fetch("".concat("","/api/admin/banned-ips/").concat(encodeURIComponent(z)),{method:"DELETE",headers:{Authorization:"Bearer ".concat(t)}})).ok)throw new Error("Failed to unban IP");h(e=>e.filter(e=>e.ip_address!==z)),P(!1),O(null)}catch(e){console.error("Failed to unban IP:",e)}finally{K(!1)}},title:"Unban IP Address",message:"Are you sure you want to unban the IP address ".concat(z,"? They will be able to post comments again."),confirmText:"Unban",cancelText:"Cancel",confirmButtonClassName:"bg-[#FFB52B] hover:bg-[#FFC54D] text-[#232E3F]",isLoading:G}),(0,u.jsx)(vj,{isOpen:_,onClose:()=>{B(!1),V(null),q("")},onConfirm:async()=>{if(U&&t)try{K(!0);if(!(await fetch("/api/admin/ban-user",{method:"POST",headers:{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"},body:JSON.stringify({authorName:U,reason:H||void 0})})).ok)throw new Error("Failed to ban user");l(e=>e.filter(e=>e.author_name!==U)),await Z(),B(!1),V(null),q("")}catch(e){console.error("Failed to ban user:",e)}finally{K(!1)}},title:"Ban User",message:(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("p",{children:["Are you sure you want to ban ",(0,u.jsx)("strong",{children:U}),"?"]}),(0,u.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"This will delete all their comments and ban their IP addresses, preventing future comments."}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Reason (optional)"}),(0,u.jsx)("input",{type:"text",value:H,onChange:e=>q(e.target.value),placeholder:"e.g., Spam, Abuse, etc.",className:"w-full px-3 py-2 border rounded-lg ".concat(s?"bg-gray-700 border-gray-600 text-gray-100 placeholder-gray-400":"bg-white border-gray-300 text-gray-900 placeholder-gray-500")})]})]}),confirmText:"Ban User",cancelText:"Cancel",confirmButtonClassName:"bg-red-600 hover:bg-red-700",isLoading:G})]}):(0,u.jsx)("div",{className:"flex items-center justify-center h-screen",children:(0,u.jsx)("p",{className:"text-gray-600 dark:text-gray-400",children:"Please log in to access this page."})})};function gU(e){return e?e.includes(" ")&&!e.includes("T")?e.replace(" ","T")+"Z":e:""}function xU(e){var t,n,a,r,s,i,o,l,c,d,u,m,h,p,g,x,f,b,y,v,w;return{id:e.id,name:e.name,description:null!==(t=e.description)&&void 0!==t?t:null,cronExpression:null!==(n=e.cron_expression)&&void 0!==n?n:null,enabled:!!e.enabled,promptType:null!==(a=e.prompt_type)&&void 0!==a?a:"",model:null!==(r=e.model)&&void 0!==r?r:null,reasoningEffort:null!==(s=e.reasoning_effort)&&void 0!==s?s:"high",maxTurns:null!==(i=e.max_turns)&&void 0!==i?i:50,maxRuntimeSeconds:null!==(o=e.max_runtime_seconds)&&void 0!==o?o:600,executionMode:null!==(l=e.execution_mode)&&void 0!==l?l:"ecs",episodeId:null!==(c=e.episode_id)&&void 0!==c?c:null,maxCostUsd:null!==(d=e.max_cost_usd)&&void 0!==d?d:null,eventTriggers:null!==(u=e.event_triggers)&&void 0!==u?u:null,eventDelaySeconds:null!==(m=e.event_delay_seconds)&&void 0!==m?m:60,eventFilterJson:null!==(h=e.event_filter)&&void 0!==h?h:null,dependsOnScheduleId:null!==(p=e.depends_on_schedule_id)&&void 0!==p?p:null,lastRunAt:gU(e.last_run_at),lastRunStatus:null!==(g=e.last_run_status)&&void 0!==g?g:null,lastRunAgentSessionId:null!==(x=e.last_run_agent_session_id)&&void 0!==x?x:null,currentRunAgentSessionId:null!==(f=e.current_run_agent_session_id)&&void 0!==f?f:null,nextRunAt:gU(e.next_run_at),runCount:null!==(b=e.run_count)&&void 0!==b?b:0,consecutiveFailures:null!==(y=e.consecutive_failures)&&void 0!==y?y:0,totalCostUsd:null!==(v=e.total_cost_usd)&&void 0!==v?v:0,createdBy:null!==(w=e.created_by)&&void 0!==w?w:"",createdAt:gU(e.created_at),updatedAt:gU(e.updated_at)}}function fU(e){var t,n,a,r,s,i;return{id:e.id,scheduleId:null!==(t=e.schedule_id)&&void 0!==t?t:"",agentSessionId:null!==(n=e.agent_session_id)&&void 0!==n?n:null,runId:null!==(a=e.run_id)&&void 0!==a?a:null,logType:null!==(r=e.log_type)&&void 0!==r?r:"info",message:null!==(s=e.message)&&void 0!==s?s:"",metadataJson:null!==(i=e.metadata_json)&&void 0!==i?i:null,createdAt:gU(e.created_at)}}function bU(e){var t,n,a,r,s,i,o,l,c;return{id:e.id,scheduleId:null!==(t=e.schedule_id)&&void 0!==t?t:"",status:null!==(n=e.status)&&void 0!==n?n:"pending",triggerType:null!==(a=e.trigger_type)&&void 0!==a?a:"manual",triggerEvent:null!==(r=e.trigger_event)&&void 0!==r?r:null,totalTokens:null!=e.total_input_tokens&&null!=e.total_output_tokens?e.total_input_tokens+e.total_output_tokens:null!==(s=e.total_tokens)&&void 0!==s?s:null,totalCost:null!==(i=null!==(o=e.total_cost_usd)&&void 0!==o?o:e.total_cost)&&void 0!==i?i:null,errorMessage:null!==(l=e.error_message)&&void 0!==l?l:null,createdAt:gU(e.created_at),completedAt:gU(e.completed_at),durationSeconds:null!==(c=e.duration_seconds)&&void 0!==c?c:null}}function yU(e){var t,n,a,r,s,i,o;return{id:e.id,promptType:null!==(t=e.prompt_type)&&void 0!==t?t:"",versionNumber:null!==(n=e.version_number)&&void 0!==n?n:0,createdAt:gU(e.created_at),createdBy:null!==(a=e.created_by)&&void 0!==a?a:"",isActive:!!e.is_active,changeSummary:null!==(r=e.change_summary)&&void 0!==r?r:null,contentHash:null!==(s=e.content_hash)&&void 0!==s?s:"",contentSize:null!==(i=e.content_size)&&void 0!==i?i:0,content:null!==(o=e.content)&&void 0!==o?o:void 0}}function vU(e){if("string"!==typeof e)return null!==e&&void 0!==e?e:null;try{return JSON.parse(e)}catch(_H){return e}}function wU(e){var t,n,a,r,s;return{id:e.id,scheduleId:null!==(t=e.schedule_id)&&void 0!==t?t:"",eventName:null!==(n=e.event_name)&&void 0!==n?n:"",eventPayloadJson:vU(e.event_payload_json),fireAt:gU(e.fire_at),sessionId:null!==(a=e.session_id)&&void 0!==a?a:null,status:null!==(r=e.status)&&void 0!==r?r:"pending",cancelledReason:null!==(s=e.cancelled_reason)&&void 0!==s?s:null,createdAt:gU(e.created_at)}}class kU{static async request(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const a="".concat("/api/v1").concat(e),r=new Headers(t.headers);r.set("Content-Type","application/json"),n&&r.set("Authorization","Bearer ".concat(n));const s=await fetch(a,d(d({},t),{},{headers:r}));if(!s.ok){let e="HTTP ".concat(s.status);try{const t=await s.json();e=(null===t||void 0===t?void 0:t.error)||(null===t||void 0===t?void 0:t.message)||e}catch(i){try{const t=await s.text();t&&t.length<200&&(e=t)}catch(o){}}throw new Error(e)}if(204!==s.status)return s.json()}static async list(e){const t=await this.request("/agent/schedules",{},e);return Array.isArray(null===t||void 0===t?void 0:t.schedules)?t.schedules.map(xU):[]}static async get(e,t){return xU(await this.request("/agent/schedules/".concat(e),{},t))}static async create(e,t){return xU(await this.request("/agent/schedules",{method:"POST",body:JSON.stringify(e)},t))}static async update(e,t,n){return xU(await this.request("/agent/schedules/".concat(e),{method:"PUT",body:JSON.stringify(t)},n))}static async delete(e,t){await this.request("/agent/schedules/".concat(e),{method:"DELETE"},t)}static async enable(e,t){return xU(await this.request("/agent/schedules/".concat(e,"/e
2nable"),{method:"POST"},t))}static async disable(e,t){return xU(await this.request("/agent/schedules/".concat(e,"/disable"),{method:"POST"},t))}static async runNow(e,t){return this.request("/agent/schedules/".concat(e,"/run-now"),{method:"POST"},t)}static async stop(e,t){await this.request("/agent/schedules/".concat(e,"/stop"),{method:"POST"},t)}static async getLogs(e,t,n,a){const r=new URLSearchParams;n&&r.append("limit",n.toString()),a&&r.append("type",a);const s=r.toString(),i="/agent/schedules/".concat(e,"/logs").concat(s?"?".concat(s):""),o=await this.request(i,{},t);return Array.isArray(null===o||void 0===o?void 0:o.logs)?o.logs.map(fU):[]}static async getRuns(e,t,n){const a=new URLSearchParams;n&&a.append("limit",n.toString());const r=a.toString(),s="/agent/schedules/".concat(e,"/runs").concat(r?"?".concat(r):""),i=await this.request(s,{},t);return Array.isArray(null===i||void 0===i?void 0:i.runs)?i.runs.map(bU):[]}static async getPrompt(e,t){var n,a;const r=await this.request("/agent/schedules/".concat(e,"/prompt"),{},t);return{content:null!==(n=null===r||void 0===r?void 0:r.content)&&void 0!==n?n:"",version:null!==(a=null===r||void 0===r?void 0:r.version)&&void 0!==a?a:0}}static async getPromptVersions(e,t){const n=await this.request("/agent/schedules/".concat(e,"/prompt/versions"),{},t);return Array.isArray(null===n||void 0===n?void 0:n.versions)?n.versions.map(yU):[]}static async updatePrompt(e,t,n,a){await this.request("/agent/schedules/".concat(e,"/prompt"),{method:"PUT",body:JSON.stringify({content:t,changeSummary:n})},a)}static async activatePromptVersion(e,t,n){await this.request("/agent/schedules/".concat(e,"/prompt/versions/").concat(t,"/activate"),{method:"POST"},n)}static async getPendingEvents(e,t){const n=await this.request("/agent/schedules/".concat(e,"/pending-events"),{},t);return Array.isArray(null===n||void 0===n?void 0:n.events)?n.events.map(wU):[]}static async cancelPendingEvents(e,t){await this.request("/agent/schedules/".concat(e,"/pending-events"),{method:"DELETE"},t)}static async cancelPendingEvent(e,t,n){await this.request("/agent/schedules/".concat(e,"/pending-events/").concat(t),{method:"DELETE"},n)}static async getEventTypes(e){const t=await this.request("/agent/events",{},e);return Array.isArray(null===t||void 0===t?void 0:t.events)?t.events:[]}}const jU=()=>{const e=oc(),[t,n]=fd(),{isAuthenticated:r,isLoading:s,token:i}=am(),{isDarkMode:o,toggleDarkMode:l}=zu(),[c,d]=(0,a.useState)([]),m=t.get("session")||t.get("run"),h=t.get("schedule"),p=t.get("trigger")||void 0,g=t.get("dateFrom")||void 0,x=t.get("dateTo")||void 0,f=(0,a.useMemo)(()=>{if(h||p||g||x)return{scheduleId:h||void 0,triggerType:p,dateFrom:g,dateTo:x,limit:200}},[g,x,h,p]),b=(0,a.useMemo)(()=>{const e=[],t=c.find(e=>e.id===h);return h&&e.push("schedule ".concat((null===t||void 0===t?void 0:t.name)||h)),p&&e.push("trigger ".concat(p)),g&&e.push("from ".concat(g)),x&&e.push("to ".concat(x)),e.length>0?"Filtered to ".concat(e.join(" \xb7 ")):null},[g,x,c,h,p]);(0,a.useEffect)(()=>{if(!r||!i)return;let e=!1;return kU.list(i).then(t=>{if(e)return;const n=[...t].sort((e,t)=>{const n=e.currentRunAgentSessionId?1:0,a=t.currentRunAgentSessionId?1:0;if(n!==a)return a-n;const r=e.lastRunAt||e.updatedAt||e.createdAt,s=t.lastRunAt||t.updatedAt||t.createdAt;return new Date(s||0).getTime()-new Date(r||0).getTime()}).slice(0,10);d(n)}).catch(()=>{e||d([])}),()=>{e=!0}},[r,i]);const y=(0,a.useMemo)(()=>!h||c.some(e=>e.id===h)?c:[{id:h,name:"Schedule ".concat(h.slice(0,8))},...c],[c,h]),v=a.useCallback((e,a)=>{const r=new URLSearchParams(t);a?r.set(e,a):r.delete(e),r.delete("session"),r.delete("run"),n(r,{replace:!0})},[t,n]),w=a.useCallback(()=>{const e=new URLSearchParams(t);e.delete("schedule"),e.delete("trigger"),e.delete("dateFrom"),e.delete("dateTo"),e.delete("session"),e.delete("run"),n(e,{replace:!0})},[t,n]),k=a.useCallback(()=>{if(!m)return;const e=new URLSearchParams(t);e.delete("session"),e.delete("run"),n(e,{replace:!0})},[m,t,n]);return s?(0,u.jsx)("div",{className:"flex h-[100dvh] items-center justify-center overflow-hidden ".concat(o?"bg-[#0f1623]":"bg-gray-50"),children:(0,u.jsx)(Lo,{className:"h-8 w-8 animate-spin text-[#FFB52B]"})}):r?(0,u.jsxs)("div",{className:"flex h-[100dvh] max-h-[100dvh] min-h-0 w-full min-w-0 flex-col overflow-hidden overscroll-none ".concat(o?"dark bg-[#0f1623]":"bg-gray-50"),children:[(0,u.jsx)("div",{className:"shrink-0 overflow-hidden border-b border-gray-200/70 bg-white/80 backdrop-blur dark:border-white/[0.08] dark:bg-[#121826]/85",children:(0,u.jsxs)("div",{className:"mx-auto flex max-w-[1800px] min-w-0 flex-col gap-4 px-4 py-3 sm:px-6",children:[(0,u.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>e("/"),className:"inline-flex items-center gap-2 rounded-lg border border-gray-200/70 px-3 py-2 text-sm text-gray-600 transition-colors hover:bg-gray-100 dark:border-white/[0.08] dark:text-gray-300 dark:hover:bg-white/[0.06]",children:[(0,u.jsx)(Yk,{className:"h-4 w-4"}),"Back"]}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 text-sm font-semibold text-gray-900 dark:text-gray-100",children:[(0,u.jsx)(wy,{className:"h-4 w-4 text-[#FFB52B]"}),"Agents"]}),(0,u.jsx)("p",{className:"truncate text-xs text-gray-500 dark:text-gray-400",children:"Global agent sessions explorer"})]}),(0,u.jsx)("button",{type:"button",onClick:l,className:"ml-auto inline-flex items-center justify-center rounded-lg border border-gray-200/70 p-2 text-gray-600 transition-colors hover:bg-gray-100 dark:border-white/[0.08] dark:text-gray-300 dark:hover:bg-white/[0.06]","aria-label":o?"Switch to light mode":"Switch to dark mode",title:o?"Switch to light mode":"Switch to dark mode",children:o?(0,u.jsx)(LE,{className:"h-4 w-4"}):(0,u.jsx)(RE,{className:"h-4 w-4"})})]}),(0,u.jsxs)("div",{className:"flex min-w-0 flex-wrap items-end gap-2",children:[(0,u.jsxs)("label",{className:"flex min-w-[200px] flex-col gap-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:["Schedule ID",(0,u.jsx)("input",{type:"text",value:h||"",onChange:e=>v("schedule",e.target.value),placeholder:"paste schedule id",list:"recent-agent-schedules",className:"rounded-lg border border-gray-200/70 bg-white px-3 py-2 text-xs font-normal normal-case text-gray-700 outline-none transition-colors focus:border-[#FFB52B] dark:border-white/[0.08] dark:bg-[#0f1623] dark:text-gray-200"})]}),(0,u.jsx)("datalist",{id:"recent-agent-schedules",children:y.map(e=>(0,u.jsx)("option",{value:e.id,children:e.name},e.id))}),(0,u.jsxs)("label",{className:"flex min-w-[220px] flex-col gap-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:["Recent Schedule",(0,u.jsxs)("select",{value:y.some(e=>e.id===(h||""))&&h||"",onChange:e=>v("schedule",e.target.value),className:"rounded-lg border border-gray-200/70 bg-white px-3 py-2 text-xs font-normal normal-case text-gray-700 outline-none transition-colors focus:border-[#FFB52B] dark:border-white/[0.08] dark:bg-[#0f1623] dark:text-gray-200",children:[(0,u.jsx)("option",{value:"",children:"Recent schedules"}),y.map(e=>(0,u.jsxs)("option",{value:e.id,children:[e.name," \xb7 ",e.id.slice(0,8)]},e.id))]})]}),(0,u.jsxs)("label",{className:"flex min-w-[130px] flex-col gap-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:["Trigger",(0,u.jsxs)("select",{value:p||"",onChange:e=>v("trigger",e.target.value),className:"rounded-lg border border-gray-200/70 bg-white px-3 py-2 text-xs font-normal normal-case text-gray-700 outline-none transition-colors focus:border-[#FFB52B] dark:border-white/[0.08] dark:bg-[#0f1623] dark:text-gray-200",children:[(0,u.jsx)("option",{value:"",children:"All triggers"}),(0,u.jsx)("option",{value:"manual",children:"Manual"}),(0,u.jsx)("option",{value:"cron",children:"Cron"}),(0,u.jsx)("option",{value:"event",children:"Event"}),(0,u.jsx)("option",{value:"dependency",children:"Dependency"})]})]}),(0,u.jsxs)("label",{className:"flex min-w-[150px] flex-col gap-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:["From",(0,u.jsx)("input",{type:"date",value:g||"",onChange:e=>v("dateFrom",e.target.value),className:"rounded-lg border border-gray-200/70 bg-white px-3 py-2 text-xs font-normal normal-case text-gray-700 outline-none transition-colors focus:border-[#FFB52B] dark:border-white/[0.08] dark:bg-[#0f1623] dark:text-gray-200"})]}),(0,u.jsxs)("label",{className:"flex min-w-[150px] flex-col gap-1 text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:["To",(0,u.jsx)("input",{type:"date",value:x||"",onChange:e=>v("dateTo",e.target.value),className:"rounded-lg border border-gray-200/70 bg-white px-3 py-2 text-xs font-normal normal-case text-gray-700 outline-none transition-colors focus:border-[#FFB52B] dark:border-white/[0.08] dark:bg-[#0f1623] dark:text-gray-200"})]}),(0,u.jsx)("button",{type:"button",onClick:w,className:"rounded-lg border border-gray-200/70 px-3 py-2 text-xs text-gray-600 transition-colors hover:bg-gray-100 dark:border-white/[0.08] dark:text-gray-300 dark:hover:bg-white/[0.06]",children:"Clear filters"})]})]})}),(0,u.jsx)("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden",children:(0,u.jsx)(qk,{token:i||void 0,preferredSessionId:m,onPreferredSessionHandled:k,sessionListOptions:f,sessionListLabel:b})})]}):(0,u.jsx)("div",{className:"h-[100dvh] overflow-hidden ".concat(o?"bg-[#0f1623]":"bg-gray-50"),children:(0,u.jsx)(ij,{})})},DU=Mo("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);function CU(e){switch(e){case"success":case"running":case"pending":return"bg-[#FFB52B] dark:bg-[#FFB52B]";case"failure":case"timeout":return"bg-red-500 dark:bg-red-400";case"skipped":return"bg-yellow-500/60 dark:bg-yellow-500/60";default:return"bg-gray-400 dark:bg-gray-500"}}function NU(e){switch(e){case"success":case"running":case"pending":return"ring-[#FFB52B]/40 dark:ring-[#FFB52B]/30";case"failure":case"timeout":return"ring-red-300 dark:ring-red-600";case"skipped":return"ring-yellow-300 dark:ring-yellow-600";default:return"ring-gray-300 dark:ring-gray-600"}}function FU(e){switch(e){case"cron":return"Cron";case"event":return"Event";case"manual":return"Manual";case"dependency":return"Dependency";default:return"Unknown"}}function SU(e){if(null==e)return"--";if(e<60)return"".concat(Math.round(e),"s");const t=Math.floor(e/60),n=Math.round(e%60);return"".concat(t,"m ").concat(n,"s")}function EU(e){let t=e;return t.includes(" ")&&!t.includes("T")&&(t=t.replace(" ","T")+"Z"),new Date(t)}function AU(e){if(!e)return"unknown";try{const t=EU(e);if(isNaN(t.getTime()))return"unknown";const n=Date.now()-t.getTime(),a=Math.floor(n/6e4);if(a<0)return"in the future";if(a<1)return"just now";if(a<60)return"".concat(a," minute").concat(1===a?"":"s"," ago");const r=Math.floor(a/60);if(r<24)return"".concat(r," hour").concat(1===r?"":"s"," ago");if(r<48)return"yesterday";const s=Math.floor(r/24);if(s<14)return"".concat(s," days ago");const i=Math.floor(s/7);return s<60?"".concat(i," week").concat(1===i?"":"s"," ago"):t.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch(_H){return"unknown"}}function TU(e){if(!e)return"";try{const t=EU(e);
2return isNaN(t.getTime())?"":t.toLocaleString()}catch(t){return""}}const MU=e=>{let{runs:t,maxVisible:n=8,onClickRun:r}=e;const[s,i]=(0,a.useState)(null),o=Array.isArray(t)?t:[],l=Math.max(1,Math.min(n,12));if(0===o.length)return(0,u.jsx)("div",{className:"flex items-center gap-1",children:(0,u.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 italic",children:"No runs yet"})});const c=o.slice(0,l).reverse();return(0,u.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 sm:gap-1 relative",children:[c.map((e,t)=>{var n;const a="running"===e.status||"pending"===e.status,o=c.length-1-t,l=s===t;return(0,u.jsxs)("div",{className:"relative flex-shrink-0",onMouseEnter:()=>i(t),onMouseLeave:()=>i(null),children:[(0,u.jsx)("button",{type:"button",onClick:()=>null===r||void 0===r?void 0:r(e),className:"\n w-5 h-5 sm:w-3 sm:h-3 rounded-full transition-all duration-200\n ".concat(CU(e.status),"\n ").concat(l?"ring-2 ".concat(NU(e.status)," scale-125"):"","\n ").concat(a?"animate-pulse":"","\n hover:scale-125 cursor-pointer\n "),"aria-label":"Run ".concat(e.status||"unknown",": ").concat(AU(e.createdAt))}),l&&(0,u.jsxs)("div",{className:"\n absolute bottom-full mb-2 px-2.5 py-1.5\n bg-gray-900 dark:bg-gray-700 text-white text-xs rounded-lg shadow-xl\n pointer-events-none whitespace-nowrap z-50\n ".concat(o<3?"left-0":"left-1/2 transform -translate-x-1/2","\n "),children:[(0,u.jsx)("div",{className:"font-medium capitalize",children:e.status}),(0,u.jsx)("div",{className:"text-gray-300 dark:text-gray-400",children:AU(e.createdAt)}),TU(e.createdAt)&&(0,u.jsx)("div",{className:"text-gray-400 dark:text-gray-500 text-[10px]",children:TU(e.createdAt)}),(0,u.jsxs)("div",{className:"text-gray-300 dark:text-gray-400",children:[FU(null!==(n=e.triggerType)&&void 0!==n?n:null)," | ",SU(e.durationSeconds)]}),null!=e.totalCost&&e.totalCost>0&&(0,u.jsxs)("div",{className:"text-gray-400",children:["$",Number(e.totalCost).toFixed(3)]}),e.errorMessage&&(0,u.jsx)("div",{className:"text-red-300 max-w-[200px] truncate mt-0.5",children:e.errorMessage}),(0,u.jsx)("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0\n border-l-4 border-r-4 border-t-4\n border-l-transparent border-r-transparent\n border-t-gray-900 dark:border-t-gray-700"})]})]},e.id||t)}),o.length>l&&(0,u.jsxs)("span",{className:"ml-0.5 flex-shrink-0 text-xs text-gray-400 dark:text-gray-500",children:["+",o.length-l]})]})};function _U(e){if(!e)return"";const t=e.trim().split(/\s+/);if(t.length<5)return e;const[n,a,r,s,i]=t;if("*"===n&&"*"===a)return"Every minute";if("*"===a&&"*"!==n)return"Every hour at :".concat(n.padStart(2,"0"));if("*"===r&&"*"===s&&"*"===i){if("*"!==n&&"*"!==a)return"Daily at ".concat(a.padStart(2,"0"),":").concat(n.padStart(2,"0")," UTC");if(a.includes("/")){const e=a.split("/")[1];return"Every ".concat(e," hours")}if(a.includes(","))return"At ".concat(a.split(",").map(e=>"".concat(e.padStart(2,"0"),":").concat(n.padStart(2,"0"))).join(", ")," UTC")}if("*"!==i&&"*"===r&&"*"===s){const e={0:"Sun",1:"Mon",2:"Tue",3:"Wed",4:"Thu",5:"Fri",6:"Sat",7:"Sun"},t=i.split(",").map(t=>e[t]||t).join(", ");return"".concat(t," at ").concat(a.padStart(2,"0"),":").concat(n.padStart(2,"0")," UTC")}return e}function BU(e){let t=e;return t.includes(" ")&&!t.includes("T")&&(t=t.replace(" ","T")+"Z"),new Date(t)}function IU(e){if(!e)return"Never";try{const t=BU(e);if(isNaN(t.getTime()))return"Never";const n=Date.now()-t.getTime(),a=Math.floor(n/6e4);if(a<0)return"in the future";if(a<1)return"just now";if(a<60)return"".concat(a," minute").concat(1===a?"":"s"," ago");const r=Math.floor(a/60);if(r<24)return"".concat(r," hour").concat(1===r?"":"s"," ago");if(r<48)return"yesterday";const s=Math.floor(r/24);if(s<14)return"".concat(s," days ago");const i=Math.floor(s/7);return s<60?"".concat(i," week").concat(1===i?"":"s"," ago"):t.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch(_H){return"Never"}}function PU(e){if(!e)return"";try{const t=BU(e);
2return isNaN(t.getTime())?"":t.toLocaleString()}catch(t){return""}}function LU(e){if(!e)return"--";try{const t=new Date(e);if(isNaN(t.getTime()))return"--";const n=t.getTime()-Date.now();if(n<0)return"overdue";const a=Math.floor(n/6e4);if(a<1)return"< 1m";if(a<60)return"in ".concat(a,"m");const r=Math.floor(a/60);if(r<24)return"in ".concat(r,"h");const s=Math.floor(r/24);return"in ".concat(s,"d")}catch(t){return"--"}}function RU(e){if(null==e)return"--";if(e<60)return"".concat(Math.round(e),"s");const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.round(e%60);return t>0?n>0?"".concat(t,"h ").concat(n,"m"):"".concat(t,"h"):a>0?"".concat(n,"m ").concat(a,"s"):"".concat(n,"m")}function zU(e){switch(e){case"running":return"bg-[#FFB52B] shadow-[#FFB52B]/50 shadow-lg schedule-pulse-ring";case"active":return"bg-[#FFB52B] shadow-[#FFB52B]/30 shadow-sm";case"disabled":return"bg-gray-400 dark:bg-gray-600"}}const OU=e=>{var t,n,r,s,i,o;let{schedule:l,runs:c=[],onRunNow:d,onStop:m,onToggleEnabled:h,onDelete:p,onSelect:g,onClickRun:x,isActioning:f=!1}=e;const[b,y]=(0,a.useState)(!1),[v,w]=(0,a.useState)(!1),[k,j]=(0,a.useState)(!1),[D,C]=(0,a.useState)(()=>Date.now()),N=!!l.currentRunAgentSessionId;a.useEffect(()=>{N||j(!1)},[N]),a.useEffect(()=>{if(!N)return;C(Date.now());const e=window.setInterval(()=>{C(Date.now())},1e3);return()=>window.clearInterval(e)},[N]);const F=function(e){return e.currentRunAgentSessionId?"running":e.enabled?"active":"disabled"}(l),S=function(e){switch(e){case"running":return{label:"Running",className:"text-[#FFB52B] text-[10px]"};case"active":return{label:"Active",className:"text-gray-500 dark:text-gray-400 text-[10px]"};case"disabled":return{label:"Disabled",className:"text-gray-400 dark:text-gray-600 text-[10px]"}}}(F),E=!!l.cronExpression,A=Array.isArray(l.eventTriggers)&&l.eventTriggers.length>0,T=!!l.dependsOnScheduleId,M=function(e,t){return e.find(e=>e.id===t)||e.find(e=>"running"===e.status)||null}(c,l.currentRunAgentSessionId),_=function(e,t){if(!e)return null;try{const n=BU(e);return isNaN(n.getTime())?null:Math.max(0,Math.floor((t-n.getTime())/1e3))}catch(n){return null}}(null!==(t=null===M||void 0===M?void 0:M.createdAt)&&void 0!==t?t:null,D),B=function(e){const t=e.map(e=>e.durationSeconds).filter(e=>"number"===typeof e&&e>0);return 0===t.length?null:t.reduce((e,t)=>e+t,0)/t.length}(c);return(0,u.jsx)("div",{onClick:()=>g(l),className:"\n relative group cursor-pointer\n rounded-2xl border\n backdrop-blur-xl\n transition-all duration-300 ease-out\n hover:scale-[1.01] hover:shadow-xl\n ".concat("running"===F?"border-[#FFB52B]/30 bg-white/[0.07] dark:bg-white/[0.04] shadow-[#FFB52B]/10 shadow-lg schedule-running-card":"active"===F?"border-white/[0.08] dark:border-white/[0.08] bg-white/90 dark:bg-white/[0.06] hover:border-white/[0.15] dark:hover:border-white/[0.15] hover:bg-white dark:hover:bg-white/[0.08]":"border-white/[0.05] dark:border-white/[0.05] bg-white/80 dark:bg-white/[0.03] opacity-70 hover:opacity-90","\n "),children:(0,u.jsxs)("div",{className:"p-4 sm:p-5",children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3 mb-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[(0,u.jsx)("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 ".concat(zU(F))}),(0,u.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white truncate",children:l.name}),(0,u.jsx)("span",{className:"text-[9px] font-mono text-gray-400 dark:text-gray-600 hidden sm:inline",title:l.id,children:l.id.slice(0,8)})]}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[(0,u.jsx)("span",{className:"font-medium ".concat(S.className),children:S.label}),(0,u.jsxs)("div",{className:"relative",children:[(0,u.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),y(!b)},"aria-label":"Schedule actions menu","aria-expanded":b,className:"p-2 sm:p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700/50 transition-colors min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:(0,u.jsx)(AO,{className:"h-4 w-4 sm:h-3.5 sm:w-3.5 text-gray-400"})}),b&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"fixed inset-0 z-40",onClick:e=>{e.stopPropagation(),y(!1)}}),(0,u.jsxs)("div",{className:"absolute right-0 top-full mt-1 z-50 w-40 rounded-xl border border-white/[0.1] dark:border-white/[0.1] bg-white/95 dar
2k:bg-[#1a2332]/95 backdrop-blur-2xl shadow-2xl py-1",children:[(0,u.jsxs)("button",{onClick:e=>{e.stopPropagation(),y(!1),h(l.id,l.enabled)},className:"w-full text-left px-3 py-2.5 sm:py-1.5 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/10 flex items-center gap-2",children:[l.enabled?(0,u.jsx)(wh,{className:"h-3 w-3"}):(0,u.jsx)(kh,{className:"h-3 w-3"}),l.enabled?"Disable":"Enable"]}),(0,u.jsxs)("button",{onClick:e=>{e.stopPropagation(),y(!1),navigator.clipboard.writeText(l.id).then(()=>{w(!0),setTimeout(()=>w(!1),2e3)}).catch(()=>{})},className:"w-full text-left px-3 py-2.5 sm:py-1.5 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/10 flex items-center gap-2",children:[v?(0,u.jsx)(Wm,{className:"h-3 w-3 text-emerald-500"}):(0,u.jsx)(Np,{className:"h-3 w-3"}),v?"Copied!":"Copy ID"]}),(0,u.jsxs)("button",{onClick:e=>{e.stopPropagation(),y(!1),p(l.id)},className:"w-full text-left px-3 py-2.5 sm:py-1.5 text-xs text-red-400 hover:bg-red-500/10 flex items-center gap-2",children:[(0,u.jsx)(kp,{className:"h-3 w-3"}),"Delete"]})]})]})]})]})]}),l.description&&(0,u.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3 line-clamp-2",children:l.description}),(0,u.jsxs)("div",{className:"space-y-1.5 mb-3",children:[E&&(0,u.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[(0,u.jsx)(wp,{className:"h-3 w-3 flex-shrink-0"}),(0,u.jsx)("span",{className:"truncate",children:_U(l.cronExpression)})]}),A&&(0,u.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,u.jsx)(hh,{className:"h-3 w-3 flex-shrink-0 text-amber-500"}),(0,u.jsx)("div",{className:"flex flex-wrap gap-1",children:(l.eventTriggers||[]).map(e=>(0,u.jsx)("span",{className:"px-1.5 py-0.5 rounded-md bg-amber-500/10 text-amber-500 dark:text-amber-400 border border-amber-500/20 text-[10px] font-medium",children:e},e))})]}),T&&(0,u.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[(0,u.jsx)(DU,{className:"h-3 w-3 flex-shrink-0"}),(0,u.jsx)("span",{children:"Depends on another schedule"})]})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-gray-500 dark:text-gray-400 mb-3",children:[(0,u.jsxs)("span",{title:PU(l.lastRunAt)||void 0,children:["Last: ",IU(l.lastRunAt),l.lastRunStatus?" (".concat(l.lastRunStatus,")"):""]}),(0,u.jsx)("span",{className:"text-gray-300 dark:text-gray-600 hidden sm:inline",children:"|"}),(0,u.jsxs)("span",{children:["Next: ",l.enabled?LU(l.nextRunAt):"--"]}),null!=_&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"text-gray-300 dark:text-gray-600 hidden sm:inline",children:"|"}),(0,u.jsxs)("span",{className:"text-[#B57700] dark:text-[#FFCF74]",title:PU(null===M||void 0===M?void 0:M.createdAt)||"Current run",children:["Live: ",RU(_)]})]})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-gray-500 dark:text-gray-400 mb-3",children:[(0,u.jsxs)("span",{children:["Runs: ",null!==(n=l.runCount)&&void 0!==n?n:0]}),null!=B&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),(0,u.jsxs)("span",{children:["Avg: ",RU(B)]})]}),(null!==(r=l.totalCostUsd)&&void 0!==r?r:0)>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),(0,u.jsxs)("span",{children:["Cost: $",(null!==(s=l.totalCostUsd)&&void 0!==s?s:0).toFixed(2)]})]}),(null!==(i=l.consecutiveFailures)&&void 0!==i?i:0)>0&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"text-gray-300 dark:text-gray-600",children:"|"}),(0,u.jsxs)("span",{className:"text-red-500 dark:text-red-400",children:[l.consecutiveFailures," failure",(null!==(o=l.consecutiveFailures)&&void 0!==o?o:0)>1?"s":""]})]})]}),(0,u.jsx)("div",{className:"min-w-0",children:(0,u.jsx)(MU,{runs:c,maxVisible:8,onClickRun:x})}),(0,u.jsx)("div",{className:"flex items-center gap-2 mt-4 pt-3 border-t border-gray-100 dark:border-white/[0.06]",children:"running"===F?(0,u.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),j(!0),m(l.id)},disabled:f||k,"aria-label":k?"Stopping schedule ".concat(l.name):"Stop schedule ".concat(l.name),className:"flex items-center gap-1.5 px-3 py-2 sm:py-1.5 rounded-lg text-xs font-medium bg-[#FFB52B]/15 text-[#FFB52B] hover:bg-[#FFB52B]/25 border border-[#FFB52B]/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed min-h-[44px] sm:min-h-0",children:[f||k?(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 animate-spin"}
2):(0,u.jsx)(Ay,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3"}),k?"Stopping...":"Stop"]}):(0,u.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),d(l.id)},disabled:f||!l.enabled,"aria-label":"Run schedule ".concat(l.name," now"),className:"flex items-center gap-1.5 px-3 py-2 sm:py-1.5 rounded-lg text-xs font-medium bg-[#FFB52B]/15 text-[#FFB52B] hover:bg-[#FFB52B]/25 border border-[#FFB52B]/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed min-h-[44px] sm:min-h-0",children:[f?(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3 animate-spin"}):(0,u.jsx)(kh,{className:"h-3.5 w-3.5 sm:h-3 sm:w-3"}),"Run Now"]})})]})})};function UU(e){if(!e)return"None";const t=e.trim().split(/\s+/);if(t.length<5)return e;const[n,a,r,s,i]=t;return"*"===n&&"*"===a?"Every minute":"*"===a&&"*"!==n?"Every hour at :".concat(n.padStart(2,"0")):"*"===r&&"*"===s&&"*"===i&&"*"!==n&&"*"!==a?"Daily at ".concat(a.padStart(2,"0"),":").concat(n.padStart(2,"0")," UTC"):a.includes("/")?"Every ".concat(a.split("/")[1]," hours"):e}function VU(e){let t=e;return t.includes(" ")&&!t.includes("T")&&(t=t.replace(" ","T")+"Z"),new Date(t)}function HU(e){const t=e.getTime()-Date.now();if(t<0)return"overdue";const n=Math.floor(t/6e4);if(n<1)return"< 1 min";if(n<60)return"in ".concat(n," min");const a=Math.floor(n/60),r=n%60;if(a<24){const t=new Date,n=e.getUTCDate()!==t.getUTCDate(),s=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",timeZone:"UTC"});return n&&a<48?"tomorrow at ".concat(s," UTC"):r>0?"in ".concat(a,"h ").concat(r,"m"):"in ".concat(a," hour").concat(1===a?"":"s")}const s=Math.floor(a/24);return"in ".concat(s," day").concat(1===s?"":"s")}function qU(e){if(!e)return"";try{const t=VU(e);if(isNaN(t.getTime()))return"";const n=new Date,a=t.getUTCDate()===n.getUTCDate()&&t.getUTCMonth()===n.getUTCMonth()&&t.getUTCFullYear()===n.getUTCFullYear(),r=new Date(n);r.setUTCDate(r.getUTCDate()+1);const s=t.getUTCDate()===r.getUTCDate()&&t.getUTCMonth()===r.getUTCMonth()&&t.getUTCFullYear()===r.getUTCFullYear(),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",timeZone:"UTC"});if(a)return"Today at ".concat(i," UTC");if(s){const e=t.toLocaleDateString("en-GB",{day:"numeric",month:"short",timeZone:"UTC"});return"Tomorrow, ".concat(e," at ").concat(i," UTC")}const o=t.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short",timeZone:"UTC"});return"".concat(o," at ").concat(i," UTC")}catch(_H){return""}}function WU(e){if(!e)return"";try{const t=VU(e);return isNaN(t.getTime())?"":t.toLocaleString()}catch(t){return""}}function YU(e){if(null==e)return"No payload";if("string"===typeof e){const t=e.trim();return t?t.length>100?"".concat(t.slice(0,97),"..."):t:"Empty payload"}if(Array.isArray(e))return"".concat(e.length," item").concat(1===e.length?"":"s");if("object"===typeof e){const t=Object.keys(e);if(0===t.length)return"Empty object";const n=t.slice(0,4).join(", ");return t.length>4?"".concat(n," +").concat(t.length-4," more"):n}return String(e)}function GU(e){let{dateStr:t,fallback:n="--"}=e;if(!t)return(0,u.jsx)("span",{children:n});const a=function(e){if(!e)return"--";try{const t=VU(e);if(isNaN(t.getTime()))return"--";const n=Date.now()-t.getTime();if(n<0)return HU(t);const a=Math.floor(n/6e4);if(a<1)return"just now";if(a<60)return"".concat(a," minute").concat(1===a?"":"s"," ago");const r=Math.floor(a/60);if(r<24)return"".concat(r," hour").concat(1===r?"":"s"," ago");if(r<48)return"yesterday";const s=Math.floor(r/24);if(s<14)return"".concat(s," days ago");const i=Math.floor(s/7);return s<60?"".concat(i," week").concat(1===i?"":"s"," ago"):t.toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}catch(t){return"--"}}(t),r=WU(t);return(0,u.jsx)("span",{title:r||void 0,children:a})}function KU(e){switch(e){case"error":return(0,u.jsx)(gh,{className:"h-3.5 w-3.5 text-red-400 flex-shrink-0"});case"warning":return(0,u.jsx)(fp,{className:"h-3.5 w-3.5 text-yellow-400 flex-shrink-0"});case"run_start":return(0,u.jsx)(kh,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"});case"run_end":return(0,u.jsx)(Ej,{className:"h-3.5 w-3.5 text-emerald-400 flex-shrink-0"});case"context":return(0,u.jsx)(DU,{className:"h-3.5 w-3.5 text-purple-400 flex-shrink-0"});default:return(0,u.jsx)(jp,{className:"h-3.5 w-3.5 text-gray-400 flex-shrink-0"})}}function XU(e){switch(e){case"error":return"bg-red-500/15 text-red-400";case"warning":return"bg-yellow-500/15 text-yellow-400";case"run_start":return"bg-blue-500/15 text-blue-400";case"run_end":return"bg-emerald-500/15 text-emerald-400";case"context":return"bg-purple-500/15 text-purple-400";default:return"bg-gray-500/15 text-gray-400"}}function JU(e){if(null==e)return"--";if(e<60)return"".concat(Math.round(e),"s");const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.round(e%60);return t>0?n>0?"".concat(t,"h ").concat(n,"m"):"".concat(t,"h"):a>0?"".concat(n,"m ").concat(a,"s"):"".concat(n,"m")}function $U(e,t){if(!e)return null;try{const n=VU(e);return isNaN(n.getTime())?null:Math.max(0,Math.floor((t-n.getTime())/1e3))}catch(n){return null}}const QU=e=>{let{label:t,value:n,icon:a}=e;return(0,u.jsxs)("div",{className:"p-3 rounded-xl border border-gray-200/60 dark:border-white/[0.06] bg-gray-50/80 dark:bg-white/[0.03] backdrop-blur-sm",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[a&&(0,u.jsx)("span",{className:"text-gray-400 dark:text-gray-500",children:a}),(0,u.jsx)("span",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-500 uppercase tracking-wider",children:t})]}),(0,u.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:n})]})},ZU=e=>{let{label:t,value:n,field:a,editingField:r,editValue:s,savingField:i,onStartEditing:o,onEditValueChange:l,onSave:c,onCancel:d,onKeyDown:m,inputType:h="text",selectOptions:p,rawValue:g}=e;const x=i===a;return r===a?(0,u.jsxs)("div",{className:"p-3 rounded-xl border border-[#FFB52B]/30 bg-[#FFB52B]/5",children:[(0,u.jsx)("div",{className:"flex items-center gap-1.5 mb-1",children:(0,u.jsx)("span",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-500 uppercase tracking-wider",children:t})}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:["select"===h&&p?(0,u.jsx)("select",{value:s,onChange:e=>l(e.target.value),onKeyDown:e=>m(e,a),autoFocus:!0,className:"flex-1 px-2 py-1 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900/50 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-[#FFB52B]/50",children:p.map(e=>(0,u.jsx)("option",{value:e.value,children:e.label},e.value))}):(0,u.jsx)("input",{type:h,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>m(e,a),autoFocus:!0,className:"flex-1 px-2 py-1 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900/50 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-[#FFB52B]/50 w-full min-w-0"}),(0,u.jsx)("button",{type:"button",onClick:()=>c(a),disabled:x,className:"p-1 rounded hover:bg-[#FFB52B]/20 transition-colors",title:"Save",children:x?(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 animate-spin text-[#FFB52B]"}):(0,u.jsx)(Wm,{className:"h-3.5 w-3.5 text-[#FFB52B]"})}),(0,u.jsx)("button",{type:"button",onClick:d,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-white/10 transition-colors",title:"Cancel",children:(0,u.jsx)(Pu,{className:"h-3.5 w-3.5 text-gray-400"})})]})]}):(0,u.jsxs)("div",{className:"p-3 rounded-xl border border-gray-200/60 dark:border-white/[0.06] bg-gray-50/80 dark:bg-white/[0.03] backdrop-blur-sm group/edit",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,u.jsx)("span",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-500 uppercase tracking-wider",children:t}),(0,u.jsx)("button",{type:"button",onClick:()=>o(a,g||String(n)||""),className:"opacity-0 group-hover/edit:opacity-100 p-0.5 rounded hover:bg-gray-200 dark:hover:bg-white/10 transition-all",title:"Edit ".concat(t),children:(0,u.jsx)(jj,{className:"h-2.5 w-2.5 text-gray-400"})})]}),(0,u.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:n})]})},eV=e=>{let{label:t,value:n,displayValue:a,field:r,editingField:s,editValue:i,savingField:o,onStartEditing:l,onEditValueChange:c,onSave:d,onCancel:m,rawValue:h,min:p=60,max:g=7200,step:x=60,ticks:f,formatDisplay:b}=e;const y=o===r,v=b||JU;if(s===r){const e=parseInt(i,10)||p,n=f&&"\u221e"===f[f.length-1]&&e>=g;return(0,u.jsxs)("div",{className:"p-3 rounded-xl border border-[#FFB52B]/30 bg-[#FFB52B]/5",children:[(0,u.jsxs)("div",{className:"space-y-1",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("span",{className:"text-[10px] font-semibold text-gray-500 uppercase tracking-wider",children:t}),(0,u.jsx)("span",{className:"text-sm font-mono text-gray-700 dark:text-gray-300",children:n?"Unlimited":v(e)})]}),(0,u.jsx)("input",{type:"range",min:p,max:g,step:x,value:e,onCh
2ange:e=>c(e.target.value),className:"w-full accent-[#FFB52B]"}),(0,u.jsx)("div",{className:"flex justify-between text-[9px] text-gray-400",children:(f||["1m","15m","30m","1h","2h"]).map((e,t)=>(0,u.jsx)("span",{children:e},t))})]}),(0,u.jsxs)("div",{className:"flex items-center justify-end gap-1.5 mt-2",children:[(0,u.jsx)("button",{type:"button",onClick:()=>d(r),disabled:y,className:"p-1 rounded hover:bg-[#FFB52B]/20 transition-colors",title:"Save",children:y?(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 animate-spin text-[#FFB52B]"}):(0,u.jsx)(Wm,{className:"h-3.5 w-3.5 text-[#FFB52B]"})}),(0,u.jsx)("button",{type:"button",onClick:m,className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-white/10 transition-colors",title:"Cancel",children:(0,u.jsx)(Pu,{className:"h-3.5 w-3.5 text-gray-400"})})]})]})}return(0,u.jsxs)("div",{className:"p-3 rounded-xl border border-gray-200/60 dark:border-white/[0.06] bg-gray-50/80 dark:bg-white/[0.03] backdrop-blur-sm group/edit",children:[(0,u.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,u.jsx)("span",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-500 uppercase tracking-wider",children:t}),(0,u.jsx)("button",{type:"button",onClick:()=>l(r,h||String(n)||""),className:"opacity-0 group-hover/edit:opacity-100 p-0.5 rounded hover:bg-gray-200 dark:hover:bg-white/10 transition-all",title:"Edit ".concat(t),children:(0,u.jsx)(jj,{className:"h-2.5 w-2.5 text-gray-400"})})]}),(0,u.jsx)("div",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:n})]})},tV=e=>{var t,n,r,s,i,o,l,c,d,m;let{schedule:h,runs:p,token:g,onClose:x,onRefresh:f,onRunNow:b,onStop:y,onToggleEnabled:v}=e;const w=Array.isArray(p)?p:[],[k,j]=(0,a.useState)("overview"),[D,C]=(0,a.useState)([]),[N,F]=(0,a.useState)(!1),[S,E]=(0,a.useState)(null),[A,T]=(0,a.useState)(""),[M,_]=(0,a.useState)([]),[B,I]=(0,a.useState)(!1),[P,L]=(0,a.useState)(null),[R,z]=(0,a.useState)(null),[O,U]=(0,a.useState)(null),[V,H]=(0,a.useState)(""),[q,W]=(0,a.useState)(""),[Y,G]=(0,a.useState)([]),[K,X]=(0,a.useState)(!1),[J,$]=(0,a.useState)(!1),[Q,Z]=(0,a.useState)(!1),[ee,te]=(0,a.useState)(""),[ne,ae]=(0,a.useState)(null),re=!!h.currentRunAgentSessionId,[se,ie]=(0,a.useState)(!1),[oe,le]=(0,a.useState)(()=>Date.now()),ce=(0,a.useRef)(null),de=re||"events"===k;(0,a.useEffect)(()=>{re||ie(!1)},[re]),(0,a.useEffect)(()=>{if(!de)return;le(Date.now());const e=window.setInterval(()=>{le(Date.now())},1e3);return()=>window.clearInterval(e)},[de]);const[ue,me]=(0,a.useState)(null),[he,pe]=(0,a.useState)(""),[ge,xe]=(0,a.useState)(null),[fe,be]=(0,a.useState)(!1),ye=(e,t)=>{me(e),pe(t)},ve=()=>{me(null),pe("")},we=async e=>{xe(e);try{const t={};"model"===e?t.model=he||void 0:"maxTurns"===e?t.maxTurns=parseInt(he,10)||50:"maxRuntimeSeconds"===e?t.maxRuntimeSeconds=parseInt(he,10)||600:"maxCostUsd"===e&&(t.maxCostUsd=he?parseFloat(he):null),await kU.update(h.id,t,g),me(null),pe(""),f()}catch(t){console.error("Failed to save field:",t)}finally{xe(null)}},ke=(e,t)=>{"Enter"===e.key?we(t):"Escape"===e.key&&ve()},je=(0,a.useCallback)(async()=>{F(!0),E(null);try{const e=await kU.getLogs(h.id,g,50,A||void 0);C(e)}catch(e){console.error("Failed to load logs:",e),E((null===e||void 0===e?void 0:e.message)||"Failed to load logs")}finally{F(!1)}},[h.id,g,A]),De=(0,a.useCallback)(async()=>{I(!0),L(null);try{const e=await kU.getPendingEvents(h.id,g);_(e)}catch(e){console.error("Failed to load pending events:",e),L((null===e||void 0===e?void 0:e.message)||"Failed to load pending events")}finally{I(!1)}},[h.id,g]),Ce=(0,a.useCallback)(async()=>{X(!0),ae(null);try{const[e,t]=await Promise.all([kU.getPrompt(h.id,g),kU.getPromptVersions(h.id,g)]);H(e.content),W(e.content),G(t)}catch(e){ae(e.message||"Failed to load prompt")}finally{X(!1)}},[h.id,g]);(0,a.useEffect)(()=>{"logs"===k&&je(),"prompt"===k&&Ce(),"events"===k&&De()},[k,je,De,Ce]),(0,a.useEffect)(()=>{De()},[De]),(0,a.useEffect)(()=>{O&&!M.some(e=>e.id===O)&&U(null)},[O,M]),(0,a.useEffect)(()=>(re&&(ce.current=setInterval(()=>{f(),"logs"===k&&je(),"events"===k&&De()},5e3)),()=>{ce.current&&clearInterval(ce.current)}),[re,f,k,je,De]);const Ne=[{id:"overview",label:"Overview"},{id:"prompt",label:"Prompt"},{id:"logs",label:"Logs"},{id:"events",label:(0,u.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,u.jsx)("span",{children:"Pending Events"}),M.length>0&&(0,u.jsx)("span",{className:"rounded-full bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-amber-500 dark:text-amber-400",children:M.length})]})},{id:"runs",label:"Runs"}],Fe=function(e,t){return e.find(e=>e.id===t)||e.find(e=>"running"===e.status)||null}(w,h.currentRunAgentSessionId),Se=$U(null!==(t=null===Fe||void 0===Fe?void 0:Fe.createdAt)&&void 0!==t?t:null,oe),Ee=function(e){const t=e.map(e=>e.durationSeconds).filter(e=>"number"===typeof e&&e>0);return 0===t.length?null:t.reduce((e,t)=>
2e+t,0)/t.length}(w),Ae=B?"Loading...":0===M.length?"None":"".concat(M.length," queued");return(0,u.jsxs)("div",{className:"fixed inset-0 z-50 flex justify-end",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:x}),(0,u.jsxs)("div",{className:"relative w-full sm:max-w-2xl bg-white/95 dark:bg-[#1a2332]/95 backdrop-blur-2xl border-l border-white/10 shadow-2xl overflow-hidden flex flex-col",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between p-4 sm:p-5 border-b border-gray-200/50 dark:border-white/[0.06]",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1 mr-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 ".concat(re?"bg-[#FFB52B] schedule-pulse-ring":h.enabled?"bg-[#FFB52B]":"bg-gray-400 dark:bg-gray-600")}),(0,u.jsx)("h2",{className:"text-base sm:text-lg font-semibold text-gray-900 dark:text-white truncate",children:h.name})]}),h.description&&(0,u.jsx)("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 mt-1 truncate",children:h.description})]}),(0,u.jsx)("button",{type:"button",onClick:x,"aria-label":"Close detail panel",className:"p-2.5 sm:p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/10 transition-colors flex-shrink-0 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:(0,u.jsx)(Pu,{className:"h-5 w-5 text-gray-500 dark:text-gray-400"})})]}),(0,u.jsx)("div",{className:"flex overflow-x-auto border-b border-gray-200/50 dark:border-white/[0.06] px-4 sm:px-5 scrollbar-hide",children:Ne.map(e=>(0,u.jsx)("button",{type:"button",onClick:()=>j(e.id),className:"\n px-3 sm:px-4 py-2.5 text-sm font-medium transition-colors border-b-2 -mb-px whitespace-nowrap flex-shrink-0 min-h-[44px] sm:min-h-0\n ".concat(k===e.id?"text-[#FFB52B] border-[#FFB52B]":"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-700 dark:hover:text-gray-300 hover:border-gray-300 dark:hover:border-gray-600","\n "),children:e.label},e.id))}),(0,u.jsxs)("div",{className:"flex-1 overflow-y-auto ".concat("prompt"===k?"flex flex-col":""),children:["overview"===k&&(0,u.jsxs)("div",{className:"p-4 sm:p-5 space-y-5",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[re?(0,u.jsxs)("button",{type:"button",onClick:async()=>{ie(!0);try{y(h.id)}catch(e){ie(!1)}},disabled:se,"aria-label":se?"Stopping agent":"Stop running agent",className:"flex items-center gap-2 px-4 py-2.5 sm:py-2 rounded-xl text-sm font-medium bg-red-500/15 text-red-400 hover:bg-red-500/25 border border-red-500/20 transition-colors disabled:opacity-60 disabled:cursor-not-allowed min-h-[44px] sm:min-h-0",children:[se?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(Ay,{className:"h-4 w-4"}),se?"Stopping...":"Stop Running Agent"]}):(0,u.jsxs)("button",{type:"button",onClick:()=>b(h.id),disabled:!h.enabled,"aria-label":"Run schedule now",className:"flex items-center gap-2 px-4 py-2.5 sm:py-2 rounded-xl text-sm font-medium bg-[#FFB52B]/15 text-[#FFB52B] hover:bg-[#FFB52B]/25 border border-[#FFB52B]/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed min-h-[44px] sm:min-h-0",children:[(0,u.jsx)(kh,{className:"h-4 w-4"})," Run Now"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>v(h.id,h.enabled),"aria-label":h.enabled?"Disable schedule":"Enable schedule",className:"flex items-center gap-2 px-4 py-2.5 sm:py-2 rounded-xl text-sm font-medium border transition-colors min-h-[44px] sm:min-h-0 ".concat(h.enabled?"bg-gray-500/15 text-gray-600 dark:text-gray-300 hover:bg-gray-500/25 border-gray-500/20":"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/25 border-emerald-500/20"),children:[h.enabled?(0,u.jsx)(wh,{className:"h-4 w-4"}):(0,u.jsx)(kh,{className:"h-4 w-4"}),h.enabled?"Disable":"Enable"]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl border border-gray-200/60 dark:border-white/[0.06] bg-gray-50/80 dark:bg-white/[0.03] backdrop-blur-sm",children:[(0,u.jsx)("span",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-500 uppercase tracking-wider",children:"ID"}),(0,u.jsx)("code",{className:"text-xs text-gray-600 dark:text-gray-400 font-mono truncate flex-1",children:h.id}),(0,u.jsx)("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(h.id),be(!0),setTimeout(()=>be(!1),2e3)}catch(e){}},className:"p-1 rounded hover:bg-gray-200 dark:hover:bg-white/10 transition-colors",title:"Copy schedule ID","aria-label":"Copy schedule ID to clipboard",children:fe?(0,u.jsx)(Wm,{className:"h-3.5 w-3.5 text-emerald-500"}):(0,u.jsx)(Np,{className:"h-3.5 w-3.5 text-gray-400"})})]}),(0,u.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-4 text-gray-900 dark:text-white",children:[(0,u.jsx)(QU,{label:"Cron",value:UU(h.cronExpression),icon:(0,u.jsx)(wp,{className:"h-4 w-4"})}),(0,u.jsx)(ZU,{label:"Model",value:h.model||"Default (Opus)",field:"model",editingField:ue,editValue:he,savingField:ge,onStartEditing:ye,onEditValueChange:pe,onSave:we,onCancel:ve,onKeyDown:ke,inputType:"select",selectOptions:[{value:"",label:"Default (Opus)"},{value:"opus",label:"Opus"},{value:"sonnet",label:"Sonnet"},{value:"haiku",label:"Haiku"}],rawValue:h.model||""}),(0,u.jsx)(eV,{label:"Max Turns",field:"maxTurns",min:50,formatDisplay:e=>e>=400?"Unlimited":String(e),max:400,step:10,value:Math.min(null!==(n=h.maxTurns)&&void 0!==n?n:200,400),displayValue:(null!==(r=h.maxTurns)&&void 0!==r?r:200)>=400?"Unlimited":String(null!==(s=h.maxTurns)&&void 0!==s?s:200),editingField:ue,editValue:he,savingField:ge,onStartEditing:(e,t)=>
2ye(e,String(Math.min(Number(t)||200,400))),onEditValueChange:pe,onSave:e=>{Number(he)>=400&&pe("999999"),we(e)},onCancel:ve,ticks:["50","100","200","300","\u221e"]}),(0,u.jsx)(eV,{label:"Max Runtime",value:JU(null!==(i=h.maxRuntimeSeconds)&&void 0!==i?i:600),field:"maxRuntimeSeconds",editingField:ue,editValue:he,savingField:ge,onStartEditing:ye,onEditValueChange:pe,onSave:we,onCancel:ve,rawValue:String(null!==(o=h.maxRuntimeSeconds)&&void 0!==o?o:600)}),(0,u.jsx)(ZU,{label:"Cost Limit",value:h.maxCostUsd?"$".concat(h.maxCostUsd):"None",field:"maxCostUsd",editingField:ue,editValue:he,savingField:ge,onStartEditing:ye,onEditValueChange:pe,onSave:we,onCancel:ve,onKeyDown:ke,inputType:"number",rawValue:h.maxCostUsd?String(h.maxCostUsd):""}),(0,u.jsx)(QU,{label:"Total Cost",value:"$".concat((null!==(l=h.totalCostUsd)&&void 0!==l?l:0).toFixed(2))}),(0,u.jsx)(QU,{label:"Total Runs",value:String(null!==(c=h.runCount)&&void 0!==c?c:0)}),(0,u.jsx)(QU,{label:"Avg Runtime",value:JU(Ee)}),(0,u.jsx)(QU,{label:"Current Run",value:null!=Se?(0,u.jsx)("span",{title:WU(null===Fe||void 0===Fe?void 0:Fe.createdAt)||void 0,children:JU(Se)}):"Idle"}),(0,u.jsx)(QU,{label:"Consecutive Failures",value:String(null!==(d=h.consecutiveFailures)&&void 0!==d?d:0)}),(0,u.jsx)(QU,{label:"Last Run",value:(0,u.jsx)(GU,{dateStr:h.lastRunAt})}),(0,u.jsx)(QU,{label:"Next Run",value:h.enabled?(0,u.jsx)("span",{title:WU(h.nextRunAt)||void 0,children:qU(h.nextRunAt)||(0,u.jsx)(GU,{dateStr:h.nextRunAt})}):"Disabled"}),(0,u.jsx)(QU,{label:"Pending Events",value:M.length>0?(0,u.jsx)("button",{type:"button",onClick:()=>j("events"),className:"text-left text-amber-600 transition-colors hover:text-amber-500 dark:text-amber-400 dark:hover:text-amber-300",children:Ae}):Ae}),(0,u.jsx)(QU,{label:"Created",value:(0,u.jsx)(GU,{dateStr:h.createdAt})}),(0,u.jsx)(QU,{label:"Created By",value:h.createdBy||"--"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2",children:"Triggers"}),(0,u.jsxs)("div",{className:"space-y-2",children:[!h.cronExpression&&!(Array.isArray(h.eventTriggers)&&h.eventTriggers.length>0)&&!h.dependsOnScheduleId&&(0,u.jsx)("p",{className:"text-sm text-gray-400 dark:text-gray-500 italic",children:"No triggers configured"}),h.cronExpression&&(0,u.jsxs)("div",{className:"flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300",children:[(0,u.jsx)(wp,{className:"h-4 w-4 text-gray-400 dark:text-gray-500 flex-shrink-0 mt-0.5"}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 min-w-0",children:[(0,u.jsx)("span",{className:"font-mono text-xs bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded px-2 py-0.5",children:h.cronExpression}),(0,u.jsx)("span",{className:"text-gray-500 text-xs sm:text-sm",children:UU(h.cronExpression)})]})]}),Array.isArray(h.eventTriggers)&&h.eventTriggers.length>0&&(0,u.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,u.jsx)(hh,{className:"h-4 w-4 text-amber-500 mt-0.5"}),(0,u.jsx)("div",{className:"flex flex-wrap gap-1.5",children:(h.eventTriggers||[]).map(e=>(0,u.jsx)("span",{className:"px-2 py-0.5 rounded-lg bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 text-xs font-medium",children:e},e))})]}),h.dependsOnScheduleId&&(0,u.jsxs)("div",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[(0,u.jsx)(DU,{className:"h-4 w-4 text-purple-400"}),(0,u.jsxs)("span",{children:["Depends on: ",(0,u.jsx)("span",{className:"font-mono text-xs",children:h.dependsOnScheduleId})]})]}),(null!==(m=h.eventDelaySeconds)&&void 0!==m?m:0)>0&&(0,u.jsxs)("div",{className:"text-xs text-gray-500",children:["Event delay: ",h.eventDelaySeconds,"s debounce"]}),M.length>0&&(0,u.jsxs)("div",{className:"text-xs text-amber-600 dark:text-amber-400",children:[M.length," pending event",1===M.length?"":"s"," queued"]})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2",children:"Recent Runs"}),(0,u.jsx)(MU,{runs:w,maxVisible:12})]})]}),"prompt"===k&&(0,u.jsx)("div",{className:"flex-1 min-h-0 flex flex-col p-4 sm:p-5",children:K?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)(Lo,{className:"h-6 w-6 animate-spin text-gray-400"})}):(0,u.jsxs)(u.Fragment,{children:[ne&&(0,u.jsx)("div",{className:"p-3 rounded-xl bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20 text-red-600 dark:text-red-400 text-sm flex-shrink-0 mb-3",children:ne}),(0,u.jsxs)("div",{className:"flex items-center justify-between mb-2 flex-shrink-0",children:[(0,u.jsx)("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Active Prompt"}),!J&&(0,u.jsx)("button",{type:"button",onClick:()=>$(!0),className:"text-xs text-[#FFB52B] hover:text-[#FFB52B]/80 transition-colors",children:"Edit"})]}),(0,u.jsx)("textarea",{value:J?q:V,onChange:e=>W(e.target.value),readOnly:!J,className:"\n w-full flex-1 min-h-0 rounded-xl border p-3 text-sm font-mono resize-none\n bg-gray-50 dark:bg-gray-900/50 text-gray-900 dark:text-gray-200 placeholder-gray-400 dark:placeholder-gray-500\n ".concat(J?"border-[#FFB52B]/30 focus:border-[#FFB52B]/50 focus:ring-1 focus:ring-[#FFB52B]/20":"border-gray-200 dark:border-white/10 cursor-default","\n focus:outline-none\n ")}),J&&(0,u.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 mt-3 flex-shrink-0",children:[(0,u.jsx)("input",{type:"text",value:ee,onChange:e=>te(e.target.value),placeholder:"Change summary (optional)",className:"flex-1 px-3 py-2 sm:py-1.5 rounded-lg border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-gray-900/50 text-sm text-gray-900 dark:text-gray-200 placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:border-[#FFB52B]/50 dark:focus:border-[#FFB52B]/30"}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsxs)("button",{type:"button",onClick:async()=>{Z(!0),ae(null);try{await kU.updatePrompt(h.id,q,ee||void 0,g),$(!1),te(""),await Ce()}catch(e){ae(e.message||"Failed to save prompt")}finally{Z(!1)}},disabled:Q||q===V,className:"flex items-center gap-1.5 px-3 py-2 sm:py-1.5 rounded-lg text-xs font-medium bg-[#FFB52B]/15 text-[#FFB52B] hover:bg-[#FFB52B]/25 border border-[#FFB52B]/20 transition-colors disabled:opacity-50 min-h-[44px] sm:min-h-0",children:[Q?(0,u.jsx)(Lo,{className:"h-3 w-3 animate-spin"}):(0,u.jsx)(Dh,{className:"h-3 w-3"}),"Save"]}),(0,u.jsx)("button",{type:"button",onClick:()=>{$(!1),W(V),te("")},className:"px-3 py-2 sm:py-1.5 rounded-lg text-xs font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors min-h-[44px] sm:min-h-0",children:"Cancel"})]})]}),Y.length>0&&(0,u.jsxs)("div",{className:"mt-4 flex-shrink-0",children:[(0,u.jsx)("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2",children:"Version History"}),(0,u.jsx)("div",{className:"space-y-1.5 max-h-48 overflow-y-auto",children:Y.map(e=>(0,u.jsxs)("div",{className:"\n flex items-center justify-between p-2.5 rounded-lg border transition-colors\n ".concat(e.isActive?"border-[#FFB52B]/30 bg-[#FFB52B]/5":"border-gray-200 dark:border-white/5 bg-gray-50 dark:bg-gray-900/30 hover:bg-gray-100 dark:hover:bg-gray-900/50","\n "),children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsxs)("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-300",children:["v",e.versionNumber]}),e.isActive&&(0,u.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[#FFB52B]/20 text-[#FFB52B]",children:"active"})]}),(0,u.jsx)("div",{className:"text-[11px] text-gray-500 dark:text-gray-500 truncate",children:e.changeSummary||"No change summary"}),(0,u.jsxs)("div",{className:"text-[10px] text-gray-400 dark:text-gray-600",children:[(0,u.jsx)(GU,{dateStr:e.createdAt})," by ",e.createdBy]})]}),!e.isActive&&(0,u.jsxs)("button",{type:"button",onClick:()=>(async e=>{try{await kU.activatePromptVersion(h.id,e,g),await Ce()}catch(t){ae(t.message||"Failed to activate version")}})(e.id),className:"ml-3 flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors",children:[(0,u.jsx)(Cy,{className:"h-3 w-3"})," Revert"]})]},e.id))})]})]})}),"logs"===k&&(0,u.jsxs)("div",{className:"p-4 sm:p-5 space-y-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,u.jsxs)("select",{value:A,onChange:e=>T(e.target.value),"aria-label":"Filter log entries by type",className:"pl-3 pr-8 py-1.5 rounded-lg border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-gray-900/50 text-xs text-gray-700 dark:text-gray-300 focus:outline-none focus:border-[#FFB52B]/50 dark:focus:border-[#FFB52B]/30 appearance-none bg-[url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20fill%3D%22none%22%20stroke%3D%22%236b7280%22%20stroke-width%3D%222%22%3E%3Cpath%20d%3D%22m2%204%204%204%204-4%22%2F%3
2E%3C%2Fsvg%3E')] bg-[length:12px] bg-[right_8px_center] bg-no-repeat",children:[(0,u.jsx)("option",{value:"",children:"All types"}),(0,u.jsx)("option",{value:"info",children:"Info"}),(0,u.jsx)("option",{value:"warning",children:"Warning"}),(0,u.jsx)("option",{value:"error",children:"Error"}),(0,u.jsx)("option",{value:"context",children:"Context"}),(0,u.jsx)("option",{value:"run_start",children:"Run Start"}),(0,u.jsx)("option",{value:"run_end",children:"Run End"})]}),(0,u.jsx)("button",{type:"button",onClick:je,disabled:N,"aria-label":"Refresh logs",className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",children:(0,u.jsx)(Cy,{className:"h-3.5 w-3.5 text-gray-400 ".concat(N?"animate-spin":"")})}),re&&(0,u.jsxs)("span",{className:"text-[10px] text-blue-400 flex items-center gap-1",children:[(0,u.jsx)("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-400 animate-pulse"}),"Auto-refreshing"]})]}),S&&(0,u.jsx)("div",{className:"p-3 rounded-xl bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20 text-red-600 dark:text-red-400 text-sm",children:S}),N&&0===D.length?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)(Lo,{className:"h-6 w-6 animate-spin text-gray-400"})}):0===D.length?(0,u.jsx)("div",{className:"text-center py-12 text-gray-500 text-sm",children:"No log entries"}):(0,u.jsx)("div",{className:"space-y-1",children:D.map(e=>(0,u.jsxs)("div",{className:"flex items-start gap-2 p-2.5 rounded-lg border border-gray-200/60 dark:border-white/[0.06] bg-gray-50/80 dark:bg-white/[0.03] hover:bg-gray-100 dark:hover:bg-white/[0.05] backdrop-blur-sm transition-colors",children:[KU(e.logType),(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,u.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded ".concat(XU(e.logType)),children:e.logType}),(0,u.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-gray-600",children:(0,u.jsx)(GU,{dateStr:e.createdAt})})]}),(0,u.jsx)("p",{className:"text-xs text-gray-700 dark:text-gray-300 whitespace-pre-wrap break-words",children:e.message})]})]},e.id))})]}),"events"===k&&(0,u.jsxs)("div",{className:"p-4 sm:p-5 space-y-3",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Queued Event Triggers"}),(0,u.jsx)("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-500",children:"Inspect delayed event payloads and cancel them before they fire."})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)("button",{type:"button",onClick:De,disabled:B,"aria-label":"Refresh pending events",className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",children:(0,u.jsx)(Cy,{className:"h-3.5 w-3.5 text-gray-400 ".concat(B?"animate-spin":"")})}),(0,u.jsxs)("button",{type:"button",onClick:async()=>{if(0!==M.length&&window.confirm("Cancel ".concat(M.length," pending event").concat(1===M.length?"":"s",' for "').concat(h.name,'"?'))){z("all"),L(null);try{await kU.cancelPendingEvents(h.id,g),U(null),await Promise.all([De(),Promise.resolve(f())])}catch(e){L((null===e||void 0===e?void 0:e.message)||"Failed to cancel pending events")}finally{z(null)}}},disabled:0===M.length||"all"===R,className:"flex items-center gap-2 rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs font-medium text-red-500 transition-colors hover:bg-red-500/15 disabled:cursor-not-allowed disabled:opacity-50",children:["all"===R?(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 animate-spin"}):(0,u.jsx)(gh,{className:"h-3.5 w-3.5"}),"Cancel All"]})]})]}),P&&(0,u.jsx)("div",{className:"rounded-xl border border-red-200 bg-red-50 p-3 text-sm text-red-600 dark:border-red-500/20 dark:bg-red-500/10 dark:text-red-400",children:P}),B&&0===M.length?(0,u.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,u.jsx)(Lo,{className:"h-6 w-6 animate-spin text-gray-400"})}):0===M.length?(0,u.jsx)("div",{className:"rounded-xl border border-dashed border-gray-200/80 bg-gray-50/80 p-8 text-center text-sm text-gray-500 dark:border-white/[0.08] dark:bg-white/[0.03] dark:text-gray-400",children:"No pending events."}):(0,u.jsx)("div",{className:"space-y-2",children:M.map(e=>{const t=function(e){if(null==e)return"";if("string"===typeof e){const t=e.trim();if(!t)return"";try{return JSON.stringify(JSON.parse(t),null,2)}catch(n){return e}}try{var t;return null!==(t=JSON.stringify(e,null,2))&&void 0!==t?t:String(e)}catch(a){return String(e)}}(e.eventPayloadJson),n=O===e.id,a=VU(e.fireAt),r=isNaN(a.getTime())?"--":HU(a);return(0,u.jsx)("div",{className:"rounded-xl border border-gray-200/60 bg-gray-50/80 p-3 backdrop-blur-sm dark:border-white/[0.06] dark:bg-white/[0.03]",children:(0,u.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-600 dar
2k:text-amber-400",children:[(0,u.jsx)(hh,{className:"h-3 w-3"}),e.eventName]}),(0,u.jsxs)("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",title:WU(e.createdAt)||void 0,children:["queued ",(0,u.jsx)(GU,{dateStr:e.createdAt})]})]}),(0,u.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-2 text-xs text-gray-600 dark:text-gray-300 sm:grid-cols-2",children:[(0,u.jsxs)("div",{className:"rounded-lg border border-gray-200/60 bg-white/70 px-3 py-2 dark:border-white/[0.06] dark:bg-black/10",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-500",children:"Fires At"}),(0,u.jsx)("div",{className:"mt-1 font-medium text-gray-800 dark:text-gray-100",children:qU(e.fireAt)||WU(e.fireAt)||"--"}),(0,u.jsx)("div",{className:"mt-1 text-[11px] text-amber-600 dark:text-amber-400",children:r})]}),(0,u.jsxs)("div",{className:"rounded-lg border border-gray-200/60 bg-white/70 px-3 py-2 dark:border-white/[0.06] dark:bg-black/10",children:[(0,u.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-500",children:"Source"}),(0,u.jsx)("div",{className:"mt-1 break-all font-mono text-[11px] text-gray-700 dark:text-gray-300",children:e.sessionId||"No source session"})]})]}),(0,u.jsxs)("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:["Payload: ",YU(e.eventPayloadJson)]}),n&&(0,u.jsx)("pre",{className:"mt-3 max-h-64 overflow-auto rounded-lg border border-gray-200/60 bg-gray-950 p-3 text-[11px] leading-5 text-gray-100 dark:border-white/[0.08]",children:t||"No payload"})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2 sm:ml-3 sm:flex-col sm:items-stretch",children:[(0,u.jsx)("button",{type:"button",onClick:()=>U(n?null:e.id),className:"rounded-lg border border-gray-200/80 px-3 py-2 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-100 dark:border-white/[0.08] dark:text-gray-300 dark:hover:bg-white/10",children:n?"Hide Payload":"Inspect Payload"}),(0,u.jsx)("button",{type:"button",onClick:()=>(async e=>{z(e),L(null);try{await kU.cancelPendingEvent(h.id,e,g),await Promise.all([De(),Promise.resolve(f())])}catch(t){L((null===t||void 0===t?void 0:t.message)||"Failed to cancel pending event")}finally{z(null)}})(e.id),disabled:R===e.id,className:"rounded-lg border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs font-medium text-red-500 transition-colors hover:bg-red-500/15 disabled:cursor-not-allowed disabled:opacity-50",children:R===e.id?(0,u.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,u.jsx)(Lo,{className:"h-3.5 w-3.5 animate-spin"}),"Cancelling..."]}):"Cancel Event"})]})]})},e.id)})})]}),"runs"===k&&(0,u.jsx)("div",{className:"p-4 sm:p-5",children:0===w.length?(0,u.jsx)("div",{className:"text-center py-12 text-gray-500 text-sm",children:"No runs yet"}):(0,u.jsx)("div",{className:"space-y-1.5",children:w.map(e=>{var t;const n=function(e){switch(e){case"success":return{label:"Success",className:"bg-emerald-500/20 text-emerald-400"};case"failure":return{label:"Failed",className:"bg-red-500/20 text-red-400"};case"timeout":return{label:"Timeout",className:"bg-orange-500/20 text-orange-400"};case"running":return{label:"Running",className:"bg-blue-500/20 text-blue-400"};case"pending":return{label:"Pending",className:"bg-gray-500/20 text-gray-400"};case"skipped":return{label:"Skipped",className:"bg-yellow-500/20 text-yellow-400"};default:return{label:e||"--",className:"bg-gray-500/20 text-gray-400"}}}(e.status),a=null!==(t=e.durationSeconds)&&void 0!==t?t:"running"===e.status?$U(e.createdAt,oe):null;return(0,u.jsxs)("div",{className:"flex items-start sm:items-center gap-2 sm:gap-3 p-2.5 sm:p-3 rounded-lg border border-gray-200/60 dark:border-white/[0.06] bg-gray-50/80 dark:bg-white/[0.03] hover:bg-gray-100 dark:hover:bg-white/[0.05] backdrop-blur-sm transition-colors",children:[(0,u.jsx)("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 ".concat("success"===e.status?"bg-[#FFB52B]":"failure"===e.status||"timeout"===e.status?"bg-red-500":"running"===e.status?"bg-[#FFB52B] schedule-pulse-ring":"bg-gray-400")}),(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 sm:gap-2 mb-0.5",children:[(0,u.jsx)("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded ".concat(n.className),children:n.label}),(0,u.jsx)("span",{className:"text-[10px] text-gray-500 capitalize",children:e.triggerType||"unknown"}),e.triggerEvent&&(0,u.jsx)("span",{className:"text-[10px] text-amber-500 truncate max-w-[120px] sm:max-w-none",children:e.triggerEvent})]}),(0,u.jsxs)("div",{className:"text-[11px] text-gray-500 dark:text-gray-500 flex flex-wrap gap-x-2",children:[(0,u.jsx)(GU,{dateStr:e.createdAt}),null!=a&&(0,u.jsxs)("span",{className:"running"===e.status?"text-[#B57700] dark:text-[#FFCF74]":"",children:[JU(a),"running"===e.status?" live":""]}),null!=e.totalTokens&&e.totalTokens>0&&(0,u.jsxs)("span",{children:[Number(e.totalTokens).toLocaleStr
2ing()," tokens"]}),null!=e.totalCost&&e.totalCost>0&&(0,u.jsxs)("span",{children:["$",Number(e.totalCost).toFixed(3)]})]}),e.errorMessage&&(0,u.jsx)("p",{className:"text-[11px] text-red-400 mt-0.5 truncate",children:e.errorMessage})]}),e.id&&"pending"!==e.status&&(0,u.jsx)("button",{type:"button",onClick:()=>{const t=new URLSearchParams({schedule:h.id,run:e.id});window.open("/agents?".concat(t.toString()),"_blank")},className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",title:"View agent session","aria-label":"View agent session in new tab",children:(0,u.jsx)(Ep,{className:"h-3.5 w-3.5 text-gray-400 dark:text-gray-500"})})]},e.id)})})})]})]})]})},nV=[["minute",0,59],["hour",0,23],["day-of-month",1,31],["month",1,12],["day-of-week",0,7]],aV=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function rV(e,t,n,a){if("*"===e)return null;if(e.includes("/")){const[r,s]=e.split("/"),i=parseInt(s,10);if(isNaN(i)||i<1)return"".concat(t,': invalid step value "').concat(s,'"');if("*"!==r){const e=rV(r,t,n,a);if(e)return e}return null}if(e.includes(",")){for(const r of e.split(",")){const e=rV(r.trim(),t,n,a);if(e)return e}return null}if(e.includes("-")){const[r,s]=e.split("-"),i=parseInt(r,10),o=parseInt(s,10);return isNaN(i)||isNaN(o)?"".concat(t,': invalid range "').concat(e,'"'):i<n||i>a?"".concat(t,": ").concat(i," out of range (").concat(n,"-").concat(a,")"):o<n||o>a?"".concat(t,": ").concat(o," out of range (").concat(n,"-").concat(a,")"):i>o?"".concat(t,": range start ").concat(i," > end ").concat(o):null}const r=parseInt(e,10);return isNaN(r)?"".concat(t,': "').concat(e,'" is not a valid number'):r<n||r>a?"".concat(t,": ").concat(r," out of range (").concat(n,"-").concat(a,")"):null}function sV(e){const t=e.trim().split(/\s+/);if(5!==t.length)return e;const[n,a,r,s,i]=t;if("*"===n&&"*"===a&&"*"===r&&"*"===s&&"*"===i)return"Runs every minute";if(n.startsWith("*/")&&"*"===a&&"*"===r&&"*"===s&&"*"===i){const e=parseInt(n.split("/")[1],10);return"Runs every ".concat(e," minute").concat(1===e?"":"s")}if(!n.includes("*")&&!n.includes("/")&&"*"===a&&"*"===r&&"*"===s&&"*"===i)return"Runs every hour at :".concat(n.padStart(2,"0"));if("0"===n&&a.startsWith("*/")&&"*"===r&&"*"===s&&"*"===i){const e=parseInt(a.split("/")[1],10);return"Runs every ".concat(e," hour").concat(1===e?"":"s")}if(!n.includes("*")&&!n.includes("/")&&!a.includes("*")&&!a.includes("/")&&"*"===r&&"*"===s&&"*"===i)return"Runs daily at ".concat(a.padStart(2,"0"),":").concat(n.padStart(2,"0")," UTC");if(!n.includes("*")&&!n.includes("/")&&!a.includes("*")&&!a.includes("/")&&"*"===r&&"*"===s&&"*"!==i){const e=parseInt(i,10),t=aV[e%7]||i;return"Runs weekly on ".concat(t," at ").concat(a.padStart(2,"0"),":").concat(n.padStart(2,"0")," UTC")}return n.includes("*")||n.includes("/")||a.includes("*")||a.includes("/")||r.includes("*")||"*"!==s||"*"!==i?"Cron: ".concat(e):"Runs monthly on day ".concat(r," at ").concat(a.padStart(2,"0"),":").concat(n.padStart(2,"0")," UTC")}function iV(e){if(null==e)return"--";if(e<60)return"".concat(Math.round(e),"s");const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.round(e%60);return t>0?n>0?"".concat(t,"h ").concat(n,"m"):"".concat(t,"h"):a>0?"".concat(n,"m ").concat(a,"s"):"".concat(n,"m")}const oV=[{id:"hourly",label:"Every hour",description:"At minute 0 of every hour"},{id:"every6h",label:"Every 6 hours",description:"At 00:00, 06:00, 12:00, 18:00 UTC"},{id:"daily",label:"Daily",description:"Once per day at a chosen time"},{id:"weekly",label:"Weekly",description:"Once per week on a chosen day and time"},{id:"custom",label:"Custom cron expression",description:"Full control with a raw cron expression"}],lV=Array.from({length:24},(e,t)=>String(t).padStart(2,"0")),cV=Array.from({length:12},(e,t)=>String(5*t).padStart(2,"0")),dV=lV.flatMap(e=>cV.map(t=>({value:"".concat(e,":").concat(t),label:"".concat(e,":").concat(t," UTC")}))),uV="rounded-xl border border-gray-200/90 dark:border-white/10 bg-gray-50/90 dark:bg-white/[0.04] text-gray-900 dark:text-gray-100 shadow-sm shadow-black/[0.02] dark:shadow-none placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:border-[#FFB52B]/50 dark:focus:border-[#FFB52B]/30 focus:ring-2 focus:ring-[#FFB52B]/10",mV="appearance-none bg-[url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%20fill%3D%22none%22%20stroke%3D%22%236b7280%22%20stroke-width%3D%222%22%3E%3Cpath%20d%3D%22m2%204%204%204%204-4%22%2F%3
2E%3C%2Fsvg%3E')] bg-[length:12px] bg-[right_12px_center] bg-no-repeat dark:[color-scheme:dark]",hV='# Scheduled Agent\n#\n# IMPORTANT: You are an autonomous scheduled agent. Key behaviours:\n# 1. Read recent context with: mlst-rescript agent-schedules logs SCHEDULE_ID --limit 50\n# 2. Persist durable state with: mlst-rescript agent-schedules log-write SCHEDULE_ID --level context --message "..."\n# 3. Be idempotent -- check whether the work was already done before doing it again\n# 4. Do not ask the user what to do next during the run\n# 5. If you find a directly fixable in-scope issue, remediate it in this run; otherwise log the blocker and finish cleanly\n# 6. Do not rely on workspace-local memory files as the system of record\n# 7. Log notable progress/errors clearly so they appear in the run history\n# 8. Write a context log as soon as you choose the bounded target for this run\n# 9. Keep runs focused and bounded\n#\n# Your task:\n',pV=e=>{let{isOpen:t,onClose:n,onCreated:r,token:s,existingSchedules:i}=e;const[o,l]=(0,a.useState)(""),[c,d]=(0,a.useState)(""),[m,h]=(0,a.useState)("cron"),[p,g]=(0,a.useState)("daily"),[x,f]=(0,a.useState)("03"),[b,y]=(0,a.useState)("00"),[v,w]=(0,a.useState)("1"),[k,j]=(0,a.useState)("03"),[D,C]=(0,a.useState)("00"),[N,F]=(0,a.useState)("0 3 * * *"),[S,E]=(0,a.useState)([]),[A,T]=(0,a.useState)(60),[M,_]=(0,a.useState)(""),[B,I]=(0,a.useState)(hV),[P,L]=(0,a.useState)("sonnet"),[R,z]=(0,a.useState)("high"),[O,U]=(0,a.useState)(200),[V,H]=(0,a.useState)(600),[q,W]=(0,a.useState)(""),[Y,G]=(0,a.useState)([]),[K,X]=(0,a.useState)(!1),[J,$]=(0,a.useState)(null),Q="".concat(x,":").concat(b),Z="".concat(k,":").concat(D),ee=(0,a.useMemo)(()=>{switch(p){case"hourly":return"0 * * * *";case"every6h":return"0 */6 * * *";case"daily":return"".concat(parseInt(b,10)," ").concat(parseInt(x,10)," * * *");case"weekly":return"".concat(parseInt(D,10)," ").concat(parseInt(k,10)," * * ").concat(v);case"custom":return N}},[p,x,b,v,k,D,N]),te=(0,a.useMemo)(()=>function(e){const t=e.trim();if(!t)return{valid:!1,error:"Cron expression is required"};const n=t.split(/\s+/);if(5!==n.length)return{valid:!1,error:"Cron must have exactly 5 fields (got ".concat(n.length,"). Format: minute hour day-of-month month day-of-week")};for(let a=0;a<5;a++){const[e,t,r]=nV[a],s=rV(n[a],e,t,r);if(s)return{valid:!1,error:s}}return{valid:!0,human:sV(t)}}(ee),[ee]),ne=(0,a.useMemo)(()=>te.valid?function(e){var t,n;let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;const r=e.trim().split(/\s+/);if(5!==r.length)return[];const[s,i,o,,l]=r,c=[],d=new Date,u=new Date(d);u.setSeconds(0,0),u.setMinutes(u.getMinutes()+1);const m=(e,t,n)=>{if("*"===e)return null;if(e.startsWith("*/")){const a=parseInt(e.split("/")[1],10);if(isNaN(a)||a<1)return null;const r=[];for(let e=t;e<=n;e+=a)r.push(e);return r}if(e.includes(","))return e.split(",").map(e=>parseInt(e.trim(),10)).filter(e=>!isNaN(e));if(e.includes("-")){const[t,n]=e.split("-").map(e=>parseInt(e,10)),a=[];for(let e=t;e<=n;e++)a.push(e);return a}const a=parseInt(e,10);return isNaN(a)?null:[a]},h=m(s,0,59),p=m(i,0,23),g=m(o,1,31),x=null!==(t=null===(n=m(l,0,6))||void 0===n?void 0:n.map(e=>e%7))&&void 0!==t?t:null,f=e=>!h||h.includes(e),b=e=>!p||p.includes(e),y=e=>!g||g.includes(e),v=e=>!x||x.includes(e);for(let w=0;w<527040&&c.length<a;w++)f(u.getUTCMinutes())&&b(u.getUTCHours())&&y(u.getUTCDate())&&v(u.getUTCDay())&&c.push(new Date(u)),u.setMinutes(u.getMinutes()+1);return c}(ee,3):[],[ee,te.valid]);(0,a.useEffect)(()=>{t&&kU.getEventTypes(s).then(G).catch(()=>{})},[t,s]),(0,a.useEffect)(()=>{t&&(l(""),d(""),h("cron"),g("daily"),f("03"),y("00"),w("1"),j("03"),C("00"),F("0 3 * * *"),E([]),T(60),_(""),I(hV),L("sonnet"),z("high"),U(200),H(600),W(""),$(null))},[t]);if(!t)return null;const ae=e=>{const t=aV[e.getUTCDay()],n=e.toLocaleString("en-US",{month:"short",timeZone:"UTC"}),a=e.getUTCDate(),r=String(e.getUTCHours()).padStart(2,"0"),s=String(e.getUTCMinutes()).padStart(2,"0");return"".concat(t,", ").concat(n," ").concat(a," at ").concat(r,":").concat(s," UTC")};return(0,u.jsxs)("div",{className:"fixed inset-0 z-50 flex items-end sm:items-center justify-center sm:px-4",children:[(0,u.jsx)("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:n}),(0,u.jsxs)("div",{className:"relative w-full sm:max-w-xl max-h-[92vh] sm:max-h-[85vh] overflow-y-auto rounded-t-2xl sm:rounded-2xl border border-gray-200/90 dark:border-white/12 bg-white/95 dar
2k:bg-[#1a2332]/95 backdrop-blur-2xl shadow-2xl",children:[(0,u.jsxs)("div",{className:"sticky top-0 z-10 flex items-center justify-between p-4 sm:p-5 border-b border-gray-200/90 dark:border-white/10 bg-white/95 dark:bg-[#1a2332]/95 backdrop-blur-2xl",children:[(0,u.jsx)("h2",{className:"text-base sm:text-lg font-semibold text-gray-900 dark:text-white",children:"New Agent Schedule"}),(0,u.jsx)("button",{type:"button",onClick:n,"aria-label":"Close modal",className:"p-2.5 sm:p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/10 transition-colors min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:(0,u.jsx)(Pu,{className:"h-5 w-5 text-gray-500 dark:text-gray-400"})})]}),(0,u.jsxs)("div",{className:"p-4 sm:p-5 space-y-4 sm:space-y-5",children:[J&&(0,u.jsxs)("div",{className:"flex items-start gap-2 p-3 rounded-xl bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20",children:[(0,u.jsx)(fp,{className:"h-4 w-4 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0"}),(0,u.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:J})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"schedule-name",className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5",children:"Name *"}),(0,u.jsx)("input",{id:"schedule-name",type:"text",value:o,onChange:e=>l(e.target.value),placeholder:"e.g., Daily Metadata Generation",maxLength:200,className:"w-full px-3 py-2 text-sm ".concat(uV)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"schedule-description",className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5",children:"Description"}),(0,u.jsx)("input",{id:"schedule-description",type:"text",value:c,onChange:e=>d(e.target.value),placeholder:"What does this scheduled agent do?",className:"w-full px-3 py-2 text-sm ".concat(uV)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2",children:"Trigger Type"}),(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:[{id:"cron",label:"Cron",icon:(0,u.jsx)(wp,{className:"h-3.5 w-3.5"})},{id:"event",label:"Event",icon:(0,u.jsx)(hh,{className:"h-3.5 w-3.5"})},{id:"dependency",label:"Dependency",icon:(0,u.jsx)(DU,{className:"h-3.5 w-3.5"})}].map(e=>(0,u.jsxs)("button",{type:"button",onClick:()=>h(e.id),"aria-pressed":m===e.id,className:"\n flex items-center gap-1.5 px-3 py-2.5 sm:py-2 rounded-xl text-xs font-medium border transition-all min-h-[44px] sm:min-h-0\n ".concat(m===e.id?"bg-[#FFB52B]/12 text-[#B57700] dark:text-[#FFCF74] border-[#FFB52B]/30 shadow-sm shadow-[#FFB52B]/10":"bg-white/80 dark:bg-white/[0.04] text-gray-600 dark:text-gray-300 border-gray-200/80 dark:border-white/[0.08] hover:border-gray-300 dark:hover:border-white/20","\n "),children:[e.icon,e.label]},e.id))})]}),"cron"===m&&(0,u.jsxs)("div",{className:"space-y-3",children:[(0,u.jsx)("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Schedule Frequency *"}),(0,u.jsx)("div",{className:"space-y-1.5",role:"radiogroup","aria-label":"Schedule frequency",children:oV.map(e=>(0,u.jsxs)("label",{className:"\n flex items-center gap-3 px-3 py-3 sm:py-2.5 rounded-xl border cursor-pointer transition-all min-h-[44px]\n ".concat(p===e.id?"bg-[#FFB52B]/12 border-[#FFB52B]/30 shadow-sm shadow-[#FFB52B]/10":"bg-white/80 dark:bg-white/[0.04] border-gray-200/80 dark:border-white/[0.08] hover:border-gray-300 dark:hover:border-white/20","\n "),children:[(0,u.jsx)("input",{type:"radio",name:"schedule-preset",value:e.id,checked:p===e.id,onChange:()=>g(e.id),className:"sr-only"}),(0,u.jsx)("div",{className:"\n w-4 h-4 rounded-full border-2 flex items-center justify-center flex-shrink-0\n ".concat(p===e.id?"border-[#FFB52B]":"border-gray-400 dark:border-gray-500","\n "),children:p===e.id&&(0,u.jsx)("div",{className:"w-2 h-2 rounded-full bg-[#FFB52B]"})}),(0,u.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,u.jsx)("span",{className:"text-sm font-medium ".concat(p===e.id?"text-[#FFB52B]":"text-gray-700 dark:text-gray-300"),children:e.label}
2),"daily"===e.id&&"daily"===p&&(0,u.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,u.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"at"}),(0,u.jsx)("select",{value:Q,onChange:e=>(e=>{const[t="03",n="00"]=e.split(":");f(t),y(n)})(e.target.value),className:"min-w-[10.5rem] px-3 py-2 pr-10 text-sm sm:text-xs ".concat(uV," ").concat(mV),children:dV.map(e=>{let{value:t,label:n}=e;return(0,u.jsx)("option",{value:t,children:n},t)})})]}),"weekly"===e.id&&"weekly"===p&&(0,u.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,u.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"on"}),(0,u.jsx)("select",{value:v,onChange:e=>w(e.target.value),className:"min-w-[9rem] px-3 py-2 pr-10 text-sm sm:text-xs ".concat(uV," ").concat(mV),children:aV.map((e,t)=>(0,u.jsx)("option",{value:String(t),children:e},t))}),(0,u.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"at"}),(0,u.jsx)("select",{value:Z,onChange:e=>(e=>{const[t="03",n="00"]=e.split(":");j(t),C(n)})(e.target.value),className:"min-w-[10.5rem] px-3 py-2 pr-10 text-sm sm:text-xs ".concat(uV," ").concat(mV),children:dV.map(e=>{let{value:t,label:n}=e;return(0,u.jsx)("option",{value:t,children:n},t)})})]}),"custom"===e.id&&"custom"===p&&(0,u.jsxs)("div",{className:"mt-2",children:[(0,u.jsx)("input",{type:"text",value:N,onChange:e=>F(e.target.value),placeholder:"0 3 * * *","aria-label":"Custom cron expression",className:"w-full px-3 py-1.5 text-xs font-mono ".concat(uV)}),(0,u.jsx)("p",{className:"text-[10px] text-gray-500 dark:text-gray-400 mt-1",children:"Format: minute hour day-of-month month day-of-week"})]})]})]},e.id))}),(0,u.jsxs)("div",{className:"\n flex items-start gap-2 px-3 py-2.5 rounded-xl border text-sm\n ".concat(te.valid?"bg-emerald-50 dark:bg-emerald-500/5 border-emerald-200 dark:border-emerald-500/20":"bg-red-50 dark:bg-red-500/5 border-red-200 dark:border-red-500/20","\n "),children:[te.valid?(0,u.jsx)(Ej,{className:"h-4 w-4 text-emerald-500 dark:text-emerald-400 mt-0.5 flex-shrink-0"}):(0,u.jsx)(gh,{className:"h-4 w-4 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0"}),(0,u.jsx)("div",{className:"flex-1 min-w-0",children:te.valid?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("p",{className:"text-emerald-600 dark:text-emerald-400 font-medium",children:te.human}),(0,u.jsx)("p",{className:"text-[11px] font-mono text-gray-500 dark:text-gray-400 mt-0.5",children:ee}),ne.length>0&&(0,u.jsxs)("div",{className:"mt-2 space-y-0.5",children:[(0,u.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400",children:"Next runs"}),ne.map((e,t)=>(0,u.jsxs)("div",{className:"flex items-center gap-1 text-[11px] text-gray-400",children:[(0,u.jsx)(bp,{className:"h-3 w-3 text-gray-600"}),ae(e)]},t))]})]}):(0,u.jsx)("p",{className:"text-red-600 dark:text-red-400",children:te.error})})]})]}),"event"===m&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2",children:"Event Triggers *"}),(0,u.jsx)("div",{className:"flex flex-wrap gap-1.5",children:(Y.length>0?Y.map(e=>e.name):["session.created","session.published","transcript.refined","metadata.finalized","upload.completed","youtube.synced","share.created","arrangement.version_created","video.source_downloaded","video.proxy_ready","video.clip_extracted","agent.session_completed"]).map(e=>(0,u.jsx)("button",{type:"button",onClick:()=>(e=>{E(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])})(e),"aria-pressed":S.includes(e),className:"\n px-2.5 py-1.5 sm:px-2 sm:py-1 rounded-lg text-xs font-medium border transition-all min-h-[36px] sm:min-h-0\n ".concat(S.includes(e)?"bg-amber-500/12 text-amber-700 dark:text-amber-300 border-amber-500/30":"bg-white/80 dark:bg-white/[0.04] text-gray-600 dark:text-gray-300 border-gray-200/80 dark:border-white/[0.08] hover:border-gray-300 dark:hover:border-white/20 hover:text-gray-700 dark:hover:text-gray-200","\n "),children:e},e))})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"event-delay",className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5",children:"Event Delay (seconds)"}),(0,u.jsx)("input",{id:"event-delay",type:"number",value:A,onChange:e=>T(parseInt(e.target.value)||0),min:0,className:"w-24 px-3 py-2 text-sm ".concat(uV)}),(0,u.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:"Debounce period before the event-triggered run f
2ires"})]})]}),"dependency"===m&&(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"depends-on-schedule",className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5",children:"Depends On Schedule *"}),(0,u.jsxs)("select",{id:"depends-on-schedule",value:M,onChange:e=>_(e.target.value),className:"w-full px-3 py-2 pr-10 text-sm ".concat(uV," ").concat(mV),children:[(0,u.jsx)("option",{value:"",children:"Select a schedule..."}),(i||[]).map(e=>(0,u.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,u.jsx)("p",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:"This schedule will fire when the selected schedule completes successfully"})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"schedule-prompt",className:"block text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-1.5",children:"Prompt *"}),(0,u.jsx)("textarea",{id:"schedule-prompt",value:B,onChange:e=>I(e.target.value),rows:8,className:"w-full px-3 py-2 text-sm font-mono resize-y ".concat(uV),placeholder:"Instructions for the scheduled agent..."})]}),(0,u.jsxs)("details",{className:"group",children:[(0,u.jsxs)("summary",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider cursor-pointer list-none flex items-center gap-1",children:[(0,u.jsx)(ik,{className:"h-3 w-3 group-open:rotate-45 transition-transform"}),"Advanced Settings"]}),(0,u.jsxs)("div",{className:"mt-3 space-y-3 pl-0 sm:pl-4",children:[(0,u.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"schedule-model",className:"mb-1 block text-[11px] text-gray-500 dark:text-gray-400",children:"Model"}),(0,u.jsx)("input",{id:"schedule-model",type:"text",value:P,onChange:e=>L(e.target.value),placeholder:"Default (Opus)",className:"w-full px-3 py-1.5 text-xs ".concat(uV)})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"schedule-reasoning",className:"mb-1 block text-[11px] text-gray-500 dark:text-gray-400",children:"Reasoning Effort"}),(0,u.jsxs)("select",{id:"schedule-reasoning",value:R,onChange:e=>z(e.target.value),className:"w-full px-3 py-1.5 pr-10 text-xs ".concat(uV," ").concat(mV),children:[(0,u.jsx)("option",{value:"low",children:"Low"}),(0,u.jsx)("option",{value:"medium",children:"Medium"}),(0,u.jsx)("option",{value:"high",children:"High"})]})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"schedule-max-turns",className:"mb-1 block text-[11px] text-gray-500 dark:text-gray-400",children:"Max Turns"}),(0,u.jsx)("input",{id:"schedule-max-turns",type:"number",value:O,onChange:e=>U(parseInt(e.target.value)||50),min:1,className:"w-full px-3 py-1.5 text-xs ".concat(uV)})]}),(0,u.jsx)("div",{className:"sm:col-span-2",children:(0,u.jsxs)("div",{className:"space-y-1",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsx)("label",{htmlFor:"schedule-max-runtime",className:"text-[11px] text-gray-500 dark:text-gray-400",children:"Max Runtime"}),(0,u.jsx)("span",{className:"text-sm font-mono text-gray-700 dark:text-gray-300",children:iV(V)})]}),(0,u.jsx)("input",{id:"schedule-max-runtime",type:"range",min:60,max:7200,step:60,value:V,onChange:e=>H(parseInt(e.target.value)||600),className:"w-full accent-[#FFB52B]"}),(0,u.jsxs)("div",{className:"flex justify-between text-[9px] text-gray-400",children:[(0,u.jsx)("span",{children:"1m"}),(0,u.jsx)("span",{children:"15m"}),(0,u.jsx)("span",{children:"30m"}),(0,u.jsx)("span",{children:"1h"}),(0,u.jsx)("span",{children:"2h"})]})]})})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("label",{htmlFor:"schedule-cost-limit",className:"mb-1 block text-[11px] text-gray-500 dark:text-gray-400",children:"Cost Limit (USD, optional)"}),(0,u.jsx)("input",{id:"schedule-cost-limit",type:"text",value:q,onChange:e=>W(e.target.value),placeholder:"No limit",className:"w-32 px-3 py-1.5 text-xs ".concat(uV)})]})]})]}),(0,u.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row items-stretch sm:items-center justify-end gap-2 sm:gap-3 pt-2 pb-2 sm:pb-0",children:[(0,u.jsx)("button",{type:"button",onClick:n,className:"px-4 py-2.5 sm:py-2 rounded-xl text-sm text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors min-h-[44px] sm:min-h-0",children:"Cancel"}),(0,u.jsxs)("button",{type:"button",onClick:async()=>
2{if(!o.trim())return void $("Name is required");if(!B.trim())return void $("Prompt is required");if("cron"===m&&!te.valid)return void $(te.error||"Invalid cron expression");if("event"===m&&0===S.length)return void $("At least one event trigger is required");if("dependency"===m&&!M)return void $("Select a schedule to depend on");X(!0),$(null);const e={name:o.trim(),description:c.trim()||void 0,prompt:B.trim(),cronExpression:"cron"===m?ee:null,eventTriggers:"event"===m?S:void 0,eventDelaySeconds:"event"===m?A:void 0,dependsOnScheduleId:"dependency"===m?M:null,model:P||void 0,reasoningEffort:R,maxTurns:O,maxRuntimeSeconds:V,maxCostUsd:q?parseFloat(q):null};try{const t=await kU.create(e,s);r(t),n()}catch(t){$(t.message||"Failed to create schedule")}finally{X(!1)}},disabled:K,"aria-label":"Create schedule",className:"flex items-center justify-center gap-2 px-5 py-2.5 sm:py-2 rounded-xl text-sm font-medium bg-[#FFB52B] text-gray-900 hover:bg-[#FFB52B]/90 transition-colors disabled:opacity-50 min-h-[44px] sm:min-h-0",children:[K?(0,u.jsx)(Lo,{className:"h-4 w-4 animate-spin"}):(0,u.jsx)(ik,{className:"h-4 w-4"}),"Create Schedule"]})]})]})]})]})},gV=()=>{var e;const t=oc(),{isAuthenticated:n,isLoading:r,token:s}=am(),{isDarkMode:i,toggleDarkMode:o}=zu(),[l,c]=(0,a.useState)([]),[d,m]=(0,a.useState)({}),[h,p]=(0,a.useState)(!0),[g,x]=(0,a.useState)(null),[f,b]=(0,a.useState)(null),[y,v]=(0,a.useState)(!1),[w,k]=(0,a.useState)(null),j=f&&null!==(e=l.find(e=>e.id===f))&&void 0!==e?e:null,D=(0,a.useRef)(null),C=(0,a.useCallback)(async()=>{if(s)try{const e=await kU.list(s);c(e);const t=e.map(async e=>{try{const t=await kU.getRuns(e.id,s,10);return{id:e.id,runs:t}}catch(_H){return{id:e.id,runs:[]}}}),n=await Promise.all(t),a={};n.forEach(e=>{a[e.id]=e.runs}),m(a),x(null)}catch(e){x(e.message||"Failed to load schedules")}finally{p(!1)}},[s]);(0,a.useEffect)(()=>{!r&&n&&C()},[r,n,C]),(0,a.useEffect)(()=>(l.some(e=>e.currentRunAgentSessionId)?D.current=setInterval(C,8e3):D.current&&clearInterval(D.current),()=>{D.current&&clearInterval(D.current)}),[l,C]);const N=async e=>{k(e);try{await kU.runNow(e,s||void 0),await C()}catch(t){alert(t.message||"Failed to run schedule")}finally{k(null)}},F=async e=>{k(e);try{await kU.stop(e,s||void 0),await C()}catch(t){alert(t.message||"Failed to stop schedule")}finally{k(null)}},S=async(e,t)=>{k(e);try{t?await kU.disable(e,s||void 0):await kU.enable(e,s||void 0),await C()}catch(n){alert(n.message||"Failed to toggle schedule")}finally{k(null)}},E=async e=>{const t=l.find(t=>t.id===e);if(window.confirm('Delete schedule "'.concat((null===t||void 0===t?void 0:t.name)||e,'"? This cannot be undone.'))){k(e);try{await kU.delete(e,s||void 0),b(null),await C()}catch(n){alert(n.message||"Failed to delete schedule")}finally{k(null)}}},A=(0,a.useCallback)((e,t)=>{const n=new URLSearchParams({schedule:e,run:t.id});window.open("/agents?".concat(n.toString()),"_blank")},[]);return r?(0,u.jsx)("div",{className:"min-h-screen flex items-center justify-center ".concat(i?"bg-[#0f1623]":"bg-gray-50"),children:(0,u.jsx)(Lo,{className:"h-8 w-8 animate-spin text-[#FFB52B]"})}):n?(0,u.jsxs)("div",{className:"min-h-screen ".concat(i?"dark bg-[#0f1623]":"bg-gray-50"),children:[(0,u.jsxs)("div",{className:"fixed inset-0 pointer-events-none",children:[(0,u.jsx)("div",{className:"absolute top-0 left-1/4 w-[500px] h-[500px] rounded-full bg-[#FFB52B]/[0.04] blur-[120px]"}),(0,u.jsx)("div",{className:"absolute bottom-0 right-1/4 w-[400px] h-[400px] rounded-full bg-[#1a2332]/30 blur-[100px]"})]}),(0,u.jsxs)("div",{className:"relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[(0,u.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6 sm:mb-8",children:[(0,u.jsxs)("div",{className:"flex items-center gap-3 sm:gap-4 min-w-0",children:[(0,u.jsx)("button",{type:"button",onClick:()=>t("/"),"aria-label":"Go back to home",className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800/50 transition-colors flex-shrink-0",children:(0,u.jsx)(Yk,{className:"h-5 w-5 text-gray-500 dark:text-gray-400"})}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,u.jsx)(mj,{className:"h-5 w-5 sm:h-6 sm:w-6 text-[#FFB52B] flex-shrink-0"}),(0,u.jsx)("h1",{className:"text-xl sm:text-2xl font-bold text-gray-900 dark:text-white truncate",children:"Agent Schedules"})]}),(0,u.jsx)("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 mt-1 hidden sm:block",children:"Manage autonomous agent executions on cron, event triggers, and dependencies"})]})]}),(0,u.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[(0,u.jsx)("button",{type:"button",onClick:C,disabled:h,className:"p-2.5 sm:p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800/50 transition-colors",title:"Refresh","aria-label":"Refresh schedules",children:(0,u.jsx)(vp,{className:"h-4 w-4 text-gray-400 ".concat(h?"animate-spin":"")})}),(0,u.jsx)("button",{type:"button",onClick:o,className:"p-2.5 sm:p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800/50 transition-colors","aria-label":i?"Switch to light mode":"Switch to dark mode",children:i?(0,u.jsx)(LE,{className:"h-4 w-4 text-gray-400"}):(0,u.jsx)(RE,{className:"h-4 w-4 text-gray-400"})}),(0,u.jsxs)("button",{type:"button",onClick:()=>v(!0),className:"flex items-center gap-2 px-3 sm:px-4 py-2.5 rounded-xl text-sm font-semibold bg-[#FFB52B] text-gray-900 hover:bg-[#FFB52B]/90 shadow-lg shadow-[#FFB52B]/20 transition-all hover:shadow-[#FFB52B]/30",children:[(0,u.jsx)(ik,{className:"h-4 w-4"}),(0,u.jsx)("span",{className:"hidden sm:inline",children:"New Schedule"}),(0,u.jsx)("span",{className:"sm:hidden",children:"New"})]})]})]}),g&&(0,u.jsx)("div",{className:"mb-6 p-4 rounded-xl bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20 text-red-600 dark:text-red-400 text-sm",children:g}),h&&0===l.length?(0,u.jsx)("div",{className:"flex items-center justify-center py-24",children:(0,u.jsx)(Lo,{className:"h-8 w-8 animate-spin text-[#FFB52B]"})}):0===l.length?(0,u.jsxs)("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[(0,u.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-[#FFB52B]/10 flex items-center justify-center mb-4",children:(0,u.jsx)(mj,{className:"h-8 w-8 text-[#FFB52B]/60"})}),(0,u.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:"No schedules
2yet"}),(0,u.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-sm mb-6",children:"Create your first agent schedule to automate recurring AI tasks like metadata generation, transcript refinement, or YouTube sync."}),(0,u.jsxs)("button",{type:"button",onClick:()=>v(!0),className:"flex items-center gap-2 px-5 py-2.5 rounded-xl text-sm font-semibold bg-[#FFB52B] text-gray-900 hover:bg-[#FFB52B]/90 transition-colors",children:[(0,u.jsx)(ik,{className:"h-4 w-4"}),"Create First Schedule"]})]}):(0,u.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 sm:gap-4",children:l.map(e=>(0,u.jsx)(OU,{schedule:e,runs:d[e.id]||[],onRunNow:N,onStop:F,onToggleEnabled:S,onDelete:E,onSelect:e=>b(e.id),onClickRun:t=>A(e.id,t),isActioning:w===e.id},e.id))})]}),j&&(0,u.jsx)(tV,{schedule:j,runs:d[j.id]||[],token:s||"",onClose:()=>b(null),onRefresh:C,onRunNow:N,onStop:F,onToggleEnabled:S},j.id),(0,u.jsx)(pV,{isOpen:y,onClose:()=>v(!1),onCreated:()=>{C()},token:s||"",existingSchedules:l})]}):(0,u.jsx)("div",{className:"min-h-screen ".concat(i?"bg-[#0f1623]":"bg-gray-50"),children:(0,u.jsx)(ij,{})})},xV=[{id:"overview",title:"Overview",description:"Health, spend posture, and organization-wide signals."},{id:"personal",title:"Personal & YouTube",description:"Your usage footprint and your YouTube auth connection."},{id:"billing",title:"Billing & Credits",description:"Monthly defaults, credit mapping, and budget policy."},{id:"members",title:"Members",description:"Roles, removals, overrides, and per-member activity."},{id:"policy",title:"Feature Policy",description:"Global access gates across chat, agent, CLI, and exports."},{id:"activity",title:"Activity Feed",description:"Cross-org event drilldowns by user, provider, and operation."}],fV=[7,30,90,180],bV=[7,14,30,90];function yV(e){return{email:e.email,name:e.name||e.email,role:e.role,capabilityModes:(t=e.capabilities,SA.reduce((e,n)=>{var a;return e[n.key]=!0===(a=null===t||void 0===t?void 0:t[n.key])?"allow":!1===a?"disable":"inherit",e},{}))};var t}function vV(e){var t;const n=null===(t=e.billing)||void 0===t?void 0:t.override;return{isUnlimited:!(null===n||void 0===n||!n.isUnlimited),monthlyCreditLimit:null!==(null===n||void 0===n?void 0:n.monthlyCreditLimit)&&void 0!==(null===n||void 0===n?void 0:n.monthlyCreditLimit)?String(n.monthlyCreditLimit):"",monthlyUsdLimit:null!==(null===n||void 0===n?void 0:n.monthlyUsdLimit)&&void 0!==(null===n||void 0===n?void 0:n.monthlyUsdLimit)?String(n.monthlyUsdLimit):""}}function wV(){return{email:"",name:"",role:"reader",capabilityModes:SA.reduce((e,t)=>(e[t.key]="inherit",e),{})}}function kV(e){return e?SA.filter(t=>!0===e[t.key]).length:0}function jV(e){return e.trim().toLowerCase()}function DV(e){return e.trim()}function CV(e){const t=DV(e);if(!t)return null;const n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function NV(e){if(null===e||void 0===e)return"0%";const t=Number(e);return Number.isFinite(t)?"".concat(Math.round(t),"%"):"0%"}function FV(e){const t=String(e||"").trim().toLowerCase();return t?t.replace(/_/g," "):"unknown"}function SV(e){if(!e)return"No expiry recorded";const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=t.getTime()-Date.now();if(n<=0)return"Expired";const a=n/36e5;return a<1?"".concat(Math.max(1,Math.round(n/6e4))," min remaining"):a<48?"".concat(Math.round(a)," hr remaining"):"".concat(Math.round(a/24)," day").concat(1===Math.round(a/24)?"":"s"," remaining")}function EV(e){let{isDarkMode:t,title:n,description:a,badge:r,active:s,onClick:i}=e;return(0,u.jsx)("button",{type:"button",onClick:i,className:"w-full rounded-2xl border px-4 py-3 text-left transition-all ".concat(s?t?"border-brand-yellow/50 bg-brand-yellow/10 text-white shadow-[0_0_0_1px_rgba(255,181,43,0.18)]":"border-[#e7c572] bg-[#fff6e5] text-gray-900 shadow-[0_0_0_1px_rgba(255,181,43,0.12)]":t?"border-gray-800 bg-gray-950/40 text-gray-100 hover:border-gray-700 hover:bg-gray-900/70":"border-gray-200 bg-white text-gray-900 hover:border-gray-300 hover:bg-gray-50"),children:(0,u.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("strong",{className:"block text-sm font-semibold",children:n}),(0,u.jsx)("span",{className:"mt-1 block text-xs ".concat(t?"text-gray-400":"text-gray-600"),children:a})]}),(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 text-[11px] font-medium ".concat(s?"bg-brand-yellow text-brand-navy":t?"bg-gray-800 text-gray-300":"bg-gray-100 text-gray-600"),children:r})]})})}function AV(e){let{isDarkMode:t,options:n,value:a,onChange:r}=e;return(0,u.jsx)("div",{className:"inline-flex flex-wrap gap-2 rounded-2xl ".concat(t?"bg-gray-950/50":"bg-white"),children:n.map(e=>(0,u.jsx)("button",{type:"button",onClick:()=>r(e.value),className:"rounded-xl px-3 py-2 text-sm font-medium transition-colors ".concat(e.value===a?"bg-brand-yellow text-brand-navy":t?"bg-gray-900 text-gray-300 hover:bg-gray-800":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:e.label},e.value))})}function TV(e){let{isDarkMode:t,title:n,description:a,children:r}=e;return(0,u.jsxs)("section",{className:"rounded-[32px] border p-5 ".concat(t?"border-gray-800 bg-gray-900/50":"border-gray-200 bg-gray-50/80"),children:[(0,u.jsxs)("div",{className:"mb-5 flex flex-col gap-2",children:[(0,u.jsx)("h3",{className:"text-xl font-semibold",children:n}),a?(0,u.jsx)("p",{className:"text-sm ".concat(t?"text-gray-400":"text-gray-600"),children:a}):null]}),r]})}function MV(e){let{isDarkMode:t,title:n,description:a,items:r,emptyText:s,primaryLabel:i,secondaryLabel:o}=e;const l=r.reduce((e,t)=>
2Math.max(e,t.value),0),c=e=>"credits"===(null===o||void 0===o?void 0:o.toLowerCase())?IA(e):BA(e);return(0,u.jsx)(TV,{isDarkMode:t,title:n,description:a,children:0===r.length?(0,u.jsx)("p",{className:t?"text-gray-400":"text-gray-600",children:s}):(0,u.jsx)("div",{className:"space-y-4",children:r.map(e=>{const n=l>0?Math.max(8,Math.round(e.value/l*100)):8;return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"truncate text-sm font-medium",children:e.label}),e.detail?(0,u.jsx)("p",{className:"mt-0.5 text-xs ".concat("text-gray-500"),children:e.detail}):null]}),(0,u.jsxs)("div",{className:"text-right",children:[(0,u.jsx)("p",{className:"text-sm font-semibold",children:_A(e.value)}),o&&void 0!==e.secondaryValue?(0,u.jsxs)("p",{className:"text-xs ".concat("text-gray-500"),children:[c(e.secondaryValue)," ",o.toLowerCase()]}):null]})]}),(0,u.jsx)("div",{className:"h-2.5 overflow-hidden rounded-full ".concat(t?"bg-gray-800":"bg-gray-200"),children:(0,u.jsx)("div",{className:"h-full rounded-full bg-gradient-to-r from-brand-navy via-[#41526a] to-brand-yellow",style:{width:"".concat(n,"%")},title:"".concat(i,": ").concat(_A(e.value)).concat(o&&void 0!==e.secondaryValue?" \xb7 ".concat(o,": ").concat(c(e.secondaryValue)):"")})})]},"".concat(e.label,"-").concat(e.value))})})})}function _V(e){let{isDarkMode:t,title:n,description:a,groups:r,emptyText:s,primaryLabel:i,secondaryLabel:o}=e;const l=r.filter(e=>e.items.length>0),c=l.reduce((e,t)=>Math.max(e,...t.items.map(e=>e.value),0),0),d=e=>"credits"===(null===o||void 0===o?void 0:o.toLowerCase())?IA(e):BA(e);return(0,u.jsx)(TV,{isDarkMode:t,title:n,description:a,children:0===l.length?(0,u.jsx)("p",{className:t?"text-gray-400":"text-gray-600",children:s}):(0,u.jsx)("div",{className:"space-y-5",children:l.map(e=>(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsx)("div",{className:"border-b border-dashed border-gray-200 pb-2 dark:border-gray-700",children:(0,u.jsx)("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] ".concat(t?"text-gray-400":"text-gray-500"),children:e.title})}),e.items.map(n=>{const a=c>0?Math.max(8,Math.round(n.value/c*100)):8;return(0,u.jsxs)("div",{className:"space-y-2",children:[(0,u.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"truncate text-sm font-medium",children:n.label}),n.detail?(0,u.jsx)("p",{className:"mt-0.5 text-xs ".concat("text-gray-500"),children:n.detail}):null]}),(0,u.jsxs)("div",{className:"text-right",children:[(0,u.jsx)("p",{className:"text-sm font-semibold",children:_A(n.value)}),o&&void 0!==n.secondaryValue?(0,u.jsxs)("p",{className:"text-xs ".concat("text-gray-500"),children:[d(n.secondaryValue)," ",o.toLowerCase()]}):null]})]}),(0,u.jsx)("div",{className:"h-2.5 overflow-hidden rounded-full ".concat(t?"bg-gray-800":"bg-gray-200"),children:(0,u.jsx)("div",{className:"h-full rounded-full bg-gradient-to-r from-brand-navy via-[#41526a] to-brand-yellow",style:{width:"".concat(a,"%")},title:"".concat(i,": ").concat(_A(n.value)).concat(o&&void 0!==n.secondaryValue?" \xb7 ".concat(o,": ").concat(d(n.secondaryValue)):"")})})]},"".concat(e.title,"-").concat(n.label,"-").concat(n.value))})]},e.title))})})}function BV(e){let{icon:t,isDarkMode:n,label:a,value:r,hint:s}=e;return(0,u.jsxs)("div",{className:"rounded-2xl border p-4 ".concat(n?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-gray-50"),children:[(0,u.jsx)("div",{className:"mb-3 inline-flex h-10 w-10 items-center justify-center rounded-xl ".concat(n?"bg-gray-800 text-gray-200":"bg-white text-gray-700"),children:t}),(0,u.jsx)("p",{className:"text-sm ".concat(n?"text-gray-400":"text-gray-600"),children:a}),(0,u.jsx)("p",{className:"mt-1 text-xl font-semibold",children:r}),s?(0,u.jsx)("p",{className:"mt-1 text-xs ".concat("text-gray-500"),children:s}):null]})}function IV(e){let{label:t,value:n,onChange:a,disabled:r=!1,placeholder:s,inputClass:i}=e;return(0,u.jsxs)("label",{className:"block",children:[(0,u.jsx)("p",{className:"mb-2 text-sm font-medium",children:t}),(0,u.jsx)("input",{type:"number",min:"0",step:"0.1",value:n,onChange:e=>a(e.target.value),disabled:r,placeholder:s,className:i})]})}function PV(e){let{isDarkMode:t,label:n,value:a,hint:r}=e;return(0,u.jsxs)("div",{className:"rounded-2xl border p-4 ".concat(t?"border-gray-700 bg-gray-950/40":"border-gray-200 bg-white"),children:[(0,u.jsx)("p",{className:"text-xs uppercase tracking-wide ".concat("text-gray-500"),children:n}),(0,u.jsx)("p",{className:"mt-2 text-lg font-semibold",children:a}
2),r?(0,u.jsx)("p",{className:"mt-1 text-xs ".concat("text-gray-500"),children:r}):null]})}function LV(e){var t,n;let{isDarkMode:a,usage:r,fallbackDays:s}=e;const i=(null===r||void 0===r?void 0:r.recentActivity)||[],o=i.reduce((e,t)=>Math.max(e,t.events),0);return(0,u.jsxs)("div",{className:"rounded-2xl border p-4 ".concat(a?"border-gray-700 bg-gray-950/40":"border-gray-200 bg-white"),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-xs uppercase tracking-wide ".concat("text-gray-500"),children:"Activity pattern"}),(0,u.jsx)("p",{className:"mt-2 text-sm font-medium",children:i.length?"".concat(i.length," day view"):"No events in last ".concat(s," days")})]}),(0,u.jsxs)("div",{className:"text-xs ".concat("text-gray-500"),children:["Peak ",BA(o)]})]}),(0,u.jsx)("div",{className:"mt-4 flex h-16 items-end gap-1",children:(i.length?i:Array.from({length:s},()=>({date:"",events:0,totalCostUsd:0}))).map((e,t)=>{const n=o>0?Math.max(12,Math.round(e.events/o*100)):12;return(0,u.jsx)("div",{className:"flex flex-1 flex-col items-center gap-2",children:(0,u.jsx)("div",{className:"w-full rounded-t ".concat(a?"bg-brand-yellow/70":"bg-brand-navy"," ").concat(0===e.events?"opacity-25":""),style:{height:"".concat(n,"%")},title:e.date?"".concat(e.date,": ").concat(e.events," events"):"No activity"})},"".concat(e.date||"empty","-").concat(t))})}),(0,u.jsxs)("div",{className:"mt-2 flex items-center justify-between text-[11px] ".concat("text-gray-500"),children:[(0,u.jsx)("span",{children:(null===(t=i[0])||void 0===t?void 0:t.date)||"Earlier"}),(0,u.jsx)("span",{children:(null===(n=i[i.length-1])||void 0===n?void 0:n.date)||"Now"})]})]})}function RV(e){let{isDarkMode:t,points:n}=e;const a=n.length?n:Array.from({length:7},(e,t)=>({date:"day-".concat(t),events:0,totalCostUsd:0,totalCreditsUsed:0})),r=a.reduce((e,t)=>Math.max(e,t.totalCostUsd),0),s=a.reduce((e,t)=>Math.max(e,t.totalCreditsUsed),0);return(0,u.jsxs)("div",{className:"mt-4",children:[(0,u.jsx)("div",{className:"flex h-40 items-end gap-2",children:a.map((e,n)=>{const a=r>0?Math.max(10,Math.round(e.totalCostUsd/r*100)):10,i=s>0?Math.max(10,Math.round(e.totalCreditsUsed/s*100)):10;return(0,u.jsxs)("div",{className:"flex flex-1 flex-col items-center gap-2",children:[(0,u.jsxs)("div",{className:"flex h-full w-full items-end justify-center gap-1",children:[(0,u.jsx)("div",{className:"w-full rounded-t ".concat(t?"bg-brand-navy/80":"bg-brand-navy"," ").concat(0===e.totalCostUsd?"opacity-25":""),style:{height:"".concat(a,"%")},title:"".concat(e.date,": ").concat(_A(e.totalCostUsd)," cost")}),(0,u.jsx)("div",{className:"w-full rounded-t ".concat(t?"bg-brand-yellow/80":"bg-brand-yellow"," ").concat(0===e.totalCreditsUsed?"opacity-25":""),style:{height:"".concat(i,"%")},title:"".concat(e.date,": ").concat(IA(e.totalCreditsUsed)," credits")})]}),(0,u.jsx)("div",{className:"text-center text-[10px] ".concat("text-gray-500"),children:e.date==="day-".concat(n)?" ":e.date.slice(5)})]},"".concat(e.date,"-").concat(n))})}),(0,u.jsxs)("div",{className:"mt-3 flex items-center gap-4 text-xs ".concat(t?"text-gray-400":"text-gray-600"),children:[(0,u.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,u.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(t?"bg-brand-navy/80":"bg-brand-navy")}),"Cost"]}),(0,u.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,u.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(t?"bg-brand-yellow/80":"bg-brand-yellow")}),"Credits"]})]})]})}function zV(e){let{isDarkMode:t,points:n}=e;const a=n.length?n:Array.from({length:6},(e,t)=>({periodId:"month-".concat(t),events:0,totalCostUsd:0,totalCreditsUsed:0})),r=a.reduce((e,t)=>Math.max(e,t.totalCostUsd),0),s=a.reduce((e,t)=>Math.max(e,t.totalCreditsUsed),0);return(0,u.jsxs)("div",{className:"mt-4",children:[(0,u.jsx)("div",{className:"flex h-40 items-end gap-2",children:a.map((e,n)=>{const a=r>0?Math.max(10,Math.round(e.totalCostUsd/r*100)):10,i=s>0?Math.max(10,Math.round(e.totalCreditsUsed/s*100)):10;return(0,u.jsxs)("div",{className:"flex flex-1 flex-col items-center gap-2",children:[(0,u.jsxs)("div",{className:"flex h-full w-full items-end justify-center gap-1",children:[(0,u.jsx)("div",{className:"w-full rounded-t ".concat(t?"bg-brand-navy
2/80":"bg-brand-navy"," ").concat(0===e.totalCostUsd?"opacity-25":""),style:{height:"".concat(a,"%")},title:"".concat(e.periodId,": ").concat(_A(e.totalCostUsd)," cost")}),(0,u.jsx)("div",{className:"w-full rounded-t ".concat(t?"bg-brand-yellow/80":"bg-brand-yellow"," ").concat(0===e.totalCreditsUsed?"opacity-25":""),style:{height:"".concat(i,"%")},title:"".concat(e.periodId,": ").concat(IA(e.totalCreditsUsed)," credits")})]}),(0,u.jsx)("div",{className:"text-center text-[10px] ".concat("text-gray-500"),children:e.periodId==="month-".concat(n)?" ":e.periodId.slice(2)})]},"".concat(e.periodId,"-").concat(n))})}),(0,u.jsxs)("div",{className:"mt-3 flex items-center gap-4 text-xs ".concat(t?"text-gray-400":"text-gray-600"),children:[(0,u.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,u.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(t?"bg-brand-navy/80":"bg-brand-navy")}),"Cost"]}),(0,u.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,u.jsx)("span",{className:"inline-block h-2.5 w-2.5 rounded-full ".concat(t?"bg-brand-yellow/80":"bg-brand-yellow")}),"Credits"]})]})]})}function OV(e){let{isDarkMode:t,modes:n,onModeChange:a,disabled:r=!1}=e;const s="w-full rounded-xl border px-3 py-2 text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-brand-yellow ".concat(t?"border-gray-600 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900"," ").concat(r?"cursor-not-allowed opacity-70":"");return(0,u.jsx)("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:SA.map(e=>(0,u.jsxs)("label",{className:"rounded-2xl border p-3 ".concat(t?"border-gray-700 bg-gray-900/60":"border-gray-200 bg-white"),children:[(0,u.jsxs)("div",{className:"mb-2",children:[(0,u.jsx)("p",{className:"text-sm font-medium",children:e.label}),(0,u.jsx)("p",{className:"mt-1 text-xs ".concat("text-gray-500"),children:e.description})]}),(0,u.jsxs)("select",{value:n[e.key]||"inherit",onChange:t=>a(e.key,t.target.value),disabled:r,className:s,children:[(0,u.jsx)("option",{value:"inherit",children:"Inherit org policy"}),(0,u.jsx)("option",{value:"allow",children:"Allow"}),(0,u.jsx)("option",{value:"disable",children:"Disable"})]})]},e.key))})}function UV(e){let{isDarkMode:t,modes:n}=e;const a=SA.filter(e=>n[e.key]&&"inherit"!==n[e.key]);return 0===a.length?(0,u.jsx)("div",{className:"rounded-2xl border p-4 text-sm ".concat(t?"border-gray-700 bg-gray-900/60 text-gray-400":"border-gray-200 bg-white text-gray-600"),children:"No explicit member overrides. This user inherits the organization policy."}):(0,u.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(e=>{const a=n[e.key];return(0,u.jsxs)("span",{className:"rounded-full px-3 py-1 text-xs font-medium ".concat("allow"===a?t?"bg-brand-yellow/15 text-brand-yellow":"bg-[#fff3d6] text-[#7a560c]":t?"bg-red-950/40 text-red-300":"bg-red-100 text-red-700"),children:[e.label,": ","allow"===a?"Allowed":"Disabled"]},e.key)})})}function VV(e){let{isDarkMode:t,title:n,headers:a,rows:r,emptyText:s}=e;return(0,u.jsxs)("div",{className:"rounded-2xl border ".concat(t?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-gray-50"),children:[(0,u.jsx)("div",{className:"border-b px-4 py-3 dark:border-gray-700",children:(0,u.jsx)("h4",{className:"font-medium",children:n})}),0===r.length?(0,u.jsx)("div",{className:"p-4",children:(0,u.jsx)("p",{className:t?"text-gray-400":"text-gray-600",children:s})}):(0,u.jsx)("div",{className:"overflow-auto",children:(0,u.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,u.jsx)("thead",{className:t?"bg-gray-950/70":"bg-white",children:(0,u.jsx)("tr",{children:a.map(e=>(0,u.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wide ".concat("text-gray-500"),children:e},e))})}),(0,u.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:r.map((e,a)=>(0,u.jsx)("tr",{className:t?"bg-transparent":"bg-gray-50",children:e.map((e,t)=>(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:e},"".concat(n,"-").concat(a,"-").concat(t)))},"".concat(n,"-").concat(a)))})]})})]})}const HV=()=>{var e,t,n;const{isDarkMode:r}=zu(),{token:s}=am(),[i,o]=(0,a.useState)(30),[l,c]=(0,a.useState)(14),[m,h]=(0,a.useState)("overview"),[p,g]=(0,a.useState)(null),[x,f]=(0,a.useState)(null),[b,y]=(0,a.useState)(null),[v,w]=(0,a.useState)({}),[k,j]=(0,a.useState)({}),[D,C]=(0,a.useState)({}),[N,F]=(0,a.useState)([]),[S,E]=(0,a.useState)(wV()),[A,T]=(0,a.useState)({}),[M,_]=(0,a.useState)(!0),[B,I]=(0,a.useState)(!1),[P,L]=(0,a.useState)(!1),[R,z]=(0,a.useState)(""),[O,U]=(0,a.useState)(""),[V,H]=(0,a.useState)(null),[q,W]=(0,a.useState)(!1),[Y,G]=(0,a.useState)(!1),[K,X]=(0,a.useState)(""),J=!(null===p||void 0===p||!p.accessProfile.permissions.organization.manage),$=!(null===p||void 0===p||!p.accessProfile.permissions.organization.viewUsage),Q="master"===(null===p||void 0===p?void 0:p.accessProfile.membership.role),Z=(null===p||void 0===p?void 0:p.accessProfile.user.email)||"",ee=(0,a.useMemo)(()=>EA.filter(e=>"master"!==e.value||Q),[Q]),te=(0,a.useMemo)(()=>new Set(N.map(jV)),[N]),ne=(0,a.useMemo)(()=>Object.values(D).sort((e,t)=>
2e.email.localeCompare(t.email)),[D]),ae=(0,a.useMemo)(()=>p?p.organization.members.filter(e=>{if(te.has(jV(e.email)))return!1;const t=v[e.email];return!!t&&(n=t,a=yV(e),!(n.role===a.role&&SA.every(e=>(n.capabilityModes[e.key]||"inherit")===(a.capabilityModes[e.key]||"inherit"))));var n,a}):[],[v,p,te]),re=(0,a.useMemo)(()=>p?p.organization.members.filter(e=>{if(te.has(jV(e.email)))return!1;const t=k[e.email];return!!t&&(n=t,a=vV(e),!(n.isUnlimited===a.isUnlimited&&DV(n.monthlyCreditLimit)===DV(a.monthlyCreditLimit)&&DV(n.monthlyUsdLimit)===DV(a.monthlyUsdLimit)));var n,a}):[],[k,p,te]),se=(0,a.useMemo)(()=>!(!p||!x)&&SA.some(e=>{var t;return(null===(t=p.organization.featurePolicy)||void 0===t?void 0:t[e.key])!==x[e.key]}),[p,x]),ie=(0,a.useMemo)(()=>{var e;return!(null===p||void 0===p||null===(e=p.organization.billing)||void 0===e||!e.policy||!b)&&JSON.stringify(p.organization.billing.policy)!==JSON.stringify(b)},[b,p]),oe=(0,a.useMemo)(()=>function(e){let{policyDirty:t,changedMembers:n,newMembers:a,removals:r}=e;const s=[];return t&&s.push("organization policy"),n&&s.push("".concat(n," member update").concat(1===n?"":"s")),a&&s.push("".concat(a," staged addition").concat(1===a?"":"s")),r&&s.push("".concat(r," removal").concat(1===r?"":"s")),s.join(", ")}({policyDirty:se||ie,changedMembers:new Set([...ae,...re].map(e=>jV(e.email))).size,newMembers:ne.length,removals:N.length}),[ie,re,ae,N.length,se,ne.length]),le=!!(se||ie||ae.length||re.length||ne.length||N.length),ce=xV.find(e=>e.id===m)||xV[0],de=(null===p||void 0===p?void 0:p.organization.billing)||null,ue=(null===p||void 0===p?void 0:p.accessProfile.billing)||null,me=(0,a.useMemo)(()=>new Set(((null===p||void 0===p?void 0:p.organization.members)||[]).map(e=>e.email.trim().toLowerCase())),[null===p||void 0===p?void 0:p.organization.members]),he=(0,a.useMemo)(()=>null!==ue&&void 0!==ue&&ue.byProvider?ue.byProvider.filter(e=>(e.totalCostUsd||0)>0||(e.totalCreditsUsed||0)>0||e.events>0).slice(0,6).map(e=>({label:"".concat(e.provider,"/").concat(e.service),value:e.totalCostUsd,secondaryValue:e.totalCreditsUsed,detail:"".concat(BA(e.events)," events")})):[],[ue]),pe=(0,a.useMemo)(()=>null!==de&&void 0!==de&&de.byProvider?de.byProvider.filter(e=>(e.totalCostUsd||0)>0||(e.totalCreditsUsed||0)>0||e.events>0).slice(0,8).map(e=>({label:"".concat(e.provider,"/").concat(e.service),value:e.totalCostUsd,secondaryValue:e.totalCreditsUsed,detail:"".concat(BA(e.events)," events")})):[],[de]),ge=(0,a.useMemo)(()=>{const e=[],t=[];return null!==de&&void 0!==de&&de.byUser?(de.byUser.filter(e=>(e.totalCostUsd||0)>0||(e.totalCreditsUsed||0)>0||e.events>0).forEach(n=>{const a=(n.userEmail||"").trim().toLowerCase(),r={label:n.userEmail||"Unknown principal",value:n.totalCostUsd,secondaryValue:n.totalCreditsUsed,detail:"".concat(BA(n.events)," events")};a&&(me.has(a)||a.includes("@"))?e.push(r):t.push(r)}),{memberItems:e.slice(0,8),otherItems:t.slice(0,6)}):{memberItems:e,otherItems:t}},[me,de]),xe=ge.memberItems,fe=(0,a.useMemo)(()=>{const e=[],t=[];return null!==p&&void 0!==p&&p.usage?(p.usage.summary.byUser.forEach(n=>{const a=(n.user_email||"").trim().toLowerCase(),r={label:n.user_email||"Unknown principal",value:n.total_cost_usd||0,secondaryValue:n.total_credits_used||0,detail:"".concat(BA(n.events)," events")};a&&(me.has(a)||a.includes("@"))?e.push(r):t.push(r)}),{memberItems:e.slice(0,10),otherItems:t.slice(0,10)}):{memberItems:e,otherItems:t}},[me,p]),be=(0,a.useMemo)(()=>p?[...p.organization.members].sort((e,t)=>{var n,a,r,s;return((null===(n=t.usage)||void 0===n?void 0:n.totalCostUsd)||(null===(a=t.billing)||void 0===a?void 0:a.totalCostUsd)||0)-((null===(r=e.usage)||void 0===r?void 0:r.totalCostUsd)||(null===(s=e.billing)||void 0===s?void 0:s.totalCostUsd)||0)}).slice(0,8).map(e=>{var t,n,a,r,s;return{label:e.name||e.email,value:(null===(t=e.usage)||void 0===t?void 0:t.totalCostUsd)||(null===(n=e.billing)||void 0===n?void 0:n.totalCostUsd)||0,secondaryValue:(null===(a=e.billing)||void 0===a?void 0:a.totalCreditsUsed)||(null===(r=e.usage)||void 0===r?void 0:r.totalCreditsUsed)||0,detail:null!==(s=e.usage)&&void 0!==s&&s.lastUsedAt?"Last used ".concat(RA(e.usage.lastUsedAt)):e.lastLoginAt?"Last login ".concat(RA(e.lastLoginAt)):"No recent tracked activity"}}):[],[p]);function ye(e){var t;f(e.organization.featurePolicy),y((null===(t=e.organization.billing)||void 0===t?void 0:t.policy)||null),w(Object.fromEntries(e.organization.members.map(e=>[e.email,yV(e)]))),j(Object.fromEntries(e.organization.members.map(e=>[e.email,vV(e)]))),C({}),F([]),E(wV())}const ve=(0,a.useCallback)(async()=>
2{if(s){W(!0),X("");try{const e=await TA("/api/v1/youtube/auth/status",s);H(e)}catch(e){X(e instanceof Error?e.message:"Failed to load YouTube auth status")}finally{W(!1)}}},[s]),we=(0,a.useCallback)(async()=>{if(s&&"undefined"!==typeof window){G(!0),X("");try{const e="".concat(window.location.origin).concat(window.location.pathname,"?pane=personal"),t=await TA("/api/v1/youtube/auth/url?returnUrl=".concat(encodeURIComponent(e)),s);window.location.assign(t.authUrl)}catch(e){G(!1),X(e instanceof Error?e.message:"Failed to start YouTube authentication")}}},[s]),ke=(0,a.useCallback)(async()=>{if(s){G(!0),X("");try{await TA("/api/v1/youtube/auth",s,{method:"DELETE"}),U("YouTube OAuth credentials removed."),await ve()}catch(e){X(e instanceof Error?e.message:"Failed to disconnect YouTube")}finally{G(!1)}}},[ve,s]),je=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i,t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l;if(s){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?_(!0):I(!0);try{z("");const a=await TA("/api/settings/overview?days=".concat(e,"&activityDays=").concat(n),s);g(a),t||ye(a)}catch(a){z(a instanceof Error?a.message:"Failed to load settings")}finally{_(!1),I(!1)}}};(0,a.useEffect)(()=>{s&&(je(i,!0,!1,l),ve())},[s,ve]),(0,a.useEffect)(()=>{if("undefined"===typeof window)return;const e=new URLSearchParams(window.location.search),t=e.get("pane");t&&xV.some(e=>e.id===t)&&h(t);const n=e.get("youtube_auth"),a=e.get("message");if(!n)return;"success"===n?(U("YouTube account connected."),ve()):"error"===n&&X(a||"YouTube authentication failed"),e.delete("youtube_auth"),e.delete("message");const r=e.toString(),s="".concat(window.location.pathname).concat(r?"?".concat(r):"").concat(window.location.hash);window.history.replaceState({},document.title,s)},[ve]);const De=(e,t)=>{w(n=>{const a=n[e];return a?d(d({},n),{},{[e]:t(a)}):n})},Ce=(e,t)=>{j(n=>{const a=n[e];return a?d(d({},n),{},{[e]:t(a)}):n})},Ne=r?"bg-gray-800 border-gray-700 text-white":"bg-white border-gray-200 text-gray-900",Fe=r?"bg-gray-900/70 border-gray-700":"bg-gray-50 border-gray-200",Se=r?"text-gray-400":"text-gray-600",Ee="text-gray-500",Ae="w-full rounded-xl border px-3 py-2 text-sm transition-colors focus:outline-none focus:ring-2 focus:ring-brand-yellow ".concat(r?"border-gray-600 bg-gray-900 text-gray-100 placeholder:text-gray-500":"border-gray-300 bg-white text-gray-900 placeholder:text-gray-400");return s?M&&!p?(0,u.jsx)("div",{className:"rounded-2xl border p-8 ".concat(Ne),children:(0,u.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,u.jsx)(vp,{className:"h-5 w-5 animate-spin"}),(0,u.jsx)("span",{className:Se,children:"Loading settings overview\u2026"})]})}):p?(0,u.jsxs)("div",{className:"space-y-6",children:[(R||O)&&(0,u.jsx)("div",{className:"rounded-2xl border p-4 ".concat(R?r?"border-red-500/40 bg-red-950/30 text-red-200":"border-red-200 bg-red-50 text-red-700":r?"border-brand-yellow/40 bg-brand-yellow/15 text-brand-yellow":"border-[#e7c572] bg-[#fff6e5] text-[#7a560c]"),children:(0,u.jsxs)("div",{className:"flex items-start gap-3",children:[R?(0,u.jsx)(Lu,{className:"mt-0.5 h-5 w-5 shrink-0"}):(0,u.jsx)(Wm,{className:"mt-0.5 h-5 w-5 shrink-0"}),(0,u.jsx)("span",{className:"text-sm",children:R||O})]})}),(0,u.jsxs)("div",{className:"grid gap-6 xl:grid-cols-[300px_minmax(0,1fr)]",children:[(0,u.jsx)("aside",{className:"rounded-[32px] border p-5 ".concat(Ne," xl:sticky xl:top-6 xl:h-[calc(100vh-3rem)] xl:overflow-hidden"),children:(0,u.jsxs)("div",{className:"flex h-full flex-col gap-5",children:[(0,u.jsxs)("div",{className:"rounded-[28px] border p-5 ".concat(Fe),children:[(0,u.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-brand-navy px-3 py-1 text-xs font-semibold text-brand-cloud",children:[(0,u.jsx)(FA,{className:"h-3.5 w-3.5"}),"Organization & Security"]}),(0,u.jsx)("h1",{className:"mt-4 text-2xl font-semibold",children:p.organization.name}),(0,u.jsxs)("p",{className:"mt-2 text-sm ".concat(Se),children:["Org slug ",(0,u.jsx)("span",{className:"font-mono",children:p.organization.slug})]}),(0,u.jsxs)("p",{className:"mt-1 text-sm ".concat(Se),children:["You are signed in as ",p.accessProfile.user.email," with ",zA(p.accessProfile.membership.role)," access."]})]}),(0,u.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-1",children:[(0,u.jsx)(PV,{isDarkMode:r,label:"Members",value:
2BA(p.organization.members.length),hint:J?"Roles, overrides, and removals":"Read-only directory"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Usage visibility",value:$?"Org-wide":"Personal only",hint:$?"Admin analytics enabled":"Request org admin access for org-wide views"})]}),(0,u.jsxs)("div",{className:"rounded-[28px] border p-4 ".concat(Fe),children:[(0,u.jsx)("p",{className:"text-sm font-medium",children:"Time windows"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(Se),children:"Apply these ranges across usage tables and activity graphs."}),(0,u.jsxs)("div",{className:"mt-4 space-y-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"mb-2 text-xs uppercase tracking-wide ".concat(Ee),children:"Usage summary"}),(0,u.jsx)(AV,{isDarkMode:r,options:fV.map(e=>({value:e,label:"".concat(e,"d")})),value:i,onChange:e=>{o(e),je(e,!1,le,l)}})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"mb-2 text-xs uppercase tracking-wide ".concat(Ee),children:"Activity graphs"}),(0,u.jsx)(AV,{isDarkMode:r,options:bV.map(e=>({value:e,label:"".concat(e,"d")})),value:l,onChange:e=>{c(e),je(i,!1,le,e)}})]})]})]}),(0,u.jsx)("nav",{className:"grid gap-2 overflow-auto xl:flex-1 xl:content-start",children:xV.map(e=>{const t="members"===e.id?BA(p.organization.members.length):"billing"===e.id&&de?_A(de.totals.totalCostUsd):"activity"===e.id&&p.usage?BA(p.usage.summary.totals.events):"personal"===e.id?_A(p.selfUsage.summary.totals.total_cost_usd):"policy"===e.id?"".concat(kV(p.organization.featurePolicy),"/").concat(SA.length):null!==ue&&void 0!==ue&&ue.isOverLimit?"Alert":"Live";return(0,u.jsx)(EV,{isDarkMode:r,title:e.title,description:e.description,badge:t,active:e.id===m,onClick:()=>h(e.id)},e.id)})})]})}),(0,u.jsxs)("section",{className:"overflow-hidden rounded-[36px] border ".concat(Ne),children:[(0,u.jsx)("div",{className:"border-b px-5 py-5 md:px-8 ".concat(r?"border-gray-800":"border-gray-200"),children:(0,u.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-xs uppercase tracking-[0.25em] ".concat(Ee),children:"Settings"}),(0,u.jsx)("h2",{className:"mt-2 text-3xl font-semibold",children:ce.title}),(0,u.jsx)("p",{className:"mt-2 max-w-3xl text-sm ".concat(Se),children:ce.description})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,u.jsxs)("div",{className:"rounded-full px-3 py-1 text-xs font-medium ".concat(Fe),children:["Usage ",i,"d \xb7 Activity ",l,"d"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{je(i,!1,le,l)},className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(r?"bg-gray-800 text-gray-100 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),disabled:B,children:[(0,u.jsx)(vp,{className:"h-4 w-4 ".concat(B?"animate-spin":"")}),"Refresh"]})]})]})}),(0,u.jsxs)("div",{className:"p-5 md:p-8",children:[J&&le&&(0,u.jsx)("section",{className:"sticky top-4 z-10 mb-6 rounded-3xl border p-4 shadow-lg backdrop-blur ".concat(r?"border-brand-yellow/30 bg-slate-950/90 text-white":"border-[#e7c572] bg-white/95 text-gray-900"),children:(0,u.jsxs)("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"inline-flex items-center gap-2 rounded-full bg-brand-yellow px-3 py-1 text-xs font-semibold text-brand-navy",children:[(0,u.jsx)(Dh,{className:"h-3.5 w-3.5"}),"Pending changes"]}),(0,u.jsx)("p",{className:"mt-3 text-sm font-medium",children:oe||"Settings changes are staged and ready to save."}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(Se),children:"Nothing is persisted until you use the global save action."})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>{p&&(ye(p),z(""),U("Discarded unsaved changes."))},disabled:P,className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(r?"bg-gray-800 text-gray-100 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"," ").concat(P?"cursor-not-allowed opacity-70":""),children:[(0,u.jsx)(fj,{className:"h-4 w-4"}),"Discard Changes"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>{(async()=>
2{if(!s||!p||!J)return;const e=p.organization.members.map(e=>jV(e.email)).filter(e=>te.has(e)),t=ae.map(e=>{const t=v[e.email],n=k[e.email]||vV(e);return{email:jV(t.email),name:t.name.trim()||jV(t.email),role:t.role,capabilities:MA(t.capabilityModes),billing:{isUnlimited:n.isUnlimited,monthlyCreditLimit:CV(n.monthlyCreditLimit),monthlyUsdLimit:CV(n.monthlyUsdLimit),clear:!n.isUnlimited&&null===CV(n.monthlyCreditLimit)&&null===CV(n.monthlyUsdLimit)}}}),n=re.filter(e=>!ae.some(t=>t.email===e.email)).map(e=>{const t=v[e.email]||yV(e),n=k[e.email]||vV(e);return{email:jV(t.email),name:t.name.trim()||jV(t.email),role:t.role,capabilities:MA(t.capabilityModes),billing:{isUnlimited:n.isUnlimited,monthlyCreditLimit:CV(n.monthlyCreditLimit),monthlyUsdLimit:CV(n.monthlyUsdLimit),clear:!n.isUnlimited&&null===CV(n.monthlyCreditLimit)&&null===CV(n.monthlyUsdLimit)}}}),a=ne.map(e=>({email:jV(e.email),name:e.name.trim()||jV(e.email),role:e.role,capabilities:MA(e.capabilityModes)}));L(!0),z(""),U("");let r=0;try{(se||ie)&&x&&(await TA("/api/settings/organization",s,{method:"PATCH",body:JSON.stringify({featurePolicy:x,billing:b})}),r+=1);for(const e of t)await TA("/api/settings/members",s,{method:"POST",body:JSON.stringify(e)}),r+=1;for(const e of n)await TA("/api/settings/members",s,{method:"POST",body:JSON.stringify(e)}),r+=1;for(const e of a)await TA("/api/settings/members",s,{method:"POST",body:JSON.stringify(e)}),r+=1;for(const t of e)await TA("/api/settings/members/".concat(encodeURIComponent(t)),s,{method:"DELETE"}),r+=1;await je(i,!1,!1),U(1===r?"Saved 1 settings change.":"Saved ".concat(r," settings changes."))}catch(o){await je(i,!1,!1);const e=o instanceof Error?o.message:"Failed to save settings";z(r>0?"".concat(e,". The page was refreshed because some changes were already applied."):e)}finally{L(!1)}})()},disabled:P,className:"inline-flex items-center gap-2 rounded-xl bg-brand-yellow px-4 py-2 text-sm font-medium text-brand-navy transition-colors hover:bg-[#ffc54d] ".concat(P?"cursor-not-allowed opacity-70":""),children:[(0,u.jsx)(Dh,{className:"h-4 w-4"}),P?"Saving Everything\u2026":"Save All"]})]})]})}),"overview"===m&&(0,u.jsxs)("div",{className:"space-y-6",children:[ue&&(0,u.jsx)("section",{className:"rounded-[32px] border p-5 ".concat(ue.isOverLimit?r?"border-red-500/40 bg-red-950/30 text-red-100":"border-red-200 bg-red-50 text-red-800":ue.isWarning?r?"border-amber-500/40 bg-amber-950/30 text-amber-100":"border-amber-200 bg-amber-50 text-amber-800":r?"border-brand-navy/30 bg-brand-navy/20 text-brand-cloud":"border-[#d4dde8] bg-[#eef2f6] text-brand-navy"),children:(0,u.jsxs)("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-sm font-semibold",children:ue.isOverLimit?"Monthly allowance exhausted":ue.isWarning?"Monthly allowance nearing limit":"Monthly allowance healthy"}),(0,u.jsx)("p",{className:"mt-2 max-w-2xl text-sm",children:ue.isUnlimited?"Your account is unlimited for this organization.":"This calendar month you have used ".concat(_A(ue.totalCostUsd)," / ").concat(null!==ue.monthlyUsdLimit?_A(ue.monthlyUsdLimit):"Unlimited"," and ").concat(IA(ue.totalCreditsUsed)," / ").concat(null!==ue.monthlyCreditLimit?IA(ue.monthlyCreditLimit):"Unlimited"," credits.")})]}),(0,u.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:min-w-[360px]",children:[(0,u.jsx)(PV,{isDarkMode:r,label:"Cost used",value:_A(ue.totalCostUsd),hint:null!==ue.monthlyUsdLimit?"".concat(NV(ue.percentUsdUsed)," of limit"):"Unlimited"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Credits remaining",value:null===ue.creditsRemaining?"Unlimited":IA(ue.creditsRemaining),hint:"Period ".concat(ue.period.periodId)})]})]})}),(0,u.jsxs)("div",{className:"grid gap-3 xl:grid-cols-6",children:[(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(fh,{className:"h-5 w-5"}),label:"Members",value:BA(p.organization.members.length),hint:J?"Manage roles and overrides below":"Read-only directory"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(FA,{className:"h-5 w-5"}),label:"Your Role",value:zA(p.accessProfile.membership.role),hint:J?"Can manage organization settings":"Limited to your accessible surfaces"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(yp,{className:"h-5 w-5"}),label:"Usage Visibility",value:$?"Enabled":"Restricted",hint:$?"Organization analytics available":"Only personal analytics visible"}
2),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(YE,{className:"h-5 w-5"}),label:"Current Month Cost",value:_A(de?de.totals.totalCostUsd:(null===ue||void 0===ue?void 0:ue.totalCostUsd)||0),hint:de?"Across the organization":"Your current billing month"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(yp,{className:"h-5 w-5"}),label:"Current Month Credits",value:IA(de?de.totals.totalCreditsUsed:(null===ue||void 0===ue?void 0:ue.totalCreditsUsed)||0),hint:de?"Across capped members":"Your usage this month"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(Lu,{className:"h-5 w-5"}),label:"Members Over Limit",value:de?BA(de.totals.overLimitMembers):null!==ue&&void 0!==ue&&ue.isOverLimit?"1":"0",hint:de?"Needs admin attention":"Your current credit posture"})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(TV,{isDarkMode:r,title:"Current month burn",description:"Daily tracked cost and credit burn for the active billing period.",children:(0,u.jsx)(RV,{isDarkMode:r,points:(null===de||void 0===de?void 0:de.byDay)||(null===ue||void 0===ue?void 0:ue.byDay)||[]})}),(0,u.jsx)(TV,{isDarkMode:r,title:"Billing-period trend",description:"Month-over-month cost and credits.",children:(0,u.jsx)(zV,{isDarkMode:r,points:(null===de||void 0===de?void 0:de.byMonth)||(null===ue||void 0===ue?void 0:ue.byMonth)||[]})})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(MV,{isDarkMode:r,title:"Top spenders",description:$?"Highest metered members in the active window.":"Your own provider mix for the active month.",items:$?xe:he,emptyText:$?"No organization spend recorded yet.":"No personal spend recorded yet.",primaryLabel:"Cost",secondaryLabel:"Credits"}),(0,u.jsx)(MV,{isDarkMode:r,title:"Provider concentration",description:"See which providers and services are driving spend.",items:$?pe:he,emptyText:"No provider usage recorded yet.",primaryLabel:"Cost",secondaryLabel:"Credits"})]})]}),(0,u.jsx)("p",{className:"text-sm ".concat(Se),children:"Costs cover recorded usage and include estimates. Unpriced work is excluded from totals; historical AWS estimates may lack verified task dimensions. These totals are not an all-in bill."}),"personal"===m&&(0,u.jsxs)("div",{className:"space-y-6",children:[(0,u.jsx)(TV,{isDarkMode:r,title:"YouTube write access",description:"Connect the Google account used for YouTube metadata updates, comments, captions, and analytics.",children:(0,u.jsxs)("div",{className:"space-y-4",children:[(0,u.jsxs)("div",{className:"grid gap-3 xl:grid-cols-4",children:[(0,u.jsx)(PV,{isDarkMode:r,label:"Status",value:q?"Loading\u2026":null!==V&&void 0!==V&&V.authenticated?"Connected":"Disconnected",hint:null!==V&&void 0!==V&&V.authenticated?"Write/auth scopes available to the app":"OAuth token missing or expired"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Expiry",value:null!==V&&void 0!==V&&V.tokenExpiry?LA(V.tokenExpiry):"Unknown",hint:SV(null===V||void 0===V?void 0:V.tokenExpiry)}),(0,u.jsx)(PV,{isDarkMode:r,label:"Video edits",value:null!==V&&void 0!==V&&V.canEditVideos?"Enabled":"Unavailable",hint:"Required for title/description updates"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Comments & captions",value:null!==V&&void 0!==V&&V.canPostComments?"Enabled":"Unavailable",hint:"Also used for managed comments and caption uploads"})]}),K?(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(r?"border-red-500/30 bg-red-950/30 text-red-100":"border-red-200 bg-red-50 text-red-700"),children:K}):null,(0,u.jsxs)("div",{className:"rounded-2xl border px-4 py-3 text-sm ".concat(r?"border-white/10 bg-white/5 text-slate-200":"border-slate-200 bg-slate-50 text-slate-700"),children:[(0,u.jsx)("div",{className:"font-medium",children:"Granted capabilities"}),(0,u.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:[{label:"Read metadata",enabled:!(null===V||void 0===V||!V.canReadVideoMetadata)},{label:"Edit videos",enabled:!(null===V||void 0===V||!V.canEditVideos)},{label:"Post comments",enabled:!(null===V||void 0===V||!V.canPostComments)}].map(e=>(0,u.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full px-3 py-1 text-xs font-medium ".concat(e.enabled?r?"bg-emerald-500/15 text-emerald-200":"bg-emerald-100 text-emerald-700":r?"bg-slate-700 text-slate-300":"bg-slate-200 text-slate-600"),children:[e.enabled?(0,u.jsx)(Wm,{className:"h-3.5 w-3.5"}):(0,u.jsx)(Pu,{className:"h-3.5 w-3.5"}),e.label]},e.label))})]}),(0,u.jsxs)("div",{className:"flex flex-wrap gap-3",children:[(0,u.jsx)("button",{type:"button",onClick:()=>{we()},disabled:Y,className:"inline-flex items-center rounded-full px-4 py-2 text-sm font-medium transition ".concat(r?"bg-emerald-500 text-slate-950 hover:bg-emerald-400 disabled:opacity-60":"bg-brand-navy text-white hover:bg-[#17304b] disabled:opacity-60"),children:Y?"Working\u2026":null!==V&&void 0!==V&&V.authenticated?"Reconnect YouTube":"Connect YouTube"}),(0,u.jsx)("button",{type:"button",onClick:()=>{ve()},disabled:q||Y,className:"inline-flex items-center rounded-full border px-4 py-2 text-sm font-medium transition ".concat(r?"border-white/15 bg-transparent text-slate-200 hover:bg-white/5 disabled:opacity-60":"border-slate-200 bg-white text-slate-700 hover:bg-slate-50 disabled:opacity-60"),children:"Refresh status"}),null!==V&&void 0!==V&&V.authenticated?(0,u.jsx)("button",{type:"button",onClick:()=>{ke()},disabled:Y,className:"inline-flex items-center rounded-full border px-4 py-2 text-sm font-medium transition ".concat(r?"border-red-500/30 bg-red-950/20 text-red-200 hover:bg-red-950/35 disabled:opacity-60":"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 disabled:opacity-60"),children:"Disconnect"}):null]})]})}),(0,u.jsxs)("div",{className:"grid gap-3 xl:grid-cols-[1fr_1fr_1fr_1fr_1.2fr]",children:[(0,u.jsx)(PV,{isDarkMode:r,label:"Last used",value:RA((null===(e=p.selfUsage.activity)||void 0===e?void 0:e.lastUsedAt)||(null===ue||void 0===ue?void 0:ue.lastUsageAt)),hint:LA((null===(t=p.selfUsage.activity)||void 0===t?void 0:t.lastUsedAt)||(null===ue||void 0===ue?void 0:ue.lastUsageAt))}),(0,u.jsx)(PV,{isDarkMode:r,label:"".concat(p.selfUsage.summary.days,"d events"),value:BA(p.selfUsage.summary.totals.events),hint:null!==(n=p.selfUsage.activity)&&void 0!==n&&n.lastUsageAt?"Tracked usage on ".concat(LA(p.selfUsage.activity.lastUsageAt)):"No metered events in the current window"}),(0,u.jsx)(PV,{isDarkMode:r,label:"".concat(p.selfUsage.summary.days,"d recorded cost"),value:_A(p.selfUsage.summary.totals.total_cost_usd),hint:p.selfUsage.summary.costCoverage?"Credits ".concat(IA(p.selfUsage.summary.totals.total_credits_used||0)," \xb7 ").concat(p.selfUsage.summary.costCoverage.unknownCostEvents," unknown costs \xb7 ").concat(p.selfUsage.summary.costCoverage.legacyAwsEstimateEvents," unverified AWS estimates"):"Cost coverage unavailable"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Current month credits",value:null!==ue&&void 0!==ue&&ue.isUnlimited?"Unlimited":IA((null===ue||void 0===ue?void 0:ue.totalCreditsUsed)||0),hint:null===(null===ue||void 0===ue?void 0:ue.creditsRemaining)?"No monthly credit cap":"".concat(IA((null===ue||void 0===ue?void 0:ue.creditsRemaining)||0)," remaining")}),(0,u.jsx)(LV,{isDarkMode:r,usage:p.selfUsage.activity,fallbackDays:l})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(TV,{isDarkMode:r,title:"My billing-month burn",description:"Daily cost and credits for your current billing period.",children:(0,u.jsx)(RV,{isDarkMode:r,points:(null===ue||void 0===ue?void 0:ue.byDay)||[]})}),(0,u.jsx)(TV,{isDarkMode:r,title:"My billing trend",description:"Billing periods over time for your account.",children:(0,u.jsx)(zV,{isDarkMode:r,points:(null===ue||void 0===ue?void 0:ue.byMonth)||[]})})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(MV,{isDarkMode:r,title:"Provider spend",description:"Your current billing month by provider and service.",items:he,emptyText:"No current-month provider usage.",primaryLabel:"Cost",secondaryLabel:"Credits"}),(0,u.jsx)(VV,{isDarkMode:r,title:"Cost status",headers:["Status","Events","Credits","Cost"],emptyText:"No current-month status data.",rows:((null===ue||void 0===ue?void 0:ue.byStatus)||[]).map(e=>[FV(e.costStatus),BA(e.events),IA(e.totalCreditsUsed),_A(e.totalCostUsd)])})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(VV,{isDarkMode:r,title:"Rolling Provider Mix",headers:["Provider","Events","Units","Credits","Cost"],emptyText:"No recent provider usage.",rows:p.selfUsage.summary.byProvider.map(e=>["".concat(e.provider,"/").concat(e.service),BA(e.events),BA(e.total_units),IA(e.total_credits_used||0),_A(e.total_cost_usd)])}),(0,u.jsx)(VV,{isDarkMode:r,title:"Rolling Cost Status",headers:["Status","Events","Credits","Cost"],emptyText:"No recent usage status data.",rows:p.selfUsage.summary.byStatus.map(e=>[FV(e.cost_status),BA(e.events),IA(e.total_credits_used||0),_A(e.total_cost_usd)])})]}),(0,u.jsx)(TV,{isDarkMode:r,title:"Recent personal usage",description:"Every metered action attributed to your account.",children:0===p.selfUsage.recent.length?(0,u.jsx)("p",{className:Se,children:"No recent personal usage events."}):(0,u.jsx)("div",{className:"max-h-[420px] overflow-auto",children:(0,u.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,u.jsx)("thead",{className:r?"bg-gray-950/70":"bg-white",children:(0,u.jsx)("tr",{children:["When","Operation","Units","Status","Credits","Cost","Details"].map(e=>(0,u.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wide ".concat(Ee),children:e},e))})}),(0,u.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:p.selfUsage.recent.map(e=>(0,u.jsxs)("tr",{className:r?"bg-transparent":"bg-white",children:[(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:LA(e.created_at)}),(0,u.jsxs)("td",{className:"px-4 py-3 text-sm",children:[(0,u.jsxs)("div",{children:[e.provider,"/",e.service]}),(0,u.jsx)("div",{className:Se,children:e.operation})]}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm ".concat(Se),children:e.total_units?BA(e.total_units):e.quantity?"".concat(BA(e.quantity)," ").concat(e.unit||"").trim():"0"}),(0,u.jsxs)("td",{className:"px-4 py-3 text-sm",children:[(0,u.jsx)("div",{className:"font-medium",children:"aws"===e.provider&&"aws:fargate-runtime"===e.price_source?"Legacy estimate (unverified)":FV(e.cost_status)}),(0,u.jsx)("div",{className:Se,children:e.price_source||"price source unavailable"})]}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:IA(e.credits_used||0)}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:null===e.cost_usd||"unknown"===e.cost_status?"Unknown":_A(e.cost_usd)}),(0,u.jsxs)("td",{className:"px-4 py-3 text-sm ".concat(Se),children:[(0,u.jsx)("div",{children:e.model||"No model"}),(0,u.jsxs)("div",{children:[e.resource_type||"resource"," ",e.resource_id?"\xb7 ".concat(e.resource_id):""]}),(0,u.jsxs)("div",{children:[e.byok?"BYOK":"Org billed",e.cache_hit?" \xb7 cache hit":""]})]})]},e.id))})]})})})]}
2),"billing"===m&&(0,u.jsx)("div",{className:"space-y-6",children:$&&de?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-5",children:[(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(FA,{className:"h-5 w-5"}),label:"Month Cost",value:_A(de.totals.totalCostUsd)}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(YE,{className:"h-5 w-5"}),label:"Credits Used",value:IA(de.totals.totalCreditsUsed)}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(fh,{className:"h-5 w-5"}),label:"Remaining Credits",value:null===de.totals.remainingCredits?"Unlimited":IA(de.totals.remainingCredits),hint:null===de.totals.remainingCredits?"No capped members in this organization":"Across capped members only"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(yp,{className:"h-5 w-5"}),label:"USD Remaining",value:null===de.totals.remainingUsd?"Unlimited":_A(de.totals.remainingUsd),hint:null===de.totals.remainingUsd?"No capped members in this organization":"Across capped members only"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(Lu,{className:"h-5 w-5"}),label:"Members Over Limit",value:BA(de.totals.overLimitMembers)})]}),b&&(0,u.jsxs)(TV,{isDarkMode:r,title:"Budget defaults",description:"Master users remain unlimited. Everyone else inherits these defaults unless a member override is set.",children:[(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-4",children:[(0,u.jsx)(IV,{label:"Default USD / Month",value:String(b.defaultMonthlyUsdLimit),onChange:e=>y(t=>{var n;return t?d(d({},t),{},{defaultMonthlyUsdLimit:null!==(n=CV(e))&&void 0!==n?n:t.defaultMonthlyUsdLimit}):t}),disabled:!J,inputClass:Ae}),(0,u.jsx)(IV,{label:"Default Credits / Month",value:String(b.defaultMonthlyCreditLimit),onChange:e=>y(t=>{var n;return t?d(d({},t),{},{defaultMonthlyCreditLimit:null!==(n=CV(e))&&void 0!==n?n:t.defaultMonthlyCreditLimit}):t}),disabled:!J,inputClass:Ae}),(0,u.jsx)(IV,{label:"Credits / USD",value:String(b.defaultCreditsPerUsd),onChange:e=>y(t=>{var n;return t?d(d({},t),{},{defaultCreditsPerUsd:null!==(n=CV(e))&&void 0!==n?n:t.defaultCreditsPerUsd}):t}),disabled:!J,inputClass:Ae}),(0,u.jsx)(IV,{label:"Warning Threshold %",value:String(b.warningThresholdPercent),onChange:e=>y(t=>{var n;return t?d(d({},t),{},{warningThresholdPercent:Math.max(1,Math.min(100,Math.round(null!==(n=CV(e))&&void 0!==n?n:t.warningThresholdPercent)))}):t}),disabled:!J,inputClass:Ae})]}),(0,u.jsxs)("div",{className:"mt-6 rounded-2xl border ".concat(Fe),children:[(0,u.jsxs)("div",{className:"border-b px-4 py-3 dark:border-gray-700",children:[(0,u.jsx)("h4",{className:"font-medium",children:"Credits per dollar mapping"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(Se),children:"These multipliers let you bias in-app credits independently from underlying USD cost."})]}),(0,u.jsx)("div",{className:"max-h-[320px] overflow-auto",children:(0,u.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,u.jsx)("thead",{className:r?"bg-gray-900/70":"bg-gray-50",children:(0,u.jsx)("tr",{children:["Provider","Service","Operation","Credits / USD"].map(e=>(0,u.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wide ".concat(Ee),children:e},e))})}),(0,u.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:b.serviceCreditRates.map((e,t)=>(0,u.jsxs)("tr",{children:[(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:e.provider}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:e.service}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:e.operation}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:(0,u.jsx)("input",{type:"number",min:"0",step:"0.1",value:String(e.creditsPerUsd),disabled:!J,onChange:e=>((e,t)=>{y(n=>{if(!n)return n;const a=n.serviceCreditRates.map((n,a)=>{var r;return a===e?d(d({},n),{},{creditsPerUsd:null!==(r=CV(t))&&void 0!==r?r:n.creditsPerUsd}):n});return d(d({},n),{},{serviceCreditRates:a})})})(t,e.target.value),className:"".concat(Ae," max-w-[140px]")})})]},"".concat(e.provider,"-").concat(e.service,"-").concat(e.operation,"-").concat(t)))})]})})]})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(TV,{isDarkMode:r,title:"Current month spend pattern",description:"Daily tracked cost and credit burn for the active billing period.",children:(0,u.jsx)(RV,{isDarkMode:r,points:de.byDay})}),(0,u.jsx)(TV,{isDarkMode:r,title:"Month-over-month trend",description:"Last ".concat(de.byMonth.length," billing periods."),children:(0,u.jsx)(zV,{isDarkMode:r,points:de.byMonth})})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(_V,{isDarkMode:r,title:"Principal breakdown",description:"Member accounts are separated from shared viewers, public surfaces, and automation clients.",groups:[{title:"Member accounts",items:ge.memberItems},{title:"Shared & system clients",items:ge.otherItems}],emptyText:"No principal spend recorded yet.",primaryLabel:"Cost",secondaryLabel:"Credits"}),(0,u.jsx)(MV,{isDarkMode:r,title:"Provider concentration",description:"Which providers are consuming the budget.",items:pe,emptyText:"No provider usage recorded yet.",primaryLabel:"Cost",secondaryLabel:"Credits"})]})]}):(0,u.jsx)(TV,{isDarkMode:r,title:"Organization billing visibility restricted",description:"You can still see your own credits in the My Usage pane.",children:(0,u.jsx)("p",{className:Se,children:"Organization-wide billing controls and analytics are only visible to org admins and master users."})})}),"members"===m&&(0,u.jsxs)("div",{className:"space-y-6",children:[(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-[1.1fr_0.9fr]",children:[(0,u.jsx)(TV,{isDarkMode:r,title:"Member posture",description:"Roles control broad access. Member overrides are optional, and removals stay staged until global save runs.",children:(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-4",children:[(0,u.jsx)(PV,{isDarkMode:r,label:"Members",value:
2BA(p.organization.members.length),hint:J?"Invite, remove, or edit access":"Read-only list"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Writers + Admins",value:BA(p.organization.members.filter(e=>"reader"!==e.role).length),hint:"Can create or manage resources"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Over limit",value:BA(p.organization.members.filter(e=>{var t;return null===(t=e.billing)||void 0===t?void 0:t.isOverLimit}).length),hint:"Needs credits or override changes"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Recently active",value:BA(p.organization.members.filter(e=>{var t;return(null===(t=e.usage)||void 0===t?void 0:t.lastUsedAt)||e.lastLoginAt}).length),hint:"Activity window ".concat(l,"d")})]})}),(0,u.jsx)(MV,{isDarkMode:r,title:"Top active members",description:"Highest spenders or most recently active accounts.",items:be,emptyText:"No tracked member activity yet.",primaryLabel:"Cost",secondaryLabel:"Credits"})]}),J&&(0,u.jsxs)(TV,{isDarkMode:r,title:"Stage new member",description:"Queue invitations and access overrides, then persist them with the global save action.",children:[(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-3",children:[(0,u.jsx)("input",{type:"email",value:S.email,onChange:e=>E(t=>d(d({},t),{},{email:e.target.value})),placeholder:"[email protected]",className:Ae}),(0,u.jsx)("input",{type:"text",value:S.name,onChange:e=>E(t=>d(d({},t),{},{name:e.target.value})),placeholder:"Display name",className:Ae}),(0,u.jsx)("select",{value:S.role,onChange:e=>E(t=>d(d({},t),{},{role:e.target.value})),className:Ae,children:ee.map(e=>(0,u.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,u.jsx)("div",{className:"mt-4",children:(0,u.jsx)(OV,{isDarkMode:r,modes:S.capabilityModes,onModeChange:(e,t)=>
2{E(n=>d(d({},n),{},{capabilityModes:d(d({},n.capabilityModes),{},{[e]:t})}))}})}),(0,u.jsx)("div",{className:"mt-4 flex justify-end",children:(0,u.jsxs)("button",{type:"button",onClick:()=>{const e=jV(S.email);e?null!==p&&void 0!==p&&p.organization.members.some(t=>jV(t.email)===e)?z("That member already exists. Edit them in the member list below."):te.has(e)?z("That user is currently queued for removal. Undo the removal before re-adding them."):(z(""),U(""),C(t=>d(d({},t),{},{[e]:d(d({},S),{},{email:e,name:S.name.trim()||e})})),E(wV())):z("Member email is required.")},className:"inline-flex items-center gap-2 rounded-xl bg-brand-navy px-4 py-2 text-sm font-medium text-brand-cloud transition-colors hover:bg-[#1a2230]",children:[(0,u.jsx)(ik,{className:"h-4 w-4"}),"Stage Member"]})})]}),ne.length>0&&(0,u.jsx)(TV,{isDarkMode:r,title:"Staged additions",description:"These entries are queued locally until you save.",children:(0,u.jsx)("div",{className:"space-y-3",children:ne.map(e=>(0,u.jsx)("div",{className:"rounded-2xl border p-4 ".concat(Fe),children:(0,u.jsxs)("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-medium",children:e.name||e.email}),(0,u.jsx)("p",{className:"text-sm ".concat(Se),children:e.email}),(0,u.jsxs)("p",{className:"mt-2 text-xs ".concat(Se),children:[zA(e.role)," with"," ",SA.filter(t=>e.capabilityModes[t.key]&&"inherit"!==e.capabilityModes[t.key]).length," ","explicit override(s)"]})]}),(0,u.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,u.jsxs)("button",{type:"button",onClick:()=>(e=>{const t=D[e];t&&(E(t),C(t=>{const n=d({},t);return delete n[e],n}))})(e.email),className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(r?"bg-gray-700 text-gray-100 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:[(0,u.jsx)(jj,{className:"h-4 w-4"}),"Edit Draft"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>C(t=>{const n=d({},t);return delete n[e.email],n}),className:"inline-flex items-center gap-2 rounded-xl bg-red-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-red-500",children:[(0,u.jsx)(Pu,{className:"h-4 w-4"}),"Remove Draft"]})]})]})},e.email))})}),(0,u.jsx)("div",{className:"space-y-4",children:p.organization.members.map(e=>{const t=v[e.email]||yV(e),n=k[e.email]||vV(e),a=!!A[e.email],s="master"===e.role&&!Q,o=te.has(jV(e.email)),c=jV(e.email)===jV(Z),m=s?[...ee,{value:"master",label:"Master"}]:ee,h=SA.filter(e=>t.capabilityModes[e.key]&&"inherit"!==t.capabilityModes[e.key]).length,p=e.usage,g=e.billing;return(0,u.jsxs)("section",{className:"rounded-[32px] border p-5 transition-opacity ".concat(Fe," ").concat(o?"opacity-70":""),children:[(0,u.jsxs)("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[(0,u.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,u.jsxs)("div",{className:"flex items-center gap-3",children:[e.picture?(0,u.jsx)("img",{src:e.picture,alt:e.name,className:"h-12 w-12 rounded-full object-cover"}):(0,u.jsx)("div",{className:"flex h-12 w-12 items-center justify-center rounded-full ".concat(r?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"),children:e.name.charAt(0).toUpperCase()}),(0,u.jsxs)("div",{className:"min-w-0",children:[(0,u.jsx)("p",{className:"truncate text-lg font-semibold",children:e.name}),(0,u.jsx)("p",{className:"truncate text-sm ".concat(Se),children:e.email})]})]}),(0,u.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-xs ".concat(Se),children:[(0,u.jsx)("span",{className:"rounded-full px-2.5 py-1 ".concat(r?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"),children:zA(e.role)}),(0,u.jsxs)("span",{children:["Explicit overrides: ",h]}),(0,u.jsxs)("span",{children:["Updated ",LA(e.updatedAt||e.createdAt)]}),null!==p&&void 0!==p&&p.lastUsedAt||e.lastLoginAt?(0,u.jsxs)("span",{children:["Last seen ",RA((null===p||void 0===p?void 0:p.lastUsedAt)||e.lastLoginAt)]}):null,(null===g||void 0===g?void 0:g.isUnlimited)&&(0,u.jsx)("span",{className:"rounded-full bg-[#e8edf2] px-2.5 py-1 text-brand-navy dark:bg-brand-navy
2/30 dark:text-brand-cloud",children:"Unlimited credits"}),(null===g||void 0===g?void 0:g.isOverLimit)&&(0,u.jsx)("span",{className:"rounded-full bg-red-100 px-2.5 py-1 text-red-700 dark:bg-red-950/40 dark:text-red-300",children:"Over monthly limit"}),!(null!==g&&void 0!==g&&g.isOverLimit)&&(null===g||void 0===g?void 0:g.isWarning)&&(0,u.jsx)("span",{className:"rounded-full bg-amber-100 px-2.5 py-1 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300",children:"Near monthly limit"}),s&&(0,u.jsx)("span",{className:"rounded-full bg-amber-100 px-2.5 py-1 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300",children:"Master changes locked to master users"}),c&&(0,u.jsx)("span",{className:"rounded-full bg-[#fff3d6] px-2.5 py-1 text-[#7a560c] dark:bg-brand-yellow/20 dark:text-brand-yellow",children:"You"}),o&&(0,u.jsx)("span",{className:"rounded-full bg-red-100 px-2.5 py-1 text-red-700 dark:bg-red-950/40 dark:text-red-300",children:"Queued for removal"})]})]}),(0,u.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:J?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("select",{value:t.role,onChange:t=>De(e.email,e=>d(d({},e),{},{role:t.target.value})),disabled:s||o,className:"".concat(Ae," min-w-[150px] ").concat(s||o?"cursor-not-allowed opacity-70":""),children:m.map(e=>(0,u.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,u.jsxs)("button",{type:"button",onClick:()=>T(t=>d(d({},t),{},{[e.email]:!t[e.email]})),className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(r?"bg-gray-700 text-gray-100 hover:bg-gray-600":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:[a?(0,u.jsx)(Tu,{className:"h-4 w-4"}):(0,u.jsx)(wd,{className:"h-4 w-4"}),"Details"]}),(0,u.jsxs)("button",{type:"button",onClick:()=>(e=>{const t=jV(e);t&&F(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])})(e.email),disabled:s||c,className:"inline-flex items-center gap-2 rounded-xl px-4 py-2 text-sm font-medium transition-colors ".concat(o?"bg-amber-500 text-white hover:bg-amber-400":"bg-red-600 text-white hover:bg-red-500"," ").concat(s||c?"cursor-not-allowed opacity-60":""),children:[o?(0,u.jsx)(fj,{className:"h-4 w-4"}):(0,u.jsx)(kp,{className:"h-4 w-4"}),o?"Undo Remove":c?"Cannot Remove Self":"Remove"]})]}):(0,u.jsx)("div",{className:"rounded-xl px-3 py-2 text-sm ".concat(Fe," ").concat(Se),children:zA(e.role)})})]}),$&&(0,u.jsxs)("div",{className:"mt-5 grid gap-3 xl:grid-cols-[1fr_1fr_1fr_1fr_1.2fr]",children:[(0,u.jsx)(PV,{isDarkMode:r,label:"Last used",value:RA((null===p||void 0===p?void 0:p.lastUsedAt)||e.lastLoginAt),hint:LA((null===p||void 0===p?void 0:p.lastUsedAt)||e.lastLoginAt)}),(0,u.jsx)(PV,{isDarkMode:r,label:"".concat((null===p||void 0===p?void 0:p.days)||i,"d events"),value:BA((null===p||void 0===p?void 0:p.events)||0),hint:null!==p&&void 0!==p&&p.lastUsageAt?"Tracked usage on ".concat(LA(p.lastUsageAt)):"No billed or metered events in window"}),(0,u.jsx)(PV,{isDarkMode:r,label:"".concat((null===p||void 0===p?void 0:p.days)||i,"d cost"),value:_A((null===p||void 0===p?void 0:p.totalCostUsd)||0),hint:null!==p&&void 0!==p&&p.lastSessionUsedAt?"Last authenticated activity ".concat(LA(p.lastSessionUsedAt)):"No recent signed activity"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Month credits",value:null!==g&&void 0!==g&&g.isUnlimited?"Unlimited":IA((null===g||void 0===g?void 0:g.totalCreditsUsed)||0),hint:null!==g&&void 0!==g&&g.isUnlimited?"No monthly cap":null!==(null===g||void 0===g?void 0:g.creditsRemaining)&&void 0!==(null===g||void 0===g?void 0:g.creditsRemaining)?"".concat(IA(g.creditsRemaining)," remaining"):"Unlimited"}),(0,u.jsx)(LV,{isDarkMode:r,usage:p,fallbackDays:l})]}),(a||!J)&&(0,u.jsxs)("div",{className:"mt-5",children:[g&&(0,u.jsxs)("div",{className:"mb-4 rounded-2xl border p-4 ".concat(r?"border-gray-700 bg-gray-950/50":"border-gray-200 bg-white"),children:[(0,u.jsxs)("div",{className:"mb-4 flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-medium",children:"Monthly billing snapshot"}),(0,u.jsxs)("p",{className:"mt-1 text-sm ".concat(Se),children:["Period ",g.period.periodId,". Costs and credits reset at the start of each calendar month."]})]}),(0,u.jsx)("div",{className:"rounded-full px-3 py-1 text-xs font-medium ".concat(g.isOverLimit?r?"bg-red-950/50 text-red-200":"bg-red-100 text-red-700":g.isWarning?r?"bg-amber-950/50 text-amber-200":"bg-amber-100 text-amber-700":r?"bg-brand-navy
2/30 text-brand-cloud":"bg-[#e8edf2] text-brand-navy"),children:g.isUnlimited?"Unlimited":g.isOverLimit?"Over limit":g.isWarning?"Warning threshold":"Within limit"})]}),(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-4",children:[(0,u.jsx)(PV,{isDarkMode:r,label:"Month cost",value:_A(g.totalCostUsd),hint:null!==g.monthlyUsdLimit?"".concat(NV(g.percentUsdUsed)," of ").concat(_A(g.monthlyUsdLimit)):"Unlimited"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Month credits",value:IA(g.totalCreditsUsed),hint:null!==g.monthlyCreditLimit?"".concat(NV(g.percentCreditsUsed)," of ").concat(IA(g.monthlyCreditLimit)):"Unlimited"}),(0,u.jsx)(PV,{isDarkMode:r,label:"Credits left",value:null===g.creditsRemaining?"Unlimited":IA(g.creditsRemaining),hint:"Updated ".concat(LA(g.lastUsageAt))}),(0,u.jsx)(PV,{isDarkMode:r,label:"USD left",value:null===g.usdRemaining?"Unlimited":_A(g.usdRemaining),hint:g.override?"Member override active":"Using org default"})]}),J&&(0,u.jsxs)("div",{className:"mt-4 border-t pt-4 dark:border-gray-700",children:[(0,u.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-3",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-medium",children:"Member override"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(Se),children:"Leave both limits empty to inherit the organization defaults."})]}),(0,u.jsxs)("label",{className:"inline-flex items-center gap-2 text-sm font-medium",children:[(0,u.jsx)("input",{type:"checkbox",checked:n.isUnlimited,disabled:s||o,onChange:t=>Ce(e.email,e=>d(d({},e),{},{isUnlimited:t.target.checked,monthlyCreditLimit:t.target.checked?"":e.monthlyCreditLimit,monthlyUsdLimit:t.target.checked?"":e.monthlyUsdLimit}))}),"Unlimited"]})]}),(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,u.jsx)(IV,{label:"USD / Month Override",value:n.monthlyUsdLimit,onChange:t=>Ce(e.email,e=>d(d({},e),{},{monthlyUsdLimit:t})),disabled:n.isUnlimited||s||o,placeholder:"Inherit",inputClass:Ae}),(0,u.jsx)(IV,{label:"Credits / Month Override",value:n.monthlyCreditLimit,onChange:t=>Ce(e.email,e=>d(d({},e),{},{monthlyCreditLimit:t})),disabled:n.isUnlimited||s||o,placeholder:"Inherit",inputClass:Ae})]})]})]}),J?(0,u.jsx)(OV,{isDarkMode:r,modes:t.capabilityModes,onModeChange:(t,n)=>De(e.email,e=>d(d({},e),{},{capabilityModes:d(d({},e.capabilityModes),{},{[t]:n})})),disabled:s||o}):(0,u.jsx)(UV,{isDarkMode:r,modes:t.capabilityModes})]})]},e.id)})})]}),"policy"===m&&(0,u.jsx)("div",{className:"space-y-6",children:(0,u.jsxs)(TV,{isDarkMode:r,title:"Global feature policy",description:"Organization policy gates the product surface for every member. Explicit member overrides cannot turn a feature back on if it is disabled here.",children:[(0,u.jsxs)("div",{className:"mb-6 grid gap-3 md:grid-cols-3",children:[(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(FA,{className:"h-5 w-5"}),label:"Enabled features",value:"".concat(kV(x||p.organization.featurePolicy),"/").concat(SA.length),hint:"Global policy before per-member overrides"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(fh,{className:"h-5 w-5"}),label:"Members inheriting",value:BA(p.organization.members.length),hint:"All members are affected by this layer"}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(yp,{className:"h-5 w-5"}),label:"Save model",value:J?"Global save":"Read-only",hint:J?"Changes stage until Save All":"You can inspect but not edit"})]}),(0,u.jsx)("div",{className:"grid gap-3 md:grid-cols-2",children:SA.map(e=>{var t;const n=null!==(t=null===x||void 0===x?void 0:x[e.key])&&void 0!==t&&t;return(0,u.jsx)("div",{className:"rounded-2xl border p-4 ".concat(Fe),children:(0,u.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-medium",children:e.label}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(Se),children:e.description})]}),(0,u.jsx)("button",{type:"button",onClick:()=>f(t=>t?d(d({},t),{},{[e.key]:!t[e.key]}):t),disabled:!J||!x,className:"relative inline-flex h-7 w-12 shrink-0 items-center rounded-full transition-colors ".concat(n?"bg-brand-yellow":r?"bg-gray-700":"bg-gray-300"," ").concat(J?"":"cursor-not-allowed opacity-70"),children:(0,u.jsx)("span",{className:"inline-block h-5 w-5 rounded-full bg-white transition-transform ".concat(n?"translate-x-6":"translate-x-1")})})]})},e.key)})})]})}),"activity"===m&&(0,u.jsx)("div",{className:"space-y-6",children:$&&p.usage?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:"grid gap-3 md:grid-cols-5",children:[(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(yp,{className:"h-5 w-5"}
2),label:"Events",value:BA(p.usage.summary.totals.events)}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(FA,{className:"h-5 w-5"}),label:"Recorded cost",value:_A(p.usage.summary.totals.total_cost_usd)}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(YE,{className:"h-5 w-5"}),label:"Credits",value:IA(p.usage.summary.totals.total_credits_used||0)}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(fh,{className:"h-5 w-5"}),label:"Units",value:BA(p.usage.summary.totals.total_units)}),(0,u.jsx)(BV,{isDarkMode:r,icon:(0,u.jsx)(yp,{className:"h-5 w-5"}),label:"Bytes Out",value:PA(p.usage.summary.totals.bytes_out)})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(_V,{isDarkMode:r,title:"Principals",description:"Member accounts are separated from shared viewers and automation identities.",groups:[{title:"Member accounts",items:fe.memberItems},{title:"Shared & system clients",items:fe.otherItems}],emptyText:"No principal usage yet.",primaryLabel:"Cost",secondaryLabel:"Credits"}),(0,u.jsx)(MV,{isDarkMode:r,title:"Operations",description:"Most expensive operation families in the selected window.",items:p.usage.summary.byOperation.slice(0,10).map(e=>({label:"".concat(e.provider,"/").concat(e.service,"/").concat(e.operation),value:e.total_cost_usd||0,secondaryValue:e.total_credits_used||0,detail:"".concat(BA(e.events)," events")})),emptyText:"No operation usage yet.",primaryLabel:"Cost",secondaryLabel:"Credits"})]}),(0,u.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,u.jsx)(VV,{isDarkMode:r,title:"By Provider",headers:["Provider","Events","Units","Credits","Cost"],emptyText:"No provider usage yet.",rows:p.usage.summary.byProvider.map(e=>["".concat(e.provider,"/").concat(e.service),BA(e.events),BA(e.total_units),IA(e.total_credits_used||0),_A(e.total_cost_usd)])}),(0,u.jsx)(VV,{isDarkMode:r,title:"By Status",headers:["Status","Events","Credits","Cost"],emptyText:"No cost status data yet.",rows:p.usage.summary.byStatus.map(e=>[FV(e.cost_status),BA(e.events),IA(e.total_credits_used||0),_A(e.total_cost_usd)])})]}),(0,u.jsx)(TV,{isDarkMode:r,title:"Recent organization usage",description:"The latest metered events across the organization.",children:0===p.usage.recent.length?(0,u.jsx)("p",{className:Se,children:"No recent usage events."}):(0,u.jsx)("div",{className:"max-h-[480px] overflow-auto",children:(0,u.jsxs)("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[(0,u.jsx)("thead",{className:r?"bg-gray-950/70":"bg-white",children:(0,u.jsx)("tr",{children:["When","User","Operation","Units","Status","Credits","Cost","Details"].map(e=>(0,u.jsx)("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wide ".concat(Ee),children:e},e))})}),(0,u.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:p.usage.recent.map(e=>(0,u.jsxs)("tr",{className:r?"bg-transparent":"bg-white",children:[(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:LA(e.created_at)}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm ".concat(Se),children:e.user_email||"Unknown"}),(0,u.jsxs)("td",{className:"px-4 py-3 text-sm",children:[(0,u.jsxs)("div",{children:[e.provider,"/",e.service]}),(0,u.jsx)("div",{className:Se,children:e.operation})]}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm ".concat(Se),children:e.total_units?BA(e.total_units):e.quantity?"".concat(BA(e.quantity)," ").concat(e.unit||"").trim():"0"}),(0,u.jsxs)("td",{className:"px-4 py-3 text-sm",children:[(0,u.jsx)("div",{className:"font-medium",children:"aws"===e.provider&&"aws:fargate-runtime"===e.price_source?"Legacy estimate (unverified)":FV(e.cost_status)}),(0,u.jsx)("div",{className:Se,children:e.price_source||"price source unavailable"})]}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:IA(e.credits_used||0)}),(0,u.jsx)("td",{className:"px-4 py-3 text-sm",children:null===e.cost_usd||"unknown"===e.cost_status?"Unknown":_A(e.cost_usd)}),(0,u.jsxs)("td",{className:"px-4 py-3 text-sm ".concat(Se),children:[(0,u.jsx)("div",{children:e.model||"No model"}),(0,u.jsxs)("div",{children:[e.resource_type||"resource"," ",e.resource_id?"\xb7 ".concat(e.resource_id):""]}),(0,u.jsxs)("div",{children:[e.byok?"BYOK":"Org billed",e.cache_hit?" \xb7 cache hit":""]})]})]},e.id))})]})})})]}):(0,u.jsx)(TV,{isDarkMode:r,title:"Organization-wide activity is restricted",description:"Your own usage remains available in the My Usage pane.",children:(0,u.jsx)("p",{className:Se,children:"Organization-wide usage visibility is limited to org admins and master users."})})})]})]})]})]}):(0,u.jsx)("div",{className:"rounded-2xl border p-6 ".concat(Ne),children:(0,u.jsxs)("div",{className:"flex items-start gap-3 text-red-500",children:[(0,u.jsx)(Lu,{className:"mt-0.5 h-5 w-5 shrink-0"}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-medium",children:"Settings failed to load."}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(Se),children:R||"
2Unknown error"})]})]})}):(0,u.jsx)("div",{className:"rounded-2xl border p-6 ".concat(Ne),children:(0,u.jsx)("p",{className:Se,children:"Sign in to load organization settings."})})},qV=()=>{var e;const{isDarkMode:t}=zu(),n=qF(),r=Xw(),{playSegment:s}=Kw(),{setHoveredTimeRange:i}=wk(),{buildClipItems:o}=GF(),[l,c]=(0,a.useState)(null),d=(0,a.useMemo)(()=>[...(null===n||void 0===n?void 0:n.clips)||[]].sort((e,t)=>e.startTime-t.startTime),[null===n||void 0===n?void 0:n.clips]),m=(0,a.useMemo)(()=>{if(!n)return null;const e=Math.max(0,r),t=n.sessionDuration?Math.min(n.sessionDuration,e+20):e+20,a=n.freeGaps.find(t=>e>=t.start&&e<t.end),s=a?{start:e,end:Math.min(t,a.end)}:{start:e,end:t};return{span:s,verdict:n.previewNewClip(s)}},[r,n]);if(!n||!n.enabled)return(0,u.jsx)("div",{className:"flex h-full items-center justify-center p-8 text-center text-sm ".concat(t?"text-gray-400":"text-gray-500"),children:"Sign in to see which cuts use this session."});const h=t?"border-white/10 bg-[rgba(17,27,42,0.55)]":"border-[rgba(215,222,233,0.82)] bg-white/80";return(0,u.jsxs)("div",{className:"flex h-full flex-col gap-4 p-4 md:p-6",children:[(0,u.jsxs)("div",{className:"rounded-2xl border ".concat(h),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[(0,u.jsx)(ck,{size:15,className:t?"text-[#ffc766]":"text-[#8a6115]"}),(0,u.jsx)("span",{className:"text-[13px] font-semibold ".concat(t?"text-gray-100":"text-gray-800"),children:"Cuts using this session"}),n.arrangements.length>0&&(0,u.jsx)("span",{className:"rounded-full px-2 py-0.5 text-[11px] ".concat(t?"bg-white/10 text-gray-300":"bg-gray-100 text-gray-600"),children:n.arrangements.length})]}),(0,u.jsx)("button",{type:"button",onClick:()=>n.refresh(),className:"rounded-full p-1.5 transition-colors ".concat(t?"text-gray-400 hover:bg-white/10":"text-gray-500 hover:bg-gray-100"),title:"Reload",children:(0,u.jsx)(vp,{size:13,className:n.detailLoading?"animate-spin":""})})]}),(0,u.jsxs)("div",{className:"px-2 pb-2",children:[n.arrangementsLoading&&(0,u.jsx)("div",{className:"px-2 py-3 text-[12px] ".concat(t?"text-gray-400":"text-gray-500"),children:"Looking for arrangements\u2026"}),n.arrangementsError&&(0,u.jsx)("div",{className:"px-2 py-3 text-[12px] text-red-500",children:n.arrangementsError}),!n.arrangementsLoading&&!n.arrangementsError&&0===n.arrangements.length&&(0,u.jsx)("div",{className:"px-2 py-3 text-[12px] ".concat(t?"text-gray-400":"text-gray-500"),children:"No arrangement references this session yet."}),n.arrangements.map(e=>{const a=e.id===n.selectedArrangementId;return(0,u.jsxs)("button",{type:"button","data-testid":"arrangement-option-".concat(e.id),onClick:()=>n.selectArrangement(a?null:e.id),className:"flex w-full items-center gap-3 rounded-xl px-2.5 py-2.5 text-left transition-colors ".concat(a?t?"bg-[rgba(255,181,43,0.14)]":"bg-[rgba(255,181,43,0.16)]":t?"hover:bg-white/5":"hover:bg-gray-100/70"),children:[(0,u.jsx)(uj,{size:14,className:a?t?"text-[#ffc766]":"text-[#8a6115]":t?"text-gray-500":"text-gray-400"}),(0,u.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,u.jsx)("span",{className:"block truncate text-[13px] ".concat(a?"font-semibold":""," ").concat(t?"text-gray-100":"text-gray-800"),children:e.title}),(0,u.jsxs)("span",{className:"block text-[11px] ".concat(t?"text-gray-400":"text-gray-500"),children:[e.clipCount," clip",1===e.clipCount?"":"s"," from this session",e.unplacedClipCount>0&&" \xb7 ".concat(e.unplacedClipCount," unplaced")," \xb7 ",MF(e.sourceSeconds)," used"]})]}),(0,u.jsx)(bp,{size:14,className:"shrink-0 transition-transform ".concat(a?"rotate-90":""," ").concat(t?"text-gray-500":"text-gray-400")})]},e.id)})]})]}),(n.lastError||n.lastSuccess)&&(0,u.jsxs)("div",{"data-testid":"arrangement-panel-message",className:"flex items-start gap-2 rounded-xl border px-3 py-2.5 text-[12px] ".concat(n.lastError?t?"border-red-500/30 bg-red-500/10 text-red-200":"border-red-200 bg-red-50 text-red-700":t?"border-emerald-500/30 bg-emerald-500/10 text-emerald-200":"border-emerald-200 bg-emerald-50 text-emerald-700"),children:[n.lastError?(0,u.jsx)(Lu,{size:14,className:"mt-0.5 shrink-0"}):(0,u.jsx)(Ej,{size:14,className:"mt-0.5 shrink-0"}),(0,u.jsxs)("span",{className:"flex-1",children:[n.lastError&&n.lastError.code&&(0,u.jsx)("code",{className:"mr-1.5 rounded bg-black/10 px-1 py-0.5 text-[10px] dark:bg-white/10",children:n.lastError.code}),(null===(e=n.lastError)||void 0===e?void 0:e.message)||n.lastSuccess]}),(0,u.jsx)("button",{type:"button",onClick:n.clearMessages,className:"shrink-0 text-[11px] underline opacity-70 hover:opacity-100",children:"dismiss"})]}),n.selectedArrangementId&&(0,u.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col rounded-2xl border ".concat(h),children:[(0,u.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b px-4 py-3 ".concat(t?"border-white/10":"border-gray-200/80"),children:[(0,u.jsx)("span",{className:"text-[13px] font-semibold ".concat(t?"text-gray-100":"text-gray-800"),children:"Clips from this session"}),m&&(0,u.jsxs)("button",{type:"button","data-testid":"arrangement-add-clip",disabled:!m.verdict.ok,title:m.verdict.ok?"Add ".concat(MF(m.span.start),"\u2013").concat(MF(m.span.end)):m.verdict.message,onClick:()=>n.addClip(m.span),className:"inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors ".concat(m.verdict.ok?t?"bg-[rgba(255,181,43,0.18)] text-[#ffd88a] hover:bg-[rgba(255,181,43,0.28)]":"bg-[#fff1cc] text-[#6e4d0e] hover:bg-[#ffe4a3]":t?"cursor-not-allowed bg-white/5 text-gray-500":"cursor-not-allowed bg-gray-100 text-gray-400"),children:[(0,u.jsx)(ik,{size:12}),"Add clip at playhead"]})]}),m&&!m.verdict.ok&&(0,u.jsx)("div",{"data-testid":"arrangement-add-blocked",className:"px-4 py-2 text-[11px] ".concat(t?"text-red-300/90":"text-red-600/90"),children:m.verdict.message}),(0,u.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2",children:[n.detailError&&(0,u.jsx)("div",{className:"px-2 py-3 text-[12px] text-red-500",children:n.detailError}
2),!n.detailError&&0===d.length&&!n.detailLoading&&(0,u.jsx)("div",{className:"px-2 py-3 text-[12px] ".concat(t?"text-gray-400":"text-gray-500"),children:"This cut has no clips from this session."}),d.map(e=>{var a,l;const d=n.selectedClipId===e.id,m=n.busyClipId===e.id,h=(null===(a=n.detail)||void 0===a||null===(l=a.dependentsByClip)||void 0===l?void 0:l[e.id])||[];return(0,u.jsxs)("div",{"data-testid":"arrangement-clip-row-".concat(e.id),onMouseEnter:()=>{n.setHoveredClipId(e.id),i({start:e.startTime,end:e.endTime})},onMouseLeave:()=>{n.setHoveredClipId(null),i(null)},onClick:()=>n.setSelectedClipId(d?null:e.id),onContextMenu:t=>{t.preventDefault();const a=n.deleteImpactFor(e.id);c({x:t.clientX,y:t.clientY,title:"".concat(e.clipCode||e.id.slice(0,8)," \xb7 ").concat(MF(e.startTime),"\u2013").concat(MF(e.endTime)),subtitle:e.title||e.speaker,warnings:(null===a||void 0===a?void 0:a.warnings)||[],items:o(e.id,{atTime:r})})},className:"group flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 transition-colors ".concat(d?t?"bg-[rgba(255,181,43,0.12)]":"bg-[rgba(255,181,43,0.14)]":t?"hover:bg-white/5":"hover:bg-gray-100/70"," ").concat(m?"opacity-60":""),children:[(0,u.jsx)("span",{className:"shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-semibold tracking-[0.08em] ".concat(e.placed?t?"bg-[rgba(255,181,43,0.2)] text-[#ffd88a]":"bg-[#fff1cc] text-[#6e4d0e]":t?"border border-dashed border-white/20 text-gray-400":"border border-dashed border-gray-300 text-gray-500"),children:e.clipCode||"\u2014"}),(0,u.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,u.jsx)("span",{className:"block truncate text-[12.5px] ".concat(t?"text-gray-100":"text-gray-800"),children:e.title||e.speaker}),(0,u.jsxs)("span",{className:"block text-[11px] tabular-nums ".concat(t?"text-gray-400":"text-gray-500"),children:[MF(e.startTime),"\u2013",MF(e.endTime)," \xb7 ",(e.endTime-e.startTime).toFixed(1),"s",!e.placed&&" \xb7
2not in the cut",e.sequenceKey&&" \xb7 ".concat(e.sequenceKey),h.length>0&&" \xb7 ".concat(h.length," depend on it")]})]}),(0,u.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),s(e.startTime,e.endTime)},className:"shrink-0 rounded-full px-2 py-1 text-[10px] opacity-0 transition-opacity group-hover:opacity-100 ".concat(t?"bg-white/10 text-gray-200":"bg-gray-100 text-gray-600"),children:"play"}),(0,u.jsx)("button",{type:"button","data-testid":"arrangement-clip-menu-button-".concat(e.id),onClick:t=>{t.stopPropagation();const a=t.currentTarget.getBoundingClientRect(),s=n.deleteImpactFor(e.id);c({x:a.right-200,y:a.bottom+4,title:"".concat(e.clipCode||e.id.slice(0,8)," \xb7 ").concat(MF(e.startTime),"\u2013").concat(MF(e.endTime)),subtitle:e.title||e.speaker,warnings:(null===s||void 0===s?void 0:s.warnings)||[],items:o(e.id,{atTime:r})})},className:"shrink-0 rounded-full p-1 transition-colors ".concat(t?"text-gray-400 hover:bg-white/10":"text-gray-500 hover:bg-gray-200"),children:(0,u.jsx)(wD,{size:14})})]},e.id)})]}),(0,u.jsx)("div",{className:"border-t px-4 py-2 text-[11px] ".concat(t?"border-white/10 text-gray-500":"border-gray-200/80 text-gray-500"),children:"Right-click a clip here, on the timeline, or in the transcript for the same options. Clips cannot overlap \u2014 trims stop at the neighbouring clip. Drag handles appear on the timeline once a clip is wide enough to grab; until then, trim from the menu."})]}),l&&(0,u.jsx)(KF,{x:l.x,y:l.y,title:l.title,subtitle:l.subtitle,warnings:l.warnings,items:l.items,isDarkMode:t,onClose:()=>c(null)})]})},WV="/api";const YV=class{static async request(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;const a="".concat(WV).concat(e),r=new Headers(t.headers);r.set("Content-Type","application/json"),n&&r.set("Authorization","Bearer ".concat(n));const s=await fetch(a,d({headers:r},t));if(!s.ok){const e=await s.json().catch(()=>({error:"Network error"}));throw Object.assign(new Error(e.error||"HTTP ".concat(s.status)),{status:s.status})}return s.json()}static async transcribeFile(e,t,n){const a=new FormData;a.append("audio",e),a.append("settings",JSON.stringify(t)),t.projectId&&a.append("projectId",t.projectId),console.log("Sending transcription request for file:",e.name,"Size:",e.size);const r=new Headers;n&&r.set("Authorization","Bearer ".concat(n));const s=await fetch("".concat(WV,"/transcribe"),{method:"POST",body:a,headers:r});if(!s.ok){const e=await s.json().catch(()=>({error:"Network error"}));throw new Error(e.error||"HTTP ".concat(s.status))}const i=await s.json();return i._cache&&(i._cache.hit?console.log("\u2705 Cache HIT - Used cached transcription from ".concat(i._cache.cachedAt)):console.log("\ud83d\udd04 Cache MISS - New transcription cached at ".concat(i._cache.cachedAt))),i}static async transcribeUrl(e,t,n){const a=await this.request("/transcribe-url",{method:"POST",body:JSON.stringify({url:e,settings:t,projectId:t.projectId})},n);return a._cache&&(a._cache.hit?console.log("\u2705 Cache HIT - Used cached transcription from ".concat(a._cache.cachedAt)):console.log("\ud83d\udd04 Cache MISS - New transcription cached at ".concat(a._cache.cachedAt))),a}static async transcribeYoutube(e,t,n){console.log("Sending YouTube transcription request for URL:",e);const a=window.__youtubeCookies,r=await this.request("/transcribe-youtube",{method:"POST",body:JSON.stringify({url:e,settings:t,cookies:a,projectId:t.projectId})},n);return r._cache&&(r._cache.hit?console.log("\u2705 YouTube Cache HIT - Used cached transcription from ".concat(r._cache.cachedAt)):console.log("\ud83d\udd04 YouTube Cache MISS - New transcription cached at ".concat(r._cache.cachedAt))),r}static async transcribeDropbox(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3?arguments[3]:void 0;console.log("Sending Dropbox transcription request for URL:",e);const r=await this.request("/transcribe-dropbox",{method:"POST",body:JSON.stringify({url:e,settings:t,videoFilename:n.videoFilename,projectId:t.projectId})},a);return r._cache&&(r._cache.hit?console.log("\u2705 Dropbox Cache HIT - Used cached transcription from ".concat(r._cache.cac
2hedAt)):console.log("\ud83d\udd04 Dropbox Cache MISS - New transcription cached at ".concat(r._cache.cachedAt))),r}static async saveSpeakerLabels(e,t,n){await this.request("/cache/metadata/".concat(e),{method:"POST",body:JSON.stringify({speakerLabels:t})},n)}static async getCacheStats(e){return this.request("/cache-stats",{},e)}static async clearCache(e){return this.request("/cache-clear",{method:"POST"},e)}static async getCacheList(e){return this.request("/cache-list",{},e)}static async getActivityLog(e){return this.request("/activity-log",{},e)}static async getAccessRequests(e){return this.request("/access-requests",{},e)}static async manageAccessRequest(e,t,n){return this.request("/manage-request",{method:"POST",body:JSON.stringify({requestId:t,action:n})},e)}static async requestAccess(e){const t=await fetch("".concat(WV,"/request-access"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})});if(!t.ok){const e=await t.json().catch(()=>({error:"Network error"}));throw new Error(e.message||"HTTP ".concat(t.status))}return t.json()}static async healthAuth(e){return this.request("/health-auth",{},e)}static isConfigured(){return!0}static async validateApiKey(e,t){try{return await this.request("/vali
2date-key",{method:"POST",body:JSON.stringify({apiKey:e})},t),!0}catch(_H){return!1}}static initializeClient(e){console.log("API key would be set on backend")}static clearApiKey(){console.log("API key would be cleared on backend")}};class GV{static formatTimestamp(e){if(e<0||!isFinite(e))return"[00:00:00]";const t=Math.floor(e/3600),n=Math.floor(e%3600/60),a=Math.floor(e%60);return"[".concat(t.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"),":").concat(a.toString().padStart(2,"0"),"]")}static extractSpeakerSegments(e){var t;const n=new Map,a=((null===(t=e.results)||void 0===t?void 0:t.channels)||[]).flatMap(e=>e.alternatives.flatMap(e=>e.words));if(0===a.length)return n;let r=null;for(const i of a){var s;if(null===(s=i.word)||void 0===s||!s.trim()||void 0===i.speaker)continue;const e=i.punctuated_word||i.word;r&&r.speaker===i.speaker?(r.transcript+=" ".concat(e),r.end=i.end):(r&&(n.has(r.speaker)||n.set(r.speaker,[]),n.get(r.speaker).push(r)),r={speaker:i.speaker,start:i.start,end:i.end,transcript:e.trim()})}return r&&(n.has(r.speaker)||n.set(r.speaker,[]),n.get(r.speaker).push(r)),n.forEach(e=>{e.sort((e,t)=>e.start-t.start)}),n}static getDistinctSpeakers(e){return Array.from(e.keys()).filter(e=>void 0!==e).sort((e,t)=>e-t)}static generateFormattedTranscript(e,t){var n,a,r,s,i;let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:15;const l=null===(n=e.results)||void 0===n||null===(a=n.channels)||void 0===a||null===(r=a[0])||void 0===r||null===(s=r.alternatives)||void 0===s||null===(i=s[0])||void 0===i?void 0:i.words;var c,d,u,m,h,p;if(!l||0===l.length)return(null===(c=e.results)||void 0===c||null===(d=c.channels)||void 0===d||null===(u=d[0])||void 0===u||null===(m=u.alternatives)||void 0===m||null===(h=m[0])||void 0===h||null===(p=h.transcript)||void 0===p?void 0:p.trim())||"No speech detected.";let g,x=[],f=[],b=0,y=o>0?o:1/0;const v=()=>{f.length>0&&(x.push(" "+f.join(" ")),f=[])};for(const k of l){var w;if(void 0===k.speaker||null===(w=k.word)||void 0===w||!w.trim())continue;if(k.speaker!==g){v(),x.length>0&&x.push("");const e=t[k.speaker]||"Speaker ".concat(k.speaker);x.push("".concat(e," ").concat(this.formatTimestamp(k.start),":")),g=k.speaker}const e=k.start-b;if(o>0&&e>2&&k.start>y){for(v(),x.push("");k.start>y;)x.push(" ".concat(this.formatTimestamp(y))),y+=o;x.push("")}if(f.push(k.punctuated_word||k.word),b=k.end,o>0&&b>=y){for(v(),x.push("");b>=y;)x.push(" ".concat(this.formatTimestamp(y))),y+=o;x.push("")}}return v(),x.join("\n")}static getSpeakerAudioSegments(e,t){return(e.get(t)||[]).map(e=>({start:e.start,end:e.end}))}static generateSampleSegment(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5;if(0===e.length)return null;const n=e.filter(e=>e.end-e.start>=t);if(n.length>0){const e=n[Math.floor(Math.random()*n.length)],a=e.end-t;return{start:Math.random()*(a-e.start)+e.start,duration:t}}{const n=e.reduce((e,t)=>t.end-t.start>e.end-e.start?t:e),a=Math.min(t,n.end-n.start);return a<.1?null:{start:n.start,duration:a}}}}const KV={updateViaCache:"none"},XV=["/","/index.html","/manifest.json","/favicon.ico"];let JV=null;function $V(){return"serviceWorker"in navigator}function QV(e){return e&&"string"===typeof e?e.startsWith("http")?e:new URL(e,window.location.origin).toString():null}function ZV(e){return"string"===typeof e&&/\.(?:js|css)(?:$|\?)/.test(e)}async function eH(){const e=new Set(XV.map(e=>QV(e)).filter(Boolean));try{const t=await fetch("/asset-manifest.json",{cache:"no-store"});if(!t.ok)return Array.from(e);const n=await t.json(),a=Object.values((null===n||void 0===n?void 0:n.files)||{}),r=Array.isArray(null===n||void 0===n?void 0:n.entrypoints)?n.entrypoints:[];a.forEach(t=>{if(ZV(t)){const n=QV(t);n&&e.add(n)}}),r.forEach(t=>{if(ZV(t)){const n=QV(t);n&&e.add(n)}})}catch(t){console.warn("[SW] Failed to read asset manifest for page-side shell caching:",t)}return Array.from(e)}async function tH(){if("undefined"===typeof caches)return!1;try{const[e,t]=await Promise.all([caches.open("mlst-app-shell-v8"),eH()]);return await Promise.all(t.map(async t=>{try{const n=function(e){const t=new URL(e,window.location.origin);
2return new Request(t.toString(),{mode:t.origin===window.location.origin?"same-origin":"no-cors",cache:"no-store"})}(t),a=await fetch(n);a&&(a.ok||"opaque"===a.type)&&await e.put(n,a.clone())}catch(n){console.warn("[SW] Failed to cache offline shell asset from page:",t,n)}})),!0}catch(e){return console.warn("[SW] Failed to open page-side offline shell cache:",e),!1}}async function nH(){return $V()?(JV||(JV=navigator.serviceWorker.register("/sw.js",KV).then(e=>function(e){const t=()=>{var t;null===(t=e.waiting)||void 0===t||t.postMessage({type:"SKIP_WAITING"})};return e.addEventListener("updatefound",()=>{const n=e.installing;n&&n.addEventListener("statechange",()=>{"installed"===n.state&&navigator.serviceWorker.controller&&t()})}),e.waiting&&t(),e.update().catch(e=>{console.warn("[SW] Update check failed:",e)}),e}(e)).catch(e=>(JV=null,console.warn("[SW] Registration failed:",e),null))),JV):null}const aH="mlst-offline-diagnostics-v1";function rH(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(null===e||void 0===e)return e;if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack?e.stack.split("\n").slice(0,6).join("\n"):void 0};if("string"===typeof e)return e.length>320?"".concat(e.slice(0,317),"..."):e;if("number"===typeof e||"boolean"===typeof e)return e;if(Array.isArray(e)){const n=e.slice(0,8).map(e=>rH(e,t+1));return e.length>8&&n.push("... ".concat(e.length-8," more items")),n}if("object"===typeof e){if(t>=2)return"[object truncated]";const n=Object.entries(e).slice(0,12),a={};n.forEach(e=>{let[n,r]=e;a[n]=rH(r,t+1)});const r=Object.keys(e).length;return r>n.length&&(a.__truncatedKeys=r-n.length),a}return String(e)}function sH(e){if(void 0!==e){if("string"===typeof e)return e;try{return JSON.stringify(rH(e),null,2)}catch(t){return"Failed to serialize details: ".concat(t instanceof Error?t.message:String(t))}}}function iH(){if("undefined"===typeof window)return[];try{const e=window.localStorage.getItem(aH);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(_H){return[]}}function oH(e){if("undefined"!==typeof window)try{window.localStorage.setItem(aH,JSON.stringify(e.slice(-80)))}catch(t){}}function lH(e,t,n){const a=iH();a.push({timestamp:(new Date).toISOString(),level:e,message:t,details:sH(n)}),oH(a)}function cH(e){const t=["MLST Offline Diagnostics","Generated: ".concat((new Date).toISOString()),"URL: ".concat(window.location.href),"Online: ".concat(navigator.onLine),"Visibility: ".concat(document.visibilityState),"User Agent: ".concat(navigator.userAgent)];var n;"serviceWorker"in navigator&&(t.push("Service Worker Controlled: ".concat(navigator.serviceWorker.controller?"yes":"no")),null!==(n=navigator.serviceWorker.controller)&&void 0!==n&&n.scriptURL&&t.push("Service Worker Script: ".concat(navigator.serviceWorker.controller.scriptURL)));e&&Object.keys(e).length>
20&&(t.push(""),t.push("Context:"),t.push(sH(e)||"(none)")),t.push(""),t.push("Entries:");const a=iH();return 0===a.length?t.push("(no offline diagnostics captured)"):a.forEach(e=>{t.push("[".concat(e.timestamp,"] ").concat(e.level.toUpperCase()," ").concat(e.message)),e.details&&t.push(e.details)}),t.join("\n")}function dH(e){return e?"".concat("","/api/public/share/").concat(e,"/audio"):null}const uH="rescript-credit-limit",mH=12e3;function hH(e){const t=Number(e);return Number.isFinite(t)?new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(t):"$0.00"}function pH(e){const t=Number(e);return Number.isFinite(t)?new Intl.NumberFormat(void 0,{minimumFractionDigits:1,maximumFractionDigits:1}).format(t):"0.0"}function gH(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return"0 B";const n=["B","KB","MB","GB","TB"],a=Math.min(Math.floor(Math.log(t)/Math.log(1024)),n.length-1),r=t/1024**a;return"".concat(r.toFixed(r>=100||0===a?0:1)," ").concat(n[a])}function xH(e){return"string"===typeof e&&e.trim().length>0}function fH(e,t){const n=null===e||void 0===e?void 0:e.youtubeUrl,a=null===e||void 0===e?void 0:e.youtube_url,r=null===e||void 0===e?void 0:e.videoUrl,s=null===e||void 0===e?void 0:e.video_url,i=null===e||void 0===e?void 0:e.linkedYoutubeUrl,o=null===t||void 0===t?void 0:t.playbackUrl,l=null===t||void 0===t?void 0:t.playbackSource,c=xH(n)?n:xH(a)?a:null,d=xH(o)?o:xH(r)?r:xH(s)?s:xH(i)?i:null,u=l||(null===e||void 0===e?void 0:e.videoSource)||(null===e||void 0===e?void 0:e.video_source)||(d?"youtube":null);return c?{youtubeUrl:c,url:c,source:"youtube"}:{youtubeUrl:c,url:d,source:u}}function bH(e){return"youtube"===e?"youtube":"audio"}function yH(e){if(!xH(e))return null;const t=[/youtube\.com\/watch\?v=([^&]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/embed\/([^?]+)/];for(const n of t){const t=e.match(n);if(null!==t&&void 0!==t&&t[1])return"https://img.youtube.com/vi/".concat(t[1],"/maxresdefault.jpg")}return null}function vH(e){const t=Xw(),{isPlaying:n,mediaSeekRequestId:a,mediaSeekRequestTime:r,volume:s,playbackRate:i}=Kw();return(0,u.jsx)(AT,d(d({},e),{},{currentTime:t,isPlaying:n,mediaSeekRequestId:a,mediaSeekRequestTime:r,volume:s,playbackRate:i}))}function wH(e){let{currentSessionId:t}=e;const n=Xw();return(0,a.useEffect)(()=>{if(!t||!n||n<1)return;const e=setTimeout(()=>{const e=(e=>{const t=Math.floor(e/60),n=Math.floor(e%60);return"".concat(t,"m").concat(n,"s")})(n),t=window.location.pathname+window.location.search,a=new URL(window.location.href);a.searchParams.set("t",e);const r=a.pathname+a.search;t!==r&&(window.history.replaceState({},"",r),zw("[URL-UPDATE] Time parameter updated:",e))},500);return()=>clearTimeout(e)},[t,n]),null}function kH(){const{sessionId:e}=lc(),t=oc(),n=rc(),[r,s]=(0,a.useState)(null),[i,o]=(0,a.useState)(null),[l,c]=(0,a.useState)(null),[d,m]=(0,a.useState)(null),[h,p]=(0,a.useState)(null),[g,x]=(0,a.useState)(!1),f=new URLSearchParams(n.search),b=f.get("t"),y="0"!==f.get("autoplay"),v=f.get("share"),[w,k]=(0,a.useState)(!!v);(0,a.useEffect)(()=>{zw("[SESSION-PAGE] Share param:",v),v&&j(v)},[v]);const j=async n=>{k(!0),m(null),x(!1);const a=async()=>{const a=n?await EN(n):null;if(a)return e&&a!==e?(t("/session/".concat(a,"?share=").concat(n),{replace:!0}),!0):(o(n),m(null),s(null),p(null),x(!0),!0);return!(!e||!await SN(e))&&(o(n),m(null),s(null),p(null),x(!0),!0)};try{if(!navigator.onLine&&await a())return;const e=await Wu("".concat("","/api/public/share/").concat(n),{cache:"no-store"},mH,"Timed out while loading the shared session");if(e.ok){const t=await e.json();Vm.primePublicShareEmbeddedData(n,t),p(t),s(t.permissions),o(n),x(!1),t.shareLink&&c(t.shareLink)}else 404===e.status?m("Share link not found"):410===e.status?m("This share link is not currently available"):403===e.status?m("This share link has been disabled"):m("Invalid share link"),s(null),p(null)}catch(r){if(console.error("Failed to load share data:",r),await a())return;m("Failed to load share link"),s(null),p(null),x(!1)}finally{k(!1)}};if(zw("[SESSION-PAGE] Render state:",{shareParam:v,isLoadingShare:w,sharePermissions:r,shareError:d,canUseOfflineShareFallback:g}),v){if(w)return(0,u.jsx)("div",{className:"flex items-center justify-center h-screen",children:(0,u.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-[#FFB52B]"})});if(!g&&(d||!r))return(0,u.jsx)("div",{className:"flex items-center justify-center h-screen",children:(0,u.jsxs)("div",{className:"text-center",children:[(0,u.jsx)("h1",{className:"text-2xl font-bold mb-2 text-red-600",children:d||"Invalid share link"}),(0,u.jsx)("p",{className:"text-gray-600",children:"The shared session you're looking for is not available."})]})})}return v&&r?(0,u.jsx)(qp,{permissions:r,shareToken:i||void 0,metadata:l,children:(0,u.jsx)(HF,{sessionId:e||null,token:null,isPublicView:!0,children:(0,u.jsx)(DH,{sessionId:e,navigate:t,timeParam:b,autoplayFromTime:y,isLoadingShare:!1,cachedShareData:h})})}):(0,u.jsx)(qp,{shareToken:v||void 0,metadata:l||void 0,children:(0,u.jsx)(jH,{sessionId:e||null,isPublicView:!!v,children:(0,u.jsx)(DH,{sessionId:e,navigate:t,timeParam:b,autoplayFromTime:y,isLoadingShare:w})})})}function jH(e){let{sessionId:t,isPublicView:n,children:a}=e;const{token:r}=am();return(0,u.jsx)(HF,{sessionId:t,token:r,isPublicView:n,children:a})}function DH(e){var t,n,r,s,i,o,l;let{sessionId:c,navigate:h,timeParam:p,autoplayFromTime:g=!0,isLoadingShare:x=!1,cachedShareData:f=null}=e;const{token:b,user:y,login:v,logout:w}=am(),{isDarkMode:k,toggleDarkMode:j}=zu(),{loadAudio:D,seekTo:C,play:N,isLoading:F,duration:E,setPlayerMode:A,setYouTubeTime:T,setYouTubeDuration:M,setYouTubePlaying:_,getPlaybackSnapshot:B}=Kw(),{setCursorSyncEnabled:I}=wk(),{permissions:P,shareToken:L}=Hp(),R=Ww(),[z,O]=(0,a.useState)(null),[U,V]=(0,a.useState)(!1),[H,q]=(0,a.useState)(!1),[W,Y]=(0,a.useState)("ready"),[G,K]=(0,a.useState)(null),[X,J]=(0,a.useState)(null),[$,Q]=(0,a.useState)(!1),[Z,ee]=(0,a.useState)(null),[te,ne]=(0,a.useState)(""),[ae,re]=(0,a.useState)({showSlug:"mlst",showTitle:"Machine Learning Street Talk"}),[se,ie]=(0,a.useState)({familySlug:"",familyTitle:"",familyVersionNumber:null,seedSessionId:"",seedSessionTitle:""}),[oe,le]=(0,a.useState)(!1),[ce,de]=(0,a.useState)({status:"idle",message:"Ready to transcribe"}),[ue,me]=(0,a.useState)(null),[he,pe]=(0,a.useState)(null),[ge,xe]=(0,a.useState)(null),[fe,be]=(0,a.useState)(new Map),[ye,ve]=(0,a.useState)([]),[we,ke]=(0,a.useState)(""),[je,De]=(0,a.useState)(""),[Ce,Ne]=(0,a.useState)({}),[Fe,Se]=(0,a.useState)([]),[Ee,Ae]=(0,a.useState)(""),[Te,Me]=(0,a.useState)(p||null),[_e,Be]=(0,a.useState)(null);(0,a.useEffect)(()=>{p&&(zw("[SESSION] Time parameter updated:",p),Me(p))}
2,[p]);const[Ie,Pe]=(0,a.useState)(!1),[Le,Re]=(0,a.useState)((()=>{if(c){const e=localStorage.getItem("activeTab_".concat(c));if(e&&["readable","ttml","chat","agent","narrative","description","context","questions"].includes(e))return zw("[TAB-PERSISTENCE] Loading saved tab from localStorage:",e),e}return zw("[TAB-PERSISTENCE] No saved tab found, defaulting to readable"),"readable"})()),ze=(0,a.useRef)(Le),[Oe,Ue]=(0,a.useState)(null),[Ve,He]=(0,a.useState)(!!c&&null),[qe,We]=(0,a.useState)(!1),[Ye,Ge]=(0,a.useState)(!1),[Ke,Xe]=(0,a.useState)(!1),[Je,$e]=(0,a.useState)(null),[Qe,Ze]=(0,a.useState)(null),et=(0,a.useRef)(null),tt=!P||!0===P.hasNarrativeData||!!_e,nt=!(!P||!0!==P.timelineEnabled&&!0!==P.rankingEnabled),at=!P||!0===P.hasContextFiles||Number((null===P||void 0===P?void 0:P.contextFileCount)||0)>0,rt=(0,a.useMemo)(()=>{if(qe)return["readable","description"];if(P){const e=[];return P.transcriptsEnabled&&e.push("readable"),"DISABLED"!==P.chatMode&&e.push("chat"),nt&&tt&&e.push("narrative"),!1!==P.descriptionEnabled&&e.push("description"),!0===P.contextFilesEnabled&&at&&e.push("context"),!0===P.questionsEnabled&&e.push("questions"),e}const e=["ttml","chat","readable","narrative","description","context","questions"];return b&&(e.splice(2,0,"agent"),e.push("cuts")),e},[qe,at,tt,P,nt,b]);(0,a.useEffect)(()=>{if(P&&rt){const[e="readable"]=rt;zw("[TAB-PERSISTENCE] Setting tab for share link:",e),Re(e)}},[rt,P,c]),(0,a.useEffect)(()=>{0!==rt.length&&(rt.includes(Le)||Re(rt[0]))},[Le,rt]),(0,a.useEffect)(()=>{c&&Le&&(zw("[TAB-PERSISTENCE] Saving active tab to localStorage:",Le),localStorage.setItem("activeTab_".concat(c),Le))},[c,Le]),(0,a.useEffect)(()=>{const e=ze.current;"readable"===Le&&"readable"!==e&&I(!1),ze.current=Le},[Le,I]),(0,a.useEffect)(()=>{const e=e=>{const t=e.detail;zw("[TAB-NAV] Navigating to agent tab",t),mt((null===t||void 0===t?void 0:t.agentSessionId)||null),Re("agent")};return window.addEventListener("navigate-to-agent",e),()=>window.removeEventListener("navigate-to-agent",e)},[]);const[st,it]=(0,a.useState)([]),[ot,lt]=(0,a.useState)(null),[ct,dt]=(0,a.useState)(c||null),[ut,mt]=(0,a.useState)(null),[ht,pt]=(0,a.useState)(""),[gt,xt]=(0,a.useState)(!!c),[ft,bt]=(0,a.useState)(null),yt=(0,a.useMemo)(()=>{const e=null===ft||void 0===ft?void 0:ft.selectedTtmlId;if(!e)return null;const t=st.find(t=>t.checksum===e||t.filename===e||t.name===e);return(null===t||void 0===t?void 0:t.checksum)||e||null},[null===ft||void 0===ft?void 0:ft.selectedTtmlId,st]),vt=(0,a.useMemo)(()=>(null===ft||void 0===ft?void 0:ft.selectedTranscriptChecksum)||(null===ft||void 0===ft?void 0:ft.selected_transcript_checksum)||(null===ft||void 0===ft?void 0:ft.transcriptionChecksum)||null,[null===ft||void 0===ft?void 0:ft.selectedTranscriptChecksum,null===ft||void 0===ft?void 0:ft.selected_transcript_checksum,null===ft||void 0===ft?void 0:ft.transcriptionChecksum]),wt=(0,a.useRef)(0),[kt,jt]=(0,a.useState)(""),[Dt,Ct]=(0,a.useState)(!1),[Nt,Ft]=(0,a.useState)(!1),[St,Et]=(0,a.useState)(!1),At=(0,a.useRef)(null),[Tt,Mt]=(0,a.useState)(!1),[_t,Bt]=(0,a.useState)(!1),[It,Pt]=(0,a.useState)([]),Lt=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(const a of t){const e=Number(a);if(Number.isFinite(e)&&e>0)return e}},[Rt,zt]=(0,a.useState)(null),[Ot,Ut]=(0,a.useState)(null),[Vt,Ht]=(0,a.useState)(null),[qt,Wt]=(0,a.useState)(!1),[Yt,Gt]=(0,a.useState)(!1),[Kt,Xt]=(0,a.useState)(384),[Jt,$t]=(0,a.useState)(!1),[Qt,Zt]=(0,a.useState)(()=>{var e,t;if("undefined"===typeof window)return{height:0,topOffset:0,bottomOffset:0};const n=window.visualViewport,a=null!==(e=null===n||void 0===n?void 0:n.height)&&void 0!==e?e:window.innerHeight,r=Math.max(0,null!==(t=null===n||void 0===n?void 0:n.offsetTop)&&void 0!==t?t:0);return{height:a,topOffset:r,bottomOffset:Math.max(0,window.innerHeight-a-r)}}),[en,tn]=(0,a.useState)(null),[nn,an]=(0,a.useState)(null),[rn,sn]=(0,a.useState)(null),[on,ln]=(0,a.useState)(null),[cn,dn]=(0,a.useState)(null),[un,mn]=(0,a.useState)(null),[hn,pn]=(0,a.useState)(!1),gn=!!(G||X||Z);(0,a.useEffect)(()=>
2{if("undefined"===typeof window)return;const e=()=>{var e,t;const n=window.visualViewport,a=null!==(e=null===n||void 0===n?void 0:n.height)&&void 0!==e?e:window.innerHeight,r=Math.max(0,null!==(t=null===n||void 0===n?void 0:n.offsetTop)&&void 0!==t?t:0),s=Math.max(0,window.innerHeight-a-r);Zt({height:a,topOffset:r,bottomOffset:s})};e();const t=window.visualViewport;return window.addEventListener("resize",e),null===t||void 0===t||t.addEventListener("resize",e),null===t||void 0===t||t.addEventListener("scroll",e),()=>{window.removeEventListener("resize",e),null===t||void 0===t||t.removeEventListener("resize",e),null===t||void 0===t||t.removeEventListener("scroll",e)}},[]),(0,a.useEffect)(()=>{if("undefined"===typeof window||!R.isMobile)return;const e=e=>{e.cancelable&&e.preventDefault()},t=e=>{var t;e.cancelable&&(e.touches.length>1?e.preventDefault():(t=e.target)instanceof HTMLElement&&t.closest('input, textarea, select, [contenteditable="true"]')||(e=>{let t=e instanceof HTMLElement?e:null;for(;t;){const e=window.getComputedStyle(t),n=e.overflowY,a=e.overflowX,r=/(auto|scroll|overlay)/.test(n)&&t.scrollHeight>t.clientHeight,s=/(auto|scroll|overlay)/.test(a)&&t.scrollWidth>t.clientWidth;if("true"===t.dataset.allowTouchScroll||r||s)return!0;t=t.parentElement}return!1})(e.target)||e.preventDefault())};return document.addEventListener("gesturestart",e,{passive:!1}),document.addEventListener("gesturechange",e,{passive:!1}),document.addEventListener("gestureend",e,{passive:!1}),document.addEventListener("touchmove",t,{passive:!1,capture:!0}),()=>{document.removeEventListener("gesturestart",e),document.removeEventListener("gesturechange",e),document.removeEventListener("gestureend",e),document.removeEventListener("touchmove",t,!0)}},[R.isMobile]),(0,a.useEffect)(()=>{if(!Te)return;const e=!!Rt;if(e&&(!E||0===E))return void zw("[SESSION] Waiting for video player to report duration...");if(!e&&(F||!E||0===E))return;const t=(e=>{const t=e.match(/(\d+)m(\d+)s/);if(t){return 60*parseInt(t[1],10)+parseInt(t[2],10)}return 0})(Te);if(zw("[SESSION] Media loaded, opening requested time:",{targetTime:t,duration:E,isAudioLoading:F,hasVideo:e,timeParam:Te,autoplayFromTime:g}),t>0&&t<E){setTimeout(async()=>{if(zw("[SESSION] Seeking to time:",t,"seconds (video mode:",e,")"),C(t),g)try{await N(),zw("[SESSION] Autoplay started successfully")}catch(n){zw("[SESSION] Autoplay blocked:",n)}Me(null)},e?500:100)}},[Te,F,E,C,N,Rt,g]);const[xn,fn]=(0,a.useState)(null),[bn,yn]=(0,a.useState)(null),[vn,wn]=(0,a.useState)(null),[kn,jn]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(!c)return void He(!1);let e=!1;return He(null),SN(c).then(t=>{e||He(t)}).catch(t=>{console.warn("[OFFLINE] Failed to check session snapshot:",t),e||He(!1)}),()=>{e=!0}},[c]),(0,a.useEffect)(()=>{const e=ct||c;if(!e)return void Ge(!1);let t=!1;return SN(e).then(e=>{t||Ge(e)}).catch(e=>{console.warn("[OFFLINE] Failed to sync availability state:",e),t||Ge(!1)}),()=>{t=!0}},[ct,c]),(0,a.useEffect)(()=>{L&&ct&&Ye&&AN(L,ct).catch(e=>{console.warn("[OFFLINE] Failed to link share token to offline session:",e)})},[ct,Ye,L]);const Dn=(0,a.useCallback)(()=>{et.current&&(URL.revokeObjectURL(et.current),et.current=null)},[]);(0,a.useEffect)(()=>()=>{Dn()},[Dn]);const Cn=(0,a.useCallback)(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=!0===t.offlineMode,a=n?d(d({},e),{},{audioUrl:t.offlineAudioUrl||null,linkedYoutubeUrl:null,videoUrl:null,videoSource:null}):e;We(n),bt(a),me(a.transcriptionData||null),pe(a.transcriptionData||null),xe(a.transcriptionChecksum||null),Ne(a.speakerLabels||{}),ke(a.finalTranscript||""),De(a.currentTranscript||a.finalTranscript||""),be(new Map(Object.entries(a.speakerSegments||{}).filter(e=>{let[t]=e;return!Number.isNaN(parseInt(t,10))}).map(e=>{let[t,n]=e;return[parseInt(t,10),n]}))),ve(Array.isArray(a.distinctSpeakers)?a.distinctSpeakers:[]),it(a.generatedTtmlFiles||[]),dt(a.sessionId),pt(Vm.generateSessionUrl(a.sessionId)),lt(null),wn(null),jn(null),yn(null),Be(n?null:a._narrativeData||null),fn(null);const r=a.title||a.filename||"Untitled Session";jt(r);const s=n?{youtubeUrl:null,url:null,source:null}:fH(a);if(s.url?(zt(s.url),Ut(s.source),Ht(s.youtubeUrl),Wt(!0),A(bH(s.source))):(zt(null),Ut(null),Ht(s.youtubeUrl),Wt(!1),A("audio")),n)tn(null),an(null),sn(null),ln(null),dn(null),mn(null),pn(!1),ee(null),J(null),le(!1),Ue(null);else if(tn(a.dropboxVideoUrl||null),an(a.videoFilename||null),sn(a.dropboxDrpUrl||null),ln(a.timelineName||null),dn(a.localVideoPath||null),mn(a.productionNotes||null),pn(!!a.publishedToHomepage),a.isYouTubeMode&&a.youtubeUrl)J(a.youtubeUrl),le(!0),K(null),ee(null);else if(a.dropboxVideoUrl)ee({dropboxVideoUrl:a.dropboxVideoUrl,localVideoPath:a.localVideoPath||"",productionNotes:a.productionNotes||"",timelineName:a.timelineName||"",dropboxDrpUrl:a.dropboxDrpUrl||"",videoFilename:a.videoFilename||a.filename,autoPrepareVideoSource:!0}),K(null),le(!1),J(null);else{const e=new File([],a.filename);K({name:a.filename,file:e,size:0}),ee(null),le(!1),J(null)}if(n){const e=new File([],a.filename||r);K({name:a.filename||r,file:e,size:0})}(a.finalTranscript||a.currentTranscript)&&(Y("completed"),de({status:"completed",message:n?"Offline session loaded.":"Session loaded successfully!"})),!a.audioUrl||s.url&&"file"!==s.source||D(a.audioUrl)},[D,A]),Nn=(0,a.useCallback)(async e=>{const t=await FN(e);if(!t)return!1;Dn();const n=t.audioBlob?URL.createObjectURL(t.audioBlob):null;return n&&(et.current=n),Cn(t.sessionData,{offlineAudioUrl:n,offlineMode:!0}),!0},[Cn,Dn]),Fn=(0,a.useCallback)((e,t)=>{const n=B();if(zt(e),Ut(t),Ht("youtube"===t?e:null),e){if(Gt(!1),Wt(!0),A(bH(t)),"file"===t){const e=L?dH(L):null===ft||void 0===ft?void 0:ft.audioUrl;e&&D(e,{startTime:n.currentTime,shouldPlay:n.isPlaying})}}else Wt(!1),A("audio")},[null===ft||void 0===ft?void 0:ft.audioUrl,B,D,A,L]),Sn=(0,a.useCallback)(e=>{Ht(e)},[]),En=Rt,An=Ot,Tn=(0,a.useCallback)(e=>{const t="boolean"===typeof e?e:!qt,n=B(),a=n.currentTime,r=n.isPlaying;if(R.isMobile&&Gt(!1),Wt(t),t){const e=bH(An||null);if(A(e),"audio"===e){const e=L?dH(L):null===ft||void 0===ft?void 0:ft.audioUrl;e&&D(e,{startTime:a,shouldPlay:r})}return}A("audio");const s=L?dH(L):null===ft||void 0===ft?void 0:ft.audioUrl;s&&(zw("[SESSION] Video collapsed - loading MP3 audio:",s),D(s,{startTime:a,shouldPlay:r}))},[null===ft||void 0===ft?void 0:ft.audioUrl,B,qt,D,R.isMobile,A,L]);(0,a.useEffect)(()=>{R.isMobile&&"readable"!==Le&&qt&&Tn(!1)},[Le,qt,R.isMobile,Tn]);const Mn=(0,a.useMemo)(()=>qt&&!!En,[En,qt]),_n=(0,a.useCallback)(()=>{},[]),Bn=(0,a.useCallback)(async()=>
2{if(ct&&b)try{const e=await Vm.getSession(ct,b);bt(e),it(e.generatedTtmlFiles||[]),jt(e.title||e.filename||"Untitled Session"),Ht(e.youtubeUrl||null),tn(e.dropboxVideoUrl||null),an(e.videoFilename||null),sn(e.dropboxDrpUrl||null),ln(e.timelineName||null),dn(e.localVideoPath||null),mn(e.productionNotes||null),pn(!!e.publishedToHomepage);const t=fH(e);zt(t.url),Ut(t.source),Ht(t.youtubeUrl),t.url||(Wt(!1),A("audio"));const n=await Vm.getNarrativeData(ct,L||b);Be(n||null),zw("[SESSION] Session data reloaded after external update")}catch(e){console.error("[SESSION] Failed to reload session data:",e)}},[ct,L,b,A]),In=(0,a.useCallback)((e,t)=>{$e({message:e,tone:t})},[]),Pn=(0,a.useCallback)((e,t)=>{Ze(e),lH("info",e,t)},[]),Ln=(0,a.useCallback)(async()=>{if(!("serviceWorker"in navigator))return!0;const e=await async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;const t=await nH();if(!t)return{ready:!1,controlled:!1,shellCached:!1};t.waiting&&t.waiting.postMessage({type:"SKIP_WAITING"});const n=await new Promise(t=>{const n=window.setTimeout(()=>{t(!1)},e);navigator.serviceWorker.ready.then(()=>{window.clearTimeout(n),t(!0)}).catch(e=>{window.clearTimeout(n),console.warn("[SW] Ready check failed:",e),t(!1)})}),a=!!n&&await tH();return{ready:n,controlled:!!navigator.serviceWorker.controller,shellCached:a}}();return lH("info","Checked offline shell readiness",e),!!e.ready||(lH("info","Service worker is not yet ready for offline navigation"),!1)},[]),Rn=(0,a.useCallback)(async()=>{try{const e=cH({sessionId:ct||null,shareToken:L||null,pending:Ke,offlineAvailable:Ye,offlineMode:qe,sessionTitle:kt||(null===ft||void 0===ft?void 0:ft.title)||null,currentStatus:Qe}),t=await Up(e);In(t?"Offline diagnostics copied to clipboard.":"Failed to copy offline diagnostics.",t?"success":"error")}catch(e){console.error("[OFFLINE] Failed to copy offline diagnostics:",e),In("Failed to copy offline diagnostics.","error")}},[null===ft||void 0===ft?void 0:ft.title,ct,Ke,Ye,qe,Qe,kt,L,In]),zn=(0,a.useCallback)(async()=>{if(ct)try{var e,t,n;if(oH([]),lH("info","Started offline availability update",{sessionId:ct,shareToken:L||null,audioUrl:(null===ft||void 0===ft?void 0:ft.audioUrl)||null,online:navigator.onLine,hadServiceWorkerController:!(null===(e=navigator.serviceWorker)||void 0===e||!e.controller)}),Xe(!0),Ye)return Pn("Removing offline copy",{sessionId:ct}),await async function(e){const t=mN();t[e]&&(delete t[e],hN(t));const n=pN();Object.entries(n).forEach(t=>{let[a,r]=t;r===e&&delete n[a]}),gN(n),await yN(e);try{await DN(e)}catch(a){console.warn("[OFFLINE] Failed to remove IndexedDB offline session:",a)}}(ct),Ge(!1),window.dispatchEvent(new CustomEvent("rescript-offline-sessions-updated")),lH("info","Offline copy removed",{sessionId:ct}),void In("Offline copy removed from this device.","success");if(null===ft||void 0===ft||!ft.audioUrl)throw new Error("This session does not currently expose an audio file for offline playback.");Pn("Requesting audio for offline playback",{audioUrl:ft.audioUrl});const i=await fetch(ft.audioUrl);if(!i.ok)throw new Error("Failed to download the session audio for offline playback.");const o=i.headers.get("Content-Length"),l=o?Number(o):NaN;if(lH("info","Audio response headers received",{status:i.status,contentType:i.headers.get("Content-Type"),contentLength:Number.isFinite(l)?l:null}),Pn(Number.isFinite(l)?"Preparing ".concat(gH(l)," of audio for offline playback"):"Preparing audio for offline playback",{audioBytes:Number.isFinite(l)?l:null}),Number.isFinite(l)&&"storage"in navigator&&"function"===typeof(null===(t=navigator.storage)||void 0===t?void 0:t.estimate))try{var a,r;const e=await navigator.storage.estimate(),t="number"===typeof e.quota&&"number"===typeof e.usage?Math.max(0,e.quota-e.usage):null;if(zw("[OFFLINE] Storage estimate before save:",{audioBytes:l,quota:null!==(a=e.quota)&&void 0!==a?a:null,usage:null!==(r=e.usage)&&void 0!==r?r:null,availableBytes:t}),null!==t&&l>t)throw new Error("This device appears to have only ".concat(gH(t)," free for offline storage, but the audio download is ").concat(gH(l),"."))}catch(s){if(s instanceof Error)throw s;console.warn("[OFFLINE] Failed to estimate browser storage:",s)}const c=Lt(null===ue||void 0===ue||null===(n=ue.metadata)||void 0===n?void 0:n.duration,ft.duration,null===xn||void 0===xn?void 0:xn.videoDurationSeconds)||0,u={sessionId:ct,transcriptionChecksum:ft.transcriptionChecksum||ge||"",filename:ft.filename||(null===G||void 0===G?void 0:G.name)||kt||"Untitled Session",title:kt||ft.title||ft.filename||"Untitled Session",thumbnailUrl:yH(ft.youtubeUrl||ft.youtube_url)||null,isYouTubeMode:!1,youtubeUrl:ft.youtubeUrl||void 0,transcriptionData:ue||ft.transcriptionData||null,speakerLabels:Ce||ft.speakerLabels||{},finalTranscript:we||ft.finalTranscript||"",currentTranscript:je||ft.currentTranscript||we||"",speakerSegments:ft.speakerSegments||Object.fromEntries(fe),distinctSpeakers:ft.distinctSpeakers||ye,generatedTtmlFiles:(st||[]).map(e=>d(d({},e),{},{content:e.content||""})),selectedTtmlId:ft.selectedTtmlId||null,youtubeDescription:ft.youtubeDescription||"",_comments:ft._comments||[],createdAt:ft.createdAt,updatedAt:ft.updatedAt,duration:c};Pn("Saving offline copy to browser storage",{sessionId:ct}),await CN(u,i,{shareToken:L,thumbnailUrl:u.thumbnailUrl,onProgress:(e,t)=>{Pn(e,t)}}),Pn("Verifying offline copy",{sessionId:ct});const[m,h]=await Promise.all([SN(ct),NN()]),p=h.some(e=>e.sessionId===ct);if(!m||!p)throw new Error("Offline save did not verify in local storage. Please try again.");Ge(!0),lH("info","Offline copy verified in local storage",{sessionId:ct,isVisibleInLibrary:p}),window.dispatchEvent(new CustomEvent("rescript-offline-sessions-updated")),Pn("Finalizing offline setup",{sessionId:ct});if(await Ln())return lH("info","Offline setup finished successfully",{sessionId:ct}),void In("Session saved for offline use on this device.","success");In("Offline copy saved, but Safari is still preparing offline page loading in the background.","success")}catch(s){console.error("[OFFLINE] Failed to update offline availability:",s),lH("error","Offline availability update failed",s),In(s instanceof Error?s.message:"Failed to update offline availability.","error")}finally{Xe(!1),Ze(null)}}
2,[ft,ct,je,ye,we,st,Ye,null===xn||void 0===xn?void 0:xn.videoDurationSeconds,null===G||void 0===G?void 0:G.name,kt,L,Ln,In,Pn,Ce,fe,ge,ue]);(0,a.useEffect)(()=>{const e=e=>{const t=e.detail||{};t.sessionId&&t.sessionId!==ct||Bn()};return window.addEventListener("rescript-session-refresh-needed",e),()=>{window.removeEventListener("rescript-session-refresh-needed",e)}},[ct,Bn]),(0,a.useEffect)(()=>{wt.current=0},[ct]),(0,a.useEffect)(()=>{if(!ct||!b||P||gt||(null===ft||void 0===ft?void 0:ft.sessionId)!==ct)return void(wt.current=0);let e=!1,t=!1,n=null;const a=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4e3;e||null!==n||(n=window.setTimeout(()=>{n=null,r()},t))},r=async()=>{if(e||t)return;if("visible"!==document.visibilityState)return void a();const n=wt.current;t=!0;try{const t=await Vm.getInvalidations(ct,n,b);if(e)return;if(t.version!==n&&(wt.current=t.version),0===n)return;if(!t.hasUpdates)return;window.dispatchEvent(new CustomEvent("rescript-session-invalidated",{detail:{sessionId:ct,scopes:t.scopes,version:t.version}})),await Bn()}catch(r){e||console.error("[SESSION] Failed to poll invalidations:",r)}finally{t=!1,a()}},s=()=>{"visible"===document.visibilityState&&a(0)};return a(0),document.addEventListener("visibilitychange",s),()=>{e=!0,null!==n&&window.clearTimeout(n),document.removeEventListener("visibilitychange",s)}},[null===ft||void 0===ft?void 0:ft.sessionId,ct,gt,Bn,P,b]);const On=(0,a.useCallback)(async e=>{zw("[TTML-UPDATE] Starting updateGeneratedTtmlFiles with",e.length,"files"),zw("[TTML-UPDATE] Files details:",e.map(e=>{var t;return{name:e.name,checksum:e.checksum,contentLength:(null===(t=e.content)||void 0===t?void 0:t.length)||0,hasStats:!!e.validationStats}}));const t=st,n=new Map;t.forEach(e=>{e.checksum&&n.set(e.checksum,e)});const a=[...t];for(const s of e)s.checksum&&n.has(s.checksum)?zw("[TTML-UPDATE] Skipping duplicate file with checksum:",s.checksum):a.push(s);if(zw("[TTML-UPDATE] Merged files count:",a.length),it(a),ct&&b)try{zw("[TTML-UPDATE] Updating session",ct,"with",a.length,"TTML files");const e=await Vm.updateSession({sessionId:ct,generatedTtmlFiles:a},b);zw("[TTML-UPDATE] Session update result:",e),zw("[SESSION] Updated session with TTML files")}catch(r){console.error("[SESSION] Failed to update TTML files in session:",r)}else console.warn("[TTML-UPDATE] Cannot update session - missing sessionId or token:",{hasSessionId:!!ct,hasToken:!!b})},[ct,b,st]),Un=(0,a.useCallback)(async e=>{zw("[TTML-REVISION] New revision created:",{checksum:e.checksum.substring(0,8),version:e.version,parentChecksum:e.parentChecksum.substring(0,8)});const t={name:"v".concat(e.version," (manual edit)"),content:e.content||"",checksum:e.checksum,version:e.version,parentChecksum:e.parentChecksum,rootChecksum:e.rootChecksum,generatedAt:e.generatedAt,model:e.model,revisionNotes:e.revisionNotes,editedBy:e.editedBy,editType:"manual",isSelected:!0},n=[...st,t].map(t=>d(d({},t),{},{isSelected:t.checksum===e.checksum}));if(it(n),lt(e.checksum),ct&&b)try{zw("[TTML-REVISION] Updating session with new revision and selecting it"),await Vm.updateSession({sessionId:ct,generatedTtmlFiles:n,selectedTtmlId:e.checksum},b);let t=(null===ft||void 0===ft?void 0:ft.sessionVisuals)||null;try{t=await RS.listSnapshot(ct,b,e.checksum)}catch(a){console.warn("[TTML-REVISION] Failed to refresh session visuals for new TTML revision:",a)}ft&&bt(d(d({},ft),{},{selectedTtmlId:e.checksum,sessionVisuals:t})),zw("[TTML-REVISION] Session updated successfully")}catch(r){console.error("[TTML-REVISION] Failed to update session:",r)}},[ct,b,st,ft]),Vn=(0,a.useCallback)(e=>{bt(t=>t?d(d({},t),{},{sessionVisuals:e}):t)},[]),[Hn,qn]=(0,a.useState)(!0),[Wn,Yn]=(0,a.useState)({model:"nova-3",language:"en-US",smartFormat:!0,diarization:!0,punctuation:!0,utterances:!0,timeInterval:15});(0,a.useEffect)(()=>{(async()=>{if(b)try{await async function(e){let{attempts:t=3,delaysMs:n=Gu,wait:a=Xu}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null;for(let o=0;o<t;o+=1)try{return await e()}catch(i){var s;r=i;const e=null===i||void 0===i?void 0:i.status;if(!("number"!==typeof e||429===e||e>=500)||o===t-1)throw i;await a(null!==(s=n[Math.min(o,n.length-1)])&&void 0!==s?s:1e3)}throw r}(()=>YV.healthAuth(b)),O(!0)}catch(e){O(!1)}finally{V(!0)}else O(!1),V(!0)})()},[b]),(0,a.useEffect)(()=>
2{if(!Jt)return;const e=e=>{e.preventDefault();const t=Math.min(Math.max(e.clientX,280),800);Xt(t)},t=()=>{$t(!1),document.body.style.cursor="",document.body.style.userSelect=""};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",t),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",t),document.body.style.cursor="",document.body.style.userSelect=""}},[Jt]),(0,a.useEffect)(()=>{if(qe)return;if("chat"!==Le)return;if(!z&&!P)return;(async()=>{try{zw("Loading AI models from OpenRouter...");const e=(await Op.getOpenRouterModels(b||void 0)).models.map(e=>e.id);if(zw("AI models loaded:",e.length,"models"),Se(e),e.length>0){const t=Rp.getSelectedModel();t&&e.includes(t)?(zw("Using persisted model:",t),Ae(t)):Ae(e[0])}}catch(e){console.error("Failed to load AI models:",e);const t=Rp.getSelectedModel(),n=t?[t]:[];zw("Using fallback models:",n),Se(n),Ae(n[0]||"")}})()},[Le,z,qe,b,P]),(0,a.useEffect)(()=>{Ee&&Rp.setSelectedModel(Ee)},[Ee]),(0,a.useEffect)(()=>{(async()=>{if(!c)return void xt(!1);if(!P&&!U)return void xt(!0);if(!(!!P||!!z&&!!b)){if(!Ve)return void xt(!1);try{xt(!0);return void(await Nn(c)||xt(!1))}catch(n){return console.error("[SESSION] Failed to load offline snapshot:",n),void xt(!1)}}try{let n;if(zw("[SESSION] Loading session:",c),xt(!0),Dn(),P&&L){var e,t;let a;if(f)zw("[SESSION] Using cached share data (no duplicate API call)"),a=f;else{zw("[SESSION] No cached data, fetching from API");const e=await Wu("".concat("","/api/public/share/").concat(L),{cache:"no-store"},mH,"Timed out while loading the shared session");if(!e.ok)throw new Error("Failed to load shared session");a=await e.json()}n=a.session,zw("[SESSION] Share data received:",{hasTranscriptionData:!!n.transcriptionData,transcriptionDataType:typeof n.transcriptionData,transcriptionDataKeys:n.transcriptionData?Object.keys(n.transcriptionData):[],hasSpeakerLabels:!!n.speakerLabels,permissions:a.permissions});const r=(null===(e=n.transcriptionData)||void 0===e?void 0:e.deepgram)||n.transcriptionData||null,s=Lt(n.duration,null===r||void 0===r||null===(t=r.metadata)||void 0===t?void 0:t.duration);n=d(d({},n),{},{sessionId:n.session_id,title:n.title,filename:n.filename,isYouTubeMode:n.is_youtube_mode,youtubeUrl:n.youtube_url,linkedYoutubeUrl:n.youtube_url||n.video_url,videoUrl:n.youtube_url||n.video_url,videoSource:n.youtube_url?"youtube":n.video_source||null,finalTranscript:n.final_transcript,currentTranscript:n.current_transcript||n.final_transcript,speakerSegments:(()=>{const e=n.speaker_segments;if(!e)return{};if(Array.isArray(e)){const n={};for(const a of e){var t;const e=null!==(t=a.speaker)&&void 0!==t?t:0;n[e]||(n[e]=[]),n[e].push(a)}return n}return e})(),distinctSpeakers:n.distinct_speakers||[],transcriptionData:r,speakerLabels:n.speakerLabels||{},generatedTtmlFiles:(n.generated_ttml_files||[]).map(e=>d(d({},e),{},{content:e.checksum===n.selected_ttml_id||e.id===n.selected_ttml_id||e.isSelected?n._ttmlContent:e.content})),audioUrl:n.s3_original_audio_key?dH(L):null,sessionVisuals:n.sessionVisuals?Sm(n.sessionVisuals):null,selectedTtmlId:n.selected_ttml_id,transcriptionChecksum:n.selectedTranscriptChecksum||n.selected_transcript_checksum||n.transcriptionChecksum||n.transcription_checksum||null,selectedTranscriptChecksum:n.selectedTranscriptChecksum||n.selected_transcript_checksum||null,youtubeDescription:n.youtube_description||"",_narrativeData:n._narrativeData||a.narrative||null,_comments:n._comments||[],_fromCdn:a._fromCdn||!1,duration:s||0}),Be(n._narrativeData||null)}else n=await Vm.getSession(c,b);Cn(n),zw("[SESSION] Session loaded successfully")}catch(n){console.error("[SESSION] Failed to load session:",n);try{if(await Nn(c))return}catch(a){console.error("[SESSION] Offline fallback also failed:",a)}de({status:"error",message:"Failed to load session. The session may not exist or you may not have access."}),setTimeout(()=>{h("/")},3e3)}finally{xt(!1)}})()},[c,z,b,h,P,L,f,U,Ve,Nn,Dn,Cn]);const Gn=(0,a.useCallback)(async e=>{if(b)try{const t=await Vm.getVideoSourceStatus(e,b);bt(e=>{var n,a,r;return e?d(d({},e),{},{videoSourceStatus:t,videoUrl:fH(e,t).url,videoSource:fH(e,t).source,videoFileHash:t.videoMetadata.hash||e.videoFileHash,videoFileSize:null!==(n=t.videoMetadata.fileSize)&&void 0!==n?n:e.videoFileSize,videoFrameRate:null!==(a=t.videoMetadata.frameRate)&&void 0!==a?a:e.videoFrameRate,videoDuration:null!==(r=t.videoMetadata.duration)&&void 0!==r?r:e.videoDuration}):e}),void 0!==t.dropboxVideoUrl&&tn(t.dropboxVideoUrl||null),void 0!==t.localVideoPath&&dn(t.localVideoPath||null);const n=fH(ft,t);if(n.url&&n.source){const e=B();if(zt(n.url),Ut(n.source),Ht(n.youtubeUrl),qt&&(A(bH(n.source)),"file"===n.source)){const t=null===ft||void 0===ft?void 0:ft.audioUrl;t&&D(t,{startTime:e.currentTime,shouldPlay:e.isPlaying})}}else zt(null),Ut(null),Ht(n.youtubeUrl),Wt(!1),A("audio")}catch(t){console.error("[SESSION] Failed to refresh video source status:",t)}},[ft,B,qt,D,A,b]);(0,a.useEffect)(()=>{var e,t,n;if(!!!(ct&&b&&en&&("processing"===(null===ft||void 0===ft||null===(e=ft.videoSourceStatus)||void 0===e||null===(t=e.proxy)||void 0===t?void 0:t.status)||!Rt&&null!==ft&&void 0!==ft&&null!==(n=ft.videoSourceStatus)&&void 0!==n&&n.sourceAvailable))||!ct)return;Gn(ct);const a=window.setInterval(()=>{Gn(ct)},2e4);return()=>window.clearInterval(a)},[null===ft||void 0===ft||null===(t=ft.videoSourceStatus)||void 0===t||null===(n=t.proxy)||void 0===n?void 0:n.status,null===ft||void 0===ft||null===(r=ft.videoSourceStatus)||void 0===r?void 0:r.sourceAvailable,ct,en,Rt,Gn,b]),(0,a.useEffect)(()=>
2{if(!ct||!b)return;const e=function(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if(!e||"string"!==typeof e)return null;try{t=new URL(e,"https://app.rescript.info").searchParams}catch(_H){return null}const a=3e5,r=t.get("X-Amz-Date"),s=Number(t.get("X-Amz-Expires"));if(r&&Number.isFinite(s)&&s>0&&t.get("X-Amz-Signature")){const e=/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/.exec(r);if(!e)return null;const t=Date.UTC(+e[1],+e[2]-1,+e[3],+e[4],+e[5],+e[6]),i=t+1e3*s;return Math.max(n,Math.min(t+800*s,i-a))}const i=t.get("Expires");return i&&/^\d+$/.test(i)&&t.get("Signature")?Math.max(n,1e3*Number(i)-a):null}(Rt);if(null===e)return;const t=window.setTimeout(()=>{Gn(ct)},Math.max(1e3,e-Date.now()));return()=>window.clearTimeout(t)},[ct,Rt,Gn,b]),(0,a.useEffect)(()=>{(async()=>{const e=(null===ft||void 0===ft?void 0:ft.youtubeUrl)||(null===ft||void 0===ft?void 0:ft.youtube_url)||null;if(zw("[RETENTION] useEffect triggered:",{currentSessionId:ct,retentionYoutubeUrl:e,linkedYoutubeUrl:Rt,linkedVideoSource:Ot}),!ct||!e)return zw("[RETENTION] Skipping - no linked YouTube video:",{currentSessionId:!!ct,retentionYoutubeUrl:!!e,linkedVideoSource:Ot}),void fn(null);try{zw("[RETENTION] Loading retention data for YouTube session:",ct);const e=await async function(e,t,n){let a;const r={};let s;n?a="".concat(YA,"/public/share/").concat(n,"/retention"):(a="".concat(YA,"/youtube-analytics/retention/").concat(e),t&&(r.Authorization="Bearer ".concat(t)));try{s=await fetch(a,{headers:r})}catch(o){throw new Error("Network error. Please check your connection and try again.")}if(!s.ok){if(404===s.status)return null;const e=await KA(s);throw new Error(e.error||e.message||"Failed to get retention data")}const i=await KA(s);return n&&null===i.retentionData?null:i}(ct,b||void 0,L||void 0);e?(zw("[RETENTION] Loaded retention data:",e.retentionData.length,"points"),fn(e)):(zw("[RETENTION] No retention data available"),fn(null))}catch(t){console.error("[RETENTION] Failed to load retention data:",t),fn(null)}})()},[null===ft||void 0===ft?void 0:ft.youtubeUrl,null===ft||void 0===ft?void 0:ft.youtube_url,ct,Rt,Ot,b,L]),(0,a.useEffect)(()=>{(async()=>{if(ct)try{zw("[NARRATIVE] Loading narrative data for session:",ct);const e=await Vm.getNarrativeData(ct,L||b||void 0);e?(zw("[NARRATIVE] Loaded narrative data:",e),Be(e)):(zw("[NARRATIVE] No narrative data available for session"),Be(null))}catch(e){console.error("[NARRATIVE] Failed to load narrative data:",e),Be(null)}else Be(null)})()},[ct,null===P||void 0===P?void 0:P.isPublicShare,b,L]),(0,a.useEffect)(()=>{zw("[TITLE-UPDATE] Effect triggered:",{sessionTitle:kt,currentSessionId:ct,hasSharePermissions:!!P});const e=(null===ft||void 0===ft?void 0:ft.customThumbnailUrl)||(null===ft||void 0===ft?void 0:ft.custom_thumbnail_url)||(null===ft||void 0===ft?void 0:ft.resolvedThumbnailUrl)||(null===ft||void 0===ft?void 0:ft.thumbnail_url)||yH((null===ft||void 0===ft?void 0:ft.youtubeUrl)||(null===ft||void 0===ft?void 0:ft.youtube_url)||Vt||Rt)||"https://files.rescript.info/mlst-og-image.png",t="https://files.rescript.info/mlst-og-image.png"===e?"Machine Learning Street Talk ReScript archive":"".concat(kt||"MLST session"," thumbnail");if(kt&&(ct||P)){document.title="".concat(kt," | MLST ReScript"),zw("[TITLE-UPDATE] Set page title to:",kt);const n="".concat(kt,P?" | Public MLST transcript, episode notes, and downloadable PDF edition.":" | MLST ReScript session"),a=P&&L?"https://app.rescript.info/share/".concat(L):window.location.href,r=document.querySelector('meta[name="description"]'),s=document.querySelector('meta[property="og:title"]'),i=document.querySelector('meta[property="og:description"]'),o=document.querySelector('meta[property="og:url"]'),l=document.querySelector('meta[property="og:image"]'),c=document.querySelector('meta[property="og:image:alt"]'),d=document.querySelector('meta[name="twitter:title"]'),u=document.querySelector('meta[name="twitter:description"]'),m=document.querySelector('meta[name="twitter:url"]'),h=document.querySelector('meta[name="twitter:image"]'),p=document.querySelector('meta[name="twitter:image:alt"]'),g=document.querySelector('link[rel="canonical"]');r&&r.setAttribute("content",n),s&&s.setAttribute("content","".concat(kt," | MLST ReScript")),i&&i.setAttribute("content",n),o&&o.setAttribute("content",a),l&&l.setAttribute("content",e),c&&c.setAttribute("content",t),d&&d.setAttribute("content","".concat(kt," | MLST ReScript")),u&&u.setAttribute("content",n),m&&m.setAttribute("content",a),h&&h.setAttribute("content",e),p&&p.setAttribute("content",t),g&&g.setAttribute("href",a)}else{document.title="Machine Learning Street Talk | ReScript Editorial Transcript Archive",zw("[TITLE-UPDATE] Set page title to default: Machine Learning Street Talk | ReScript Editorial Transcript Archive");const e="Machine Learning Street Talk ReScript is the editorial transcript archive for long-form AI conversations: searchable transcripts, episode notes, and downloadable PDF editions.",t=document.querySelector('meta[name="description"]'),n=document.querySelector('meta[property="og:title"]'),a=document.querySelector('meta[property="og:description"]'),r=document.querySelector('meta[property="og:url"]'),s=document.querySelector('meta[property="og:image"]'),i=document.querySelector('meta[property="og:image:alt"]'),o=document.querySelector('meta[name="twitter:title"]'),l=d
2ocument.querySelector('meta[name="twitter:description"]'),c=document.querySelector('meta[name="twitter:url"]'),d=document.querySelector('meta[name="twitter:image"]'),u=document.querySelector('meta[name="twitter:image:alt"]'),m=document.querySelector('link[rel="canonical"]');t&&t.setAttribute("content",e),n&&n.setAttribute("content","Machine Learning Street Talk | ReScript Archive"),a&&a.setAttribute("content","Search, read, and export Machine Learning Street Talk interviews through the MLST editorial transcript archive."),r&&r.setAttribute("content","https://app.rescript.info"),s&&s.setAttribute("content","https://files.rescript.info/mlst-og-image.png"),i&&i.setAttribute("content","Machine Learning Street Talk ReScript archive"),o&&o.setAttribute("content","Machine Learning Street Talk | ReScript Archive"),l&&l.setAttribute("content","An editorial transcript archive for MLST podcast episodes, with searchable transcripts and downloadable PDFs."),c&&c.setAttribute("content","https://app.rescript.info"),d&&d.setAttribute("content","https://files.rescript.info/mlst-og-image.png"),u&&u.setAttribute("content","Machine Learning Street Talk ReScript archive"),m&&m.setAttribute("href","https://app.rescript.info")}},[kt,ct,P,L,null===ft||void 0===ft?void 0:ft.youtubeUrl,null===ft||void 0===ft?void 0:ft.youtube_url,Vt,Rt]),(0,a.useEffect)(()=>{const e=()=>{Mt(!(!ct||"completed"!==W&&"labeling"!==W)&&window.scrollY>400)};return window.addEventListener("scroll",e),()=>window.removeEventListener("scroll",e)},[ct,W]);const Kn=(0,a.useCallback)(e=>(null===Z||void 0===Z?void 0:Z.videoFilename)||(null===G||void 0===G?void 0:G.name)||(null===e||void 0===e?void 0:e._videoTitle)||(null===ue||void 0===ue?void 0:ue._videoTitle)||"Transcript Session",[null===Z||void 0===Z?void 0:Z.videoFilename,null===G||void 0===G?void 0:G.name,ue]),Xn=(0,a.useCallback)(e=>{var t;return{transcriptionChecksum:e.checksum,filename:Kn(e.result),isYouTubeMode:oe,youtubeUrl:X||void 0,transcriptionData:e.result,speakerLabels:e.speakerLabels,finalTranscript:e.finalTranscript,currentTranscript:e.currentTranscript,speakerSegments:e.speakerSegmentsPayload,distinctSpeakers:e.distinctSpeakersPayload,dropboxVideoUrl:(null===Z||void 0===Z?void 0:Z.dropboxVideoUrl)||void 0,videoFilename:(null===Z||void 0===Z?void 0:Z.videoFilename)||void 0,dropboxDrpUrl:(null===Z||void 0===Z?void 0:Z.dropboxDrpUrl)||void 0,timelineName:(null===Z||void 0===Z?void 0:Z.timelineName)||void 0,localVideoPath:(null===Z||void 0===Z?void 0:Z.localVideoPath)||void 0,productionNotes:(null===Z||void 0===Z?void 0:Z.productionNotes)||void 0,videoSourceInfo:(null===(t=e.result)||void 0===t?void 0:t._videoSourceInfo)||void 0,autoPrepareVideoSource:!1!==(null===Z||void 0===Z?void 0:Z.autoPrepareVideoSource),projectId:te,showSlug:ae.showSlug.trim(),showTitle:ae.showTitle.trim(),familySlug:se.familySlug.trim()||void 0,familyTitle:se.familyTitle.trim()||void 0,familyVersionNumber:se.familySlug.trim()?se.familyVersionNumber:void 0}},[Kn,oe,se.familySlug,se.familyTitle,se.familyVersionNumber,te,ae.showSlug,ae.showTitle,Z,X]),Jn=(0,a.useCallback)(async()=>{const e=se.familySlug.trim();if(b&&se.seedSessionId.trim()&&e)try{await Vm.updateSession({sessionId:se.seedSessionId.trim(),familySlug:e,familyTitle:se.familyTitle.trim()||void 0,familyVersionNumber:1},b)}catch(t){console.error("[SESSION] Failed to promote seed episode into family:",t)}},[se.familySlug,se.familyTitle,se.seedSessionId,b]),$n=(0,a.useCallback)(async()=>{if(ge&&we&&b)try{if(ct)await Vm.updateSession({sessionId:ct,transcriptionData:ue,speakerLabels:Ce,finalTranscript:we,currentTranscript:je,generatedTtmlFiles:st},b),zw("[SESSION] Updated session:",ct);else{zw("[SESSION] Creating new session...");const e=await Vm.createSession(Xn({checksum:ge,result:ue,speakerLabels:Ce,finalTranscript:we,currentTranscript:je,speakerSegmentsPayload:Object.fromEntries(fe),distinctSpeakersPayload:ye}),b);e.isExisting||await Jn(),dt(e.sessionId);const t=Vm.generateSessionUrl(e.sessionId);pt(t),h?(h("/session/".concat(e.sessionId),{replace:!0}),zw("[SESSION] URL updated to:","/session/".concat(e.sessionId))):console.warn("[SESSION] Navigate function not available"),zw("[SESSION] Created new session:",e.sessionId)}}catch(e){console.error("[SESSION] Failed to create/update session:",e)}else zw("[SESSION] Missing requirements for session creation:",{hasChecksum:!!ge,hasTranscript:!!we,hasToken:!!b})}
2,[ge,we,b,ct,ue,Ce,je,fe,ye,st,h,Xn,Jn]),Qn=(0,a.useCallback)(e=>{K(e),J(null),ee(null),le(!1),me(null),be(new Map),ve([]),ke(""),De(""),Ne({}),de({status:"idle",message:'File selected. Click "Start Transcription" to begin.'})},[]),Zn=(0,a.useCallback)((e,t)=>{J(e),K(null),ee(null),le(!0),t&&(window.__youtubeCookies=t),me(null),be(new Map),ve([]),ke(""),De(""),Ne({}),de({status:"idle",message:'YouTube URL selected. Click "Start Transcription" to begin.'})},[]),ea=(0,a.useCallback)(e=>{ee(e),K(null),J(null),le(!1),tn(e.dropboxVideoUrl),an(e.videoFilename||null),sn(e.dropboxDrpUrl),ln(e.timelineName),dn(e.localVideoPath),mn(e.productionNotes||null),me(null),be(new Map),ve([]),ke(""),De(""),Ne({}),de({status:"idle",message:'Dropbox video selected. Click "Start Transcription" to begin.'})},[]),ta=(0,a.useCallback)(async e=>{if(ue){if(Ne(e),ge&&b)try{await YV.saveSpeakerLabels(ge,e,b),zw("[CACHE] Speaker labels saved to cache.")}catch(t){console.error("Failed to save speaker labels to cache:",t)}try{const n=GV.generateFormattedTranscript(ue,e,Wn.timeInterval);if(zw("Generated transcript preview:",n.substring(0,200)),zw("Transcript type:",typeof n),zw("Transcript length:",n.length),ke(n),De(n),Y("completed"),de({status:"completed",message:"Transcript generated successfully!"}),ge&&b)try{zw("[SESSION] Creating session with transcript length:",n.length);const t=await Vm.createSession(Xn({checksum:ge,result:ue,speakerLabels:e,finalTranscript:n,currentTranscript:n,speakerSegmentsPayload:Object.fromEntries(fe),distinctSpeakersPayload:ye}),b);t.isExisting||await Jn(),dt(t.sessionId);const a=Vm.generateSessionUrl(t.sessionId);pt(a),h&&(h("/session/".concat(t.sessionId),{replace:!0}),zw("[SESSION] URL updated to:","/session/".concat(t.sessionId))),t.isExisting?(zw("[SESSION] Redirected to existing session:",t.sessionId),zw("[SESSION] Message:",t.message)):zw("[SESSION] Created new session:",t.sessionId)}catch(t){console.error("[SESSION] Failed to create session:",t)}}catch(t){console.error("Failed to generate transcript:",t),de({status:"error",message:"Failed to generate final transcript. Please try again."})}}},[ue,Wn.timeInterval,ge,b,$n,fe,ye,Xn,h,Jn]),na=e=>{De(e)},aa=()=>{De(we)},ra=(0,a.useCallback)(async e=>{if(!ct||!b||!ue)throw new Error("Missing required data to update speaker labels");zw("[SPEAKERS] Updating speaker labels:",e);const t=GV.generateFormattedTranscript(ue,e,Wn.timeInterval);Ne(e),ke(t),De(t),await Vm.updateSession({sessionId:ct,speakerLabels:e,finalTranscript:t,currentTranscript:t},b),zw("[SPEAKERS] Speaker labels updated successfully")},[ct,b,ue,Wn.timeInterval]),sa=je||we;(0,a.useEffect)(()=>{pe(ue)},[ct,ue]),(0,a.useEffect)(()=>{At.current=null},[ct]),(0,a.useEffect)(()=>{(kt||"").trim()&&(At.current=null)},[kt]);const ia=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{navigateToAgent:t=!0,automatic:n=!1}=e;if(ct&&b&&sa&&(!n||At.current!==ct)){Et(!0);try{const e=await Jh({sessionId:ct},b);At.current=ct,t&&window.dispatchEvent(new CustomEvent("navigate-to-agent",{detail:{agentSessionId:e.agentSessionId}}))}catch(a){console.error("Failed to generate title:",a),n&&(At.current=null)}finally{Et(!1)}}},oa=async e=>{if(ct&&b){Ft(!0);try{await Vm.updateTitle(ct,e,b),jt(e),Ct(!1)}catch(t){console.error("Failed to save title:",t)}finally{Ft(!1)}}};(0,a.useEffect)(()=>{ct&&"completed"===W&&sa&&!kt.trim()&&ia({navigateToAgent:!1,automatic:!0})},[ct,W,sa,kt]);const la=null!==P,ca=!!c&&!0===Ve,da=Lt(null===ue||void 0===ue||null===(s=ue.metadata)||void 0===s?void 0:s.duration,null===ft||void 0===ft?void 0:ft.duration,null===xn||void 0===xn?void 0:xn.videoDurationSeconds);return la||U&&null!==Ve?z||la||x||ca?H?(0,u.jsx)(cj,{email:(null===y||void 0===y?void 0:y.email)||"your email"}):(0,u.jsxs)("div",{className:"app-shell relative flex flex-col overflow-hidden bg-[#EEF1F3] text-[#232E3F] transition-colors dark:bg-[#111826] dark:text-[#F4F4F4]",style:{position:"fixed",top:0,left:0,right:0,width:"calc(100% / var(--app-ui-shell-scale, 1))",height:Qt.height>0?"calc(".concat(Qt.height,"px / var(--app-ui-shell-scale, 1))"):"calc(100dvh / var(--app-ui-shell-scale, 1))",maxHeight:Qt.height>0?"calc(".concat(Qt.height,"px / var(--app-ui-shell-scale, 1))"):"calc(100dvh / var(--app-ui-shell-scale, 1))",boxSizing:"border-box",overscrollBehavior:"none",paddingTop:"var(--app-mobile-top-offset)",paddingBottom:"var(--app-mobile-bottom-offset)","--app-mobile-top-offset":"calc(env(safe-area-inset-top, 0px) + ".concat(Qt.topOffset,"px)"),"--app-mobile-bottom-offset":"calc(env(safe-area-inset-bottom, 0px) + ".concat(Qt.bottomOffset,"px)")},children:[(0,u.jsx)("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[1] bg-[#232E3F] dark:bg-[#111826]",style:{height:"var(--app-mobile-top-offset)"}}),(0,u.jsxs)("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[(0,u.jsx)("div",{className:"absolute -left-20 -top-24 h-72 w-72 rounded-full bg-[#FFB52B]/[0.18] blur-3xl dark:bg-[#FFB52B]/10"}),(0,u.jsx)("div",{className:"absolute right-[-8rem] top-10 h-[24rem] w-[24rem] rounded-full bg-[#232E3F]/[0.12] blur-3xl dark:bg-[#314158]/40"}),(0,u.jsx)("div",{className:"absolute inset-0 bg-[linear-gradient(180deg,rgba(255,255,255,0.78),rgba(244,244,244,0.94))] dark:bg-[linear-gradient(180deg,rgba(9,14,22,0.72),rgba(17,24,38,0.96))]"}),(0,u.jsx)("div",{className:"absolute inset-0 opacity-[0.05] dark:opacity-[0.08]",style:{backgroundImage:"linear-gradient(rgba(35,46,63,0.16) 1px, transparent 1px), linear-gradient(90deg, rgba(35,46,63,0.12) 1px, transparent 1px)",backgroundSize:"34px 34px"}})]}),(0,u.jsxs)("div",{className:"relative z-10 flex h-full flex-col overflow-hidden",children:[(0,u.jsx)(S,{children:Tt&&(0,u.jsx)(Do.div,{initial:{opacity:0,y:-50}
2,animate:{opacity:1,y:0},exit:{opacity:0,y:-50},transition:{duration:.2},className:"fixed left-0 right-0 top-0 z-50 border-b backdrop-blur-xl ".concat(k?"border-[#FFB52B]/20 bg-[#232E3F]/[0.92] text-[#F4F4F4] shadow-[0_24px_48px_-28px_rgba(10,14,20,0.72)]":"border-[#D6DCE4] bg-[linear-gradient(180deg,rgba(255,255,255,0.95),rgba(244,244,244,0.97))] text-[#232E3F] shadow-[0_20px_40px_-30px_rgba(35,46,63,0.24)]"),style:{top:"var(--app-mobile-top-offset)"},children:(0,u.jsx)("div",{className:"max-w-4xl mx-auto px-4 py-3",children:(0,u.jsxs)("div",{className:"flex items-center justify-between",children:[(0,u.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,u.jsx)("div",{className:"rounded-2xl border border-[#FFB52B]/25 bg-[#FFB52B]/[0.12] p-2 shadow-[0_16px_30px_-24px_rgba(255,181,43,0.95)]",children:(0,u.jsx)(_o,{size:20,className:"text-brand-yellow"})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"font-headlines text-[10px] font-semibold uppercase tracking-[0.28em] ".concat(k?"text-[#FFB52B]/80":"text-[#A36A00]"),children:"Active Session"}),(0,u.jsx)("h2",{className:"max-w-96 truncate font-headlines text-lg font-bold ".concat(k?"text-[#F4F4F4]":"text-[#232E3F]"),children:kt||"Untitled Session"}),(0,u.jsxs)("p",{className:"font-body text-xs ".concat(k?"text-[#D5D9E0]":"text-[#5B687C]"),children:[(null===G||void 0===G?void 0:G.name)||(null===ue||void 0===ue?void 0:ue._videoTitle)||"Session"," \u2022",null===ct||void 0===ct?void 0:ct.substring(0,8),"..."]})]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,u.jsx)("button",{onClick:()=>window.scrollTo({top:0,behavior:"smooth"}),className:"rounded-full border p-2 transition-colors ".concat(k?"border-white/10 bg-white/[0.05] text-white/80 hover:border-[#FFB52B]/40 hover:bg-[#FFB52B] hover:text-[#232E3F]":"border-[#D6DCE4] bg-white/[0.92] text-[#4A586E] hover:border-[#FFB52B]/45 hover:bg-[#FFB52B] hover:text-[#232E3F]"),title:"Scroll to top",children:(0,u.jsx)(Bo,{size:16})}),(0,u.jsx)("button",{onClick:()=>
2h("/"),className:"rounded-full border p-2 transition-colors ".concat(k?"border-white/10 bg-white/[0.05] text-white/80 hover:border-[#FFB52B]/40 hover:bg-[#FFB52B] hover:text-[#232E3F]":"border-[#D6DCE4] bg-white/[0.92] text-[#4A586E] hover:border-[#FFB52B]/45 hover:bg-[#FFB52B] hover:text-[#232E3F]"),title:"Return to Home",children:(0,u.jsx)(Io,{size:16})})]})]})})})}),!_t&&(0,u.jsx)(sT,{isDarkMode:k,toggleDarkMode:j,userName:null===y||void 0===y?void 0:y.name,userEmail:null===y||void 0===y?void 0:y.email,userPicture:null===y||void 0===y?void 0:y.picture,onLogout:()=>{w()},onHome:()=>h("/"),onToggleUpload:c?void 0:()=>Q(e=>!e),uploadVisible:$,sessionId:ct,sessionTitle:kt,sessionShowSlug:(null===ft||void 0===ft?void 0:ft.showSlug)||null,sessionShowTitle:(null===ft||void 0===ft?void 0:ft.showTitle)||null,sessionFamily:(null===ft||void 0===ft?void 0:ft.family)||null,token:b||void 0,onTitleUpdate:e=>jt(e),onSessionRefresh:Bn,activeTabId:Le,onTabChange:Re,availableTabIds:rt,selectedTtmlName:null!==ft&&void 0!==ft&&ft.selectedTtmlId?null===(i=st.find(e=>(e.filename||e.name)===ft.selectedTtmlId))||void 0===i?void 0:i.name:void 0,youtubeUrl:Vt,onYoutubeUrlChange:Sn,videoUrl:Rt,videoSource:Ot,onVideoUrlChange:Fn,onRefreshVideoSource:()=>ct?Gn(ct):void 0,onToggleYoutubePlayer:()=>Tn(),isYoutubePlayerVisible:qt,videoStats:null===xn||void 0===xn?void 0:xn.videoStats,videoDurationSeconds:null===xn||void 0===xn?void 0:xn.videoDurationSeconds,fetchedAt:null===xn||void 0===xn?void 0:xn.fetchedAt,onRetentionDataUpdate:e=>fn(e),speakerIds:ye,speakerSegments:fe,speakerLabels:Ce,onSaveSpeakerLabels:ra,transcriptionChecksum:ge||(null===ft||void 0===ft?void 0:ft.transcriptionChecksum),hesitationTranscriptChecksum:(null===ft||void 0===ft?void 0:ft.hesitationTranscriptChecksum)||null,isYouTubeMode:oe||(null===ft||void 0===ft?void 0:ft.isYouTubeMode),youtubeTitle:null===ft||void 0===ft?void 0:ft.youtubeTitle,youtubeTitleUpdatedAt:null===ft||void 0===ft?void 0:ft.youtubeTitleUpdatedAt,youtubeTitleSync:null===ft||void 0===ft?void 0:ft.youtubeTitleSync,dropboxVideoUrl:en,videoFilename:nn,dropboxDrpUrl:rn,timelineName:on,localVideoPath:cn,productionNotes:un,videoFileHash:null===ft||void 0===ft?void 0:ft.videoFileHash,videoFileSize:null===ft||void 0===ft?void 0:ft.videoFileSize,videoFrameRate:null===ft||void 0===ft?void 0:ft.videoFrameRate,videoDuration:null===ft||void 0===ft?void 0:ft.videoDuration,audioDuration:null!==da&&void 0!==da?da:null===ft||void 0===ft?void 0:ft.duration,videoSourceStatus:null===ft||void 0===ft?void 0:ft.videoSourceStatus,customThumbnailUrl:null===ft||void 0===ft?void 0:ft.customThumbnailUrl,customThumbnailTimeSeconds:null===ft||void 0===ft?void 0:ft.customThumbnailTimeSeconds,publishedToHomepage:hn,onPublishChange:e=>pn(e),isOfflineAvailable:Ye,isOfflineMode:qe,isOfflineActionPending:Ke,offlineActionStatusLabel:Qe||void 0,onToggleOfflineAvailability:ct&&(L||Ye||qe)?zn:void 0,onCopyOfflineDiagnostics:ct?Rn:void 0,onNavigateToFamilyMember:e=>{h("/session/".concat(e))},onProductionMetadataUpdate:e=>{void 0!==e.dropboxVideoUrl&&tn(e.dropboxVideoUrl),void 0!==e.videoFilename&&an(e.videoFilename),void 0!==e.dropboxDrpUrl&&sn(e.dropboxDrpUrl),void 0!==e.timelineName&&ln(e.timelineName),void 0!==e.localVideoPath&&dn(e.localVideoPath),void 0!==e.productionNotes&&mn(e.productionNotes)},onVideoSourceStatusUpdate:e=>{const t=fH(ft,e);bt(t=>{var n,a,r;return t?d(d({},t),{},{videoSourceStatus:e,videoUrl:fH(t,e).url,videoSource:fH(t,e).source,videoFileHash:e.videoMetadata.hash||t.videoFileHash,videoFileSize:null!==(n=e.videoMetadata.fileSize)&&void 0!==n?n:t.videoFileSize,videoFrameRate:null!==(a=e.videoMetadata.frameRate)&&void 0!==a?a:t.videoFrameRate,videoDuration:null!==(r=e.videoMetadata.duration)&&void 0!==r?r:t.videoDuration}):t}),t.url&&t.source?(zt(t.url),Ut(t.source),Ht(t.youtubeUrl),qt&&A(bH(t.source))):(zt(null),Ut(null),Ht(t.youtubeUrl),Wt(!1),A("audio"))}}),(0,u.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:["completed"===W&&gn&&we?(0,u.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:(0,u.jsxs)("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[Mn&&En&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{"data-session-video-panel":"true",className:"relative flex-shrink-0 w-full md:w-auto",style:{width:"undefined"!==typeof window&&window.innerWidth>=768?Yt?0:Kt:"100%"},children:(0,u.jsx)(vH,{videoUrl:En,videoSource:An||"youtube",useExternalAudioSync:"file"===An,sessionId:ct,sessionVisuals:(null===ft||void 0===ft?void 0:ft.sessionVisuals)||null,selectedTtmlChecksum:yt,selectedTranscriptChecksum:vt,totalDuration:E,token:b||void 0,speakerSegments:fe,speakerLabels:Ce,isVisible:qt,onClose:()=>Tn(!1),onTimeUpdate:"file"===An?_n:T,onDurationChange:"file"===An?()=>{}:M,onPlayStateChange:"file"===An?_n:_,onReady:()=>
2A(bH(An||null)),isDarkMode:k,isMinimized:!1,onFloatingChange:R.isMobile?void 0:Gt,isMobile:R.isMobile,mobileTopicTitle:R.isMobile&&"readable"===Le?Oe:null})}),!Yt&&(0,u.jsx)("div",{className:"group hidden w-1.5 flex-shrink-0 cursor-col-resize items-center justify-center transition-colors hover:bg-[#FFB52B]/[0.18] md:flex ".concat(Jt?"bg-[#FFB52B]/26":""),onMouseDown:e=>{e.preventDefault(),$t(!0)},children:(0,u.jsx)("div",{className:"h-8 w-0.5 rounded-full transition-colors ".concat(k?"bg-[#556176] group-hover:bg-[#FFB52B]":"bg-[#9AA6B7] group-hover:bg-[#FFB52B]"," ").concat(Jt?"bg-[#FFB52B]":"")})})]}),!Mn&&En&&(0,u.jsx)(u.Fragment,{children:(0,u.jsx)("div",{className:"hidden w-14 flex-shrink-0 border-r md:flex ".concat(k?"border-[#39465A] bg-[#182130]/[0.92]":"border-[#D4DAE2] bg-[#F8F8F7]/[0.92]"),children:(0,u.jsxs)("button",{type:"button",onClick:()=>Tn(!0),className:"flex h-full w-full flex-col items-center justify-center gap-4 transition-colors ".concat(k?"text-[#D8DDE5] hover:bg-[#232E3F]":"text-[#4A586E] hover:bg-[#FFFFFF]"),title:"Open video panel",children:["youtube"===An?(0,u.jsx)(Au,{className:"h-5 w-5 text-red-500"}):(0,u.jsx)(gA,{className:"h-5 w-5"}),(0,u.jsx)("span",{className:"rotate-180 font-headlines text-[10px] font-semibold uppercase tracking-[0.22em]",style:{writingMode:"vertical-rl"},children:"Video"})]})})}),(0,u.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden",children:(0,u.jsx)(iT,{isDarkMode:k,activeTab:Le,onTabChange:Re,hideNavigation:_t,tabs:((e,t,n)=>{const a=[{id:"ttml",title:"Ranking and Metadata",icon:(0,u.jsx)(YE,{size:18}),component:vy,props:{transcript:sa,filename:(null===G||void 0===G?void 0:G.name)||(null===ue||void 0===ue?void 0:ue._videoTitle)||"YouTube Video",transcriptionData:ue||void 0,transcriptionChecksum:ge||void 0,sessionId:ct||void 0,currentSessionData:ft,onTtmlGenerated:On,speakerLabels:Ce,audioFile:(null===G||void 0===G?void 0:G.file)||void 0,onTtmlPreview:e=>{lt(e)},onTtmlSelected:e=>{ft&&bt(d(d({},ft),{},{selectedTtmlId:e}))}}},{id:"chat",title:"Chat with Transcript",icon:(0,u.jsx)(Fp,{size:18}),component:Pk,props:{transcript:sa,model:Ee,onModelChange:Ae,supportedModels:Fe,currentTtmlFiles:(()=>{if(null!==ft&&void 0!==ft&&ft.selectedTtmlId){return st.filter(e=>e.checksum===ft.selectedTtmlId||e.filename===ft.selectedTtmlId||e.name===ft.selectedTtmlId)}return st.length>0?[st[0]]:[]})(),sessionId:ct,transcriptionData:ue,transcriptionChecksum:ge||void 0,speakerLabels:Ce,shareToken:L||void 0,isPublicView:!!L,narrativeData:_e,youtubeRetentionData:(zw("[TAB-CONFIG] Setting youtubeRetentionData in ChatInterface props:",xn?{videoId:xn.videoId,hasStats:!!xn.videoStats}:null),xn)}},{id:"agent",title:"Agent",icon:(0,u.jsx)(Po,{size:18}),component:qk,props:{sessionId:ct,isPublicView:!!L,shareToken:L||void 0,token:b||void 0,preferredSessionId:ut,onPreferredSessionHandled:()=>mt(null)}},{id:"readable",title:"Transcript",icon:(0,u.jsx)(Ap,{size:18}),component:xO,props:{ttmlFiles:st,sessionId:ct,transcriptionChecksum:ge||void 0,selectedTranscriptChecksum:vt||void 0,hesitationTranscriptChecksum:(null===ft||void 0===ft?void 0:ft.hesitationTranscriptChecksum)||void 0,transcript:sa,filename:(null===G||void 0===G?void 0:G.name)||(null===ue||void 0===ue?void 0:ue._videoTitle)||"YouTube Video",transcriptionData:ue||void 0,speakerLabels:Ce,speakerSegments:fe,sessionVisuals:(null===ft||void 0===ft?void 0:ft.sessionVisuals)||null,duration:da,youtubeUrl:qe?null:Vt,speakerCount:ye.length,comments:(null===ft||void 0===ft?void 0:ft._comments)||[],onTranscriptChange:na,onRestoreOriginal:aa,selectedTtmlId:ot||(null===ft||void 0===ft?void 0:ft.selectedTtmlId),onFullscreenChange:Bt,onSearchMatchesChange:Pt,onActiveTranscriptionDataChange:e=>{pe(e||ue)},onCurrentTopicChange:Ue,onTtmlRevisionCreated:Un,showVideoPanel:!qe&&Mn,gapAnalysisData:bn,onFilteredGapClustersChange:(e,t)=>
2{wn(e),jn(t||null)}}},{id:"narrative",title:"Topics Map",icon:(0,u.jsx)(DU,{size:18}),component:vO,props:{sessionId:ct||"",transcript:sa,ttml:null!==ft&&void 0!==ft&&ft.selectedTtmlId&&st.length>0&&(null===(e=st.find(e=>e.checksum===ft.selectedTtmlId||e.filename===ft.selectedTtmlId||e.name===ft.selectedTtmlId))||void 0===e?void 0:e.content)||"",maxDuration:((null===ue||void 0===ue||null===(t=ue.metadata)||void 0===t?void 0:t.duration)||0)/60,title:"Narrative Timeline",shareToken:L||void 0,youtubeUrl:Rt}},{id:"description",title:"Description",icon:(0,u.jsx)(hA,{size:18}),component:FO,props:{sessionId:ct||"",youtubeDescription:(null===ft||void 0===ft?void 0:ft.youtubeDescription)||"",ttmlContent:null!==ft&&void 0!==ft&&ft.selectedTtmlId&&st.length>0&&(null===(n=st.find(e=>e.checksum===ft.selectedTtmlId||e.filename===ft.selectedTtmlId||e.name===ft.selectedTtmlId))||void 0===n?void 0:n.content)||"",sessionTitle:kt,linkedYoutubeUrl:qe?null:Rt,sessionVisuals:(null===ft||void 0===ft?void 0:ft.sessionVisuals)||null,transcript:we||je||"",onDescriptionChange:e=>{ft&&bt(d(d({},ft),{},{youtubeDescription:e}))},onSeek:C,forceReadOnly:qe}},{id:"context",title:"Context",icon:(0,u.jsx)(NA,{size:18}),component:qO,props:{sessionId:ct||"",isPublicView:!!P,shareToken:L,sharePermissions:P,isDarkMode:k}},{id:"questions",title:"Questions",icon:(0,u.jsx)("span",{className:"flex h-[18px] w-[18px] items-center justify-center rounded-full border border-current text-[10px] font-bold leading-none",children:"Q"}),component:QO,props:{sessionId:ct||"",isDarkMode:k,onSeek:C}},{id:"cuts",title:"Cuts",icon:(0,u.jsx)(ck,{size:18}),component:qV,props:{}}];return qe?a.filter(e=>"readable"===e.id||"description"===e.id):P?a.filter(e=>{switch(e.id){case"ttml":case"agent":default:return!1;case"chat":return"DISABLED"!==P.chatMode;case"readable":return P.transcriptsEnabled;case"narrative":return nt&&tt;case"description":return!1!==P.descriptionEnabled;case"context":return!0===P.contextFilesEnabled&&at;case"questions":return!0===P.questionsEnabled}}):b?a.filter(e=>"chat"!==e.id):a.filter(e=>"agent"!==e.id&&"chat"!==e.id)})()})})]})}):(0,u.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,u.jsxs)("div",{className:"mx-auto max-w-5xl px-4 pb-20",children:[("completed"===W||"labeling"===W)&&ct&&(0,u.jsx)(Do.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"mt-6 space-y-3",children:(0,u.jsx)("div",{className:"rounded-[28px] border border-[#D6DCE4] bg-[#F8F8F7]/[0.92] p-6 shadow-[0_28px_60px_-36px_rgba(35,46,63,0.42)] backdrop-blur dark:border-[#344052] dark:bg-[#1B2432]/[0.92]",children:(0,u.jsxs)("div",{className:"flex items-center justify-between space-x-4",children:[(0,u.jsxs)("div",{className:"flex-1",children:[Dt?(0,u.jsx)("input",{type:"text",defaultValue:kt,onKeyPress:e=>((e,t)=>{"Enter"===e.key?oa(t):"Escape"===e.key&&Ct(!1)})(e,e.target.value),onBlur:e=>oa(e.target.value),className:"w-full border-b-2 border-[#FFB52B] bg-transparent font-headlines text-xl font-bold text-[#232E3F] focus:outline-none dark:text-[#F4F4F4]",placeholder:"Enter session title...",autoFocus:!0}):(0,u.jsx)("h2",{className:"font-headlines text-xl font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:kt||"Untitled Session"}),(0,u.jsxs)("p",{className:"mt-1 font-body text-sm text-[#566377] dark:text-[#C6CDD8]",children:[(null===G||void 0===G?void 0:G.name)||(null===ue||void 0===ue?void 0:ue._videoTitle)||"Session"," \u2022",null===ct||void 0===ct?void 0:ct.substring(0,8),"..."]})]}),(0,u.jsxs)("div",{className:"flex items-center space-x-2",children:[!Dt&&!P&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{onClick:()=>{ia()},disabled:St||!sa,className:"flex items-center space-x-2 rounded-2xl bg-[#232E3F] px-4 py-2.5 font-headlines text-sm font-semibold text-[#F4F4F4] shadow-[0_18px_32px_-24px_rgba(35,46,63,0.78)] transition-all hover:bg-[#2F3B4E] hover:shadow-[0_22px_36px_-24px_rgba(35,46,63,0.88)] disabled:cursor-not-allowed disabled:opacity-50",title:"Start title generation agent",children:St?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Lo,{className:"animate-spin",size:16}),(0,u.jsx)("span",{children:"Generating..."})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(Po,{size:16}),(0,u.jsx)("span",{children:"AI Title"})]})}),(0,u.jsx)("button",{onClick:()=>Ct(!0),className:"rounded-2xl border border-[#D6DCE4] p-2 text-[#566377] transition-colors hover:border-[#FFB52B]/60 hover:bg-[#FFF8EA] hover:text-[#232E3F] dark:border-[#3A4658] dark:text-[#C6CDD8] dark:hover:bg-[#2A3446] dark:hover:text-[#F4F4F4]",title:"Edit title",children:(0,u.jsx)(Ro,{size:16})})]}),Nt&&(0,u.jsxs)("div",{className:"flex items-center space-x-2 text-[#C98A00] dark:text-[#FFB52B]",children:[(0,u.jsx)(Lo,{className:"animate-spin",size:16}),(0,u.jsx)("span",{className:"text-sm",children:"Saving..."})]})]})]})})}),gt&&(0,u.jsx)(Do.div,{initial:{opacity:0,scale:.95}
2,animate:{opacity:1,scale:1},className:"text-center py-8",children:(0,u.jsxs)("div",{className:"rounded-[28px] border border-[#D6DCE4] bg-[#F8F8F7]/[0.92] p-8 shadow-[0_28px_60px_-36px_rgba(35,46,63,0.42)] backdrop-blur dark:border-[#344052] dark:bg-[#1B2432]/[0.92]",children:[(0,u.jsx)("div",{className:"mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-4 border-[#FFB52B] border-t-transparent"}),(0,u.jsx)("h3",{className:"mb-2 font-headlines text-lg font-bold text-[#232E3F] dark:text-[#F4F4F4]",children:"Loading Session"}),(0,u.jsx)("p",{className:"font-body text-[#566377] dark:text-[#C6CDD8]",children:"Restoring your session data..."})]})}),!gt&&(0,u.jsxs)(Do.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"space-y-6",children:[!c&&($||gn||"processing"===W)&&("ready"===W||"processing"===W)&&(0,u.jsx)(uh,{rulesKeyterms:Hn,onRulesKeytermsChange:qn,onFileSelect:Qn,onYouTubeSelect:Zn,onDropboxSelect:ea,projectId:te,onProjectChange:ne,showAssignment:ae,onShowAssignmentChange:re,familyAssignment:se,onFamilyAssignmentChange:ie,isProcessing:"processing"===W}),!c&&"ready"===W&&!gn&&(0,u.jsx)(WC,{onSessionSelect:e=>{h("/session/".concat(e))},className:"mb-6"}),(0,u.jsx)(Dd,{audit:null===ue||void 0===ue||null===(o=ue.metadata)||void 0===o?void 0:o.transcriptRules}),!c&&"ready"===W&&gn&&(0,u.jsx)(Do.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"text-center",children:(0,u.jsx)("button",{onClick:async()=>{if(G||X||Z)if(te)if(ae.showSlug.trim()&&ae.showTitle.trim())if(!se.familySlug.trim()||se.familyVersionNumber)if(se.seedSessionId.trim()&&(!se.familySlug.trim()||(se.familyVersionNumber||0)<2))de({status:"error",message:"Please seed the new family from an existing session and use version 2 or higher for this upload."});else try{var e,t,n,a,r;Y("processing"),de(Z?{status:"uploading",message:"Extracting aligned audio from Dropbox video...",progress:10}:oe&&X?{status:"uploading",message:"Extracting audio from YouTube video...",progress:10}:{status:"uploading",message:"Preparing audio file for transcription...",progress:10}),await new Promise(e=>setTimeout(e,500));const l=d(d({},Wn),{},{projectId:te,rulesContext:{rulesKeyterms:Hn,familySlug:se.familySlug,seedSessionId:se.seedSessionId,showSlug:ae.showSlug}});let c;if(Z?(de({status:"transcribing",message:"Transcribing audio extracted from Dropbox video...",progress:30}),c=await YV.transcribeDropbox(Z.dropboxVideoUrl,l,{videoFilename:Z.videoFilename||void 0},b)):oe&&X?(de({status:"transcribing",message:"Transcribing YouTube audio...",progress:30}),c=await YV.transcribeYoutube(X,l,b)):G&&(de({status:"transcribing",message:"Checking cache and transcribing audio...",progress:30}),c=await YV.transcribeFile(G.file,l,b)),!c)throw new Error("No transcription result was returned");if(null!==(e=c.metadata)&&void 0!==e&&e.transcriptRules){var s,i;const e=c.metadata.transcriptRules;de({status:"transcribing",message:"Rules: ".concat(e.keyterms.sentCount," keyterms; ").concat(null!==(s=null===(i=e.rules)||void 0===i?void 0:i.remainingCorrections)&&void 0!==s?s:"?"," remaining corrections"),progress:90})}me(c);const u=(null===(t=c._cache)||void 0===t?void 0:t.checksum)||null;if(u&&xe(u),Z&&c._videoSourceInfo&&an(e=>e||Z.videoFilename||null),null!==(n=c._cache)&&void 0!==n&&n.hit&&de({status:"completed",message:"Used cached transcription from ".concat(new Date(c._cache.cachedAt).toLocaleString()),progress:100}),c._speakerLabels)Ne(c._speakerLabels);else{const e={};GV.getDistinctSpeakers(GV.extractSpeakerSegments(c)).forEach(t=>{e[t]="Speaker ".concat(t)}),Ne(e)}null!==(a=c._cache)&&void 0!==a&&a.hit||de({status:"processing",message:Z?"Processing transcript and queueing AWS video prep...":"Processing transcript and identifying speakers...",progress:70}),await new Promise(e=>setTimeout(e,500));const m=GV.extractSpeakerSegments(c),p=GV.getDistinctSpeakers(m);be(m),ve(p);const g="Found ".concat(p.length," speaker").concat(1!==p.length?"s":"",". Ready for labeling."),x=null!==(r=c._cache)&&void 0!==r&&r.hit?" (from cache)":"";if(de({status:"completed",message:g+x,progress:100}),p.length>0)Y("labeling");else{const e=GV.generateFormattedTranscript(c,{},Wn.timeInterval);if(ke(e),De(e),Y("completed"),u&&b)try{zw("[SESSION] Creating session (no speakers) with transcript length:",e.length);const t=await Vm.createSession(Xn({checksum:u,result:c,speakerLabels:{},finalTranscript:e,currentTranscript:e,speakerSegmentsPayload:Object.fromEntries(m),distinctSpeakersPayload:p}),b);t.isExisting||await Jn(),dt(t.sessionId);const n=Vm.generateSessionUrl(t.sessionId);pt(n),h&&(h("/session/".concat(t.sessionId),{replace:!0}),zw("[SESSION] URL updated to:","/session/".concat(t.sessionId)))}catch(o){console.error("[SESSION] Failed to create session (no speakers):",o)}}}catch(o){console.error("Transcription failed:",o),o instanceof Error&&o.message.includes("Deepgram API key not configured")?de({status:"error",message:"Transcription service not configured. Please contact your administrator."}):de({status:"error",message:o instanceof Error?o.message:"Transcription failed. Please try again."}),setTimeout(()=>{Y("ready"),de({status:"idle",message:"Ready to transcribe"})},5e3)}else de({status:"error",message:"Please choose a valid family version number before starting transcription."});else de({status:"error",message:"Please choose a valid show assignment before starting transcription."});else de({status:"error",message:"Choose a project before starting transcription."});else de({status:"error",message:"Please select an audio file, YouTube URL, or Dropbox video first."})},className:"rounded-full bg-[#232E3F] px-8 py-3 font-headlines text-lg font-semibold text-[#F4F4F4] shadow-[0_24px_42px_-24px_rgba(35,46,63,0.7)] transition-all hover:-translate-y-0.5 hover:bg-[#2F3B4E] hover:shadow-[0_28px_48px_-24px_rgba(35,46,63,0.82)]",children:"Start Transcription"})}),"processing"===W&&(0,u.jsx)(xh,{status:ce}),(null===ft||void 0===ft||null===(l=ft.audioStatus)||void 0===l?void 0:l.isOrphan)&&!oe&&(0,u.jsx)(dj,{sessionId:ft.sessionId,filename:ft.filename,transcriptionChecksum:ft.transcriptionChecksum,onRecoverySuccess:Bn,className:"mb-6"}),"labeling"===W&&gn&&(0,u.jsx)(pp,{sessionId:ct||void 0,speakers:ye,speakerSegments:fe,audioFile:G,onLabelsComplete:ta,initialLabels:Ce,isYouTubeMode:oe,transcriptionChecksum:ge||void 0}),(0,u.jsx)(Do.div,{initial:{opacity:0}
2,animate:{opacity:1},transition:{delay:.5},className:"pt-8 text-center font-headlines text-[11px] font-semibold uppercase tracking-[0.24em] text-[#6B788B] dark:text-[#8D99AA]",children:"\xa9 MLST, 2025"})]})]})}),(zw("[APP] CentralAudioPlayer condition:",{currentSessionId:null===ct||void 0===ct?void 0:ct.substring(0,8),appState:W,shouldRender:!(!ct||"completed"!==W&&"labeling"!==W)}),null),ct&&("completed"===W||"labeling"===W)&&(0,u.jsx)(PE,{sessionId:ct,sessionTitle:kt,sessionVisuals:(null===ft||void 0===ft?void 0:ft.sessionVisuals)||null,speakerSegments:fe,speakerLabels:Ce,transcriptionData:he||ue,ttmlFiles:st,duration:da,selectedTtmlId:ot||(null===ft||void 0===ft?void 0:ft.selectedTtmlId),selectedTtmlChecksum:yt,shareToken:L||void 0,isPublicView:!!L,retentionData:xn,youtubeUrl:Rt,initialComments:null===ft||void 0===ft?void 0:ft._comments,fromCdn:null===ft||void 0===ft?void 0:ft._fromCdn,onTtmlRevisionCreated:Un,onSessionVisualsChanged:Vn,searchMatches:It,gapClusters:vn||(null===bn||void 0===bn?void 0:bn.clusters),nonClusteredGaps:kn||void 0}),(0,u.jsx)(wH,{currentSessionId:ct})]}),!Mn&&En&&R.isMobile&&"readable"===Le&&(0,u.jsxs)("button",{type:"button",onClick:()=>Tn(!0),className:"fixed right-20 z-40 inline-flex items-center gap-2 rounded-full border px-4 py-3 text-sm font-headlines font-semibold shadow-lg backdrop-blur ".concat(k?"border-[#445166] bg-[#232E3F]/95 text-[#F4F4F4] hover:border-[#FFB52B]/60 hover:bg-[#2D3A4F]":"border-[#D4DAE2] bg-white/95 text-[#232E3F] hover:border-[#FFB52B]/60 hover:bg-[#FFF8EA]"),style:{bottom:"calc(var(--app-mobile-bottom-offset) + 8rem)"},title:"Open video panel",children:["youtube"===An?(0,u.jsx)(Au,{className:"h-4 w-4 text-red-500"}):(0,u.jsx)(gA,{className:"h-4 w-4 text-brand-yellow"}),(0,u.jsx)("span",{children:"Video"})]}),(0,u.jsx)(S,{children:Je&&(0,u.jsx)(Do.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},className:"app-toast-host fixed bottom-6 right-3 sm:right-6 max-w-[calc(100vw-24px)] sm:max-w-sm",children:(0,u.jsx)("div",{className:"rounded-2xl border px-4 py-3 text-sm font-medium shadow-[0_22px_50px_-28px_rgba(15,23,42,0.75)] backdrop-blur ".concat("error"===Je.tone?"border-red-200 bg-red-50/95 text-red-700 dark:border-red-900/60 dark:bg-red-950/85 dark:text-red-100":"border-[#FFB52B]/35 bg-white/95 text-[#232E3F] dark:border-[#FFB52B]/30 dark:bg-[#1B2432]/95 dark:text-[#F4F4F4]"),children:(0,u.jsx)(m,{toast:Je,onDismiss:()=>$e(null)})})})})]})]}):(0,u.jsx)(ij,{}):(0,u.jsx)("div",{className:"flex h-screen items-center justify-center bg-[#EEF1F3] dark:bg-[#111826]",children:(0,u.jsx)("div",{className:"h-10 w-10 animate-spin rounded-full border-4 border-[#FFB52B] border-t-transparent"})})}function CH(){const e=oc(),{isAuthenticated:t,isLoading:n}=am(),{isDarkMode:a}=zu();return n?(0,u.jsx)("div",{className:"min-h-screen flex items-center justify-center ".concat(a?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-700"),children:(0,u.jsx)("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-[#FFB52B]"})}):t?(0,u.jsx)(DH,{navigate:e}):(0,u.jsx)("div",{className:a?"dark":"",children:(0,u.jsx)(uU,{})})}function NH(){const{shareToken:e}=lc(),t=rc(),n=oc(),[r,s]=(0,a.useState)(null),[i,o]=(0,a.useState)(null),l=a.useMemo(()=>{const e=new URLSearchParams(t.search),n=new URLSearchParams,a=e.get("t");a&&n.set("t",a);const r=n.toString();return r?"&".concat(r):""},[t.search]);return(0,a.useEffect)(()=>{e&&(async()=>{const t=async()=>{if(!e)return!1;const t=await EN(e);return!!t&&(n("/session/".concat(t,"?share=").concat(e).concat(l),{replace:!0}),!0)};try{if(!navigator.onLine&&await t())return;const n=await Wu("".concat("","/api/public/share/").concat(e),{cache:"no-store",credentials:"omit"},mH,"Timed out while loading the shared session");if(n.ok){const t=await n.json();Vm.primePublicShareEmbeddedData(e,t),s(t.session.session_id)}else o("Invalid share link")}catch(a){if(await t())return;o("Failed to load share link")}})()},[l,n,e]),i?(0,u.jsx)("div",{className:"flex items-center justify-center h-screen",children:(0,u.jsxs)("div",{className:"text-center",children:[(0,u.jsx)("h1",{className:"text-2xl font-bold mb-2 text-red-600",children:i}),(0,u.jsx)("p",{className:"text-gray-600",children:"The shared session you're looking for is not available."})]})}):r?(window.location.href="/session/".concat(r,"?share=").concat(e).concat(l),null):(0,u.jsx)("div",{className:"flex items-center justify-center h-screen",children:(0,u.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-[#FFB52B]"})})}function FH(){const{previewToken:e}=lc(),t=rc();return(0,a.useEffect)(()=>{e&&window.location.replace("".concat("","/arrangement/").concat(e).concat(t.search||""))},[t.search,e]),(0,u.jsx)("div",{className:"flex items-center justify-center h-screen",children:(0,u.jsx)("div",{className:"text-sm text-gray-500",children:"Opening arrangement viewer\u2026"})})}function SH(){const e=oc(),{isAuthenticated:t,isLoading:n}=am(),{isDarkMode:a}=zu();return n?(0,u.jsx)("div",{className:"min-h-screen flex items-center justify-center ".concat(a?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-700"),children:(0,u.jsx)("div",{className:"animate-spin rounded-full h-10 w-10 border-b-2 border-[#FFB52B]"})}):t?(0,u.jsx)("div",{className:"min-h-screen ".concat(a?"bg-gray-900":"bg-gray-50"),children:(0,u.jsxs)("div",{className:"max-w-6xl mx-auto px-4 py-8",children:[(0,u.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("h1",{className:"text-2xl font-bold ".concat(a?"text-white":"text-gray-900"),children:"Settings"}),(0,u.jsx)("p",{className:"mt-1 text-sm ".concat(a?"text-gray-400":"text-gray-600"),children:"Organization controls, billing, and YouTube authentication."})]}),(0,u.jsx)("button",{onClick:()=>e("/"),className:"px-4 py-2 rounded-lg text-sm font-medium transition-colors ".concat(a?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-200 text-gray-700 hover:bg-gray-300"),children:"Back to Home"})]}),(0,u.jsx)(HV,{})]})}):(0,u.jsx)("div",{className:"min-h-screen ".concat(a?"bg-gray-900":"bg-gray-50"),children:(0,u.jsx)(ij,{})})}function EH(){const{isDarkMode:e}=zu();return(0,a.useEffect)(()=>
2{if("undefined"===typeof document)return;const t=e?"#111826":"#232E3F",n=e?"black":"default",a=Array.from(document.querySelectorAll('meta[name="theme-color"]')),r=document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');if(0===a.length){const e=document.createElement("meta");e.setAttribute("name","theme-color"),e.setAttribute("content",t),document.head.appendChild(e)}else a.forEach(e=>{e.setAttribute("content",t)});r&&r.setAttribute("content",n),document.documentElement.style.colorScheme=e?"dark":"light",document.documentElement.style.backgroundColor=t,document.body.style.backgroundColor=t},[e]),null}const AH=function(){var e,t;zw("[APP] Current location:",window.location.pathname+window.location.search);const[n,r]=(0,a.useState)(null);return(0,a.useEffect)(()=>{const e=e=>{var t;const n=e;null!==(t=n.detail)&&void 0!==t&&t.message&&r(n.detail)};if(window.addEventListener(uH,e),!window.__rescriptCreditFetchPatched){const e=window.fetch.bind(window);window.fetch=async function(){const t=await e(...arguments);if(402===t.status)try{const e=await t.clone().json();if("CREDIT_LIMIT_REACHED"===(null===e||void 0===e?void 0:e.code)){const t=arguments.length<=0?void 0:arguments[0],n="string"===typeof t?t:t instanceof Request?t.url:null;window.dispatchEvent(new CustomEvent(uH,{detail:{message:e.message||e.error||"This action is unavailable because your monthly allowance has been exhausted.",billing:e.billing||null,sourceUrl:n}}))}}catch(n){console.warn("[APP] Failed to parse credit limit response:",n)}return t},window.__rescriptCreditFetchPatched=!0}return()=>{window.removeEventListener(uH,e)}},[]),(0,u.jsx)(Vw,{children:(0,u.jsx)(Uu,{children:(0,u.jsx)(Qw,{children:(0,u.jsx)(tE,{children:(0,u.jsx)(vk,{children:(0,u.jsx)(nF,{children:(0,u.jsx)(_T,{children:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(EH,{}),(0,u.jsxs)(Ac,{children:[(0,u.jsx)(Sc,{path:"/",element:(0,u.jsx)(CH,{})}),(0,u.jsx)(Sc,{path:"/questions",element:(0,u.jsx)(eU,{})}),(0,u.jsx)(Sc,{path:"/session/:sessionId",element:(0,u.jsx)(kH,{})}),(0,u.jsx)(Sc,{path:"/arrangement/:previewToken",element:(0,u.jsx)(FH,{})}),(0,u.jsx)(Sc,{path:"/settings",element:(0,u.jsx)(SH,{})}),(0,u.jsx)(Sc,{path:"/admin/comments",element:(0,u.jsx)(pU,{})}),(0,u.jsx)(Sc,{path:"/agents",element:(0,u.jsx)(jU,{})}),(0,u.jsx)(Sc,{path:"/schedules",element:(0,u.jsx)(gV,{})}),(0,u.jsx)(Sc,{path:"/public/share/:shareToken",element:(0,u.jsx)(NH,{})}),(0,u.jsx)(Sc,{path:"/share/:shareToken",element:(0,u.jsx)(TN,{})})]}),n&&(0,u.jsx)("div",{className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/50 px-4",children:(0,u.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-red-200 bg-white p-6 shadow-2xl",children:[(0,u.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"text-sm font-semibold uppercase tracking-[0.2em] text-red-600",children:"Monthly allowance reached"}),(0,u.jsx)("h2",{className:"mt-2 text-xl font-semibold text-slate-900",children:"This action is currently blocked"})]}),(0,u.jsx)("button",{type:"button",className:"rounded-full border border-slate-200 px-3 py-1 text-sm text-slate-600 hover:bg-slate-50",onClick:()=>r(null),children:"Close"})]}),(0,u.jsx)("p",{className:"mt-4 text-sm leading-6 text-slate-700",children:n.message}),n.billing&&(0,u.jsxs)("div",{className:"mt-5 grid gap-3 sm:grid-cols-2",children:[(0,u.jsxs)("div",{className:"rounded-xl border border-slate-200 bg-slate-50 px-4 py-3",children:[(0,u.jsx)("p",{className:"text-xs uppercase tracking-wide text-slate-500",children:"USD this month"}),(0,u.jsxs)("p",{className:"mt-1 text-lg font-semibold text-slate-900",children:[hH(n.billing.totalCostUsd)," / ",null==n.billing.monthlyUsdLimit?"Unlimited":hH(n.billing.monthlyUsdLimit)]})]}),(0,u.jsxs)("div",{className:"rounded-xl border border-slate-200 bg-slate-50 px-4 py-3",children:[(0,u.jsx)("p",{className:"text-xs uppercase tracking-wide text-slate-500",children:"Credits this month"}),(0,u.jsxs)("p",{className:"mt-1 text-lg font-semibold text-slate-900",children:[pH(n.billing.totalCreditsUsed)," / ",null==n.billing.monthlyCreditLimit?"Unlimited":pH(n.billing.monthlyCreditLimit)]})]})]}),(null===(e=n.billing)||void 0===e||null===(t=e.period)||void 0===t?void 0:t.periodId)&&(0,u.jsxs)("p",{className:"mt-4 text-xs uppercase tracking-wide text-slate-500",children:["Billing period ",n.billing.period.periodId]}),n.sourceUrl&&(0,u.jsxs)("p",{className:"mt-2 text-xs text-slate-500 break-all",children:["Request: ",n.sourceUrl]})]})})]})})})})})})})})}
2,TH=e=>{e&&e instanceof Function&&n.e(206).then(n.bind(n,206)).then(t=>{let{getCLS:n,getFID:a,getFCP:r,getLCP:s,getTTFB:i}=t;n(e),a(e),r(e),s(e),i(e)})},MH=a.StrictMode;$V()&&nH();s.createRoot(document.getElementById("root")).render((0,u.jsx)(MH,{children:(0,u.jsx)(ud,{children:(0,u.jsx)(Xk,{clientId:"650914284514-arrnrmrkrk8r37chamjmk7ta7tfj5nuk.apps.googleusercontent.com",children:(0,u.jsx)(nm,{children:(0,u.jsx)(AH,{})})})})})),TH()})()})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.