diff --git "a/assets/index-Brll-5IE.js" "b/assets/index-Brll-5IE.js" new file mode 100644--- /dev/null +++ "b/assets/index-Brll-5IE.js" @@ -0,0 +1,4322 @@ +var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),l=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)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`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1ne||(e.current=L[ne],L[ne]=null,ne--)}function B(e,t){ne++,L[ne]=e.current,e.current=t}var re=R(null),ie=R(null),ae=R(null),oe=R(null);function se(e,t){switch(B(ae,t),B(ie,e),B(re,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Gd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Gd(t),e=Kd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(re),B(re,e)}function ce(){z(re),z(ie),z(ae)}function le(e){e.memoizedState!==null&&B(oe,e);var t=re.current,n=Kd(t,e.type);t!==n&&(B(ie,e),B(re,n))}function ue(e){ie.current===e&&(z(re),z(ie)),oe.current===e&&(z(oe),np._currentValue=te)}var de,fe;function V(e){if(de===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);de=t&&t[1]||``,fe=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{H=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?V(n):``}function me(e,t){switch(e.tag){case 26:case 27:case 5:return V(e.type);case 16:return V(`Lazy`);case 13:return e.child!==t&&t!==null?V(`Suspense Fallback`):V(`Suspense`);case 19:return V(`SuspenseList`);case 0:case 15:return pe(e.type,!1);case 11:return pe(e.type.render,!1);case 1:return pe(e.type,!0);case 31:return V(`Activity`);default:return``}}function he(e){try{var t=``,n=null;do t+=me(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var U=Object.prototype.hasOwnProperty,ge=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,ve=t.unstable_shouldYield,ye=t.unstable_requestPaint,W=t.unstable_now,be=t.unstable_getCurrentPriorityLevel,xe=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,Ce=t.unstable_NormalPriority,we=t.unstable_LowPriority,Te=t.unstable_IdlePriority,Ee=t.log,De=t.unstable_setDisableYieldValue,Oe=null,ke=null;function Ae(e){if(typeof Ee==`function`&&De(e),ke&&typeof ke.setStrictMode==`function`)try{ke.setStrictMode(Oe,e)}catch{}}var je=Math.clz32?Math.clz32:Pe,Me=Math.log,Ne=Math.LN2;function Pe(e){return e>>>=0,e===0?32:31-(Me(e)/Ne|0)|0}var Fe=256,Ie=262144,Le=4194304;function Re(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ze(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Re(n))):i=Re(o):i=Re(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Re(n))):i=Re(o)):i=Re(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Be(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ve(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function He(){var e=Le;return Le<<=1,!(Le&62914560)&&(Le=4194304),e}function Ue(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function We(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ge(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),Qt=!1;if(Zt)try{var $t={};Object.defineProperty($t,"passive",{get:function(){Qt=!0}}),window.addEventListener(`test`,$t,$t),window.removeEventListener(`test`,$t,$t)}catch{Qt=!1}var en=null,tn=null,nn=null;function rn(){if(nn)return nn;var e,t=tn,n=t.length,r,i=`value`in en?en.value:en.textContent,a=i.length;for(e=0;e=In),zn=` `,Bn=!1;function Vn(e,t){switch(e){case`keyup`:return Pn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Hn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Un=!1;function Wn(e,t){switch(e){case`compositionend`:return Hn(t);case`keypress`:return t.which===32?(Bn=!0,zn):null;case`textInput`:return e=t.data,e===zn&&Bn?null:e;default:return null}}function Gn(e,t){if(Un)return e===`compositionend`||!Fn&&Vn(e,t)?(e=rn(),nn=tn=en=null,Un=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=pr(n)}}function hr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?hr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function gr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ot(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ot(e.document)}return t}function _r(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var vr=Zt&&`documentMode`in document&&11>=document.documentMode,yr=null,br=null,xr=null,Sr=!1;function Cr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Sr||yr==null||yr!==Ot(r)||(r=yr,`selectionStart`in r&&_r(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),xr&&fr(xr,r)||(xr=r,r=kd(br,`onSelect`),0>=o,i-=o,hi=1<<32-je(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),wi&&_i(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),wi&&_i(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return wi&&_i(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),wi&&_i(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&va(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ta(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ni(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ti(o.type,o.key,o.props,null,e.mode,c),Ta(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ai(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=va(o),b(e,r,o,c)}if(P(o))return h(e,r,o,c);if(M(o)){if(l=M(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,wa(o),c);if(o.$$typeof===C)return b(e,r,Ki(e,o),c);Ea(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ri(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ca=0;var i=b(e,t,n,r);return Sa=null,i}catch(t){if(t===fa||t===ma)throw t;var a=Zr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Oa=Da(!0),ka=Da(!1),Aa=!1;function ja(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ma(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 Na(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Pa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Fl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Jr(e),qr(e,null,n),t}return Wr(e,r,t,n),Jr(e)}function Fa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,qe(e,n)}}function Ia(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var La=!1;function Ra(){if(La){var e=ra;if(e!==null)throw e}}function za(e,t,n,r){La=!1;var i=e.updateQueue;Aa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Rl&f)===f:(r&f)===f){f!==0&&f===na&&(La=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Aa=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Kl|=o,e.lanes=o,e.memoizedState=d}}function Ba(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Va(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=F.T,s={};F.T=s,Os(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ds(e,t,oa(c,r),mu(e)):Ds(e,t,r,mu(e))}catch(n){Ds(e,t,{then:function(){},status:`rejected`,reason:n},mu())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function _s(){}function vs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=ys(e).queue;gs(e,a,t,te,n===null?_s:function(){return bs(e),n(r)})}function ys(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ko,lastRenderedState:te},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ko,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function bs(e){var t=ys(e);t.next===null&&(t=e.alternate.memoizedState),Ds(e,t.next.queue,{},mu())}function xs(){return Gi(np)}function Ss(){return wo().memoizedState}function Cs(){return wo().memoizedState}function ws(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=mu();e=Na(n);var r=Pa(t,e,n);r!==null&&(gu(r,t,n),Fa(r,t,n)),t={cache:Qi()},e.payload=t;return}t=t.return}}function Ts(e,t,n){var r=mu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},ks(e)?As(t,n):(n=Gr(e,t,n,r),n!==null&&(gu(n,e,r),js(n,t,r)))}function Es(e,t,n){Ds(e,t,n,mu())}function Ds(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(ks(e))As(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,dr(s,o))return Wr(e,t,i,0),Il===null&&Ur(),!1}catch{}if(n=Gr(e,t,i,r),n!==null)return gu(n,e,r),js(n,t,r),!0}return!1}function Os(e,t,n,r){if(r={lane:2,revertLane:pd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},ks(e)){if(t)throw Error(i(479))}else t=Gr(e,n,r,2),t!==null&&gu(t,e,2)}function ks(e){var t=e.alternate;return e===ro||t!==null&&t===ro}function As(e,t){so=oo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function js(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,qe(e,n)}}var Ms={readContext:Gi,use:Do,useCallback:mo,useContext:mo,useEffect:mo,useImperativeHandle:mo,useLayoutEffect:mo,useInsertionEffect:mo,useMemo:mo,useReducer:mo,useRef:mo,useState:mo,useDebugValue:mo,useDeferredValue:mo,useTransition:mo,useSyncExternalStore:mo,useId:mo,useHostTransitionStatus:mo,useFormState:mo,useActionState:mo,useOptimistic:mo,useMemoCache:mo,useCacheRefresh:mo};Ms.useEffectEvent=mo;var Ns={readContext:Gi,use:Do,useCallback:function(e,t){return Co().memoizedState=[e,t===void 0?null:t],e},useContext:Gi,useEffect:rs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ts(4194308,4,ls.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ts(4194308,4,e,t)},useInsertionEffect:function(e,t){ts(4,2,e,t)},useMemo:function(e,t){var n=Co();t=t===void 0?null:t;var r=e();if(co){Ae(!0);try{e()}finally{Ae(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Co();if(n!==void 0){var i=n(t);if(co){Ae(!0);try{n(t)}finally{Ae(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ts.bind(null,ro,e),[r.memoizedState,e]},useRef:function(e){var t=Co();return e={current:e},t.memoizedState=e},useState:function(e){e=zo(e);var t=e.queue,n=Es.bind(null,ro,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ds,useDeferredValue:function(e,t){return ms(Co(),e,t)},useTransition:function(){var e=zo(!1);return e=gs.bind(null,ro,e.queue,!0,!1),Co().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=ro,a=Co();if(wi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Il===null)throw Error(i(349));Rl&127||Po(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,rs(Io.bind(null,r,o,e),[e]),r.flags|=2048,$o(9,{destroy:void 0},Fo.bind(null,r,o,n,t),null),n},useId:function(){var e=Co(),t=Il.identifierPrefix;if(wi){var n=gi,r=hi;n=(r&~(1<<32-je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=lo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[et]=t,o[tt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Rd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Dc(t)}}return Mc(t),Oc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Dc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ae.current,ji(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Si,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[et]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Fd(e.nodeValue,n)),e||Oi(t,!0)}else e=Wd(e).createTextNode(r),e[et]=t,t.stateNode=e}return Mc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ji(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[et]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Mc(t),e=!1}else n=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?($a(t),t):($a(t),null);if(t.flags&128)throw Error(i(558))}return Mc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ji(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[et]=t}else Mi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Mc(t),a=!1}else a=Ni(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?($a(t),t):($a(t),null)}return $a(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ac(t,t.updateQueue),Mc(t),null);case 4:return ce(),e===null&&Td(t.stateNode.containerInfo),Mc(t),null;case 10:return zi(t.type),Mc(t),null;case 19:if(z(eo),r=t.memoizedState,r===null)return Mc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)jc(r,!1);else{if(Gl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=to(e),o!==null){for(t.flags|=128,jc(r,!1),e=o.updateQueue,t.updateQueue=e,Ac(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ei(n,e),n=n.sibling;return B(eo,eo.current&1|2),wi&&_i(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&W()>nu&&(t.flags|=128,a=!0,jc(r,!1),t.lanes=4194304)}else{if(!a)if(e=to(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Ac(t,e),jc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!wi)return Mc(t),null}else 2*W()-r.renderingStartTime>nu&&n!==536870912&&(t.flags|=128,a=!0,jc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Mc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=W(),e.sibling=null,n=eo.current,B(eo,a?n&1|2:n&1),wi&&_i(t,r.treeForkCount),e);case 22:case 23:return $a(t),Ka(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Mc(t),t.subtreeFlags&6&&(t.flags|=8192)):Mc(t),n=t.updateQueue,n!==null&&Ac(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&z(ca),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),zi(Zi),Mc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Pc(e,t){switch(bi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zi(Zi),ce(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ue(t),null;case 31:if(t.memoizedState!==null){if($a(t),t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if($a(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Mi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return z(eo),null;case 4:return ce(),null;case 10:return zi(t.type),null;case 22:case 23:return $a(t),Ka(),e!==null&&z(ca),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return zi(Zi),null;case 25:return null;default:return null}}function Fc(e,t){switch(bi(t),t.tag){case 3:zi(Zi),ce();break;case 26:case 27:case 5:ue(t);break;case 4:ce();break;case 31:t.memoizedState!==null&&$a(t);break;case 13:$a(t);break;case 19:z(eo);break;case 10:zi(t.type);break;case 22:case 23:$a(t),Ka(),e!==null&&z(ca);break;case 24:zi(Zi)}}function Ic(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Ku(t,t.return,e)}}function Lc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Ku(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Ku(t,t.return,e)}}function Rc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Va(t,n)}catch(t){Ku(e,e.return,t)}}}function zc(e,t,n){n.props=Bs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Ku(e,t,n)}}function Bc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Ku(e,t,n)}}function Vc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Ku(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Ku(e,t,n)}else n.current=null}function Hc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Ku(e,e.return,t)}}function Uc(e,t,n){try{var r=e.stateNode;zd(r,e.type,n,t),r[tt]=t}catch(t){Ku(e,e.return,t)}}function Wc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&tf(e.type)||e.tag===4}function Gc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Wc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&tf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Kc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Y));else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Kc(e,t,n),e=e.sibling;e!==null;)Kc(e,t,n),e=e.sibling}function qc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&tf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(qc(e,t,n),e=e.sibling;e!==null;)qc(e,t,n),e=e.sibling}function Jc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Rd(t,r,n),t[et]=e,t[tt]=n}catch(t){Ku(e,e.return,t)}}var Yc=!1,Xc=!1,Zc=!1,Qc=typeof WeakSet==`function`?WeakSet:Set,$c=null;function el(e,t){if(e=e.containerInfo,Hd=dp,e=gr(e),_r(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Ud={focusedElem:e,selectionRange:n},dp=!1,$c=t;$c!==null;)if(t=$c,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,$c=e;else for(;$c!==null;){switch(t=$c,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Rd(o,r,n),o[et]=e,pt(o),r=o;break a;case`link`:var s=Gf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=mr(s,h),v=mr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,F.T=null,n=uu,uu=null;var o=ou,s=cu;if(au=0,su=ou=null,cu=0,Fl&6)throw Error(i(331));var c=Fl;if(Fl|=4,Al(o.current),Sl(o,o.current,s,n),Fl=c,od(0,!1),ke&&typeof ke.onPostCommitFiberRoot==`function`)try{ke.onPostCommitFiberRoot(Oe,o)}catch{}return!0}finally{I.p=a,F.T=r,Hu(e,t)}}function Gu(e,t,n){t=si(n,t),t=Ks(e.stateNode,t,2),e=Pa(e,t,2),e!==null&&(We(e,2),ad(e))}function Ku(e,t,n){if(e.tag===3)Gu(e,e,n);else for(;t!==null;){if(t.tag===3){Gu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(iu===null||!iu.has(r))){e=si(n,e),n=qs(2),r=Pa(t,n,2),r!==null&&(Js(n,r,t,e),We(r,2),ad(r));break}}t=t.return}}function qu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Pl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ul=!0,i.add(n),e=Ju.bind(null,e,t,n),t.then(e,e))}function Ju(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Il===e&&(Rl&n)===n&&(Gl===4||Gl===3&&(Rl&62914560)===Rl&&300>W()-eu?!(Fl&2)&&Cu(e,0):Jl|=n,Xl===Rl&&(Xl=0)),ad(e)}function Yu(e,t){t===0&&(t=He()),e=Kr(e,t),e!==null&&(We(e,t),ad(e))}function Xu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Yu(e,n)}function Zu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Yu(e,n)}function Qu(e,t){return ge(e,t)}var $u=null,ed=null,td=!1,nd=!1,rd=!1,id=0;function ad(e){e!==ed&&e.next===null&&(ed===null?$u=ed=e:ed=ed.next=e),nd=!0,td||(td=!0,fd())}function od(e,t){if(!rd&&nd){rd=!0;do for(var n=!1,r=$u;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-je(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,dd(r,a))}else a=Rl,a=ze(r,r===Il?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Be(r,a)||(n=!0,dd(r,a));r=r.next}while(n);rd=!1}}function sd(){cd()}function cd(){nd=td=!1;var e=0;id!==0&&Yd()&&(e=id);for(var t=W(),n=null,r=$u;r!==null;){var i=r.next,a=ld(r,t);a===0?(r.next=null,n===null?$u=i:n.next=i,i===null&&(ed=n)):(n=r,(e!==0||a&3)&&(nd=!0)),r=i}au!==0&&au!==5||od(e,!1),id!==0&&(id=0)}function ld(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Bd(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function Tf(e,t,n){var r=wf;if(r&&typeof t==`string`&&t){var i=At(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),yf.has(i)||(yf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Rd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function Ef(e){xf.D(e),Tf(`dns-prefetch`,e,null)}function Df(e,t){xf.C(e,t),Tf(`preconnect`,e,t)}function Of(e,t,n){xf.L(e,t,n);var r=wf;if(r&&e&&t){var i=`link[rel="preload"][as="`+At(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+At(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+At(n.imageSizes)+`"]`)):i+=`[href="`+At(e)+`"]`;var a=i;switch(t){case`style`:a=Pf(e);break;case`script`:a=Rf(e)}vf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Ff(a))||t===`script`&&r.querySelector(zf(a))||(t=r.createElement(`link`),Rd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function kf(e,t){xf.m(e,t);var n=wf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+At(r)+`"][href="`+At(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rf(e)}if(!vf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),vf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zf(a)))return}r=n.createElement(`link`),Rd(r,`link`,e),pt(r),n.head.appendChild(r)}}}function Af(e,t,n){xf.S(e,t,n);var r=wf;if(r&&e){var i=ft(r).hoistableStyles,a=Pf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Ff(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vf.get(a))&&Hf(e,n);var c=o=r.createElement(`link`);pt(c),Rd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jf(e,t){xf.X(e,t);var n=wf;if(n&&e){var r=ft(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),pt(a),Rd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mf(e,t){xf.M(e,t);var n=wf;if(n&&e){var r=ft(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),pt(a),Rd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nf(e,t,n,r){var a=(a=ae.current)?bf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Pf(n.href),n=ft(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pf(n.href);var o=ft(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Ff(e)))&&!o._p&&(s.instance=o,s.state.loading=5),vf.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},vf.set(e,n),o||Lf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Rf(n),n=ft(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pf(e){return`href="`+At(e)+`"`}function Ff(e){return`link[rel="stylesheet"][`+e+`]`}function If(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Lf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Rd(t,`link`,n),pt(t),e.head.appendChild(t))}function Rf(e){return`[src="`+At(e)+`"]`}function zf(e){return`script[async]`+e}function Bf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+At(n.href)+`"]`);if(r)return t.instance=r,pt(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),pt(r),Rd(r,`style`,a),Vf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pf(n.href);var o=e.querySelector(Ff(a));if(o)return t.state.loading|=4,t.instance=o,pt(o),o;r=If(n),(a=vf.get(a))&&Hf(r,a),o=(e.ownerDocument||e).createElement(`link`),pt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Rd(o,`link`,r),t.state.loading|=4,Vf(o,n.precedence,e),t.instance=o;case`script`:return o=Rf(n.src),(a=e.querySelector(zf(o)))?(t.instance=a,pt(a),a):(r=n,(a=vf.get(o))&&(r=m({},n),Uf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),pt(a),Rd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vf(r,n.precedence,e));return t.instance}function Vf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Yf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pf(r.href),a=t.querySelector(Ff(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Qf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,pt(a);return}a=t.ownerDocument||t,r=If(r),(i=vf.get(i))&&Hf(r,i),a=a.createElement(`link`),pt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Rd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Qf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Xf=0;function Zf(e,t){return e.stylesheets&&e.count===0&&ep(e,e.stylesheets),0Xf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Qf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ep(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var $f=null;function ep(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,$f=new Map,t.forEach(tp,e),$f=null,Qf.call(e))}function tp(e,t){if(!(t.state.loading&4)){var n=$f.get(e);if(n)var r=n.get(null);else{n=new Map,$f.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),y=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),b=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),x=e=>{let t=b(e);return t.charAt(0).toUpperCase()+t.slice(1)},S={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`},C=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},w=c(d()),T=(0,w.createContext)({}),E=()=>(0,w.useContext)(T),D=(0,w.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=E()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,w.createElement)(`svg`,{ref:c,...S,width:t??l??S.width,height:t??l??S.height,stroke:e??f,strokeWidth:m,className:v(`lucide`,p,i),...!a&&!C(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,w.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),O=(e,t)=>{let n=(0,w.forwardRef)(({className:n,...r},i)=>(0,w.createElement)(D,{ref:i,iconNode:t,className:v(`lucide-${y(x(e))}`,`lucide-${e}`,n),...r}));return n.displayName=x(e),n},k=O(`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`}]]),A=O(`align-vertical-justify-center`,[[`rect`,{width:`14`,height:`6`,x:`5`,y:`16`,rx:`2`,key:`1i8z2d`}],[`rect`,{width:`10`,height:`6`,x:`7`,y:`2`,rx:`2`,key:`ypihtt`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),j=O(`align-vertical-justify-end`,[[`rect`,{width:`14`,height:`6`,x:`5`,y:`12`,rx:`2`,key:`4l4tp2`}],[`rect`,{width:`10`,height:`6`,x:`7`,y:`2`,rx:`2`,key:`ypihtt`}],[`path`,{d:`M2 22h20`,key:`272qi7`}]]),M=O(`align-vertical-justify-start`,[[`rect`,{width:`14`,height:`6`,x:`5`,y:`16`,rx:`2`,key:`1i8z2d`}],[`rect`,{width:`10`,height:`6`,x:`7`,y:`6`,rx:`2`,key:`13squh`}],[`path`,{d:`M2 2h20`,key:`1ennik`}]]),N=O(`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`}]]),ee=O(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),P=O(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),F=O(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),I=O(`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`}]]),te=O(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),L=O(`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`}]]),ne=O(`disc`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),R=O(`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`}]]),z=O(`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`}]]),B=O(`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`}]]),re=O(`fast-forward`,[[`path`,{d:`M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z`,key:`b19h5q`}],[`path`,{d:`M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z`,key:`h7h5ge`}]]),ie=O(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),ae=O(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),oe=O(`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`}]]),se=O(`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`}]]),ce=O(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),le=O(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),ue=O(`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`}]]),de=O(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),fe=O(`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`}]]),V=O(`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`}]]),H=O(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),pe=O(`list-music`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M11 19H3`,key:`zflm78`}],[`path`,{d:`M21 16V5`,key:`yxg4q8`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),me=O(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),he=O(`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`}]]),U=O(`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`}]]),ge=O(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),_e=O(`palette`,[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`,key:`e79jfc`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}]]),ve=O(`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`}]]),ye=O(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),W=O(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),be=O(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),xe=O(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),Se=O(`repeat-1`,[[`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`}],[`path`,{d:`M11 10h1v4`,key:`70cz1p`}]]),Ce=O(`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`}]]),we=O(`rewind`,[[`path`,{d:`M12 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 12 18z`,key:`2a1g8i`}],[`path`,{d:`M22 6a2 2 0 0 0-3.414-1.414l-6 6a2 2 0 0 0 0 2.828l6 6A2 2 0 0 0 22 18z`,key:`rg3s36`}]]),Te=O(`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`}]]),Ee=O(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`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`}]]),De=O(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Oe=O(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ke=O(`shuffle`,[[`path`,{d:`m18 14 4 4-4 4`,key:`10pe0f`}],[`path`,{d:`m18 2 4 4-4 4`,key:`pucp1d`}],[`path`,{d:`M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22`,key:`1ailkh`}],[`path`,{d:`M2 6h1.972a4 4 0 0 1 3.6 2.2`,key:`km57vx`}],[`path`,{d:`M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45`,key:`os18l9`}]]),Ae=O(`skip-back`,[[`path`,{d:`M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z`,key:`15892j`}],[`path`,{d:`M3 20V4`,key:`1ptbpl`}]]),je=O(`skip-forward`,[[`path`,{d:`M21 4v16`,key:`7j8fe9`}],[`path`,{d:`M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,key:`zs4d6`}]]),Me=O(`sliders-vertical`,[[`path`,{d:`M10 8h4`,key:`1sr2af`}],[`path`,{d:`M12 21v-9`,key:`17s77i`}],[`path`,{d:`M12 8V3`,key:`13r4qs`}],[`path`,{d:`M17 16h4`,key:`h1uq16`}],[`path`,{d:`M19 12V3`,key:`o1uvq1`}],[`path`,{d:`M19 21v-5`,key:`qua636`}],[`path`,{d:`M3 14h4`,key:`bcjad9`}],[`path`,{d:`M5 10V3`,key:`cb8scm`}],[`path`,{d:`M5 21v-7`,key:`1w1uti`}]]),Ne=O(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Pe=O(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),Fe=O(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Ie=O(`strikethrough`,[[`path`,{d:`M16 4H9a3 3 0 0 0-2.83 4`,key:`43sutm`}],[`path`,{d:`M14 12a4 4 0 0 1 0 8H6`,key:`nlfj13`}],[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}]]),Le=O(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Re=O(`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`}]]),ze=O(`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`}]]),Be=O(`underline`,[[`path`,{d:`M6 4v6a6 6 0 0 0 12 0V4`,key:`9kb039`}],[`line`,{x1:`4`,x2:`20`,y1:`20`,y2:`20`,key:`nun2al`}]]),Ve=O(`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`}]]),He=O(`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`}]]),Ue=O(`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`}]]),We=O(`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`}]]),Ge=O(`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`}]]),Ke=O(`volume-x`,[[`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`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),qe=O(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Je=O(`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`}]]),Ye=O(`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`}]]),Xe=c(_(),1),Ze=function(e){return e.PLAYER=`PLAYER`,e.EDITOR=`EDITOR`,e}({}),Qe=4.5,$e=.55;function et(e){return e.text.trim()===``}function tt(e,t){return e.findIndex((n,r)=>{if(n.endTime!==void 0)return t>=n.time&&t=n.time&&(!i||t!et(e)&&e.endTime!==void 0)}function rt(e,t){for(let n=t;n>=0;n--)if(!et(e[n]))return n;return-1}function it(e,t){for(let n=t+1;ne.time>t&&!et(e))}function ot(e){return e.trim().split(/\s+/).filter(Boolean).length}function st(e,t){let n=e[t],r=it(e,t),i=r===-1?void 0:e[r].time;if(n.words&&n.words.length>0){let e=n.words[n.words.length-1].endTime;return i!==void 0&&(e=Math.min(e,i)),e}let a=ot(n.text),o=n.time+Math.max(2,a*$e);return i===void 0?o:i-n.time<=10?i:Math.min(Math.max(o,n.time+10),i)}function ct(e,t){return Math.min(e+10,t-Qe)}function lt(e,t,n){return{autoHideLyrics:!0,displayIdx:-1,virtualActiveIdx:t===-1?n:t}}function ut(e){return{autoHideLyrics:!1,displayIdx:e,virtualActiveIdx:e}}function dt(e,t,n){if(e.length===0)return-1;let r=t;if(r<0||r>=e.length||et(e[r])){let t=rt(e,r>=0?r-1:e.length-1),n=it(e,r>=0?r-1:-1);if(r=t===-1?n:t,r===-1)return-1}if(n===0)return r;let i=r,a=Math.abs(n),o=n>0;for(;a>0;){if(o){let t=it(e,i);if(t===-1)return-1;i=t}else{let t=rt(e,i-1);if(t===-1)return-1;i=t}a--}return i}function ft(e,t,n){if(n!==-1&&!et(e[n]))return ut(n);if(n!==-1&&et(e[n])){let r=e[n].time,i=rt(e,n-1);return i===-1?lt(e,it(e,n),0):t-r<2?ut(i):lt(e,it(e,n),i)}let r=at(e,t);if(r===0)return lt(e,0,0);let i=rt(e,r>0?r-1:e.length-1);if(i===-1)return lt(e,r===-1?0:r,0);let a=e[i];if(r===-1)return a.endTime!==void 0&&t>=a.endTime?lt(e,-1,i):ut(i);let o=e[r],s=a.endTime??a.time,c=o.time-s;return t>=s&&c>3?lt(e,r,i):ut(i)}function pt(e,t,n,r){let i=rt(e,e.length-1);if(r!==-1&&!et(e[r])){let a=st(e,r),o=it(e,r);if(t>=a&&o!==-1)return lt(e,o,r);if(n>0&&i!==-1&&r===i&&o===-1){let r=e[i].time;if(n-r>10&&t>=ct(r,n))return lt(e,-1,i)}return ut(r)}if(r!==-1&&et(e[r])){let n=e[r].time,i=rt(e,r-1);return i===-1?lt(e,it(e,r)===-1?0:it(e,r),0):t-n<2?ut(i):lt(e,it(e,r),i)}return lt(e,it(e,-1)===-1?0:it(e,-1),0)}function mt(e,t,n=0){let r=tt(e,t);return nt(e)?ft(e,t,r):pt(e,t,n,r)}var ht=e=>e.replace(/([\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF])\s+([\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF])/g,`$1$2`),G=e=>{if(!e)return 0;let t=e.replace(`,`,`.`).trim().split(`:`),n=0;return t.length===3?(n+=parseInt(t[0],10)*3600,n+=parseInt(t[1],10)*60,n+=parseFloat(t[2])):t.length===2?(n+=parseInt(t[0],10)*60,n+=parseFloat(t[1])):t.length===1&&(n+=parseFloat(t[0])),isNaN(n)?0:n};function gt(e){return e.length===0?e:e.map((t,n)=>{if(!t.words||t.words.length===0)return t;let r;for(let t=n+1;t{if(n`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`,vt=e=>{let t=e.split(` +`),n=[],r=/\[(\d{2}):(\d{2})(\.(\d{2,3}))?\]/g,i=/<(\d{2}):(\d{2})(\.(\d{2,3}))?>/g;return t.forEach(e=>{let t=[...e.matchAll(r)];if(t.length>0){let a=e.replace(r,``).trim();a=a.replace(/\\n/g,` +`);let o=[...a.matchAll(i)],s,c=a.replace(i,``).replace(/ +/g,` `).trim();if(o.length>0){s=[];for(let e=0;e{t&&s.push({text:t,startTime:c,endTime:0}),n{let t=parseInt(e[1],10),r=parseInt(e[2],10),i=e[4],a=t*60+r;i&&(i.length===2?a+=parseInt(i,10)/100:(i.length,a+=parseInt(i,10)/1e3)),n.push({time:a,text:c,words:s})})}}),gt(n.sort((e,t)=>e.time-t.time))},yt=e=>{let t=e.replace(/\r\n/g,` +`).replace(/\r/g,` +`).split(` + +`),n=[],r=/(\d{2}):(\d{2}):(\d{2}),(\d{3})/,i=e=>{let t=e.match(r);if(t){let e=parseInt(t[1],10),n=parseInt(t[2],10),r=parseInt(t[3],10),i=parseInt(t[4],10);return e*3600+n*60+r+i/1e3}return null};return t.forEach(e=>{let t=e.split(` +`);if(t.length>=3){let e=t[1],r=ht(t.slice(2).join(` `).trim()),a=e.split(` --> `);if(a.length>=2){let e=i(a[0]),t=i(a[1]);e!==null&&r&&n.push({time:e,text:r,endTime:t===null?void 0:t})}}}),n},bt=e=>{let t=[];try{let n=new DOMParser().parseFromString(e,`text/xml`),r=Array.from(n.getElementsByTagName(`*`)).filter(e=>e.localName===`p`),i=e=>{if(!e)return;let t=e.trim();return t.endsWith(`ms`)?parseFloat(t.slice(0,-2))/1e3:t.endsWith(`s`)?parseFloat(t.slice(0,-1)):G(t)},a=(e,t)=>{if(e.hasAttribute(t))return e.getAttribute(t);for(let n=0;ne.localName===`span`);for(let e=0;e0){let e=i(n),t=i(r);e!==void 0&&t!==void 0&&l.push({text:o,startTime:e,endTime:t})}}e!==void 0&&t.push({time:e,text:c,endTime:r,words:l.length>0?l:void 0})}}}catch(e){console.error(`Failed to parse TTML`,e)}return t.sort((e,t)=>e.time-t.time)},xt=e=>{try{let t=JSON.parse(e);if(Array.isArray(t)&&t.every(e=>typeof e==`object`&&!!e&&typeof e.time==`number`&&typeof e.text==`string`))return gt(t)}catch(e){console.warn(`Failed to parse JSON lyrics`,e)}return[]},St=e=>{let t=e.replace(/\r\n/g,` +`).replace(/\r/g,` +`).split(` +`),n=[],r=/(\d{2}:)?(\d{2}):(\d{2})\.(\d{3})/,i=e=>{let t=e.match(r);if(t){let e=t[1]?parseInt(t[1].replace(`:`,``),10):0,n=parseInt(t[2],10),r=parseInt(t[3],10),i=parseInt(t[4],10);return e*3600+n*60+r+i/1e3}return null},a=0;for(t[0]&&t[0].startsWith(`WEBVTT`)&&(a=1);a`)){let r=e.split(`-->`);if(r.length>=2){let e=r[0].trim(),o=r[1].trim().split(` `)[0],s=i(e),c=i(o);if(s!==null){a++;let e=[];for(;a`))break;e.push(t[a]),a++}if(a`),e.length>0){let t=e.join(` `).trim(),r=/<(\d{2}:)?(\d{2}):(\d{2})\.(\d{3})>/g,i,a=[...t.matchAll(r)];if(a.length>0){i=[],a.forEach((e,n)=>{let r=e[1]?parseInt(e[1].replace(`:`,``),10):0,o=parseInt(e[2],10),c=parseInt(e[3],10),l=parseInt(e[4],10),u=r*3600+o*60+c+l/1e3,d=(e.index||0)+e[0].length,f=t.length;n+10){let n=t.substring(0,e.index);n.trim()&&i.push({text:n.trim(),startTime:s,endTime:u})}p&&i.push({text:p,startTime:u,endTime:0})});for(let e=0;e/g,``).replace(/\s+/g,` `).trim());n.push({time:s,text:o,endTime:c===null?void 0:c,words:i&&i.length>0?i:void 0})}continue}}}a++}return gt(n)},Ct=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),K=o(((e,t)=>{t.exports=Ct()}))(),wt=({toast:e,onRemove:t})=>{let[n,r]=(0,w.useState)(!1);(0,w.useEffect)(()=>{let t=setTimeout(()=>{i()},e.duration||500);return()=>clearTimeout(t)},[]);let i=()=>{r(!0),setTimeout(t,300)};return(0,K.jsxs)(`div`,{className:` + flex items-center gap-3 bg-zinc-900/60 backdrop-blur-xl border ${(()=>{switch(e.type){case`success`:return`border-green-500/30`;case`error`:return`border-red-500/30`;default:return`border-blue-500/30`}})()} + text-zinc-100 px-4 py-3 rounded-xl shadow-2xl min-w-[300px] max-w-md + transition-all duration-300 transform + ${n?`opacity-0 translate-x-full`:`opacity-100 translate-x-0`} + animate-in slide-in-from-right fade-in + `,role:`alert`,children:[(0,K.jsx)(`div`,{className:`shrink-0`,children:(()=>{switch(e.type){case`success`:return(0,K.jsx)(ee,{size:18,className:`text-green-400`});case`error`:return(0,K.jsx)(I,{size:18,className:`text-red-400`});default:return(0,K.jsx)(de,{size:18,className:`text-blue-400`})}})()}),(0,K.jsx)(`p`,{className:`text-sm font-medium flex-1`,children:e.message}),(0,K.jsx)(`button`,{onClick:i,className:`text-zinc-500 hover:text-white transition-colors`,children:(0,K.jsx)(qe,{size:16})})]})},Tt=({toasts:e,removeToast:t})=>(0,K.jsx)(`div`,{className:`fixed top-4 right-4 z-[9999] flex flex-col gap-3 pointer-events-none`,children:e.map(e=>(0,K.jsx)(`div`,{className:`pointer-events-auto`,children:(0,K.jsx)(wt,{toast:e,onRemove:()=>t(e.id)})},e.id))}),Et=({isOpen:e,message:t,onConfirm:n,onCancel:r,title:i=`Confirm Action`})=>{let[a,o]=(0,w.useState)(!1);return(0,w.useEffect)(()=>{e?o(!0):setTimeout(()=>o(!1),300)},[e]),(0,w.useEffect)(()=>{let t=t=>{e&&(t.key===`Enter`?(t.preventDefault(),n()):t.key===`Escape`&&(t.preventDefault(),r()))};return e&&window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,t)}},[e,n,r]),!e&&!a?null:(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[9999] flex items-center justify-center p-4 transition-all duration-300 ${e?`opacity-100`:`opacity-0`}`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm transition-opacity`,onClick:r}),(0,K.jsxs)(`div`,{className:` + relative bg-zinc-900 border border-white/10 rounded-2xl shadow-2xl w-full max-w-md overflow-hidden transform transition-all duration-300 + ${e?`scale-100 translate-y-0`:`scale-95 translate-y-4`} + `,children:[(0,K.jsx)(`div`,{className:`p-6`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,K.jsx)(`div`,{className:`p-3 bg-orange-500/10 rounded-full shrink-0`,children:(0,K.jsx)(Re,{className:`text-orange-500`,size:24})}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-bold text-white mb-2`,children:i}),(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm leading-relaxed`,children:t})]}),(0,K.jsx)(`button`,{onClick:r,className:`text-zinc-500 hover:text-white transition-colors`,children:(0,K.jsx)(qe,{size:20})})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-3 p-4 bg-zinc-950/50 border-t border-white/5`,children:[(0,K.jsx)(`button`,{onClick:r,className:`px-4 py-2 text-sm font-medium text-zinc-400 hover:text-white hover:bg-white/5 rounded-lg transition-colors`,children:`Cancel`}),(0,K.jsx)(`button`,{onClick:n,className:`px-4 py-2 text-sm font-medium text-white bg-purple-600 hover:bg-purple-500 rounded-lg shadow-lg hover:shadow-purple-500/20 transition-all`,children:`Confirm`})]})]})]})},Dt=(0,w.createContext)(void 0),Ot=()=>{let e=(0,w.useContext)(Dt);if(!e)throw Error(`useUI must be used within a UIProvider`);return e},kt=({children:e})=>{let[t,n]=(0,w.useState)([]),r=(0,w.useCallback)((e,t,r)=>{let i,a;typeof r==`number`?i=r:typeof r==`object`&&(i=r.duration,a=r.id);let o=a||Math.random().toString(36).substr(2,9);n(n=>[...n.filter(e=>e.id!==o),{id:o,type:e,message:t,duration:i}])},[]),i=(0,w.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]),a={success:(e,t)=>r(`success`,e,t),error:(e,t)=>r(`error`,e,t),info:(e,t)=>r(`info`,e,t)},[o,s]=(0,w.useState)({isOpen:!1,message:``,title:``,resolve:null}),c=(0,w.useCallback)((e,t=`Confirm Action`)=>new Promise(n=>{s({isOpen:!0,message:e,title:t,resolve:n})}),[]),l=(0,w.useCallback)(()=>{o.resolve&&o.resolve(!0),s(e=>({...e,isOpen:!1,resolve:null}))},[o]),u=(0,w.useCallback)(()=>{o.resolve&&o.resolve(!1),s(e=>({...e,isOpen:!1,resolve:null}))},[o]);return(0,K.jsxs)(Dt.Provider,{value:{toast:a,confirm:c},children:[e,(0,K.jsx)(Tt,{toasts:t,removeToast:i}),(0,K.jsx)(Et,{isOpen:o.isOpen,message:o.message,title:o.title,onConfirm:l,onCancel:u})]})},At=e=>e>=150?.5:e>=100?1:e>=60?2:e>=40?5:e>=25?10:15,jt=(e,t)=>{let n=Math.floor(e/60),r=e%60;return t<1?`${n}:${r.toFixed(1).padStart(4,`0`)}`:`${n}:${Math.floor(r).toString().padStart(2,`0`)}`},Mt=10,Nt=50,Pt={RULER_HEIGHT:24,VISUAL_L2_TOP:32,VISUAL_L2_HEIGHT:48,VISUAL_L1_TOP:84,VISUAL_L1_HEIGHT:48,LYRICS_TOP:136,LYRICS_HEIGHT:32,AUDIO_L1_TOP:172,AUDIO_L1_HEIGHT:32,AUDIO_L2_TOP:208,AUDIO_L2_HEIGHT:32},Ft=e=>new Promise(t=>{let n=URL.createObjectURL(e),r=document.createElement(e.type.startsWith(`audio/`)?`audio`:`video`);r.preload=`metadata`,r.onloadedmetadata=()=>{t(r.duration),URL.revokeObjectURL(n)},r.onerror=()=>{URL.revokeObjectURL(n),t(0)},r.src=n}),It=({value:e,onChange:t})=>{let[n,r]=(0,w.useState)(e.toString());(0,w.useEffect)(()=>{let t=parseFloat(n);!isNaN(t)&&Math.abs(t-e)<.001||r(e.toString())},[e]);let i=()=>{let i=parseFloat(n);n===``||isNaN(i)||i<=0?r(e.toString()):t(i)},a=i=>{let a=parseFloat(n),o=Math.round(((isNaN(a)?e:a)+i)*100)/100;o<.05||(t(o),r(o.toString()))};return(0,K.jsxs)(`div`,{className:`flex items-center bg-zinc-900 rounded border border-zinc-700 h-[18px]`,children:[(0,K.jsx)(`button`,{onClick:()=>a(-.05),className:`px-0.5 hover:bg-zinc-700 text-zinc-400 hover:text-white transition-colors h-full flex items-center justify-center border-r border-zinc-700`,children:(0,K.jsx)(P,{size:10})}),(0,K.jsx)(`input`,{type:`text`,name:`speed-input`,"aria-label":`Speed Input`,className:`bg-transparent text-[10px] text-zinc-300 focus:outline-none w-10 text-center`,value:n,onChange:e=>{/^\d*\.?\d*$/.test(e.target.value)&&r(e.target.value)},onBlur:i,onKeyDown:e=>{e.stopPropagation(),e.key===`ArrowUp`&&(e.preventDefault(),a(.05)),e.key===`ArrowDown`&&(e.preventDefault(),a(-.05)),e.key===`Enter`&&e.currentTarget.blur()}}),(0,K.jsx)(`button`,{onClick:()=>a(.05),className:`px-0.5 hover:bg-zinc-700 text-zinc-400 hover:text-white transition-colors h-full flex items-center justify-center border-l border-zinc-700`,children:(0,K.jsx)(F,{size:10})})]})},Lt=({slides:e,setSlides:t,currentTime:n,duration:r,lyrics:i,onSeek:a,onClose:o,renderConfig:s,setRenderConfig:c})=>{let{confirm:l,toast:u}=Ot(),d=(0,w.useRef)(null),f=(0,w.useRef)(null),p=(0,w.useRef)(null),[m,h]=(0,w.useState)(40),[g,_]=(0,w.useState)([]),[v,y]=(0,w.useState)(null),[b,x]=(0,w.useState)([]),[S,C]=(0,w.useState)(null),[T,E]=(0,w.useState)(!1),[D,O]=(0,w.useState)(null),[k,A]=(0,w.useState)([{slides:e,selection:[]}]),[j,M]=(0,w.useState)(0),N=(0,w.useRef)(!1),[ee,P]=(0,w.useState)([]);(0,w.useEffect)(()=>{if(N.current){N.current=!1;return}if(S||T)return;let t=k[j],n={slides:e,selection:g};if(JSON.stringify(t)!==JSON.stringify(n)){let e=k.slice(0,j+1);e.push(n),e.length>Nt?(e.shift(),A(e)):(A(e),M(j+1))}},[e,g,k,j,S,T]);let F=j>0,I=j{if(j>0){let e=j-1;M(e),N.current=!0,t(k[e].slides),_(k[e].selection)}},[t,_,k,j]),R=(0,w.useCallback)(()=>{if(je.endTime)),ie=Math.max(r,60,re),ae=ie*m,se=(0,w.useCallback)(()=>{if(g.length===0)return;let t=e.filter(e=>g.includes(e.id));x(t),u.success(`Copied ${t.length} items`)},[g,e,u]),le=(0,w.useCallback)(()=>{if(g.length===0)return;let n=e.filter(e=>g.includes(e.id));x(n),t(e=>e.filter(e=>!g.includes(e.id))),_([]),u.success(`Cut ${n.length} items`)},[g,e,t,u]),ue=(0,w.useRef)(e),de=(0,w.useRef)(m);(0,w.useEffect)(()=>{ue.current=e,de.current=m},[e,m]);let fe=(0,w.useCallback)(()=>{if(b.length===0)return;let e=n-Math.min(...b.map(e=>e.startTime)),r=b.map(t=>({...t,id:Math.random().toString(36).substr(2,9),startTime:t.startTime+e,endTime:t.endTime+e}));t(e=>[...e,...r].sort((e,t)=>e.startTime-t.startTime)),_(r.map(e=>e.id)),u.success(`Pasted ${r.length} items`)},[b,n,t,u]),V=(0,w.useCallback)(()=>{let r=e.filter(e=>g.includes(e.id)&&n>e.startTime&&n{let t=n,r={...e,id:Math.random().toString(36).substr(2,9),endTime:t},s=t-e.startTime,c={...e,id:Math.random().toString(36).substr(2,9),startTime:t,mediaStartOffset:(e.mediaStartOffset||0)+s};a.push(e.id),i.push(r,c),o.push(c.id)}),t(e=>[...e.filter(e=>!a.includes(e.id)),...i].sort((e,t)=>e.startTime-t.startTime)),_(o),u.success(`Split ${r.length} items`)},[e,g,n,t,u]),H=async e=>{if(e.target.files&&e.target.files.length>0){let i=Array.from(e.target.files),a=i.every(e=>e.type.startsWith(`image/`)),o=[];if(a){let e=i.length,t=n,a=Math.max(0,r-t)/e,s=Math.max(3,a);i.forEach((e,n)=>{let r=URL.createObjectURL(e),i=t+n*s,a=i+s;o.push({id:Math.random().toString(36).substr(2,9),url:r,type:`image`,startTime:i,endTime:a,name:e.name,layer:0})})}else{let e=n;for(let t of i){let n=t.type.startsWith(`image/`)?`image`:t.type.startsWith(`video/`)?`video`:`audio`,r=5;if(n!==`image`){let e=await Ft(t);e>0&&(r=e)}let i=URL.createObjectURL(t);o.push({id:Math.random().toString(36).substr(2,9),url:i,type:n,startTime:e,endTime:e+r,mediaDuration:n===`image`?void 0:r,name:t.name,isMuted:n===`video`,volume:n===`video`||n===`audio`?1:void 0,layer:0}),e+=r}}t(e=>[...e,...o].sort((e,t)=>e.startTime-t.startTime)),e.target.value=``}},pe=e=>{t(t=>t.filter(t=>t.id!==e))},me=async n=>{n.stopPropagation(),e.length!==0&&await l(`Are you sure you want to remove all visual slides?`,`Remove All Slides`)&&t([])},he=(t,n,r)=>{if(t.stopPropagation(),t.preventDefault(),d.current?.focus(),t.shiftKey&&v){let t=e.findIndex(e=>e.id===v),r=e.findIndex(e=>e.id===n);if(t!==-1&&r!==-1){let n=Math.min(t,r),i=Math.max(t,r),a=e.slice(n,i+1).map(e=>e.id);_(e=>{let t=new Set([...e,...a]);return Array.from(t)})}}else t.ctrlKey||t.metaKey?(_(e=>e.includes(n)?e.filter(e=>e!==n):[...e,n]),y(n)):(g.includes(n)||_([n]),y(n));let i=e.find(e=>e.id===n);if(!i)return;let a=g.includes(n),o=t.ctrlKey||t.metaKey||t.shiftKey,s=[];if(!o&&!a)s=[n];else if(o){if(s=[n],(t.ctrlKey||t.metaKey)&&!a)s=[...g,n];else if((t.ctrlKey||t.metaKey)&&a){s=g.filter(e=>e!==n);return}}else s=g;let c={};e.forEach(e=>{s.includes(e.id)&&(c[e.id]={start:e.startTime,end:e.endTime})}),c[n]||(c[n]={start:i.startTime,end:i.endTime}),C({id:n,type:r,startX:t.clientX,initialStart:i.startTime,initialEnd:i.endTime,initialMap:c}),window.addEventListener(`mousemove`,Ce),window.addEventListener(`mouseup`,we)},U=e=>{e.button===0&&(e.stopPropagation(),d.current?.focus(),_([]),E(!0),_e(e.clientX),window.addEventListener(`mousemove`,ve),window.addEventListener(`mouseup`,ye))},ge=e=>{if(e.button!==0)return;d.current?.focus();let t=e.clientX,n=e.clientY,r=p.current?.getBoundingClientRect();if(!r)return;let i=t-r.left,a=n-r.top,o=!1,s=e=>{let r=Math.sqrt((e.clientX-t)**2+(e.clientY-n)**2);if(!o&&r>5&&(o=!0,O({x:i,y:a,w:0,h:0})),o&&p.current){let t=p.current.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;O(e=>{if(!e)return null;let t=n-i,o=r-a;return{x:t>0?i:n,y:o>0?a:r,w:Math.abs(t),h:Math.abs(o)}});let o=[],s=ue.current,c=de.current,l=Math.min(i,n),u=Math.min(a,r),d=Math.abs(n-i),f=Math.abs(r-a),m=l+d,h=u+f;s.forEach(e=>{let t=e.startTime*c+96,n=e.endTime*c+96,r=0,i=0,a=e.layer||0;e.type===`audio`?a===0?(r=Pt.AUDIO_L1_TOP,i=Pt.AUDIO_L1_TOP+Pt.AUDIO_L1_HEIGHT):(r=Pt.AUDIO_L2_TOP,i=Pt.AUDIO_L2_TOP+Pt.AUDIO_L2_HEIGHT):a===0?(r=Pt.VISUAL_L1_TOP,i=Pt.VISUAL_L1_TOP+Pt.VISUAL_L1_HEIGHT):(r=Pt.VISUAL_L2_TOP,i=Pt.VISUAL_L2_TOP+Pt.VISUAL_L2_HEIGHT),lt&&ur&&o.push(e.id)}),_(o)}},c=e=>{o||(_([]),_e(e.clientX)),O(null),window.removeEventListener(`mousemove`,s),window.removeEventListener(`mouseup`,c)};window.addEventListener(`mousemove`,s),window.addEventListener(`mouseup`,c)},_e=e=>{if(!p.current)return;let t=e-p.current.getBoundingClientRect().left-96,n=Math.max(0,Math.min(t/m,ie));n=Se(n),a(n)},ve=e=>{_e(e.clientX)},ye=()=>{E(!1),window.removeEventListener(`mousemove`,ve),window.removeEventListener(`mouseup`,ye)},W=n=>{let r=n.target;if(!(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable)){if((n.ctrlKey||n.metaKey)&&n.key===`z`&&!n.shiftKey){n.preventDefault(),ne();return}if((n.ctrlKey||n.metaKey)&&(n.key===`y`||n.key===`z`&&n.shiftKey)){n.preventDefault(),R();return}if((n.ctrlKey||n.metaKey)&&n.key===`c`){n.preventDefault(),se();return}if((n.ctrlKey||n.metaKey)&&n.key===`x`){n.preventDefault(),le();return}if((n.ctrlKey||n.metaKey)&&n.key===`v`){n.preventDefault(),fe();return}if(n.key.toLowerCase()===`x`&&!n.ctrlKey&&!n.metaKey||(n.ctrlKey||n.metaKey)&&n.key===`k`){n.preventDefault(),n.stopPropagation(),V();return}if((n.key===`Delete`||n.key===`Backspace`)&&g.length>0&&(n.preventDefault(),t(e=>e.filter(e=>!g.includes(e.id))),_([])),g.length>0&&(n.key===`ArrowLeft`||n.key===`ArrowRight`)){if(n.ctrlKey||n.metaKey||n.altKey)return;n.preventDefault(),n.stopPropagation();let r=n.key===`ArrowRight`?.01:-.01,i=e.find(e=>e.id===g[0]);i&&a(Math.max(0,i.startTime+r)),t(e=>e.map(e=>{if(g.includes(e.id)){let t=e.endTime-e.startTime,n=e.startTime+r;return n=Math.max(0,n),{...e,startTime:n,endTime:n+t}}return e}).sort((e,t)=>e.startTime-t.startTime))}}},Se=(t,a=[])=>{let o=Mt/m,s=[0,r,n],c=At(m),l=Math.round(t/c)*c;s.push(l),e.forEach(e=>{a.includes(e.id)||(s.push(e.startTime),s.push(e.endTime))}),i.forEach(e=>{s.push(e.time)});let u=t,d=o;for(let e of s){let n=Math.abs(e-t);n{C(o=>{if(!o)return null;let s=(a.clientX-o.startX)/m,c=[];return t(t=>{if(o.type===`move`){let l=Object.keys(o.initialMap),u=Object.values(o.initialMap),d=Math.min(...u.map(e=>e.start)),f=Math.max(...u.map(e=>e.end)),h=o.initialMap[o.id],g=[{type:`drag-start`,initVal:h.start,ref:`start`},{type:`drag-end`,initVal:h.end,ref:`end`},{type:`group-start`,initVal:d,ref:`start`},{type:`group-end`,initVal:f,ref:`end`}],_=Mt/m,v=[0,r,n],y=At(m);e.forEach(e=>{l.includes(e.id)||(v.push(e.startTime),v.push(e.endTime))}),i.forEach(e=>{v.push(e.time)});let b=s,x=_,S=!1,C=-1;g.forEach(e=>{let t=e.initVal+s;for(let n of v){let r=Math.abs(n-t);r{let t=o.initialMap[e.id];if(t){let n=t.end-t.start,r=e.layer||0,i=p.current?.getBoundingClientRect();if(i){let t=a.clientY-i.top,n=(e,t,n)=>e>=t-10&&e<=t+n+10;e.type===`audio`?n(t,Pt.AUDIO_L1_TOP,Pt.AUDIO_L1_HEIGHT)?r=0:n(t,Pt.AUDIO_L2_TOP,Pt.AUDIO_L2_HEIGHT)&&(r=1):n(t,Pt.VISUAL_L1_TOP,Pt.VISUAL_L1_HEIGHT)?r=0:n(t,Pt.VISUAL_L2_TOP,Pt.VISUAL_L2_HEIGHT)&&(r=1)}return{...e,startTime:t.start+w,endTime:t.start+w+n,layer:r}}return e})}else if(o.type===`resize-start`){let e=o.initialStart+s,n=Se(e,[o.id]);Math.abs(n-e)>1e-4&&(c=[n]),e=n;let r=o.initialEnd;return e=Math.max(0,Math.min(e,r-.5)),e===0&&(c=[0]),t.map(t=>t.id===o.id?{...t,startTime:e}:t)}else{let e=o.initialEnd+s,n=Se(e,[o.id]);Math.abs(n-e)>1e-4&&(c=[n]),e=n;let r=o.initialStart;return e=Math.max(r+.5,e),t.map(t=>t.id===o.id?{...t,endTime:e}:t)}}),P(c),o})},we=e=>{S&&S.type===`move`&&Math.abs(e.clientX-S.startX)<5&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&_([S.id]),C(null),P([]),window.removeEventListener(`mousemove`,Ce),window.removeEventListener(`mouseup`,we),t(e=>[...e].sort((e,t)=>e.startTime-t.startTime))},De=()=>h(e=>Math.min(200,e+10)),Oe=()=>h(e=>Math.max(10,e-10)),ke=(e,t)=>{c(n=>{let r=n.layerVisibility?.[e]||{},i={...r,[t]:r[t]===!1};return{...n,layerVisibility:{...n.layerVisibility,[e]:i,...e===`visual`?{audio:n.layerVisibility?.audio||{}}:{visual:n.layerVisibility?.visual||{}}}}})},Ae=(e,t)=>s.layerVisibility?.[e]?.[t]!==!1;return(0,K.jsxs)(`div`,{ref:d,className:`w-full max-w-full h-64 flex flex-col bg-zinc-900/95 backdrop-blur-md border-t border-white/10 z-20 shadow-xl outline-none overflow-hidden min-w-0`,tabIndex:0,onMouseDown:e=>e.currentTarget.focus(),onKeyDown:W,children:[(0,K.jsxs)(`div`,{className:`p-2 border-b border-white/10 flex items-center justify-between bg-zinc-900 z-30 shrink-0 h-12`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0 overflow-x-auto no-scrollbar pr-4`,children:[(0,K.jsxs)(`h2`,{className:`text-sm font-bold flex items-center gap-2 text-zinc-300 whitespace-nowrap`,children:[(0,K.jsx)(oe,{size:16,className:`text-purple-400`}),`Timeline`]}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 px-3 py-1 bg-purple-600 hover:bg-purple-500 rounded text-xs font-medium cursor-pointer transition-colors text-white whitespace-nowrap`,children:[(0,K.jsx)(be,{size:14}),` Import Media`,(0,K.jsx)(`input`,{type:`file`,name:`import-media`,id:`import-media`,className:`hidden`,accept:`image/*,video/*,audio/*`,multiple:!0,onChange:H})]}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:Oe,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white`,title:`Zoom Out`,children:(0,K.jsx)(Ye,{size:14})}),(0,K.jsxs)(`div`,{className:`text-[10px] text-zinc-500 font-mono min-w-[50px] text-center`,children:[m,`px/s`]}),(0,K.jsx)(`button`,{onClick:De,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white`,title:`Zoom In`,children:(0,K.jsx)(Je,{size:14})})]}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:ne,disabled:!F,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Undo (Ctrl+Z)`,children:(0,K.jsx)(Ve,{size:14})}),(0,K.jsx)(`button`,{onClick:R,disabled:!I,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Redo (Ctrl+Y)`,children:(0,K.jsx)(xe,{size:14})})]}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:se,disabled:g.length===0,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Copy (Ctrl+C)`,children:(0,K.jsx)(L,{size:14})}),(0,K.jsx)(`button`,{onClick:le,disabled:g.length===0,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Cut (Ctrl+X)`,children:(0,K.jsx)(Ee,{size:14})}),(0,K.jsx)(`button`,{onClick:fe,disabled:b.length===0,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Paste (Ctrl+V)`,children:(0,K.jsx)(te,{size:14})})]}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,K.jsx)(`button`,{onClick:V,disabled:g.length===0,className:`p-1 hover:bg-zinc-700 rounded text-zinc-400 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Split Content (X)`,children:(0,K.jsx)(Pe,{size:14})})}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>{e.length>0&&g.length===e.length?_([]):_(e.map(e=>e.id))},className:`px-2 py-0.5 text-[10px] bg-zinc-800 hover:bg-zinc-700 border border-zinc-700 rounded text-zinc-300 transition-colors`,children:`Select All`}),g.length===1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-zinc-800 rounded px-1 border border-zinc-700`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 px-1`,children:`Dur:`}),(0,K.jsx)(`input`,{type:`text`,name:`duration-input`,"aria-label":`Slide Duration`,className:`w-12 bg-transparent text-[10px] text-white font-mono focus:outline-none py-0.5 text-center`,placeholder:`MM:SS`,defaultValue:(()=>{let t=e.find(e=>e.id===g[0]);return t?_t(t.endTime-t.startTime):`00:00`})(),onBlur:n=>{let r=n.target.value.split(`:`);if(r.length===2){let e=parseInt(r[0])||0,n=parseInt(r[1])||0,i=e*60+n;i>0&&t(e=>e.map(e=>e.id===g[0]?{...e,endTime:e.startTime+i}:e))}let i=e.find(e=>e.id===g[0]);i&&(n.target.value=_t(i.endTime-i.startTime))},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}},g[0])]}),g.length===1&&(()=>{let n=e.find(e=>e.id===g[0]);return n&&(n.type===`video`||n.type===`audio`)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 rounded px-2 border border-zinc-700 h-[22px]`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`Vol:`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 w-20`,children:[(0,K.jsx)(`button`,{onClick:()=>{t(e=>e.map(e=>e.id===n.id?{...e,isMuted:!e.isMuted}:e))},className:`p-0.5 hover:bg-zinc-700 rounded cursor-pointer text-zinc-400 hover:text-white`,title:n.isMuted===!1?`Mute`:`Unmute`,children:n.isMuted===!1?(0,K.jsx)(Ge,{size:10}):(0,K.jsx)(Ke,{size:10})}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,name:`volume-input`,"aria-label":`Volume Level`,className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer`,value:n.volume===void 0?1:n.volume,onChange:e=>{let r=parseFloat(e.target.value);t(e=>e.map(e=>e.id===n.id?{...e,volume:r,isMuted:r===0}:e))}})]}),(0,K.jsxs)(`span`,{className:`text-[9px] text-zinc-400 w-6 text-right`,children:[Math.round((n.volume||1)*100),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`Spd:`}),(0,K.jsx)(It,{value:n.playbackRate||1,onChange:e=>{t(t=>t.map(t=>{if(t.id===n.id){let n=t.playbackRate||1,r=(t.endTime-t.startTime)*(n/e);return{...t,playbackRate:e,endTime:t.startTime+r}}return t}))}})]})]}):null})()]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,K.jsx)(`button`,{onClick:me,className:`p-1 hover:bg-red-900/50 text-zinc-500 hover:text-red-200 rounded transition-colors`,title:`Clear All Slides`,children:(0,K.jsx)(Le,{size:14})}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700 mx-1 self-center`}),(0,K.jsx)(`button`,{onClick:o,className:`p-1 hover:bg-zinc-700 text-zinc-400 hover:text-white rounded transition-colors`,title:`Close Timeline`,children:(0,K.jsx)(qe,{size:14})})]})]}),(0,K.jsx)(`div`,{ref:f,onWheel:e=>{f.current&&e.shiftKey&&(e.preventDefault(),f.current.scrollLeft+=e.deltaY)},className:`flex-1 overflow-x-auto overflow-y-auto relative bg-zinc-950 scroll-smooth custom-scrollbar cursor-default`,children:(0,K.jsxs)(`div`,{ref:p,className:`relative`,style:{width:`${ae+96}px`,minWidth:`100%`,height:`max(100%, 280px)`},onMouseDown:ge,children:[D&&(0,K.jsx)(`div`,{className:`absolute border border-purple-500 bg-purple-500/20 z-50 pointer-events-none`,style:{left:D.x,top:D.y,width:D.w,height:D.h}}),ee.map((e,t)=>(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-yellow-400 z-[60] shadow-[0_0_8px_rgba(250,204,21,0.6)]`,style:{left:e*m}},`snap-${t}`)),(0,K.jsxs)(`div`,{className:`absolute top-0 bottom-0 left-[96px] right-0 pointer-events-none z-0`,children:[(()=>{let e=At(m);return Array.from({length:Math.ceil(ae/(m*e))}).map((t,n)=>(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l border-white/5`,style:{left:n*e*m}},n))})(),r>0&&(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 border-l-2 border-red-900/50 flex flex-col justify-end z-0`,style:{left:r*m},children:(0,K.jsx)(`span`,{className:`text-[9px] text-red-900/50 bg-black/50 px-1 whitespace-nowrap`,children:`End`})})]}),(0,K.jsxs)(`div`,{className:`sticky top-0 left-0 right-0 h-6 border-b border-white/10 bg-zinc-900/90 backdrop-blur-sm select-none cursor-pointer z-[60] flex`,onMouseDown:U,children:[(0,K.jsx)(`div`,{className:`w-[96px] shrink-0 border-r border-white/10 flex items-center justify-center text-[10px] text-zinc-500 bg-zinc-900/90`,children:`Time`}),(0,K.jsx)(`div`,{className:`relative flex-1`,children:(()=>{let e=At(m);return Array.from({length:Math.ceil(ae/(m*e))}).map((t,n)=>{let r=n*e;return r>ie?null:(0,K.jsx)(`div`,{className:`absolute bottom-0 border-l border-white/20 text-[9px] text-zinc-500 font-mono pl-1 pb-0.5 pointer-events-none`,style:{left:r*m,width:e*m},children:jt(r,e)},n)})})()})]}),(0,K.jsx)(`div`,{className:`absolute top-6 bottom-0 w-px bg-red-500 z-50 pointer-events-none`,style:{left:`96px`,transform:`translateX(${n*m}px)`,willChange:`transform`},children:(0,K.jsx)(`div`,{className:`absolute -top-1.5 -left-1.5 w-3 h-3 bg-red-500 rotate-45 transform origin-center shadow-sm`})}),(0,K.jsxs)(`div`,{className:`absolute left-0 right-0 border-b border-white/5 bg-zinc-900/20`,style:{top:Pt.VISUAL_L1_TOP,height:Pt.VISUAL_L1_HEIGHT},children:[(0,K.jsxs)(`div`,{className:`sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm`,children:[(0,K.jsx)(`span`,{children:`Visual 1`}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ke(`visual`,0)},className:`p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors`,children:Ae(`visual`,0)?(0,K.jsx)(B,{size:12}):(0,K.jsx)(z,{size:12,className:`text-zinc-600`})})]}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ae(`visual`,0)?``:`opacity-30 grayscale pointer-events-none`}`,children:e.filter(e=>e.type!==`audio`&&(e.layer===0||e.layer===void 0)).map(e=>(0,K.jsxs)(`div`,{style:{left:e.startTime*m,width:Math.max(10,(e.endTime-e.startTime)*m)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-zinc-800 border shadow-sm select-none cursor-move + ${S?.id===e.id||g.includes(e.id)?`border-purple-400 z-30 shadow-xl opacity-90`:`border-zinc-600 hover:border-zinc-400 z-10 hover:z-20`} + ${g.includes(e.id)?`ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950`:``} + `,onMouseDown:t=>he(t,e.id,`move`),children:[e.type===`video`?(0,K.jsx)(`video`,{src:e.url,className:`w-full h-full object-cover opacity-60 pointer-events-none`,muted:!0}):(0,K.jsx)(`img`,{src:e.url,className:`w-full h-full object-cover opacity-60 pointer-events-none`,draggable:!1,alt:e.name}),(0,K.jsx)(`div`,{className:`absolute inset-0 p-1 pointer-events-none flex flex-col justify-end`,children:(0,K.jsx)(`span`,{className:`text-[10px] font-bold drop-shadow-md truncate text-zinc-200 bg-black/30 px-1 rounded w-max max-w-full`,children:e.name})}),(S?.id===e.id||g.includes(e.id))&&(0,K.jsx)(`div`,{className:`absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none`,children:_t(e.startTime)}),e.type===`video`&&e.mediaDuration&&(Math.abs(e.endTime-e.startTime-e.mediaDuration)>.1||e.playbackRate!==void 0&&Math.abs(e.playbackRate-1)>.01)&&(0,K.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(t=>t.map(t=>t.id===e.id&&t.mediaDuration?{...t,endTime:t.startTime+t.mediaDuration,playbackRate:1}:t))},className:`absolute top-1 left-12 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,title:`Reset to Original Duration`,children:(0,K.jsx)(Te,{size:10})}),e.type===`video`&&(0,K.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(t=>t.map(t=>t.id===e.id?{...t,isMuted:!t.isMuted}:t))},className:`absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,title:e.isMuted===!1?`Mute`:`Unmute`,children:e.isMuted===!1?(0,K.jsx)(Ge,{size:10}):(0,K.jsx)(Ke,{size:10})}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),pe(e.id)},className:`absolute top-1 right-4 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-30`,children:(0,K.jsx)(qe,{size:10})}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-0 w-3 cursor-w-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-start`),children:(0,K.jsx)(ce,{size:10,className:`text-white/70 rotate-90`})}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 right-0 w-3 cursor-e-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-end`),children:(0,K.jsx)(ce,{size:10,className:`text-white/70 rotate-90`})})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`absolute left-0 right-0 border-b border-white/5 bg-zinc-900/20`,style:{top:Pt.VISUAL_L2_TOP,height:Pt.VISUAL_L2_HEIGHT},children:[(0,K.jsxs)(`div`,{className:`sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm`,children:[(0,K.jsx)(`span`,{children:`Visual 2`}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ke(`visual`,1)},className:`p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors`,children:Ae(`visual`,1)?(0,K.jsx)(B,{size:12}):(0,K.jsx)(z,{size:12,className:`text-zinc-600`})})]}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ae(`visual`,1)?``:`opacity-30 grayscale pointer-events-none`}`,children:e.filter(e=>e.type!==`audio`&&e.layer===1).map(e=>(0,K.jsxs)(`div`,{style:{left:e.startTime*m,width:Math.max(10,(e.endTime-e.startTime)*m)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-zinc-800 border shadow-sm select-none cursor-move + ${S?.id===e.id||g.includes(e.id)?`border-purple-400 z-30 shadow-xl opacity-90`:`border-zinc-600 hover:border-zinc-400 z-10 hover:z-20`} + ${g.includes(e.id)?`ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950`:``} + `,onMouseDown:t=>he(t,e.id,`move`),children:[e.type===`video`?(0,K.jsx)(`video`,{src:e.url,className:`w-full h-full object-cover opacity-60 pointer-events-none`,muted:!0}):(0,K.jsx)(`img`,{src:e.url,className:`w-full h-full object-cover opacity-60 pointer-events-none`,draggable:!1,alt:e.name}),(0,K.jsx)(`div`,{className:`absolute inset-0 p-1 pointer-events-none flex flex-col justify-end`,children:(0,K.jsx)(`span`,{className:`text-[10px] font-bold drop-shadow-md truncate text-zinc-200 bg-black/30 px-1 rounded w-max max-w-full`,children:e.name})}),(S?.id===e.id||g.includes(e.id))&&(0,K.jsx)(`div`,{className:`absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none`,children:_t(e.startTime)}),e.type===`video`&&e.mediaDuration&&(Math.abs(e.endTime-e.startTime-e.mediaDuration)>.1||e.playbackRate!==void 0&&Math.abs(e.playbackRate-1)>.01)&&(0,K.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(t=>t.map(t=>t.id===e.id&&t.mediaDuration?{...t,endTime:t.startTime+t.mediaDuration,playbackRate:1}:t))},className:`absolute top-1 left-12 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,title:`Reset to Original Duration`,children:(0,K.jsx)(Te,{size:10})}),e.type===`video`&&(0,K.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(t=>t.map(t=>t.id===e.id?{...t,isMuted:!t.isMuted}:t))},className:`absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-zinc-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,children:e.isMuted===!1?(0,K.jsx)(Ge,{size:10}):(0,K.jsx)(Ke,{size:10})}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),pe(e.id)},className:`absolute top-1 right-4 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-30`,children:(0,K.jsx)(qe,{size:10})}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-0 w-3 cursor-w-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-start`),children:(0,K.jsx)(ce,{size:10,className:`text-white/70 rotate-90`})}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 right-0 w-3 cursor-e-resize flex items-center justify-center bg-black/20 hover:bg-purple-500/80 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-end`),children:(0,K.jsx)(ce,{size:10,className:`text-white/70 rotate-90`})})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`absolute left-0 right-0 overflow-hidden`,style:{top:Pt.LYRICS_TOP,height:Pt.LYRICS_HEIGHT},children:[(0,K.jsx)(`div`,{className:`sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center px-2 text-[10px] text-zinc-400 backdrop-blur-sm select-none`,children:(0,K.jsx)(`span`,{children:`Lyrics`})}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-[96px] right-0 pointer-events-none`,children:i.map((e,t)=>(0,K.jsxs)(`div`,{className:`absolute top-1 bottom-1 text-[10px] text-zinc-400 truncate hover:text-white transition-colors hover:bg-zinc-800/50 rounded px-2 cursor-pointer border-l border-zinc-700 flex items-center whitespace-nowrap pointer-events-auto`,style:{left:e.time*m},title:`${_t(e.time)} - ${e.text}`,onClick:t=>{t.stopPropagation(),a(e.time)},children:[(0,K.jsx)(`span`,{className:`mr-1 text-zinc-600 font-mono text-[9px]`,children:_t(e.time)}),e.text]},t))})]}),(0,K.jsxs)(`div`,{className:`absolute left-0 right-0 border-t border-white/5 bg-zinc-900/40`,style:{top:Pt.AUDIO_L1_TOP,height:Pt.AUDIO_L1_HEIGHT},children:[(0,K.jsxs)(`div`,{className:`sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm`,children:[(0,K.jsx)(`span`,{children:`Audio 1`}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ke(`audio`,0)},className:`p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors`,children:Ae(`audio`,0)?(0,K.jsx)(B,{size:12}):(0,K.jsx)(z,{size:12,className:`text-zinc-600`})})]}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ae(`audio`,0)?``:`opacity-30 grayscale pointer-events-none`}`,children:e.filter(e=>e.type===`audio`&&(e.layer===0||e.layer===void 0)).map(e=>(0,K.jsxs)(`div`,{style:{left:e.startTime*m,width:Math.max(10,(e.endTime-e.startTime)*m)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-emerald-900/50 border shadow-sm select-none cursor-move + ${S?.id===e.id||g.includes(e.id)?`border-emerald-400 z-30 shadow-xl opacity-90`:`border-emerald-700/50 hover:border-emerald-500 z-10 hover:z-20`} + ${g.includes(e.id)?`ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950`:``} + `,onMouseDown:t=>he(t,e.id,`move`),children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center opacity-30`,children:(0,K.jsx)(Ge,{size:16,className:`text-emerald-200`})}),(0,K.jsx)(`div`,{className:`absolute inset-0 p-1 pointer-events-none flex flex-col justify-center`,children:(0,K.jsx)(`span`,{className:`text-[9px] font-bold drop-shadow-md truncate text-emerald-100 px-1`,children:e.name})}),(S?.id===e.id||g.includes(e.id))&&(0,K.jsx)(`div`,{className:`absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none`,children:_t(e.startTime)}),(0,K.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(t=>t.map(t=>t.id===e.id?{...t,isMuted:!t.isMuted}:t))},className:`absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-emerald-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,title:e.isMuted===!0?`Unmute`:`Mute`,children:e.isMuted===!0?(0,K.jsx)(Ke,{size:10}):(0,K.jsx)(Ge,{size:10})}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),pe(e.id)},className:`absolute top-1 right-3 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,children:(0,K.jsx)(qe,{size:10})}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-0 w-2 cursor-w-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-start`)}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 right-0 w-2 cursor-e-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-end`)})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`absolute left-0 right-0 border-t border-white/5 bg-zinc-900/40`,style:{top:Pt.AUDIO_L2_TOP,height:Pt.AUDIO_L2_HEIGHT},children:[(0,K.jsxs)(`div`,{className:`sticky left-0 w-[96px] h-full bg-zinc-900/90 border-r border-white/10 z-30 flex items-center justify-between px-2 text-[10px] text-zinc-400 backdrop-blur-sm`,children:[(0,K.jsx)(`span`,{children:`Audio 2`}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ke(`audio`,1)},className:`p-1 hover:text-white hover:bg-zinc-700 rounded transition-colors`,children:Ae(`audio`,1)?(0,K.jsx)(B,{size:12}):(0,K.jsx)(z,{size:12,className:`text-zinc-600`})})]}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-[96px] right-0 ${Ae(`audio`,1)?``:`opacity-30 grayscale pointer-events-none`}`,children:e.filter(e=>e.type===`audio`&&e.layer===1).map(e=>(0,K.jsxs)(`div`,{style:{left:e.startTime*m,width:Math.max(10,(e.endTime-e.startTime)*m)},className:`absolute top-1 bottom-1 rounded-md overflow-hidden group bg-emerald-900/50 border shadow-sm select-none cursor-move + ${S?.id===e.id||g.includes(e.id)?`border-emerald-400 z-30 shadow-xl opacity-90`:`border-emerald-700/50 hover:border-emerald-500 z-10 hover:z-20`} + ${g.includes(e.id)?`ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950`:``} + `,onMouseDown:t=>he(t,e.id,`move`),children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center opacity-30`,children:(0,K.jsx)(Ge,{size:16,className:`text-emerald-200`})}),(0,K.jsx)(`div`,{className:`absolute inset-0 p-1 pointer-events-none flex flex-col justify-center`,children:(0,K.jsx)(`span`,{className:`text-[9px] font-bold drop-shadow-md truncate text-emerald-100 px-1`,children:e.name})}),(S?.id===e.id||g.includes(e.id))&&(0,K.jsx)(`div`,{className:`absolute top-0 left-0 bg-black/80 text-white text-[9px] px-1.5 py-0.5 rounded-br font-mono z-50 pointer-events-none`,children:_t(e.startTime)}),(0,K.jsx)(`button`,{onClick:n=>{n.stopPropagation(),t(t=>t.map(t=>t.id===e.id?{...t,isMuted:!t.isMuted}:t))},className:`absolute top-1 right-10 p-0.5 bg-black/60 hover:bg-emerald-600 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,title:e.isMuted===!0?`Unmute`:`Mute`,children:e.isMuted===!0?(0,K.jsx)(Ke,{size:10}):(0,K.jsx)(Ge,{size:10})}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),pe(e.id)},className:`absolute top-1 right-3 p-0.5 bg-black/60 hover:bg-red-500 rounded text-white opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer z-40`,children:(0,K.jsx)(qe,{size:10})}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 left-0 w-2 cursor-w-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-start`)}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 right-0 w-2 cursor-e-resize flex items-center justify-center hover:bg-emerald-500/50 transition-colors z-20`,onMouseDown:t=>he(t,e.id,`resize-end`)})]},e.id))})]})]})})]})},Rt=void 0,zt=void 0;function Bt(){return{geminiUrl:Rt,vertexUrl:zt}}function Vt(e,t,n,r){if(!e?.baseUrl){let e=Bt();return t?e.vertexUrl??n:e.geminiUrl??r}return e.baseUrl}var Ht=class{};function q(e,t){return e.replace(/\{([^}]+)\}/g,(e,n)=>{if(Object.prototype.hasOwnProperty.call(t,n)){let e=t[n];return e==null?``:String(e)}else throw Error(`Key '${n}' not found in valueMap.`)})}function J(e,t,n){for(let r=0;r({}));else throw Error(`Value must be a list given an array path ${i}`);if(Array.isArray(e[a])){let i=e[a];if(Array.isArray(n))for(let e=0;eY(e,t.slice(r+1),n)):n}else return n}else e=e[i]}return e}catch(e){if(e instanceof TypeError)return n;throw e}}function Ut(e,t){for(let[n,r]of Object.entries(t)){let t=n.split(`.`),i=r.split(`.`),a=new Set,o=-1;for(let e=0;eo)for(let e=o;e=t.length||typeof e!=`object`||!e)return;let a=t[r];if(a.endsWith(`[]`)){let o=a.slice(0,-2),s=e;if(o in s&&Array.isArray(s[o]))for(let e of s[o])Wt(e,t,n,r+1,i)}else if(a===`*`){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,a=Object.keys(t).filter(e=>!e.startsWith(`_`)&&!i.has(e)),o={};for(let e of a)o[e]=t[e];for(let[e,i]of Object.entries(o)){let a=[];for(let t of n.slice(r))t===`*`?a.push(e):a.push(t);J(t,a,i)}for(let e of a)delete t[e]}}else{let o=e;a in o&&Wt(o[a],t,n,r+1,i)}}function Gt(e){if(typeof e!=`string`)throw Error(`fromImageBytes must be a string`);return e}function Kt(e){let t={},n=Y(e,[`operationName`]);n!=null&&J(t,[`operationName`],n);let r=Y(e,[`resourceName`]);return r!=null&&J(t,[`_url`,`resourceName`],r),t}function qt(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`]);r!=null&&J(t,[`metadata`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`response`,`generateVideoResponse`]);return o!=null&&J(t,[`response`],Yt(o)),t}function Jt(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`]);r!=null&&J(t,[`metadata`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`response`]);return o!=null&&J(t,[`response`],Xt(o)),t}function Yt(e){let t={},n=Y(e,[`generatedSamples`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Zt(e))),J(t,[`generatedVideos`],e)}let r=Y(e,[`raiMediaFilteredCount`]);r!=null&&J(t,[`raiMediaFilteredCount`],r);let i=Y(e,[`raiMediaFilteredReasons`]);return i!=null&&J(t,[`raiMediaFilteredReasons`],i),t}function Xt(e){let t={},n=Y(e,[`videos`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Qt(e))),J(t,[`generatedVideos`],e)}let r=Y(e,[`raiMediaFilteredCount`]);r!=null&&J(t,[`raiMediaFilteredCount`],r);let i=Y(e,[`raiMediaFilteredReasons`]);return i!=null&&J(t,[`raiMediaFilteredReasons`],i),t}function Zt(e){let t={},n=Y(e,[`video`]);return n!=null&&J(t,[`video`],on(n)),t}function Qt(e){let t={},n=Y(e,[`_self`]);return n!=null&&J(t,[`video`],sn(n)),t}function $t(e){let t={},n=Y(e,[`operationName`]);return n!=null&&J(t,[`_url`,`operationName`],n),t}function en(e){let t={},n=Y(e,[`operationName`]);return n!=null&&J(t,[`_url`,`operationName`],n),t}function tn(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`]);r!=null&&J(t,[`metadata`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`response`]);return o!=null&&J(t,[`response`],nn(o)),t}function nn(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`parent`]);r!=null&&J(t,[`parent`],r);let i=Y(e,[`documentName`]);return i!=null&&J(t,[`documentName`],i),t}function rn(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`]);r!=null&&J(t,[`metadata`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`response`]);return o!=null&&J(t,[`response`],an(o)),t}function an(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`parent`]);r!=null&&J(t,[`parent`],r);let i=Y(e,[`documentName`]);return i!=null&&J(t,[`documentName`],i),t}function on(e){let t={},n=Y(e,[`uri`]);n!=null&&J(t,[`uri`],n);let r=Y(e,[`encodedVideo`]);r!=null&&J(t,[`videoBytes`],Gt(r));let i=Y(e,[`encoding`]);return i!=null&&J(t,[`mimeType`],i),t}function sn(e){let t={},n=Y(e,[`gcsUri`]);n!=null&&J(t,[`uri`],n);let r=Y(e,[`bytesBase64Encoded`]);r!=null&&J(t,[`videoBytes`],Gt(r));let i=Y(e,[`mimeType`]);return i!=null&&J(t,[`mimeType`],i),t}var cn;(function(e){e.OUTCOME_UNSPECIFIED=`OUTCOME_UNSPECIFIED`,e.OUTCOME_OK=`OUTCOME_OK`,e.OUTCOME_FAILED=`OUTCOME_FAILED`,e.OUTCOME_DEADLINE_EXCEEDED=`OUTCOME_DEADLINE_EXCEEDED`})(cn||={});var ln;(function(e){e.LANGUAGE_UNSPECIFIED=`LANGUAGE_UNSPECIFIED`,e.PYTHON=`PYTHON`})(ln||={});var un;(function(e){e.SCHEDULING_UNSPECIFIED=`SCHEDULING_UNSPECIFIED`,e.SILENT=`SILENT`,e.WHEN_IDLE=`WHEN_IDLE`,e.INTERRUPT=`INTERRUPT`})(un||={});var dn;(function(e){e.TYPE_UNSPECIFIED=`TYPE_UNSPECIFIED`,e.STRING=`STRING`,e.NUMBER=`NUMBER`,e.INTEGER=`INTEGER`,e.BOOLEAN=`BOOLEAN`,e.ARRAY=`ARRAY`,e.OBJECT=`OBJECT`,e.NULL=`NULL`})(dn||={});var fn;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.MODE_DYNAMIC=`MODE_DYNAMIC`})(fn||={});var pn;(function(e){e.API_SPEC_UNSPECIFIED=`API_SPEC_UNSPECIFIED`,e.SIMPLE_SEARCH=`SIMPLE_SEARCH`,e.ELASTIC_SEARCH=`ELASTIC_SEARCH`})(pn||={});var mn;(function(e){e.AUTH_TYPE_UNSPECIFIED=`AUTH_TYPE_UNSPECIFIED`,e.NO_AUTH=`NO_AUTH`,e.API_KEY_AUTH=`API_KEY_AUTH`,e.HTTP_BASIC_AUTH=`HTTP_BASIC_AUTH`,e.GOOGLE_SERVICE_ACCOUNT_AUTH=`GOOGLE_SERVICE_ACCOUNT_AUTH`,e.OAUTH=`OAUTH`,e.OIDC_AUTH=`OIDC_AUTH`})(mn||={});var hn;(function(e){e.HTTP_IN_UNSPECIFIED=`HTTP_IN_UNSPECIFIED`,e.HTTP_IN_QUERY=`HTTP_IN_QUERY`,e.HTTP_IN_HEADER=`HTTP_IN_HEADER`,e.HTTP_IN_PATH=`HTTP_IN_PATH`,e.HTTP_IN_BODY=`HTTP_IN_BODY`,e.HTTP_IN_COOKIE=`HTTP_IN_COOKIE`})(hn||={});var gn;(function(e){e.PHISH_BLOCK_THRESHOLD_UNSPECIFIED=`PHISH_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_HIGH_AND_ABOVE=`BLOCK_HIGH_AND_ABOVE`,e.BLOCK_HIGHER_AND_ABOVE=`BLOCK_HIGHER_AND_ABOVE`,e.BLOCK_VERY_HIGH_AND_ABOVE=`BLOCK_VERY_HIGH_AND_ABOVE`,e.BLOCK_ONLY_EXTREMELY_HIGH=`BLOCK_ONLY_EXTREMELY_HIGH`})(gn||={});var _n;(function(e){e.THINKING_LEVEL_UNSPECIFIED=`THINKING_LEVEL_UNSPECIFIED`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`,e.MINIMAL=`MINIMAL`})(_n||={});var vn;(function(e){e.HARM_CATEGORY_UNSPECIFIED=`HARM_CATEGORY_UNSPECIFIED`,e.HARM_CATEGORY_HARASSMENT=`HARM_CATEGORY_HARASSMENT`,e.HARM_CATEGORY_HATE_SPEECH=`HARM_CATEGORY_HATE_SPEECH`,e.HARM_CATEGORY_SEXUALLY_EXPLICIT=`HARM_CATEGORY_SEXUALLY_EXPLICIT`,e.HARM_CATEGORY_DANGEROUS_CONTENT=`HARM_CATEGORY_DANGEROUS_CONTENT`,e.HARM_CATEGORY_CIVIC_INTEGRITY=`HARM_CATEGORY_CIVIC_INTEGRITY`,e.HARM_CATEGORY_IMAGE_HATE=`HARM_CATEGORY_IMAGE_HATE`,e.HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT=`HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT`,e.HARM_CATEGORY_IMAGE_HARASSMENT=`HARM_CATEGORY_IMAGE_HARASSMENT`,e.HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT=`HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT`,e.HARM_CATEGORY_JAILBREAK=`HARM_CATEGORY_JAILBREAK`})(vn||={});var yn;(function(e){e.HARM_BLOCK_METHOD_UNSPECIFIED=`HARM_BLOCK_METHOD_UNSPECIFIED`,e.SEVERITY=`SEVERITY`,e.PROBABILITY=`PROBABILITY`})(yn||={});var bn;(function(e){e.HARM_BLOCK_THRESHOLD_UNSPECIFIED=`HARM_BLOCK_THRESHOLD_UNSPECIFIED`,e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`,e.OFF=`OFF`})(bn||={});var xn;(function(e){e.FINISH_REASON_UNSPECIFIED=`FINISH_REASON_UNSPECIFIED`,e.STOP=`STOP`,e.MAX_TOKENS=`MAX_TOKENS`,e.SAFETY=`SAFETY`,e.RECITATION=`RECITATION`,e.LANGUAGE=`LANGUAGE`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.SPII=`SPII`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.UNEXPECTED_TOOL_CALL=`UNEXPECTED_TOOL_CALL`,e.IMAGE_PROHIBITED_CONTENT=`IMAGE_PROHIBITED_CONTENT`,e.NO_IMAGE=`NO_IMAGE`,e.IMAGE_RECITATION=`IMAGE_RECITATION`,e.IMAGE_OTHER=`IMAGE_OTHER`})(xn||={});var Sn;(function(e){e.HARM_PROBABILITY_UNSPECIFIED=`HARM_PROBABILITY_UNSPECIFIED`,e.NEGLIGIBLE=`NEGLIGIBLE`,e.LOW=`LOW`,e.MEDIUM=`MEDIUM`,e.HIGH=`HIGH`})(Sn||={});var Cn;(function(e){e.HARM_SEVERITY_UNSPECIFIED=`HARM_SEVERITY_UNSPECIFIED`,e.HARM_SEVERITY_NEGLIGIBLE=`HARM_SEVERITY_NEGLIGIBLE`,e.HARM_SEVERITY_LOW=`HARM_SEVERITY_LOW`,e.HARM_SEVERITY_MEDIUM=`HARM_SEVERITY_MEDIUM`,e.HARM_SEVERITY_HIGH=`HARM_SEVERITY_HIGH`})(Cn||={});var wn;(function(e){e.URL_RETRIEVAL_STATUS_UNSPECIFIED=`URL_RETRIEVAL_STATUS_UNSPECIFIED`,e.URL_RETRIEVAL_STATUS_SUCCESS=`URL_RETRIEVAL_STATUS_SUCCESS`,e.URL_RETRIEVAL_STATUS_ERROR=`URL_RETRIEVAL_STATUS_ERROR`,e.URL_RETRIEVAL_STATUS_PAYWALL=`URL_RETRIEVAL_STATUS_PAYWALL`,e.URL_RETRIEVAL_STATUS_UNSAFE=`URL_RETRIEVAL_STATUS_UNSAFE`})(wn||={});var Tn;(function(e){e.BLOCKED_REASON_UNSPECIFIED=`BLOCKED_REASON_UNSPECIFIED`,e.SAFETY=`SAFETY`,e.OTHER=`OTHER`,e.BLOCKLIST=`BLOCKLIST`,e.PROHIBITED_CONTENT=`PROHIBITED_CONTENT`,e.IMAGE_SAFETY=`IMAGE_SAFETY`,e.MODEL_ARMOR=`MODEL_ARMOR`,e.JAILBREAK=`JAILBREAK`})(Tn||={});var En;(function(e){e.TRAFFIC_TYPE_UNSPECIFIED=`TRAFFIC_TYPE_UNSPECIFIED`,e.ON_DEMAND=`ON_DEMAND`,e.PROVISIONED_THROUGHPUT=`PROVISIONED_THROUGHPUT`})(En||={});var Dn;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.AUDIO=`AUDIO`})(Dn||={});var On;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`})(On||={});var kn;(function(e){e.TUNING_MODE_UNSPECIFIED=`TUNING_MODE_UNSPECIFIED`,e.TUNING_MODE_FULL=`TUNING_MODE_FULL`,e.TUNING_MODE_PEFT_ADAPTER=`TUNING_MODE_PEFT_ADAPTER`})(kn||={});var An;(function(e){e.ADAPTER_SIZE_UNSPECIFIED=`ADAPTER_SIZE_UNSPECIFIED`,e.ADAPTER_SIZE_ONE=`ADAPTER_SIZE_ONE`,e.ADAPTER_SIZE_TWO=`ADAPTER_SIZE_TWO`,e.ADAPTER_SIZE_FOUR=`ADAPTER_SIZE_FOUR`,e.ADAPTER_SIZE_EIGHT=`ADAPTER_SIZE_EIGHT`,e.ADAPTER_SIZE_SIXTEEN=`ADAPTER_SIZE_SIXTEEN`,e.ADAPTER_SIZE_THIRTY_TWO=`ADAPTER_SIZE_THIRTY_TWO`})(An||={});var jn;(function(e){e.JOB_STATE_UNSPECIFIED=`JOB_STATE_UNSPECIFIED`,e.JOB_STATE_QUEUED=`JOB_STATE_QUEUED`,e.JOB_STATE_PENDING=`JOB_STATE_PENDING`,e.JOB_STATE_RUNNING=`JOB_STATE_RUNNING`,e.JOB_STATE_SUCCEEDED=`JOB_STATE_SUCCEEDED`,e.JOB_STATE_FAILED=`JOB_STATE_FAILED`,e.JOB_STATE_CANCELLING=`JOB_STATE_CANCELLING`,e.JOB_STATE_CANCELLED=`JOB_STATE_CANCELLED`,e.JOB_STATE_PAUSED=`JOB_STATE_PAUSED`,e.JOB_STATE_EXPIRED=`JOB_STATE_EXPIRED`,e.JOB_STATE_UPDATING=`JOB_STATE_UPDATING`,e.JOB_STATE_PARTIALLY_SUCCEEDED=`JOB_STATE_PARTIALLY_SUCCEEDED`})(jn||={});var Mn;(function(e){e.TUNING_TASK_UNSPECIFIED=`TUNING_TASK_UNSPECIFIED`,e.TUNING_TASK_I2V=`TUNING_TASK_I2V`,e.TUNING_TASK_T2V=`TUNING_TASK_T2V`,e.TUNING_TASK_R2V=`TUNING_TASK_R2V`})(Mn||={});var Nn;(function(e){e.MEDIA_RESOLUTION_UNSPECIFIED=`MEDIA_RESOLUTION_UNSPECIFIED`,e.MEDIA_RESOLUTION_LOW=`MEDIA_RESOLUTION_LOW`,e.MEDIA_RESOLUTION_MEDIUM=`MEDIA_RESOLUTION_MEDIUM`,e.MEDIA_RESOLUTION_HIGH=`MEDIA_RESOLUTION_HIGH`,e.MEDIA_RESOLUTION_ULTRA_HIGH=`MEDIA_RESOLUTION_ULTRA_HIGH`})(Nn||={});var Pn;(function(e){e.FEATURE_SELECTION_PREFERENCE_UNSPECIFIED=`FEATURE_SELECTION_PREFERENCE_UNSPECIFIED`,e.PRIORITIZE_QUALITY=`PRIORITIZE_QUALITY`,e.BALANCED=`BALANCED`,e.PRIORITIZE_COST=`PRIORITIZE_COST`})(Pn||={});var Fn;(function(e){e.UNSPECIFIED=`UNSPECIFIED`,e.BLOCKING=`BLOCKING`,e.NON_BLOCKING=`NON_BLOCKING`})(Fn||={});var In;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.MODE_DYNAMIC=`MODE_DYNAMIC`})(In||={});var Ln;(function(e){e.ENVIRONMENT_UNSPECIFIED=`ENVIRONMENT_UNSPECIFIED`,e.ENVIRONMENT_BROWSER=`ENVIRONMENT_BROWSER`})(Ln||={});var Rn;(function(e){e.MODE_UNSPECIFIED=`MODE_UNSPECIFIED`,e.AUTO=`AUTO`,e.ANY=`ANY`,e.NONE=`NONE`,e.VALIDATED=`VALIDATED`})(Rn||={});var zn;(function(e){e.BLOCK_LOW_AND_ABOVE=`BLOCK_LOW_AND_ABOVE`,e.BLOCK_MEDIUM_AND_ABOVE=`BLOCK_MEDIUM_AND_ABOVE`,e.BLOCK_ONLY_HIGH=`BLOCK_ONLY_HIGH`,e.BLOCK_NONE=`BLOCK_NONE`})(zn||={});var Bn;(function(e){e.DONT_ALLOW=`DONT_ALLOW`,e.ALLOW_ADULT=`ALLOW_ADULT`,e.ALLOW_ALL=`ALLOW_ALL`})(Bn||={});var Vn;(function(e){e.auto=`auto`,e.en=`en`,e.ja=`ja`,e.ko=`ko`,e.hi=`hi`,e.zh=`zh`,e.pt=`pt`,e.es=`es`})(Vn||={});var Hn;(function(e){e.MASK_MODE_DEFAULT=`MASK_MODE_DEFAULT`,e.MASK_MODE_USER_PROVIDED=`MASK_MODE_USER_PROVIDED`,e.MASK_MODE_BACKGROUND=`MASK_MODE_BACKGROUND`,e.MASK_MODE_FOREGROUND=`MASK_MODE_FOREGROUND`,e.MASK_MODE_SEMANTIC=`MASK_MODE_SEMANTIC`})(Hn||={});var Un;(function(e){e.CONTROL_TYPE_DEFAULT=`CONTROL_TYPE_DEFAULT`,e.CONTROL_TYPE_CANNY=`CONTROL_TYPE_CANNY`,e.CONTROL_TYPE_SCRIBBLE=`CONTROL_TYPE_SCRIBBLE`,e.CONTROL_TYPE_FACE_MESH=`CONTROL_TYPE_FACE_MESH`})(Un||={});var Wn;(function(e){e.SUBJECT_TYPE_DEFAULT=`SUBJECT_TYPE_DEFAULT`,e.SUBJECT_TYPE_PERSON=`SUBJECT_TYPE_PERSON`,e.SUBJECT_TYPE_ANIMAL=`SUBJECT_TYPE_ANIMAL`,e.SUBJECT_TYPE_PRODUCT=`SUBJECT_TYPE_PRODUCT`})(Wn||={});var Gn;(function(e){e.EDIT_MODE_DEFAULT=`EDIT_MODE_DEFAULT`,e.EDIT_MODE_INPAINT_REMOVAL=`EDIT_MODE_INPAINT_REMOVAL`,e.EDIT_MODE_INPAINT_INSERTION=`EDIT_MODE_INPAINT_INSERTION`,e.EDIT_MODE_OUTPAINT=`EDIT_MODE_OUTPAINT`,e.EDIT_MODE_CONTROLLED_EDITING=`EDIT_MODE_CONTROLLED_EDITING`,e.EDIT_MODE_STYLE=`EDIT_MODE_STYLE`,e.EDIT_MODE_BGSWAP=`EDIT_MODE_BGSWAP`,e.EDIT_MODE_PRODUCT_IMAGE=`EDIT_MODE_PRODUCT_IMAGE`})(Gn||={});var Kn;(function(e){e.FOREGROUND=`FOREGROUND`,e.BACKGROUND=`BACKGROUND`,e.PROMPT=`PROMPT`,e.SEMANTIC=`SEMANTIC`,e.INTERACTIVE=`INTERACTIVE`})(Kn||={});var qn;(function(e){e.ASSET=`ASSET`,e.STYLE=`STYLE`})(qn||={});var Jn;(function(e){e.INSERT=`INSERT`,e.REMOVE=`REMOVE`,e.REMOVE_STATIC=`REMOVE_STATIC`,e.OUTPAINT=`OUTPAINT`})(Jn||={});var Yn;(function(e){e.OPTIMIZED=`OPTIMIZED`,e.LOSSLESS=`LOSSLESS`})(Yn||={});var Xn;(function(e){e.SUPERVISED_FINE_TUNING=`SUPERVISED_FINE_TUNING`,e.PREFERENCE_TUNING=`PREFERENCE_TUNING`})(Xn||={});var Zn;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.STATE_PENDING=`STATE_PENDING`,e.STATE_ACTIVE=`STATE_ACTIVE`,e.STATE_FAILED=`STATE_FAILED`})(Zn||={});var Qn;(function(e){e.STATE_UNSPECIFIED=`STATE_UNSPECIFIED`,e.PROCESSING=`PROCESSING`,e.ACTIVE=`ACTIVE`,e.FAILED=`FAILED`})(Qn||={});var $n;(function(e){e.SOURCE_UNSPECIFIED=`SOURCE_UNSPECIFIED`,e.UPLOADED=`UPLOADED`,e.GENERATED=`GENERATED`})($n||={});var er;(function(e){e.TURN_COMPLETE_REASON_UNSPECIFIED=`TURN_COMPLETE_REASON_UNSPECIFIED`,e.MALFORMED_FUNCTION_CALL=`MALFORMED_FUNCTION_CALL`,e.RESPONSE_REJECTED=`RESPONSE_REJECTED`,e.NEED_MORE_INPUT=`NEED_MORE_INPUT`})(er||={});var tr;(function(e){e.MODALITY_UNSPECIFIED=`MODALITY_UNSPECIFIED`,e.TEXT=`TEXT`,e.IMAGE=`IMAGE`,e.VIDEO=`VIDEO`,e.AUDIO=`AUDIO`,e.DOCUMENT=`DOCUMENT`})(tr||={});var nr;(function(e){e.VAD_SIGNAL_TYPE_UNSPECIFIED=`VAD_SIGNAL_TYPE_UNSPECIFIED`,e.VAD_SIGNAL_TYPE_SOS=`VAD_SIGNAL_TYPE_SOS`,e.VAD_SIGNAL_TYPE_EOS=`VAD_SIGNAL_TYPE_EOS`})(nr||={});var rr;(function(e){e.START_SENSITIVITY_UNSPECIFIED=`START_SENSITIVITY_UNSPECIFIED`,e.START_SENSITIVITY_HIGH=`START_SENSITIVITY_HIGH`,e.START_SENSITIVITY_LOW=`START_SENSITIVITY_LOW`})(rr||={});var ir;(function(e){e.END_SENSITIVITY_UNSPECIFIED=`END_SENSITIVITY_UNSPECIFIED`,e.END_SENSITIVITY_HIGH=`END_SENSITIVITY_HIGH`,e.END_SENSITIVITY_LOW=`END_SENSITIVITY_LOW`})(ir||={});var ar;(function(e){e.ACTIVITY_HANDLING_UNSPECIFIED=`ACTIVITY_HANDLING_UNSPECIFIED`,e.START_OF_ACTIVITY_INTERRUPTS=`START_OF_ACTIVITY_INTERRUPTS`,e.NO_INTERRUPTION=`NO_INTERRUPTION`})(ar||={});var or;(function(e){e.TURN_COVERAGE_UNSPECIFIED=`TURN_COVERAGE_UNSPECIFIED`,e.TURN_INCLUDES_ONLY_ACTIVITY=`TURN_INCLUDES_ONLY_ACTIVITY`,e.TURN_INCLUDES_ALL_INPUT=`TURN_INCLUDES_ALL_INPUT`})(or||={});var sr;(function(e){e.SCALE_UNSPECIFIED=`SCALE_UNSPECIFIED`,e.C_MAJOR_A_MINOR=`C_MAJOR_A_MINOR`,e.D_FLAT_MAJOR_B_FLAT_MINOR=`D_FLAT_MAJOR_B_FLAT_MINOR`,e.D_MAJOR_B_MINOR=`D_MAJOR_B_MINOR`,e.E_FLAT_MAJOR_C_MINOR=`E_FLAT_MAJOR_C_MINOR`,e.E_MAJOR_D_FLAT_MINOR=`E_MAJOR_D_FLAT_MINOR`,e.F_MAJOR_D_MINOR=`F_MAJOR_D_MINOR`,e.G_FLAT_MAJOR_E_FLAT_MINOR=`G_FLAT_MAJOR_E_FLAT_MINOR`,e.G_MAJOR_E_MINOR=`G_MAJOR_E_MINOR`,e.A_FLAT_MAJOR_F_MINOR=`A_FLAT_MAJOR_F_MINOR`,e.A_MAJOR_G_FLAT_MINOR=`A_MAJOR_G_FLAT_MINOR`,e.B_FLAT_MAJOR_G_MINOR=`B_FLAT_MAJOR_G_MINOR`,e.B_MAJOR_A_FLAT_MINOR=`B_MAJOR_A_FLAT_MINOR`})(sr||={});var cr;(function(e){e.MUSIC_GENERATION_MODE_UNSPECIFIED=`MUSIC_GENERATION_MODE_UNSPECIFIED`,e.QUALITY=`QUALITY`,e.DIVERSITY=`DIVERSITY`,e.VOCALIZATION=`VOCALIZATION`})(cr||={});var lr;(function(e){e.PLAYBACK_CONTROL_UNSPECIFIED=`PLAYBACK_CONTROL_UNSPECIFIED`,e.PLAY=`PLAY`,e.PAUSE=`PAUSE`,e.STOP=`STOP`,e.RESET_CONTEXT=`RESET_CONTEXT`})(lr||={});var ur=class{constructor(e){let t={};for(let n of e.headers.entries())t[n[0]]=n[1];this.headers=t,this.responseInternal=e}json(){return this.responseInternal.json()}},dr=class{get text(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning text from the first one.`);let e=``,t=!1,n=[];for(let r of this.candidates?.[0]?.content?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&e!==`thoughtSignature`&&(t!==null||t!==void 0)&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning data from the first one.`);let e=``,t=[];for(let n of this.candidates?.[0]?.content?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&(r!==null||r!==void 0)&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}get functionCalls(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning function calls from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.functionCall).map(e=>e.functionCall).filter(e=>e!==void 0);if(e?.length!==0)return e}get executableCode(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning executable code from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.executableCode).map(e=>e.executableCode).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.code}get codeExecutionResult(){if(this.candidates?.[0]?.content?.parts?.length===0)return;this.candidates&&this.candidates.length>1&&console.warn(`there are multiple candidates in the response, returning code execution result from the first one.`);let e=(this.candidates?.[0]?.content?.parts)?.filter(e=>e.codeExecutionResult).map(e=>e.codeExecutionResult).filter(e=>e!==void 0);if(e?.length!==0)return e?.[0]?.output}},fr=class{},pr=class{},mr=class{},hr=class{},gr=class{},_r=class{},vr=class{},yr=class{},br=class{},xr=class{},Sr=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i,a=t;return i=n?Jt(a):qt(a),Object.assign(r,i),r}},Cr=class{},wr=class{},Tr=class{},Er=class{},Dr=class{},Or=class{},kr=class{},Ar=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=tn(t);return Object.assign(r,i),r}},jr=class{},Mr=class{},Nr=class{},Pr=class{},Fr=class{get text(){let e=``,t=!1,n=[];for(let r of this.serverContent?.modelTurn?.parts??[]){for(let[e,t]of Object.entries(r))e!==`text`&&e!==`thought`&&t!==null&&n.push(e);if(typeof r.text==`string`){if(typeof r.thought==`boolean`&&r.thought)continue;t=!0,e+=r.text}}return n.length>0&&console.warn(`there are non-text parts ${n} in the response, returning concatenation of all text parts. Please refer to the non text parts for a full response from model.`),t?e:void 0}get data(){let e=``,t=[];for(let n of this.serverContent?.modelTurn?.parts??[]){for(let[e,r]of Object.entries(n))e!==`inlineData`&&r!==null&&t.push(e);n.inlineData&&typeof n.inlineData.data==`string`&&(e+=atob(n.inlineData.data))}return t.length>0&&console.warn(`there are non-data parts ${t} in the response, returning concatenation of all data parts. Please refer to the non data parts for a full response from model.`),e.length>0?btoa(e):void 0}},Ir=class{get audioChunk(){if(this.serverContent&&this.serverContent.audioChunks&&this.serverContent.audioChunks.length>0)return this.serverContent.audioChunks[0]}},Lr=class e{_fromAPIResponse({apiResponse:t,_isVertexAI:n}){let r=new e,i=rn(t);return Object.assign(r,i),r}};function Rr(e,t){if(!t||typeof t!=`string`)throw Error(`model is required and must be a string`);if(t.includes(`..`)||t.includes(`?`)||t.includes(`&`))throw Error(`invalid model parameter`);if(e.isVertexAI()){if(t.startsWith(`publishers/`)||t.startsWith(`projects/`)||t.startsWith(`models/`))return t;if(t.indexOf(`/`)>=0){let e=t.split(`/`,2);return`publishers/${e[0]}/models/${e[1]}`}else return`publishers/google/models/${t}`}else if(t.startsWith(`models/`)||t.startsWith(`tunedModels/`))return t;else return`models/${t}`}function zr(e,t){let n=Rr(e,t);return n?n.startsWith(`publishers/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}`:n.startsWith(`models/`)&&e.isVertexAI()?`projects/${e.getProject()}/locations/${e.getLocation()}/publishers/google/${n}`:n:``}function Br(e){return Array.isArray(e)?e.map(e=>Vr(e)):[Vr(e)]}function Vr(e){if(typeof e==`object`&&e)return e;throw Error(`Could not parse input as Blob. Unsupported blob type: ${typeof e}`)}function Hr(e){let t=Vr(e);if(t.mimeType&&t.mimeType.startsWith(`image/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function Ur(e){let t=Vr(e);if(t.mimeType&&t.mimeType.startsWith(`audio/`))return t;throw Error(`Unsupported mime type: ${t.mimeType}`)}function Wr(e){if(e==null)throw Error(`PartUnion is required`);if(typeof e==`object`)return e;if(typeof e==`string`)return{text:e};throw Error(`Unsupported part type: ${typeof e}`)}function Gr(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`PartListUnion is required`);return Array.isArray(e)?e.map(e=>Wr(e)):[Wr(e)]}function Kr(e){return typeof e==`object`&&!!e&&`parts`in e&&Array.isArray(e.parts)}function qr(e){return typeof e==`object`&&!!e&&`functionCall`in e}function Jr(e){return typeof e==`object`&&!!e&&`functionResponse`in e}function Yr(e){if(e==null)throw Error(`ContentUnion is required`);return Kr(e)?e:{role:`user`,parts:Gr(e)}}function Xr(e,t){if(!t)return[];if(e.isVertexAI()&&Array.isArray(t))return t.flatMap(e=>{let t=Yr(e);return t.parts&&t.parts.length>0&&t.parts[0].text!==void 0?[t.parts[0].text]:[]});if(e.isVertexAI()){let e=Yr(t);return e.parts&&e.parts.length>0&&e.parts[0].text!==void 0?[e.parts[0].text]:[]}return Array.isArray(t)?t.map(e=>Yr(e)):[Yr(t)]}function Zr(e){if(e==null||Array.isArray(e)&&e.length===0)throw Error(`contents are required`);if(!Array.isArray(e)){if(qr(e)||Jr(e))throw Error(`To specify functionCall or functionResponse parts, please wrap them in a Content object, specifying the role for them`);return[Yr(e)]}let t=[],n=[],r=Kr(e[0]);for(let i of e){let e=Kr(i);if(e!=r)throw Error(`Mixing Content and Parts is not supported, please group the parts into a the appropriate Content objects and specify the roles for them`);if(e)t.push(i);else if(qr(i)||Jr(i))throw Error(`To specify functionCall or functionResponse parts, please wrap them, and any other parts, in Content objects as appropriate, specifying the role for them`);else n.push(i)}return r||t.push({role:`user`,parts:Gr(n)}),t}function Qr(e,t){e.includes(`null`)&&(t.nullable=!0);let n=e.filter(e=>e!==`null`);if(n.length===1)t.type=Object.values(dn).includes(n[0].toUpperCase())?n[0].toUpperCase():dn.TYPE_UNSPECIFIED;else{t.anyOf=[];for(let e of n)t.anyOf.push({type:Object.values(dn).includes(e.toUpperCase())?e.toUpperCase():dn.TYPE_UNSPECIFIED})}}function $r(e){let t={},n=[`items`],r=[`anyOf`],i=[`properties`];if(e.type&&e.anyOf)throw Error(`type and anyOf cannot be both populated.`);let a=e.anyOf;a!=null&&a.length==2&&(a[0].type===`null`?(t.nullable=!0,e=a[1]):a[1].type===`null`&&(t.nullable=!0,e=a[0])),e.type instanceof Array&&Qr(e.type,t);for(let[a,o]of Object.entries(e))if(o!=null)if(a==`type`){if(o===`null`)throw Error(`type: null can not be the only possible type for the field.`);if(o instanceof Array)continue;t.type=Object.values(dn).includes(o.toUpperCase())?o.toUpperCase():dn.TYPE_UNSPECIFIED}else if(n.includes(a))t[a]=$r(o);else if(r.includes(a)){let e=[];for(let n of o){if(n.type==`null`){t.nullable=!0;continue}e.push($r(n))}t[a]=e}else if(i.includes(a)){let e={};for(let[t,n]of Object.entries(o))e[t]=$r(n);t[a]=e}else{if(a===`additionalProperties`)continue;t[a]=o}return t}function ei(e){return $r(e)}function ti(e){if(typeof e==`object`)return e;if(typeof e==`string`)return{voiceConfig:{prebuiltVoiceConfig:{voiceName:e}}};throw Error(`Unsupported speechConfig type: ${typeof e}`)}function ni(e){if(`multiSpeakerVoiceConfig`in e)throw Error(`multiSpeakerVoiceConfig is not supported in the live API.`);return e}function ri(e){if(e.functionDeclarations)for(let t of e.functionDeclarations)t.parameters&&(Object.keys(t.parameters).includes(`$schema`)?t.parametersJsonSchema||(t.parametersJsonSchema=t.parameters,delete t.parameters):t.parameters=$r(t.parameters)),t.response&&(Object.keys(t.response).includes(`$schema`)?t.responseJsonSchema||(t.responseJsonSchema=t.response,delete t.response):t.response=$r(t.response));return e}function ii(e){if(e==null)throw Error(`tools is required`);if(!Array.isArray(e))throw Error(`tools is required and must be an array of Tools`);let t=[];for(let n of e)t.push(n);return t}function ai(e,t,n,r=1){let i=!t.startsWith(`${n}/`)&&t.split(`/`).length===r;return e.isVertexAI()?t.startsWith(`projects/`)?t:t.startsWith(`locations/`)?`projects/${e.getProject()}/${t}`:t.startsWith(`${n}/`)?`projects/${e.getProject()}/locations/${e.getLocation()}/${t}`:i?`projects/${e.getProject()}/locations/${e.getLocation()}/${n}/${t}`:t:i?`${n}/${t}`:t}function oi(e,t){if(typeof t!=`string`)throw Error(`name must be a string`);return ai(e,t,`cachedContents`)}function si(e){switch(e){case`STATE_UNSPECIFIED`:return`JOB_STATE_UNSPECIFIED`;case`CREATING`:return`JOB_STATE_RUNNING`;case`ACTIVE`:return`JOB_STATE_SUCCEEDED`;case`FAILED`:return`JOB_STATE_FAILED`;default:return e}}function ci(e){return Gt(e)}function li(e){return typeof e==`object`&&!!e&&`name`in e}function ui(e){return typeof e==`object`&&!!e&&`video`in e}function di(e){return typeof e==`object`&&!!e&&`uri`in e}function fi(e){let t;if(li(e)&&(t=e.name),!(di(e)&&(t=e.uri,t===void 0))&&!(ui(e)&&(t=e.video?.uri,t===void 0))){if(typeof e==`string`&&(t=e),t===void 0)throw Error(`Could not extract file name from the provided input.`);if(t.startsWith(`https://`)){let e=t.split(`files/`)[1].match(/[a-z0-9]+/);if(e===null)throw Error(`Could not extract file name from URI ${t}`);t=e[0]}else t.startsWith(`files/`)&&(t=t.split(`files/`)[1]);return t}}function pi(e,t){let n;return n=e.isVertexAI()?t?`publishers/google/models`:`models`:t?`models`:`tunedModels`,n}function mi(e){for(let t of[`models`,`tunedModels`,`publisherModels`])if(hi(e,t))return e[t];return[]}function hi(e,t){return typeof e==`object`&&!!e&&t in e}function gi(e,t={}){let n=e,r={name:n.name,description:n.description,parametersJsonSchema:n.inputSchema};return n.outputSchema&&(r.responseJsonSchema=n.outputSchema),t.behavior&&(r.behavior=t.behavior),{functionDeclarations:[r]}}function _i(e,t={}){let n=[],r=new Set;for(let i of e){let e=i.name;if(r.has(e))throw Error(`Duplicate function name ${e} found in MCP tools. Please ensure function names are unique.`);r.add(e);let a=gi(i,t);a.functionDeclarations&&n.push(...a.functionDeclarations)}return{functionDeclarations:n}}function vi(e,t){let n;if(typeof t==`string`)if(e.isVertexAI())if(t.startsWith(`gs://`))n={format:`jsonl`,gcsUri:[t]};else if(t.startsWith(`bq://`))n={format:`bigquery`,bigqueryUri:t};else throw Error(`Unsupported string source for Vertex AI: ${t}`);else if(t.startsWith(`files/`))n={fileName:t};else throw Error(`Unsupported string source for Gemini API: ${t}`);else if(Array.isArray(t)){if(e.isVertexAI())throw Error(`InlinedRequest[] is not supported in Vertex AI.`);n={inlinedRequests:t}}else n=t;let r=[n.gcsUri,n.bigqueryUri].filter(Boolean).length,i=[n.inlinedRequests,n.fileName].filter(Boolean).length;if(e.isVertexAI()){if(i>0||r!==1)throw Error("Exactly one of `gcsUri` or `bigqueryUri` must be set for Vertex AI.")}else if(r>0||i!==1)throw Error("Exactly one of `inlinedRequests`, `fileName`, must be set for Gemini API.");return n}function yi(e){if(typeof e!=`string`)return e;let t=e;if(t.startsWith(`gs://`))return{format:`jsonl`,gcsUri:t};if(t.startsWith(`bq://`))return{format:`bigquery`,bigqueryUri:t};throw Error(`Unsupported destination: ${t}`)}function bi(e){if(typeof e!=`object`||!e)return{};let t=e,n=t.inlinedResponses;if(typeof n!=`object`||!n)return e;let r=n.inlinedResponses;if(!Array.isArray(r)||r.length===0)return e;let i=!1;for(let e of r){if(typeof e!=`object`||!e)continue;let t=e.response;if(!(typeof t!=`object`||!t)&&t.embedding!==void 0){i=!0;break}}return i&&(t.inlinedEmbedContentResponses=t.inlinedResponses,delete t.inlinedResponses),e}function xi(e,t){let n=t;if(!e.isVertexAI()){if(/batches\/[^/]+$/.test(n))return n.split(`/`).pop();throw Error(`Invalid batch job name: ${n}.`)}if(/^projects\/[^/]+\/locations\/[^/]+\/batchPredictionJobs\/[^/]+$/.test(n))return n.split(`/`).pop();if(/^\d+$/.test(n))return n;throw Error(`Invalid batch job name: ${n}.`)}function Si(e){let t=e;return t===`BATCH_STATE_UNSPECIFIED`?`JOB_STATE_UNSPECIFIED`:t===`BATCH_STATE_PENDING`?`JOB_STATE_PENDING`:t===`BATCH_STATE_RUNNING`?`JOB_STATE_RUNNING`:t===`BATCH_STATE_SUCCEEDED`?`JOB_STATE_SUCCEEDED`:t===`BATCH_STATE_FAILED`?`JOB_STATE_FAILED`:t===`BATCH_STATE_CANCELLED`?`JOB_STATE_CANCELLED`:t===`BATCH_STATE_EXPIRED`?`JOB_STATE_EXPIRED`:t}function Ci(e){let t={},n=Y(e,[`responsesFile`]);n!=null&&J(t,[`fileName`],n);let r=Y(e,[`inlinedResponses`,`inlinedResponses`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>sa(e))),J(t,[`inlinedResponses`],e)}let i=Y(e,[`inlinedEmbedContentResponses`,`inlinedResponses`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`inlinedEmbedContentResponses`],e)}return t}function wi(e){let t={},n=Y(e,[`predictionsFormat`]);n!=null&&J(t,[`format`],n);let r=Y(e,[`gcsDestination`,`outputUriPrefix`]);r!=null&&J(t,[`gcsUri`],r);let i=Y(e,[`bigqueryDestination`,`outputUri`]);return i!=null&&J(t,[`bigqueryUri`],i),t}function Ti(e){let t={},n=Y(e,[`format`]);n!=null&&J(t,[`predictionsFormat`],n);let r=Y(e,[`gcsUri`]);r!=null&&J(t,[`gcsDestination`,`outputUriPrefix`],r);let i=Y(e,[`bigqueryUri`]);if(i!=null&&J(t,[`bigqueryDestination`,`outputUri`],i),Y(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Vertex AI.`);if(Y(e,[`inlinedResponses`])!==void 0)throw Error(`inlinedResponses parameter is not supported in Vertex AI.`);if(Y(e,[`inlinedEmbedContentResponses`])!==void 0)throw Error(`inlinedEmbedContentResponses parameter is not supported in Vertex AI.`);return t}function Ei(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`,`displayName`]);r!=null&&J(t,[`displayName`],r);let i=Y(e,[`metadata`,`state`]);i!=null&&J(t,[`state`],Si(i));let a=Y(e,[`metadata`,`createTime`]);a!=null&&J(t,[`createTime`],a);let o=Y(e,[`metadata`,`endTime`]);o!=null&&J(t,[`endTime`],o);let s=Y(e,[`metadata`,`updateTime`]);s!=null&&J(t,[`updateTime`],s);let c=Y(e,[`metadata`,`model`]);c!=null&&J(t,[`model`],c);let l=Y(e,[`metadata`,`output`]);return l!=null&&J(t,[`dest`],Ci(bi(l))),t}function Di(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`displayName`]);r!=null&&J(t,[`displayName`],r);let i=Y(e,[`state`]);i!=null&&J(t,[`state`],Si(i));let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`createTime`]);o!=null&&J(t,[`createTime`],o);let s=Y(e,[`startTime`]);s!=null&&J(t,[`startTime`],s);let c=Y(e,[`endTime`]);c!=null&&J(t,[`endTime`],c);let l=Y(e,[`updateTime`]);l!=null&&J(t,[`updateTime`],l);let u=Y(e,[`model`]);u!=null&&J(t,[`model`],u);let d=Y(e,[`inputConfig`]);d!=null&&J(t,[`src`],Oi(d));let f=Y(e,[`outputConfig`]);f!=null&&J(t,[`dest`],wi(bi(f)));let p=Y(e,[`completionStats`]);return p!=null&&J(t,[`completionStats`],p),t}function Oi(e){let t={},n=Y(e,[`instancesFormat`]);n!=null&&J(t,[`format`],n);let r=Y(e,[`gcsSource`,`uris`]);r!=null&&J(t,[`gcsUri`],r);let i=Y(e,[`bigquerySource`,`inputUri`]);return i!=null&&J(t,[`bigqueryUri`],i),t}function ki(e,t){let n={};if(Y(t,[`format`])!==void 0)throw Error(`format parameter is not supported in Gemini API.`);if(Y(t,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(Y(t,[`bigqueryUri`])!==void 0)throw Error(`bigqueryUri parameter is not supported in Gemini API.`);let r=Y(t,[`fileName`]);r!=null&&J(n,[`fileName`],r);let i=Y(t,[`inlinedRequests`]);if(i!=null){let t=i;Array.isArray(t)&&(t=t.map(t=>oa(e,t))),J(n,[`requests`,`requests`],t)}return n}function Ai(e){let t={},n=Y(e,[`format`]);n!=null&&J(t,[`instancesFormat`],n);let r=Y(e,[`gcsUri`]);r!=null&&J(t,[`gcsSource`,`uris`],r);let i=Y(e,[`bigqueryUri`]);if(i!=null&&J(t,[`bigquerySource`,`inputUri`],i),Y(e,[`fileName`])!==void 0)throw Error(`fileName parameter is not supported in Vertex AI.`);if(Y(e,[`inlinedRequests`])!==void 0)throw Error(`inlinedRequests parameter is not supported in Vertex AI.`);return t}function ji(e){let t={},n=Y(e,[`data`]);if(n!=null&&J(t,[`data`],n),Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function Mi(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],xi(e,r)),n}function Ni(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],xi(e,r)),n}function Pi(e){let t={},n=Y(e,[`content`]);n!=null&&J(t,[`content`],n);let r=Y(e,[`citationMetadata`]);r!=null&&J(t,[`citationMetadata`],Fi(r));let i=Y(e,[`tokenCount`]);i!=null&&J(t,[`tokenCount`],i);let a=Y(e,[`finishReason`]);a!=null&&J(t,[`finishReason`],a);let o=Y(e,[`avgLogprobs`]);o!=null&&J(t,[`avgLogprobs`],o);let s=Y(e,[`groundingMetadata`]);s!=null&&J(t,[`groundingMetadata`],s);let c=Y(e,[`index`]);c!=null&&J(t,[`index`],c);let l=Y(e,[`logprobsResult`]);l!=null&&J(t,[`logprobsResult`],l);let u=Y(e,[`safetyRatings`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`safetyRatings`],e)}let d=Y(e,[`urlContextMetadata`]);return d!=null&&J(t,[`urlContextMetadata`],d),t}function Fi(e){let t={},n=Y(e,[`citationSources`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`citations`],e)}return t}function Ii(e){let t={},n=Y(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>ma(e))),J(t,[`parts`],e)}let r=Y(e,[`role`]);return r!=null&&J(t,[`role`],r),t}function Li(e,t){let n={},r=Y(e,[`displayName`]);if(t!==void 0&&r!=null&&J(t,[`batch`,`displayName`],r),Y(e,[`dest`])!==void 0)throw Error(`dest parameter is not supported in Gemini API.`);return n}function Ri(e,t){let n={},r=Y(e,[`displayName`]);t!==void 0&&r!=null&&J(t,[`displayName`],r);let i=Y(e,[`dest`]);return t!==void 0&&i!=null&&J(t,[`outputConfig`],Ti(yi(i))),n}function zi(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`src`]);i!=null&&J(n,[`batch`,`inputConfig`],ki(e,vi(e,i)));let a=Y(t,[`config`]);return a!=null&&Li(a,n),n}function Bi(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`model`],Rr(e,r));let i=Y(t,[`src`]);i!=null&&J(n,[`inputConfig`],Ai(vi(e,i)));let a=Y(t,[`config`]);return a!=null&&Ri(a,n),n}function Vi(e,t){let n={},r=Y(e,[`displayName`]);return t!==void 0&&r!=null&&J(t,[`batch`,`displayName`],r),n}function Hi(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`src`]);i!=null&&J(n,[`batch`,`inputConfig`],Yi(e,i));let a=Y(t,[`config`]);return a!=null&&Vi(a,n),n}function Ui(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],xi(e,r)),n}function Wi(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],xi(e,r)),n}function Gi(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`name`]);r!=null&&J(t,[`name`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);return a!=null&&J(t,[`error`],a),t}function Ki(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`name`]);r!=null&&J(t,[`name`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);return a!=null&&J(t,[`error`],a),t}function qi(e,t){let n={},r=Y(t,[`contents`]);if(r!=null){let t=Xr(e,r);Array.isArray(t)&&(t=t.map(e=>e)),J(n,[`requests[]`,`request`,`content`],t)}let i=Y(t,[`config`]);return i!=null&&(J(n,[`_self`],Ji(i,n)),Ut(n,{"requests[].*":`requests[].request.*`})),n}function Ji(e,t){let n={},r=Y(e,[`taskType`]);t!==void 0&&r!=null&&J(t,[`requests[]`,`taskType`],r);let i=Y(e,[`title`]);t!==void 0&&i!=null&&J(t,[`requests[]`,`title`],i);let a=Y(e,[`outputDimensionality`]);if(t!==void 0&&a!=null&&J(t,[`requests[]`,`outputDimensionality`],a),Y(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(Y(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);return n}function Yi(e,t){let n={},r=Y(t,[`fileName`]);r!=null&&J(n,[`file_name`],r);let i=Y(t,[`inlinedRequests`]);return i!=null&&J(n,[`requests`],qi(e,i)),n}function Xi(e){let t={};if(Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=Y(e,[`fileUri`]);n!=null&&J(t,[`fileUri`],n);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function Zi(e){let t={},n=Y(e,[`id`]);n!=null&&J(t,[`id`],n);let r=Y(e,[`args`]);r!=null&&J(t,[`args`],r);let i=Y(e,[`name`]);if(i!=null&&J(t,[`name`],i),Y(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(Y(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Qi(e){let t={},n=Y(e,[`mode`]);n!=null&&J(t,[`mode`],n);let r=Y(e,[`allowedFunctionNames`]);if(r!=null&&J(t,[`allowedFunctionNames`],r),Y(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function $i(e,t,n){let r={},i=Y(t,[`systemInstruction`]);n!==void 0&&i!=null&&J(n,[`systemInstruction`],Ii(Yr(i)));let a=Y(t,[`temperature`]);a!=null&&J(r,[`temperature`],a);let o=Y(t,[`topP`]);o!=null&&J(r,[`topP`],o);let s=Y(t,[`topK`]);s!=null&&J(r,[`topK`],s);let c=Y(t,[`candidateCount`]);c!=null&&J(r,[`candidateCount`],c);let l=Y(t,[`maxOutputTokens`]);l!=null&&J(r,[`maxOutputTokens`],l);let u=Y(t,[`stopSequences`]);u!=null&&J(r,[`stopSequences`],u);let d=Y(t,[`responseLogprobs`]);d!=null&&J(r,[`responseLogprobs`],d);let f=Y(t,[`logprobs`]);f!=null&&J(r,[`logprobs`],f);let p=Y(t,[`presencePenalty`]);p!=null&&J(r,[`presencePenalty`],p);let m=Y(t,[`frequencyPenalty`]);m!=null&&J(r,[`frequencyPenalty`],m);let h=Y(t,[`seed`]);h!=null&&J(r,[`seed`],h);let g=Y(t,[`responseMimeType`]);g!=null&&J(r,[`responseMimeType`],g);let _=Y(t,[`responseSchema`]);_!=null&&J(r,[`responseSchema`],ei(_));let v=Y(t,[`responseJsonSchema`]);if(v!=null&&J(r,[`responseJsonSchema`],v),Y(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(Y(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let y=Y(t,[`safetySettings`]);if(n!==void 0&&y!=null){let e=y;Array.isArray(e)&&(e=e.map(e=>ha(e))),J(n,[`safetySettings`],e)}let b=Y(t,[`tools`]);if(n!==void 0&&b!=null){let e=ii(b);Array.isArray(e)&&(e=e.map(e=>_a(ri(e)))),J(n,[`tools`],e)}let x=Y(t,[`toolConfig`]);if(n!==void 0&&x!=null&&J(n,[`toolConfig`],ga(x)),Y(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let S=Y(t,[`cachedContent`]);n!==void 0&&S!=null&&J(n,[`cachedContent`],oi(e,S));let C=Y(t,[`responseModalities`]);C!=null&&J(r,[`responseModalities`],C);let w=Y(t,[`mediaResolution`]);w!=null&&J(r,[`mediaResolution`],w);let T=Y(t,[`speechConfig`]);if(T!=null&&J(r,[`speechConfig`],ti(T)),Y(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let E=Y(t,[`thinkingConfig`]);E!=null&&J(r,[`thinkingConfig`],E);let D=Y(t,[`imageConfig`]);D!=null&&J(r,[`imageConfig`],aa(D));let O=Y(t,[`enableEnhancedCivicAnswers`]);return O!=null&&J(r,[`enableEnhancedCivicAnswers`],O),r}function ea(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`candidates`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Pi(e))),J(t,[`candidates`],e)}let i=Y(e,[`modelVersion`]);i!=null&&J(t,[`modelVersion`],i);let a=Y(e,[`promptFeedback`]);a!=null&&J(t,[`promptFeedback`],a);let o=Y(e,[`responseId`]);o!=null&&J(t,[`responseId`],o);let s=Y(e,[`usageMetadata`]);return s!=null&&J(t,[`usageMetadata`],s),t}function ta(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],xi(e,r)),n}function na(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],xi(e,r)),n}function ra(e){let t={};if(Y(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=Y(e,[`enableWidget`]);return n!=null&&J(t,[`enableWidget`],n),t}function ia(e){let t={};if(Y(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(Y(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let n=Y(e,[`timeRangeFilter`]);return n!=null&&J(t,[`timeRangeFilter`],n),t}function aa(e){let t={},n=Y(e,[`aspectRatio`]);n!=null&&J(t,[`aspectRatio`],n);let r=Y(e,[`imageSize`]);if(r!=null&&J(t,[`imageSize`],r),Y(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(Y(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);return t}function oa(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`request`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let e=Zr(i);Array.isArray(e)&&(e=e.map(e=>Ii(e))),J(n,[`request`,`contents`],e)}let a=Y(t,[`metadata`]);a!=null&&J(n,[`metadata`],a);let o=Y(t,[`config`]);return o!=null&&J(n,[`request`,`generationConfig`],$i(e,o,Y(n,[`request`],{}))),n}function sa(e){let t={},n=Y(e,[`response`]);n!=null&&J(t,[`response`],ea(n));let r=Y(e,[`error`]);return r!=null&&J(t,[`error`],r),t}function ca(e,t){let n={},r=Y(e,[`pageSize`]);t!==void 0&&r!=null&&J(t,[`_query`,`pageSize`],r);let i=Y(e,[`pageToken`]);if(t!==void 0&&i!=null&&J(t,[`_query`,`pageToken`],i),Y(e,[`filter`])!==void 0)throw Error(`filter parameter is not supported in Gemini API.`);return n}function la(e,t){let n={},r=Y(e,[`pageSize`]);t!==void 0&&r!=null&&J(t,[`_query`,`pageSize`],r);let i=Y(e,[`pageToken`]);t!==void 0&&i!=null&&J(t,[`_query`,`pageToken`],i);let a=Y(e,[`filter`]);return t!==void 0&&a!=null&&J(t,[`_query`,`filter`],a),n}function ua(e){let t={},n=Y(e,[`config`]);return n!=null&&ca(n,t),t}function da(e){let t={},n=Y(e,[`config`]);return n!=null&&la(n,t),t}function fa(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`operations`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Ei(e))),J(t,[`batchJobs`],e)}return t}function pa(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`batchPredictionJobs`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Di(e))),J(t,[`batchJobs`],e)}return t}function ma(e){let t={},n=Y(e,[`mediaResolution`]);n!=null&&J(t,[`mediaResolution`],n);let r=Y(e,[`codeExecutionResult`]);r!=null&&J(t,[`codeExecutionResult`],r);let i=Y(e,[`executableCode`]);i!=null&&J(t,[`executableCode`],i);let a=Y(e,[`fileData`]);a!=null&&J(t,[`fileData`],Xi(a));let o=Y(e,[`functionCall`]);o!=null&&J(t,[`functionCall`],Zi(o));let s=Y(e,[`functionResponse`]);s!=null&&J(t,[`functionResponse`],s);let c=Y(e,[`inlineData`]);c!=null&&J(t,[`inlineData`],ji(c));let l=Y(e,[`text`]);l!=null&&J(t,[`text`],l);let u=Y(e,[`thought`]);u!=null&&J(t,[`thought`],u);let d=Y(e,[`thoughtSignature`]);d!=null&&J(t,[`thoughtSignature`],d);let f=Y(e,[`videoMetadata`]);return f!=null&&J(t,[`videoMetadata`],f),t}function ha(e){let t={},n=Y(e,[`category`]);if(n!=null&&J(t,[`category`],n),Y(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=Y(e,[`threshold`]);return r!=null&&J(t,[`threshold`],r),t}function ga(e){let t={},n=Y(e,[`functionCallingConfig`]);n!=null&&J(t,[`functionCallingConfig`],Qi(n));let r=Y(e,[`retrievalConfig`]);return r!=null&&J(t,[`retrievalConfig`],r),t}function _a(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`functionDeclarations`],e)}if(Y(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=Y(e,[`googleSearchRetrieval`]);r!=null&&J(t,[`googleSearchRetrieval`],r);let i=Y(e,[`computerUse`]);i!=null&&J(t,[`computerUse`],i);let a=Y(e,[`fileSearch`]);a!=null&&J(t,[`fileSearch`],a);let o=Y(e,[`codeExecution`]);if(o!=null&&J(t,[`codeExecution`],o),Y(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=Y(e,[`googleMaps`]);s!=null&&J(t,[`googleMaps`],ra(s));let c=Y(e,[`googleSearch`]);c!=null&&J(t,[`googleSearch`],ia(c));let l=Y(e,[`urlContext`]);return l!=null&&J(t,[`urlContext`],l),t}var va;(function(e){e.PAGED_ITEM_BATCH_JOBS=`batchJobs`,e.PAGED_ITEM_MODELS=`models`,e.PAGED_ITEM_TUNING_JOBS=`tuningJobs`,e.PAGED_ITEM_FILES=`files`,e.PAGED_ITEM_CACHED_CONTENTS=`cachedContents`,e.PAGED_ITEM_FILE_SEARCH_STORES=`fileSearchStores`,e.PAGED_ITEM_DOCUMENTS=`documents`})(va||={});var ya=class{constructor(e,t,n,r){this.pageInternal=[],this.paramsInternal={},this.requestInternal=t,this.init(e,n,r)}init(e,t,n){this.nameInternal=e,this.pageInternal=t[this.nameInternal]||[],this.sdkHttpResponseInternal=t?.sdkHttpResponse,this.idxInternal=0;let r={config:{}};r=!n||Object.keys(n).length===0?{config:{}}:typeof n==`object`?Object.assign({},n):n,r.config&&(r.config.pageToken=t.nextPageToken),this.paramsInternal=r,this.pageInternalSize=r.config?.pageSize??this.pageInternal.length}initNextPage(e){this.init(this.nameInternal,e,this.paramsInternal)}get page(){return this.pageInternal}get name(){return this.nameInternal}get pageSize(){return this.pageInternalSize}get sdkHttpResponse(){return this.sdkHttpResponseInternal}get params(){return this.paramsInternal}get pageLength(){return this.pageInternal.length}getItem(e){return this.pageInternal[e]}[Symbol.asyncIterator](){return{next:async()=>{if(this.idxInternal>=this.pageLength)if(this.hasNextPage())await this.nextPage();else return{value:void 0,done:!0};let e=this.getItem(this.idxInternal);return this.idxInternal+=1,{value:e,done:!1}},return:async()=>({value:void 0,done:!0})}}async nextPage(){if(!this.hasNextPage())throw Error(`No more pages to fetch.`);let e=await this.requestInternal(this.params);return this.initNextPage(e),this.page}hasNextPage(){return this.params.config?.pageToken!==void 0}},ba=class extends Ht{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new ya(va.PAGED_ITEM_BATCH_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.create=async e=>(this.apiClient.isVertexAI()&&(e.config=this.formatDestination(e.src,e.config)),this.createInternal(e)),this.createEmbeddings=async e=>{if(console.warn(`batches.createEmbeddings() is experimental and may change without notice.`),this.apiClient.isVertexAI())throw Error(`Vertex AI does not support batches.createEmbeddings.`);return this.createEmbeddingsInternal(e)}}createInlinedGenerateContentRequest(e){let t=zi(this.apiClient,e),n=t._url,r=q(`{model}:batchGenerateContent`,n),i=t.batch.inputConfig.requests,a=i.requests,o=[];for(let e of a){let t=Object.assign({},e);if(t.systemInstruction){let e=t.systemInstruction;delete t.systemInstruction;let n=t.request;n.systemInstruction=e,t.request=n}o.push(t)}return i.requests=o,delete t.config,delete t._url,delete t._query,{path:r,body:t}}getGcsUri(e){if(typeof e==`string`)return e.startsWith(`gs://`)?e:void 0;if(!Array.isArray(e)&&e.gcsUri&&e.gcsUri.length>0)return e.gcsUri[0]}getBigqueryUri(e){if(typeof e==`string`)return e.startsWith(`bq://`)?e:void 0;if(!Array.isArray(e))return e.bigqueryUri}formatDestination(e,t){let n=t?Object.assign({},t):{},r=Date.now().toString();if(n.displayName||=`genaiBatchJob_${r}`,n.dest===void 0){let t=this.getGcsUri(e),i=this.getBigqueryUri(e);if(t)t.endsWith(`.jsonl`)?n.dest=`${t.slice(0,-6)}/dest`:n.dest=`${t}_dest_${r}`;else if(i)n.dest=`${i}_dest_${r}`;else throw Error(`Unsupported source for Vertex AI: No GCS or BigQuery URI found.`)}return n}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Bi(this.apiClient,e);return n=q(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Di(e))}else{let i=zi(this.apiClient,e);return n=q(`{model}:batchGenerateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Ei(e))}}async createEmbeddingsInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Hi(this.apiClient,e);return n=q(`{model}:asyncBatchEmbedContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Ei(e))}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=na(this.apiClient,e);return n=q(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Di(e))}else{let i=ta(this.apiClient,e);return n=q(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>Ei(e))}}async cancel(e){let t=``,n={};if(this.apiClient.isVertexAI()){let r=Ni(this.apiClient,e);t=q(`batchPredictionJobs/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}else{let r=Mi(this.apiClient,e);t=q(`batches/{name}:cancel`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=da(e);return n=q(`batchPredictionJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=pa(e),n=new Pr;return Object.assign(n,t),n})}else{let i=ua(e);return n=q(`batches`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=fa(e),n=new Pr;return Object.assign(n,t),n})}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Wi(this.apiClient,e);return n=q(`batchPredictionJobs/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Ki(e))}else{let i=Ui(this.apiClient,e);return n=q(`batches/{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>Gi(e))}}};function xa(e){let t={},n=Y(e,[`data`]);if(n!=null&&J(t,[`data`],n),Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function Sa(e){let t={},n=Y(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Ga(e))),J(t,[`parts`],e)}let r=Y(e,[`role`]);return r!=null&&J(t,[`role`],r),t}function Ca(e,t){let n={},r=Y(e,[`ttl`]);t!==void 0&&r!=null&&J(t,[`ttl`],r);let i=Y(e,[`expireTime`]);t!==void 0&&i!=null&&J(t,[`expireTime`],i);let a=Y(e,[`displayName`]);t!==void 0&&a!=null&&J(t,[`displayName`],a);let o=Y(e,[`contents`]);if(t!==void 0&&o!=null){let e=Zr(o);Array.isArray(e)&&(e=e.map(e=>Sa(e))),J(t,[`contents`],e)}let s=Y(e,[`systemInstruction`]);t!==void 0&&s!=null&&J(t,[`systemInstruction`],Sa(Yr(s)));let c=Y(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>qa(e))),J(t,[`tools`],e)}let l=Y(e,[`toolConfig`]);if(t!==void 0&&l!=null&&J(t,[`toolConfig`],Ka(l)),Y(e,[`kmsKeyName`])!==void 0)throw Error(`kmsKeyName parameter is not supported in Gemini API.`);return n}function wa(e,t){let n={},r=Y(e,[`ttl`]);t!==void 0&&r!=null&&J(t,[`ttl`],r);let i=Y(e,[`expireTime`]);t!==void 0&&i!=null&&J(t,[`expireTime`],i);let a=Y(e,[`displayName`]);t!==void 0&&a!=null&&J(t,[`displayName`],a);let o=Y(e,[`contents`]);if(t!==void 0&&o!=null){let e=Zr(o);Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`contents`],e)}let s=Y(e,[`systemInstruction`]);t!==void 0&&s!=null&&J(t,[`systemInstruction`],Yr(s));let c=Y(e,[`tools`]);if(t!==void 0&&c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>Ja(e))),J(t,[`tools`],e)}let l=Y(e,[`toolConfig`]);t!==void 0&&l!=null&&J(t,[`toolConfig`],l);let u=Y(e,[`kmsKeyName`]);return t!==void 0&&u!=null&&J(t,[`encryption_spec`,`kmsKeyName`],u),n}function Ta(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`model`],zr(e,r));let i=Y(t,[`config`]);return i!=null&&Ca(i,n),n}function Ea(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`model`],zr(e,r));let i=Y(t,[`config`]);return i!=null&&wa(i,n),n}function Da(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],oi(e,r)),n}function Oa(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],oi(e,r)),n}function ka(e){let t={},n=Y(e,[`sdkHttpResponse`]);return n!=null&&J(t,[`sdkHttpResponse`],n),t}function Aa(e){let t={},n=Y(e,[`sdkHttpResponse`]);return n!=null&&J(t,[`sdkHttpResponse`],n),t}function ja(e){let t={};if(Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=Y(e,[`fileUri`]);n!=null&&J(t,[`fileUri`],n);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function Ma(e){let t={},n=Y(e,[`id`]);n!=null&&J(t,[`id`],n);let r=Y(e,[`args`]);r!=null&&J(t,[`args`],r);let i=Y(e,[`name`]);if(i!=null&&J(t,[`name`],i),Y(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(Y(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Na(e){let t={},n=Y(e,[`mode`]);n!=null&&J(t,[`mode`],n);let r=Y(e,[`allowedFunctionNames`]);if(r!=null&&J(t,[`allowedFunctionNames`],r),Y(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function Pa(e){let t={};if(Y(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Vertex AI.`);let n=Y(e,[`description`]);n!=null&&J(t,[`description`],n);let r=Y(e,[`name`]);r!=null&&J(t,[`name`],r);let i=Y(e,[`parameters`]);i!=null&&J(t,[`parameters`],i);let a=Y(e,[`parametersJsonSchema`]);a!=null&&J(t,[`parametersJsonSchema`],a);let o=Y(e,[`response`]);o!=null&&J(t,[`response`],o);let s=Y(e,[`responseJsonSchema`]);return s!=null&&J(t,[`responseJsonSchema`],s),t}function Fa(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],oi(e,r)),n}function Ia(e,t){let n={},r=Y(t,[`name`]);return r!=null&&J(n,[`_url`,`name`],oi(e,r)),n}function La(e){let t={};if(Y(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=Y(e,[`enableWidget`]);return n!=null&&J(t,[`enableWidget`],n),t}function Ra(e){let t={};if(Y(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(Y(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let n=Y(e,[`timeRangeFilter`]);return n!=null&&J(t,[`timeRangeFilter`],n),t}function za(e,t){let n={},r=Y(e,[`pageSize`]);t!==void 0&&r!=null&&J(t,[`_query`,`pageSize`],r);let i=Y(e,[`pageToken`]);return t!==void 0&&i!=null&&J(t,[`_query`,`pageToken`],i),n}function Ba(e,t){let n={},r=Y(e,[`pageSize`]);t!==void 0&&r!=null&&J(t,[`_query`,`pageSize`],r);let i=Y(e,[`pageToken`]);return t!==void 0&&i!=null&&J(t,[`_query`,`pageToken`],i),n}function Va(e){let t={},n=Y(e,[`config`]);return n!=null&&za(n,t),t}function Ha(e){let t={},n=Y(e,[`config`]);return n!=null&&Ba(n,t),t}function Ua(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`cachedContents`],e)}return t}function Wa(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`cachedContents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`cachedContents`],e)}return t}function Ga(e){let t={},n=Y(e,[`mediaResolution`]);n!=null&&J(t,[`mediaResolution`],n);let r=Y(e,[`codeExecutionResult`]);r!=null&&J(t,[`codeExecutionResult`],r);let i=Y(e,[`executableCode`]);i!=null&&J(t,[`executableCode`],i);let a=Y(e,[`fileData`]);a!=null&&J(t,[`fileData`],ja(a));let o=Y(e,[`functionCall`]);o!=null&&J(t,[`functionCall`],Ma(o));let s=Y(e,[`functionResponse`]);s!=null&&J(t,[`functionResponse`],s);let c=Y(e,[`inlineData`]);c!=null&&J(t,[`inlineData`],xa(c));let l=Y(e,[`text`]);l!=null&&J(t,[`text`],l);let u=Y(e,[`thought`]);u!=null&&J(t,[`thought`],u);let d=Y(e,[`thoughtSignature`]);d!=null&&J(t,[`thoughtSignature`],d);let f=Y(e,[`videoMetadata`]);return f!=null&&J(t,[`videoMetadata`],f),t}function Ka(e){let t={},n=Y(e,[`functionCallingConfig`]);n!=null&&J(t,[`functionCallingConfig`],Na(n));let r=Y(e,[`retrievalConfig`]);return r!=null&&J(t,[`retrievalConfig`],r),t}function qa(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`functionDeclarations`],e)}if(Y(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=Y(e,[`googleSearchRetrieval`]);r!=null&&J(t,[`googleSearchRetrieval`],r);let i=Y(e,[`computerUse`]);i!=null&&J(t,[`computerUse`],i);let a=Y(e,[`fileSearch`]);a!=null&&J(t,[`fileSearch`],a);let o=Y(e,[`codeExecution`]);if(o!=null&&J(t,[`codeExecution`],o),Y(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=Y(e,[`googleMaps`]);s!=null&&J(t,[`googleMaps`],La(s));let c=Y(e,[`googleSearch`]);c!=null&&J(t,[`googleSearch`],Ra(c));let l=Y(e,[`urlContext`]);return l!=null&&J(t,[`urlContext`],l),t}function Ja(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Pa(e))),J(t,[`functionDeclarations`],e)}let r=Y(e,[`retrieval`]);r!=null&&J(t,[`retrieval`],r);let i=Y(e,[`googleSearchRetrieval`]);i!=null&&J(t,[`googleSearchRetrieval`],i);let a=Y(e,[`computerUse`]);if(a!=null&&J(t,[`computerUse`],a),Y(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Vertex AI.`);let o=Y(e,[`codeExecution`]);o!=null&&J(t,[`codeExecution`],o);let s=Y(e,[`enterpriseWebSearch`]);s!=null&&J(t,[`enterpriseWebSearch`],s);let c=Y(e,[`googleMaps`]);c!=null&&J(t,[`googleMaps`],c);let l=Y(e,[`googleSearch`]);l!=null&&J(t,[`googleSearch`],l);let u=Y(e,[`urlContext`]);return u!=null&&J(t,[`urlContext`],u),t}function Ya(e,t){let n={},r=Y(e,[`ttl`]);t!==void 0&&r!=null&&J(t,[`ttl`],r);let i=Y(e,[`expireTime`]);return t!==void 0&&i!=null&&J(t,[`expireTime`],i),n}function Xa(e,t){let n={},r=Y(e,[`ttl`]);t!==void 0&&r!=null&&J(t,[`ttl`],r);let i=Y(e,[`expireTime`]);return t!==void 0&&i!=null&&J(t,[`expireTime`],i),n}function Za(e,t){let n={},r=Y(t,[`name`]);r!=null&&J(n,[`_url`,`name`],oi(e,r));let i=Y(t,[`config`]);return i!=null&&Ya(i,n),n}function Qa(e,t){let n={},r=Y(t,[`name`]);r!=null&&J(n,[`_url`,`name`],oi(e,r));let i=Y(t,[`config`]);return i!=null&&Xa(i,n),n}var $a=class extends Ht{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new ya(va.PAGED_ITEM_CACHED_CONTENTS,e=>this.listInternal(e),await this.listInternal(e),e)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ea(this.apiClient,e);return n=q(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=Ta(this.apiClient,e);return n=q(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ia(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=Fa(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Oa(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Aa(e),n=new Tr;return Object.assign(n,t),n})}else{let i=Da(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ka(e),n=new Tr;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Qa(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}else{let i=Za(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ha(e);return n=q(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Wa(e),n=new Er;return Object.assign(n,t),n})}else{let i=Va(e);return n=q(`cachedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ua(e),n=new Er;return Object.assign(n,t),n})}}};function eo(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function no(e){return this instanceof no?(this.v=e,this):new no(e)}function ro(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof no?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function io(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof to==`function`?to(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function ao(e){if(e.candidates==null||e.candidates.length===0)return!1;let t=e.candidates[0]?.content;return t===void 0?!1:oo(t)}function oo(e){if(e.parts===void 0||e.parts.length===0)return!1;for(let t of e.parts)if(t===void 0||Object.keys(t).length===0)return!1;return!0}function so(e){if(e.length!==0){for(let t of e)if(t.role!==`user`&&t.role!==`model`)throw Error(`Role must be user or model, but got ${t.role}.`)}}function co(e){if(e===void 0||e.length===0)return[];let t=[],n=e.length,r=0;for(;r{let e=await n,r=e.candidates?.[0]?.content,i=e.automaticFunctionCallingHistory,a=this.getHistory(!0).length,o=[];i!=null&&(o=i.slice(a)??[]);let s=r?[r]:[];this.recordHistory(t,s,o)})(),await this.sendPromise.catch(()=>{this.sendPromise=Promise.resolve()}),n}async sendMessageStream(e){await this.sendPromise;let t=Yr(e.message),n=this.modelsModule.generateContentStream({model:this.model,contents:this.getHistory(!0).concat(t),config:e.config??this.config});this.sendPromise=n.then(()=>void 0).catch(()=>void 0);let r=await n;return this.processStreamResponse(r,t)}getHistory(e=!1){let t=e?co(this.history):this.history;return structuredClone(t)}processStreamResponse(e,t){return ro(this,arguments,function*(){var n,r,i,a;let o=[];try{for(var s=!0,c=io(e),l;l=yield no(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;if(ao(e)){let t=e.candidates?.[0]?.content;t!==void 0&&o.push(t)}yield yield no(e)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield no(i.call(c)))}finally{if(r)throw r.error}}this.recordHistory(t,o)})}recordHistory(e,t,n){let r=[];t.length>0&&t.every(e=>e.role!==void 0)?r=t:r.push({role:`model`,parts:[]}),n&&n.length>0?this.history.push(...co(n)):this.history.push(e),this.history.push(...r)}},fo=class e extends Error{constructor(t){super(t.message),this.name=`ApiError`,this.status=t.status,Object.setPrototypeOf(this,e.prototype)}};function po(e){let t={},n=Y(e,[`file`]);return n!=null&&J(t,[`file`],n),t}function mo(e){let t={},n=Y(e,[`sdkHttpResponse`]);return n!=null&&J(t,[`sdkHttpResponse`],n),t}function ho(e){let t={},n=Y(e,[`name`]);return n!=null&&J(t,[`_url`,`file`],fi(n)),t}function go(e){let t={},n=Y(e,[`sdkHttpResponse`]);return n!=null&&J(t,[`sdkHttpResponse`],n),t}function _o(e){let t={},n=Y(e,[`name`]);return n!=null&&J(t,[`_url`,`file`],fi(n)),t}function vo(e,t){let n={},r=Y(e,[`pageSize`]);t!==void 0&&r!=null&&J(t,[`_query`,`pageSize`],r);let i=Y(e,[`pageToken`]);return t!==void 0&&i!=null&&J(t,[`_query`,`pageToken`],i),n}function yo(e){let t={},n=Y(e,[`config`]);return n!=null&&vo(n,t),t}function bo(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`files`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`files`],e)}return t}var xo=class extends Ht{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new ya(va.PAGED_ITEM_FILES,e=>this.listInternal(e),await this.listInternal(e),e)}async upload(e){if(this.apiClient.isVertexAI())throw Error(`Vertex AI does not support uploading files. You can share files through a GCS bucket.`);return this.apiClient.uploadFile(e.file,e.config).then(e=>e)}async download(e){await this.apiClient.downloadFile(e)}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=yo(e);return n=q(`files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=bo(e),n=new jr;return Object.assign(n,t),n})}}async createInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=po(e);return n=q(`upload/v1beta/files`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=mo(e),n=new Mr;return Object.assign(n,t),n})}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=_o(e);return n=q(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ho(e);return n=q(`files/{file}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=go(e),n=new Nr;return Object.assign(n,t),n})}}};function So(e){let t={},n=Y(e,[`data`]);if(n!=null&&J(t,[`data`],n),Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function Co(e){let t={},n=Y(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>zo(e))),J(t,[`parts`],e)}let r=Y(e,[`role`]);return r!=null&&J(t,[`role`],r),t}function wo(e){let t={};if(Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=Y(e,[`fileUri`]);n!=null&&J(t,[`fileUri`],n);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function To(e){let t={},n=Y(e,[`id`]);n!=null&&J(t,[`id`],n);let r=Y(e,[`args`]);r!=null&&J(t,[`args`],r);let i=Y(e,[`name`]);if(i!=null&&J(t,[`name`],i),Y(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(Y(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function Eo(e){let t={};if(Y(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Vertex AI.`);let n=Y(e,[`description`]);n!=null&&J(t,[`description`],n);let r=Y(e,[`name`]);r!=null&&J(t,[`name`],r);let i=Y(e,[`parameters`]);i!=null&&J(t,[`parameters`],i);let a=Y(e,[`parametersJsonSchema`]);a!=null&&J(t,[`parametersJsonSchema`],a);let o=Y(e,[`response`]);o!=null&&J(t,[`response`],o);let s=Y(e,[`responseJsonSchema`]);return s!=null&&J(t,[`responseJsonSchema`],s),t}function Do(e){let t={},n=Y(e,[`modelSelectionConfig`]);n!=null&&J(t,[`modelConfig`],n);let r=Y(e,[`responseJsonSchema`]);r!=null&&J(t,[`responseJsonSchema`],r);let i=Y(e,[`audioTimestamp`]);i!=null&&J(t,[`audioTimestamp`],i);let a=Y(e,[`candidateCount`]);a!=null&&J(t,[`candidateCount`],a);let o=Y(e,[`enableAffectiveDialog`]);o!=null&&J(t,[`enableAffectiveDialog`],o);let s=Y(e,[`frequencyPenalty`]);s!=null&&J(t,[`frequencyPenalty`],s);let c=Y(e,[`logprobs`]);c!=null&&J(t,[`logprobs`],c);let l=Y(e,[`maxOutputTokens`]);l!=null&&J(t,[`maxOutputTokens`],l);let u=Y(e,[`mediaResolution`]);u!=null&&J(t,[`mediaResolution`],u);let d=Y(e,[`presencePenalty`]);d!=null&&J(t,[`presencePenalty`],d);let f=Y(e,[`responseLogprobs`]);f!=null&&J(t,[`responseLogprobs`],f);let p=Y(e,[`responseMimeType`]);p!=null&&J(t,[`responseMimeType`],p);let m=Y(e,[`responseModalities`]);m!=null&&J(t,[`responseModalities`],m);let h=Y(e,[`responseSchema`]);h!=null&&J(t,[`responseSchema`],h);let g=Y(e,[`routingConfig`]);g!=null&&J(t,[`routingConfig`],g);let _=Y(e,[`seed`]);_!=null&&J(t,[`seed`],_);let v=Y(e,[`speechConfig`]);v!=null&&J(t,[`speechConfig`],v);let y=Y(e,[`stopSequences`]);y!=null&&J(t,[`stopSequences`],y);let b=Y(e,[`temperature`]);b!=null&&J(t,[`temperature`],b);let x=Y(e,[`thinkingConfig`]);x!=null&&J(t,[`thinkingConfig`],x);let S=Y(e,[`topK`]);S!=null&&J(t,[`topK`],S);let C=Y(e,[`topP`]);if(C!=null&&J(t,[`topP`],C),Y(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Vertex AI.`);return t}function Oo(e){let t={};if(Y(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=Y(e,[`enableWidget`]);return n!=null&&J(t,[`enableWidget`],n),t}function ko(e){let t={};if(Y(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(Y(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let n=Y(e,[`timeRangeFilter`]);return n!=null&&J(t,[`timeRangeFilter`],n),t}function Ao(e,t){let n={},r=Y(e,[`generationConfig`]);t!==void 0&&r!=null&&J(t,[`setup`,`generationConfig`],r);let i=Y(e,[`responseModalities`]);t!==void 0&&i!=null&&J(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=Y(e,[`temperature`]);t!==void 0&&a!=null&&J(t,[`setup`,`generationConfig`,`temperature`],a);let o=Y(e,[`topP`]);t!==void 0&&o!=null&&J(t,[`setup`,`generationConfig`,`topP`],o);let s=Y(e,[`topK`]);t!==void 0&&s!=null&&J(t,[`setup`,`generationConfig`,`topK`],s);let c=Y(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&J(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=Y(e,[`mediaResolution`]);t!==void 0&&l!=null&&J(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=Y(e,[`seed`]);t!==void 0&&u!=null&&J(t,[`setup`,`generationConfig`,`seed`],u);let d=Y(e,[`speechConfig`]);t!==void 0&&d!=null&&J(t,[`setup`,`generationConfig`,`speechConfig`],ni(d));let f=Y(e,[`thinkingConfig`]);t!==void 0&&f!=null&&J(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=Y(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&J(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=Y(e,[`systemInstruction`]);t!==void 0&&m!=null&&J(t,[`setup`,`systemInstruction`],Co(Yr(m)));let h=Y(e,[`tools`]);if(t!==void 0&&h!=null){let e=ii(h);Array.isArray(e)&&(e=e.map(e=>Vo(ri(e)))),J(t,[`setup`,`tools`],e)}let g=Y(e,[`sessionResumption`]);t!==void 0&&g!=null&&J(t,[`setup`,`sessionResumption`],Bo(g));let _=Y(e,[`inputAudioTranscription`]);t!==void 0&&_!=null&&J(t,[`setup`,`inputAudioTranscription`],_);let v=Y(e,[`outputAudioTranscription`]);t!==void 0&&v!=null&&J(t,[`setup`,`outputAudioTranscription`],v);let y=Y(e,[`realtimeInputConfig`]);t!==void 0&&y!=null&&J(t,[`setup`,`realtimeInputConfig`],y);let b=Y(e,[`contextWindowCompression`]);t!==void 0&&b!=null&&J(t,[`setup`,`contextWindowCompression`],b);let x=Y(e,[`proactivity`]);if(t!==void 0&&x!=null&&J(t,[`setup`,`proactivity`],x),Y(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);return n}function jo(e,t){let n={},r=Y(e,[`generationConfig`]);t!==void 0&&r!=null&&J(t,[`setup`,`generationConfig`],Do(r));let i=Y(e,[`responseModalities`]);t!==void 0&&i!=null&&J(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=Y(e,[`temperature`]);t!==void 0&&a!=null&&J(t,[`setup`,`generationConfig`,`temperature`],a);let o=Y(e,[`topP`]);t!==void 0&&o!=null&&J(t,[`setup`,`generationConfig`,`topP`],o);let s=Y(e,[`topK`]);t!==void 0&&s!=null&&J(t,[`setup`,`generationConfig`,`topK`],s);let c=Y(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&J(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=Y(e,[`mediaResolution`]);t!==void 0&&l!=null&&J(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=Y(e,[`seed`]);t!==void 0&&u!=null&&J(t,[`setup`,`generationConfig`,`seed`],u);let d=Y(e,[`speechConfig`]);t!==void 0&&d!=null&&J(t,[`setup`,`generationConfig`,`speechConfig`],ni(d));let f=Y(e,[`thinkingConfig`]);t!==void 0&&f!=null&&J(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=Y(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&J(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=Y(e,[`systemInstruction`]);t!==void 0&&m!=null&&J(t,[`setup`,`systemInstruction`],Yr(m));let h=Y(e,[`tools`]);if(t!==void 0&&h!=null){let e=ii(h);Array.isArray(e)&&(e=e.map(e=>Ho(ri(e)))),J(t,[`setup`,`tools`],e)}let g=Y(e,[`sessionResumption`]);t!==void 0&&g!=null&&J(t,[`setup`,`sessionResumption`],g);let _=Y(e,[`inputAudioTranscription`]);t!==void 0&&_!=null&&J(t,[`setup`,`inputAudioTranscription`],_);let v=Y(e,[`outputAudioTranscription`]);t!==void 0&&v!=null&&J(t,[`setup`,`outputAudioTranscription`],v);let y=Y(e,[`realtimeInputConfig`]);t!==void 0&&y!=null&&J(t,[`setup`,`realtimeInputConfig`],y);let b=Y(e,[`contextWindowCompression`]);t!==void 0&&b!=null&&J(t,[`setup`,`contextWindowCompression`],b);let x=Y(e,[`proactivity`]);t!==void 0&&x!=null&&J(t,[`setup`,`proactivity`],x);let S=Y(e,[`explicitVadSignal`]);return t!==void 0&&S!=null&&J(t,[`setup`,`explicitVadSignal`],S),n}function Mo(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`setup`,`model`],Rr(e,r));let i=Y(t,[`config`]);return i!=null&&J(n,[`config`],Ao(i,n)),n}function No(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`setup`,`model`],Rr(e,r));let i=Y(t,[`config`]);return i!=null&&J(n,[`config`],jo(i,n)),n}function Po(e){let t={},n=Y(e,[`musicGenerationConfig`]);return n!=null&&J(t,[`musicGenerationConfig`],n),t}function Fo(e){let t={},n=Y(e,[`weightedPrompts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`weightedPrompts`],e)}return t}function Io(e){let t={},n=Y(e,[`media`]);if(n!=null){let e=Br(n);Array.isArray(e)&&(e=e.map(e=>So(e))),J(t,[`mediaChunks`],e)}let r=Y(e,[`audio`]);r!=null&&J(t,[`audio`],So(Ur(r)));let i=Y(e,[`audioStreamEnd`]);i!=null&&J(t,[`audioStreamEnd`],i);let a=Y(e,[`video`]);a!=null&&J(t,[`video`],So(Hr(a)));let o=Y(e,[`text`]);o!=null&&J(t,[`text`],o);let s=Y(e,[`activityStart`]);s!=null&&J(t,[`activityStart`],s);let c=Y(e,[`activityEnd`]);return c!=null&&J(t,[`activityEnd`],c),t}function Lo(e){let t={},n=Y(e,[`media`]);if(n!=null){let e=Br(n);Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`mediaChunks`],e)}let r=Y(e,[`audio`]);r!=null&&J(t,[`audio`],Ur(r));let i=Y(e,[`audioStreamEnd`]);i!=null&&J(t,[`audioStreamEnd`],i);let a=Y(e,[`video`]);a!=null&&J(t,[`video`],Hr(a));let o=Y(e,[`text`]);o!=null&&J(t,[`text`],o);let s=Y(e,[`activityStart`]);s!=null&&J(t,[`activityStart`],s);let c=Y(e,[`activityEnd`]);return c!=null&&J(t,[`activityEnd`],c),t}function Ro(e){let t={},n=Y(e,[`setupComplete`]);n!=null&&J(t,[`setupComplete`],n);let r=Y(e,[`serverContent`]);r!=null&&J(t,[`serverContent`],r);let i=Y(e,[`toolCall`]);i!=null&&J(t,[`toolCall`],i);let a=Y(e,[`toolCallCancellation`]);a!=null&&J(t,[`toolCallCancellation`],a);let o=Y(e,[`usageMetadata`]);o!=null&&J(t,[`usageMetadata`],Uo(o));let s=Y(e,[`goAway`]);s!=null&&J(t,[`goAway`],s);let c=Y(e,[`sessionResumptionUpdate`]);c!=null&&J(t,[`sessionResumptionUpdate`],c);let l=Y(e,[`voiceActivityDetectionSignal`]);return l!=null&&J(t,[`voiceActivityDetectionSignal`],l),t}function zo(e){let t={},n=Y(e,[`mediaResolution`]);n!=null&&J(t,[`mediaResolution`],n);let r=Y(e,[`codeExecutionResult`]);r!=null&&J(t,[`codeExecutionResult`],r);let i=Y(e,[`executableCode`]);i!=null&&J(t,[`executableCode`],i);let a=Y(e,[`fileData`]);a!=null&&J(t,[`fileData`],wo(a));let o=Y(e,[`functionCall`]);o!=null&&J(t,[`functionCall`],To(o));let s=Y(e,[`functionResponse`]);s!=null&&J(t,[`functionResponse`],s);let c=Y(e,[`inlineData`]);c!=null&&J(t,[`inlineData`],So(c));let l=Y(e,[`text`]);l!=null&&J(t,[`text`],l);let u=Y(e,[`thought`]);u!=null&&J(t,[`thought`],u);let d=Y(e,[`thoughtSignature`]);d!=null&&J(t,[`thoughtSignature`],d);let f=Y(e,[`videoMetadata`]);return f!=null&&J(t,[`videoMetadata`],f),t}function Bo(e){let t={},n=Y(e,[`handle`]);if(n!=null&&J(t,[`handle`],n),Y(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function Vo(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`functionDeclarations`],e)}if(Y(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=Y(e,[`googleSearchRetrieval`]);r!=null&&J(t,[`googleSearchRetrieval`],r);let i=Y(e,[`computerUse`]);i!=null&&J(t,[`computerUse`],i);let a=Y(e,[`fileSearch`]);a!=null&&J(t,[`fileSearch`],a);let o=Y(e,[`codeExecution`]);if(o!=null&&J(t,[`codeExecution`],o),Y(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=Y(e,[`googleMaps`]);s!=null&&J(t,[`googleMaps`],Oo(s));let c=Y(e,[`googleSearch`]);c!=null&&J(t,[`googleSearch`],ko(c));let l=Y(e,[`urlContext`]);return l!=null&&J(t,[`urlContext`],l),t}function Ho(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Eo(e))),J(t,[`functionDeclarations`],e)}let r=Y(e,[`retrieval`]);r!=null&&J(t,[`retrieval`],r);let i=Y(e,[`googleSearchRetrieval`]);i!=null&&J(t,[`googleSearchRetrieval`],i);let a=Y(e,[`computerUse`]);if(a!=null&&J(t,[`computerUse`],a),Y(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Vertex AI.`);let o=Y(e,[`codeExecution`]);o!=null&&J(t,[`codeExecution`],o);let s=Y(e,[`enterpriseWebSearch`]);s!=null&&J(t,[`enterpriseWebSearch`],s);let c=Y(e,[`googleMaps`]);c!=null&&J(t,[`googleMaps`],c);let l=Y(e,[`googleSearch`]);l!=null&&J(t,[`googleSearch`],l);let u=Y(e,[`urlContext`]);return u!=null&&J(t,[`urlContext`],u),t}function Uo(e){let t={},n=Y(e,[`promptTokenCount`]);n!=null&&J(t,[`promptTokenCount`],n);let r=Y(e,[`cachedContentTokenCount`]);r!=null&&J(t,[`cachedContentTokenCount`],r);let i=Y(e,[`candidatesTokenCount`]);i!=null&&J(t,[`responseTokenCount`],i);let a=Y(e,[`toolUsePromptTokenCount`]);a!=null&&J(t,[`toolUsePromptTokenCount`],a);let o=Y(e,[`thoughtsTokenCount`]);o!=null&&J(t,[`thoughtsTokenCount`],o);let s=Y(e,[`totalTokenCount`]);s!=null&&J(t,[`totalTokenCount`],s);let c=Y(e,[`promptTokensDetails`]);if(c!=null){let e=c;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`promptTokensDetails`],e)}let l=Y(e,[`cacheTokensDetails`]);if(l!=null){let e=l;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`cacheTokensDetails`],e)}let u=Y(e,[`candidatesTokensDetails`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`responseTokensDetails`],e)}let d=Y(e,[`toolUsePromptTokensDetails`]);if(d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`toolUsePromptTokensDetails`],e)}let f=Y(e,[`trafficType`]);return f!=null&&J(t,[`trafficType`],f),t}function Wo(e){let t={},n=Y(e,[`data`]);if(n!=null&&J(t,[`data`],n),Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function Go(e){let t={},n=Y(e,[`content`]);n!=null&&J(t,[`content`],n);let r=Y(e,[`citationMetadata`]);r!=null&&J(t,[`citationMetadata`],Ko(r));let i=Y(e,[`tokenCount`]);i!=null&&J(t,[`tokenCount`],i);let a=Y(e,[`finishReason`]);a!=null&&J(t,[`finishReason`],a);let o=Y(e,[`avgLogprobs`]);o!=null&&J(t,[`avgLogprobs`],o);let s=Y(e,[`groundingMetadata`]);s!=null&&J(t,[`groundingMetadata`],s);let c=Y(e,[`index`]);c!=null&&J(t,[`index`],c);let l=Y(e,[`logprobsResult`]);l!=null&&J(t,[`logprobsResult`],l);let u=Y(e,[`safetyRatings`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`safetyRatings`],e)}let d=Y(e,[`urlContextMetadata`]);return d!=null&&J(t,[`urlContextMetadata`],d),t}function Ko(e){let t={},n=Y(e,[`citationSources`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`citations`],e)}return t}function qo(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let e=Zr(i);Array.isArray(e)&&(e=e.map(e=>e)),J(n,[`contents`],e)}return n}function Jo(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`tokensInfo`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`tokensInfo`],e)}return t}function Yo(e){let t={},n=Y(e,[`values`]);n!=null&&J(t,[`values`],n);let r=Y(e,[`statistics`]);return r!=null&&J(t,[`statistics`],Xo(r)),t}function Xo(e){let t={},n=Y(e,[`truncated`]);n!=null&&J(t,[`truncated`],n);let r=Y(e,[`token_count`]);return r!=null&&J(t,[`tokenCount`],r),t}function Zo(e){let t={},n=Y(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>gc(e))),J(t,[`parts`],e)}let r=Y(e,[`role`]);return r!=null&&J(t,[`role`],r),t}function Qo(e){let t={},n=Y(e,[`controlType`]);n!=null&&J(t,[`controlType`],n);let r=Y(e,[`enableControlImageComputation`]);return r!=null&&J(t,[`computeControl`],r),t}function $o(e){let t={};if(Y(e,[`systemInstruction`])!==void 0)throw Error(`systemInstruction parameter is not supported in Gemini API.`);if(Y(e,[`tools`])!==void 0)throw Error(`tools parameter is not supported in Gemini API.`);if(Y(e,[`generationConfig`])!==void 0)throw Error(`generationConfig parameter is not supported in Gemini API.`);return t}function es(e,t){let n={},r=Y(e,[`systemInstruction`]);t!==void 0&&r!=null&&J(t,[`systemInstruction`],Yr(r));let i=Y(e,[`tools`]);if(t!==void 0&&i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>Nc(e))),J(t,[`tools`],e)}let a=Y(e,[`generationConfig`]);return t!==void 0&&a!=null&&J(t,[`generationConfig`],Xs(a)),n}function ts(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let e=Zr(i);Array.isArray(e)&&(e=e.map(e=>Zo(e))),J(n,[`contents`],e)}let a=Y(t,[`config`]);return a!=null&&$o(a),n}function ns(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let e=Zr(i);Array.isArray(e)&&(e=e.map(e=>e)),J(n,[`contents`],e)}let a=Y(t,[`config`]);return a!=null&&es(a,n),n}function rs(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`totalTokens`]);r!=null&&J(t,[`totalTokens`],r);let i=Y(e,[`cachedContentTokenCount`]);return i!=null&&J(t,[`cachedContentTokenCount`],i),t}function is(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`totalTokens`]);return r!=null&&J(t,[`totalTokens`],r),t}function as(e,t){let n={},r=Y(t,[`model`]);return r!=null&&J(n,[`_url`,`name`],Rr(e,r)),n}function os(e,t){let n={},r=Y(t,[`model`]);return r!=null&&J(n,[`_url`,`name`],Rr(e,r)),n}function ss(e){let t={},n=Y(e,[`sdkHttpResponse`]);return n!=null&&J(t,[`sdkHttpResponse`],n),t}function cs(e){let t={},n=Y(e,[`sdkHttpResponse`]);return n!=null&&J(t,[`sdkHttpResponse`],n),t}function ls(e,t){let n={},r=Y(e,[`outputGcsUri`]);t!==void 0&&r!=null&&J(t,[`parameters`,`storageUri`],r);let i=Y(e,[`negativePrompt`]);t!==void 0&&i!=null&&J(t,[`parameters`,`negativePrompt`],i);let a=Y(e,[`numberOfImages`]);t!==void 0&&a!=null&&J(t,[`parameters`,`sampleCount`],a);let o=Y(e,[`aspectRatio`]);t!==void 0&&o!=null&&J(t,[`parameters`,`aspectRatio`],o);let s=Y(e,[`guidanceScale`]);t!==void 0&&s!=null&&J(t,[`parameters`,`guidanceScale`],s);let c=Y(e,[`seed`]);t!==void 0&&c!=null&&J(t,[`parameters`,`seed`],c);let l=Y(e,[`safetyFilterLevel`]);t!==void 0&&l!=null&&J(t,[`parameters`,`safetySetting`],l);let u=Y(e,[`personGeneration`]);t!==void 0&&u!=null&&J(t,[`parameters`,`personGeneration`],u);let d=Y(e,[`includeSafetyAttributes`]);t!==void 0&&d!=null&&J(t,[`parameters`,`includeSafetyAttributes`],d);let f=Y(e,[`includeRaiReason`]);t!==void 0&&f!=null&&J(t,[`parameters`,`includeRaiReason`],f);let p=Y(e,[`language`]);t!==void 0&&p!=null&&J(t,[`parameters`,`language`],p);let m=Y(e,[`outputMimeType`]);t!==void 0&&m!=null&&J(t,[`parameters`,`outputOptions`,`mimeType`],m);let h=Y(e,[`outputCompressionQuality`]);t!==void 0&&h!=null&&J(t,[`parameters`,`outputOptions`,`compressionQuality`],h);let g=Y(e,[`addWatermark`]);t!==void 0&&g!=null&&J(t,[`parameters`,`addWatermark`],g);let _=Y(e,[`labels`]);t!==void 0&&_!=null&&J(t,[`labels`],_);let v=Y(e,[`editMode`]);t!==void 0&&v!=null&&J(t,[`parameters`,`editMode`],v);let y=Y(e,[`baseSteps`]);return t!==void 0&&y!=null&&J(t,[`parameters`,`editConfig`,`baseSteps`],y),n}function us(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`prompt`]);i!=null&&J(n,[`instances[0]`,`prompt`],i);let a=Y(t,[`referenceImages`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>Sc(e))),J(n,[`instances[0]`,`referenceImages`],e)}let o=Y(t,[`config`]);return o!=null&&ls(o,n),n}function ds(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Ks(e))),J(t,[`generatedImages`],e)}return t}function fs(e,t){let n={},r=Y(e,[`taskType`]);t!==void 0&&r!=null&&J(t,[`requests[]`,`taskType`],r);let i=Y(e,[`title`]);t!==void 0&&i!=null&&J(t,[`requests[]`,`title`],i);let a=Y(e,[`outputDimensionality`]);if(t!==void 0&&a!=null&&J(t,[`requests[]`,`outputDimensionality`],a),Y(e,[`mimeType`])!==void 0)throw Error(`mimeType parameter is not supported in Gemini API.`);if(Y(e,[`autoTruncate`])!==void 0)throw Error(`autoTruncate parameter is not supported in Gemini API.`);return n}function ps(e,t){let n={},r=Y(e,[`taskType`]);t!==void 0&&r!=null&&J(t,[`instances[]`,`task_type`],r);let i=Y(e,[`title`]);t!==void 0&&i!=null&&J(t,[`instances[]`,`title`],i);let a=Y(e,[`outputDimensionality`]);t!==void 0&&a!=null&&J(t,[`parameters`,`outputDimensionality`],a);let o=Y(e,[`mimeType`]);t!==void 0&&o!=null&&J(t,[`instances[]`,`mimeType`],o);let s=Y(e,[`autoTruncate`]);return t!==void 0&&s!=null&&J(t,[`parameters`,`autoTruncate`],s),n}function ms(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let t=Xr(e,i);Array.isArray(t)&&(t=t.map(e=>e)),J(n,[`requests[]`,`content`],t)}let a=Y(t,[`config`]);a!=null&&fs(a,n);let o=Y(t,[`model`]);return o!==void 0&&J(n,[`requests[]`,`model`],Rr(e,o)),n}function hs(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let t=Xr(e,i);Array.isArray(t)&&(t=t.map(e=>e)),J(n,[`instances[]`,`content`],t)}let a=Y(t,[`config`]);return a!=null&&ps(a,n),n}function gs(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`embeddings`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`embeddings`],e)}let i=Y(e,[`metadata`]);return i!=null&&J(t,[`metadata`],i),t}function _s(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`predictions[]`,`embeddings`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Yo(e))),J(t,[`embeddings`],e)}let i=Y(e,[`metadata`]);return i!=null&&J(t,[`metadata`],i),t}function vs(e){let t={},n=Y(e,[`endpoint`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`deployedModelId`]);return r!=null&&J(t,[`deployedModelId`],r),t}function ys(e){let t={};if(Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=Y(e,[`fileUri`]);n!=null&&J(t,[`fileUri`],n);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function bs(e){let t={},n=Y(e,[`id`]);n!=null&&J(t,[`id`],n);let r=Y(e,[`args`]);r!=null&&J(t,[`args`],r);let i=Y(e,[`name`]);if(i!=null&&J(t,[`name`],i),Y(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(Y(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function xs(e){let t={},n=Y(e,[`mode`]);n!=null&&J(t,[`mode`],n);let r=Y(e,[`allowedFunctionNames`]);if(r!=null&&J(t,[`allowedFunctionNames`],r),Y(e,[`streamFunctionCallArguments`])!==void 0)throw Error(`streamFunctionCallArguments parameter is not supported in Gemini API.`);return t}function Ss(e){let t={};if(Y(e,[`behavior`])!==void 0)throw Error(`behavior parameter is not supported in Vertex AI.`);let n=Y(e,[`description`]);n!=null&&J(t,[`description`],n);let r=Y(e,[`name`]);r!=null&&J(t,[`name`],r);let i=Y(e,[`parameters`]);i!=null&&J(t,[`parameters`],i);let a=Y(e,[`parametersJsonSchema`]);a!=null&&J(t,[`parametersJsonSchema`],a);let o=Y(e,[`response`]);o!=null&&J(t,[`response`],o);let s=Y(e,[`responseJsonSchema`]);return s!=null&&J(t,[`responseJsonSchema`],s),t}function Cs(e,t,n){let r={},i=Y(t,[`systemInstruction`]);n!==void 0&&i!=null&&J(n,[`systemInstruction`],Zo(Yr(i)));let a=Y(t,[`temperature`]);a!=null&&J(r,[`temperature`],a);let o=Y(t,[`topP`]);o!=null&&J(r,[`topP`],o);let s=Y(t,[`topK`]);s!=null&&J(r,[`topK`],s);let c=Y(t,[`candidateCount`]);c!=null&&J(r,[`candidateCount`],c);let l=Y(t,[`maxOutputTokens`]);l!=null&&J(r,[`maxOutputTokens`],l);let u=Y(t,[`stopSequences`]);u!=null&&J(r,[`stopSequences`],u);let d=Y(t,[`responseLogprobs`]);d!=null&&J(r,[`responseLogprobs`],d);let f=Y(t,[`logprobs`]);f!=null&&J(r,[`logprobs`],f);let p=Y(t,[`presencePenalty`]);p!=null&&J(r,[`presencePenalty`],p);let m=Y(t,[`frequencyPenalty`]);m!=null&&J(r,[`frequencyPenalty`],m);let h=Y(t,[`seed`]);h!=null&&J(r,[`seed`],h);let g=Y(t,[`responseMimeType`]);g!=null&&J(r,[`responseMimeType`],g);let _=Y(t,[`responseSchema`]);_!=null&&J(r,[`responseSchema`],ei(_));let v=Y(t,[`responseJsonSchema`]);if(v!=null&&J(r,[`responseJsonSchema`],v),Y(t,[`routingConfig`])!==void 0)throw Error(`routingConfig parameter is not supported in Gemini API.`);if(Y(t,[`modelSelectionConfig`])!==void 0)throw Error(`modelSelectionConfig parameter is not supported in Gemini API.`);let y=Y(t,[`safetySettings`]);if(n!==void 0&&y!=null){let e=y;Array.isArray(e)&&(e=e.map(e=>Tc(e))),J(n,[`safetySettings`],e)}let b=Y(t,[`tools`]);if(n!==void 0&&b!=null){let e=ii(b);Array.isArray(e)&&(e=e.map(e=>Mc(ri(e)))),J(n,[`tools`],e)}let x=Y(t,[`toolConfig`]);if(n!==void 0&&x!=null&&J(n,[`toolConfig`],jc(x)),Y(t,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let S=Y(t,[`cachedContent`]);n!==void 0&&S!=null&&J(n,[`cachedContent`],oi(e,S));let C=Y(t,[`responseModalities`]);C!=null&&J(r,[`responseModalities`],C);let w=Y(t,[`mediaResolution`]);w!=null&&J(r,[`mediaResolution`],w);let T=Y(t,[`speechConfig`]);if(T!=null&&J(r,[`speechConfig`],ti(T)),Y(t,[`audioTimestamp`])!==void 0)throw Error(`audioTimestamp parameter is not supported in Gemini API.`);let E=Y(t,[`thinkingConfig`]);E!=null&&J(r,[`thinkingConfig`],E);let D=Y(t,[`imageConfig`]);D!=null&&J(r,[`imageConfig`],tc(D));let O=Y(t,[`enableEnhancedCivicAnswers`]);return O!=null&&J(r,[`enableEnhancedCivicAnswers`],O),r}function ws(e,t,n){let r={},i=Y(t,[`systemInstruction`]);n!==void 0&&i!=null&&J(n,[`systemInstruction`],Yr(i));let a=Y(t,[`temperature`]);a!=null&&J(r,[`temperature`],a);let o=Y(t,[`topP`]);o!=null&&J(r,[`topP`],o);let s=Y(t,[`topK`]);s!=null&&J(r,[`topK`],s);let c=Y(t,[`candidateCount`]);c!=null&&J(r,[`candidateCount`],c);let l=Y(t,[`maxOutputTokens`]);l!=null&&J(r,[`maxOutputTokens`],l);let u=Y(t,[`stopSequences`]);u!=null&&J(r,[`stopSequences`],u);let d=Y(t,[`responseLogprobs`]);d!=null&&J(r,[`responseLogprobs`],d);let f=Y(t,[`logprobs`]);f!=null&&J(r,[`logprobs`],f);let p=Y(t,[`presencePenalty`]);p!=null&&J(r,[`presencePenalty`],p);let m=Y(t,[`frequencyPenalty`]);m!=null&&J(r,[`frequencyPenalty`],m);let h=Y(t,[`seed`]);h!=null&&J(r,[`seed`],h);let g=Y(t,[`responseMimeType`]);g!=null&&J(r,[`responseMimeType`],g);let _=Y(t,[`responseSchema`]);_!=null&&J(r,[`responseSchema`],ei(_));let v=Y(t,[`responseJsonSchema`]);v!=null&&J(r,[`responseJsonSchema`],v);let y=Y(t,[`routingConfig`]);y!=null&&J(r,[`routingConfig`],y);let b=Y(t,[`modelSelectionConfig`]);b!=null&&J(r,[`modelConfig`],b);let x=Y(t,[`safetySettings`]);if(n!==void 0&&x!=null){let e=x;Array.isArray(e)&&(e=e.map(e=>e)),J(n,[`safetySettings`],e)}let S=Y(t,[`tools`]);if(n!==void 0&&S!=null){let e=ii(S);Array.isArray(e)&&(e=e.map(e=>Nc(ri(e)))),J(n,[`tools`],e)}let C=Y(t,[`toolConfig`]);n!==void 0&&C!=null&&J(n,[`toolConfig`],C);let w=Y(t,[`labels`]);n!==void 0&&w!=null&&J(n,[`labels`],w);let T=Y(t,[`cachedContent`]);n!==void 0&&T!=null&&J(n,[`cachedContent`],oi(e,T));let E=Y(t,[`responseModalities`]);E!=null&&J(r,[`responseModalities`],E);let D=Y(t,[`mediaResolution`]);D!=null&&J(r,[`mediaResolution`],D);let O=Y(t,[`speechConfig`]);O!=null&&J(r,[`speechConfig`],ti(O));let k=Y(t,[`audioTimestamp`]);k!=null&&J(r,[`audioTimestamp`],k);let A=Y(t,[`thinkingConfig`]);A!=null&&J(r,[`thinkingConfig`],A);let j=Y(t,[`imageConfig`]);if(j!=null&&J(r,[`imageConfig`],nc(j)),Y(t,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Vertex AI.`);return r}function Ts(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let e=Zr(i);Array.isArray(e)&&(e=e.map(e=>Zo(e))),J(n,[`contents`],e)}let a=Y(t,[`config`]);return a!=null&&J(n,[`generationConfig`],Cs(e,a,n)),n}function Es(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`contents`]);if(i!=null){let e=Zr(i);Array.isArray(e)&&(e=e.map(e=>e)),J(n,[`contents`],e)}let a=Y(t,[`config`]);return a!=null&&J(n,[`generationConfig`],ws(e,a,n)),n}function Ds(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`candidates`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Go(e))),J(t,[`candidates`],e)}let i=Y(e,[`modelVersion`]);i!=null&&J(t,[`modelVersion`],i);let a=Y(e,[`promptFeedback`]);a!=null&&J(t,[`promptFeedback`],a);let o=Y(e,[`responseId`]);o!=null&&J(t,[`responseId`],o);let s=Y(e,[`usageMetadata`]);return s!=null&&J(t,[`usageMetadata`],s),t}function Os(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`candidates`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`candidates`],e)}let i=Y(e,[`createTime`]);i!=null&&J(t,[`createTime`],i);let a=Y(e,[`modelVersion`]);a!=null&&J(t,[`modelVersion`],a);let o=Y(e,[`promptFeedback`]);o!=null&&J(t,[`promptFeedback`],o);let s=Y(e,[`responseId`]);s!=null&&J(t,[`responseId`],s);let c=Y(e,[`usageMetadata`]);return c!=null&&J(t,[`usageMetadata`],c),t}function ks(e,t){let n={};if(Y(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(Y(e,[`negativePrompt`])!==void 0)throw Error(`negativePrompt parameter is not supported in Gemini API.`);let r=Y(e,[`numberOfImages`]);t!==void 0&&r!=null&&J(t,[`parameters`,`sampleCount`],r);let i=Y(e,[`aspectRatio`]);t!==void 0&&i!=null&&J(t,[`parameters`,`aspectRatio`],i);let a=Y(e,[`guidanceScale`]);if(t!==void 0&&a!=null&&J(t,[`parameters`,`guidanceScale`],a),Y(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let o=Y(e,[`safetyFilterLevel`]);t!==void 0&&o!=null&&J(t,[`parameters`,`safetySetting`],o);let s=Y(e,[`personGeneration`]);t!==void 0&&s!=null&&J(t,[`parameters`,`personGeneration`],s);let c=Y(e,[`includeSafetyAttributes`]);t!==void 0&&c!=null&&J(t,[`parameters`,`includeSafetyAttributes`],c);let l=Y(e,[`includeRaiReason`]);t!==void 0&&l!=null&&J(t,[`parameters`,`includeRaiReason`],l);let u=Y(e,[`language`]);t!==void 0&&u!=null&&J(t,[`parameters`,`language`],u);let d=Y(e,[`outputMimeType`]);t!==void 0&&d!=null&&J(t,[`parameters`,`outputOptions`,`mimeType`],d);let f=Y(e,[`outputCompressionQuality`]);if(t!==void 0&&f!=null&&J(t,[`parameters`,`outputOptions`,`compressionQuality`],f),Y(e,[`addWatermark`])!==void 0)throw Error(`addWatermark parameter is not supported in Gemini API.`);if(Y(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);let p=Y(e,[`imageSize`]);if(t!==void 0&&p!=null&&J(t,[`parameters`,`sampleImageSize`],p),Y(e,[`enhancePrompt`])!==void 0)throw Error(`enhancePrompt parameter is not supported in Gemini API.`);return n}function As(e,t){let n={},r=Y(e,[`outputGcsUri`]);t!==void 0&&r!=null&&J(t,[`parameters`,`storageUri`],r);let i=Y(e,[`negativePrompt`]);t!==void 0&&i!=null&&J(t,[`parameters`,`negativePrompt`],i);let a=Y(e,[`numberOfImages`]);t!==void 0&&a!=null&&J(t,[`parameters`,`sampleCount`],a);let o=Y(e,[`aspectRatio`]);t!==void 0&&o!=null&&J(t,[`parameters`,`aspectRatio`],o);let s=Y(e,[`guidanceScale`]);t!==void 0&&s!=null&&J(t,[`parameters`,`guidanceScale`],s);let c=Y(e,[`seed`]);t!==void 0&&c!=null&&J(t,[`parameters`,`seed`],c);let l=Y(e,[`safetyFilterLevel`]);t!==void 0&&l!=null&&J(t,[`parameters`,`safetySetting`],l);let u=Y(e,[`personGeneration`]);t!==void 0&&u!=null&&J(t,[`parameters`,`personGeneration`],u);let d=Y(e,[`includeSafetyAttributes`]);t!==void 0&&d!=null&&J(t,[`parameters`,`includeSafetyAttributes`],d);let f=Y(e,[`includeRaiReason`]);t!==void 0&&f!=null&&J(t,[`parameters`,`includeRaiReason`],f);let p=Y(e,[`language`]);t!==void 0&&p!=null&&J(t,[`parameters`,`language`],p);let m=Y(e,[`outputMimeType`]);t!==void 0&&m!=null&&J(t,[`parameters`,`outputOptions`,`mimeType`],m);let h=Y(e,[`outputCompressionQuality`]);t!==void 0&&h!=null&&J(t,[`parameters`,`outputOptions`,`compressionQuality`],h);let g=Y(e,[`addWatermark`]);t!==void 0&&g!=null&&J(t,[`parameters`,`addWatermark`],g);let _=Y(e,[`labels`]);t!==void 0&&_!=null&&J(t,[`labels`],_);let v=Y(e,[`imageSize`]);t!==void 0&&v!=null&&J(t,[`parameters`,`sampleImageSize`],v);let y=Y(e,[`enhancePrompt`]);return t!==void 0&&y!=null&&J(t,[`parameters`,`enhancePrompt`],y),n}function js(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`prompt`]);i!=null&&J(n,[`instances[0]`,`prompt`],i);let a=Y(t,[`config`]);return a!=null&&ks(a,n),n}function Ms(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`prompt`]);i!=null&&J(n,[`instances[0]`,`prompt`],i);let a=Y(t,[`config`]);return a!=null&&As(a,n),n}function Ns(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Gs(e))),J(t,[`generatedImages`],e)}let i=Y(e,[`positivePromptSafetyAttributes`]);return i!=null&&J(t,[`positivePromptSafetyAttributes`],Cc(i)),t}function Ps(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Ks(e))),J(t,[`generatedImages`],e)}let i=Y(e,[`positivePromptSafetyAttributes`]);return i!=null&&J(t,[`positivePromptSafetyAttributes`],wc(i)),t}function Fs(e,t){let n={},r=Y(e,[`numberOfVideos`]);if(t!==void 0&&r!=null&&J(t,[`parameters`,`sampleCount`],r),Y(e,[`outputGcsUri`])!==void 0)throw Error(`outputGcsUri parameter is not supported in Gemini API.`);if(Y(e,[`fps`])!==void 0)throw Error(`fps parameter is not supported in Gemini API.`);let i=Y(e,[`durationSeconds`]);if(t!==void 0&&i!=null&&J(t,[`parameters`,`durationSeconds`],i),Y(e,[`seed`])!==void 0)throw Error(`seed parameter is not supported in Gemini API.`);let a=Y(e,[`aspectRatio`]);t!==void 0&&a!=null&&J(t,[`parameters`,`aspectRatio`],a);let o=Y(e,[`resolution`]);t!==void 0&&o!=null&&J(t,[`parameters`,`resolution`],o);let s=Y(e,[`personGeneration`]);if(t!==void 0&&s!=null&&J(t,[`parameters`,`personGeneration`],s),Y(e,[`pubsubTopic`])!==void 0)throw Error(`pubsubTopic parameter is not supported in Gemini API.`);let c=Y(e,[`negativePrompt`]);t!==void 0&&c!=null&&J(t,[`parameters`,`negativePrompt`],c);let l=Y(e,[`enhancePrompt`]);if(t!==void 0&&l!=null&&J(t,[`parameters`,`enhancePrompt`],l),Y(e,[`generateAudio`])!==void 0)throw Error(`generateAudio parameter is not supported in Gemini API.`);let u=Y(e,[`lastFrame`]);t!==void 0&&u!=null&&J(t,[`instances[0]`,`lastFrame`],ac(u));let d=Y(e,[`referenceImages`]);if(t!==void 0&&d!=null){let e=d;Array.isArray(e)&&(e=e.map(e=>Kc(e))),J(t,[`instances[0]`,`referenceImages`],e)}if(Y(e,[`mask`])!==void 0)throw Error(`mask parameter is not supported in Gemini API.`);if(Y(e,[`compressionQuality`])!==void 0)throw Error(`compressionQuality parameter is not supported in Gemini API.`);return n}function Is(e,t){let n={},r=Y(e,[`numberOfVideos`]);t!==void 0&&r!=null&&J(t,[`parameters`,`sampleCount`],r);let i=Y(e,[`outputGcsUri`]);t!==void 0&&i!=null&&J(t,[`parameters`,`storageUri`],i);let a=Y(e,[`fps`]);t!==void 0&&a!=null&&J(t,[`parameters`,`fps`],a);let o=Y(e,[`durationSeconds`]);t!==void 0&&o!=null&&J(t,[`parameters`,`durationSeconds`],o);let s=Y(e,[`seed`]);t!==void 0&&s!=null&&J(t,[`parameters`,`seed`],s);let c=Y(e,[`aspectRatio`]);t!==void 0&&c!=null&&J(t,[`parameters`,`aspectRatio`],c);let l=Y(e,[`resolution`]);t!==void 0&&l!=null&&J(t,[`parameters`,`resolution`],l);let u=Y(e,[`personGeneration`]);t!==void 0&&u!=null&&J(t,[`parameters`,`personGeneration`],u);let d=Y(e,[`pubsubTopic`]);t!==void 0&&d!=null&&J(t,[`parameters`,`pubsubTopic`],d);let f=Y(e,[`negativePrompt`]);t!==void 0&&f!=null&&J(t,[`parameters`,`negativePrompt`],f);let p=Y(e,[`enhancePrompt`]);t!==void 0&&p!=null&&J(t,[`parameters`,`enhancePrompt`],p);let m=Y(e,[`generateAudio`]);t!==void 0&&m!=null&&J(t,[`parameters`,`generateAudio`],m);let h=Y(e,[`lastFrame`]);t!==void 0&&h!=null&&J(t,[`instances[0]`,`lastFrame`],oc(h));let g=Y(e,[`referenceImages`]);if(t!==void 0&&g!=null){let e=g;Array.isArray(e)&&(e=e.map(e=>qc(e))),J(t,[`instances[0]`,`referenceImages`],e)}let _=Y(e,[`mask`]);t!==void 0&&_!=null&&J(t,[`instances[0]`,`mask`],Gc(_));let v=Y(e,[`compressionQuality`]);return t!==void 0&&v!=null&&J(t,[`parameters`,`compressionQuality`],v),n}function Ls(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`]);r!=null&&J(t,[`metadata`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`response`,`generateVideoResponse`]);return o!=null&&J(t,[`response`],Vs(o)),t}function Rs(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`]);r!=null&&J(t,[`metadata`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`response`]);return o!=null&&J(t,[`response`],Hs(o)),t}function zs(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`prompt`]);i!=null&&J(n,[`instances[0]`,`prompt`],i);let a=Y(t,[`image`]);a!=null&&J(n,[`instances[0]`,`image`],ac(a));let o=Y(t,[`video`]);o!=null&&J(n,[`instances[0]`,`video`],Jc(o));let s=Y(t,[`source`]);s!=null&&Us(s,n);let c=Y(t,[`config`]);return c!=null&&Fs(c,n),n}function Bs(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`prompt`]);i!=null&&J(n,[`instances[0]`,`prompt`],i);let a=Y(t,[`image`]);a!=null&&J(n,[`instances[0]`,`image`],oc(a));let o=Y(t,[`video`]);o!=null&&J(n,[`instances[0]`,`video`],Yc(o));let s=Y(t,[`source`]);s!=null&&Ws(s,n);let c=Y(t,[`config`]);return c!=null&&Is(c,n),n}function Vs(e){let t={},n=Y(e,[`generatedSamples`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Js(e))),J(t,[`generatedVideos`],e)}let r=Y(e,[`raiMediaFilteredCount`]);r!=null&&J(t,[`raiMediaFilteredCount`],r);let i=Y(e,[`raiMediaFilteredReasons`]);return i!=null&&J(t,[`raiMediaFilteredReasons`],i),t}function Hs(e){let t={},n=Y(e,[`videos`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Ys(e))),J(t,[`generatedVideos`],e)}let r=Y(e,[`raiMediaFilteredCount`]);r!=null&&J(t,[`raiMediaFilteredCount`],r);let i=Y(e,[`raiMediaFilteredReasons`]);return i!=null&&J(t,[`raiMediaFilteredReasons`],i),t}function Us(e,t){let n={},r=Y(e,[`prompt`]);t!==void 0&&r!=null&&J(t,[`instances[0]`,`prompt`],r);let i=Y(e,[`image`]);t!==void 0&&i!=null&&J(t,[`instances[0]`,`image`],ac(i));let a=Y(e,[`video`]);return t!==void 0&&a!=null&&J(t,[`instances[0]`,`video`],Jc(a)),n}function Ws(e,t){let n={},r=Y(e,[`prompt`]);t!==void 0&&r!=null&&J(t,[`instances[0]`,`prompt`],r);let i=Y(e,[`image`]);t!==void 0&&i!=null&&J(t,[`instances[0]`,`image`],oc(i));let a=Y(e,[`video`]);return t!==void 0&&a!=null&&J(t,[`instances[0]`,`video`],Yc(a)),n}function Gs(e){let t={},n=Y(e,[`_self`]);n!=null&&J(t,[`image`],rc(n));let r=Y(e,[`raiFilteredReason`]);r!=null&&J(t,[`raiFilteredReason`],r);let i=Y(e,[`_self`]);return i!=null&&J(t,[`safetyAttributes`],Cc(i)),t}function Ks(e){let t={},n=Y(e,[`_self`]);n!=null&&J(t,[`image`],ic(n));let r=Y(e,[`raiFilteredReason`]);r!=null&&J(t,[`raiFilteredReason`],r);let i=Y(e,[`_self`]);i!=null&&J(t,[`safetyAttributes`],wc(i));let a=Y(e,[`prompt`]);return a!=null&&J(t,[`enhancedPrompt`],a),t}function qs(e){let t={},n=Y(e,[`_self`]);n!=null&&J(t,[`mask`],ic(n));let r=Y(e,[`labels`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`labels`],e)}return t}function Js(e){let t={},n=Y(e,[`video`]);return n!=null&&J(t,[`video`],Uc(n)),t}function Ys(e){let t={},n=Y(e,[`_self`]);return n!=null&&J(t,[`video`],Wc(n)),t}function Xs(e){let t={},n=Y(e,[`modelSelectionConfig`]);n!=null&&J(t,[`modelConfig`],n);let r=Y(e,[`responseJsonSchema`]);r!=null&&J(t,[`responseJsonSchema`],r);let i=Y(e,[`audioTimestamp`]);i!=null&&J(t,[`audioTimestamp`],i);let a=Y(e,[`candidateCount`]);a!=null&&J(t,[`candidateCount`],a);let o=Y(e,[`enableAffectiveDialog`]);o!=null&&J(t,[`enableAffectiveDialog`],o);let s=Y(e,[`frequencyPenalty`]);s!=null&&J(t,[`frequencyPenalty`],s);let c=Y(e,[`logprobs`]);c!=null&&J(t,[`logprobs`],c);let l=Y(e,[`maxOutputTokens`]);l!=null&&J(t,[`maxOutputTokens`],l);let u=Y(e,[`mediaResolution`]);u!=null&&J(t,[`mediaResolution`],u);let d=Y(e,[`presencePenalty`]);d!=null&&J(t,[`presencePenalty`],d);let f=Y(e,[`responseLogprobs`]);f!=null&&J(t,[`responseLogprobs`],f);let p=Y(e,[`responseMimeType`]);p!=null&&J(t,[`responseMimeType`],p);let m=Y(e,[`responseModalities`]);m!=null&&J(t,[`responseModalities`],m);let h=Y(e,[`responseSchema`]);h!=null&&J(t,[`responseSchema`],h);let g=Y(e,[`routingConfig`]);g!=null&&J(t,[`routingConfig`],g);let _=Y(e,[`seed`]);_!=null&&J(t,[`seed`],_);let v=Y(e,[`speechConfig`]);v!=null&&J(t,[`speechConfig`],v);let y=Y(e,[`stopSequences`]);y!=null&&J(t,[`stopSequences`],y);let b=Y(e,[`temperature`]);b!=null&&J(t,[`temperature`],b);let x=Y(e,[`thinkingConfig`]);x!=null&&J(t,[`thinkingConfig`],x);let S=Y(e,[`topK`]);S!=null&&J(t,[`topK`],S);let C=Y(e,[`topP`]);if(C!=null&&J(t,[`topP`],C),Y(e,[`enableEnhancedCivicAnswers`])!==void 0)throw Error(`enableEnhancedCivicAnswers parameter is not supported in Vertex AI.`);return t}function Zs(e,t){let n={},r=Y(t,[`model`]);return r!=null&&J(n,[`_url`,`name`],Rr(e,r)),n}function Qs(e,t){let n={},r=Y(t,[`model`]);return r!=null&&J(n,[`_url`,`name`],Rr(e,r)),n}function $s(e){let t={};if(Y(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=Y(e,[`enableWidget`]);return n!=null&&J(t,[`enableWidget`],n),t}function ec(e){let t={};if(Y(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(Y(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let n=Y(e,[`timeRangeFilter`]);return n!=null&&J(t,[`timeRangeFilter`],n),t}function tc(e){let t={},n=Y(e,[`aspectRatio`]);n!=null&&J(t,[`aspectRatio`],n);let r=Y(e,[`imageSize`]);if(r!=null&&J(t,[`imageSize`],r),Y(e,[`outputMimeType`])!==void 0)throw Error(`outputMimeType parameter is not supported in Gemini API.`);if(Y(e,[`outputCompressionQuality`])!==void 0)throw Error(`outputCompressionQuality parameter is not supported in Gemini API.`);return t}function nc(e){let t={},n=Y(e,[`aspectRatio`]);n!=null&&J(t,[`aspectRatio`],n);let r=Y(e,[`imageSize`]);r!=null&&J(t,[`imageSize`],r);let i=Y(e,[`outputMimeType`]);i!=null&&J(t,[`imageOutputOptions`,`mimeType`],i);let a=Y(e,[`outputCompressionQuality`]);return a!=null&&J(t,[`imageOutputOptions`,`compressionQuality`],a),t}function rc(e){let t={},n=Y(e,[`bytesBase64Encoded`]);n!=null&&J(t,[`imageBytes`],ci(n));let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function ic(e){let t={},n=Y(e,[`gcsUri`]);n!=null&&J(t,[`gcsUri`],n);let r=Y(e,[`bytesBase64Encoded`]);r!=null&&J(t,[`imageBytes`],ci(r));let i=Y(e,[`mimeType`]);return i!=null&&J(t,[`mimeType`],i),t}function ac(e){let t={};if(Y(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);let n=Y(e,[`imageBytes`]);n!=null&&J(t,[`bytesBase64Encoded`],ci(n));let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function oc(e){let t={},n=Y(e,[`gcsUri`]);n!=null&&J(t,[`gcsUri`],n);let r=Y(e,[`imageBytes`]);r!=null&&J(t,[`bytesBase64Encoded`],ci(r));let i=Y(e,[`mimeType`]);return i!=null&&J(t,[`mimeType`],i),t}function sc(e,t,n){let r={},i=Y(t,[`pageSize`]);n!==void 0&&i!=null&&J(n,[`_query`,`pageSize`],i);let a=Y(t,[`pageToken`]);n!==void 0&&a!=null&&J(n,[`_query`,`pageToken`],a);let o=Y(t,[`filter`]);n!==void 0&&o!=null&&J(n,[`_query`,`filter`],o);let s=Y(t,[`queryBase`]);return n!==void 0&&s!=null&&J(n,[`_url`,`models_url`],pi(e,s)),r}function cc(e,t,n){let r={},i=Y(t,[`pageSize`]);n!==void 0&&i!=null&&J(n,[`_query`,`pageSize`],i);let a=Y(t,[`pageToken`]);n!==void 0&&a!=null&&J(n,[`_query`,`pageToken`],a);let o=Y(t,[`filter`]);n!==void 0&&o!=null&&J(n,[`_query`,`filter`],o);let s=Y(t,[`queryBase`]);return n!==void 0&&s!=null&&J(n,[`_url`,`models_url`],pi(e,s)),r}function lc(e,t){let n={},r=Y(t,[`config`]);return r!=null&&sc(e,r,n),n}function uc(e,t){let n={},r=Y(t,[`config`]);return r!=null&&cc(e,r,n),n}function dc(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`_self`]);if(i!=null){let e=mi(i);Array.isArray(e)&&(e=e.map(e=>mc(e))),J(t,[`models`],e)}return t}function fc(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`_self`]);if(i!=null){let e=mi(i);Array.isArray(e)&&(e=e.map(e=>hc(e))),J(t,[`models`],e)}return t}function pc(e){let t={},n=Y(e,[`maskMode`]);n!=null&&J(t,[`maskMode`],n);let r=Y(e,[`segmentationClasses`]);r!=null&&J(t,[`maskClasses`],r);let i=Y(e,[`maskDilation`]);return i!=null&&J(t,[`dilation`],i),t}function mc(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`displayName`]);r!=null&&J(t,[`displayName`],r);let i=Y(e,[`description`]);i!=null&&J(t,[`description`],i);let a=Y(e,[`version`]);a!=null&&J(t,[`version`],a);let o=Y(e,[`_self`]);o!=null&&J(t,[`tunedModelInfo`],Pc(o));let s=Y(e,[`inputTokenLimit`]);s!=null&&J(t,[`inputTokenLimit`],s);let c=Y(e,[`outputTokenLimit`]);c!=null&&J(t,[`outputTokenLimit`],c);let l=Y(e,[`supportedGenerationMethods`]);l!=null&&J(t,[`supportedActions`],l);let u=Y(e,[`temperature`]);u!=null&&J(t,[`temperature`],u);let d=Y(e,[`maxTemperature`]);d!=null&&J(t,[`maxTemperature`],d);let f=Y(e,[`topP`]);f!=null&&J(t,[`topP`],f);let p=Y(e,[`topK`]);p!=null&&J(t,[`topK`],p);let m=Y(e,[`thinking`]);return m!=null&&J(t,[`thinking`],m),t}function hc(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`displayName`]);r!=null&&J(t,[`displayName`],r);let i=Y(e,[`description`]);i!=null&&J(t,[`description`],i);let a=Y(e,[`versionId`]);a!=null&&J(t,[`version`],a);let o=Y(e,[`deployedModels`]);if(o!=null){let e=o;Array.isArray(e)&&(e=e.map(e=>vs(e))),J(t,[`endpoints`],e)}let s=Y(e,[`labels`]);s!=null&&J(t,[`labels`],s);let c=Y(e,[`_self`]);c!=null&&J(t,[`tunedModelInfo`],Fc(c));let l=Y(e,[`defaultCheckpointId`]);l!=null&&J(t,[`defaultCheckpointId`],l);let u=Y(e,[`checkpoints`]);if(u!=null){let e=u;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`checkpoints`],e)}return t}function gc(e){let t={},n=Y(e,[`mediaResolution`]);n!=null&&J(t,[`mediaResolution`],n);let r=Y(e,[`codeExecutionResult`]);r!=null&&J(t,[`codeExecutionResult`],r);let i=Y(e,[`executableCode`]);i!=null&&J(t,[`executableCode`],i);let a=Y(e,[`fileData`]);a!=null&&J(t,[`fileData`],ys(a));let o=Y(e,[`functionCall`]);o!=null&&J(t,[`functionCall`],bs(o));let s=Y(e,[`functionResponse`]);s!=null&&J(t,[`functionResponse`],s);let c=Y(e,[`inlineData`]);c!=null&&J(t,[`inlineData`],Wo(c));let l=Y(e,[`text`]);l!=null&&J(t,[`text`],l);let u=Y(e,[`thought`]);u!=null&&J(t,[`thought`],u);let d=Y(e,[`thoughtSignature`]);d!=null&&J(t,[`thoughtSignature`],d);let f=Y(e,[`videoMetadata`]);return f!=null&&J(t,[`videoMetadata`],f),t}function _c(e){let t={},n=Y(e,[`productImage`]);return n!=null&&J(t,[`image`],oc(n)),t}function vc(e,t){let n={},r=Y(e,[`numberOfImages`]);t!==void 0&&r!=null&&J(t,[`parameters`,`sampleCount`],r);let i=Y(e,[`baseSteps`]);t!==void 0&&i!=null&&J(t,[`parameters`,`baseSteps`],i);let a=Y(e,[`outputGcsUri`]);t!==void 0&&a!=null&&J(t,[`parameters`,`storageUri`],a);let o=Y(e,[`seed`]);t!==void 0&&o!=null&&J(t,[`parameters`,`seed`],o);let s=Y(e,[`safetyFilterLevel`]);t!==void 0&&s!=null&&J(t,[`parameters`,`safetySetting`],s);let c=Y(e,[`personGeneration`]);t!==void 0&&c!=null&&J(t,[`parameters`,`personGeneration`],c);let l=Y(e,[`addWatermark`]);t!==void 0&&l!=null&&J(t,[`parameters`,`addWatermark`],l);let u=Y(e,[`outputMimeType`]);t!==void 0&&u!=null&&J(t,[`parameters`,`outputOptions`,`mimeType`],u);let d=Y(e,[`outputCompressionQuality`]);t!==void 0&&d!=null&&J(t,[`parameters`,`outputOptions`,`compressionQuality`],d);let f=Y(e,[`enhancePrompt`]);t!==void 0&&f!=null&&J(t,[`parameters`,`enhancePrompt`],f);let p=Y(e,[`labels`]);return t!==void 0&&p!=null&&J(t,[`labels`],p),n}function yc(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`source`]);i!=null&&xc(i,n);let a=Y(t,[`config`]);return a!=null&&vc(a,n),n}function bc(e){let t={},n=Y(e,[`predictions`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Ks(e))),J(t,[`generatedImages`],e)}return t}function xc(e,t){let n={},r=Y(e,[`prompt`]);t!==void 0&&r!=null&&J(t,[`instances[0]`,`prompt`],r);let i=Y(e,[`personImage`]);t!==void 0&&i!=null&&J(t,[`instances[0]`,`personImage`,`image`],oc(i));let a=Y(e,[`productImages`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>_c(e))),J(t,[`instances[0]`,`productImages`],e)}return n}function Sc(e){let t={},n=Y(e,[`referenceImage`]);n!=null&&J(t,[`referenceImage`],oc(n));let r=Y(e,[`referenceId`]);r!=null&&J(t,[`referenceId`],r);let i=Y(e,[`referenceType`]);i!=null&&J(t,[`referenceType`],i);let a=Y(e,[`maskImageConfig`]);a!=null&&J(t,[`maskImageConfig`],pc(a));let o=Y(e,[`controlImageConfig`]);o!=null&&J(t,[`controlImageConfig`],Qo(o));let s=Y(e,[`styleImageConfig`]);s!=null&&J(t,[`styleImageConfig`],s);let c=Y(e,[`subjectImageConfig`]);return c!=null&&J(t,[`subjectImageConfig`],c),t}function Cc(e){let t={},n=Y(e,[`safetyAttributes`,`categories`]);n!=null&&J(t,[`categories`],n);let r=Y(e,[`safetyAttributes`,`scores`]);r!=null&&J(t,[`scores`],r);let i=Y(e,[`contentType`]);return i!=null&&J(t,[`contentType`],i),t}function wc(e){let t={},n=Y(e,[`safetyAttributes`,`categories`]);n!=null&&J(t,[`categories`],n);let r=Y(e,[`safetyAttributes`,`scores`]);r!=null&&J(t,[`scores`],r);let i=Y(e,[`contentType`]);return i!=null&&J(t,[`contentType`],i),t}function Tc(e){let t={},n=Y(e,[`category`]);if(n!=null&&J(t,[`category`],n),Y(e,[`method`])!==void 0)throw Error(`method parameter is not supported in Gemini API.`);let r=Y(e,[`threshold`]);return r!=null&&J(t,[`threshold`],r),t}function Ec(e){let t={},n=Y(e,[`image`]);return n!=null&&J(t,[`image`],oc(n)),t}function Dc(e,t){let n={},r=Y(e,[`mode`]);t!==void 0&&r!=null&&J(t,[`parameters`,`mode`],r);let i=Y(e,[`maxPredictions`]);t!==void 0&&i!=null&&J(t,[`parameters`,`maxPredictions`],i);let a=Y(e,[`confidenceThreshold`]);t!==void 0&&a!=null&&J(t,[`parameters`,`confidenceThreshold`],a);let o=Y(e,[`maskDilation`]);t!==void 0&&o!=null&&J(t,[`parameters`,`maskDilation`],o);let s=Y(e,[`binaryColorThreshold`]);t!==void 0&&s!=null&&J(t,[`parameters`,`binaryColorThreshold`],s);let c=Y(e,[`labels`]);return t!==void 0&&c!=null&&J(t,[`labels`],c),n}function Oc(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`source`]);i!=null&&Ac(i,n);let a=Y(t,[`config`]);return a!=null&&Dc(a,n),n}function kc(e){let t={},n=Y(e,[`predictions`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>qs(e))),J(t,[`generatedMasks`],e)}return t}function Ac(e,t){let n={},r=Y(e,[`prompt`]);t!==void 0&&r!=null&&J(t,[`instances[0]`,`prompt`],r);let i=Y(e,[`image`]);t!==void 0&&i!=null&&J(t,[`instances[0]`,`image`],oc(i));let a=Y(e,[`scribbleImage`]);return t!==void 0&&a!=null&&J(t,[`instances[0]`,`scribble`],Ec(a)),n}function jc(e){let t={},n=Y(e,[`functionCallingConfig`]);n!=null&&J(t,[`functionCallingConfig`],xs(n));let r=Y(e,[`retrievalConfig`]);return r!=null&&J(t,[`retrievalConfig`],r),t}function Mc(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`functionDeclarations`],e)}if(Y(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=Y(e,[`googleSearchRetrieval`]);r!=null&&J(t,[`googleSearchRetrieval`],r);let i=Y(e,[`computerUse`]);i!=null&&J(t,[`computerUse`],i);let a=Y(e,[`fileSearch`]);a!=null&&J(t,[`fileSearch`],a);let o=Y(e,[`codeExecution`]);if(o!=null&&J(t,[`codeExecution`],o),Y(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=Y(e,[`googleMaps`]);s!=null&&J(t,[`googleMaps`],$s(s));let c=Y(e,[`googleSearch`]);c!=null&&J(t,[`googleSearch`],ec(c));let l=Y(e,[`urlContext`]);return l!=null&&J(t,[`urlContext`],l),t}function Nc(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>Ss(e))),J(t,[`functionDeclarations`],e)}let r=Y(e,[`retrieval`]);r!=null&&J(t,[`retrieval`],r);let i=Y(e,[`googleSearchRetrieval`]);i!=null&&J(t,[`googleSearchRetrieval`],i);let a=Y(e,[`computerUse`]);if(a!=null&&J(t,[`computerUse`],a),Y(e,[`fileSearch`])!==void 0)throw Error(`fileSearch parameter is not supported in Vertex AI.`);let o=Y(e,[`codeExecution`]);o!=null&&J(t,[`codeExecution`],o);let s=Y(e,[`enterpriseWebSearch`]);s!=null&&J(t,[`enterpriseWebSearch`],s);let c=Y(e,[`googleMaps`]);c!=null&&J(t,[`googleMaps`],c);let l=Y(e,[`googleSearch`]);l!=null&&J(t,[`googleSearch`],l);let u=Y(e,[`urlContext`]);return u!=null&&J(t,[`urlContext`],u),t}function Pc(e){let t={},n=Y(e,[`baseModel`]);n!=null&&J(t,[`baseModel`],n);let r=Y(e,[`createTime`]);r!=null&&J(t,[`createTime`],r);let i=Y(e,[`updateTime`]);return i!=null&&J(t,[`updateTime`],i),t}function Fc(e){let t={},n=Y(e,[`labels`,`google-vertex-llm-tuning-base-model-id`]);n!=null&&J(t,[`baseModel`],n);let r=Y(e,[`createTime`]);r!=null&&J(t,[`createTime`],r);let i=Y(e,[`updateTime`]);return i!=null&&J(t,[`updateTime`],i),t}function Ic(e,t){let n={},r=Y(e,[`displayName`]);t!==void 0&&r!=null&&J(t,[`displayName`],r);let i=Y(e,[`description`]);t!==void 0&&i!=null&&J(t,[`description`],i);let a=Y(e,[`defaultCheckpointId`]);return t!==void 0&&a!=null&&J(t,[`defaultCheckpointId`],a),n}function Lc(e,t){let n={},r=Y(e,[`displayName`]);t!==void 0&&r!=null&&J(t,[`displayName`],r);let i=Y(e,[`description`]);t!==void 0&&i!=null&&J(t,[`description`],i);let a=Y(e,[`defaultCheckpointId`]);return t!==void 0&&a!=null&&J(t,[`defaultCheckpointId`],a),n}function Rc(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`name`],Rr(e,r));let i=Y(t,[`config`]);return i!=null&&Ic(i,n),n}function zc(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`config`]);return i!=null&&Lc(i,n),n}function Bc(e,t){let n={},r=Y(e,[`outputGcsUri`]);t!==void 0&&r!=null&&J(t,[`parameters`,`storageUri`],r);let i=Y(e,[`safetyFilterLevel`]);t!==void 0&&i!=null&&J(t,[`parameters`,`safetySetting`],i);let a=Y(e,[`personGeneration`]);t!==void 0&&a!=null&&J(t,[`parameters`,`personGeneration`],a);let o=Y(e,[`includeRaiReason`]);t!==void 0&&o!=null&&J(t,[`parameters`,`includeRaiReason`],o);let s=Y(e,[`outputMimeType`]);t!==void 0&&s!=null&&J(t,[`parameters`,`outputOptions`,`mimeType`],s);let c=Y(e,[`outputCompressionQuality`]);t!==void 0&&c!=null&&J(t,[`parameters`,`outputOptions`,`compressionQuality`],c);let l=Y(e,[`enhanceInputImage`]);t!==void 0&&l!=null&&J(t,[`parameters`,`upscaleConfig`,`enhanceInputImage`],l);let u=Y(e,[`imagePreservationFactor`]);t!==void 0&&u!=null&&J(t,[`parameters`,`upscaleConfig`,`imagePreservationFactor`],u);let d=Y(e,[`labels`]);t!==void 0&&d!=null&&J(t,[`labels`],d);let f=Y(e,[`numberOfImages`]);t!==void 0&&f!=null&&J(t,[`parameters`,`sampleCount`],f);let p=Y(e,[`mode`]);return t!==void 0&&p!=null&&J(t,[`parameters`,`mode`],p),n}function Vc(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`_url`,`model`],Rr(e,r));let i=Y(t,[`image`]);i!=null&&J(n,[`instances[0]`,`image`],oc(i));let a=Y(t,[`upscaleFactor`]);a!=null&&J(n,[`parameters`,`upscaleConfig`,`upscaleFactor`],a);let o=Y(t,[`config`]);return o!=null&&Bc(o,n),n}function Hc(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`predictions`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>Ks(e))),J(t,[`generatedImages`],e)}return t}function Uc(e){let t={},n=Y(e,[`uri`]);n!=null&&J(t,[`uri`],n);let r=Y(e,[`encodedVideo`]);r!=null&&J(t,[`videoBytes`],ci(r));let i=Y(e,[`encoding`]);return i!=null&&J(t,[`mimeType`],i),t}function Wc(e){let t={},n=Y(e,[`gcsUri`]);n!=null&&J(t,[`uri`],n);let r=Y(e,[`bytesBase64Encoded`]);r!=null&&J(t,[`videoBytes`],ci(r));let i=Y(e,[`mimeType`]);return i!=null&&J(t,[`mimeType`],i),t}function Gc(e){let t={},n=Y(e,[`image`]);n!=null&&J(t,[`_self`],oc(n));let r=Y(e,[`maskMode`]);return r!=null&&J(t,[`maskMode`],r),t}function Kc(e){let t={},n=Y(e,[`image`]);n!=null&&J(t,[`image`],ac(n));let r=Y(e,[`referenceType`]);return r!=null&&J(t,[`referenceType`],r),t}function qc(e){let t={},n=Y(e,[`image`]);n!=null&&J(t,[`image`],oc(n));let r=Y(e,[`referenceType`]);return r!=null&&J(t,[`referenceType`],r),t}function Jc(e){let t={},n=Y(e,[`uri`]);n!=null&&J(t,[`uri`],n);let r=Y(e,[`videoBytes`]);r!=null&&J(t,[`encodedVideo`],ci(r));let i=Y(e,[`mimeType`]);return i!=null&&J(t,[`encoding`],i),t}function Yc(e){let t={},n=Y(e,[`uri`]);n!=null&&J(t,[`gcsUri`],n);let r=Y(e,[`videoBytes`]);r!=null&&J(t,[`bytesBase64Encoded`],ci(r));let i=Y(e,[`mimeType`]);return i!=null&&J(t,[`mimeType`],i),t}function Xc(e,t){let n={},r=Y(e,[`displayName`]);return t!==void 0&&r!=null&&J(t,[`displayName`],r),n}function Zc(e){let t={},n=Y(e,[`config`]);return n!=null&&Xc(n,t),t}function Qc(e,t){let n={},r=Y(e,[`force`]);return t!==void 0&&r!=null&&J(t,[`_query`,`force`],r),n}function $c(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`_url`,`name`],n);let r=Y(e,[`config`]);return r!=null&&Qc(r,t),t}function el(e){let t={},n=Y(e,[`name`]);return n!=null&&J(t,[`_url`,`name`],n),t}function tl(e,t){let n={},r=Y(e,[`customMetadata`]);if(t!==void 0&&r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`customMetadata`],e)}let i=Y(e,[`chunkingConfig`]);return t!==void 0&&i!=null&&J(t,[`chunkingConfig`],i),n}function nl(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`name`],n);let r=Y(e,[`metadata`]);r!=null&&J(t,[`metadata`],r);let i=Y(e,[`done`]);i!=null&&J(t,[`done`],i);let a=Y(e,[`error`]);a!=null&&J(t,[`error`],a);let o=Y(e,[`response`]);return o!=null&&J(t,[`response`],il(o)),t}function rl(e){let t={},n=Y(e,[`fileSearchStoreName`]);n!=null&&J(t,[`_url`,`file_search_store_name`],n);let r=Y(e,[`fileName`]);r!=null&&J(t,[`fileName`],r);let i=Y(e,[`config`]);return i!=null&&tl(i,t),t}function il(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`parent`]);r!=null&&J(t,[`parent`],r);let i=Y(e,[`documentName`]);return i!=null&&J(t,[`documentName`],i),t}function al(e,t){let n={},r=Y(e,[`pageSize`]);t!==void 0&&r!=null&&J(t,[`_query`,`pageSize`],r);let i=Y(e,[`pageToken`]);return t!==void 0&&i!=null&&J(t,[`_query`,`pageToken`],i),n}function ol(e){let t={},n=Y(e,[`config`]);return n!=null&&al(n,t),t}function sl(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`fileSearchStores`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`fileSearchStores`],e)}return t}function cl(e,t){let n={},r=Y(e,[`mimeType`]);t!==void 0&&r!=null&&J(t,[`mimeType`],r);let i=Y(e,[`displayName`]);t!==void 0&&i!=null&&J(t,[`displayName`],i);let a=Y(e,[`customMetadata`]);if(t!==void 0&&a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`customMetadata`],e)}let o=Y(e,[`chunkingConfig`]);return t!==void 0&&o!=null&&J(t,[`chunkingConfig`],o),n}function ll(e){let t={},n=Y(e,[`fileSearchStoreName`]);n!=null&&J(t,[`_url`,`file_search_store_name`],n);let r=Y(e,[`config`]);return r!=null&&cl(r,t),t}function ul(e){let t={},n=Y(e,[`sdkHttpResponse`]);return n!=null&&J(t,[`sdkHttpResponse`],n),t}var dl=`Content-Type`,fl=`X-Server-Timeout`,pl=`User-Agent`,ml=`x-goog-api-client`,hl=`google-genai-sdk/1.34.0`,gl=`v1beta1`,_l=`v1beta`,vl=class{constructor(e){this.clientOptions=Object.assign(Object.assign({},e),{project:e.project,location:e.location,apiKey:e.apiKey,vertexai:e.vertexai});let t={};this.clientOptions.vertexai?(t.apiVersion=this.clientOptions.apiVersion??gl,t.baseUrl=this.baseUrlFromProjectLocation(),this.normalizeAuthParameters()):(t.apiVersion=this.clientOptions.apiVersion??_l,t.baseUrl=`https://generativelanguage.googleapis.com/`),t.headers=this.getDefaultHeaders(),this.clientOptions.httpOptions=t,e.httpOptions&&(this.clientOptions.httpOptions=this.patchHttpOptions(t,e.httpOptions))}baseUrlFromProjectLocation(){return this.clientOptions.project&&this.clientOptions.location&&this.clientOptions.location!==`global`?`https://${this.clientOptions.location}-aiplatform.googleapis.com/`:`https://aiplatform.googleapis.com/`}normalizeAuthParameters(){if(this.clientOptions.project&&this.clientOptions.location){this.clientOptions.apiKey=void 0;return}this.clientOptions.project=void 0,this.clientOptions.location=void 0}isVertexAI(){return this.clientOptions.vertexai??!1}getProject(){return this.clientOptions.project}getLocation(){return this.clientOptions.location}async getAuthHeaders(){let e=new Headers;return await this.clientOptions.auth.addAuthHeaders(e),e}getApiVersion(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.apiVersion!==void 0)return this.clientOptions.httpOptions.apiVersion;throw Error(`API version is not set.`)}getBaseUrl(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.baseUrl!==void 0)return this.clientOptions.httpOptions.baseUrl;throw Error(`Base URL is not set.`)}getRequestUrl(){return this.getRequestUrlInternal(this.clientOptions.httpOptions)}getHeaders(){if(this.clientOptions.httpOptions&&this.clientOptions.httpOptions.headers!==void 0)return this.clientOptions.httpOptions.headers;throw Error(`Headers are not set.`)}getRequestUrlInternal(e){if(!e||e.baseUrl===void 0||e.apiVersion===void 0)throw Error(`HTTP options are not correctly set.`);let t=[e.baseUrl.endsWith(`/`)?e.baseUrl.slice(0,-1):e.baseUrl];return e.apiVersion&&e.apiVersion!==``&&t.push(e.apiVersion),t.join(`/`)}getBaseResourcePath(){return`projects/${this.clientOptions.project}/locations/${this.clientOptions.location}`}getApiKey(){return this.clientOptions.apiKey}getWebsocketBaseUrl(){let e=this.getBaseUrl(),t=new URL(e);return t.protocol=t.protocol==`http:`?`ws`:`wss`,t.toString()}setBaseUrl(e){if(this.clientOptions.httpOptions)this.clientOptions.httpOptions.baseUrl=e;else throw Error(`HTTP options are not correctly set.`)}constructUrl(e,t,n){let r=[this.getRequestUrlInternal(t)];return n&&r.push(this.getBaseResourcePath()),e!==``&&r.push(e),new URL(`${r.join(`/`)}`)}shouldPrependVertexProjectPath(e){return!(this.clientOptions.apiKey||!this.clientOptions.vertexai||e.path.startsWith(`projects/`)||e.httpMethod===`GET`&&e.path.startsWith(`publishers/google/models`))}async request(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e),r=this.constructUrl(e.path,t,n);if(e.queryParams)for(let[t,n]of Object.entries(e.queryParams))r.searchParams.append(t,String(n));let i={};if(e.httpMethod===`GET`){if(e.body&&e.body!==`{}`)throw Error(`Request body should be empty for GET request, but got non empty request body`)}else i.body=e.body;return i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString(),e.abortSignal),this.unaryApiCall(r,i,e.httpMethod)}patchHttpOptions(e,t){let n=JSON.parse(JSON.stringify(e));for(let[e,r]of Object.entries(t))typeof r==`object`?n[e]=Object.assign(Object.assign({},n[e]),r):r!==void 0&&(n[e]=r);return n}async requestStream(e){let t=this.clientOptions.httpOptions;e.httpOptions&&(t=this.patchHttpOptions(this.clientOptions.httpOptions,e.httpOptions));let n=this.shouldPrependVertexProjectPath(e),r=this.constructUrl(e.path,t,n);(!r.searchParams.has(`alt`)||r.searchParams.get(`alt`)!==`sse`)&&r.searchParams.set(`alt`,`sse`);let i={};return i.body=e.body,i=await this.includeExtraHttpOptionsToRequestInit(i,t,r.toString(),e.abortSignal),this.streamApiCall(r,i,e.httpMethod)}async includeExtraHttpOptionsToRequestInit(e,t,n,r){if(t&&t.timeout||r){let n=new AbortController,i=n.signal;if(t.timeout&&t?.timeout>0){let e=setTimeout(()=>n.abort(),t.timeout);e&&typeof e.unref==`function`&&e.unref()}r&&r.addEventListener(`abort`,()=>{n.abort()}),e.signal=i}return t&&t.extraBody!==null&&bl(e,t.extraBody),e.headers=await this.getHeadersInternal(t,n),e}async unaryApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await yl(e),new ur(e))).catch(e=>{throw e instanceof Error?e:Error(JSON.stringify(e))})}async streamApiCall(e,t,n){return this.apiCall(e.toString(),Object.assign(Object.assign({},t),{method:n})).then(async e=>(await yl(e),this.processStreamResponse(e))).catch(e=>{throw e instanceof Error?e:Error(JSON.stringify(e))})}processStreamResponse(e){return ro(this,arguments,function*(){let t=(e?.body)?.getReader(),n=new TextDecoder(`utf-8`);if(!t)throw Error(`Response body is empty`);try{let r=``,i=[` + +`,`\r\r`,`\r +\r +`];for(;;){let{done:a,value:o}=yield no(t.read());if(a){if(r.trim().length>0)throw Error(`Incomplete JSON segment at the end`);break}let s=n.decode(o,{stream:!0});try{let e=JSON.parse(s);if(`error`in e){let t=JSON.parse(JSON.stringify(e.error)),n=t.status,r=t.code,i=`got status: ${n}. ${JSON.stringify(e)}`;if(r>=400&&r<600)throw new fo({message:i,status:r})}}catch(e){if(e.name===`ApiError`)throw e}r+=s;let c=-1,l=0;for(;;){c=-1,l=0;for(let e of i){let t=r.indexOf(e);t!==-1&&(c===-1||t{throw Error(`exception ${e} sending request`)})}getDefaultHeaders(){let e={},t=hl+` `+this.clientOptions.userAgentExtra;return e[pl]=t,e[ml]=t,e[dl]=`application/json`,e}async getHeadersInternal(e,t){let n=new Headers;if(e&&e.headers){for(let[t,r]of Object.entries(e.headers))n.append(t,r);e.timeout&&e.timeout>0&&n.append(fl,String(Math.ceil(e.timeout/1e3)))}return await this.clientOptions.auth.addAuthHeaders(n,t),n}getFileName(e){let t=``;return typeof e==`string`&&(t=e.replace(/[/\\]+$/,``),t=t.split(/[/\\]/).pop()??``),t}async uploadFile(e,t){let n={};t!=null&&(n.mimeType=t.mimeType,n.name=t.name,n.displayName=t.displayName),n.name&&!n.name.startsWith(`files/`)&&(n.name=`files/${n.name}`);let r=this.clientOptions.uploader,i=await r.stat(e);n.sizeBytes=String(i.size);let a=t?.mimeType??i.type;if(a===void 0||a===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);n.mimeType=a;let o={file:n},s=this.getFileName(e),c=q(`upload/v1beta/files`,o._url),l=await this.fetchUploadUrl(c,n.sizeBytes,n.mimeType,s,o,t?.httpOptions);return r.upload(e,l,this)}async uploadFileToFileSearchStore(e,t,n){let r=this.clientOptions.uploader,i=await r.stat(t),a=String(i.size),o=n?.mimeType??i.type;if(o===void 0||o===``)throw Error(`Can not determine mimeType. Please provide mimeType in the config.`);let s=`upload/v1beta/${e}:uploadToFileSearchStore`,c=this.getFileName(t),l={};n!=null&&cl(n,l);let u=await this.fetchUploadUrl(s,a,o,c,l,n?.httpOptions);return r.uploadToFileSearchStore(t,u,this)}async downloadFile(e){await this.clientOptions.downloader.download(e,this)}async fetchUploadUrl(e,t,n,r,i,a){let o={};o=a||{apiVersion:``,headers:Object.assign({"Content-Type":`application/json`,"X-Goog-Upload-Protocol":`resumable`,"X-Goog-Upload-Command":`start`,"X-Goog-Upload-Header-Content-Length":`${t}`,"X-Goog-Upload-Header-Content-Type":`${n}`},r?{"X-Goog-Upload-File-Name":r}:{})};let s=await this.request({path:e,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:o});if(!s||!s?.headers)throw Error(`Server did not return an HttpResponse or the returned HttpResponse did not have headers.`);let c=s?.headers?.[`x-goog-upload-url`];if(c===void 0)throw Error(`Failed to get upload url. Server did not return the x-google-upload-url in the headers`);return c}};async function yl(e){if(e===void 0)throw Error(`response is undefined`);if(!e.ok){let t=e.status,n;n=e.headers.get(`content-type`)?.includes(`application/json`)?await e.json():{error:{message:await e.text(),code:e.status,status:e.statusText}};let r=JSON.stringify(n);throw t>=400&&t<600?new fo({message:r,status:t}):Error(r)}}function bl(e,t){if(!t||Object.keys(t).length===0)return;if(e.body instanceof Blob){console.warn(`includeExtraBodyToRequestInit: extraBody provided but current request body is a Blob. extraBody will be ignored as merging is not supported for Blob bodies.`);return}let n={};if(typeof e.body==`string`&&e.body.length>0)try{let t=JSON.parse(e.body);if(typeof t==`object`&&t&&!Array.isArray(t))n=t;else{console.warn(`includeExtraBodyToRequestInit: Original request body is valid JSON but not a non-array object. Skip applying extraBody to the request body.`);return}}catch{console.warn(`includeExtraBodyToRequestInit: Original request body is not valid JSON. Skip applying extraBody to the request body.`);return}function r(e,t){let n=Object.assign({},e);for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let i=t[e],a=n[e];i&&typeof i==`object`&&!Array.isArray(i)&&a&&typeof a==`object`&&!Array.isArray(a)?n[e]=r(a,i):(a&&i&&typeof a!=typeof i&&console.warn(`includeExtraBodyToRequestInit:deepMerge: Type mismatch for key "${e}". Original type: ${typeof a}, New type: ${typeof i}. Overwriting.`),n[e]=i)}return n}let i=r(n,t);e.body=JSON.stringify(i)}var xl=`mcp_used/unknown`,Sl=!1;function Cl(e){for(let t of e)if(Tl(t)||typeof t==`object`&&`inputSchema`in t)return!0;return Sl}function wl(e){e[ml]=((e[ml]??``)+` ${xl}`).trimStart()}function Tl(e){return typeof e==`object`&&!!e&&e instanceof Dl}function El(e){return ro(this,arguments,function*(e,t=100){let n,r=0;for(;r0)return;let i={},a=[];for(let l of this.mcpClients)try{for(var o=!0,s=(t=void 0,io(El(l))),c;c=await s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;a.push(e);let t=e.name;if(i[t])throw Error(`Duplicate function name ${t} found in MCP tools. Please ensure function names are unique.`);i[t]=l}}catch(e){t={error:e}}finally{try{!o&&!e&&(n=s.return)&&await n.call(s)}finally{if(t)throw t.error}}this.mcpTools=a,this.functionNameToMcpClient=i}async tool(){return await this.initialize(),_i(this.mcpTools,this.config)}async callTool(e){await this.initialize();let t=[];for(let n of e)if(n.name in this.functionNameToMcpClient){let e=this.functionNameToMcpClient[n.name],r;this.config.timeout&&(r={timeout:this.config.timeout});let i=await e.callTool({name:n.name,arguments:n.args},void 0,r);t.push({functionResponse:{name:n.name,response:i.isError?{error:i}:i}})}return t}};async function Ol(e,t,n){let r=new Ir,i;i=n.data instanceof Blob?JSON.parse(await n.data.text()):JSON.parse(n.data),Object.assign(r,i),t(r)}var kl=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n}async connect(e){if(this.apiClient.isVertexAI())throw Error(`Live music is not supported for Vertex AI.`);console.warn(`Live music generation is experimental and may change in future versions.`);let t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r=Ml(this.apiClient.getDefaultHeaders()),i=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.BidiGenerateMusic?key=${this.apiClient.getApiKey()}`,a=()=>{},o=new Promise(e=>{a=e}),s=e.callbacks,c=function(){a({})},l=this.apiClient,u={onopen:c,onmessage:e=>{Ol(l,s.onmessage,e)},onerror:s?.onerror??function(e){},onclose:s?.onclose??function(e){}},d=this.webSocketFactory.create(i,jl(r),u);d.connect(),await o;let f={setup:{model:Rr(this.apiClient,e.model)}};return d.send(JSON.stringify(f)),new Al(d,this.apiClient)}},Al=class{constructor(e,t){this.conn=e,this.apiClient=t}async setWeightedPrompts(e){if(!e.weightedPrompts||Object.keys(e.weightedPrompts).length===0)throw Error(`Weighted prompts must be set and contain at least one entry.`);let t=Fo(e);this.conn.send(JSON.stringify({clientContent:t}))}async setMusicGenerationConfig(e){e.musicGenerationConfig||={};let t=Po(e);this.conn.send(JSON.stringify(t))}sendPlaybackControl(e){let t={playbackControl:e};this.conn.send(JSON.stringify(t))}play(){this.sendPlaybackControl(lr.PLAY)}pause(){this.sendPlaybackControl(lr.PAUSE)}stop(){this.sendPlaybackControl(lr.STOP)}resetContext(){this.sendPlaybackControl(lr.RESET_CONTEXT)}close(){this.conn.close()}};function jl(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function Ml(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}var Nl="FunctionResponse request must have an `id` field from the response of a ToolCall.FunctionalCalls in Google AI.";async function Pl(e,t,n){let r=new Fr,i;i=n.data instanceof Blob?await n.data.text():n.data instanceof ArrayBuffer?new TextDecoder().decode(n.data):n.data;let a=JSON.parse(i);if(e.isVertexAI()){let e=Ro(a);Object.assign(r,e)}else Object.assign(r,a);t(r)}var Fl=class{constructor(e,t,n){this.apiClient=e,this.auth=t,this.webSocketFactory=n,this.music=new kl(this.apiClient,this.auth,this.webSocketFactory)}async connect(e){if(e.config&&e.config.httpOptions)throw Error(`The Live module does not support httpOptions at request-level in LiveConnectConfig yet. Please use the client-level httpOptions configuration instead.`);let t=this.apiClient.getWebsocketBaseUrl(),n=this.apiClient.getApiVersion(),r,i=this.apiClient.getHeaders();e.config&&e.config.tools&&Cl(e.config.tools)&&wl(i);let a=zl(i);if(this.apiClient.isVertexAI())r=`${t}/ws/google.cloud.aiplatform.${n}.LlmBidiService/BidiGenerateContent`,await this.auth.addAuthHeaders(a,r);else{let e=this.apiClient.getApiKey(),i=`BidiGenerateContent`,a=`key`;e?.startsWith(`auth_tokens/`)&&(console.warn(`Warning: Ephemeral token support is experimental and may change in future versions.`),n!==`v1alpha`&&console.warn(`Warning: The SDK's ephemeral token support is in v1alpha only. Please use const ai = new GoogleGenAI({apiKey: token.name, httpOptions: { apiVersion: 'v1alpha' }}); before session connection.`),i=`BidiGenerateContentConstrained`,a=`access_token`),r=`${t}/ws/google.ai.generativelanguage.${n}.GenerativeService.${i}?${a}=${e}`}let o=()=>{},s=new Promise(e=>{o=e}),c=e.callbacks,l=function(){var e;(e=c?.onopen)==null||e.call(c),o({})},u=this.apiClient,d={onopen:l,onmessage:e=>{Pl(u,c.onmessage,e)},onerror:c?.onerror??function(e){},onclose:c?.onclose??function(e){}},f=this.webSocketFactory.create(r,Rl(a),d);f.connect(),await s;let p=Rr(this.apiClient,e.model);this.apiClient.isVertexAI()&&p.startsWith(`publishers/`)&&(p=`projects/${this.apiClient.getProject()}/locations/${this.apiClient.getLocation()}/`+p);let m={};this.apiClient.isVertexAI()&&e.config?.responseModalities===void 0&&(e.config===void 0?e.config={responseModalities:[Dn.AUDIO]}:e.config.responseModalities=[Dn.AUDIO]),e.config?.generationConfig&&console.warn("Setting `LiveConnectConfig.generation_config` is deprecated, please set the fields on `LiveConnectConfig` directly. This will become an error in a future version (not before Q3 2025).");let h=e.config?.tools??[],g=[];for(let e of h)if(this.isCallableTool(e)){let t=e;g.push(await t.tool())}else g.push(e);g.length>0&&(e.config.tools=g);let _={model:p,config:e.config,callbacks:e.callbacks};return m=this.apiClient.isVertexAI()?No(this.apiClient,_):Mo(this.apiClient,_),delete m.config,f.send(JSON.stringify(m)),new Ll(f,this.apiClient)}isCallableTool(e){return`callTool`in e&&typeof e.callTool==`function`}},Il={turnComplete:!0},Ll=class{constructor(e,t){this.conn=e,this.apiClient=t}tLiveClientContent(e,t){if(t.turns!==null&&t.turns!==void 0){let n=[];try{n=Zr(t.turns),e.isVertexAI()||(n=n.map(e=>Zo(e)))}catch{throw Error(`Failed to parse client content "turns", type: '${typeof t.turns}'`)}return{clientContent:{turns:n,turnComplete:t.turnComplete}}}return{clientContent:{turnComplete:t.turnComplete}}}tLiveClienttToolResponse(e,t){let n=[];if(t.functionResponses==null||(n=Array.isArray(t.functionResponses)?t.functionResponses:[t.functionResponses],n.length===0))throw Error(`functionResponses is required.`);for(let t of n){if(typeof t!=`object`||!t||!(`name`in t)||!(`response`in t))throw Error(`Could not parse function response, type '${typeof t}'.`);if(!e.isVertexAI()&&!(`id`in t))throw Error(Nl)}return{toolResponse:{functionResponses:n}}}sendClientContent(e){e=Object.assign(Object.assign({},Il),e);let t=this.tLiveClientContent(this.apiClient,e);this.conn.send(JSON.stringify(t))}sendRealtimeInput(e){let t={};t=this.apiClient.isVertexAI()?{realtimeInput:Lo(e)}:{realtimeInput:Io(e)},this.conn.send(JSON.stringify(t))}sendToolResponse(e){if(e.functionResponses==null)throw Error(`Tool response parameters are required.`);let t=this.tLiveClienttToolResponse(this.apiClient,e);this.conn.send(JSON.stringify(t))}close(){this.conn.close()}};function Rl(e){let t={};return e.forEach((e,n)=>{t[n]=e}),t}function zl(e){let t=new Headers;for(let[n,r]of Object.entries(e))t.append(n,r);return t}var Bl=10;function Vl(e){if(e?.automaticFunctionCalling?.disable)return!0;let t=!1;for(let n of e?.tools??[])if(Hl(n)){t=!0;break}if(!t)return!0;let n=e?.automaticFunctionCalling?.maximumRemoteCalls;return n&&(n<0||!Number.isInteger(n))||n==0?(console.warn(`Invalid maximumRemoteCalls value provided for automatic function calling. Disabled automatic function calling. Please provide a valid integer value greater than 0. maximumRemoteCalls provided:`,n),!0):!1}function Hl(e){return`callTool`in e&&typeof e.callTool==`function`}function Ul(e){return(e.config?.tools)?.some(e=>Hl(e))??!1}function Wl(e){let t=[];return e?.config?.tools&&e.config.tools.forEach((e,n)=>{if(Hl(e))return;let r=e;r.functionDeclarations&&r.functionDeclarations.length>0&&t.push(n)}),t}function Gl(e){return!e?.automaticFunctionCalling?.ignoreCallHistory}var Kl=class extends Ht{constructor(e){super(),this.apiClient=e,this.generateContent=async e=>{let t=await this.processParamsMaybeAddMcpUsage(e);if(this.maybeMoveToResponseJsonSchem(e),!Ul(e)||Vl(e.config))return await this.generateContentInternal(t);let n=Wl(e);if(n.length>0){let e=n.map(e=>`tools[${e}]`).join(`, `);throw Error(`Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations is not yet supported. Incompatible tools found at ${e}.`)}let r,i,a=Zr(t.contents),o=t.config?.automaticFunctionCalling?.maximumRemoteCalls??Bl,s=0;for(;s{if(this.maybeMoveToResponseJsonSchem(e),Vl(e.config)){let t=await this.processParamsMaybeAddMcpUsage(e);return await this.generateContentStreamInternal(t)}let t=Wl(e);if(t.length>0){let e=t.map(e=>`tools[${e}]`).join(`, `);throw Error(`Incompatible tools found at ${e}. Automatic function calling with CallableTools (or MCP objects) and basic FunctionDeclarations" is not yet supported.`)}let n=e?.config?.toolConfig?.functionCallingConfig?.streamFunctionCallArguments,r=e?.config?.automaticFunctionCalling?.disable;if(n&&!r)throw Error(`Running in streaming mode with 'streamFunctionCallArguments' enabled, this feature is not compatible with automatic function calling (AFC). Please set 'config.automaticFunctionCalling.disable' to true to disable AFC or leave 'config.toolConfig.functionCallingConfig.streamFunctionCallArguments' to be undefined or set to false to disable streaming function call arguments feature.`);return await this.processAfcStream(e)},this.generateImages=async e=>await this.generateImagesInternal(e).then(e=>{let t,n=[];if(e?.generatedImages)for(let r of e.generatedImages)r&&r?.safetyAttributes&&r?.safetyAttributes?.contentType===`Positive Prompt`?t=r?.safetyAttributes:n.push(r);let r;return r=t?{generatedImages:n,positivePromptSafetyAttributes:t,sdkHttpResponse:e.sdkHttpResponse}:{generatedImages:n,sdkHttpResponse:e.sdkHttpResponse},r}),this.list=async e=>{let t={config:Object.assign(Object.assign({},{queryBase:!0}),e?.config)};if(this.apiClient.isVertexAI()&&!t.config.queryBase){if(t.config?.filter)throw Error(`Filtering tuned models list for Vertex AI is not currently supported`);t.config.filter=`labels.tune-type:*`}return new ya(va.PAGED_ITEM_MODELS,e=>this.listInternal(e),await this.listInternal(t),t)},this.editImage=async e=>{let t={model:e.model,prompt:e.prompt,referenceImages:[],config:e.config};return e.referenceImages&&e.referenceImages&&(t.referenceImages=e.referenceImages.map(e=>e.toReferenceImageAPI())),await this.editImageInternal(t)},this.upscaleImage=async e=>{let t={numberOfImages:1,mode:`upscale`};e.config&&(t=Object.assign(Object.assign({},t),e.config));let n={model:e.model,image:e.image,upscaleFactor:e.upscaleFactor,config:t};return await this.upscaleImageInternal(n)},this.generateVideos=async e=>{if((e.prompt||e.image||e.video)&&e.source)throw Error(`Source and prompt/image/video are mutually exclusive. Please only use source.`);return this.apiClient.isVertexAI()||(e.video?.uri&&e.video?.videoBytes?e.video={uri:e.video.uri,mimeType:e.video.mimeType}:e.source?.video?.uri&&e.source?.video?.videoBytes&&(e.source.video={uri:e.source.video.uri,mimeType:e.source.video.mimeType})),await this.generateVideosInternal(e)}}maybeMoveToResponseJsonSchem(e){e.config&&e.config.responseSchema&&(e.config.responseJsonSchema||Object.keys(e.config.responseSchema).includes(`$schema`)&&(e.config.responseJsonSchema=e.config.responseSchema,delete e.config.responseSchema))}async processParamsMaybeAddMcpUsage(e){let t=e.config?.tools;if(!t)return e;let n=await Promise.all(t.map(async e=>Hl(e)?await e.tool():e)),r={model:e.model,contents:e.contents,config:Object.assign(Object.assign({},e.config),{tools:n})};if(r.config.tools=n,e.config&&e.config.tools&&Cl(e.config.tools)){let t=e.config.httpOptions?.headers??{},n=Object.assign({},t);Object.keys(n).length===0&&(n=this.apiClient.getDefaultHeaders()),wl(n),r.config.httpOptions=Object.assign(Object.assign({},e.config.httpOptions),{headers:n})}return r}async initAfcToolsMap(e){let t=new Map;for(let n of e.config?.tools??[])if(Hl(n)){let e=n,r=await e.tool();for(let n of r.functionDeclarations??[]){if(!n.name)throw Error(`Function declaration name is required.`);if(t.has(n.name))throw Error(`Duplicate tool declaration name: ${n.name}`);t.set(n.name,e)}}return t}async processAfcStream(e){let t=e.config?.automaticFunctionCalling?.maximumRemoteCalls??Bl,n=!1,r=0,i=await this.initAfcToolsMap(e);return(function(e,i,a){return ro(this,arguments,function*(){for(var o,s,c,l;r0){n=!0;let e=new dr;e.candidates=[{content:{role:`user`,parts:h}}],yield yield no(e);let t=[];t.push(...g),t.push({role:`user`,parts:h}),a.contents=Zr(a.contents).concat(t)}else break}})})(this,i,e)}async generateContentInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Es(this.apiClient,e);return n=q(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Os(e),n=new dr;return Object.assign(n,t),n})}else{let i=Ts(this.apiClient,e);return n=q(`{model}:generateContent`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ds(e),n=new dr;return Object.assign(n,t),n})}}async generateContentStreamInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Es(this.apiClient,e);return n=q(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(e){return ro(this,arguments,function*(){var t,n,r,i;try{for(var a=!0,o=io(e),s;s=yield no(o.next()),t=s.done,!t;a=!0){i=s.value,a=!1;let e=i,t=Os(yield no(e.json()));t.sdkHttpResponse={headers:e.headers};let n=new dr;Object.assign(n,t),yield yield no(n)}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield no(r.call(o)))}finally{if(n)throw n.error}}})})}else{let i=Ts(this.apiClient,e);return n=q(`{model}:streamGenerateContent?alt=sse`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.requestStream({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}),t.then(function(e){return ro(this,arguments,function*(){var t,n,r,i;try{for(var a=!0,o=io(e),s;s=yield no(o.next()),t=s.done,!t;a=!0){i=s.value,a=!1;let e=i,t=Ds(yield no(e.json()));t.sdkHttpResponse={headers:e.headers};let n=new dr;Object.assign(n,t),yield yield no(n)}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield no(r.call(o)))}finally{if(n)throw n.error}}})})}}async embedContent(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=hs(this.apiClient,e);return n=q(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=_s(e),n=new fr;return Object.assign(n,t),n})}else{let i=ms(this.apiClient,e);return n=q(`{model}:batchEmbedContents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=gs(e),n=new fr;return Object.assign(n,t),n})}}async generateImagesInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Ms(this.apiClient,e);return n=q(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ps(e),n=new pr;return Object.assign(n,t),n})}else{let i=js(this.apiClient,e);return n=q(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Ns(e),n=new pr;return Object.assign(n,t),n})}}async editImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=us(this.apiClient,e);return n=q(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ds(e),n=new mr;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async upscaleImageInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Vc(this.apiClient,e);return n=q(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Hc(e),n=new hr;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async recontextImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=yc(this.apiClient,e);return n=q(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=bc(e),n=new gr;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async segmentImage(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Oc(this.apiClient,e);return n=q(`{model}:predict`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=kc(e),n=new _r;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Qs(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>hc(e))}else{let i=Zs(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>mc(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=uc(this.apiClient,e);return n=q(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=fc(e),n=new vr;return Object.assign(n,t),n})}else{let i=lc(this.apiClient,e);return n=q(`{models_url}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=dc(e),n=new vr;return Object.assign(n,t),n})}}async update(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=zc(this.apiClient,e);return n=q(`{model}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>hc(e))}else{let i=Rc(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`PATCH`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>mc(e))}}async delete(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=os(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=cs(e),n=new yr;return Object.assign(n,t),n})}else{let i=as(this.apiClient,e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ss(e),n=new yr;return Object.assign(n,t),n})}}async countTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=ns(this.apiClient,e);return n=q(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=is(e),n=new br;return Object.assign(n,t),n})}else{let i=ts(this.apiClient,e);return n=q(`{model}:countTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=rs(e),n=new br;return Object.assign(n,t),n})}}async computeTokens(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=qo(this.apiClient,e);return n=q(`{model}:computeTokens`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Jo(e),n=new xr;return Object.assign(n,t),n})}else throw Error(`This method is only supported by the Vertex AI.`)}async generateVideosInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Bs(this.apiClient,e);return n=q(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Rs(e),n=new Sr;return Object.assign(n,t),n})}else{let i=zs(this.apiClient,e);return n=q(`{model}:predictLongRunning`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=Ls(e),n=new Sr;return Object.assign(n,t),n})}}},ql=class extends Ht{constructor(e){super(),this.apiClient=e}async getVideosOperation(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}else{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async get(e){let t=e.operation,n=e.config;if(t.name===void 0||t.name===``)throw Error(`Operation name is required.`);if(this.apiClient.isVertexAI()){let e=t.name.split(`/operations/`)[0],r;n&&`httpOptions`in n&&(r=n.httpOptions);let i=await this.fetchPredictVideosOperationInternal({operationName:t.name,resourceName:e,config:{httpOptions:r}});return t._fromAPIResponse({apiResponse:i,_isVertexAI:!0})}else{let e=await this.getVideosOperationInternal({operationName:t.name,config:n});return t._fromAPIResponse({apiResponse:e,_isVertexAI:!1})}}async getVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=en(e);return n=q(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}else{let i=$t(e);return n=q(`{operationName}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}}async fetchPredictVideosOperationInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Kt(e);return n=q(`{resourceName}:fetchPredictOperation`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t}else throw Error(`This method is only supported by the Vertex AI.`)}};function Jl(e){let t={},n=Y(e,[`data`]);if(n!=null&&J(t,[`data`],n),Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function Yl(e){let t={},n=Y(e,[`parts`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>iu(e))),J(t,[`parts`],e)}let r=Y(e,[`role`]);return r!=null&&J(t,[`role`],r),t}function Xl(e,t,n){let r={},i=Y(t,[`expireTime`]);n!==void 0&&i!=null&&J(n,[`expireTime`],i);let a=Y(t,[`newSessionExpireTime`]);n!==void 0&&a!=null&&J(n,[`newSessionExpireTime`],a);let o=Y(t,[`uses`]);n!==void 0&&o!=null&&J(n,[`uses`],o);let s=Y(t,[`liveConnectConstraints`]);n!==void 0&&s!=null&&J(n,[`bidiGenerateContentSetup`],ru(e,s));let c=Y(t,[`lockAdditionalFields`]);return n!==void 0&&c!=null&&J(n,[`fieldMask`],c),r}function Zl(e,t){let n={},r=Y(t,[`config`]);return r!=null&&J(n,[`config`],Xl(e,r,n)),n}function Ql(e){let t={};if(Y(e,[`displayName`])!==void 0)throw Error(`displayName parameter is not supported in Gemini API.`);let n=Y(e,[`fileUri`]);n!=null&&J(t,[`fileUri`],n);let r=Y(e,[`mimeType`]);return r!=null&&J(t,[`mimeType`],r),t}function $l(e){let t={},n=Y(e,[`id`]);n!=null&&J(t,[`id`],n);let r=Y(e,[`args`]);r!=null&&J(t,[`args`],r);let i=Y(e,[`name`]);if(i!=null&&J(t,[`name`],i),Y(e,[`partialArgs`])!==void 0)throw Error(`partialArgs parameter is not supported in Gemini API.`);if(Y(e,[`willContinue`])!==void 0)throw Error(`willContinue parameter is not supported in Gemini API.`);return t}function eu(e){let t={};if(Y(e,[`authConfig`])!==void 0)throw Error(`authConfig parameter is not supported in Gemini API.`);let n=Y(e,[`enableWidget`]);return n!=null&&J(t,[`enableWidget`],n),t}function tu(e){let t={};if(Y(e,[`excludeDomains`])!==void 0)throw Error(`excludeDomains parameter is not supported in Gemini API.`);if(Y(e,[`blockingConfidence`])!==void 0)throw Error(`blockingConfidence parameter is not supported in Gemini API.`);let n=Y(e,[`timeRangeFilter`]);return n!=null&&J(t,[`timeRangeFilter`],n),t}function nu(e,t){let n={},r=Y(e,[`generationConfig`]);t!==void 0&&r!=null&&J(t,[`setup`,`generationConfig`],r);let i=Y(e,[`responseModalities`]);t!==void 0&&i!=null&&J(t,[`setup`,`generationConfig`,`responseModalities`],i);let a=Y(e,[`temperature`]);t!==void 0&&a!=null&&J(t,[`setup`,`generationConfig`,`temperature`],a);let o=Y(e,[`topP`]);t!==void 0&&o!=null&&J(t,[`setup`,`generationConfig`,`topP`],o);let s=Y(e,[`topK`]);t!==void 0&&s!=null&&J(t,[`setup`,`generationConfig`,`topK`],s);let c=Y(e,[`maxOutputTokens`]);t!==void 0&&c!=null&&J(t,[`setup`,`generationConfig`,`maxOutputTokens`],c);let l=Y(e,[`mediaResolution`]);t!==void 0&&l!=null&&J(t,[`setup`,`generationConfig`,`mediaResolution`],l);let u=Y(e,[`seed`]);t!==void 0&&u!=null&&J(t,[`setup`,`generationConfig`,`seed`],u);let d=Y(e,[`speechConfig`]);t!==void 0&&d!=null&&J(t,[`setup`,`generationConfig`,`speechConfig`],ni(d));let f=Y(e,[`thinkingConfig`]);t!==void 0&&f!=null&&J(t,[`setup`,`generationConfig`,`thinkingConfig`],f);let p=Y(e,[`enableAffectiveDialog`]);t!==void 0&&p!=null&&J(t,[`setup`,`generationConfig`,`enableAffectiveDialog`],p);let m=Y(e,[`systemInstruction`]);t!==void 0&&m!=null&&J(t,[`setup`,`systemInstruction`],Yl(Yr(m)));let h=Y(e,[`tools`]);if(t!==void 0&&h!=null){let e=ii(h);Array.isArray(e)&&(e=e.map(e=>ou(ri(e)))),J(t,[`setup`,`tools`],e)}let g=Y(e,[`sessionResumption`]);t!==void 0&&g!=null&&J(t,[`setup`,`sessionResumption`],au(g));let _=Y(e,[`inputAudioTranscription`]);t!==void 0&&_!=null&&J(t,[`setup`,`inputAudioTranscription`],_);let v=Y(e,[`outputAudioTranscription`]);t!==void 0&&v!=null&&J(t,[`setup`,`outputAudioTranscription`],v);let y=Y(e,[`realtimeInputConfig`]);t!==void 0&&y!=null&&J(t,[`setup`,`realtimeInputConfig`],y);let b=Y(e,[`contextWindowCompression`]);t!==void 0&&b!=null&&J(t,[`setup`,`contextWindowCompression`],b);let x=Y(e,[`proactivity`]);if(t!==void 0&&x!=null&&J(t,[`setup`,`proactivity`],x),Y(e,[`explicitVadSignal`])!==void 0)throw Error(`explicitVadSignal parameter is not supported in Gemini API.`);return n}function ru(e,t){let n={},r=Y(t,[`model`]);r!=null&&J(n,[`setup`,`model`],Rr(e,r));let i=Y(t,[`config`]);return i!=null&&J(n,[`config`],nu(i,n)),n}function iu(e){let t={},n=Y(e,[`mediaResolution`]);n!=null&&J(t,[`mediaResolution`],n);let r=Y(e,[`codeExecutionResult`]);r!=null&&J(t,[`codeExecutionResult`],r);let i=Y(e,[`executableCode`]);i!=null&&J(t,[`executableCode`],i);let a=Y(e,[`fileData`]);a!=null&&J(t,[`fileData`],Ql(a));let o=Y(e,[`functionCall`]);o!=null&&J(t,[`functionCall`],$l(o));let s=Y(e,[`functionResponse`]);s!=null&&J(t,[`functionResponse`],s);let c=Y(e,[`inlineData`]);c!=null&&J(t,[`inlineData`],Jl(c));let l=Y(e,[`text`]);l!=null&&J(t,[`text`],l);let u=Y(e,[`thought`]);u!=null&&J(t,[`thought`],u);let d=Y(e,[`thoughtSignature`]);d!=null&&J(t,[`thoughtSignature`],d);let f=Y(e,[`videoMetadata`]);return f!=null&&J(t,[`videoMetadata`],f),t}function au(e){let t={},n=Y(e,[`handle`]);if(n!=null&&J(t,[`handle`],n),Y(e,[`transparent`])!==void 0)throw Error(`transparent parameter is not supported in Gemini API.`);return t}function ou(e){let t={},n=Y(e,[`functionDeclarations`]);if(n!=null){let e=n;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`functionDeclarations`],e)}if(Y(e,[`retrieval`])!==void 0)throw Error(`retrieval parameter is not supported in Gemini API.`);let r=Y(e,[`googleSearchRetrieval`]);r!=null&&J(t,[`googleSearchRetrieval`],r);let i=Y(e,[`computerUse`]);i!=null&&J(t,[`computerUse`],i);let a=Y(e,[`fileSearch`]);a!=null&&J(t,[`fileSearch`],a);let o=Y(e,[`codeExecution`]);if(o!=null&&J(t,[`codeExecution`],o),Y(e,[`enterpriseWebSearch`])!==void 0)throw Error(`enterpriseWebSearch parameter is not supported in Gemini API.`);let s=Y(e,[`googleMaps`]);s!=null&&J(t,[`googleMaps`],eu(s));let c=Y(e,[`googleSearch`]);c!=null&&J(t,[`googleSearch`],tu(c));let l=Y(e,[`urlContext`]);return l!=null&&J(t,[`urlContext`],l),t}function su(e){let t=[];for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n];if(typeof r==`object`&&r&&Object.keys(r).length>0){let e=Object.keys(r).map(e=>`${n}.${e}`);t.push(...e)}else t.push(n)}return t.join(`,`)}function cu(e,t){let n=null,r=e.bidiGenerateContentSetup;if(typeof r==`object`&&r&&`setup`in r){let t=r.setup;typeof t==`object`&&t?(e.bidiGenerateContentSetup=t,n=t):delete e.bidiGenerateContentSetup}else r!==void 0&&delete e.bidiGenerateContentSetup;let i=e.fieldMask;if(n){let r=su(n);if(Array.isArray(t?.lockAdditionalFields)&&t?.lockAdditionalFields.length===0)r?e.fieldMask=r:delete e.fieldMask;else if(t?.lockAdditionalFields&&t.lockAdditionalFields.length>0&&i!==null&&Array.isArray(i)&&i.length>0){let t=[`temperature`,`topK`,`topP`,`maxOutputTokens`,`responseModalities`,`seed`,`speechConfig`],n=[];i.length>0&&(n=i.map(e=>t.includes(e)?`generationConfig.${e}`:e));let a=[];r&&a.push(r),n.length>0&&a.push(...n),a.length>0?e.fieldMask=a.join(`,`):delete e.fieldMask}else delete e.fieldMask}else i!==null&&Array.isArray(i)&&i.length>0?e.fieldMask=i.join(`,`):delete e.fieldMask;return e}var lu=class extends Ht{constructor(e){super(),this.apiClient=e}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`The client.tokens.create method is only supported by the Gemini Developer API.`);{let i=Zl(this.apiClient,e);n=q(`auth_tokens`,i._url),r=i._query,delete i.config,delete i._url,delete i._query;let a=cu(i,e.config);return t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(a),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}};function uu(e,t){let n={},r=Y(e,[`force`]);return t!==void 0&&r!=null&&J(t,[`_query`,`force`],r),n}function du(e){let t={},n=Y(e,[`name`]);n!=null&&J(t,[`_url`,`name`],n);let r=Y(e,[`config`]);return r!=null&&uu(r,t),t}function fu(e){let t={},n=Y(e,[`name`]);return n!=null&&J(t,[`_url`,`name`],n),t}function pu(e,t){let n={},r=Y(e,[`pageSize`]);t!==void 0&&r!=null&&J(t,[`_query`,`pageSize`],r);let i=Y(e,[`pageToken`]);return t!==void 0&&i!=null&&J(t,[`_query`,`pageToken`],i),n}function mu(e){let t={},n=Y(e,[`parent`]);n!=null&&J(t,[`_url`,`parent`],n);let r=Y(e,[`config`]);return r!=null&&pu(r,t),t}function hu(e){let t={},n=Y(e,[`sdkHttpResponse`]);n!=null&&J(t,[`sdkHttpResponse`],n);let r=Y(e,[`nextPageToken`]);r!=null&&J(t,[`nextPageToken`],r);let i=Y(e,[`documents`]);if(i!=null){let e=i;Array.isArray(e)&&(e=e.map(e=>e)),J(t,[`documents`],e)}return t}var gu=class extends Ht{constructor(e){super(),this.apiClient=e,this.list=async e=>new ya(va.PAGED_ITEM_DOCUMENTS,t=>this.listInternal({parent:e.parent,config:t.config}),await this.listInternal(e),e)}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=fu(e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=du(e);t=q(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=mu(e);return n=q(`{parent}/documents`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=hu(e),n=new Dr;return Object.assign(n,t),n})}}},_u=class extends Ht{constructor(e,t=new gu(e)){super(),this.apiClient=e,this.documents=t,this.list=async(e={})=>new ya(va.PAGED_ITEM_FILE_SEARCH_STORES,e=>this.listInternal(e),await this.listInternal(e),e)}async uploadToFileSearchStore(e){if(this.apiClient.isVertexAI())throw Error(`Vertex AI does not support uploading files to a file search store.`);return this.apiClient.uploadFileToFileSearchStore(e.fileSearchStoreName,e.file,e.config)}async create(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=Zc(e);return n=q(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async get(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=el(e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>e)}}async delete(e){let t=``,n={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let r=$c(e);t=q(`{name}`,r._url),n=r._query,delete r._url,delete r._query,await this.apiClient.request({path:t,queryParams:n,body:JSON.stringify(r),httpMethod:`DELETE`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal})}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ol(e);return n=q(`fileSearchStores`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=sl(e),n=new Or;return Object.assign(n,t),n})}}async uploadToFileSearchStoreInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=ll(e);return n=q(`upload/v1beta/{file_search_store_name}:uploadToFileSearchStore`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=ul(e),n=new kr;return Object.assign(n,t),n})}}async importFile(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=rl(e);return n=q(`{file_search_store_name}:importFile`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json()),t.then(e=>{let t=nl(e),n=new Ar;return Object.assign(n,t),n})}}},vu=function(){let{crypto:e}=globalThis;if(e?.randomUUID)return vu=e.randomUUID.bind(e),e.randomUUID();let t=new Uint8Array(1),n=e?()=>e.getRandomValues(t)[0]:()=>Math.random()*255&255;return`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,e=>(e^n()&15>>e/4).toString(16))},yu=()=>vu();function bu(e){return typeof e==`object`&&!!e&&(`name`in e&&e.name===`AbortError`||`message`in e&&String(e.message).includes(`FetchRequestCanceledException`))}var xu=e=>{if(e instanceof Error)return e;if(typeof e==`object`&&e){try{if(Object.prototype.toString.call(e)===`[object Error]`){let t=Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(t.stack=e.stack),e.cause&&!t.cause&&(t.cause=e.cause),e.name&&(t.name=e.name),t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)},Su=class extends Error{},Cu=class e extends Su{constructor(t,n,r,i){super(`${e.makeMessage(t,n,r)}`),this.status=t,this.headers=i,this.error=n}static makeMessage(e,t,n){let r=t?.message?typeof t.message==`string`?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||`(no status code or body)`}static generate(t,n,r,i){if(!t||!i)return new Tu({message:r,cause:xu(n)});let a=n;return t===400?new Du(t,a,r,i):t===401?new Ou(t,a,r,i):t===403?new ku(t,a,r,i):t===404?new Au(t,a,r,i):t===409?new ju(t,a,r,i):t===422?new Mu(t,a,r,i):t===429?new Nu(t,a,r,i):t>=500?new Pu(t,a,r,i):new e(t,a,r,i)}},wu=class extends Cu{constructor({message:e}={}){super(void 0,void 0,e||`Request was aborted.`,void 0)}},Tu=class extends Cu{constructor({message:e,cause:t}){super(void 0,void 0,e||`Connection error.`,void 0),t&&(this.cause=t)}},Eu=class extends Tu{constructor({message:e}={}){super({message:e??`Request timed out.`})}},Du=class extends Cu{},Ou=class extends Cu{},ku=class extends Cu{},Au=class extends Cu{},ju=class extends Cu{},Mu=class extends Cu{},Nu=class extends Cu{},Pu=class extends Cu{},Fu=/^[a-z][a-z0-9+.-]*:/i,Iu=e=>Fu.test(e),Lu=e=>(Lu=Array.isArray,Lu(e)),Ru=Lu;function zu(e){if(!e)return!0;for(let t in e)return!1;return!0}function Bu(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Vu=(e,t)=>{if(typeof t!=`number`||!Number.isInteger(t))throw new Su(`${e} must be an integer`);if(t<0)throw new Su(`${e} must be a positive integer`);return t},Hu=e=>{try{return JSON.parse(e)}catch{return}},Uu=e=>new Promise(t=>setTimeout(t,e)),Wu=`0.0.1`;function Gu(){return typeof Deno<`u`&&Deno.build!=null?`deno`:typeof EdgeRuntime<`u`?`edge`:Object.prototype.toString.call(globalThis.process===void 0?0:globalThis.process)===`[object process]`?`node`:`unknown`}var Ku=()=>{let e=Gu();if(e===`deno`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Wu,"X-Stainless-OS":Yu(Deno.build.os),"X-Stainless-Arch":Ju(Deno.build.arch),"X-Stainless-Runtime":`deno`,"X-Stainless-Runtime-Version":typeof Deno.version==`string`?Deno.version:Deno.version?.deno??`unknown`};if(typeof EdgeRuntime<`u`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Wu,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":`edge`,"X-Stainless-Runtime-Version":globalThis.process.version};if(e===`node`)return{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Wu,"X-Stainless-OS":Yu(globalThis.process.platform??`unknown`),"X-Stainless-Arch":Ju(globalThis.process.arch??`unknown`),"X-Stainless-Runtime":`node`,"X-Stainless-Runtime-Version":globalThis.process.version??`unknown`};let t=qu();return t?{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Wu,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:{"X-Stainless-Lang":`js`,"X-Stainless-Package-Version":Wu,"X-Stainless-OS":`Unknown`,"X-Stainless-Arch":`unknown`,"X-Stainless-Runtime":`unknown`,"X-Stainless-Runtime-Version":`unknown`}};function qu(){if(typeof navigator>`u`||!navigator)return null;for(let{key:e,pattern:t}of[{key:`edge`,pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`ie`,pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`chrome`,pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`firefox`,pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:`safari`,pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}]){let n=t.exec(navigator.userAgent);if(n)return{browser:e,version:`${n[1]||0}.${n[2]||0}.${n[3]||0}`}}return null}var Ju=e=>e===`x32`?`x32`:e===`x86_64`||e===`x64`?`x64`:e===`arm`?`arm`:e===`aarch64`||e===`arm64`?`arm64`:e?`other:${e}`:`unknown`,Yu=e=>(e=e.toLowerCase(),e.includes(`ios`)?`iOS`:e===`android`?`Android`:e===`darwin`?`MacOS`:e===`win32`?`Windows`:e===`freebsd`?`FreeBSD`:e===`openbsd`?`OpenBSD`:e===`linux`?`Linux`:e?`Other:${e}`:`Unknown`),Xu,Zu=()=>Xu??=Ku();function Qu(){if(typeof fetch<`u`)return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function $u(...e){let t=globalThis.ReadableStream;if(t===void 0)throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ed(e){let t=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return $u({start(){},async pull(e){let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)},async cancel(){await t.return?.call(t)}})}function td(e){if(e[Symbol.asyncIterator])return e;let t=e.getReader();return{async next(){try{let e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){let e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function nd(e){var t;if(typeof e!=`object`||!e)return;if(e[Symbol.asyncIterator]){await(t=e[Symbol.asyncIterator]()).return?.call(t);return}let n=e.getReader(),r=n.cancel();n.releaseLock(),await r}var rd=({headers:e,body:t})=>({bodyHeaders:{"content-type":`application/json`},body:JSON.stringify(t)}),id=()=>{if(typeof File>`u`){let{process:e}=globalThis,t=typeof e?.versions?.node==`string`&&parseInt(e.versions.node.split(`.`))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(t?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":``))}};function ad(e,t,n){return id(),new File(e,t??`unknown_file`,n)}function od(e){return(typeof e==`object`&&!!e&&(`name`in e&&e.name&&String(e.name)||`url`in e&&e.url&&String(e.url)||`filename`in e&&e.filename&&String(e.filename)||`path`in e&&e.path&&String(e.path))||``).split(/[\\/]/).pop()||void 0}var sd=e=>typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`,cd=e=>typeof e==`object`&&!!e&&typeof e.size==`number`&&typeof e.type==`string`&&typeof e.text==`function`&&typeof e.slice==`function`&&typeof e.arrayBuffer==`function`,ld=e=>typeof e==`object`&&!!e&&typeof e.name==`string`&&typeof e.lastModified==`number`&&cd(e),ud=e=>typeof e==`object`&&!!e&&typeof e.url==`string`&&typeof e.blob==`function`;async function dd(e,t,n){if(id(),e=await e,ld(e))return e instanceof File?e:ad([await e.arrayBuffer()],e.name);if(ud(e)){let r=await e.blob();return t||=new URL(e.url).pathname.split(/[\\/]/).pop(),ad(await fd(r),t,n)}let r=await fd(e);if(t||=od(e),!n?.type){let e=r.find(e=>typeof e==`object`&&`type`in e&&e.type);typeof e==`string`&&(n=Object.assign(Object.assign({},n),{type:e}))}return ad(r,t,n)}async function fd(e){var t,n,r,i;let a=[];if(typeof e==`string`||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)a.push(e);else if(cd(e))a.push(e instanceof Blob?e:await e.arrayBuffer());else if(sd(e))try{for(var o=!0,s=io(e),c;c=await s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let e=i;a.push(...await fd(e))}}catch(e){n={error:e}}finally{try{!o&&!t&&(r=s.return)&&await r.call(s)}finally{if(n)throw n.error}}else{let t=e?.constructor?.name;throw Error(`Unexpected data type: ${typeof e}${t?`; constructor: ${t}`:``}${pd(e)}`)}return a}function pd(e){return typeof e!=`object`||!e?``:`; props: [${Object.getOwnPropertyNames(e).map(e=>`"${e}"`).join(`, `)}]`}var md=class{constructor(e){this._client=e}};md._key=[];function hd(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var gd=Object.freeze(Object.create(null)),_d=((e=hd)=>(function(t,...n){if(t.length===1)return t[0];let r=!1,i=[],a=t.reduce((t,a,o)=>{/[?#]/.test(a)&&(r=!0);let s=n[o],c=(r?encodeURIComponent:e)(``+s);return o!==n.length&&(s==null||typeof s==`object`&&s.toString===Object.getPrototypeOf(Object.getPrototypeOf(s.hasOwnProperty??gd)??gd)?.toString)&&(c=s+``,i.push({start:t.length+a.length,length:c.length,error:`Value of type ${Object.prototype.toString.call(s).slice(8,-1)} is not a valid path parameter`})),t+a+(o===n.length?``:c)},``),o=a.split(/[?#]/,1)[0],s=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,c;for(;(c=s.exec(o))!==null;)i.push({start:c.index,length:c[0].length,error:`Value "${c[0]}" can\'t be safely passed as a path parameter`});if(i.sort((e,t)=>e.start-t.start),i.length>0){let e=0,t=i.reduce((t,n)=>{let r=` `.repeat(n.start-e),i=`^`.repeat(n.length);return e=n.start+n.length,t+r+i},``);throw new Su(`Path parameters result in path with invalid segments:\n${i.map(e=>e.error).join(` +`)}\n${a}\n${t}`)}return a}))(hd),vd=class extends md{create(e,t){let{api_version:n=this._client.apiVersion}=e,r=eo(e,[`api_version`]);if(`model`in r&&`agent_config`in r)throw new Su("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");if(`agent`in r&&`generation_config`in r)throw new Su("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");return this._client.post(_d`/${n}/interactions`,Object.assign(Object.assign({body:r},t),{stream:e.stream??!1}))}delete(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.delete(_d`/${r}/interactions/${e}`,n)}cancel(e,t={},n){let{api_version:r=this._client.apiVersion}=t??{};return this._client.post(_d`/${r}/interactions/${e}/cancel`,n)}get(e,t={},n){let r=t??{},{api_version:i=this._client.apiVersion}=r,a=eo(r,[`api_version`]);return this._client.get(_d`/${i}/interactions/${e}`,Object.assign(Object.assign({query:a},n),{stream:t?.stream??!1}))}};vd._key=Object.freeze([`interactions`]);var yd=class extends vd{};function bd(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var xd;function Sd(e){let t;return(xd??=(t=new globalThis.TextEncoder,t.encode.bind(t)))(e)}var Cd;function wd(e){let t;return(Cd??=(t=new globalThis.TextDecoder,t.decode.bind(t)))(e)}var Td=class{constructor(){this.buffer=new Uint8Array,this.carriageReturnIndex=null}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Sd(e):e;this.buffer=bd([this.buffer,t]);let n=[],r;for(;(r=Ed(this.buffer,this.carriageReturnIndex))!=null;){if(r.carriage&&this.carriageReturnIndex==null){this.carriageReturnIndex=r.index;continue}if(this.carriageReturnIndex!=null&&(r.index!==this.carriageReturnIndex+1||r.carriage)){n.push(wd(this.buffer.subarray(0,this.carriageReturnIndex-1))),this.buffer=this.buffer.subarray(this.carriageReturnIndex),this.carriageReturnIndex=null;continue}let e=this.carriageReturnIndex===null?r.preceding:r.preceding-1,t=wd(this.buffer.subarray(0,e));n.push(t),this.buffer=this.buffer.subarray(r.index),this.carriageReturnIndex=null}return n}flush(){return this.buffer.length?this.decode(` +`):[]}};Td.NEWLINE_CHARS=new Set([` +`,`\r`]),Td.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function Ed(e,t){for(let n=t??0;n{if(e){if(Bu(Od,e))return e;Pd(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(Od))}`)}};function Ad(){}function jd(e,t,n){return!t||Od[e]>Od[n]?Ad:t[e].bind(t)}var Md={error:Ad,warn:Ad,info:Ad,debug:Ad},Nd=new WeakMap;function Pd(e){let t=e.logger,n=e.logLevel??`off`;if(!t)return Md;let r=Nd.get(t);if(r&&r[0]===n)return r[1];let i={error:jd(`error`,t,n),warn:jd(`warn`,t,n),info:jd(`info`,t,n),debug:jd(`debug`,t,n)};return Nd.set(t,[n,i]),i}var Fd=e=>(e.options&&(e.options=Object.assign({},e.options),delete e.options.headers),e.headers&&=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([e,t])=>[e,e.toLowerCase()===`x-goog-api-key`||e.toLowerCase()===`authorization`||e.toLowerCase()===`cookie`||e.toLowerCase()===`set-cookie`?`***`:t])),`retryOfRequestLogID`in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e),Id=class e{constructor(e,t,n){this.iterator=e,this.controller=t,this.client=n}static fromSSEResponse(t,n,r){let i=!1,a=r?Pd(r):console;function o(){return ro(this,arguments,function*(){var e,r,o,s;if(i)throw new Su("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let c=!1;try{try{for(var l=!0,u=io(Ld(t,n)),d;d=yield no(u.next()),e=d.done,!e;l=!0){s=d.value,l=!1;let e=s;if(!c)if(e.data.startsWith(`[DONE]`)){c=!0;continue}else try{yield yield no(JSON.parse(e.data))}catch(t){throw a.error(`Could not parse message into JSON:`,e.data),a.error(`From chunk:`,e.raw),t}}}catch(e){r={error:e}}finally{try{!l&&!e&&(o=u.return)&&(yield no(o.call(u)))}finally{if(r)throw r.error}}c=!0}catch(e){if(bu(e))return yield no(void 0);throw e}finally{c||n.abort()}})}return new e(o,n,r)}static fromReadableStream(t,n,r){let i=!1;function a(){return ro(this,arguments,function*(){var e,n,r,i;let a=new Td,o=td(t);try{for(var s=!0,c=io(o),l;l=yield no(c.next()),e=l.done,!e;s=!0){i=l.value,s=!1;let e=i;for(let t of a.decode(e))yield yield no(t)}}catch(e){n={error:e}}finally{try{!s&&!e&&(r=c.return)&&(yield no(r.call(c)))}finally{if(n)throw n.error}}for(let e of a.flush())yield yield no(e)})}function o(){return ro(this,arguments,function*(){var e,t,r,o;if(i)throw new Su("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let s=!1;try{try{for(var c=!0,l=io(a()),u;u=yield no(l.next()),e=u.done,!e;c=!0){o=u.value,c=!1;let e=o;s||e&&(yield yield no(JSON.parse(e)))}}catch(e){t={error:e}}finally{try{!c&&!e&&(r=l.return)&&(yield no(r.call(l)))}finally{if(t)throw t.error}}s=!0}catch(e){if(bu(e))return yield no(void 0);throw e}finally{s||n.abort()}})}return new e(o,n,r)}[Symbol.asyncIterator](){return this.iterator()}tee(){let t=[],n=[],r=this.iterator(),i=e=>({next:()=>{if(e.length===0){let e=r.next();t.push(e),n.push(e)}return e.shift()}});return[new e(()=>i(t),this.controller,this.client),new e(()=>i(n),this.controller,this.client)]}toReadableStream(){let e=this,t;return $u({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{let{value:n,done:r}=await t.next();if(r)return e.close();let i=Sd(JSON.stringify(n)+` +`);e.enqueue(i)}catch(t){e.error(t)}},async cancel(){await t.return?.call(t)}})}};function Ld(e,t){return ro(this,arguments,function*(){var n,r,i,a;if(!e.body)throw t.abort(),globalThis.navigator!==void 0&&globalThis.navigator.product===`ReactNative`?new Su(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`):new Su(`Attempted to iterate over a response with no body`);let o=new zd,s=new Td,c=td(e.body);try{for(var l=!0,u=io(Rd(c)),d;d=yield no(u.next()),n=d.done,!n;l=!0){a=d.value,l=!1;let e=a;for(let t of s.decode(e)){let e=o.decode(t);e&&(yield yield no(e))}}}catch(e){r={error:e}}finally{try{!l&&!n&&(i=u.return)&&(yield no(i.call(u)))}finally{if(r)throw r.error}}for(let e of s.flush()){let t=o.decode(e);t&&(yield yield no(t))}})}function Rd(e){return ro(this,arguments,function*(){var t,n,r,i;let a=new Uint8Array;try{for(var o=!0,s=io(e),c;c=yield no(s.next()),t=c.done,!t;o=!0){i=c.value,o=!1;let e=i;if(e==null)continue;let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e==`string`?Sd(e):e,n=new Uint8Array(a.length+t.length);n.set(a),n.set(t,a.length),a=n;let r;for(;(r=Dd(a))!==-1;)yield yield no(a.slice(0,r)),a=a.slice(r)}}catch(e){n={error:e}}finally{try{!o&&!t&&(r=s.return)&&(yield no(r.call(s)))}finally{if(n)throw n.error}}a.length>0&&(yield yield no(a))})}var zd=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith(`\r`)&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let e={event:this.event,data:this.data.join(` +`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(`:`))return null;let[t,n,r]=Bd(e,`:`);return r.startsWith(` `)&&(r=r.substring(1)),t===`event`?this.event=r:t===`data`&&this.data.push(r),null}};function Bd(e,t){let n=e.indexOf(t);return n===-1?[e,``,``]:[e.substring(0,n),t,e.substring(n+t.length)]}async function Vd(e,t){let{response:n,requestLogID:r,retryOfRequestLogID:i,startTime:a}=t,o=await(async()=>{if(t.options.stream)return Pd(e).debug(`response`,n.status,n.url,n.headers,n.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(n,t.controller,e):Id.fromSSEResponse(n,t.controller,e);if(n.status===204)return null;if(t.options.__binaryResponse)return n;let r=(n.headers.get(`content-type`)?.split(`;`)[0])?.trim();return r?.includes(`application/json`)||r?.endsWith(`+json`)?await n.json():await n.text()})();return Pd(e).debug(`[${r}] response parsed`,Fd({retryOfRequestLogID:i,url:n.url,status:n.status,body:o,durationMs:Date.now()-a})),o}var Hd=class e extends Promise{constructor(e,t,n=Vd){super(e=>{e(null)}),this.responsePromise=t,this.parseResponse=n,this.client=e}_thenUnwrap(t){return new e(this.client,this.responsePromise,async(e,n)=>t(await this.parseResponse(e,n),n))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t}}parse(){return this.parsedPromise||=this.responsePromise.then(e=>this.parseResponse(this.client,e)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}},Ud=Symbol(`brand.privateNullableHeaders`);function*Wd(e){if(!e)return;if(Ud in e){let{values:t,nulls:n}=e;yield*t.entries();for(let e of n)yield[e,null];return}let t=!1,n;e instanceof Headers?n=e.entries():Ru(e)?n=e:(t=!0,n=Object.entries(e??{}));for(let e of n){let n=e[0];if(typeof n!=`string`)throw TypeError(`expected header name to be a string`);let r=Ru(e[1])?e[1]:[e[1]],i=!1;for(let e of r)e!==void 0&&(t&&!i&&(i=!0,yield[n,null]),yield[n,e])}}var Gd=e=>{let t=new Headers,n=new Set;for(let r of e){let e=new Set;for(let[i,a]of Wd(r)){let r=i.toLowerCase();e.has(r)||(t.delete(i),e.add(r)),a===null?(t.delete(i),n.add(r)):(t.append(i,a),n.delete(r))}}return{[Ud]:!0,values:t,nulls:n}},Kd=e=>{var t;if(globalThis.process!==void 0)return{}[e]?.trim()??void 0;if(globalThis.Deno!==void 0)return(((t=globalThis.Deno.env)?.get)?.call(t,e))?.trim()},qd,Jd=class e{constructor(t){var{baseURL:n=Kd(`GEMINI_NEXT_GEN_API_BASE_URL`),apiKey:r=Kd(`GEMINI_API_KEY`)??null,apiVersion:i=`v1beta`}=t,a=eo(t,[`baseURL`,`apiKey`,`apiVersion`]);let o=Object.assign(Object.assign({apiKey:r,apiVersion:i},a),{baseURL:n||`https://generativelanguage.googleapis.com`});this.baseURL=o.baseURL,this.timeout=o.timeout??e.DEFAULT_TIMEOUT,this.logger=o.logger??console;let s=`warn`;this.logLevel=s,this.logLevel=kd(o.logLevel,`ClientOptions.logLevel`,this)??kd(Kd(`GEMINI_NEXT_GEN_API_LOG`),`process.env['GEMINI_NEXT_GEN_API_LOG']`,this)??s,this.fetchOptions=o.fetchOptions,this.maxRetries=o.maxRetries??2,this.fetch=o.fetch??Qu(),this.encoder=rd,this._options=o,this.apiKey=r,this.apiVersion=i,this.clientAdapter=o.clientAdapter}withOptions(e){return new this.constructor(Object.assign(Object.assign(Object.assign({},this._options),{baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,apiVersion:this.apiVersion}),e))}baseURLOverridden(){return this.baseURL!==`https://generativelanguage.googleapis.com`}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.has(`authorization`)||e.has(`x-goog-api-key`))&&!(this.apiKey&&e.get(`x-goog-api-key`))&&!t.has(`x-goog-api-key`))throw Error(`Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted`)}async authHeaders(e){let t=Gd([e.headers]);if(!(t.values.has(`authorization`)||t.values.has(`x-goog-api-key`))){if(this.apiKey)return Gd([{"x-goog-api-key":this.apiKey}]);if(this.clientAdapter.isVertexAI())return Gd([await this.clientAdapter.getAuthHeaders()])}}stringifyQuery(e){return Object.entries(e).filter(([e,t])=>t!==void 0).map(([e,t])=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(t===null)return`${encodeURIComponent(e)}=`;throw new Su(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join(`&`)}getUserAgent(){return`${this.constructor.name}/JS ${Wu}`}defaultIdempotencyKey(){return`stainless-node-retry-${yu()}`}makeStatusError(e,t,n,r){return Cu.generate(e,t,n,r)}buildURL(e,t,n){let r=!this.baseURLOverridden()&&n||this.baseURL,i=Iu(e)?new URL(e):new URL(r+(r.endsWith(`/`)&&e.startsWith(`/`)?e.slice(1):e)),a=this.defaultQuery();return zu(a)||(t=Object.assign(Object.assign({},a),t)),typeof t==`object`&&t&&!Array.isArray(t)&&(i.search=this.stringifyQuery(t)),i.toString()}async prepareOptions(e){if(this.clientAdapter&&this.clientAdapter.isVertexAI()&&!e.path.startsWith(`/${this.apiVersion}/projects/`)){let t=e.path.slice(this.apiVersion.length+1);e.path=`/${this.apiVersion}/projects/${this.clientAdapter.getProject()}/locations/${this.clientAdapter.getLocation()}${t}`}}async prepareRequest(e,{url:t,options:n}){}get(e,t){return this.methodRequest(`get`,e,t)}post(e,t){return this.methodRequest(`post`,e,t)}patch(e,t){return this.methodRequest(`patch`,e,t)}put(e,t){return this.methodRequest(`put`,e,t)}delete(e,t){return this.methodRequest(`delete`,e,t)}methodRequest(e,t,n){return this.request(Promise.resolve(n).then(n=>Object.assign({method:e,path:t},n)))}request(e,t=null){return new Hd(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,n){let r=await e,i=r.maxRetries??this.maxRetries;t??=i,await this.prepareOptions(r);let{req:a,url:o,timeout:s}=await this.buildRequest(r,{retryCount:i-t});await this.prepareRequest(a,{url:o,options:r});let c=`log_`+(Math.random()*(1<<24)|0).toString(16).padStart(6,`0`),l=n===void 0?``:`, retryOf: ${n}`,u=Date.now();if(Pd(this).debug(`[${c}] sending request`,Fd({retryOfRequestLogID:n,method:r.method,url:o,options:r,headers:a.headers})),r.signal?.aborted)throw new wu;let d=new AbortController,f=await this.fetchWithTimeout(o,a,s,d).catch(xu),p=Date.now();if(f instanceof globalThis.Error){let e=`retrying, ${t} attempts remaining`;if(r.signal?.aborted)throw new wu;let i=bu(f)||/timed? ?out/i.test(String(f)+(`cause`in f?String(f.cause):``));if(t)return Pd(this).info(`[${c}] connection ${i?`timed out`:`failed`} - ${e}`),Pd(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (${e})`,Fd({retryOfRequestLogID:n,url:o,durationMs:p-u,message:f.message})),this.retryRequest(r,t,n??c);throw Pd(this).info(`[${c}] connection ${i?`timed out`:`failed`} - error; no more retries left`),Pd(this).debug(`[${c}] connection ${i?`timed out`:`failed`} (error; no more retries left)`,Fd({retryOfRequestLogID:n,url:o,durationMs:p-u,message:f.message})),i?new Eu:new Tu({cause:f})}let m=`[${c}${l}] ${a.method} ${o} ${f.ok?`succeeded`:`failed`} with status ${f.status} in ${p-u}ms`;if(!f.ok){let e=await this.shouldRetry(f);if(t&&e){let e=`retrying, ${t} attempts remaining`;return await nd(f.body),Pd(this).info(`${m} - ${e}`),Pd(this).debug(`[${c}] response error (${e})`,Fd({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:p-u})),this.retryRequest(r,t,n??c,f.headers)}let i=e?`error; no more retries left`:`error; not retryable`;Pd(this).info(`${m} - ${i}`);let a=await f.text().catch(e=>xu(e).message),o=Hu(a),s=o?void 0:a;throw Pd(this).debug(`[${c}] response error (${i})`,Fd({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,message:s,durationMs:Date.now()-u})),this.makeStatusError(f.status,o,s,f.headers)}return Pd(this).info(m),Pd(this).debug(`[${c}] response start`,Fd({retryOfRequestLogID:n,url:f.url,status:f.status,headers:f.headers,durationMs:p-u})),{response:f,options:r,controller:d,requestLogID:c,retryOfRequestLogID:n,startTime:u}}async fetchWithTimeout(e,t,n,r){let i=t||{},{signal:a,method:o}=i,s=eo(i,[`signal`,`method`]);a&&a.addEventListener(`abort`,()=>r.abort());let c=setTimeout(()=>r.abort(),n),l=globalThis.ReadableStream&&s.body instanceof globalThis.ReadableStream||typeof s.body==`object`&&s.body!==null&&Symbol.asyncIterator in s.body,u=Object.assign(Object.assign(Object.assign({signal:r.signal},l?{duplex:`half`}:{}),{method:`GET`}),s);o&&(u.method=o.toUpperCase());try{return await this.fetch.call(void 0,e,u)}finally{clearTimeout(c)}}async shouldRetry(e){let t=e.headers.get(`x-should-retry`);return t===`true`?!0:t===`false`?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,n,r){let i,a=r?.get(`retry-after-ms`);if(a){let e=parseFloat(a);Number.isNaN(e)||(i=e)}let o=r?.get(`retry-after`);if(o&&!i){let e=parseFloat(o);i=Number.isNaN(e)?Date.parse(o)-Date.now():e*1e3}if(!(i&&0<=i&&i<60*1e3)){let n=e.maxRetries??this.maxRetries;i=this.calculateDefaultRetryTimeoutMillis(t,n)}return await Uu(i),this.makeRequest(e,t-1,n)}calculateDefaultRetryTimeoutMillis(e,t){let n=t-e;return Math.min(.5*2**n,8)*(1-Math.random()*.25)*1e3}async buildRequest(e,{retryCount:t=0}={}){let n=Object.assign({},e),{method:r,path:i,query:a,defaultBaseURL:o}=n,s=this.buildURL(i,a,o);`timeout`in n&&Vu(`timeout`,n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:c,body:l}=this.buildBody({options:n}),u=await this.buildHeaders({options:e,method:r,bodyHeaders:c,retryCount:t});return{req:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({method:r,headers:u},n.signal&&{signal:n.signal}),globalThis.ReadableStream&&l instanceof globalThis.ReadableStream&&{duplex:`half`}),l&&{body:l}),this.fetchOptions??{}),n.fetchOptions??{}),url:s,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:r}){let i={};this.idempotencyHeader&&t!==`get`&&(e.idempotencyKey||=this.defaultIdempotencyKey(),i[this.idempotencyHeader]=e.idempotencyKey);let a=await this.authHeaders(e),o=Gd([i,Object.assign(Object.assign({Accept:`application/json`,"User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(r)},e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{}),Zu()),this._options.defaultHeaders,n,e.headers,a]);return this.validateHeaders(o),o.values}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=Gd([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e==`string`&&n.values.has(`content-type`)||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e==`object`&&(Symbol.asyncIterator in e||Symbol.iterator in e&&`next`in e&&typeof e.next==`function`)?{bodyHeaders:void 0,body:ed(e)}:this.encoder({body:e,headers:n})}};Jd.DEFAULT_TIMEOUT=6e4;var Yd=class extends Jd{constructor(){super(...arguments),this.interactions=new yd(this)}};qd=Yd,Yd.GeminiNextGenAPIClient=qd,Yd.GeminiNextGenAPIClientError=Su,Yd.APIError=Cu,Yd.APIConnectionError=Tu,Yd.APIConnectionTimeoutError=Eu,Yd.APIUserAbortError=wu,Yd.NotFoundError=Au,Yd.ConflictError=ju,Yd.RateLimitError=Nu,Yd.BadRequestError=Du,Yd.AuthenticationError=Ou,Yd.InternalServerError=Pu,Yd.PermissionDeniedError=ku,Yd.UnprocessableEntityError=Mu,Yd.toFile=dd,Yd.Interactions=yd;function Xd(e,t){let n={},r=Y(e,[`name`]);return r!=null&&J(n,[`_url`,`name`],r),n}function Zd(e,t){let n={},r=Y(e,[`name`]);return r!=null&&J(n,[`_url`,`name`],r),n}function Qd(e,t){let n={},r=Y(e,[`sdkHttpResponse`]);return r!=null&&J(n,[`sdkHttpResponse`],r),n}function $d(e,t){let n={},r=Y(e,[`sdkHttpResponse`]);return r!=null&&J(n,[`sdkHttpResponse`],r),n}function ef(e,t,n){let r={};if(Y(e,[`validationDataset`])!==void 0)throw Error(`validationDataset parameter is not supported in Gemini API.`);let i=Y(e,[`tunedModelDisplayName`]);if(t!==void 0&&i!=null&&J(t,[`displayName`],i),Y(e,[`description`])!==void 0)throw Error(`description parameter is not supported in Gemini API.`);let a=Y(e,[`epochCount`]);t!==void 0&&a!=null&&J(t,[`tuningTask`,`hyperparameters`,`epochCount`],a);let o=Y(e,[`learningRateMultiplier`]);if(o!=null&&J(r,[`tuningTask`,`hyperparameters`,`learningRateMultiplier`],o),Y(e,[`exportLastCheckpointOnly`])!==void 0)throw Error(`exportLastCheckpointOnly parameter is not supported in Gemini API.`);if(Y(e,[`preTunedModelCheckpointId`])!==void 0)throw Error(`preTunedModelCheckpointId parameter is not supported in Gemini API.`);if(Y(e,[`adapterSize`])!==void 0)throw Error(`adapterSize parameter is not supported in Gemini API.`);let s=Y(e,[`batchSize`]);t!==void 0&&s!=null&&J(t,[`tuningTask`,`hyperparameters`,`batchSize`],s);let c=Y(e,[`learningRate`]);if(t!==void 0&&c!=null&&J(t,[`tuningTask`,`hyperparameters`,`learningRate`],c),Y(e,[`labels`])!==void 0)throw Error(`labels parameter is not supported in Gemini API.`);if(Y(e,[`beta`])!==void 0)throw Error(`beta parameter is not supported in Gemini API.`);return r}function tf(e,t,n){let r={},i=Y(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=Y(e,[`validationDataset`]);t!==void 0&&n!=null&&J(t,[`supervisedTuningSpec`],yf(n))}else if(i===`PREFERENCE_TUNING`){let n=Y(e,[`validationDataset`]);t!==void 0&&n!=null&&J(t,[`preferenceOptimizationSpec`],yf(n))}let a=Y(e,[`tunedModelDisplayName`]);t!==void 0&&a!=null&&J(t,[`tunedModelDisplayName`],a);let o=Y(e,[`description`]);t!==void 0&&o!=null&&J(t,[`description`],o);let s=Y(n,[`config`,`method`]);if(s===void 0&&(s=`SUPERVISED_FINE_TUNING`),s===`SUPERVISED_FINE_TUNING`){let n=Y(e,[`epochCount`]);t!==void 0&&n!=null&&J(t,[`supervisedTuningSpec`,`hyperParameters`,`epochCount`],n)}else if(s===`PREFERENCE_TUNING`){let n=Y(e,[`epochCount`]);t!==void 0&&n!=null&&J(t,[`preferenceOptimizationSpec`,`hyperParameters`,`epochCount`],n)}let c=Y(n,[`config`,`method`]);if(c===void 0&&(c=`SUPERVISED_FINE_TUNING`),c===`SUPERVISED_FINE_TUNING`){let n=Y(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&J(t,[`supervisedTuningSpec`,`hyperParameters`,`learningRateMultiplier`],n)}else if(c===`PREFERENCE_TUNING`){let n=Y(e,[`learningRateMultiplier`]);t!==void 0&&n!=null&&J(t,[`preferenceOptimizationSpec`,`hyperParameters`,`learningRateMultiplier`],n)}let l=Y(n,[`config`,`method`]);if(l===void 0&&(l=`SUPERVISED_FINE_TUNING`),l===`SUPERVISED_FINE_TUNING`){let n=Y(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&J(t,[`supervisedTuningSpec`,`exportLastCheckpointOnly`],n)}else if(l===`PREFERENCE_TUNING`){let n=Y(e,[`exportLastCheckpointOnly`]);t!==void 0&&n!=null&&J(t,[`preferenceOptimizationSpec`,`exportLastCheckpointOnly`],n)}let u=Y(n,[`config`,`method`]);if(u===void 0&&(u=`SUPERVISED_FINE_TUNING`),u===`SUPERVISED_FINE_TUNING`){let n=Y(e,[`adapterSize`]);t!==void 0&&n!=null&&J(t,[`supervisedTuningSpec`,`hyperParameters`,`adapterSize`],n)}else if(u===`PREFERENCE_TUNING`){let n=Y(e,[`adapterSize`]);t!==void 0&&n!=null&&J(t,[`preferenceOptimizationSpec`,`hyperParameters`,`adapterSize`],n)}if(Y(e,[`batchSize`])!==void 0)throw Error(`batchSize parameter is not supported in Vertex AI.`);if(Y(e,[`learningRate`])!==void 0)throw Error(`learningRate parameter is not supported in Vertex AI.`);let d=Y(e,[`labels`]);t!==void 0&&d!=null&&J(t,[`labels`],d);let f=Y(e,[`beta`]);return t!==void 0&&f!=null&&J(t,[`preferenceOptimizationSpec`,`hyperParameters`,`beta`],f),r}function nf(e,t){let n={},r=Y(e,[`baseModel`]);r!=null&&J(n,[`baseModel`],r);let i=Y(e,[`preTunedModel`]);i!=null&&J(n,[`preTunedModel`],i);let a=Y(e,[`trainingDataset`]);a!=null&&mf(a);let o=Y(e,[`config`]);return o!=null&&ef(o,n),n}function rf(e,t){let n={},r=Y(e,[`baseModel`]);r!=null&&J(n,[`baseModel`],r);let i=Y(e,[`preTunedModel`]);i!=null&&J(n,[`preTunedModel`],i);let a=Y(e,[`trainingDataset`]);a!=null&&hf(a,n,t);let o=Y(e,[`config`]);return o!=null&&tf(o,n,t),n}function af(e,t){let n={},r=Y(e,[`name`]);return r!=null&&J(n,[`_url`,`name`],r),n}function of(e,t){let n={},r=Y(e,[`name`]);return r!=null&&J(n,[`_url`,`name`],r),n}function sf(e,t,n){let r={},i=Y(e,[`pageSize`]);t!==void 0&&i!=null&&J(t,[`_query`,`pageSize`],i);let a=Y(e,[`pageToken`]);t!==void 0&&a!=null&&J(t,[`_query`,`pageToken`],a);let o=Y(e,[`filter`]);return t!==void 0&&o!=null&&J(t,[`_query`,`filter`],o),r}function cf(e,t,n){let r={},i=Y(e,[`pageSize`]);t!==void 0&&i!=null&&J(t,[`_query`,`pageSize`],i);let a=Y(e,[`pageToken`]);t!==void 0&&a!=null&&J(t,[`_query`,`pageToken`],a);let o=Y(e,[`filter`]);return t!==void 0&&o!=null&&J(t,[`_query`,`filter`],o),r}function lf(e,t){let n={},r=Y(e,[`config`]);return r!=null&&sf(r,n),n}function uf(e,t){let n={},r=Y(e,[`config`]);return r!=null&&cf(r,n),n}function df(e,t){let n={},r=Y(e,[`sdkHttpResponse`]);r!=null&&J(n,[`sdkHttpResponse`],r);let i=Y(e,[`nextPageToken`]);i!=null&&J(n,[`nextPageToken`],i);let a=Y(e,[`tunedModels`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>gf(e))),J(n,[`tuningJobs`],e)}return n}function ff(e,t){let n={},r=Y(e,[`sdkHttpResponse`]);r!=null&&J(n,[`sdkHttpResponse`],r);let i=Y(e,[`nextPageToken`]);i!=null&&J(n,[`nextPageToken`],i);let a=Y(e,[`tuningJobs`]);if(a!=null){let e=a;Array.isArray(e)&&(e=e.map(e=>_f(e))),J(n,[`tuningJobs`],e)}return n}function pf(e,t){let n={},r=Y(e,[`name`]);r!=null&&J(n,[`model`],r);let i=Y(e,[`name`]);return i!=null&&J(n,[`endpoint`],i),n}function mf(e,t){let n={};if(Y(e,[`gcsUri`])!==void 0)throw Error(`gcsUri parameter is not supported in Gemini API.`);if(Y(e,[`vertexDatasetResource`])!==void 0)throw Error(`vertexDatasetResource parameter is not supported in Gemini API.`);let r=Y(e,[`examples`]);if(r!=null){let e=r;Array.isArray(e)&&(e=e.map(e=>e)),J(n,[`examples`,`examples`],e)}return n}function hf(e,t,n){let r={},i=Y(n,[`config`,`method`]);if(i===void 0&&(i=`SUPERVISED_FINE_TUNING`),i===`SUPERVISED_FINE_TUNING`){let n=Y(e,[`gcsUri`]);t!==void 0&&n!=null&&J(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(i===`PREFERENCE_TUNING`){let n=Y(e,[`gcsUri`]);t!==void 0&&n!=null&&J(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}let a=Y(n,[`config`,`method`]);if(a===void 0&&(a=`SUPERVISED_FINE_TUNING`),a===`SUPERVISED_FINE_TUNING`){let n=Y(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&J(t,[`supervisedTuningSpec`,`trainingDatasetUri`],n)}else if(a===`PREFERENCE_TUNING`){let n=Y(e,[`vertexDatasetResource`]);t!==void 0&&n!=null&&J(t,[`preferenceOptimizationSpec`,`trainingDatasetUri`],n)}if(Y(e,[`examples`])!==void 0)throw Error(`examples parameter is not supported in Vertex AI.`);return r}function gf(e,t){let n={},r=Y(e,[`sdkHttpResponse`]);r!=null&&J(n,[`sdkHttpResponse`],r);let i=Y(e,[`name`]);i!=null&&J(n,[`name`],i);let a=Y(e,[`state`]);a!=null&&J(n,[`state`],si(a));let o=Y(e,[`createTime`]);o!=null&&J(n,[`createTime`],o);let s=Y(e,[`tuningTask`,`startTime`]);s!=null&&J(n,[`startTime`],s);let c=Y(e,[`tuningTask`,`completeTime`]);c!=null&&J(n,[`endTime`],c);let l=Y(e,[`updateTime`]);l!=null&&J(n,[`updateTime`],l);let u=Y(e,[`description`]);u!=null&&J(n,[`description`],u);let d=Y(e,[`baseModel`]);d!=null&&J(n,[`baseModel`],d);let f=Y(e,[`_self`]);return f!=null&&J(n,[`tunedModel`],pf(f)),n}function _f(e,t){let n={},r=Y(e,[`sdkHttpResponse`]);r!=null&&J(n,[`sdkHttpResponse`],r);let i=Y(e,[`name`]);i!=null&&J(n,[`name`],i);let a=Y(e,[`state`]);a!=null&&J(n,[`state`],si(a));let o=Y(e,[`createTime`]);o!=null&&J(n,[`createTime`],o);let s=Y(e,[`startTime`]);s!=null&&J(n,[`startTime`],s);let c=Y(e,[`endTime`]);c!=null&&J(n,[`endTime`],c);let l=Y(e,[`updateTime`]);l!=null&&J(n,[`updateTime`],l);let u=Y(e,[`error`]);u!=null&&J(n,[`error`],u);let d=Y(e,[`description`]);d!=null&&J(n,[`description`],d);let f=Y(e,[`baseModel`]);f!=null&&J(n,[`baseModel`],f);let p=Y(e,[`tunedModel`]);p!=null&&J(n,[`tunedModel`],p);let m=Y(e,[`preTunedModel`]);m!=null&&J(n,[`preTunedModel`],m);let h=Y(e,[`supervisedTuningSpec`]);h!=null&&J(n,[`supervisedTuningSpec`],h);let g=Y(e,[`preferenceOptimizationSpec`]);g!=null&&J(n,[`preferenceOptimizationSpec`],g);let _=Y(e,[`tuningDataStats`]);_!=null&&J(n,[`tuningDataStats`],_);let v=Y(e,[`encryptionSpec`]);v!=null&&J(n,[`encryptionSpec`],v);let y=Y(e,[`partnerModelTuningSpec`]);y!=null&&J(n,[`partnerModelTuningSpec`],y);let b=Y(e,[`customBaseModel`]);b!=null&&J(n,[`customBaseModel`],b);let x=Y(e,[`experiment`]);x!=null&&J(n,[`experiment`],x);let S=Y(e,[`labels`]);S!=null&&J(n,[`labels`],S);let C=Y(e,[`outputUri`]);C!=null&&J(n,[`outputUri`],C);let w=Y(e,[`pipelineJob`]);w!=null&&J(n,[`pipelineJob`],w);let T=Y(e,[`serviceAccount`]);T!=null&&J(n,[`serviceAccount`],T);let E=Y(e,[`tunedModelDisplayName`]);E!=null&&J(n,[`tunedModelDisplayName`],E);let D=Y(e,[`veoTuningSpec`]);return D!=null&&J(n,[`veoTuningSpec`],D),n}function vf(e,t){let n={},r=Y(e,[`sdkHttpResponse`]);r!=null&&J(n,[`sdkHttpResponse`],r);let i=Y(e,[`name`]);i!=null&&J(n,[`name`],i);let a=Y(e,[`metadata`]);a!=null&&J(n,[`metadata`],a);let o=Y(e,[`done`]);o!=null&&J(n,[`done`],o);let s=Y(e,[`error`]);return s!=null&&J(n,[`error`],s),n}function yf(e,t){let n={},r=Y(e,[`gcsUri`]);r!=null&&J(n,[`validationDatasetUri`],r);let i=Y(e,[`vertexDatasetResource`]);return i!=null&&J(n,[`validationDatasetUri`],i),n}var bf=class extends Ht{constructor(e){super(),this.apiClient=e,this.list=async(e={})=>new ya(va.PAGED_ITEM_TUNING_JOBS,e=>this.listInternal(e),await this.listInternal(e),e),this.get=async e=>await this.getInternal(e),this.tune=async e=>{if(this.apiClient.isVertexAI())if(e.baseModel.startsWith(`projects/`)){let t={tunedModelName:e.baseModel};e.config?.preTunedModelCheckpointId&&(t.checkpointId=e.config.preTunedModelCheckpointId);let n=Object.assign(Object.assign({},e),{preTunedModel:t});return n.baseModel=void 0,await this.tuneInternal(n)}else{let t=Object.assign({},e);return await this.tuneInternal(t)}else{let t=Object.assign({},e),n=await this.tuneMldevInternal(t),r=``;return n.metadata!==void 0&&n.metadata.tunedModel!==void 0?r=n.metadata.tunedModel:n.name!==void 0&&n.name.includes(`/operations/`)&&(r=n.name.split(`/operations/`)[0]),{name:r,state:jn.JOB_STATE_QUEUED}}}}async getInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=of(e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>_f(e))}else{let i=af(e);return n=q(`{name}`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>gf(e))}}async listInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=uf(e);return n=q(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=ff(e),n=new Cr;return Object.assign(n,t),n})}else{let i=lf(e);return n=q(`tunedModels`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`GET`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=df(e),n=new Cr;return Object.assign(n,t),n})}}async cancel(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=Zd(e);return n=q(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=$d(e),n=new wr;return Object.assign(n,t),n})}else{let i=Xd(e);return n=q(`{name}:cancel`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>{let t=Qd(e),n=new wr;return Object.assign(n,t),n})}}async tuneInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI()){let i=rf(e,e);return n=q(`tuningJobs`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>_f(e))}else throw Error(`This method is only supported by the Vertex AI.`)}async tuneMldevInternal(e){let t,n=``,r={};if(this.apiClient.isVertexAI())throw Error(`This method is only supported by the Gemini Developer API.`);{let i=nf(e);return n=q(`tunedModels`,i._url),r=i._query,delete i._url,delete i._query,t=this.apiClient.request({path:n,queryParams:r,body:JSON.stringify(i),httpMethod:`POST`,httpOptions:e.config?.httpOptions,abortSignal:e.config?.abortSignal}).then(e=>e.json().then(t=>{let n=t;return n.sdkHttpResponse={headers:e.headers},n})),t.then(e=>vf(e))}}},xf=class{async download(e,t){throw Error(`Download to file is not supported in the browser, please use a browser compliant download like an tag.`)}},Sf=1024*1024*8,Cf=3,wf=1e3,Tf=2,Ef=`x-goog-upload-status`;async function Df(e,t,n){let r=await kf(e,t,n),i=await r?.json();if(r?.headers?.[Ef]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);return i.file}async function Of(e,t,n){let r=await kf(e,t,n),i=await r?.json();if(r?.headers?.[Ef]!==`final`)throw Error(`Failed to upload file: Upload status is not finalized.`);let a=rn(i),o=new Lr;return Object.assign(o,a),o}async function kf(e,t,n){let r=0,i=0,a=new ur(new Response),o=`upload`;for(r=e.size;i=r&&(o+=`, finalize`);let l=0,u=wf;for(;lsetTimeout(t,e))}var Mf=class{async upload(e,t,n){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await Df(e,t,n)}async uploadToFileSearchStore(e,t,n){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await Of(e,t,n)}async stat(e){if(typeof e==`string`)throw Error(`File path is not supported in browser uploader.`);return await Af(e)}},Nf=class{create(e,t,n){return new Pf(e,t,n)}},Pf=class{constructor(e,t,n){this.url=e,this.headers=t,this.callbacks=n}connect(){this.ws=new WebSocket(this.url),this.ws.onopen=this.callbacks.onopen,this.ws.onerror=this.callbacks.onerror,this.ws.onclose=this.callbacks.onclose,this.ws.onmessage=this.callbacks.onmessage}send(e){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.send(e)}close(){if(this.ws===void 0)throw Error(`WebSocket is not connected`);this.ws.close()}},Ff=`x-goog-api-key`,If=class{constructor(e){this.apiKey=e}async addAuthHeaders(e,t){if(e.get(Ff)===null){if(this.apiKey.startsWith(`auth_tokens/`))throw Error(`Ephemeral tokens are only supported by the live API.`);if(!this.apiKey)throw Error(`API key is missing. Please provide a valid API key.`);e.append(Ff,this.apiKey)}}},Lf=class{get interactions(){if(this._interactions!==void 0)return this._interactions;console.warn(`GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.`);let e=this.httpOptions;e?.extraBody&&console.warn(`GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.`);let t=new Yd({baseURL:this.apiClient.getBaseUrl(),apiKey:this.apiKey,apiVersion:this.apiClient.getApiVersion(),clientAdapter:this.apiClient,defaultHeaders:this.apiClient.getDefaultHeaders(),timeout:e?.timeout});return this._interactions=t.interactions,this._interactions}constructor(e){if(e.apiKey==null)throw Error(`An API Key must be set when running in a browser`);if(e.project||e.location)throw Error(`Vertex AI project based authentication is not supported on browser runtimes. Please do not provide a project or location.`);this.vertexai=e.vertexai??!1,this.apiKey=e.apiKey;let t=Vt(e.httpOptions,e.vertexai,void 0,void 0);t&&(e.httpOptions?e.httpOptions.baseUrl=t:e.httpOptions={baseUrl:t}),this.apiVersion=e.apiVersion,this.httpOptions=e.httpOptions;let n=new If(this.apiKey);this.apiClient=new vl({auth:n,apiVersion:this.apiVersion,apiKey:this.apiKey,vertexai:this.vertexai,httpOptions:this.httpOptions,userAgentExtra:`gl-node/web`,uploader:new Mf,downloader:new xf}),this.models=new Kl(this.apiClient),this.live=new Fl(this.apiClient,n,new Nf),this.batches=new ba(this.apiClient),this.chats=new lo(this.models,this.apiClient),this.caches=new $a(this.apiClient),this.files=new xo(this.apiClient),this.operations=new ql(this.apiClient),this.authTokens=new lu(this.apiClient),this.tunings=new bf(this.apiClient),this.fileSearchStores=new _u(this.apiClient)}},Rf=e=>new Lf({apiKey:e||`PLACEHOLDER_API_KEY`}),zf={type:dn.OBJECT,properties:{segments:{type:dn.ARRAY,items:{type:dn.OBJECT,properties:{startTime:{type:dn.STRING,description:`Absolute timestamp in MM:SS.mmm format (e.g. '01:05.300'). Cumulative from start.`},endTime:{type:dn.STRING,description:`Absolute timestamp in MM:SS.mmm format.`},text:{type:dn.STRING,description:`Transcribed text. Exact words spoken. No hallucinations. Must include every single word.`}},required:[`startTime`,`endTime`,`text`]}}},required:[`segments`]},Bf={type:dn.OBJECT,properties:{segments:{type:dn.ARRAY,items:{type:dn.OBJECT,properties:{startTime:{type:dn.STRING},endTime:{type:dn.STRING},text:{type:dn.STRING},words:{type:dn.ARRAY,items:{type:dn.OBJECT,properties:{text:{type:dn.STRING,description:`The single word, or character (for Chinese), or linguistic unit.`},startTime:{type:dn.STRING,description:`Start time of the word`},endTime:{type:dn.STRING,description:`End time of the word`}},required:[`text`,`startTime`,`endTime`]}}},required:[`startTime`,`endTime`,`text`,`words`]}}},required:[`segments`]};function Vf(e){if(!e)return`00:00.000`;let t=e.trim().replace(/[^\d:.]/g,``),n=0;if(!t.includes(`:`)&&/^[\d.]+$/.test(t))n=parseFloat(t);else{let e=t.split(`:`);if(e.length===3){let t=parseInt(e[0],10)||0,r=parseInt(e[1],10)||0,i=e[2].split(`.`),a=parseInt(i[0],10)||0,o=0;i[1]&&(o=parseFloat(`0.`+i[1])),n=t*3600+r*60+a+o}else if(e.length===2){let t=parseInt(e[0],10)||0,r=e[1].split(`.`),i=parseInt(r[0],10)||0,a=0;r[1]&&(a=parseFloat(`0.`+r[1])),n=t*60+i+a}}if(isNaN(n)||n<0)return`00:00.000`;let r=Math.floor(n/60),i=Math.floor(n%60),a=Math.round(n%1*1e3);return`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}.${String(a).padStart(3,`0`)}`}function Hf(e){let t=e.trim();try{let e=JSON.parse(t);if(e.segments&&Array.isArray(e.segments))return e;if(Array.isArray(e))return{segments:e}}catch{}let n=t.lastIndexOf(`}`);if(n!==-1){for(let e of[`]}`,`}`,`]}`])try{let n=t+e,r=JSON.parse(n);if(r.segments)return r}catch{}let e=t.substring(0,n+1)+`]}`;try{let t=JSON.parse(e);if(t.segments&&Array.isArray(t.segments))return t}catch{}}if(t.includes(`"words"`))throw Error(`Complex nested JSON (word-level) could not be parsed. PLease try again.`);let r=[],i=/\{\s*"startTime"\s*:\s*"?([^",]+)"?\s*,\s*"endTime"\s*:\s*"?([^",]+)"?\s*,\s*"text"\s*:\s*(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)')/g,a;for(;(a=i.exec(t))!==null;){let e=a[3]===void 0?a[4]:a[3],t=e;try{t=JSON.parse(`"${e.replace(/"/g,`\\"`)}"`)}catch{t=e.replace(/\\"/g,`"`).replace(/\\'/g,`'`).replace(/\\\\/g,`\\`)}r.push({startTime:a[1],endTime:a[2],text:t})}if(r.length>0)return{segments:r};throw Error(`Response structure invalid and could not be repaired.`)}async function Uf(e,t,n,r,i,a=`line`){try{let o=Rf(r),s=e.includes(`gemini-3`),c=``;c=a===`word`?` + SEGMENTATION: HIERARCHICAL WORD-LEVEL (TTML/KARAOKE/Enhanced LRC) + --------------------------------------------------- + CRITICAL: You are generating data for rich TTML or Karaoke display. + + 1. STRUCTURE: Group words into short, natural lines/phrases (this is the parent object). + 2. LINE LENGTH: **CRITICAL** Keep lines SHORT (approx 3-8 words). Split long sentences into multiple lines. + - Example: "I will love you forever and ever" -> Line 1: "I will love you", Line 2: "forever and ever". + 3. REPEATED WORDS & STUTTERS: **EXTREMELY IMPORTANT** + - Treat every spoken utterance as a distinct word which must be timestamped. + - Example: "No no no wait" -> 4 distinct word objects. + - Example: "I I I didn't mean it" -> 3 distinct "I" objects followed by "didn't", "mean", "it". + - NEVER merge repeated words into a single event. + 4. DETAILS: Inside each line object, you MUST provide a "words" array. + 5. WORDS: The "words" array must contain EVERY single word from that line with its own precise start/end time. + 6. CJK HANDLING: For Chinese, Japanese, or Korean scripts, treat each character (or logical block of characters) as a separate "word" for the purposes of karaoke timing. + 7. FAST SPEECH / RAP / CONVERSATION HANDLING: + - Anticipate RAPID speech delivery (high words-per-minute). + - Ensure NO DRIFT: Align every word's start/end exactly to its pronunciation. + - For rapid-fire lyrics or conversation, word segments should be distinct and tightly packed. + `:` + SEGMENTATION: LINE-LEVEL (SUBTITLE/LRC MODE) + --------------------------------------------------- + CRITICAL: You are generating subtitles for a movie/music video. + + 1. PHRASES: Group words into complete sentences or musical phrases. + 2. CLARITY: Do not break a sentence in the middle unless there is a pause. + 3. REPETITIONS: Separate repetitive vocalizations (e.g. "Oh oh oh") from the main lyrics into their own lines. + 4. LENGTH: Keep segments between 2 and 6 seconds for readability. + 5. WORDS ARRAY: You may omit the "words" array in this mode to save tokens. + `;let l=` + You are an expert Audio Transcription AI specialized in generating precise timed lyrics and subtitled conversations. + + TASK: Transcribe the audio file into JSON segments. + MODE: ${a.toUpperCase()} LEVEL. + + + TIMING RULES: + 1. FORMAT: strictly **MM:SS.mmm** (e.g., 01:23.450). + 2. CONTINUITY: Timestamps must be strictly chronological. + 3. ACCURACY: Sync text exactly to the audio. + 4. PRECISION: For fast speech/rap, ensure word-level timestamps are millisecond-accurate. + + + ${c} + + LANGUAGE HANDLING (CRITICAL): + 1. RAPID CODE-SWITCHING: Audio often contains multiple languages mixed within the SAME sentence. + 2. MULTI-LINGUAL EQUALITY: The languages might NOT include English (e.g. Indonesian mixed with Japanese, Chinese mixed with Japanese). Treat all detected languages as equally probable. + 3. WORD-LEVEL DETECTION: Detect the language of every individual word. + 4. NATIVE SCRIPT STRICTNESS: Write EACH word in its native script. + - Example: "Aku cinta kamu" (Indonesian) -> Latin. + - Example: "愛してる" (Japanese) -> Kanji/Kana. + 5. MIXED SCRIPT PRESERVATION (IMPORTANT): + - If specific English/Latin words are spoken amidst Japanese/Chinese/etc., KEEP them in LATIN script. + - DO NOT transliterate English words into Katakana (e.g. if audio says "I love you", write "I love you", NOT "アイラブユー"). + - Maintain mixed text (Kanji/Kana + Latin) exactly as spoken. + 6. PROHIBITIONS: + - DO NOT translate. + - DO NOT romanize (unless explicitly spelled out). + - DO NOT force English if it is not spoken. + + GENERAL RULES: + - Verbatim: Transcribe exactly what is heard. Include fillers (um, ah) if sung. + - Completeness: Transcribe from 00:00 to the very end. Do not summarize. + - JSON Only: Output pure JSON. No markdown fences. + `,u={responseMimeType:`application/json`,responseSchema:a===`word`?Bf:zf,temperature:.1};s&&(u.thinkingConfig={thinkingBudget:1024});let d=new Promise((e,t)=>{i?.aborted&&t(new DOMException(`Aborted`,`AbortError`)),i?.addEventListener(`abort`,()=>t(new DOMException(`Aborted`,`AbortError`)))}),f=(await Promise.race([o.models.generateContent({model:e,contents:[{parts:[{inlineData:{data:t,mimeType:n}},{text:l}]}],config:u}),d])).text;if(!f)throw Error(`Empty response from model`);return f=f.trim(),f.startsWith("```json")?f=f.replace(/^```json\s*/,``).replace(/\s*```$/,``):f.startsWith("```")&&(f=f.replace(/^```\s*/,``).replace(/\s*```$/,``)),(Hf(f).segments||[]).map(e=>({startTime:Vf(String(e.startTime)),endTime:Vf(String(e.endTime)),text:String(e.text),words:e.words?e.words.map(e=>({text:String(e.text),startTime:Vf(String(e.startTime)),endTime:Vf(String(e.endTime))})):void 0}))}catch(t){throw t.name===`AbortError`?t:(console.error(`Error with ${e}:`,t),Error(t.message||`Transcription failed`))}}var Wf=new Set([`LYRICS`,`UNSYNCEDLYRICS`,`UNSYNCED LYRICS`,`SYNCEDLYRICS`,`SYNCED LYRICS`]);async function Gf(e){let t=e.name.split(`.`).pop()?.toLowerCase();if(!t)return{lyrics:null};try{if(t===`flac`)return await Kf(e);if(t===`ogg`||t===`opus`||t===`oga`||t===`spx`)return await qf(e);if(t===`wav`||t===`wave`)return await Yf(e)}catch(e){console.warn(`[EmbeddedLyrics] Extraction failed:`,e)}return{lyrics:null}}async function Kf(e){let t=Math.min(e.size,256*1024),n=await e.slice(0,t).arrayBuffer(),r=new Uint8Array(n);if(r[0]!==102||r[1]!==76||r[2]!==97||r[3]!==67)return{lyrics:null};let i=4;for(;i+4<=r.length;){let t=r[i],a=(t&128)!=0,o=t&127,s=r[i+1]<<16|r[i+2]<<8|r[i+3],c=i+4,l=c+s;if(o===4){let t;if(l>r.length){let n=await e.slice(c,l).arrayBuffer();t=new Uint8Array(n)}else t=r.slice(c,l);return Xf(new DataView(t.buffer,t.byteOffset,t.byteLength),t)}if(i=l,i+4>r.length&&!a){let t=Math.min(e.size,i+256*1024);if(t>r.length)n=await e.slice(0,t).arrayBuffer(),r=new Uint8Array(n);else break}if(a)break}return{lyrics:null}}async function qf(e){let t=Math.min(e.size,2*1024*1024),n=await e.slice(0,t).arrayBuffer(),r=new Uint8Array(n),i=0,a=0,o=[];for(;i+27r.length)break;let t=[];for(let n=0;nr.length)return{lyrics:null};if(o.push(r.slice(n,n+i)),n+=i,i<255){if(a===1)return Jf(Zf(o));a++,o=[]}}if(i=n,a>5)break}return{lyrics:null}}function Jf(e){if(e.length<10)return{lyrics:null};let t=new TextDecoder(`utf-8`),n=0;if(e[0]===3&&e.length>7&&t.decode(e.slice(1,7))===`vorbis`&&(n=7),n===0&&e.length>8&&t.decode(e.slice(0,8))===`OpusTags`&&(n=8),n===0&&(n=0,e.length>=4)){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!0);if(t>0&&tt.length)return n;let a=e.getUint32(i,!0);if(i+=4+a,i+4>t.length)return n;let o=e.getUint32(i,!0);i+=4;for(let a=0;at.length)break;let o=r.decode(t.slice(i,i+a));i+=a;let s=o.indexOf(`=`);if(s===-1)continue;let c=o.substring(0,s).toUpperCase(),l=o.substring(s+1);Wf.has(c)?n.lyrics=l:c===`TITLE`&&!n.title?n.title=l:c===`ARTIST`&&!n.artist?n.artist=l:c===`ALBUM`&&!n.album&&(n.album=l)}}catch(e){console.warn(`[EmbeddedLyrics] Vorbis Comment parse error:`,e)}return n}function Zf(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var Qf=`modulepreload`,$f=function(e){return`/`+e},ep={},tp=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=$f(t,n),t in ep)return;ep[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Qf,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},np=({playlist:e,setPlaylist:t,currentTrackIndex:n,setCurrentTrackIndex:r,onPlayTrack:i,isPlaying:a,onTogglePlay:o,onSeek:s,onClearPlaylist:l,onRemoveTrack:u,currentTime:d,onClose:f})=>{let{confirm:p}=Ot(),m=(0,w.useRef)(null),h=(0,w.useRef)(new Map),g=e=>`[${Math.floor(e/60).toString().padStart(2,`0`)}:${(e%60).toFixed(2).padStart(5,`0`)}]`,[_,v]=(0,w.useState)(null),[y,b]=(0,w.useState)({key:null,direction:`asc`}),[x,S]=(0,w.useState)(new Set),[C,T]=(0,w.useState)(new Set),[E,D]=(0,w.useState)(localStorage.getItem(`gemini_api_key`)||``),[O,k]=(0,w.useState)(`gemini-2.5-flash`),[A,j]=(0,w.useState)(`line`),[M,N]=(0,w.useState)(!1),ee=(0,w.useRef)(null),[P,F]=(0,w.useState)(null);(0,w.useEffect)(()=>{E&&localStorage.setItem(`gemini_api_key`,E)},[E]);let I=n>=0?e[n]:null,te=I?.parsedLyrics||[],L=(0,w.useMemo)(()=>I?te.findIndex((e,t)=>{if(e.endTime!==void 0)return d>=e.time&&d=e.time&&(!n||d{if(L!==-1){let e=document.getElementById(`lyric-active-${n}`);e&&e.scrollIntoView({behavior:`smooth`,inline:`nearest`,block:`nearest`})}},[L,n]);let R=i=>{if(e.length===0)return;let a=n>=0?e[n]:null,o=[...e],s=`asc`;if(i===`random`){b({key:`random`,direction:`asc`});for(let e=o.length-1;e>0;e--){let t=Math.floor(Math.random()*(e+1));[o[e],o[t]]=[o[t],o[e]]}}else{y.key===i&&y.direction===`asc`&&(s=`desc`),b({key:i,direction:s});let e=s===`asc`?1:-1;i===`filename`?o.sort((t,n)=>e*t.audioFile.name.localeCompare(n.audioFile.name)):i===`artist`?o.sort((t,n)=>e*(t.metadata.artist||``).localeCompare(n.metadata.artist||``)):i===`title`?o.sort((t,n)=>e*(t.metadata.title||``).localeCompare(n.metadata.title||``)):i===`album`&&o.sort((t,n)=>e*(t.metadata.album||``).localeCompare(n.metadata.album||``))}if(t(o),a){let e=o.findIndex(e=>e.id===a.id);e!==-1&&r(e)}},z=(0,w.useCallback)(n=>{let r=n.target;r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable)||n.ctrlKey||n.metaKey||n.altKey||(_!==null&&n.key===`Delete`?(n.preventDefault(),n.stopPropagation(),u?u(_):t(e=>{let t=[...e];return t.splice(_,1),t}),_>=e.length-1&&v(e.length>1?e.length-2:null)):n.key===`ArrowDown`&&e.length>0?(n.preventDefault(),n.stopPropagation(),v(t=>t===null?0:Math.min(t+1,e.length-1))):n.key===`ArrowUp`&&e.length>0?(n.preventDefault(),n.stopPropagation(),v(e=>e===null?0:Math.max(e-1,0))):n.key===`Enter`&&_!==null?(n.preventDefault(),n.stopPropagation(),i(_)):n.key===`Escape`&&v(null))},[_,e.length,t,i]);(0,w.useEffect)(()=>{let e=m.current;if(e)return e.addEventListener(`keydown`,z),()=>e.removeEventListener(`keydown`,z)},[z]),(0,w.useEffect)(()=>{let e=m.current;if(!e)return;let t=e=>{let t=e.target.closest(`.lyric-timeline-scroll`);t&&t.scrollWidth>t.clientWidth&&Math.abs(e.deltaY)>0&&(e.preventDefault(),t.scrollLeft+=e.deltaY)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,w.useEffect)(()=>{_!==null&&_>=e.length&&v(e.length>0?e.length-1:null)},[e.length,_]);let B=async n=>{let r=new Map;n.forEach(e=>{let t=e.name.split(`.`).pop()?.toLowerCase(),n=(e.webkitRelativePath||e.name).replace(/\.[^/.]+$/,``);r.has(n)||r.set(n,{});let i=r.get(n);[`mp3`,`wav`,`ogg`,`flac`,`m4a`,`mp4`,`webm`,`ogg`,`mkv`,`mov`,`avi`,`m4v`].includes(t||``)?i.audio=e:[`lrc`,`srt`,`ttml`,`xml`,`json`,`vtt`].includes(t||``)&&(i.lyric=e)});let a=[],o=async(e,t)=>new Promise(n=>{if(e.type.startsWith(`video/`)){n({metadata:{title:t,artist:`Unknown Artist`,coverUrl:URL.createObjectURL(e),backgroundType:`video`}});return}tp(()=>import(`./jsmediatags.min-CmKRqElg.js`).then(e=>c(e.default,1)).then(r=>{r.read(e,{onSuccess:r=>{let{title:i,artist:a,album:o,picture:s}=r.tags,c=null;if(s){let{data:e,format:t}=s,n=``;for(let t=0;t{n({metadata:d,embeddedLyrics:e.lyrics||void 0})}).catch(()=>{n({metadata:d})})},onError:()=>{Gf(e).then(e=>{n({metadata:{title:e.title||t,artist:e.artist||`Unknown Artist`,album:e.album||void 0,coverUrl:null},embeddedLyrics:e.lyrics||void 0})}).catch(()=>{n({metadata:{title:t,artist:`Unknown Artist`,coverUrl:null}})})}})}),[]).catch(()=>{Gf(e).then(e=>{n({metadata:{title:e.title||t,artist:e.artist||`Unknown Artist`,album:e.album||void 0,coverUrl:null},embeddedLyrics:e.lyrics||void 0})}).catch(()=>{n({metadata:{title:t,artist:`Unknown Artist`,coverUrl:null}})})})}),s=async e=>{try{let t=await e.text(),n=e.name.split(`.`).pop()?.toLowerCase();if(n===`lrc`)return vt(t);if(n===`srt`)return yt(t);if(n===`ttml`||n===`xml`)return bt(t);if(n===`vtt`)return St(t);if(n===`json`)return xt(t)}catch(e){console.error(`Failed to parse lyrics`,e)}return[]};for(let[e,t]of r.entries())if(t.audio){let{metadata:n,embeddedLyrics:r}=await o(t.audio,e),i=Math.random().toString(36).substr(2,9),c=[],l=t.lyric;if(t.lyric)c=await s(t.lyric);else if(r){if(c=vt(r),c.length===0&&r.trim()){let e=r.split(` +`).map(e=>e.trim()),t=[];for(let n=0;n0&&t[t.length-1]!==``&&t.push(``):t.push(e[n]);t.length>0&&t[t.length-1]===``&&t.pop(),c=t.map(e=>({time:0,text:e}))}l=new File([r],`embedded.lrc`,{type:`text/plain`})}a.push({id:i,audioFile:t.audio,lyricFile:l,parsedLyrics:c,metadata:n,duration:0})}if(a.length>0){let n=[...e,...a];t(n),i(0,!1,n)}},re=async e=>{e.target.files&&e.target.files.length>0&&(await B(Array.from(e.target.files)),e.target.value=``)},[oe,ce]=(0,w.useState)(!1),[ue,de]=(0,w.useState)(null),[fe,H]=(0,w.useState)(null),[he,U]=(0,w.useState)(null),_e=(e,t)=>{de(t),e.dataTransfer.effectAllowed=`move`},ve=(e,t)=>{if(e.preventDefault(),e.stopPropagation(),ue===null||ue===t)return;let n=e.currentTarget.getBoundingClientRect(),r=n.top+n.height/2,i=e.clientY{if(i.preventDefault(),i.stopPropagation(),ue===null)return;let o=[...e],[s]=o.splice(ue,1),c=a;he===`after`&&c++,ue=n?r(n-1):ue>n&&c<=n&&r(n+1),Se()},Se=()=>{de(null),H(null),U(null)},Ce=e=>{e.preventDefault(),e.stopPropagation(),ue===null&&ce(!0)},we=e=>{e.preventDefault(),e.stopPropagation(),ce(!1)},Ee=async e=>{e.preventDefault(),e.stopPropagation(),ce(!1),e.dataTransfer.files&&e.dataTransfer.files.length>0&&await B(Array.from(e.dataTransfer.files))},Oe=e=>{u?u(e):t(t=>{let n=[...t];return n.splice(e,1),n})},Ae=e=>new Promise((t,n)=>{let r=new FileReader;r.readAsDataURL(e),r.onload=()=>{let e=r.result.split(`,`)[1];t(e)},r.onerror=e=>n(e)}),je=async e=>{if(!navigator.onLine){alert(`Unable to transcribe: No internet connection.`);return}if(x.has(e.id)){let t=h.current.get(e.id);t&&t.abort();return}let n=E||`PLACEHOLDER_API_KEY`;if(!n||n.trim().length<39){alert(n?`Invalid API Key length (${n.trim().length}). It must be at least 39 characters.`:`Please set your Gemini API Key first!`),N(!0);return}S(t=>new Set(t).add(e.id));let r=new AbortController;if(h.current.set(e.id,r),e.audioFile.size>19.5*1024*1024){alert(`File is too large (${(e.audioFile.size/1024/1024).toFixed(1)}MB). Gemini inline audio limit is ~20MB.\n\nPlease convert to MP3/M4A or use a smaller file.`),S(t=>{let n=new Set(t);return n.delete(e.id),n}),h.current.delete(e.id);return}try{let i=await Ae(e.audioFile),a=e.duration||0;if(a===0)try{a=await new Promise(t=>{let n=new Audio(URL.createObjectURL(e.audioFile));n.onloadedmetadata=()=>{t(n.duration),URL.revokeObjectURL(n.src)},n.onerror=()=>{URL.revokeObjectURL(n.src),t(0)}})}catch(e){console.warn(`Could not determine duration for AI validation`,e)}let o=(await Uf(O,i,e.audioFile.type,n,r.signal,A)).map(e=>({time:G(e.startTime),text:e.text,endTime:G(e.endTime),words:e.words?e.words.map(e=>({text:e.text,startTime:G(e.startTime),endTime:G(e.endTime)})):void 0}));a>0&&(o=o.filter(e=>e.time=0)),t(t=>t.map(t=>t.id===e.id?{...t,parsedLyrics:o.sort((e,t)=>e.time-t.time),duration:a>0?a:t.duration}:t))}catch(e){if(e.name===`AbortError`)console.log(`Transcription aborted via user action.`);else{console.error(`Transcription failed:`,e);let t=`Transcription failed. Please check your API key or file format.`;if(!navigator.onLine)t=`Connection lost. Please check your internet connection.`;else if(e.message){let n=e.message.toLowerCase();n.includes(`fetch`)||n.includes(`network`)||n.includes(`failed to connect`)?t=`Network error. Please check your connection.`:(n.includes(`api key`)||e.message.includes(`400`)||e.message.includes(`401`)||e.message.includes(`403`))&&(t=`API Key Error: Please check if your key is valid and has credits.`)}alert(t)}}finally{h.current.delete(e.id),S(t=>{let n=new Set(t);return n.delete(e.id),n})}},Me=async e=>{if(!navigator.onLine){alert(`No internet connection.`);return}T(t=>new Set(t).add(e.id));try{let t=await tp(()=>import(`./index.min-BUW2bet6.js`).then(e=>c(e.default,1)),[]),n,r=t.default||t;console.log(`SyncLyrics Module:`,t);let i=[`musixmatch`,`lrclib`,`netease`];if(typeof r==`function`&&r.prototype&&r.prototype.getLyrics){console.log(`Detected Class usage`);let e=new r({sources:i});n=t=>e.getLyrics(t)}else if(r.getLyrics&&typeof r.getLyrics==`function`)console.log(`Detected Instance usage`),n=e=>r.getLyrics(e);else if(r.SyncLyrics){console.log(`Detected Mod.SyncLyrics export`);let e=r.SyncLyrics;if(typeof e==`function`&&e.prototype&&e.prototype.getLyrics){console.log(`Using SyncLyrics as Class`);let t=new e({sources:i});n=e=>t.getLyrics(e)}else if(typeof e==`function`)console.log(`Using SyncLyrics as Function`),n=e;else throw Error(`Mod.SyncLyrics found but is not a function or class.`)}else if(typeof r==`function`)console.log(`Detected Function usage`),n=r;else throw Error(`Could not find suitable search function. Mod type: ${typeof r}. Keys: ${typeof r==`object`?JSON.stringify(Object.keys(r)):`N/A`}`);let a={track:e.metadata.title,artist:e.metadata.artist,album:e.metadata.album,sources:i};console.log(`Searching lyrics with options:`,a);let o=await n(a);if(o&&typeof o==`string`)Pe(o,e);else{console.warn(`npm package returned no result. Attempting fallback to LrcLib.net API directly...`);let t=e.duration||0;if(t===0)try{t=await new Promise(t=>{let n=new Audio(URL.createObjectURL(e.audioFile));n.onloadedmetadata=()=>{let e=n.duration;URL.revokeObjectURL(n.src),t(e)},n.onerror=()=>t(0)})}catch(e){console.warn(`Could not determine duration for search`,e)}let n=new URLSearchParams({artist_name:e.metadata.artist,track_name:e.metadata.title,album_name:e.metadata.album||``,duration:t.toString()}),r=await fetch(`https://lrclib.net/api/get?${n.toString()}`);if(!r.ok){let t=await fetch(`https://lrclib.net/api/search?q=${encodeURIComponent(e.metadata.title+` `+e.metadata.artist)}`);if(t.ok){let n=await t.json();if(Array.isArray(n)&&n.length>0){let t=n.find(e=>e.syncedLyrics);if(t){Pe(t.syncedLyrics,e);return}else if(n[0].plainLyrics){Pe(n[0].plainLyrics,e);return}}}throw Error(`No lyrics found in fallback source.`)}let i=await r.json();i.syncedLyrics?Pe(i.syncedLyrics,e):i.plainLyrics?Pe(i.plainLyrics,e):alert(`No lyrics found.`)}}catch(e){console.error(`Search failed:`,e),e.message?.includes(`CORS`)||e.message?.includes(`etwork`)||e.message?.includes(`Failed to fetch`)?alert(`Network Error: Could not connect to lyric services. +(Possible CORS blocking in browser).`):alert(`Search failed: `+e.message)}finally{T(t=>{let n=new Set(t);return n.delete(e.id),n})}},Pe=(e,n)=>{let r=vt(e);if(r.length===0&&(r=yt(e)),r.length>0){let i=r.some(e=>e.words&&e.words.length>0);console.log(i?`Word-level (enhanced) lyrics found!`:`Line-level lyrics found.`),t(t=>t.map(t=>t.id===n.id?{...t,parsedLyrics:r,lyricFile:new File([e],`synched-lyrics${i?`.lrc-enhanced`:`.lrc`}`,{type:`text/plain`})}:t))}else alert(`Lyrics found but could not be parsed.`)},Ie=(e,t,n)=>{let r=new Blob([e],{type:`application/octet-stream`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},Re=async(e,t)=>{let n=e.parsedLyrics||[];if(n.length===0)return;let r=``,i=t===`lrc-enhanced`?`lrc`:t,a=`${e.metadata.title||`lyrics`}.${i}`,o=e.duration||0;if(o===0)try{o=await new Promise(t=>{let n=new Audio(URL.createObjectURL(e.audioFile));n.onloadedmetadata=()=>{t(n.duration),URL.revokeObjectURL(n.src)},n.onerror=()=>t(0)})}catch(e){console.warn(`Could not determine duration for export check`,e)}let s=n.map(e=>({...e,words:e.words?e.words.filter(e=>e.text.trim().length>0).map(e=>({...e})):void 0}));for(let e=0;e0?o:n.time+5),n.words&&n.words.length>0)for(let e=0;ee.text).join(` +`);else if(t===`json`)r=JSON.stringify(s,null,2);else if(t===`srt`){let e=e=>`${Math.floor(e/3600).toString().padStart(2,`0`)}:${Math.floor(e%3600/60).toString().padStart(2,`0`)}:${Math.floor(e%60).toString().padStart(2,`0`)},${Math.floor(e%1*1e3).toString().padStart(3,`0`)}`;r=s.map((t,n)=>{let r=e(t.time),i=e(t.endTime!==void 0&&t.endTime>t.time?t.endTime:t.time+2);return`${n+1}\n${r} --> ${i}\n${t.text}\n`}).join(` +`)}else if(t===`lrc`){let e=[],t=e=>`[${Math.floor(e/60).toString().padStart(2,`0`)}:${(e%60).toFixed(2).padStart(5,`0`)}]`;for(let r=0;r0)||s<=o)&&(a?a.time>s&&e.push(`${t(s)}`):e.push(`${t(s)}`))}r=e.join(` +`)}else if(t===`lrc-enhanced`){let e=[],t=e=>`[${Math.floor(e/60).toString().padStart(2,`0`)}:${(e%60).toFixed(2).padStart(5,`0`)}]`,i=e=>`<${Math.floor(e/60).toString().padStart(2,`0`)}:${(e%60).toFixed(2).padStart(5,`0`)}>`;for(let r=0;r0?a.words.forEach((e,t)=>{let n=e.text.replace(/[ \t]+/g,` `).trim().replace(/\n/g,`\\n`);c+=`${i(e.startTime)}${n}`,t0)||l<=o)&&(s?s.time>l&&e.push(`${t(l)}`):e.push(`${t(l)}`))}r=e.join(` +`)}else if(t===`ttml`){let e=e=>`${Math.floor(e/3600).toString().padStart(2,`0`)}:${Math.floor(e%3600/60).toString().padStart(2,`0`)}:${Math.floor(e%60).toString().padStart(2,`0`)}.${Math.floor(e%1*1e3).toString().padStart(3,`0`)}`;r=` + + +
`,s.forEach(t=>{let n=e(t.time),i=e(t.endTime!==void 0&&t.endTime>t.time?t.endTime:t.time+3);r+=`\n

`,t.words&&t.words.length>0?t.words.forEach(t=>{if(!t.text.trim())return;let n=e(t.startTime),i=t.endTime;(i===void 0||i<=t.startTime)&&(i=t.startTime+.5);let a=e(i),o=t.text.replace(/[ \t]+/g,` `).trim();o.endsWith(`-`)||(o+=` `),r+=`\n ${o}`}):r+=`\n ${t.text.replace(/-\s+/g,`-`).replace(/[ \t]+/g,` `).trim()}`,r+=` +

`}),r+=` +
+ +
`}else if(t===`vtt`){let e=e=>`${Math.floor(e/3600).toString().padStart(2,`0`)}:${Math.floor(e%3600/60).toString().padStart(2,`0`)}:${Math.floor(e%60).toString().padStart(2,`0`)}.${Math.floor(e%1*1e3).toString().padStart(3,`0`)}`;r=`WEBVTT + +`,s.forEach(t=>{let n=e(t.time),i=e(t.endTime!==void 0&&t.endTime>t.time?t.endTime:t.time+2),a=t.text.trim();if(t.words&&t.words.length>0){let n=t.words.map(t=>`<${e(t.startTime)}>${t.text.trim()}`).join(` `);n.length>0&&(a=n)}r+=`${n} --> ${i}\n${a}\n\n`})}Ie(r,a,`application/octet-stream`)},ze=async()=>{if(e.length===0)return;let t=async e=>new Promise(t=>{let n=new Audio(URL.createObjectURL(e));n.onloadedmetadata=()=>{t(n.duration),URL.revokeObjectURL(n.src)},n.onerror=()=>{t(0),URL.revokeObjectURL(n.src)}}),n=`#EXTM3U +`;for(let r of e){let e=r.duration||0;if(e===0)try{e=await t(r.audioFile)}catch(e){console.error(`Failed to get duration for export`,e)}let i=Math.round(e),a=(r.metadata.artist||`Unknown Artist`).replace(/[\r\n]/g,``),o=(r.metadata.title||`Unknown Title`).replace(/[\r\n]/g,``);n+=`#EXTINF:${i},${a} - ${o}\n`;let s=r.audioFile.webkitRelativePath||r.audioFile.name;n+=`${s}\n`}Ie(n,`playlist.m3u8`,`application/octet-stream`)},Be=async e=>{await p(`Are you sure you want to clear the lyric timeline?`,`Clear Lyrics`)&&t(t=>t.map(t=>t.id===e.id?{...t,parsedLyrics:[],lyricFile:void 0}:t))},Ve=async e=>{if(!e.audioFile)return;let n=n=>{let r=vt(n);if(r.length===0&&n.trim()){let e=n.split(` +`).map(e=>e.trim()),t=[];for(let n=0;n0&&t[t.length-1]!==``&&t.push(``):t.push(e[n]);t.length>0&&t[t.length-1]===``&&t.pop(),r=t.map(e=>({time:0,text:e}))}r.length>0?t(t=>t.map(t=>t.id===e.id?{...t,parsedLyrics:r,lyricFile:new File([n],`embedded.lrc`,{type:`text/plain`})}:t)):alert(`No embedded lyrics found in this audio file.`)},r=()=>{Gf(e.audioFile).then(e=>{e.lyrics?n(e.lyrics):alert(`No embedded lyrics found in this audio file.`)}).catch(()=>{alert(`No embedded lyrics found or could not read tags.`)})};tp(()=>import(`./jsmediatags.min-CmKRqElg.js`).then(e=>c(e.default,1)).then(t=>{t.read(e.audioFile,{onSuccess:e=>{let t=e.tags.lyrics||e.tags.LYRICS||e.tags.USLT||e.tags.SYLT||e.tags.unsyncedlyrics||e.tags.SYNCEDLYRICS||e.tags[`©lyr`],i;t&&(i=typeof t==`string`?t:Array.isArray(t)?t.join(` +`):t.lyrics||t.data||t.text||void 0),i?n(i):r()},onError:()=>{r()}})}),[]).catch(()=>{r()})};return(0,K.jsxs)(`div`,{className:`w-full max-w-full h-64 flex flex-col bg-zinc-900/95 backdrop-blur-md border-t border-white/10 z-20 shadow-xl overflow-hidden outline-none relative transition-colors ${oe?`bg-zinc-800 border-orange-500`:``}`,onDragOver:Ce,onDragLeave:we,onDrop:Ee,children:[oe&&(0,K.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-zinc-900/90 backdrop-blur-sm pointer-events-none`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 text-orange-500 animate-pulse`,children:[(0,K.jsx)(He,{size:48}),(0,K.jsx)(`h3`,{className:`text-xl font-bold`,children:`Drop Audio & Lyrics Here`}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-400`,children:`Supported formats: MP3, WAV, FLAC, Video (MP4/WebM), LRC, SRT, VTT`})]})}),(0,K.jsx)(`input`,{type:`file`,name:`manual-lyric-upload`,id:`manual-lyric-upload`,ref:ee,className:`hidden`,accept:`.lrc,.srt,.ttml,.xml,.vtt`,onChange:async e=>{let n=e.target.files?.[0];if(!(!n||!P)){try{let e=await n.text(),r=n.name.split(`.`).pop()?.toLowerCase(),i=[];r===`lrc`?i=vt(e):r===`srt`?i=yt(e):r===`ttml`||r===`xml`?i=bt(e):r===`vtt`&&(i=St(e)),i.length>0?t(e=>e.map(e=>e.id===P?{...e,lyricFile:n,parsedLyrics:i}:e)):alert(`Could not parse lyrics. Ensure file is .lrc, .srt, or .vtt`)}catch(e){console.error(`Failed to load lyrics`,e),alert(`Failed to load lyrics file.`)}F(null),e.target.value=``}}}),(0,K.jsxs)(`div`,{className:`p-2 border-b border-white/10 flex items-center justify-between bg-zinc-900 z-30 shrink-0 h-12`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 flex-1 min-w-0 overflow-x-auto no-scrollbar pr-4`,children:[(0,K.jsxs)(`h2`,{className:`text-sm font-bold flex items-center gap-2 text-zinc-300 whitespace-nowrap`,children:[(0,K.jsx)(pe,{size:16,className:`text-orange-400`}),`Playlist`]}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex bg-orange-600 rounded overflow-hidden`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 px-3 py-1 hover:bg-orange-500 cursor-pointer transition-colors text-white text-xs font-medium whitespace-nowrap border-r border-orange-700`,children:[(0,K.jsx)(be,{size:14}),` Add Files`,(0,K.jsx)(`input`,{type:`file`,name:`add-files`,id:`add-files`,className:`hidden`,accept:`audio/*,video/*,.lrc,.srt,.ttml,.xml,.vtt`,multiple:!0,onChange:re})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1 hover:bg-orange-500 cursor-pointer transition-colors text-white text-xs whitespace-nowrap`,title:`Add Folder`,children:[(0,K.jsx)(se,{size:14}),(0,K.jsx)(`input`,{type:`file`,name:`add-folder`,id:`add-folder`,className:`hidden`,multiple:!0,webkitdirectory:``,onChange:re})]})]}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>R(`filename`),className:`p-1 rounded transition-colors ${y.key===`filename`?`bg-zinc-700 text-white`:`hover:bg-zinc-700 text-zinc-400 hover:text-white`}`,title:`Sort by Filename ${y.key===`filename`?y.direction===`asc`?`(A-Z)`:`(Z-A)`:``}`,children:(0,K.jsx)(ae,{size:14,className:y.key===`filename`&&y.direction===`desc`?`rotate-180 transition-transform`:`transition-transform`})}),(0,K.jsx)(`button`,{onClick:()=>R(`artist`),className:`p-1 rounded transition-colors ${y.key===`artist`?`bg-zinc-700 text-white`:`hover:bg-zinc-700 text-zinc-400 hover:text-white`}`,title:`Sort by Artist ${y.key===`artist`?y.direction===`asc`?`(A-Z)`:`(Z-A)`:``}`,children:(0,K.jsx)(Ue,{size:14,className:y.key===`artist`&&y.direction===`desc`?`rotate-180 transition-transform`:`transition-transform`})}),(0,K.jsx)(`button`,{onClick:()=>R(`title`),className:`p-1 rounded transition-colors ${y.key===`title`?`bg-zinc-700 text-white`:`hover:bg-zinc-700 text-zinc-400 hover:text-white`}`,title:`Sort by Title ${y.key===`title`?y.direction===`asc`?`(A-Z)`:`(Z-A)`:``}`,children:(0,K.jsx)(ge,{size:14,className:y.key===`title`&&y.direction===`desc`?`rotate-180 transition-transform`:`transition-transform`})}),(0,K.jsx)(`button`,{onClick:()=>R(`album`),className:`p-1 rounded transition-colors ${y.key===`album`?`bg-zinc-700 text-white`:`hover:bg-zinc-700 text-zinc-400 hover:text-white`}`,title:`Sort by Album ${y.key===`album`?y.direction===`asc`?`(A-Z)`:`(Z-A)`:``}`,children:(0,K.jsx)(ne,{size:14,className:y.key===`album`&&y.direction===`desc`?`rotate-180 transition-transform`:`transition-transform`})}),(0,K.jsx)(`button`,{onClick:()=>R(`random`),className:`p-1 rounded transition-colors ${y.key===`random`?`bg-zinc-700 text-white`:`hover:bg-zinc-700 text-zinc-400 hover:text-white`}`,title:`Shuffle`,children:(0,K.jsx)(ke,{size:14})})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 shrink-0 items-center`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-zinc-800/50 rounded px-1`,children:[(0,K.jsx)(`button`,{onClick:()=>N(!M),className:`p-1 rounded transition-colors ${M?`text-orange-400`:`text-zinc-500 hover:text-zinc-300`}`,title:`Gemini API Key`,children:(0,K.jsx)(V,{size:14})}),M&&(0,K.jsx)(`input`,{type:E?`password`:`text`,name:`api-key`,"aria-label":`Gemini API Key`,value:E,onChange:e=>D(e.target.value),placeholder:`Paste API Key here`,className:`bg-transparent border-none outline-none text-xs text-zinc-200 w-32 placeholder:text-zinc-600`,autoFocus:!0,autoComplete:`off`,spellCheck:!1})]}),(0,K.jsx)(`div`,{className:`relative group`,children:(0,K.jsxs)(`select`,{value:O,onChange:e=>k(e.target.value),className:`bg-zinc-800 text-[10px] text-zinc-300 border border-zinc-700 rounded px-1 py-1 focus:outline-none focus:border-orange-500 appearance-none cursor-pointer hover:bg-zinc-700`,title:`Select Gemini Model`,name:`gemini-model`,id:`gemini-model`,"aria-label":`Gemini Model`,children:[(0,K.jsx)(`option`,{value:`gemini-2.5-flash`,children:`Gemini 2.5 Flash`}),(0,K.jsx)(`option`,{value:`gemini-3-flash-preview`,children:`Gemini 3.0 Flash Preview`})]})}),(0,K.jsx)(`div`,{className:`relative group`,children:(0,K.jsxs)(`select`,{value:A,onChange:e=>j(e.target.value),className:`bg-zinc-800 text-[10px] text-zinc-300 border border-zinc-700 rounded px-1 py-1 focus:outline-none focus:border-orange-500 appearance-none cursor-pointer hover:bg-zinc-700 w-[60px]`,title:`Transcription Mode (Line or Word Level)`,name:`transcription-mode`,id:`transcription-mode`,"aria-label":`Transcription Mode`,children:[(0,K.jsx)(`option`,{value:`line`,children:`Line`}),(0,K.jsx)(`option`,{value:`word`,children:`Word`})]})}),(0,K.jsx)(`button`,{onClick:ze,className:`p-1 hover:bg-zinc-700 text-zinc-500 hover:text-white rounded transition-colors`,title:`Export Playlist (.m3u8)`,children:(0,K.jsx)(ie,{size:14})}),(0,K.jsx)(`button`,{onClick:async()=>{e.length>0&&await p(`Clear entire playlist?`,`Clear Playlist`)&&(l(),t([]))},className:`p-1 hover:bg-red-900/50 text-zinc-500 hover:text-red-200 rounded transition-colors`,title:`Clear Playlist`,children:(0,K.jsx)(Le,{size:14})}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-zinc-700 mx-1 self-center`}),(0,K.jsx)(`button`,{onClick:f,className:`p-1 hover:bg-zinc-700 text-zinc-400 hover:text-white rounded transition-colors`,title:`Close Playlist`,children:(0,K.jsx)(qe,{size:14})})]})]}),(0,K.jsx)(`div`,{ref:m,tabIndex:0,onMouseEnter:()=>m.current?.focus(),className:`flex-1 overflow-y-auto overflow-x-hidden custom-scrollbar bg-zinc-950 p-1 space-y-1 focus:outline-none`,children:e.length===0?(0,K.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-zinc-500 text-xs`,children:[(0,K.jsx)(pe,{size:32,className:`mb-2 opacity-50`}),(0,K.jsx)(`p`,{children:`Playlist is empty`}),(0,K.jsx)(`p`,{className:`opacity-50`,children:`Add audio files (matches .lrc/.srt/.ttml by name)`})]}):e.map((e,t)=>{let r=t===n,c=t===_,l=e.parsedLyrics||[],u=l.length>0&&l.every(e=>e.time===0&&(e.endTime===void 0||e.endTime===0)),f=r&&!u?l.findIndex((e,t)=>{if(e.endTime!==void 0)return d>=e.time&&d=e.time&&(!n||d_e(e,t),onDragEnd:Se,onDragOver:e=>ve(e,t),onDrop:e=>xe(e,t),onClick:()=>v(t),className:`group relative flex gap-2 p-1.5 rounded-md border transition-all cursor-pointer + ${r?`bg-zinc-800 border-orange-500/50 shadow-lg`:`bg-zinc-900/50 border-zinc-800 hover:bg-zinc-800 hover:border-zinc-700`} + ${c?`ring-2 ring-blue-500/70 ring-offset-1 ring-offset-zinc-950`:``} + ${ue===t?`opacity-50 border-dashed border-zinc-500`:``} + ${fe===t&&he===`before`?`border-t-2 border-t-orange-500`:``} + ${fe===t&&he===`after`?`border-b-2 border-b-orange-500`:``} + `,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center px-1 cursor-grab active:cursor-grabbing text-zinc-600 hover:text-zinc-400 self-stretch`,onMouseDown:e=>e.stopPropagation(),children:(0,K.jsx)(le,{size:12})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0 w-48`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r?o():i(t)},className:`p-1.5 rounded-full transition-colors flex-shrink-0 + ${r?`bg-orange-500 text-white`:`bg-zinc-800 text-zinc-400 hover:bg-zinc-700 hover:text-white`} + `,children:r&&a?(0,K.jsx)(ye,{size:14}):(0,K.jsx)(W,{size:14})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium truncate ${r?`text-orange-100`:`text-zinc-300`}`,title:e.audioFile.name,children:e.metadata.title}),(0,K.jsx)(`div`,{className:`text-[9px] text-zinc-500 truncate`,title:e.metadata.artist,children:e.metadata.artist})]})]}),(0,K.jsxs)(`div`,{className:`ml-8 flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-[8px] text-zinc-600`,children:[(e.audioFile.size/1024/1024).toFixed(1),`MB`]}),e.lyricFile?(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 text-[8px] px-1 rounded ${e.lyricFile.name===`embedded.lrc`?`bg-zinc-600/50 text-zinc-300`:`bg-[#202022] text-zinc-200 border border-zinc-700/30`}`,title:e.lyricFile.name===`embedded.lrc`?`Metadata Lyrics`:e.lyricFile.name,children:[(0,K.jsx)(ae,{size:7}),(0,K.jsx)(`span`,{className:`truncate max-w-[80px]`,children:e.lyricFile.name===`embedded.lrc`?`Embedded`:e.lyricFile.name})]}):(0,K.jsx)(`span`,{className:`text-[8px] text-zinc-700 italic`,children:`No Lyrics`})]})]}),(0,K.jsx)(`div`,{className:`lyric-timeline-scroll flex-1 min-w-0 h-12 bg-zinc-950/50 rounded border border-zinc-800/50 overflow-x-auto overflow-y-hidden custom-scrollbar`,children:l.length>0?(0,K.jsx)(`div`,{className:`relative h-full min-w-max flex items-center px-1`,children:l.map((e,r)=>{let a=r===f;return(0,K.jsxs)(`div`,{id:a?`lyric-active-${t}`:void 0,className:`flex items-center gap-1 px-1.5 py-0.5 mx-0.5 rounded text-[9px] transition-colors whitespace-nowrap cursor-pointer + ${a?`bg-orange-600 text-white border border-orange-400 shadow-[0_0_10px_rgba(234,88,12,0.3)]`:`bg-zinc-800/50 hover:bg-blue-900/50 border border-zinc-700/30 hover:border-blue-500/50 text-zinc-400`} + `,title:`${g(e.time)} - ${e.text}`,onClick:r=>{r.stopPropagation(),t===n?s(e.time):(i(t),setTimeout(()=>s(e.time),150))},children:[!u&&(0,K.jsx)(`span`,{className:`font-mono text-[8px] ${a?`text-orange-200`:`text-zinc-500`}`,children:g(e.time)}),(0,K.jsx)(`span`,{className:`truncate max-w-[120px] ${a?`text-white font-medium`:`text-zinc-400`}`,children:e.text||`♪`})]},r)})}):(0,K.jsx)(`div`,{className:`h-full flex items-center justify-center text-zinc-700 text-[9px] italic`,children:`No lyric timeline`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 px-1`,children:[l.length===0&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Ve(e)},className:`p-1.5 rounded bg-zinc-800/50 border border-zinc-700/50 text-zinc-400 hover:bg-zinc-700/50 transition-colors`,title:`Reload Embedded Lyrics`,children:(0,K.jsx)(Te,{size:14})}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),F(e.id),ee.current&&(ee.current.value=``),ee.current?.click()},className:`p-1.5 rounded bg-blue-900/30 border border-blue-500/30 text-blue-400 hover:bg-blue-800/50 transition-colors`,title:`Load Lyrics Manually`,children:(0,K.jsx)(He,{size:14})}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Me(e)},className:`group/btn relative p-1.5 rounded bg-cyan-900/30 border border-cyan-500/30 text-cyan-400 hover:bg-cyan-800/50 transition-colors ${C.has(e.id)?`animate-pulse`:``}`,title:`Search Lyrics (Online)`,disabled:C.has(e.id),children:C.has(e.id)?(0,K.jsx)(me,{size:14,className:`animate-spin`}):(0,K.jsx)(De,{size:14})}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),je(e)},className:`group/btn relative p-1.5 rounded bg-purple-900/30 border border-purple-500/30 text-purple-400 hover:bg-purple-800/50 transition-colors ${x.has(e.id)?`text-red-400 border-red-500/50 hover:bg-red-900/30`:``}`,title:x.has(e.id)?`Stop Transcription`:`AI Sync Transcribe`,children:x.has(e.id)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(me,{size:14,className:`animate-spin group-hover/btn:hidden`}),(0,K.jsx)(Fe,{size:14,className:`hidden group-hover/btn:block fill-current`})]}):(0,K.jsx)(Ne,{size:14})}),l.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 bg-zinc-800/50 rounded p-0.5 border border-zinc-700/50`,children:[(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Re(e,`txt`)},className:`p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold`,title:`Download TXT`,children:`TXT`}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Re(e,`lrc`)},className:`p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold`,title:`Download LRC`,children:`LRC`}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Re(e,`lrc-enhanced`)},className:`p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold`,title:`Download Enhanced LRC (Word Level)`,children:`eLRC`}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Re(e,`srt`)},className:`p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold`,title:`Download SRT`,children:`SRT`}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Re(e,`vtt`)},className:`p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold`,title:`Download VTT`,children:`VTT`}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Re(e,`ttml`)},className:`p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold`,title:`Download TTML`,children:`TTML`}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Re(e,`json`)},className:`p-1 hover:bg-white/10 rounded text-[8px] text-zinc-400 font-bold`,title:`Download JSON`,children:`JSON`}),(0,K.jsx)(`div`,{className:`w-px h-3 bg-zinc-700 mx-0.5`}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),Be(e)},className:`p-1 hover:bg-red-900/50 rounded text-[8px] text-red-500 hover:text-red-300 font-bold`,title:`Clear Lyrics`,children:`CLR`})]})]}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),Oe(t)},className:`p-1 text-zinc-600 hover:text-red-400 hover:bg-red-900/20 rounded self-start`,title:`Remove Track`,children:(0,K.jsx)(Le,{size:12})})]},e.id)})})]})},rp=[{label:`Modern & Clean`,options:[{label:`System Sans Serif`,value:`ui-sans-serif, system-ui, sans-serif`},{label:`Inter`,value:`'Inter', sans-serif`},{label:`Roboto`,value:`'Roboto', sans-serif`},{label:`Poppins`,value:`'Poppins', sans-serif`},{label:`Montserrat`,value:`'Montserrat', sans-serif`},{label:`Open Sans`,value:`'Open Sans', sans-serif`},{label:`Lato`,value:`'Lato', sans-serif`},{label:`Raleway`,value:`'Raleway', sans-serif`},{label:`Outfit`,value:`'Outfit', sans-serif`},{label:`Nunito`,value:`'Nunito', sans-serif`}]},{label:`Classic & Elegant`,options:[{label:`System Serif`,value:`ui-serif, Georgia, serif`},{label:`Playfair Display`,value:`'Playfair Display', serif`},{label:`Merriweather`,value:`'Merriweather', serif`},{label:`Lora`,value:`'Lora', serif`},{label:`Crimson Text`,value:`'Crimson Text', serif`},{label:`EB Garamond`,value:`'EB Garamond', serif`},{label:`Libre Baskerville`,value:`'Libre Baskerville', serif`}]},{label:`Display & Bold`,options:[{label:`Bebas Neue`,value:`'Bebas Neue', sans-serif`},{label:`Anton`,value:`'Anton', sans-serif`},{label:`Oswald`,value:`'Oswald', sans-serif`},{label:`Archivo Black`,value:`'Archivo Black', sans-serif`},{label:`Staatliches`,value:`'Staatliches', cursive`},{label:`Righteous`,value:`'Righteous', cursive`},{label:`Bungee`,value:`'Bungee', cursive`}]},{label:`Handwritten & Script`,options:[{label:`Dancing Script`,value:`'Dancing Script', cursive`},{label:`Pacifico`,value:`'Pacifico', cursive`},{label:`Great Vibes`,value:`'Great Vibes', cursive`},{label:`Satisfy`,value:`'Satisfy', cursive`},{label:`Shadows Into Light`,value:`'Shadows Into Light', cursive`},{label:`Caveat`,value:`'Caveat', cursive`},{label:`Indie Flower`,value:`'Indie Flower', cursive`},{label:`Kalam`,value:`'Kalam', cursive`},{label:`Sacramento`,value:`'Sacramento', cursive`}]},{label:`Fun & Playful`,options:[{label:`Fredoka One`,value:`'Fredoka One', cursive`},{label:`Bangers`,value:`'Bangers', cursive`},{label:`Luckiest Guy`,value:`'Luckiest Guy', cursive`},{label:`Chewy`,value:`'Chewy', cursive`},{label:`Bubblegum Sans`,value:`'Bubblegum Sans', cursive`},{label:`Cherry Cream Soda`,value:`'Cherry Cream Soda', cursive`},{label:`Patrick Hand`,value:`'Patrick Hand', cursive`}]},{label:`Tech & Futuristic`,options:[{label:`System Monospace`,value:`ui-monospace, monospace`},{label:`Orbitron`,value:`'Orbitron', sans-serif`},{label:`Audiowide`,value:`'Audiowide', cursive`},{label:`Share Tech Mono`,value:`'Share Tech Mono', monospace`},{label:`VT323`,value:`'VT323', monospace`},{label:`Press Start 2P`,value:`'Press Start 2P', cursive`},{label:`Fira Code`,value:`'Fira Code', monospace`},{label:`JetBrains Mono`,value:`'JetBrains Mono', monospace`}]},{label:`Decorative & Themed`,options:[{label:`Metal Mania`,value:`'Metal Mania', cursive`},{label:`UnifrakturMaguntia`,value:`'UnifrakturMaguntia', cursive`},{label:`Cinzel`,value:`'Cinzel', serif`},{label:`Creepster`,value:`'Creepster', cursive`},{label:`Pirata One`,value:`'Pirata One', cursive`},{label:`Rubik Moonrocks`,value:`'Rubik Moonrocks', cursive`},{label:`Nabla`,value:`'Nabla', cursive`}]},{label:`International & Multilingual`,options:[{label:`Noto Sans SC (Chinese)`,value:`'Noto Sans SC', sans-serif`},{label:`Noto Sans JP (Japanese)`,value:`'Noto Sans JP', sans-serif`},{label:`Noto Sans KR (Korean)`,value:`'Noto Sans KR', sans-serif`},{label:`Noto Sans Arabic (Arabic)`,value:`'Noto Sans Arabic', sans-serif`},{label:`Noto Sans Devanagari (Hindi)`,value:`'Noto Sans Devanagari', sans-serif`}]}],ip=`Metal Mania.Bebas Neue.Anton.Staatliches.Righteous.Bungee.Dancing Script.Pacifico.Great Vibes.Satisfy.Shadows Into Light.Caveat.Indie Flower.Kalam.Sacramento.Fredoka One.Bangers.Luckiest Guy.Chewy.Bubblegum Sans.Cherry Cream Soda.Patrick Hand.Orbitron.Audiowide.Share Tech Mono.VT323.Press Start 2P.Fira Code.JetBrains Mono.UnifrakturMaguntia.Creepster.Pirata One.Rubik Moonrocks.Nabla`.split(`.`),ap=()=>{if(!document.getElementById(`google-fonts-preconnect`)){let e=document.createElement(`link`);e.id=`google-fonts-preconnect`,e.rel=`preconnect`,e.href=`https://fonts.googleapis.com`,e.crossOrigin=`anonymous`,document.head.appendChild(e);let t=document.createElement(`link`);t.rel=`preconnect`,t.href=`https://fonts.gstatic.com`,t.crossOrigin=`anonymous`,document.head.appendChild(t)}rp.forEach((e,t)=>{let n=new Set;if(e.options.forEach(e=>{let t=e.value.split(`,`)[0].trim().replace(/['"]/g,``);!t.startsWith(`ui-`)&&t!==`system-ui`&&t!==`sans-serif`&&t!==`serif`&&t!==`monospace`&&n.add(t)}),n.size===0)return;let r=`https://fonts.googleapis.com/css2?${Array.from(n).map(e=>{let t=e.replace(/['"]/g,``);return ip.includes(t)?`family=${e.replace(/ /g,`+`)}`:`family=${e.replace(/ /g,`+`)}:wght@400;700`}).join(`&`)}&display=swap`,i=`google-fonts-group-${t}`;if(document.getElementById(i))return;let a=document.createElement(`link`);a.id=i,a.rel=`stylesheet`,a.crossOrigin=`anonymous`,a.href=r,document.head.appendChild(a)})},op=e=>{let t=`google-font-${e.replace(/\s+/g,`-`).toLowerCase()}`;if(document.getElementById(t))return;let n=e.replace(/['"]/g,``),r=`family=${e.replace(/\s+/g,`+`)}:wght@400;700`;ip.includes(n)&&(r=`family=${e.replace(/\s+/g,`+`)}`);let i=document.createElement(`link`);i.id=t,i.rel=`stylesheet`,i.crossOrigin=`anonymous`,i.href=`https://fonts.googleapis.com/css2?${r}&display=swap`,document.head.appendChild(i)},sp=[{label:`Basic`,options:[{label:`Default`,value:`default`},{label:`Custom`,value:`custom`}]},{label:`Typography`,options:[{label:`Large Text`,value:`large`},{label:`Large Uppercase`,value:`large_upper`},{label:`Big Center`,value:`big_center`},{label:`Classic Serif`,value:`classic`},{label:`Monospace`,value:`monospace`}]},{label:`Thematic`,options:[{label:`Heavy Metal`,value:`metal`},{label:`Kids Fun`,value:`kids`},{label:`Melancholy`,value:`sad`},{label:`Romantic`,value:`romantic`},{label:`Tech / Sci-Fi`,value:`tech`},{label:`Gothic`,value:`gothic`}]},{label:`Layout & Minimal`,options:[{label:`Slideshow (Small)`,value:`slideshow`},{label:`Subtitle Mode`,value:`subtitle`},{label:`Video Only`,value:`just_video`}]},{label:`Debug`,options:[{label:`Testing`,value:`testing`},{label:`Testing Up`,value:`testing_up`}]}],cp={default:{fontSizeScale:1,fontFamily:`ui-sans-serif, system-ui, sans-serif`,textCase:`none`,textAlign:`center`,fontColor:`#ffffff`},large:{fontSizeScale:1.8,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fontColor:`#ffffff`,fontWeight:`bold`},classic:{fontSizeScale:1,fontFamily:`ui-serif, Georgia, Cambria, "Times New Roman", Times, serif`,fontColor:`#fef3c7`,fontStyle:`italic`,fontWeight:`bold`},large_upper:{fontSizeScale:1.6,fontFamily:`ui-sans-serif, system-ui, sans-serif`,textCase:`upper`,fontColor:`#ffffff`,fontWeight:`bold`},monospace:{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,fontColor:`#ffffff`,fontWeight:`bold`},big_center:{fontSizeScale:1.6,fontFamily:`ui-sans-serif, system-ui, sans-serif`,textCase:`upper`,textAlign:`center`,contentPosition:`center`,fontColor:`#ffffff`,fontWeight:`bold`},metal:{fontFamily:`"Metal Mania", cursive`,fontSizeScale:1.6,textCase:`upper`,fontColor:`#ffffff`},kids:{fontFamily:`"Fredoka One", cursive`,fontSizeScale:1.6,textCase:`upper`,fontColor:`#ffffff`},sad:{fontFamily:`"Shadows Into Light", cursive`,fontSizeScale:1.2,fontColor:`#e4e4e7`},romantic:{fontFamily:`"Dancing Script", cursive`,fontSizeScale:1.2,fontColor:`#fce7f3`,fontStyle:`italic`},tech:{fontFamily:`"Orbitron", sans-serif`,fontSizeScale:1.6,textCase:`upper`,fontColor:`#ecfeff`,fontWeight:`bold`},gothic:{fontFamily:`"UnifrakturMaguntia", cursive`,fontSizeScale:1.2,fontColor:`#d4d4d8`},slideshow:{fontSizeScale:.6,fontColor:`#ffffff`},just_video:{},subtitle:{fontSizeScale:.6,contentPosition:`bottom`,fontColor:`#ffffff`},testing:{fontSizeScale:1.6},testing_up:{fontSizeScale:1.6,textCase:`upper`}},lp=sp.flatMap(e=>e.options.map(e=>e.value)),up=({onApply:e,placeholder:t=`Google Font Name`})=>{let{toast:n}=Ot(),[r,i]=(0,w.useState)(``),a=()=>{if(!r.trim())return;let t=r.trim().replace(/['"]/g,``).replace(/\s+/g,` `);op(t),e(t),n.success(`Loaded & Applied: ${t}`),i(``)};return(0,K.jsxs)(`div`,{className:`flex gap-2 mt-2 items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase whitespace-nowrap`,children:`Google Font:`}),(0,K.jsx)(`input`,{type:`text`,name:`google-font-name`,"aria-label":`Google Font Name`,value:r,onChange:e=>i(e.target.value),placeholder:t,className:`flex-1 min-w-0 bg-zinc-900 border border-white/10 rounded-md px-2 py-1 text-[10px] text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500`,onKeyDown:e=>{e.key===`Enter`&&a()}}),(0,K.jsx)(`button`,{onClick:a,disabled:!r.trim(),className:`bg-zinc-700 hover:bg-zinc-600 text-white text-[10px] px-2 py-1 rounded-md font-medium disabled:opacity-50 transition-colors`,title:`Load and apply`,children:`Load`})]})},dp={backgroundSource:`custom`,backgroundColor:`#581c87`,backgroundGradient:`linear-gradient(to bottom right, #312e81, #581c87, #000000)`,renderMode:`current`,textAlign:`center`,contentPosition:`center`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fontSizeScale:1,lyricLineHeight:1.3,fontColor:`#ffffff`,textEffect:`preset`,textAnimation:`none`,transitionEffect:`none`,lyricDisplayMode:`all`,lyricVisibilityMode:`default`,fontWeight:`bold`,fontStyle:`normal`,lyricStyleTarget:`active-only`,textDecoration:`none`,showTitle:!0,showArtist:!0,showCover:!0,showIntro:!0,showLyrics:!0,infoPosition:`top-left`,infoStyle:`classic`,infoMarginScale:1,infoSizeScale:1,infoFontFamily:`ui-sans-serif, system-ui, sans-serif`,infoFontWeight:`bold`,infoFontStyle:`normal`,infoFontColor:`#ffffff`,backgroundBlurStrength:0,introMode:`auto`,introText:``,textCase:`none`,highlightEffect:`karaoke`,highlightColor:`#fb923c`,highlightBackground:`#fb923c`,showChannelInfo:!1,channelInfoText:`Music Channel`,channelInfoPosition:`bottom-right`,channelInfoStyle:`classic`,channelInfoSizeScale:1,channelInfoMarginScale:1,channelInfoFontFamily:`ui-sans-serif, system-ui, sans-serif`,channelInfoFontWeight:`bold`,channelInfoFontStyle:`normal`,channelInfoFontColor:`#ffffff`,channelInfoImage:void 0,useCustomHighlightColors:!1,backgroundImage:void 0,visualTransitionType:`none`,visualTransitionDuration:1,enableGradientOverlay:!1,useRealColorMedia:!1,marginTopScale:1,marginBottomScale:1,showVisualization:!1,visualizationType:`bars`,visualizationColorMode:`gradient`,visualizationColor1:`#a855f7`,visualizationColor2:`#6366f1`,visualizationOpacity:.6,visualizationPosition:`bottom`,visualizationSensitivity:1.5,visualizationBarCount:48,showFloatingNotes:!1,floatingNotesLayout:`text-only`,floatingNotesMedia:void 0,floatingNotesMediaType:`image`,floatingNotesText:`Floating Notes`,floatingNotesPosition:`bottom-left`,floatingNotesShape:`rounded`,floatingNotesFillColor:`#000000`,floatingNotesOutlineColor:`#ffffff`,floatingNotesOutlineSize:1,floatingNotesOpacity:.8,floatingNotesMarginScale:1,floatingNotesWidth:300,floatingNotesHeight:150,floatingNotesMediaSizeScale:.4,floatingNotesFontSizeScale:1,floatingNotesFontFamily:`ui-sans-serif, system-ui, sans-serif`,floatingNotesFontStyle:`normal`,floatingNotesFontWeight:`normal`,floatingNotesFontColor:`#ffffff`,floatingNotesTextAlign:`left`,floatingNotesVisibilityMode:`all`,floatingNotesFromStartDuration:10,floatingNotesFromEndDuration:10,floatingNotesSpecificStart:`0:00`,floatingNotesSpecificEnd:`0:30`,randomizeBackgroundSource:!0,randomizeBackgroundEffects:!0,randomizeAudioVisualizer:!0,randomizeLyricDisplayMode:!0,randomizeHighlightEffect:!0,randomizeVisibleElements:!0,randomizeIntroSettings:!0,randomizeTypographyStyle:!0,randomizeTextEffect:!0,randomizeTextAnimation:!0,randomizeTransitionEffect:!0,randomizeVisualTransition:!0,randomizeChannelInfo:!0,randomizeFloatingNotes:!0,randomizeSongInfoDesign:!0},fp=[`randomizeBackgroundSource`,`randomizeBackgroundEffects`,`randomizeAudioVisualizer`,`randomizeLyricDisplayMode`,`randomizeHighlightEffect`,`randomizeVisibleElements`,`randomizeIntroSettings`,`randomizeTypographyStyle`,`randomizeTextEffect`,`randomizeTextAnimation`,`randomizeTransitionEffect`,`randomizeVisualTransition`,`randomizeChannelInfo`,`randomizeFloatingNotes`,`randomizeSongInfoDesign`],pp=[`randomizeTypographyStyle`,`randomizeTextEffect`,`randomizeTextAnimation`,`randomizeTransitionEffect`,`randomizeVisualTransition`],mp=[`randomizeBackgroundSource`,`randomizeBackgroundEffects`,`randomizeAudioVisualizer`,`randomizeHighlightEffect`,`randomizeVisibleElements`,`randomizeTextEffect`,`randomizeTextAnimation`,`randomizeTransitionEffect`,`randomizeVisualTransition`],hp=[`randomizePreset`,`randomizeRenderScope`,`randomizeLyricVisibility`,`randomizeOutputSettings`];function gp(e,t){return Object.fromEntries(e.map(e=>[e,t]))}function _p(e){let t=new Set(e);return Object.fromEntries(fp.map(e=>[e,t.has(e)]))}var vp=[{label:`Basic`,options:[{label:`Use Preset Default`,value:`preset`},{label:`None`,value:`none`},{label:`Drop Shadow`,value:`shadow`},{label:`Outline`,value:`outline`}]},{label:`Glow Effects`,options:[{label:`Soft Glow`,value:`glow`},{label:`Neon Glow`,value:`neon`},{label:`Multi-Color Neon`,value:`neon-multi`}]},{label:`3D & Pop`,options:[{label:`3D Pop`,value:`3d`},{label:`Embossed`,value:`emboss`},{label:`Chrome Metallic`,value:`chrome`},{label:`Gold Foil`,value:`gold`}]},{label:`Artistic`,options:[{label:`Glassmorphism`,value:`glass`},{label:`Gradient Fill`,value:`gradient`},{label:`Fire`,value:`fire`},{label:`Frozen Ice`,value:`frozen`},{label:`Rainbow`,value:`rainbow`},{label:`Reflection`,value:`mirror`}]},{label:`Retro & Stylized`,options:[{label:`VHS Glitch`,value:`vhs`},{label:`Retro 80s`,value:`retro`},{label:`Cyberpunk`,value:`cyberpunk`},{label:`Hologram`,value:`hologram`},{label:`Comic Book`,value:`comic`},{label:`Digital Glitch`,value:`glitch-text`}]}],yp=[{label:`Static`,options:[{label:`None (Static)`,value:`none`}]},{label:`Subtle`,options:[{label:`Pulse`,value:`pulse`},{label:`Breathe`,value:`breathe`},{label:`Float`,value:`float`},{label:`Sway`,value:`sway`},{label:`Flicker`,value:`flicker`}]},{label:`Energetic`,options:[{label:`Bounce`,value:`bounce`},{label:`Shake`,value:`shake`},{label:`Wave`,value:`wave`},{label:`Wobble`,value:`wobble`},{label:`Jello`,value:`jello`},{label:`Rubber Band`,value:`rubberband`}]},{label:`Attention`,options:[{label:`Heartbeat`,value:`heartbeat`},{label:`Flash`,value:`flash`},{label:`Tada!`,value:`tada`},{label:`Swing`,value:`swing`}]},{label:`Rotation`,options:[{label:`Gentle Rotate`,value:`rotate`},{label:`Spin`,value:`spin`}]},{label:`Special`,options:[{label:`Glitch`,value:`glitch`},{label:`Typewriter`,value:`typewriter`}]}],bp=[{label:`Basic`,options:[{label:`Instant`,value:`none`},{label:`Smooth Fade`,value:`fade`}]},{label:`Slide & Move`,options:[{label:`Slide In`,value:`slide`},{label:`Float Up`,value:`float`},{label:`Drop In`,value:`drop`},{label:`Lightspeed`,value:`lightspeed`},{label:`Roll In`,value:`roll`}]},{label:`Scale & Transform`,options:[{label:`Zoom In`,value:`zoom`},{label:`Bounce In`,value:`bounce`},{label:`Elastic Pop`,value:`elastic`},{label:`Scale + Rotate`,value:`scale-rotate`}]},{label:`Rotation`,options:[{label:`Flip In`,value:`flip`},{label:`Rotate In`,value:`rotate-in`},{label:`Spiral In`,value:`spiral`},{label:`Swing In`,value:`swing`}]},{label:`Special`,options:[{label:`Motion Blur`,value:`blur`},{label:`Shatter In`,value:`shatter`},{label:`Typewriter`,value:`typewriter`}]}],xp=[{label:`Visual Transition`,options:[{label:`None (Cut)`,value:`none`},{label:`Crossfade`,value:`crossfade`},{label:`Fade Through Black`,value:`fade-to-black`}]}],Sp=[{label:`Basic`,options:[{label:`None`,value:`none`},{label:`Simple Color`,value:`color`},{label:`Scale Up`,value:`scale`},{label:`Intense Glow`,value:`glow`},{label:`Background Box`,value:`background`}]},{label:`Karaoke Standard`,options:[{label:`Default (Line/Fill)`,value:`karaoke`},{label:`Smooth Transition`,value:`karaoke-smooth`},{label:`Smooth Transition White`,value:`karaoke-smooth-white`},{label:`Smooth Transition Plus`,value:`karaoke-smooth-plus`},{label:`Fill Background`,value:`karaoke-fill`},{label:`Outline Only`,value:`karaoke-outline`},{label:`Underline`,value:`karaoke-underline`},{label:`Shadow`,value:`karaoke-shadow`},{label:`Gradient`,value:`karaoke-gradient`}]},{label:`Animations`,options:[{label:`Bounce`,value:`karaoke-bounce`},{label:`Wave`,value:`karaoke-wave`},{label:`Zoom In`,value:`karaoke-scale`}]},{label:`Neon & Glow`,options:[{label:`Neon White`,value:`karaoke-neon`},{label:`Glow Blue`,value:`karaoke-glow-blue`},{label:`Glow Pink`,value:`karaoke-glow-pink`},{label:`Multi-Color Neon`,value:`karaoke-neon-multi`},{label:`Soft Glow`,value:`karaoke-soft-glow`}]},{label:`3D & Artistic`,options:[{label:`3D Pop`,value:`karaoke-3d`},{label:`Embossed`,value:`karaoke-emboss`},{label:`Chrome Metallic`,value:`karaoke-chrome`},{label:`Gold Foil`,value:`karaoke-gold`},{label:`Glassmorphism`,value:`karaoke-glass`},{label:`Gradient Fill`,value:`karaoke-gradient-fill`},{label:`Fire`,value:`karaoke-fire`},{label:`Frozen Ice`,value:`karaoke-frozen`},{label:`Rainbow`,value:`karaoke-rainbow`},{label:`Reflection`,value:`karaoke-mirror`}]},{label:`Retro & Stylized`,options:[{label:`VHS Glitch`,value:`karaoke-vhs`},{label:`Retro 80s`,value:`karaoke-retro`},{label:`Cyberpunk`,value:`karaoke-cyberpunk`},{label:`Hologram`,value:`karaoke-hologram`},{label:`Comic Book`,value:`karaoke-comic`},{label:`Digital Glitch`,value:`karaoke-glitch-text`}]},{label:`Detailed Animations`,options:[{label:`Pulse`,value:`karaoke-pulse`},{label:`Breathe`,value:`karaoke-breathe`},{label:`Float`,value:`karaoke-float`},{label:`Sway`,value:`karaoke-sway`},{label:`Flicker`,value:`karaoke-flicker`},{label:`Shake`,value:`karaoke-shake`},{label:`Wobble`,value:`karaoke-wobble`},{label:`Jello`,value:`karaoke-jello`},{label:`Rubber Band`,value:`karaoke-rubberband`},{label:`Heartbeat`,value:`karaoke-heartbeat`},{label:`Flash`,value:`karaoke-flash`},{label:`Tada!`,value:`karaoke-tada`},{label:`Swing`,value:`karaoke-swing`},{label:`Gentle Rotate`,value:`karaoke-rotate`},{label:`Spin`,value:`karaoke-spin`},{label:`Glitch Anim`,value:`karaoke-glitch`},{label:`Typewriter`,value:`karaoke-typewriter`}]},{label:`Motion & Transitions`,options:[{label:`Smooth Fade`,value:`karaoke-fade`},{label:`Slide In`,value:`karaoke-slide`},{label:`Drop In`,value:`karaoke-drop`},{label:`Lightspeed`,value:`karaoke-lightspeed`},{label:`Roll In`,value:`karaoke-roll`},{label:`Zoom In`,value:`karaoke-zoom`},{label:`Elastic Pop`,value:`karaoke-elastic`},{label:`Scale + Rotate`,value:`karaoke-scale-rotate`},{label:`Flip In`,value:`karaoke-flip`},{label:`Rotate In`,value:`karaoke-rotate-in`},{label:`Spiral In`,value:`karaoke-spiral`},{label:`Motion Blur`,value:`karaoke-blur`},{label:`Shatter`,value:`karaoke-shatter`}]},{label:`Solid Colors`,options:[{label:`Blue`,value:`karaoke-blue`},{label:`Purple`,value:`karaoke-purple`},{label:`Green`,value:`karaoke-green`},{label:`Pink`,value:`karaoke-pink`},{label:`Cyan`,value:`karaoke-cyan`}]},{label:`Shapes`,options:[{label:`Pill Shape`,value:`karaoke-pill`},{label:`Square Box`,value:`karaoke-box`},{label:`Rounded Box`,value:`karaoke-rounded`}]}],Cp=e=>{let t=``,n=``;return e.includes(`blue`)||e.includes(`cyan`)?(t=e.includes(`cyan`)?`#06b6d4`:`#3b82f6`,n=t):e.includes(`purple`)?(t=`#a855f7`,n=t):e.includes(`green`)?(t=`#22c55e`,n=t):e.includes(`pink`)?(t=`#ec4899`,n=t):(e===`karaoke-pill`||e===`karaoke-box`||e===`karaoke-rounded`)&&(t=`#fb923c`,n=`#fb923c`),t?{color:t,bg:n}:null},wp=[{label:`Source`,options:[{label:`From Timeline`,value:`timeline`},{label:`Metadata / Default`,value:`custom`},{label:`Smart Gradient`,value:`smart-gradient`},{label:`Gradient (Manual)`,value:`gradient`},{label:`Solid Color`,value:`color`},{label:`Custom Image`,value:`image`},{label:`Custom Video (Loops)`,value:`video`},{label:`Three.js 3D Background`,value:`threejs`}]}],Tp=[{label:`Classic`,options:[{label:`✦ Stars`,value:`stars`},{label:`◇ Rotating Cubes`,value:`cubes`},{label:`≈ Wireframe Waves`,value:`waves`},{label:`● Particle Flow`,value:`particles`}]},{label:`Cosmic`,options:[{label:`🌀 Spiral Galaxy`,value:`galaxy`},{label:`☁ Cosmic Nebula`,value:`nebula`},{label:`🌌 Aurora Borealis`,value:`aurora`},{label:`🚀 Warp Speed`,value:`warp`},{label:`🌪 Particle Vortex`,value:`vortex`}]},{label:`Sci-Fi`,options:[{label:`🧬 DNA Helix`,value:`dna`},{label:`▓ Matrix Rain`,value:`matrix`},{label:`◎ Saturn Rings`,value:`rings`},{label:`🚇 Infinity Tunnel`,value:`tunnel`},{label:`🌐 Cyber Grid`,value:`cybergrid`},{label:`💎 Geometric Crystals`,value:`crystals`}]}],Ep=[{label:`Display Modes`,options:[{label:`Show All (Default)`,value:`all`},{label:`Prev & Next (Centered)`,value:`previous-next`},{label:`Current & Next`,value:`next-only`},{label:`Current Line Only`,value:`active-only`}]},{label:`Unsynchronized / Static`,options:[{label:`Static Full Text`,value:`static-all`},{label:`Compact ( / line, // verse )`,value:`static-compact`},{label:`Compact ( , line, . verse + newline )`,value:`static-compact-comma`},{label:`Compact ( no symbol, . verse + newline )`,value:`static-compact-clean`}]}],Dp=[`none`,`upper`,`lower`,`title`,`sentence`,`invert`],Op=[{label:`Layout Styles`,options:[{label:`Classic (Detailed)`,value:`classic`},{label:`Modern + Cover`,value:`modern_art`},{label:`Circle Cover`,value:`circle_art`},{label:`Modern (Text Only)`,value:`modern`},{label:`Boxed Cover`,value:`box`},{label:`Minimal (Text Only)`,value:`minimal`}]}],kp=[{label:`Layout Styles`,options:[{label:`Classic (Row)`,value:`classic`},{label:`Modern (Col)`,value:`modern`},{label:`Minimal (Text Only)`,value:`minimal`},{label:`Circle (Avatar)`,value:`circle`},{label:`Logo Only`,value:`logo`},{label:`Boxed`,value:`box`}]}],Ap=[{label:`Content Layout`,options:[{label:`Text Only`,value:`text-only`},{label:`Media Only`,value:`media-only`},{label:`Media (Left) + Text`,value:`media-left-text`},{label:`Media (Right) + Text`,value:`media-right-text`},{label:`Media (Top) + Text`,value:`media-top-text`},{label:`Media (Bottom) + Text`,value:`media-bottom-text`}]}],jp=[{label:`When To Show`,options:[{label:`All Duration`,value:`all`},{label:`Follow Lyrics Settings`,value:`follow-lyrics`},{label:`Duration From Start of Audio`,value:`from-start`},{label:`Duration Before End of Audio`,value:`from-end`},{label:`From Start + Before End of Audio`,value:`from-start-and-end`},{label:`Specific Time Range`,value:`specific`}]}],Mp=[{label:`Background Shape`,options:[{label:`None (Transparent)`,value:`none`},{label:`Sharp Corner`,value:`sharp`},{label:`Rounded Corner`,value:`rounded`}]}],Np=[{label:`Frame Rate`,options:[{label:`24 FPS (Cinematic)`,value:`24`},{label:`30 FPS (Standard)`,value:`30`},{label:`60 FPS (Smooth)`,value:`60`}]}],Pp=({value:e,onChange:t,groups:n})=>{let[r,i]=(0,w.useState)(!1),[a,o]=(0,w.useState)(e);(0,w.useEffect)(()=>{r||o(e)},[e,r]);let s=e=>{for(let t of n){let n=t.options.find(t=>t.value===e);if(n)return n.label}return e},c=e=>{t(e)},l=()=>{r&&t(a),i(!1)},u=e=>{t(e),o(e),i(!1)};return(0,K.jsxs)(`div`,{className:`space-y-2 relative`,onMouseLeave:l,children:[(0,K.jsxs)(`button`,{onClick:()=>i(!r),className:`w-full bg-zinc-800 border border-white/10 rounded-lg px-3 py-2 text-sm text-zinc-200 flex items-center justify-between focus:outline-none focus:ring-1 focus:ring-purple-500 hover:bg-zinc-700/50 transition-colors`,title:r?`Close List`:`Expand List`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:s(e)}),(0,K.jsx)(P,{size:14,className:`transition-transform duration-200 ${r?`rotate-180`:``}`})]}),r&&(0,K.jsx)(`div`,{className:`bg-zinc-900/50 border border-white/10 rounded-lg overflow-hidden transition-all animate-in fade-in slide-in-from-top-2 z-10`,children:n.map(t=>(0,K.jsxs)(`div`,{className:`px-2 py-1.5 border-b border-white/5 last:border-0`,children:[(0,K.jsx)(`div`,{className:`text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2`,children:t.label}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-0.5`,children:t.options.map(t=>(0,K.jsx)(`button`,{onMouseEnter:()=>c(t.value),onClick:()=>u(t.value),className:`w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors ${e===t.value?`bg-purple-600/50 text-white`:`text-zinc-300 hover:bg-white/10`}`,children:t.label},t.value))})]},t.label))})]})},Fp=(e,t,n)=>{if(e===`CustomFont`&&n)return n;for(let n of t){let t=n.options.find(t=>t.value===e);if(t)return t.label}return`Select Font`},Ip=({value:e,onChange:t,customFontName:n,groups:r=rp})=>{let[i,a]=(0,w.useState)(!1),[o,s]=(0,w.useState)(e);(0,w.useEffect)(()=>{i||s(e)},[e,i]);let c=e=>{t(e)},l=()=>{i&&t(o)},u=e=>{t(e),s(e),a(!1)};return(0,K.jsxs)(`div`,{className:`space-y-2`,onMouseLeave:l,children:[(0,K.jsxs)(`button`,{onClick:()=>a(!i),className:`w-full bg-zinc-800 border border-white/10 rounded-lg px-3 py-2 text-sm text-zinc-200 flex items-center justify-between focus:outline-none focus:ring-1 focus:ring-purple-500 hover:bg-zinc-700/50 transition-colors`,title:i?`Close Font List`:`Expand Font List`,children:[(0,K.jsx)(`span`,{className:`truncate`,style:{fontFamily:e},children:Fp(e,r,n)}),(0,K.jsx)(P,{size:14,className:`transition-transform duration-200 ${i?`rotate-180`:``}`})]}),i&&(0,K.jsxs)(`div`,{className:`bg-zinc-900/50 border border-white/10 rounded-lg overflow-hidden transition-all animate-in fade-in slide-in-from-top-2`,children:[n&&(0,K.jsxs)(`div`,{className:`px-2 py-1.5 border-b border-white/5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2`,children:`Custom`}),(0,K.jsx)(`button`,{onMouseEnter:()=>c(`CustomFont`),onClick:()=>u(`CustomFont`),className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${e===`CustomFont`?`bg-purple-600 text-white`:`text-zinc-300 hover:bg-white/10`}`,children:(0,K.jsxs)(`span`,{style:{fontFamily:`CustomFont`},children:[`✨ `,n]})})]}),r.map(t=>(0,K.jsxs)(`div`,{className:`px-2 py-1.5 border-b border-white/5 last:border-0`,children:[(0,K.jsx)(`div`,{className:`text-[10px] text-zinc-500 font-bold uppercase mb-1 px-2`,children:t.label}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 gap-0.5`,children:t.options.map(t=>(0,K.jsx)(`button`,{onMouseEnter:()=>c(t.value),onClick:()=>u(t.value),className:`w-full text-left px-3 py-1.5 rounded-md text-sm transition-colors ${e===t.value?`bg-purple-600/50 text-white`:`text-zinc-300 hover:bg-white/10`}`,title:t.label,children:(0,K.jsx)(`span`,{style:{fontFamily:t.value},children:t.label})},t.value))})]},t.label))]})]})},Lp=[{label:`Visual Presets`,options:Object.values(cp).filter(e=>e.fontFamily).reduce((e,t)=>{if(!e.find(e=>e.value===t.fontFamily)){let n=t.fontFamily.split(`,`)[0].replace(/['"]/g,``);n.includes(`ui-serif`)?n=`Classic Serif`:n.includes(`ui-monospace`)?n=`Monospace`:n===`sans-serif`&&(n=`Default Sans`),e.push({label:`${n} (Preset)`,value:t.fontFamily})}return e},[])},...rp],Rp=({config:e,setConfig:t,preset:n,setPreset:r,onClose:i,isPlaylistMode:a,hasPlaylist:o,onRender:s,customFontName:c,onFontUpload:l,onClearCustomFont:u,resolution:d,setResolution:f,aspectRatio:p,setAspectRatio:m,renderCodec:h,setRenderCodec:g,supportedCodecs:_,renderQuality:v,setRenderQuality:y,renderFps:b,setRenderFps:x,renderEngine:S,setRenderEngine:C,ffmpegCodec:T,setFfmpegCodec:E,customChannelFontName:D,onChannelFontUpload:O,onClearChannelCustomFont:P,customInfoFontName:F,onInfoFontUpload:I,onClearInfoCustomFont:te})=>{let{toast:L,confirm:ne}=Ot(),[z,B]=(0,w.useState)([]),re=(e,t)=>{z.includes(e)||B(t=>[e,...t]),W(t,e.includes(` `)?`'${e}'`:e)},ie=w.useMemo(()=>{let t=[],n=e.fontFamily?e.fontFamily.split(`,`)[0].replace(/['"]/g,``):``;return n&&t.push({label:`Matched`,options:[{label:`Use Lyric Font (${n})`,value:e.fontFamily}]}),z.length>0&&t.push({label:`Loaded Google Fonts`,options:z.map(e=>({label:e,value:e.includes(` `)?`'${e}'`:e}))}),[...t,...Lp]},[z,e.fontFamily]),oe=(0,w.useRef)(null),se=(0,w.useRef)(null),ce=(0,w.useRef)(null),le=(0,w.useRef)(null),de=(0,w.useRef)(null),V=(0,w.useRef)(null),H=(0,w.useRef)(null),pe=(0,w.useRef)(null),me=(0,w.useRef)(null),[U,ye]=(0,w.useState)(null),W=(n,r)=>{let i={...e,[n]:r};if(n===`highlightEffect`){let e=Cp(r);i.useCustomHighlightColors=!1,e?(i.highlightColor=e.color,i.highlightBackground=e.bg):(i.highlightColor=`#fb923c`,i.highlightBackground=`#fb923c`)}else if(n===`useCustomHighlightColors`&&r===!1){let t=e.highlightEffect,n=Cp(t);n?(i.highlightColor=n.color,i.highlightBackground=n.bg):(i.highlightColor=`#fb923c`,i.highlightBackground=`#fb923c`)}t(i)},be=n=>{t({...e,...n})},xe=()=>{be(gp(fp,!0))},Se=()=>{be(gp(fp,!1))},Ce=()=>{be(_p(pp))},we=()=>{be(_p(mp))},Ee=()=>{be(Object.fromEntries(fp.map(t=>[t,e[t]===!1])))},De=n=>{r(n);let i=cp[n];if(i){let n={fontFamily:`sans-serif`,fontSizeScale:1,fontColor:`#ffffff`,fontWeight:`bold`,fontStyle:`normal`,textCase:`none`,textAlign:`center`,contentPosition:`center`,textDecoration:`none`,textEffect:`preset`,textAnimation:`none`,highlightEffect:`karaoke`,highlightColor:`#fb923c`,highlightBackground:`#fb923c`,useCustomHighlightColors:!1,lyricStyleTarget:`active-only`,transitionEffect:`none`};t({...e,...n,...i})}},Ae=e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{e.target?.result&&W(`channelInfoImage`,e.target.result)},e.readAsDataURL(t)}e.target.value=``},je=n=>{let r=n.target.files?.[0];if(r){let n=r.type.startsWith(`video/`),i=r.type.startsWith(`image/`);if(!n&&!i){L.error(`Please upload a valid image or video file.`);return}let a=new FileReader;a.onload=r=>{r.target?.result&&t({...e,floatingNotesMedia:r.target.result,floatingNotesMediaType:n?`video`:`image`})},a.readAsDataURL(r)}n.target.value=``},Pe=e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{e.target?.result&&W(`backgroundImage`,e.target.result)},e.readAsDataURL(t)}e.target.value=``},Fe=e=>{let t=e.target.files?.[0];if(t){if(!t.type.startsWith(`video/`)){L.error(`Please upload a valid video file.`);return}let e=new FileReader;e.onload=e=>{e.target?.result&&W(`backgroundVideo`,e.target.result)},e.readAsDataURL(t)}e.target.value=``},Re=()=>{let n=e=>e[Math.floor(Math.random()*e.length)],i=e=>e.flatMap(e=>e.options.map(e=>e.value)),a=(e,t,n=2)=>Number((e+Math.random()*(t-e)).toFixed(n)),o=()=>`#`+Math.floor(Math.random()*16777215).toString(16).padStart(6,`0`),s=[`to right`,`to left`,`to bottom`,`to top`,`to bottom right`,`to bottom left`,`to top right`,`to top left`],c=()=>`linear-gradient(${n(s)}, ${o()}, ${o()}, ${o()})`,l=i(vp).filter(e=>e!==`preset`),u=i(yp),d=i(bp),f=i(Sp),p=[`custom`,`color`,`gradient`,`smart-gradient`],m=i(Ep).filter(e=>!e.startsWith(`static-`)),h=i(Op),g=i(kp),_=[...Dp],v=[`top-left`,`top-right`,`bottom-left`,`bottom-right`,`top-center`,`bottom-center`,`left-middle`,`center-middle`,`right-middle`],y=[`top`,`center`,`bottom`],b=[`left`,`center`,`right`],x=[`bars`,`wave`,`circular`,`particles`,`pulse-ring`,`waveform`,`spectrogram`,`spectrum`,`stereo-field`],S=[`accent`,`gradient`,`custom`,`rainbow`],C=[`bottom`,`top`,`full`,`center`],w=Lp.flatMap(e=>e.options.map(e=>e.value)),T=n(f),E=Cp(T),D=E?.color??o(),O=E?.bg??o(),k=n(p),A=()=>Math.random()>.5,j={...e};e.randomizeBackgroundSource!==!1&&(j.backgroundSource=k,j.backgroundColor=o(),j.backgroundGradient=c()),e.randomizeBackgroundEffects!==!1&&(j.backgroundBlurStrength=Math.random()>.6?Math.floor(Math.random()*25):0,j.enableGradientOverlay=A()),e.randomizeTypographyStyle!==!1&&(j.fontFamily=n(w),j.fontSizeScale=a(.6,2),j.fontColor=o(),j.fontWeight=n([`normal`,`bold`]),j.fontStyle=n([`normal`,`italic`]),j.textDecoration=n([`none`,`none`,`none`,`underline`,`line-through`]),j.textCase=n(_),j.lyricLineHeight=a(1,2),j.lyricStyleTarget=n([`active-only`,`all`]),j.textAlign=n(b),j.contentPosition=n(y),j.marginTopScale=a(.5,2.5),j.marginBottomScale=a(.5,2.5)),e.randomizeLyricDisplayMode!==!1&&(j.lyricDisplayMode=n(m)),e.randomizeTextEffect!==!1&&(j.textEffect=n(l)),e.randomizeTextAnimation!==!1&&(j.textAnimation=n(u)),e.randomizeTransitionEffect!==!1&&(j.transitionEffect=n(d)),e.randomizeHighlightEffect!==!1&&(j.highlightEffect=T,j.highlightColor=D,j.highlightBackground=O,j.useCustomHighlightColors=!1),e.randomizeVisibleElements!==!1&&(j.showTitle=A(),j.showArtist=A(),j.showCover=A(),j.showIntro=A(),j.showLyrics=!0),e.randomizeIntroSettings!==!1&&(j.introMode=n([`auto`,`manual`])),e.randomizeChannelInfo!==!1&&(j.showChannelInfo=Math.random()>.7,j.channelInfoPosition=n(v),j.channelInfoStyle=n(g),j.channelInfoSizeScale=a(.6,1.6),j.channelInfoMarginScale=a(.5,2),j.channelInfoFontFamily=n(w),j.channelInfoFontWeight=n([`normal`,`bold`]),j.channelInfoFontStyle=n([`normal`,`italic`]),j.channelInfoFontColor=o()),e.randomizeFloatingNotes!==!1&&(j.showFloatingNotes=Math.random()>.7,j.floatingNotesLayout=n([`text-only`,`media-only`,`media-left-text`,`media-right-text`,`media-top-text`,`media-bottom-text`]),j.floatingNotesPosition=n(v),j.floatingNotesShape=n([`none`,`sharp`,`rounded`]),j.floatingNotesFillColor=o(),j.floatingNotesOutlineColor=o(),j.floatingNotesOutlineSize=Math.floor(Math.random()*5),j.floatingNotesOpacity=a(.3,1),j.floatingNotesMarginScale=a(.5,2),j.floatingNotesWidth=Math.floor(150+Math.random()*300),j.floatingNotesHeight=Math.floor(100+Math.random()*200),j.floatingNotesMediaSizeScale=a(.2,.7),j.floatingNotesFontSizeScale=a(.8,1.8),j.floatingNotesFontFamily=n(w),j.floatingNotesFontStyle=n([`normal`,`italic`]),j.floatingNotesFontWeight=n([`normal`,`bold`]),j.floatingNotesFontColor=o(),j.floatingNotesTextAlign=n([`left`,`center`,`right`])),e.randomizeSongInfoDesign!==!1&&(j.infoPosition=n(v),j.infoStyle=n(h),j.infoMarginScale=a(.5,2),j.infoSizeScale=a(.6,1.6),j.infoFontFamily=n(w),j.infoFontWeight=n([`normal`,`bold`]),j.infoFontStyle=n([`normal`,`italic`]),j.infoFontColor=o()),e.randomizeVisualTransition!==!1&&(j.visualTransitionType=n([`none`,`crossfade`,`fade-to-black`]),j.visualTransitionDuration=a(.5,2)),e.randomizeAudioVisualizer!==!1&&(j.showVisualization=Math.random()>.6,j.visualizationType=n(x),j.visualizationColorMode=n(S),j.visualizationColor1=o(),j.visualizationColor2=o(),j.visualizationOpacity=a(.3,1),j.visualizationPosition=n(C),j.visualizationSensitivity=a(.5,3),j.visualizationBarCount=Math.floor(16+Math.random()*112)),j.renderMode=e.renderMode,j.introText=e.introText,j.introMode=e.introMode,t(j),r(`custom`),L.success(`🎲 Random settings generated!`)},Ve=async()=>{await ne(`This will reset ALL settings to factory defaults: + +• Visual preset → Default +• Background, fonts & colors +• Text effects, animations & transitions +• Song info, watermark & visualization +• Output: 1080p, 30fps, WebCodecs + +This cannot be undone.`,`Reset All Settings to Default`)&&(t(dp),r(`default`),f(`1080p`),m(`16:9`),g(`auto`),x(30),y(`med`),C(`webcodecs`),E(`h264`),de.current&&(de.current.value=``),V.current&&(V.current.value=``),H.current&&(H.current.value=``),me.current&&(me.current.value=``),u(),P&&P(),te&&te(),se.current&&(se.current.value=``),ce.current&&(ce.current.value=``),le.current&&(le.current.value=``),ye(null),L.success(`All settings have been reset to default.`))},Ue=()=>{let t=new Date,r=t.toISOString().replace(/[:.]/g,`-`).slice(0,19),i=(e,t=6)=>typeof e==`number`?Number(e.toFixed(t)):e,a=(e,t,n,r)=>{if(e===n&&t)return{slot:r,cssValue:n,realName:t,source:`uploaded-file`,warning:`Re-upload font file "${t}" after importing this config.`};if(e&&z.some(t=>e.includes(t))){let t=e.replace(/['"]/g,``).trim();return{slot:r,cssValue:e,realName:t,source:`google-font`,warning:`Google Font "${t}" – internet connection required on target machine.`}}return{slot:r,cssValue:e??`sans-serif`,realName:e??`sans-serif`,source:`built-in`,warning:``}},o=a(e.fontFamily,c,`CustomFont`,`lyrics`),s=a(e.channelInfoFontFamily,D,`ChannelFont`,`channel-watermark`),l=a(e.infoFontFamily,F,`InfoFont`,`song-info`),u=[o,s,l].filter(e=>e.source!==`built-in`),f={_meta:{exportedAt:t.toISOString(),appVersion:`1.0`,schema:`render-settings-v1`,_fontNotes:u.length>0?u:`all fonts are built-in system fonts`},...e,fontSizeScale:i(e.fontSizeScale),infoSizeScale:i(e.infoSizeScale),infoMarginScale:i(e.infoMarginScale),channelInfoSizeScale:i(e.channelInfoSizeScale),channelInfoMarginScale:i(e.channelInfoMarginScale),marginTopScale:i(e.marginTopScale),marginBottomScale:i(e.marginBottomScale),visualizationOpacity:i(e.visualizationOpacity,4),visualizationSensitivity:i(e.visualizationSensitivity,4),fontFamily:e.fontFamily,...o.source!==`built-in`&&{__note_fontFamily:`Real name: "${o.realName}" [${o.source}]`+(o.source===`uploaded-file`?` – re-upload required after import`:``)},channelInfoFontFamily:e.channelInfoFontFamily,...s.source!==`built-in`&&e.channelInfoFontFamily&&{__note_channelInfoFontFamily:`Real name: "${s.realName}" [${s.source}]`+(s.source===`uploaded-file`?` – re-upload required after import`:``)},infoFontFamily:e.infoFontFamily,...l.source!==`built-in`&&e.infoFontFamily&&{__note_infoFontFamily:`Real name: "${l.realName}" [${l.source}]`+(l.source===`uploaded-file`?` – re-upload required after import`:``)},preset:n,resolution:d,aspectRatio:p,renderCodec:h,renderFps:b,renderQuality:v,renderEngine:S,ffmpegCodec:T,customFontName:c,customChannelFontName:D,customInfoFontName:F,channelInfoFontWeight:e.channelInfoFontWeight,channelInfoFontStyle:e.channelInfoFontStyle,infoFontWeight:e.infoFontWeight,infoFontStyle:e.infoFontStyle};f.backgroundSource!==`image`&&delete f.backgroundImage,f.backgroundSource!==`video`&&delete f.backgroundVideo,f.showChannelInfo||delete f.channelInfoImage,hp.forEach(e=>{delete f[e]});try{let e=JSON.stringify(f,null,2),t=new Blob([e],{type:`application/json`}),n=URL.createObjectURL(t),i=document.createElement(`a`);i.href=n,i.download=`render_settings_${r}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(n),L.success(`Settings exported as render_settings_${r}.json`,3e3)}catch(e){console.error(`Export failed:`,e),L.error(`Failed to export settings.`,3e3)}};return(0,w.useEffect)(()=>{let e=e=>{oe.current&&!oe.current.contains(e.target)&&i()};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[i]),(0,K.jsxs)(`div`,{ref:oe,onMouseDown:e=>e.stopPropagation(),className:`no-minimal-mode-toggle absolute right-0 top-0 bottom-0 w-full sm:w-80 bg-zinc-900/95 backdrop-blur-xl border-l border-white/10 z-50 flex flex-col shadow-2xl animate-in slide-in-from-right duration-300`,children:[(0,K.jsxs)(`div`,{className:`h-14 border-b border-white/10 flex items-center justify-between px-3 md:px-4 bg-zinc-900/50 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(Oe,{size:18,className:`text-purple-400 shrink-0`}),(0,K.jsx)(`h2`,{className:`font-bold text-zinc-200 truncate`,children:`Render Settings`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-2`,children:[(0,K.jsx)(`input`,{ref:me,type:`file`,name:`import-settings`,id:`import-settings`,"aria-label":`Import Settings JSON`,accept:`.json`,className:`hidden`,onChange:e=>{let n=e.target.files?.[0];if(!n)return;ye(n.name);let i=new FileReader;i.onload=e=>{try{let n=JSON.parse(e.target?.result);if(n&&typeof n==`object`){let{_meta:e,__note_fontFamily:i,__note_channelInfoFontFamily:a,__note_infoFontFamily:o,resolution:s,aspectRatio:l,renderCodec:u,renderFps:d,renderQuality:p,renderEngine:h,ffmpegCodec:_,preset:v,customFontName:b,customChannelFontName:S,customInfoFontName:w,channelInfoFontWeight:T,channelInfoFontStyle:D,infoFontWeight:O,infoFontStyle:k,...A}=n,j={...dp,...A};if(hp.forEach(e=>{delete j[e]}),fp.forEach(e=>{j[e]!==void 0&&(j[e]=!!j[e])}),T&&(j.channelInfoFontWeight=T),D&&(j.channelInfoFontStyle=D),O&&(j.infoFontWeight=O),k&&(j.infoFontStyle=k),[`backgroundBlurStrength`,`fontSizeScale`,`infoMarginScale`,`infoSizeScale`,`channelInfoSizeScale`,`channelInfoMarginScale`,`visualTransitionDuration`,`lyricLineHeight`,`marginTopScale`,`marginBottomScale`,`visualizationOpacity`,`visualizationSensitivity`,`visualizationBarCount`].forEach(e=>{j[e]!==void 0&&(j[e]=Number(j[e]))}),j.useCustomHighlightColors!==void 0&&(j.useCustomHighlightColors=!!j.useCustomHighlightColors),j.useRealColorMedia!==void 0&&(j.useRealColorMedia=!!j.useRealColorMedia),j.showChannelInfo!==void 0&&(j.showChannelInfo=!!j.showChannelInfo),j.showIntro!==void 0&&(j.showIntro=!!j.showIntro),j.showTitle!==void 0&&(j.showTitle=!!j.showTitle),j.showArtist!==void 0&&(j.showArtist=!!j.showArtist),j.showCover!==void 0&&(j.showCover=!!j.showCover),j.showLyrics!==void 0&&(j.showLyrics=!!j.showLyrics),j.showVisualization!==void 0&&(j.showVisualization=!!j.showVisualization),j.enableGradientOverlay!==void 0&&(j.enableGradientOverlay=!!j.enableGradientOverlay),j.threejsCameraMovement!==void 0&&(j.threejsCameraMovement=!!j.threejsCameraMovement),j.highlightEffect&&(!j.highlightColor||!j.highlightBackground)){let e=Cp(j.highlightEffect);e&&(j.highlightColor||=e.color,j.highlightBackground||=e.bg)}let M=(e,t)=>t.some(t=>t.options.some(t=>t.value===e));j.textEffect&&!M(j.textEffect,vp)&&(j.textEffect=`shadow`),j.textAnimation&&!M(j.textAnimation,yp)&&(j.textAnimation=`none`),j.transitionEffect&&!M(j.transitionEffect,bp)&&(j.transitionEffect=`none`),j.visualTransitionType&&!M(j.visualTransitionType,xp)&&(j.visualTransitionType=`none`),j.highlightEffect&&!M(j.highlightEffect,Sp)&&(j.highlightEffect=`karaoke`),j.backgroundSource&&!M(j.backgroundSource,wp)&&(j.backgroundSource=`custom`),[`current`,`playlist`].includes(j.renderMode)||(j.renderMode=`current`),[`left`,`center`,`right`].includes(j.textAlign)||(j.textAlign=`center`),[`top`,`center`,`bottom`].includes(j.contentPosition)||(j.contentPosition=`center`),j.marginTopScale===void 0||isNaN(j.marginTopScale)?j.marginTopScale=1:j.marginTopScale=Math.max(0,Math.min(5,j.marginTopScale)),j.marginBottomScale===void 0||isNaN(j.marginBottomScale)?j.marginBottomScale=1:j.marginBottomScale=Math.max(0,Math.min(5,j.marginBottomScale)),j.lyricDisplayMode&&!M(j.lyricDisplayMode,Ep)&&(j.lyricDisplayMode=`all`),j.lyricVisibilityMode&&![`default`,`auto`].includes(j.lyricVisibilityMode)&&(j.lyricVisibilityMode=`default`),j.lyricVisibilityMode||=`default`,[`normal`,`bold`].includes(j.fontWeight)||(j.fontWeight=`bold`),[`normal`,`italic`].includes(j.fontStyle)||(j.fontStyle=`normal`),[`none`,`underline`,`line-through`].includes(j.textDecoration)||(j.textDecoration=`none`),Dp.includes(j.textCase)||(j.textCase=`none`),[`auto`,`manual`].includes(j.introMode)||(j.introMode=`auto`),j.lyricStyleTarget&&![`active-only`,`all`].includes(j.lyricStyleTarget)&&(j.lyricStyleTarget=`active-only`);let N=[`top-left`,`top-right`,`bottom-left`,`bottom-right`,`top-center`,`bottom-center`,`left-middle`,`center-middle`,`right-middle`];j.infoPosition&&!N.includes(j.infoPosition)&&(j.infoPosition=`top-left`),j.infoStyle&&!M(j.infoStyle,Op)&&(j.infoStyle=`classic`),j.channelInfoPosition&&!N.includes(j.channelInfoPosition)&&(j.channelInfoPosition=`bottom-right`),j.channelInfoStyle&&!M(j.channelInfoStyle,kp)&&(j.channelInfoStyle=`classic`),j.floatingNotesPosition&&!N.includes(j.floatingNotesPosition)&&(j.floatingNotesPosition=`bottom-left`),j.floatingNotesLayout&&![`text-only`,`media-only`,`media-left-text`,`media-right-text`,`media-top-text`,`media-bottom-text`].includes(j.floatingNotesLayout)&&(j.floatingNotesLayout=`text-only`),j.floatingNotesShape&&![`none`,`sharp`,`rounded`].includes(j.floatingNotesShape)&&(j.floatingNotesShape=`rounded`),j.floatingNotesTextAlign&&![`left`,`center`,`right`].includes(j.floatingNotesTextAlign)&&(j.floatingNotesTextAlign=`left`),j.floatingNotesMediaSizeScale!==void 0&&(j.floatingNotesMediaSizeScale=Math.min(.9,Math.max(.1,Number(j.floatingNotesMediaSizeScale)||.4))),j.floatingNotesFontSizeScale!==void 0&&(j.floatingNotesFontSizeScale=Math.min(3,Math.max(.5,Number(j.floatingNotesFontSizeScale)||1))),j.floatingNotesOutlineSize!==void 0&&(j.floatingNotesOutlineSize=Math.max(0,Number(j.floatingNotesOutlineSize)||0)),j.floatingNotesVisibilityMode&&![`all`,`follow-lyrics`,`from-start`,`from-end`,`from-start-and-end`,`specific`].includes(j.floatingNotesVisibilityMode)&&(j.floatingNotesVisibilityMode=`all`),j.floatingNotesFromStartDuration!==void 0&&(j.floatingNotesFromStartDuration=Math.max(0,Number(j.floatingNotesFromStartDuration)||0)),j.floatingNotesFromEndDuration!==void 0&&(j.floatingNotesFromEndDuration=Math.max(0,Number(j.floatingNotesFromEndDuration)||0)),j.visualizationType&&![`bars`,`wave`,`circular`,`particles`,`pulse-ring`,`waveform`,`spectrogram`,`spectrum`,`stereo-field`].includes(j.visualizationType)&&(j.visualizationType=`bars`),j.visualizationColorMode&&![`accent`,`gradient`,`custom`,`rainbow`].includes(j.visualizationColorMode)&&(j.visualizationColorMode=`gradient`),j.visualizationPosition&&![`bottom`,`top`,`full`,`center`].includes(j.visualizationPosition)&&(j.visualizationPosition=`bottom`),j.visualizationOpacity!==void 0&&(j.visualizationOpacity=Math.max(0,Math.min(1,j.visualizationOpacity))),j.visualizationSensitivity!==void 0&&(j.visualizationSensitivity=Math.max(.5,Math.min(3,j.visualizationSensitivity))),j.visualizationBarCount!==void 0&&(j.visualizationBarCount=Math.max(16,Math.min(128,Math.round(j.visualizationBarCount)))),t(j),s&&f(s),l&&m(l),u&&g(u),d&&x(Number(d)),p&&y(p),h&&C(h),_&&E(_),r(v||`custom`),b&&b!==c?L.success(`Settings loaded. Note: Config used font "${b}".`,4e3):S||w?L.success(`Settings loaded. Custom fonts referenced: ${[S,w].filter(Boolean).join(`, `)}`,4e3):L.success(`Settings loaded successfully!`,3e3)}}catch(e){console.error(e),L.error(`Failed to parse settings file. Please ensure it is a valid JSON file.`,4e3)}},i.readAsText(n),e.target.value=``}}),(0,K.jsx)(`button`,{onClick:()=>me.current?.click(),className:`p-1.5 rounded-lg text-zinc-400 hover:text-emerald-300 hover:bg-emerald-500/10 transition-all`,title:`Import settings (.json)`,children:(0,K.jsx)(He,{size:15})}),(0,K.jsx)(`button`,{onClick:Ue,className:`p-1.5 rounded-lg text-zinc-400 hover:text-blue-300 hover:bg-blue-500/10 transition-all`,title:`Export settings (.json)`,children:(0,K.jsx)(R,{size:15})}),(0,K.jsx)(`button`,{onClick:Ve,className:`p-1.5 rounded-lg text-zinc-500 hover:text-red-400 hover:bg-red-500/10 transition-all`,title:`Reset all settings to defaults`,children:(0,K.jsx)(Te,{size:15})}),(0,K.jsx)(`div`,{className:`w-px h-4 bg-white/10 mx-0.5`}),(0,K.jsx)(`button`,{onClick:i,className:`p-1.5 hover:bg-white/10 rounded-lg text-zinc-400 hover:text-white transition-colors`,title:`Close`,children:(0,K.jsx)(qe,{size:18})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-3 md:p-4 space-y-6 custom-scrollbar`,children:[(0,K.jsxs)(`section`,{className:`space-y-2`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(Oe,{size:14}),` Settings Management`]}),(0,K.jsxs)(`div`,{className:`rounded-xl border border-white/10 bg-zinc-800/40 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 border-b border-white/5`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs font-semibold text-zinc-200`,children:`Import Settings`}),(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500 truncate`,children:U?(0,K.jsxs)(`span`,{className:`text-emerald-400 font-mono`,children:[`✓ `,U]}):`Load a previously exported .json file`})]}),(0,K.jsxs)(`button`,{onClick:()=>me.current?.click(),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-emerald-600/20 hover:bg-emerald-600/40 border border-emerald-500/30 text-emerald-300 hover:text-emerald-100 text-xs font-semibold transition-all active:scale-95 shrink-0`,title:`Import settings from a .json file`,children:[(0,K.jsx)(He,{size:13}),` Import`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5 border-b border-white/5`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs font-semibold text-zinc-200`,children:`Export Settings`}),(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500`,children:`Save current config as a .json file`})]}),(0,K.jsxs)(`button`,{onClick:Ue,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-blue-600/20 hover:bg-blue-600/40 border border-blue-500/30 text-blue-300 hover:text-blue-100 text-xs font-semibold transition-all active:scale-95 shrink-0`,title:`Export current settings as a .json file`,children:[(0,K.jsx)(R,{size:13}),` Export`]})]}),(0,K.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-white/5 space-y-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs font-semibold text-zinc-200`,children:`Random Settings`}),(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500`,children:`Generate random visual settings`})]}),(0,K.jsxs)(`button`,{onClick:Re,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-purple-600/20 hover:bg-purple-600/40 border border-purple-500/30 text-purple-300 hover:text-purple-100 text-xs font-semibold transition-all active:scale-95 shrink-0`,title:`Generate random visual settings`,children:[(0,K.jsx)(ke,{size:13}),` Randomize`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,K.jsx)(`button`,{onClick:xe,className:`px-2 py-1 rounded-md bg-zinc-800 hover:bg-zinc-700 border border-white/10 text-[10px] text-zinc-300 hover:text-white transition-colors`,title:`Check all random toggles`,children:`All`}),(0,K.jsx)(`button`,{onClick:Se,className:`px-2 py-1 rounded-md bg-zinc-800 hover:bg-zinc-700 border border-white/10 text-[10px] text-zinc-300 hover:text-white transition-colors`,title:`Uncheck all random toggles`,children:`None`}),(0,K.jsx)(`button`,{onClick:Ce,className:`px-2 py-1 rounded-md bg-zinc-800 hover:bg-zinc-700 border border-white/10 text-[10px] text-zinc-300 hover:text-white transition-colors`,title:`Typography & style + text/visual effects only`,children:`Lyrics`}),(0,K.jsx)(`button`,{onClick:we,className:`px-2 py-1 rounded-md bg-zinc-800 hover:bg-zinc-700 border border-white/10 text-[10px] text-zinc-300 hover:text-white transition-colors`,title:`Background, visualizer, highlight, visible elements, text & transition effects`,children:`Style & FX`}),(0,K.jsx)(`button`,{onClick:Ee,className:`px-2 py-1 rounded-md bg-zinc-800 hover:bg-zinc-700 border border-white/10 text-[10px] text-zinc-300 hover:text-white transition-colors`,title:`Invert current checkbox selection`,children:`Invert`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs font-semibold text-zinc-200`,children:`Reset to Default`}),(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500`,children:`Restore all settings to factory defaults`})]}),(0,K.jsxs)(`button`,{onClick:Ve,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-red-600/10 hover:bg-red-600/30 border border-red-500/20 hover:border-red-500/50 text-red-400 hover:text-red-200 text-xs font-semibold transition-all active:scale-95 shrink-0`,title:`Reset all settings to factory defaults`,children:[(0,K.jsx)(Te,{size:13}),` Reset`]})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(Ne,{size:14}),` Visual Preset`]}),(0,K.jsx)(Pp,{value:n,onChange:e=>De(e),groups:sp})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(We,{size:14}),` Render Scope`]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`renderMode`,`current`),className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${e.renderMode===`current`?`bg-purple-600 border-purple-500 text-white shadow-[0_0_10px_rgba(147,51,234,0.3)]`:`bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20`}`,children:`Current Song`}),(0,K.jsx)(`button`,{onClick:()=>W(`renderMode`,`playlist`),disabled:!o,className:`px-3 py-2 rounded-lg text-xs font-medium border transition-all ${e.renderMode===`playlist`?`bg-purple-600 border-purple-500 text-white shadow-[0_0_10px_rgba(147,51,234,0.3)]`:`bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20 disabled:opacity-30 disabled:cursor-not-allowed`}`,children:`All Playlist`})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ue,{size:14}),` Background Source`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeBackgroundSource!==!1,onChange:e=>W(`randomizeBackgroundSource`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsx)(Pp,{value:e.backgroundSource,onChange:n=>{n===`gradient`&&!e.backgroundGradient?(r(`custom`),t({...e,backgroundSource:`gradient`,backgroundGradient:`linear-gradient(to bottom right, #312e81, #581c87, #000000)`})):n===`smart-gradient`&&(!e.backgroundColor||e.backgroundColor===`#000000`)?(r(`custom`),t({...e,backgroundSource:`smart-gradient`,backgroundColor:`#581c87`})):n===`color`&&!e.backgroundColor?(r(`custom`),t({...e,backgroundSource:`color`,backgroundColor:`#000000`})):W(`backgroundSource`,n)},groups:wp}),e.backgroundSource===`smart-gradient`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{type:`color`,name:`smart-bg-color`,"aria-label":`Smart Gradient Base Color`,value:e.backgroundColor,onChange:e=>W(`backgroundColor`,e.target.value),className:`w-10 h-10 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsxs)(`div`,{className:`flex flex-col flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-xs text-zinc-300 font-medium`,children:`Pick Base Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`Hex:`}),(0,K.jsx)(`input`,{type:`text`,name:`smart-bg-hex`,"aria-label":`Smart Gradient Base Color Hex`,value:e.backgroundColor,onChange:e=>W(`backgroundColor`,e.target.value),className:`bg-transparent border-b border-zinc-700 focus:border-purple-500 text-[10px] text-zinc-300 font-mono focus:outline-none p-0 w-20 uppercase`})]})]})]}),e.backgroundSource===`color`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`solid-bg-color`,type:`color`,name:`solid-bg-color`,"aria-label":`Background Color`,value:e.backgroundColor,onChange:e=>W(`backgroundColor`,e.target.value),className:`w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`input`,{id:`solid-bg-hex`,type:`text`,name:`solid-bg-hex`,"aria-label":`Background Color Hex`,value:e.backgroundColor,onChange:e=>W(`backgroundColor`,e.target.value),className:`bg-transparent border-b border-zinc-700 text-xs text-zinc-300 font-mono flex-1 focus:outline-none focus:border-purple-500 uppercase py-1`})]}),e.backgroundSource===`gradient`&&(0,K.jsx)(`input`,{type:`text`,name:`custom-gradient`,"aria-label":`Custom CSS Gradient`,value:e.backgroundGradient,onChange:e=>W(`backgroundGradient`,e.target.value),placeholder:`linear-gradient(to bottom right, #312e81, #581c87, #000000)`,className:`w-full bg-zinc-800 border border-white/10 rounded-lg px-3 py-2 text-xs font-mono text-zinc-300 focus:outline-none focus:ring-1 focus:ring-purple-500`}),e.backgroundSource===`image`&&(0,K.jsx)(`div`,{className:`space-y-3 animate-in slide-in-from-top-1 fade-in duration-200`,children:(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`bg-image-upload`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Custom Background Image`}),(0,K.jsx)(`input`,{ref:V,type:`file`,name:`bg-image-upload`,id:`bg-image-upload`,accept:`image/*`,onChange:Pe,className:`hidden`}),e.backgroundImage?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5`,children:(0,K.jsx)(`img`,{src:e.backgroundImage,alt:`Background`,className:`w-full h-full object-cover`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-300 truncate`,children:`Image Loaded`}),(0,K.jsx)(`button`,{onClick:()=>W(`backgroundImage`,void 0),className:`text-[10px] text-red-400 hover:text-red-300`,children:`Remove`})]}),(0,K.jsx)(`button`,{onClick:()=>V.current?.click(),className:`p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white`,children:(0,K.jsx)(Oe,{size:14})})]}):(0,K.jsxs)(`button`,{onClick:()=>V.current?.click(),className:`w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-3 text-zinc-400 hover:text-purple-300 transition-colors`,children:[(0,K.jsx)(He,{size:14}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Upload Background`})]})]})}),e.backgroundSource===`video`&&(0,K.jsx)(`div`,{className:`space-y-3 animate-in slide-in-from-top-1 fade-in duration-200`,children:(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`bg-video-upload`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Custom Background Video`}),(0,K.jsx)(`input`,{ref:H,type:`file`,name:`bg-video-upload`,id:`bg-video-upload`,accept:`video/*`,onChange:Fe,className:`hidden`}),e.backgroundVideo?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5`,children:(0,K.jsx)(`video`,{src:e.backgroundVideo,className:`w-full h-full object-cover`,muted:!0,autoPlay:!0,loop:!0})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-300 truncate`,children:`Video Loaded`}),(0,K.jsx)(`button`,{onClick:()=>W(`backgroundVideo`,void 0),className:`text-[10px] text-red-400 hover:text-red-300`,children:`Remove`})]}),(0,K.jsx)(`button`,{onClick:()=>H.current?.click(),className:`p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white`,children:(0,K.jsx)(Oe,{size:14})})]}):(0,K.jsxs)(`button`,{onClick:()=>H.current?.click(),className:`w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-3 text-zinc-400 hover:text-purple-300 transition-colors`,children:[(0,K.jsx)(He,{size:14}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Upload Video Loop`})]})]})}),e.backgroundSource===`threejs`&&(0,K.jsxs)(`div`,{className:`space-y-3 animate-in slide-in-from-top-1 fade-in duration-200`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Three.js Scene Effect`}),(0,K.jsx)(Pp,{value:e.threejsScene||`stars`,onChange:e=>W(`threejsScene`,e),groups:Tp})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5 flex flex-col gap-1`,children:[(0,K.jsxs)(`label`,{htmlFor:`threejs-speed`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:[`Speed: `,e.threejsSpeed||1,`x`]}),(0,K.jsx)(`input`,{id:`threejs-speed`,type:`range`,min:`0.1`,max:`5`,step:`0.1`,value:e.threejsSpeed||1,onChange:e=>W(`threejsSpeed`,parseFloat(e.target.value)),className:`w-full accent-purple-500`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`threejs-color`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Theme Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5 h-9`,children:[(0,K.jsx)(`input`,{id:`threejs-color`,name:`threejs-color`,type:`color`,value:e.threejsColor||`#a855f7`,onChange:e=>W(`threejsColor`,e.target.value),className:`w-6 h-6 bg-transparent cursor-pointer border-none shrink-0`}),(0,K.jsx)(`input`,{id:`threejs-color-hex`,name:`threejs-color-hex`,type:`text`,"aria-label":`Theme Color Hex`,value:e.threejsColor||`#a855f7`,onChange:e=>W(`threejsColor`,e.target.value),className:`w-full bg-transparent border-none text-xs items-center flex text-zinc-200 focus:outline-none font-mono`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`threejs-bg-color`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,title:`Leave empty for transparent (uses app background)`,children:`Bg Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5 h-9`,children:[(0,K.jsx)(`input`,{id:`threejs-bg-color`,name:`threejs-bg-color`,type:`color`,value:e.threejsBgColor||`#000000`,onChange:e=>W(`threejsBgColor`,e.target.value),className:`w-6 h-6 bg-transparent cursor-pointer border-none shrink-0`}),(0,K.jsx)(`input`,{id:`threejs-bg-color-hex`,name:`threejs-bg-color-hex`,type:`text`,placeholder:`None`,"aria-label":`Background Color Hex`,value:e.threejsBgColor||``,onChange:e=>W(`threejsBgColor`,e.target.value),className:`w-full bg-transparent border-none text-xs items-center flex text-zinc-200 focus:outline-none placeholder:text-zinc-600 font-mono`})]})]})]}),(0,K.jsx)(`div`,{className:`pt-1`,children:(0,K.jsxs)(`label`,{htmlFor:`threejs-camera-movement`,className:`flex items-center gap-2 cursor-pointer group`,children:[(0,K.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,K.jsx)(`input`,{id:`threejs-camera-movement`,name:`threejs-camera-movement`,type:`checkbox`,checked:e.threejsCameraMovement||!1,onChange:e=>W(`threejsCameraMovement`,e.target.checked),className:`peer sr-only`}),(0,K.jsx)(`div`,{className:`w-5 h-5 bg-zinc-800 border border-white/20 rounded-md peer-checked:bg-purple-500 peer-checked:border-purple-500 transition-colors`}),(0,K.jsx)(ee,{size:12,className:`absolute text-white opacity-0 peer-checked:opacity-100 transition-opacity`})]}),(0,K.jsx)(`span`,{className:`text-xs text-zinc-300 font-medium group-hover:text-purple-300 transition-colors`,children:`Auto Camera Movement`})]})})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(_e,{size:14}),` Background Effects`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeBackgroundEffects!==!1,onChange:e=>W(`randomizeBackgroundEffects`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 p-1 rounded-lg border border-white/5`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`backgroundBlurStrength`,0),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-all ${e.backgroundBlurStrength===0?`bg-zinc-600 text-white shadow-sm`:`text-zinc-400 hover:text-zinc-200 hover:bg-white/5`}`,children:`Sharp`}),(0,K.jsx)(`button`,{onClick:()=>W(`backgroundBlurStrength`,12),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-all ${e.backgroundBlurStrength>0?`bg-purple-600 text-white shadow-sm`:`text-zinc-400 hover:text-zinc-200 hover:bg-white/5`}`,children:`Blur`})]}),e.backgroundBlurStrength>0&&(0,K.jsxs)(`div`,{className:`space-y-1.5 animate-in slide-in-from-top-2 fade-in duration-200`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Blur Intensity`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[e.backgroundBlurStrength,`px`]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,name:`blur-strength`,"aria-label":`Blur Intensity`,min:`1`,max:`64`,step:`1`,value:e.backgroundBlurStrength,onChange:e=>W(`backgroundBlurStrength`,parseInt(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800/30 border border-white/5 rounded-lg p-2.5 flex items-center justify-between cursor-pointer hover:bg-zinc-800/50 transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`label`,{htmlFor:`real-color-media`,className:`text-xs text-zinc-300 font-medium cursor-pointer`,children:`Real Color Media Source`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`Disable dark dimming effect on background`})]}),(0,K.jsxs)(`div`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`real-color-media`,name:`real-color-media`,"aria-label":`Real Color Media`,checked:e.useRealColorMedia??!1,onChange:e=>W(`useRealColorMedia`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`label`,{htmlFor:`real-color-media`,className:`w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer`})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800/30 border border-white/5 rounded-lg p-2.5 flex items-center justify-between cursor-pointer hover:bg-zinc-800/50 transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`label`,{htmlFor:`gradient-overlay`,className:`text-xs text-zinc-300 font-medium cursor-pointer`,children:`Black Gradient Overlay`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`Fade bottom to top (readability)`})]}),(0,K.jsxs)(`div`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`gradient-overlay`,name:`gradient-overlay`,"aria-label":`Gradient Overlay`,checked:e.enableGradientOverlay??!1,onChange:e=>W(`enableGradientOverlay`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`label`,{htmlFor:`gradient-overlay`,className:`w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer`})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(k,{size:14}),` Audio Visualizer`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeAudioVisualizer!==!1,onChange:e=>W(`randomizeAudioVisualizer`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800/30 border border-white/5 rounded-lg p-2.5 flex items-center justify-between cursor-pointer hover:bg-zinc-800/50 transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`label`,{htmlFor:`show-visualization`,className:`text-xs text-zinc-300 font-medium cursor-pointer`,children:`Show Visualization`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`Real-time audio reactive visuals`})]}),(0,K.jsxs)(`div`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`show-visualization`,name:`show-visualization`,"aria-label":`Show Visualization`,checked:e.showVisualization??!1,onChange:e=>W(`showVisualization`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`label`,{htmlFor:`show-visualization`,className:`w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer`})]})]}),e.showVisualization&&(0,K.jsxs)(`div`,{className:`space-y-3 animate-in slide-in-from-top-2 fade-in duration-200`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Visualization Type`}),(0,K.jsx)(Pp,{value:e.visualizationType||`bars`,onChange:e=>W(`visualizationType`,e),groups:[{label:`Minimalist`,options:[{label:`Bars`,value:`bars`},{label:`Wave`,value:`wave`},{label:`Waveform (Filled)`,value:`waveform`},{label:`Spectrum`,value:`spectrum`}]},{label:`Advanced`,options:[{label:`Spectrogram`,value:`spectrogram`},{label:`Stereo Field`,value:`stereo-field`}]},{label:`Dynamic`,options:[{label:`Circular`,value:`circular`},{label:`Particles`,value:`particles`},{label:`Pulse Ring`,value:`pulse-ring`}]}]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Color Mode`}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:[`accent`,`gradient`,`rainbow`,`custom`].map(t=>(0,K.jsx)(`button`,{onClick:()=>W(`visualizationColorMode`,t),className:`px-2 py-1.5 rounded-md text-[10px] font-medium border transition-all capitalize ${e.visualizationColorMode===t?`bg-purple-600/40 border-purple-500/50 text-purple-200`:`bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20`}`,children:t},t))})]}),e.visualizationColorMode===`custom`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 animate-in slide-in-from-top-2 fade-in duration-200`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`viz-color-1`,type:`color`,name:`viz-color-1`,"aria-label":`Visualization Color 1`,value:e.visualizationColor1||`#a855f7`,onChange:e=>W(`visualizationColor1`,e.target.value),className:`w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400`,children:`Color 1`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`viz-color-2`,type:`color`,name:`viz-color-2`,"aria-label":`Visualization Color 2`,value:e.visualizationColor2||`#6366f1`,onChange:e=>W(`visualizationColor2`,e.target.value),className:`w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400`,children:`Color 2`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Position`}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:[{label:`Bottom`,value:`bottom`},{label:`Top`,value:`top`},{label:`Center`,value:`center`},{label:`Full`,value:`full`}].map(t=>(0,K.jsx)(`button`,{onClick:()=>W(`visualizationPosition`,t.value),className:`px-2 py-1.5 rounded-md text-[10px] font-medium border transition-all ${(e.visualizationPosition||`bottom`)===t.value?`bg-purple-600/40 border-purple-500/50 text-purple-200`:`bg-zinc-800/50 border-white/5 text-zinc-400 hover:border-white/20`}`,children:t.label},t.value))})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Opacity`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[((e.visualizationOpacity??.6)*100).toFixed(0),`%`]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,name:`viz-opacity`,"aria-label":`Visualization Opacity`,min:`0.1`,max:`1.0`,step:`0.05`,value:e.visualizationOpacity??.6,onChange:e=>W(`visualizationOpacity`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Sensitivity`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.visualizationSensitivity??1.5).toFixed(1),`x`]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,name:`viz-sensitivity`,"aria-label":`Visualization Sensitivity`,min:`0.5`,max:`3.0`,step:`0.1`,value:e.visualizationSensitivity??1.5,onChange:e=>W(`visualizationSensitivity`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]}),[`bars`,`circular`,`pulse-ring`].includes(e.visualizationType||`bars`)&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:[`circular`,`pulse-ring`].includes(e.visualizationType||`bars`)?`Segments`:`Bar Count`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:e.visualizationBarCount??48})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,name:`viz-bar-count`,"aria-label":`Visualization Bar Count`,min:`16`,max:`128`,step:`4`,value:e.visualizationBarCount??48,onChange:e=>W(`visualizationBarCount`,parseInt(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ae,{size:14}),` Lyric Display Mode`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeLyricDisplayMode!==!1,onChange:e=>W(`randomizeLyricDisplayMode`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsx)(Pp,{value:e.lyricDisplayMode,onChange:e=>W(`lyricDisplayMode`,e),groups:Ep})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ae,{size:14}),` Lyric Visibility`]}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 p-1 rounded-lg border border-white/5`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`lyricVisibilityMode`,`default`),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-all ${(e.lyricVisibilityMode??`default`)==="default"?`bg-zinc-600 text-white shadow-sm`:`text-zinc-400 hover:text-zinc-200 hover:bg-white/5`}`,children:`Default`}),(0,K.jsx)(`button`,{onClick:()=>W(`lyricVisibilityMode`,`auto`),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-all ${e.lyricVisibilityMode===`auto`?`bg-purple-600 text-white shadow-sm`:`text-zinc-400 hover:text-zinc-200 hover:bg-white/5`}`,children:`Auto`})]}),e.lyricVisibilityMode===`auto`&&(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500 leading-relaxed px-1`,children:`TTML/SRT: hides lyrics when the gap between line end and the next cue exceeds 3 seconds (short gaps keep the previous line). LRC/eLRC: estimates line duration from word timing or word count, then hides during long gaps; final line also hides near the end of long outros.`})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(Ne,{size:14}),` Highlight Effect`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeHighlightEffect!==!1,onChange:e=>W(`randomizeHighlightEffect`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsx)(Pp,{value:e.highlightEffect||`none`,onChange:e=>{W(`highlightEffect`,e)},groups:Sp}),e.highlightEffect&&e.highlightEffect!==`none`&&(0,K.jsxs)(`div`,{className:`mt-2 space-y-2 animate-in slide-in-from-top-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>W(`useCustomHighlightColors`,!e.useCustomHighlightColors),className:`w-full flex items-center justify-between p-2 rounded-lg border text-xs font-medium transition-all ${e.useCustomHighlightColors?`bg-purple-900/30 border-purple-500/50 text-purple-200`:`bg-zinc-800 border-white/5 text-zinc-400 hover:bg-zinc-700`}`,children:[(0,K.jsx)(`span`,{children:`Custom Colors`}),(0,K.jsx)(`div`,{className:`w-8 h-4 rounded-full p-0.5 transition-colors ${e.useCustomHighlightColors?`bg-purple-500`:`bg-zinc-600`}`,children:(0,K.jsx)(`div`,{className:`w-3 h-3 bg-white rounded-full shadow-sm transition-transform ${e.useCustomHighlightColors?`translate-x-4`:`translate-x-0`}`})})]}),e.useCustomHighlightColors&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 animate-in fade-in duration-200`,children:[(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-bold uppercase`,children:`Text/Glow Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 p-1.5 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`highlight-color`,type:`color`,name:`highlight-color`,"aria-label":`Highlight Text Color`,value:e.highlightColor||`#fb923c`,onChange:e=>W(`highlightColor`,e.target.value),className:`w-8 h-6 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`input`,{id:`highlight-color-hex`,type:`text`,name:`highlight-color-hex`,"aria-label":`Highlight Text Color Hex`,value:e.highlightColor||`#fb923c`,onChange:e=>W(`highlightColor`,e.target.value),className:`bg-transparent border-none text-[10px] text-zinc-300 font-mono w-full focus:outline-none uppercase`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-bold uppercase`,children:`Back/Shape Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 p-1.5 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`highlight-bg-color`,type:`color`,name:`highlight-bg-color`,"aria-label":`Highlight Background Color`,value:e.highlightBackground||`#fb923c`,onChange:e=>W(`highlightBackground`,e.target.value),className:`w-8 h-6 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`input`,{id:`highlight-bg-hex`,type:`text`,name:`highlight-bg-hex`,"aria-label":`Highlight Background Color Hex`,value:e.highlightBackground||`#fb923c`,onChange:e=>W(`highlightBackground`,e.target.value),className:`bg-transparent border-none text-[10px] text-zinc-300 font-mono w-full focus:outline-none uppercase`})]})]})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ve,{size:14}),` Visible Elements`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeVisibleElements!==!1,onChange:e=>W(`randomizeVisibleElements`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:[{label:`Lyrics / Subtitles`,key:`showLyrics`},{label:`Song Title`,key:`showTitle`},{label:`Artist Name`,key:`showArtist`},{label:`Cover Art`,key:`showCover`},{label:`Intro Info`,key:`showIntro`}].map(t=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded-lg bg-zinc-800/30 border border-white/5 hover:bg-zinc-800/50 cursor-pointer transition-colors`,children:[(0,K.jsx)(`label`,{htmlFor:t.key,className:`text-xs text-zinc-300 cursor-pointer w-full`,children:t.label}),(0,K.jsxs)(`div`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:t.key,name:t.key,"aria-label":t.label,checked:e[t.key],onChange:e=>W(t.key,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`label`,{htmlFor:t.key,className:`w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer`})]})]},t.key))})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ze,{size:14}),` Intro Settings`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeIntroSettings!==!1,onChange:e=>W(`randomizeIntroSettings`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800/30 border border-white/5 rounded-lg p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-xs text-zinc-300 font-medium`,children:`Intro Text`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 rounded-md p-1 border border-white/5`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`introMode`,`auto`),className:`px-2 py-1 text-[10px] font-medium rounded transition-all ${e.introMode===`auto`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-400 hover:text-zinc-200`}`,children:`Auto`}),(0,K.jsx)(`button`,{onClick:()=>W(`introMode`,`manual`),className:`px-2 py-1 text-[10px] font-medium rounded transition-all ${e.introMode===`manual`?`bg-purple-600 text-white shadow-sm`:`text-zinc-400 hover:text-zinc-200`}`,children:`Manual`})]})]}),e.introMode===`manual`&&(0,K.jsxs)(`div`,{className:`space-y-1 animate-in slide-in-from-top-1 fade-in duration-200`,children:[(0,K.jsx)(`label`,{htmlFor:`intro-text`,className:`text-[10px] text-zinc-500 uppercase font-bold`,children:`Custom Intro Content`}),(0,K.jsx)(`textarea`,{id:`intro-text`,name:`intro-text`,"aria-label":`Intro Text`,value:e.introText,onChange:e=>W(`introText`,e.target.value),placeholder:`Enter intro text...`,className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500 min-h-[60px]`})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ze,{size:14}),` Typography & Style`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeTypographyStyle!==!1,onChange:e=>W(`randomizeTypographyStyle`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-4 pt-1`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Alignment`}),(0,K.jsx)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1`,children:[`left`,`center`,`right`].map(t=>(0,K.jsx)(`button`,{onClick:()=>W(`textAlign`,t),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${e.textAlign===t?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,children:t},t))})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Vertical Position`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1 gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`contentPosition`,`top`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.contentPosition===`top`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Top`,children:(0,K.jsx)(M,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`contentPosition`,`center`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.contentPosition===`center`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Center`,children:(0,K.jsx)(A,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`contentPosition`,`bottom`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.contentPosition===`bottom`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Bottom`,children:(0,K.jsx)(j,{size:14})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mt-2`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Top Margin`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.marginTopScale??1).toFixed(1),`x`]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,name:`margin-top`,"aria-label":`Lyrics Top Margin`,min:`0.0`,max:`5.0`,step:`0.1`,value:e.marginTopScale??1,onChange:e=>W(`marginTopScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Bottom Margin`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.marginBottomScale??1).toFixed(1),`x`]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,name:`margin-bottom`,"aria-label":`Lyrics Bottom Margin`,min:`0.0`,max:`5.0`,step:`0.1`,value:e.marginBottomScale??1,onChange:e=>W(`marginBottomScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Style`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1 gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`fontWeight`,e.fontWeight===`bold`?`normal`:`bold`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.fontWeight===`bold`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Bold`,children:(0,K.jsx)(N,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`fontStyle`,e.fontStyle===`italic`?`normal`:`italic`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.fontStyle===`italic`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Italic`,children:(0,K.jsx)(fe,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`textDecoration`,e.textDecoration===`underline`?`none`:`underline`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.textDecoration===`underline`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Underline`,children:(0,K.jsx)(Be,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`textDecoration`,e.textDecoration===`line-through`?`none`:`line-through`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.textDecoration===`line-through`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Strikethrough`,children:(0,K.jsx)(Ie,{size:14})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Apply Style To`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1 gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`lyricStyleTarget`,`active-only`),className:`flex-1 py-1.5 rounded-md text-[10px] transition-all ${e.lyricStyleTarget===`active-only`||!e.lyricStyleTarget?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,title:`Apply style to current line only (others normal)`,children:`Current Only`}),(0,K.jsx)(`button`,{onClick:()=>W(`lyricStyleTarget`,`all`),className:`flex-1 py-1.5 rounded-md text-[10px] transition-all ${e.lyricStyleTarget===`all`?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,title:`Apply style to all lines (previous, current, next)`,children:`All Lines`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Case`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-1 bg-zinc-800 rounded-lg p-1`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`textCase`,`none`),className:`py-1.5 rounded-md text-[10px] transition-all ${e.textCase===`none`?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,children:`Normal`}),(0,K.jsx)(`button`,{onClick:()=>W(`textCase`,`upper`),className:`py-1.5 rounded-md text-[10px] uppercase transition-all ${e.textCase===`upper`?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,children:`Upper`}),(0,K.jsx)(`button`,{onClick:()=>W(`textCase`,`lower`),className:`py-1.5 rounded-md text-[10px] lowercase transition-all ${e.textCase===`lower`?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,children:`Lower`}),(0,K.jsx)(`button`,{onClick:()=>W(`textCase`,`title`),className:`py-1.5 rounded-md text-[10px] capitalize transition-all ${e.textCase===`title`?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,children:`Title Case`}),(0,K.jsx)(`button`,{onClick:()=>W(`textCase`,`sentence`),className:`py-1.5 rounded-md text-[10px] transition-all ${e.textCase===`sentence`?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,children:`Sentence case`}),(0,K.jsx)(`button`,{onClick:()=>W(`textCase`,`invert`),className:`py-1.5 rounded-md text-[10px] transition-all ${e.textCase===`invert`?`bg-zinc-600 text-white shadow-sm font-bold`:`text-zinc-500 hover:text-zinc-300`}`,children:`Invert Case`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Family`}),(0,K.jsx)(Ip,{value:e.fontFamily,onChange:e=>W(`fontFamily`,e),customFontName:c,groups:ie}),(0,K.jsx)(up,{onApply:e=>re(e,`fontFamily`),placeholder:`Lyrics Font (e.g. Pacifico)`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`main-font-upload`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Custom Font File`}),(0,K.jsx)(`input`,{ref:se,type:`file`,name:`main-font-upload`,id:`main-font-upload`,accept:`.ttf,.otf,.woff,.woff2`,onChange:l,className:`hidden`}),c?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800/50 border border-purple-500/30 rounded-lg px-3 py-2`,children:[(0,K.jsx)(ze,{size:14,className:`text-purple-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs text-purple-300 font-medium truncate flex-1`,children:c}),(0,K.jsx)(`button`,{onClick:()=>{W(`fontFamily`,`CustomFont`)},className:`text-[10px] px-2 py-1 rounded transition-colors ${e.fontFamily===`CustomFont`?`bg-purple-600 text-white`:`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`}`,children:e.fontFamily===`CustomFont`?`Active`:`Use`}),(0,K.jsx)(`button`,{onClick:u,className:`p-1 text-zinc-500 hover:text-red-400 transition-colors`,title:`Remove custom font`,children:(0,K.jsx)(Le,{size:14})})]}):(0,K.jsxs)(`button`,{onClick:()=>se.current?.click(),className:`w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-2.5 text-zinc-400 hover:text-purple-300 transition-colors`,children:[(0,K.jsx)(He,{size:14}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Upload Custom Font (.ttf, .otf, .woff2)`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Size`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.fontSizeScale*100).toFixed(0),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(ze,{size:12})}),(0,K.jsx)(`input`,{type:`range`,name:`font-size`,"aria-label":`Font Size`,min:`0.1`,max:`3.0`,step:`0.1`,value:e.fontSizeScale,onChange:e=>W(`fontSizeScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`}),(0,K.jsx)(`span`,{className:`text-zinc-300`,children:(0,K.jsx)(ze,{size:16})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Current Line Height`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.lyricLineHeight||1.3).toFixed(1),`x`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(A,{size:12})}),(0,K.jsx)(`input`,{type:`range`,name:`line-height`,"aria-label":`Line Height`,min:`1.0`,max:`3.0`,step:`0.1`,value:e.lyricLineHeight||1.3,onChange:e=>W(`lyricLineHeight`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),e.fontFamily!==`sans-serif`&&e.fontFamily!==`CustomFont`&&(0,K.jsx)(`div`,{className:`text-[10px] text-zinc-500 bg-zinc-800/30 p-2 rounded border border-white/5`,children:`Some presets like Gothic, Metal, or Tech use specific fonts. Changing Font Family here might override that look.`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`main-font-color`,type:`color`,name:`main-font-color`,"aria-label":`Main Font Color`,value:e.fontColor,onChange:e=>W(`fontColor`,e.target.value),className:`w-8 h-8 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`input`,{id:`main-font-hex`,type:`text`,name:`main-font-hex`,"aria-label":`Main Font Color Hex`,value:e.fontColor,onChange:e=>W(`fontColor`,e.target.value),className:`bg-transparent border-b border-zinc-700 text-xs text-zinc-300 font-mono flex-1 focus:outline-none focus:border-purple-500 uppercase py-1`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Effect`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeTextEffect!==!1,onChange:e=>W(`randomizeTextEffect`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsx)(Pp,{value:e.textEffect,onChange:e=>W(`textEffect`,e),groups:vp})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Animation`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeTextAnimation!==!1,onChange:e=>W(`randomizeTextAnimation`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsx)(Pp,{value:e.textAnimation,onChange:e=>W(`textAnimation`,e),groups:yp})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Transition`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeTransitionEffect!==!1,onChange:e=>W(`randomizeTransitionEffect`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsx)(Pp,{value:e.transitionEffect,onChange:e=>W(`transitionEffect`,e),groups:bp})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5 pt-2 border-t border-white/5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Visual Transition (Images/Video)`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.visualTransitionDuration&&(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[e.visualTransitionDuration.toFixed(1),`s`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeVisualTransition!==!1,onChange:e=>W(`randomizeVisualTransition`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(Pp,{value:e.visualTransitionType||`none`,onChange:e=>W(`visualTransitionType`,e),groups:xp})}),e.visualTransitionType&&e.visualTransitionType!==`none`&&(0,K.jsx)(`div`,{className:`w-1/3 flex items-center bg-zinc-800 border border-white/10 rounded-lg px-2`,children:(0,K.jsx)(`input`,{type:`range`,name:`transition-duration`,"aria-label":`Transition Duration`,min:`0.1`,max:`5.0`,step:`0.1`,value:e.visualTransitionDuration||1,onChange:e=>W(`visualTransitionDuration`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ge,{size:14}),` Song Info Design`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeSongInfoDesign!==!1,onChange:e=>W(`randomizeSongInfoDesign`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Position`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`top-left`),className:`h-8 rounded-md border flex items-start justify-start p-1 transition-all ${e.infoPosition===`top-left`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`top-center`),className:`h-8 rounded-md border flex items-start justify-center p-1 transition-all ${e.infoPosition===`top-center`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`top-right`),className:`h-8 rounded-md border flex items-start justify-end p-1 transition-all ${e.infoPosition===`top-right`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`left-middle`),className:`h-8 rounded-md border flex items-center justify-start p-1 transition-all ${e.infoPosition===`left-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Left Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`center-middle`),className:`h-8 rounded-md border flex items-center justify-center p-1 transition-all ${e.infoPosition===`center-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Center Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`right-middle`),className:`h-8 rounded-md border flex items-center justify-end p-1 transition-all ${e.infoPosition===`right-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Right Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`bottom-left`),className:`h-8 rounded-md border flex items-end justify-start p-1 transition-all ${e.infoPosition===`bottom-left`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`bottom-center`),className:`h-8 rounded-md border flex items-end justify-center p-1 transition-all ${e.infoPosition===`bottom-center`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoPosition`,`bottom-right`),className:`h-8 rounded-md border flex items-end justify-end p-1 transition-all ${e.infoPosition===`bottom-right`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Style`}),(0,K.jsx)(Pp,{value:e.infoStyle||`classic`,onChange:e=>W(`infoStyle`,e),groups:Op})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Edge Margin`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.infoMarginScale??1).toFixed(1),`x`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(he,{size:12})}),(0,K.jsx)(`input`,{type:`range`,name:`info-margin`,"aria-label":`Song Info Margin`,min:`0.0`,max:`5.0`,step:`0.1`,value:e.infoMarginScale??1,onChange:e=>W(`infoMarginScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Info Size`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.infoSizeScale??1).toFixed(1),`x`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(ze,{size:12})}),(0,K.jsx)(`input`,{type:`range`,name:`info-size`,"aria-label":`Song Info Size`,min:`0.5`,max:`3.0`,step:`0.1`,value:e.infoSizeScale??1,onChange:e=>W(`infoSizeScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Family`}),(0,K.jsx)(Ip,{value:e.infoFontFamily||`sans-serif`,onChange:e=>W(`infoFontFamily`,e),customFontName:F||null,groups:ie}),(0,K.jsx)(up,{onApply:e=>re(e,`infoFontFamily`),placeholder:`Info Font (e.g. Roboto)`}),(0,K.jsx)(`input`,{"aria-label":`Upload Info Font`,ref:le,type:`file`,name:`info-font-upload`,id:`info-font-upload`,accept:`.ttf,.otf,.woff,.woff2`,onChange:I,className:`hidden`}),F?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800/50 border border-purple-500/30 rounded-lg px-2 py-1.5 mt-1`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-purple-300 font-medium truncate flex-1`,children:F}),(0,K.jsx)(`button`,{onClick:()=>W(`infoFontFamily`,`InfoFont`),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${e.infoFontFamily===`InfoFont`?`bg-purple-600 text-white`:`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`}`,children:`Use`}),(0,K.jsx)(`button`,{onClick:te,className:`text-zinc-500 hover:text-red-400`,children:(0,K.jsx)(Le,{size:12})})]}):(0,K.jsxs)(`button`,{onClick:()=>le.current?.click(),className:`w-full flex items-center justify-center gap-2 bg-zinc-800/30 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-2 py-1.5 text-zinc-500 hover:text-purple-300 transition-colors mt-1`,children:[(0,K.jsx)(He,{size:10}),(0,K.jsx)(`span`,{className:`text-[10px]`,children:`Upload Font`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Style`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1 gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`infoFontWeight`,e.infoFontWeight===`bold`?`normal`:`bold`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.infoFontWeight===`bold`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Bold`,children:(0,K.jsx)(N,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`infoFontStyle`,e.infoFontStyle===`italic`?`normal`:`italic`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.infoFontStyle===`italic`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Italic`,children:(0,K.jsx)(fe,{size:14})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`info-font-color`,type:`color`,name:`info-font-color`,"aria-label":`Song Info Text Color`,value:e.infoFontColor||`#ffffff`,onChange:e=>W(`infoFontColor`,e.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-mono uppercase`,children:e.infoFontColor||`#ffffff`})]})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ue,{size:14}),` Channel Info / Watermark`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeChannelInfo!==!1,onChange:e=>W(`randomizeChannelInfo`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800/30 border border-white/5 rounded-lg p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,K.jsx)(`label`,{htmlFor:`show-channel-info`,className:`text-xs text-zinc-300 font-medium cursor-pointer`,children:`Show Channel Info`}),(0,K.jsxs)(`div`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`show-channel-info`,name:`show-channel-info`,"aria-label":`Show Channel Info`,checked:e.showChannelInfo??!1,onChange:e=>W(`showChannelInfo`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`label`,{htmlFor:`show-channel-info`,className:`w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer`})]})]}),e.showChannelInfo&&(0,K.jsxs)(`div`,{className:`space-y-3 animate-in slide-in-from-top-1 fade-in duration-200 pt-2 border-t border-white/5`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`channel-image-upload`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Channel Logo / Image`}),(0,K.jsx)(`input`,{ref:de,type:`file`,name:`channel-image-upload`,id:`channel-image-upload`,accept:`image/*`,onChange:Ae,className:`hidden`}),e.channelInfoImage?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5`,children:(0,K.jsx)(`img`,{src:e.channelInfoImage,alt:`Channel`,className:`w-full h-full object-cover`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-300 truncate`,children:`Image Loaded`}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoImage`,void 0),className:`text-[10px] text-red-400 hover:text-red-300`,children:`Remove`})]}),(0,K.jsx)(`button`,{onClick:()=>de.current?.click(),className:`p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white`,children:(0,K.jsx)(Oe,{size:14})})]}):(0,K.jsxs)(`button`,{onClick:()=>de.current?.click(),className:`w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-3 text-zinc-400 hover:text-purple-300 transition-colors`,children:[(0,K.jsx)(He,{size:14}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Upload Image`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`channel-info-text`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Channel Name / SVG Code`}),(0,K.jsx)(`textarea`,{id:`channel-info-text`,name:`channel-info-text`,"aria-label":`Channel Info Text`,value:e.channelInfoText??``,onChange:e=>W(`channelInfoText`,e.target.value),placeholder:`Display Name or ...`,className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500 min-h-[40px] resize-y font-mono`,rows:2})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Position`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`top-left`),className:`h-8 rounded-md border flex items-start justify-start p-1 transition-all ${e.channelInfoPosition===`top-left`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Top Left`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`top-center`),className:`h-8 rounded-md border flex items-start justify-center p-1 transition-all ${e.channelInfoPosition===`top-center`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Top Center`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`top-right`),className:`h-8 rounded-md border flex items-start justify-end p-1 transition-all ${e.channelInfoPosition===`top-right`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Top Right`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`left-middle`),className:`h-8 rounded-md border flex items-center justify-start p-1 transition-all ${e.channelInfoPosition===`left-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Left Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`center-middle`),className:`h-8 rounded-md border flex items-center justify-center p-1 transition-all ${e.channelInfoPosition===`center-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Center Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`right-middle`),className:`h-8 rounded-md border flex items-center justify-end p-1 transition-all ${e.channelInfoPosition===`right-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Right Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`bottom-left`),className:`h-8 rounded-md border flex items-end justify-start p-1 transition-all ${e.channelInfoPosition===`bottom-left`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Bottom Left`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`bottom-center`),className:`h-8 rounded-md border flex items-end justify-center p-1 transition-all ${e.channelInfoPosition===`bottom-center`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Bottom Center`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoPosition`,`bottom-right`),className:`h-8 rounded-md border flex items-end justify-end p-1 transition-all ${e.channelInfoPosition===`bottom-right`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Bottom Right`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Style`}),(0,K.jsx)(Pp,{value:e.channelInfoStyle||`classic`,onChange:e=>W(`channelInfoStyle`,e),groups:kp})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Edge Margin`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.channelInfoMarginScale??1).toFixed(1),`x`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(he,{size:12})}),(0,K.jsx)(`input`,{type:`range`,name:`channel-margin`,"aria-label":`Channel Info Margin`,min:`0.0`,max:`5.0`,step:`0.1`,value:e.channelInfoMarginScale??1,onChange:e=>W(`channelInfoMarginScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Size`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.channelInfoSizeScale??1).toFixed(1),`x`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(he,{size:12})}),(0,K.jsx)(`input`,{type:`range`,name:`channel-size`,"aria-label":`Channel Info Size`,min:`0.5`,max:`3.0`,step:`0.1`,value:e.channelInfoSizeScale??1,onChange:e=>W(`channelInfoSizeScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Family`}),(0,K.jsx)(Ip,{value:e.channelInfoFontFamily||`sans-serif`,onChange:e=>W(`channelInfoFontFamily`,e),customFontName:D||null,groups:ie}),(0,K.jsx)(up,{onApply:e=>re(e,`channelInfoFontFamily`),placeholder:`Channel Font (e.g. Oswald)`}),(0,K.jsx)(`input`,{"aria-label":`Upload Channel Font`,ref:ce,type:`file`,name:`channel-font-upload`,id:`channel-font-upload`,accept:`.ttf,.otf,.woff,.woff2`,onChange:O,className:`hidden`}),D?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800/50 border border-purple-500/30 rounded-lg px-2 py-1.5 mt-1`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-purple-300 font-medium truncate flex-1`,children:D}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoFontFamily`,`ChannelFont`),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${e.channelInfoFontFamily===`ChannelFont`?`bg-purple-600 text-white`:`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`}`,children:`Use`}),(0,K.jsx)(`button`,{onClick:P,className:`text-zinc-500 hover:text-red-400`,children:(0,K.jsx)(Le,{size:12})})]}):(0,K.jsxs)(`button`,{onClick:()=>ce.current?.click(),className:`w-full flex items-center justify-center gap-2 bg-zinc-800/30 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-2 py-1.5 text-zinc-500 hover:text-purple-300 transition-colors mt-1`,children:[(0,K.jsx)(He,{size:10}),(0,K.jsx)(`span`,{className:`text-[10px]`,children:`Upload Font`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Style`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1 gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoFontWeight`,e.channelInfoFontWeight===`bold`?`normal`:`bold`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.channelInfoFontWeight===`bold`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Bold`,children:(0,K.jsx)(N,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`channelInfoFontStyle`,e.channelInfoFontStyle===`italic`?`normal`:`italic`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.channelInfoFontStyle===`italic`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Italic`,children:(0,K.jsx)(fe,{size:14})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{id:`channel-font-color`,type:`color`,name:`channel-font-color`,"aria-label":`Channel Font Color`,onChange:e=>W(`channelInfoFontColor`,e.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-mono uppercase`,children:e.channelInfoFontColor||`#ffffff`})]})]})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(ue,{size:14}),` Floating Notes / Media`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-zinc-400 hover:text-zinc-200 cursor-pointer select-none`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.randomizeFloatingNotes!==!1,onChange:e=>W(`randomizeFloatingNotes`,e.target.checked),className:`w-3 h-3 rounded border-white/10 bg-zinc-800 text-purple-600 focus:ring-0 cursor-pointer`}),(0,K.jsx)(`span`,{children:`Random`})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800/30 border border-white/5 rounded-lg p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between cursor-pointer`,children:[(0,K.jsx)(`label`,{htmlFor:`show-floating-notes`,className:`text-xs text-zinc-300 font-medium cursor-pointer`,children:`Show Floating Notes`}),(0,K.jsxs)(`div`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`show-floating-notes`,name:`show-floating-notes`,"aria-label":`Show Floating Notes`,checked:e.showFloatingNotes??!1,onChange:e=>W(`showFloatingNotes`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`label`,{htmlFor:`show-floating-notes`,className:`w-8 h-4 bg-zinc-700 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-purple-600 block cursor-pointer`})]})]}),e.showFloatingNotes&&(0,K.jsxs)(`div`,{className:`space-y-3 animate-in slide-in-from-top-1 fade-in duration-200 pt-2 border-t border-white/5`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Layout`}),(0,K.jsx)(Pp,{value:e.floatingNotesLayout||`text-only`,onChange:e=>W(`floatingNotesLayout`,e),groups:Ap})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Visibility Duration`}),(0,K.jsx)(Pp,{value:e.floatingNotesVisibilityMode??`all`,onChange:e=>W(`floatingNotesVisibilityMode`,e),groups:jp})]}),(e.floatingNotesVisibilityMode??`all`)===`follow-lyrics`&&(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500 leading-relaxed px-1`,children:`Notes appear and hide together with lyrics, respecting Default or Auto lyric visibility mode and timestamps.`}),(e.floatingNotesVisibilityMode??`all`)===`from-start`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`floating-notes-from-start`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Show For (seconds from start)`}),(0,K.jsx)(`input`,{id:`floating-notes-from-start`,type:`number`,min:`0`,step:`0.1`,value:e.floatingNotesFromStartDuration??10,onChange:e=>W(`floatingNotesFromStartDuration`,Math.max(0,parseFloat(e.target.value)||0)),className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500`})]}),(e.floatingNotesVisibilityMode??`all`)===`from-end`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`floating-notes-from-end`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Show For (seconds before audio ends)`}),(0,K.jsx)(`input`,{id:`floating-notes-from-end`,type:`number`,min:`0`,step:`0.1`,value:e.floatingNotesFromEndDuration??10,onChange:e=>W(`floatingNotesFromEndDuration`,Math.max(0,parseFloat(e.target.value)||0)),className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500`})]}),(e.floatingNotesVisibilityMode??`all`)===`from-start-and-end`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`floating-notes-from-start-combined`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`From Start (sec)`}),(0,K.jsx)(`input`,{id:`floating-notes-from-start-combined`,type:`number`,min:`0`,step:`0.1`,value:e.floatingNotesFromStartDuration??10,onChange:e=>W(`floatingNotesFromStartDuration`,Math.max(0,parseFloat(e.target.value)||0)),className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`floating-notes-from-end-combined`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Before End (sec)`}),(0,K.jsx)(`input`,{id:`floating-notes-from-end-combined`,type:`number`,min:`0`,step:`0.1`,value:e.floatingNotesFromEndDuration??10,onChange:e=>W(`floatingNotesFromEndDuration`,Math.max(0,parseFloat(e.target.value)||0)),className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500`})]})]}),(e.floatingNotesVisibilityMode??`all`)===`specific`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`floating-notes-specific-start`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Start`}),(0,K.jsx)(`input`,{id:`floating-notes-specific-start`,type:`text`,placeholder:`0:00.000`,value:e.floatingNotesSpecificStart??`0:00`,onChange:e=>W(`floatingNotesSpecificStart`,e.target.value),className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 font-mono focus:outline-none focus:ring-1 focus:ring-purple-500`}),(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500 ml-1`,children:`(hh:mm:ss.xxx)`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`floating-notes-specific-end`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`End`}),(0,K.jsx)(`input`,{id:`floating-notes-specific-end`,type:`text`,placeholder:`0:30.000`,value:e.floatingNotesSpecificEnd??`0:30`,onChange:e=>W(`floatingNotesSpecificEnd`,e.target.value),className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 font-mono focus:outline-none focus:ring-1 focus:ring-purple-500`}),(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500 ml-1`,children:`(hh:mm:ss.xxx)`})]})]}),e.floatingNotesLayout!==`text-only`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Upload Media (Image/Video)`}),(0,K.jsx)(`input`,{ref:pe,type:`file`,accept:`image/*,video/*`,onChange:je,className:`hidden`}),e.floatingNotesMedia?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800 p-2 rounded-lg border border-white/10`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-zinc-700/50 flex items-center justify-center overflow-hidden border border-white/5`,children:e.floatingNotesMediaType===`video`?(0,K.jsx)(`video`,{src:e.floatingNotesMedia,className:`w-full h-full object-cover`,muted:!0}):(0,K.jsx)(`img`,{src:e.floatingNotesMedia,alt:`Notes Media`,className:`w-full h-full object-cover`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-300 truncate`,children:`Media Loaded`}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesMedia`,void 0),className:`text-[10px] text-red-400 hover:text-red-300`,children:`Remove`})]}),(0,K.jsx)(`button`,{onClick:()=>pe.current?.click(),className:`p-1.5 hover:bg-white/10 rounded-md text-zinc-400 hover:text-white`,children:(0,K.jsx)(Oe,{size:14})})]}):(0,K.jsxs)(`button`,{onClick:()=>pe.current?.click(),className:`w-full flex items-center justify-center gap-2 bg-zinc-800/50 border border-dashed border-white/10 hover:border-purple-500/50 rounded-lg px-3 py-3 text-zinc-400 hover:text-purple-300 transition-colors`,children:[(0,K.jsx)(He,{size:14}),(0,K.jsx)(`span`,{className:`text-xs`,children:`Upload Media`})]})]}),e.floatingNotesLayout!==`media-only`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{htmlFor:`floating-notes-text`,className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Notes Text`}),(0,K.jsx)(`textarea`,{id:`floating-notes-text`,value:e.floatingNotesText??``,onChange:e=>W(`floatingNotesText`,e.target.value),placeholder:`Enter note details...`,className:`w-full bg-zinc-900 border border-white/10 rounded-md px-3 py-2 text-xs text-zinc-200 focus:outline-none focus:ring-1 focus:ring-purple-500 min-h-[60px] resize-y`,rows:3})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Position`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`top-left`),className:`h-8 rounded-md border flex items-start justify-start p-1 transition-all ${e.floatingNotesPosition===`top-left`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Top Left`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`top-center`),className:`h-8 rounded-md border flex items-start justify-center p-1 transition-all ${e.floatingNotesPosition===`top-center`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Top Center`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`top-right`),className:`h-8 rounded-md border flex items-start justify-end p-1 transition-all ${e.floatingNotesPosition===`top-right`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Top Right`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`left-middle`),className:`h-8 rounded-md border flex items-center justify-start p-1 transition-all ${e.floatingNotesPosition===`left-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Left Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`center-middle`),className:`h-8 rounded-md border flex items-center justify-center p-1 transition-all ${e.floatingNotesPosition===`center-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Center Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`right-middle`),className:`h-8 rounded-md border flex items-center justify-end p-1 transition-all ${e.floatingNotesPosition===`right-middle`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Right Middle`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`bottom-left`),className:`h-8 rounded-md border flex items-end justify-start p-1 transition-all ${e.floatingNotesPosition===`bottom-left`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Bottom Left`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`bottom-center`),className:`h-8 rounded-md border flex items-end justify-center p-1 transition-all ${e.floatingNotesPosition===`bottom-center`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Bottom Center`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesPosition`,`bottom-right`),className:`h-8 rounded-md border flex items-end justify-end p-1 transition-all ${e.floatingNotesPosition===`bottom-right`?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:border-white/20`}`,title:`Bottom Right`,children:(0,K.jsx)(`div`,{className:`w-2 h-2 bg-current rounded-sm`})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Shape Style`}),(0,K.jsx)(Pp,{value:e.floatingNotesShape||`rounded`,onChange:e=>W(`floatingNotesShape`,e),groups:Mp})]}),e.floatingNotesShape!==`none`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Fill Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-900 border border-white/10 rounded-md p-1`,children:[(0,K.jsx)(`input`,{type:`color`,value:e.floatingNotesFillColor||`#000000`,onChange:e=>W(`floatingNotesFillColor`,e.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border-none`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-mono uppercase`,children:e.floatingNotesFillColor||`#000000`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Outline Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-900 border border-white/10 rounded-md p-1`,children:[(0,K.jsx)(`input`,{type:`color`,value:e.floatingNotesOutlineColor||`#ffffff`,onChange:e=>W(`floatingNotesOutlineColor`,e.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border-none`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-mono uppercase`,children:e.floatingNotesOutlineColor||`#ffffff`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Outline Size`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[e.floatingNotesOutlineSize??1,`px`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(he,{size:12})}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:`10`,step:`1`,value:e.floatingNotesOutlineSize??1,onChange:e=>W(`floatingNotesOutlineSize`,parseInt(e.target.value,10)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]})]}),e.floatingNotesLayout!==`text-only`&&e.floatingNotesLayout!==`media-only`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Media Size`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[Math.round((e.floatingNotesMediaSizeScale??.4)*100),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(he,{size:12})}),(0,K.jsx)(`input`,{type:`range`,min:`0.1`,max:`0.9`,step:`0.05`,value:e.floatingNotesMediaSizeScale??.4,onChange:e=>W(`floatingNotesMediaSizeScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),e.floatingNotesLayout!==`media-only`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Size`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.floatingNotesFontSizeScale??1).toFixed(1),`x`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(ze,{size:12})}),(0,K.jsx)(`input`,{type:`range`,min:`0.5`,max:`3.0`,step:`0.1`,value:e.floatingNotesFontSizeScale??1,onChange:e=>W(`floatingNotesFontSizeScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Opacity`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[Math.round((e.floatingNotesOpacity??.8)*100),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(Me,{size:12})}),(0,K.jsx)(`input`,{type:`range`,min:`0.0`,max:`1.0`,step:`0.05`,value:e.floatingNotesOpacity??.8,onChange:e=>W(`floatingNotesOpacity`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Edge Margin`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[(e.floatingNotesMarginScale??1).toFixed(1),`x`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:(0,K.jsx)(he,{size:12})}),(0,K.jsx)(`input`,{type:`range`,min:`0.0`,max:`5.0`,step:`0.1`,value:e.floatingNotesMarginScale??1,onChange:e=>W(`floatingNotesMarginScale`,parseFloat(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Width`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[e.floatingNotesWidth??300,`px`]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,min:`100`,max:`800`,step:`10`,value:e.floatingNotesWidth??300,onChange:e=>W(`floatingNotesWidth`,parseInt(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Height`}),(0,K.jsxs)(`span`,{className:`text-[10px] text-zinc-400 font-mono`,children:[e.floatingNotesHeight??150,`px`]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 bg-zinc-800 border border-white/10 rounded-lg px-2 py-1.5`,children:(0,K.jsx)(`input`,{type:`range`,min:`50`,max:`600`,step:`10`,value:e.floatingNotesHeight??150,onChange:e=>W(`floatingNotesHeight`,parseInt(e.target.value)),className:`w-full h-1 bg-zinc-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-white [&::-webkit-slider-thumb]:rounded-full hover:[&::-webkit-slider-thumb]:bg-purple-400 transition-all`})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Family`}),(0,K.jsx)(Ip,{value:e.floatingNotesFontFamily||`sans-serif`,onChange:e=>W(`floatingNotesFontFamily`,e),customFontName:null,groups:ie}),(0,K.jsx)(up,{onApply:e=>re(e,`floatingNotesFontFamily`),placeholder:`Notes Font (e.g. Roboto)`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Align`}),(0,K.jsx)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1`,children:[`left`,`center`,`right`].map(t=>(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesTextAlign`,t),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${e.floatingNotesTextAlign===t?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,children:t},t))})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Font Style`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1 gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesFontWeight`,e.floatingNotesFontWeight===`bold`?`normal`:`bold`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.floatingNotesFontWeight===`bold`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Bold`,children:(0,K.jsx)(N,{size:14})}),(0,K.jsx)(`button`,{onClick:()=>W(`floatingNotesFontStyle`,e.floatingNotesFontStyle===`italic`?`normal`:`italic`),className:`flex-1 py-1.5 rounded-md flex items-center justify-center transition-all ${e.floatingNotesFontStyle===`italic`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,title:`Italic`,children:(0,K.jsx)(fe,{size:14})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Text Color`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 bg-zinc-800/30 p-2 rounded-lg border border-white/5`,children:[(0,K.jsx)(`input`,{type:`color`,value:e.floatingNotesFontColor||`#ffffff`,onChange:e=>W(`floatingNotesFontColor`,e.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border-none shrink-0`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-400 font-mono uppercase`,children:e.floatingNotesFontColor||`#ffffff`})]})]})]})]})]}),(0,K.jsxs)(`section`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`pt-2 border-t border-white/5 space-y-3`,children:[(0,K.jsxs)(`h3`,{className:`text-xs font-bold text-zinc-500 uppercase tracking-wider flex items-center gap-2`,children:[(0,K.jsx)(We,{size:14}),` Output Settings`]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Resolution`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1`,children:[(0,K.jsx)(`button`,{onClick:()=>f(`720p`),className:`flex-1 py-1 px-2 rounded-md text-[10px] font-bold transition-all ${d===`720p`?`bg-zinc-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,children:`720p`}),(0,K.jsx)(`button`,{onClick:()=>f(`1080p`),className:`flex-1 py-1 px-2 rounded-md text-[10px] font-bold transition-all ${d===`1080p`?`bg-purple-600 text-white shadow-sm`:`text-zinc-500 hover:text-zinc-300`}`,children:`1080p`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`FPS`}),(0,K.jsx)(Pp,{value:String(b),onChange:e=>x(parseInt(e)),groups:Np})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Aspect Ratio`}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:[`16:9`,`9:16`,`1:1`,`4:5`,`3:4`,`4:3`,`2:3`,`3:2`,`1:2`,`2:1`,`20:9`,`21:9`].map(e=>(0,K.jsx)(`button`,{onClick:()=>m(e),className:`py-1.5 rounded-md text-[10px] font-mono transition-all border ${p===e?`bg-purple-600 border-purple-500 text-white`:`bg-zinc-800 border-white/5 text-zinc-500 hover:bg-zinc-700 hover:text-zinc-300`}`,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Render Engine`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1 gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>C(`mediarecorder`),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${S===`mediarecorder`?`bg-purple-600 text-white`:`text-zinc-500 hover:text-zinc-300`}`,title:`Uses browser's MediaRecorder API. Renders in realtime while playing audio.`,children:`Realtime`}),(0,K.jsx)(`button`,{onClick:()=>C(`webcodecs`),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${S===`webcodecs`?`bg-blue-600 text-white`:`text-zinc-500 hover:text-zinc-300`}`,title:`Uses WebCodecs API. Hardware accelerated rendering. Fastest option.`,children:`WebCodecs`}),(0,K.jsx)(`button`,{onClick:()=>C(`ffmpeg`),className:`flex-1 py-2 rounded-md text-[10px] font-bold uppercase transition-all ${S===`ffmpeg`?`bg-orange-500 text-white`:`text-zinc-500 hover:text-zinc-300`}`,title:`Uses FFmpeg WASM. Frame-by-frame rendering with professional codecs.`,children:`FFmpeg`})]}),(0,K.jsx)(`p`,{className:`text-[9px] text-zinc-600 ml-1 leading-tight`,children:S===`mediarecorder`?`Realtime recording. Fast but quality depends on browser.`:S===`webcodecs`?`Hardware accelerated (GPU). Very fast export with simple MP4.`:`Software rendering. High compatiblity but slower.`})]}),S===`mediarecorder`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Video Codec`}),(0,K.jsx)(Pp,{value:h,onChange:e=>g(e),groups:[{label:`Format`,options:[{label:`Auto Select (Best)`,value:`auto`},..._]}]})]}),S===`ffmpeg`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`FFmpeg Codec`}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,children:[{label:`H.264`,value:`h264`,desc:`Best Compatibility`},{label:`H.265`,value:`h265`,desc:`Higher Quality`}].map(e=>(0,K.jsxs)(`button`,{onClick:()=>E(e.value),className:`py-2 px-2 rounded-md text-[10px] font-medium transition-all border text-left ${T===e.value?`bg-orange-500 border-orange-400 text-white`:`bg-zinc-800 border-white/5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200`}`,title:e.desc,children:[(0,K.jsx)(`div`,{className:`font-bold`,children:e.label}),(0,K.jsx)(`div`,{className:`text-[8px] opacity-75`,children:e.desc})]},e.value))})]}),S===`webcodecs`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Video Codec`}),(0,K.jsx)(`div`,{className:`p-2 bg-zinc-800/50 rounded border border-white/5 text-[10px] text-zinc-400`,children:`H.264 / AAC (Hardware Accelerated)`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 font-bold uppercase ml-1`,children:`Render Quality (Bitrate)`}),(0,K.jsxs)(`div`,{className:`flex bg-zinc-800 rounded-lg p-1`,children:[(0,K.jsx)(`button`,{onClick:()=>y(`low`),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${v===`low`?`bg-zinc-600 text-white`:`text-zinc-500 hover:text-zinc-300`}`,children:`Low`}),(0,K.jsx)(`button`,{onClick:()=>y(`med`),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${v===`med`?`bg-zinc-600 text-white`:`text-zinc-500 hover:text-zinc-300`}`,children:`Medium`}),(0,K.jsx)(`button`,{onClick:()=>y(`high`),className:`flex-1 py-1.5 rounded-md text-[10px] font-bold uppercase transition-all ${v===`high`?`bg-purple-600 text-white`:`text-zinc-500 hover:text-zinc-300`}`,children:`High`})]})]})]}),(0,K.jsx)(`div`,{className:`pt-2 border-t border-white/5`,children:(0,K.jsxs)(`p`,{className:`text-[10px] text-zinc-500 italic leading-relaxed`,children:[(0,K.jsx)(`span`,{className:`text-purple-400 font-bold`,children:`*Tip:`}),` You can backup your current configuration using the `,(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Export`}),` button above.`]})})]})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-white/10 bg-zinc-900/50 space-y-3`,children:[(0,K.jsxs)(`button`,{onClick:s,className:`w-full py-2.5 rounded-lg bg-purple-600 hover:bg-purple-500 text-white font-bold text-sm shadow-lg shadow-purple-500/20 active:scale-95 transition-all flex items-center justify-center gap-2`,children:[(0,K.jsx)(We,{size:16}),` Start Render`]}),(0,K.jsx)(`p`,{className:`text-[10px] text-zinc-500 text-center leading-relaxed italic`,children:`These settings will be applied to the final video. Ensure all sources are loaded correctly.`})]})]})};function zp(e){let t=e.replace(`#`,``);return[parseInt(t.substring(0,2),16)||0,parseInt(t.substring(2,4),16)||0,parseInt(t.substring(4,6),16)||0]}function Bp(e,t,n,r,i,a,o,s){let c=t>1?e/(t-1):0;switch(r){case`rainbow`:return`hsla(${(c*360+s*.05)%360}, 80%, ${55+n*15}%, ${o})`;case`accent`:return`hsla(270, 80%, ${50+n*20}%, ${o})`;case`custom`:{let[e,t,n]=zp(i),[r,s,l]=zp(a);return`rgba(${Math.round(e+(r-e)*c)}, ${Math.round(t+(s-t)*c)}, ${Math.round(n+(l-n)*c)}, ${o})`}default:return`hsla(${260+c*60}, 75%, ${50+n*15}%, ${o})`}}function Vp(e){return{type:e.visualizationType||`bars`,colorMode:e.visualizationColorMode||`gradient`,color1:e.visualizationColor1||`#a855f7`,color2:e.visualizationColor2||`#6366f1`,opacity:e.visualizationOpacity??.6,position:e.visualizationPosition||`bottom`,sensitivity:e.visualizationSensitivity??1.5,barCount:e.visualizationBarCount??48}}function Hp(e,t,n,r,i,a,o){let{type:s,sensitivity:c,barCount:l}=a,u=Up(t)/255;e.save();let d=Wp(a.position,r,i);switch(e.beginPath(),e.rect(d.x,d.y,d.w,d.h),e.clip(),s){case`bars`:Kp(e,t,d,a,o);break;case`wave`:qp(e,n||t,d,a,o);break;case`circular`:Jp(e,t,d,a,o,u);break;case`particles`:Yp(e,t,d,a,o,u);break;case`pulse-ring`:Xp(e,t,n,d,a,o,u);break;case`waveform`:rm(e,n||t,d,a,o);break;case`spectrum`:nm(e,t,d,a,o);break;case`spectrogram`:tm(e,t,d,a,o);break;case`stereo-field`:im(e,n||t,d,a,o);break}e.restore()}function Up(e){let t=0;for(let n=0;n{let t=Math.sin(e*127.1+e*311.7)*43758.5453;return t-Math.floor(t)},h=Math.min(80,Math.floor(l*40+10));for(let t=0;tn.x+n.w||yn.y+n.h)continue;let b=(1+d*3)*(1-p*.6),x=(1-p)*d*r.opacity*.6;x<.03||(e.globalAlpha=x,e.fillStyle=Gp(r,u/t.length,1,d,i),e.beginPath(),e.arc(v,y,b,0,Math.PI*2),e.fill())}let _=Math.min(15,Math.floor(d*8+3));for(let t=0;t<_;t++){let a=m(t*31.1+200),s=m(t*17.3+200.5),c=m(t*9.7+200.9),l=Math.sin(o*(.3+a*.5)+t*2.1)*n.w*.3,u=Math.cos(o*(.2+s*.3)+t*1.7)*n.h*.2,f=n.x+a*n.w+l,p=n.y+s*n.h+u;if(fn.x+n.w||pn.y+n.h)continue;let h=1+Math.sin(o*3+c*10)*.3*d,g=(3+c*5)*h;e.globalAlpha=(.08+d*.15)*r.opacity;let _=e.createRadialGradient(f,p,0,f,p,g),v=Gp(r,a,1,.7,i);_.addColorStop(0,v),_.addColorStop(.5,v.replace(/[\d.]+\)$/,`0.3)`)),_.addColorStop(1,v.replace(/[\d.]+\)$/,`0)`)),e.fillStyle=_,e.beginPath(),e.arc(f,p,g,0,Math.PI*2),e.fill()}if(l>.5){let t=o*.8%1,a=t*Math.min(n.w,n.h)*.45,s=(1-t)*(l-.5)*r.opacity*.5;if(s>.03){let o=n.x+n.w/2,c=n.y+n.h/2;e.globalAlpha=s,e.beginPath(),e.arc(o,c,a,0,Math.PI*2),e.strokeStyle=Gp(r,0,1,l,i),e.lineWidth=2+(1-t)*3,e.stroke()}}e.globalAlpha=1}function Xp(e,t,n,r,i,a,o){let s=r.x+r.w/2,c=r.y+r.h/2,l=Math.min(r.w,r.h)*.4,u=a*.001;for(let t=0;t<3;t++){let n=(u*.5+t*.3)%1,r=l*(.3+n*.7)*(1+o*i.sensitivity*.3),d=(1-n)*i.opacity*.5;e.beginPath(),e.arc(s,c,r,0,Math.PI*2),e.strokeStyle=Gp(i,t/3,3,o,a),e.lineWidth=2+o*3,e.globalAlpha=d,e.stroke()}if(e.globalAlpha=1,n){let t=l*.35*(1+o*i.sensitivity*.2),r=Math.min(i.barCount,n.length);e.beginPath();for(let a=0;a<=r;a++){let o=(n[Math.floor(a*(n.length/r))]/128-1)*i.sensitivity,u=a/r*Math.PI*2-Math.PI/2,d=t+o*l*.15,f=s+Math.cos(u)*d,p=c+Math.sin(u)*d;a===0?e.moveTo(f,p):e.lineTo(f,p)}e.closePath(),e.strokeStyle=Gp(i,0,1,o,a),e.lineWidth=2,e.stroke()}}var Zp=null,Qp=null,$p=-1;function em(e,t){return(!Zp||Zp.width!==e||Zp.height!==t)&&(typeof OffscreenCanvas<`u`?Zp=new OffscreenCanvas(e,t):(Zp=document.createElement(`canvas`),Zp.width=e,Zp.height=t),Qp=Zp.getContext(`2d`,{willReadFrequently:!0}),Qp&&(Qp.fillStyle=`#000000`,Qp.fillRect(0,0,e,t))),{specCanvas:Zp,specCtx:Qp}}function tm(e,t,n,r,i){let{specCanvas:a,specCtx:o}=em(n.w,n.h);if(i!==$p){$p=i,o.drawImage(a,0,0,n.w,n.h-2,0,2,n.w,n.h-2);let e=t.length,s=n.w/e;for(let n=0;n=0;r--){let i=t[r]/128,c=Math.abs(i-1);e.lineTo(n.x+r*s,a+c*o)}e.closePath(),e.fillStyle=Gp(r,.5,1,.8,i),e.fill()}function im(e,t,n,r,i){let a=n.x+n.w/2,o=n.y+n.h/2,s=Math.min(n.w,n.h)*.45*r.sensitivity;e.beginPath(),e.strokeStyle=Gp(r,.5,1,.8,i),e.lineWidth=2;let c=Math.max(1,Math.floor(t.length*.02)),l=!1,u=!1;for(let e=0;e<10;e++)t[e]!==128&&(u=!0);if(!u){e.arc(a,o,2,0,Math.PI*2),e.fillStyle=e.strokeStyle,e.fill();return}for(let n=c;n=0&&n=0&&n((!om||om.state===`closed`)&&(om=new(window.AudioContext||window.webkitAudioContext)),om),lm=(e,t=cm())=>{if(sm.has(e))return sm.get(e);let n=t.createMediaElementSource(e);return sm.set(e,n),n},um=null,dm=null,fm=null,pm=null,mm=null;function hm(){try{dm&&dm.disconnect(),um&&=(um.disconnect(),null),fm=null,pm=null,mm=null}catch(e){console.warn(`AudioVisualizer: disconnect failed`,e)}}var gm=({audioElement:e,config:t,isPlaying:n})=>{let r=(0,w.useRef)(null),i=(0,w.useRef)(0),a=(0,w.useRef)(0);return(0,w.useEffect)(()=>{if(!e)return;let t=cm();if(!(fm===e&&um)){try{um=t.createAnalyser(),um.fftSize=512,um.smoothingTimeConstant=.8,fm!==e&&(dm=lm(e,t)),dm&&(dm.disconnect(),dm.connect(um),um.connect(t.destination));let n=um.frequencyBinCount;pm=new Uint8Array(n),mm=new Uint8Array(n),fm=e}catch(e){console.warn(`AudioVisualizer: Failed to connect audio context`,e)}return()=>{}}},[e]),(0,w.useEffect)(()=>{let e=cm();n&&e&&e.state===`suspended`&&e.resume()},[n]),(0,w.useEffect)(()=>{if(!t.showVisualization)return;let e=r.current;if(!e)return;let n=e.getContext(`2d`,{alpha:!0});if(!n)return;let o=!0,s=r=>{if(!o||(i.current=requestAnimationFrame(s),r-a.current<33))return;a.current=r;let c=e.getBoundingClientRect(),l=Math.min(window.devicePixelRatio||1,2),u=Math.round(c.width*l),d=Math.round(c.height*l);(e.width!==u||e.height!==d)&&(e.width=u,e.height=d);let f=c.width,p=c.height;if(n.setTransform(l,0,0,l,0,0),n.clearRect(0,0,f,p),!um||!pm||!mm)return;um.getByteFrequencyData(pm);let m=Vp(t),h=[`wave`,`pulse-ring`,`waveform`,`stereo-field`].includes(m.type);h&&um.getByteTimeDomainData(mm),Hp(n,pm,h?mm:null,f,p,m,r)};return i.current=requestAnimationFrame(s),()=>{o=!1,cancelAnimationFrame(i.current)}},[t.showVisualization,t.visualizationType,t.visualizationColorMode,t.visualizationColor1,t.visualizationColor2,t.visualizationOpacity,t.visualizationPosition,t.visualizationSensitivity,t.visualizationBarCount]),t.showVisualization?(0,K.jsx)(`canvas`,{ref:r,className:`absolute inset-0 w-full h-full pointer-events-none z-[5]`}):null},_m=1e3,vm=1001,ym=1002,bm=1003,xm=1004,Sm=1005,Cm=1006,wm=1007,Tm=1008,Em=1009,Dm=1010,Om=1011,km=1012,Am=1013,jm=1014,Mm=1015,Nm=1016,Pm=1017,Fm=1018,Im=1020,Lm=35902,Rm=35899,zm=1021,Bm=1022,Vm=1023,Hm=1026,Um=1027,Wm=1028,Gm=1029,Km=1030,qm=1031,Jm=1033,Ym=33776,Xm=33777,Zm=33778,Qm=33779,$m=35840,eh=35841,th=35842,nh=35843,rh=36196,ih=37492,ah=37496,oh=37488,sh=37489,ch=37490,lh=37491,uh=37808,dh=37809,fh=37810,ph=37811,mh=37812,hh=37813,gh=37814,_h=37815,vh=37816,yh=37817,bh=37818,xh=37819,Sh=37820,Ch=37821,wh=36492,Th=36494,Eh=36495,Dh=36283,Oh=36284,kh=36285,Ah=36286,jh=2300,Mh=2301,Nh=2302,Ph=2303,Fh=2400,Ih=2401,Lh=2402,Rh=3200,zh=`srgb`,Bh=`srgb-linear`,Vh=`linear`,Hh=`srgb`,Uh=7680,Wh=35044,Gh=2e3;function Kh(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function qh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Jh(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function Yh(){let e=Jh(`canvas`);return e.style.display=`block`,e}var Xh={},Zh=null;function Qh(...e){let t=`THREE.`+e.shift();Zh?Zh(`log`,t,...e):console.log(t,...e)}function $h(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function eg(...e){e=$h(e);let t=`THREE.`+e.shift();if(Zh)Zh(`warn`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function tg(...e){e=$h(e);let t=`THREE.`+e.shift();if(Zh)Zh(`error`,t,...e);else{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function ng(...e){let t=e.join(` `);t in Xh||(Xh[t]=!0,eg(...e))}function rg(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var ig={0:1,2:6,4:7,3:5,1:0,6:2,7:4,5:3},ag=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let t=n.slice(0);for(let n=0,r=t.length;n>8&255]+og[e>>16&255]+og[e>>24&255]+`-`+og[t&255]+og[t>>8&255]+`-`+og[t>>16&15|64]+og[t>>24&255]+`-`+og[n&63|128]+og[n>>8&255]+`-`+og[n>>16&255]+og[n>>24&255]+og[r&255]+og[r>>8&255]+og[r>>16&255]+og[r>>24&255]).toLowerCase()}function ug(e,t,n){return Math.max(t,Math.min(n,e))}function dg(e,t){return(e%t+t)%t}function fg(e,t,n){return(1-n)*e+n*t}function pg(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function mg(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var hg=class e{static{e.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=ug(this.x,e.x,t.x),this.y=ug(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ug(this.x,e,t),this.y=ug(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ug(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ug(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},gg=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:eg(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ug(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},X=class e{static{e.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(vg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(vg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=ug(this.x,e.x,t.x),this.y=ug(this.y,e.y,t.y),this.z=ug(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ug(this.x,e,t),this.y=ug(this.y,e,t),this.z=ug(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(ug(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return _g.copy(this).projectOnVector(e),this.sub(_g)}reflect(e){return this.sub(_g.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ug(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},_g=new X,vg=new gg,yg=class e{static{e.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(bg.makeScale(e,t)),this}rotate(e){return this.premultiply(bg.makeRotation(-e)),this}translate(e,t){return this.premultiply(bg.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},bg=new yg,xg=new yg().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Sg=new yg().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Cg(){let e={enabled:!0,workingColorSpace:Bh,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n?e:(this.spaces[t].transfer===`srgb`&&(e.r=Tg(e.r),e.g=Tg(e.g),e.b=Tg(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Eg(e.r),e.g=Eg(e.g),e.b=Eg(e.b)),e)},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?Vh:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,n){return ng(`ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace().`),e.workingToColorSpace(t,n)},toWorkingColorSpace:function(t,n){return ng(`ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking().`),e.colorSpaceToWorking(t,n)}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Bh]:{primaries:t,whitePoint:r,transfer:Vh,toXYZ:xg,fromXYZ:Sg,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:zh},outputColorSpaceConfig:{drawingBufferColorSpace:zh}},[zh]:{primaries:t,whitePoint:r,transfer:Hh,toXYZ:xg,fromXYZ:Sg,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:zh}}}),e}var wg=Cg();function Tg(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Eg(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Dg,Og=class{static getDataURL(e,t=`image/png`){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Dg===void 0&&(Dg=Jh(`canvas`)),Dg.width=e.width,Dg.height=e.height;let t=Dg.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Dg}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=Jh(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Ng).x}get height(){return this.source.getSize(Ng).y}get depth(){return this.source.getSize(Ng).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){eg(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){eg(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:`Texture`,generator:`Texture.toJSON`},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case _m:e.x-=Math.floor(e.x);break;case vm:e.x=e.x<0?0:1;break;case ym:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case _m:e.y-=Math.floor(e.y);break;case vm:e.y=e.y<0?0:1;break;case ym:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Pg.DEFAULT_IMAGE=null,Pg.DEFAULT_MAPPING=300,Pg.DEFAULT_ANISOTROPY=1;var Fg=class e{static{e.prototype.isVector4=!0}constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot===null?null:e.pivot.clone(),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(h_)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new m_;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},__={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},v_={h:0,s:0,l:0},y_={h:0,s:0,l:0};function b_(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var x_=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=zh){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,wg.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=wg.workingColorSpace){return this.r=e,this.g=t,this.b=n,wg.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=wg.workingColorSpace){if(e=dg(e,1),t=ug(t,0,1),n=ug(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=b_(i,r,e+1/3),this.g=b_(i,r,e),this.b=b_(i,r,e-1/3)}return wg.colorSpaceToWorking(this,r),this}setStyle(e,t=zh){function n(t){t!==void 0&&parseFloat(t)<1&&eg(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:eg(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);eg(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=zh){let n=__[e.toLowerCase()];return n===void 0?eg(`Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Tg(e.r),this.g=Tg(e.g),this.b=Tg(e.b),this}copyLinearToSRGB(e){return this.r=Eg(e.r),this.g=Eg(e.g),this.b=Eg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=zh){return wg.workingToColorSpace(S_.copy(this),e),Math.round(ug(S_.r*255,0,255))*65536+Math.round(ug(S_.g*255,0,255))*256+Math.round(ug(S_.b*255,0,255))}getHexString(e=zh){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=wg.workingColorSpace){wg.workingToColorSpace(S_.copy(this),t);let n=S_.r,r=S_.g,i=S_.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},w_=new X,T_=new X,E_=new X,D_=new X,O_=new X,k_=new X,A_=new X,j_=new X,M_=new X,N_=new X,P_=new Fg,F_=new Fg,I_=new Fg,L_=class e{constructor(e=new X,t=new X,n=new X){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),w_.subVectors(e,t),r.cross(w_);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){w_.subVectors(r,t),T_.subVectors(n,t),E_.subVectors(e,t);let a=w_.dot(w_),o=w_.dot(T_),s=w_.dot(E_),c=T_.dot(T_),l=T_.dot(E_),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,D_)===null?!1:D_.x>=0&&D_.y>=0&&D_.x+D_.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,D_)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,D_.x),s.addScaledVector(a,D_.y),s.addScaledVector(o,D_.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return P_.setScalar(0),F_.setScalar(0),I_.setScalar(0),P_.fromBufferAttribute(e,t),F_.fromBufferAttribute(e,n),I_.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(P_,i.x),a.addScaledVector(F_,i.y),a.addScaledVector(I_,i.z),a}static isFrontFacing(e,t,n,r){return w_.subVectors(n,t),T_.subVectors(e,t),w_.cross(T_).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return w_.subVectors(this.c,this.b),T_.subVectors(this.a,this.b),w_.cross(T_).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;O_.subVectors(r,n),k_.subVectors(i,n),j_.subVectors(e,n);let s=O_.dot(j_),c=k_.dot(j_);if(s<=0&&c<=0)return t.copy(n);M_.subVectors(e,r);let l=O_.dot(M_),u=k_.dot(M_);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(O_,a);N_.subVectors(e,i);let f=O_.dot(N_),p=k_.dot(N_);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(k_,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return A_.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(A_,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(O_,a).addScaledVector(k_,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},R_=class{constructor(e=new X(1/0,1/0,1/0),t=new X(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,B_),B_.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(J_),Y_.subVectors(this.max,J_),H_.subVectors(e.a,J_),U_.subVectors(e.b,J_),W_.subVectors(e.c,J_),G_.subVectors(U_,H_),K_.subVectors(W_,U_),q_.subVectors(H_,W_);let t=[0,-G_.z,G_.y,0,-K_.z,K_.y,0,-q_.z,q_.y,G_.z,0,-G_.x,K_.z,0,-K_.x,q_.z,0,-q_.x,-G_.y,G_.x,0,-K_.y,K_.x,0,-q_.y,q_.x,0];return!Q_(t,H_,U_,W_,Y_)||(t=[1,0,0,0,1,0,0,0,1],!Q_(t,H_,U_,W_,Y_))?!1:(X_.crossVectors(G_,K_),t=[X_.x,X_.y,X_.z],Q_(t,H_,U_,W_,Y_))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,B_).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(B_).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(z_[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),z_[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),z_[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),z_[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),z_[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),z_[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),z_[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),z_[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(z_),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},z_=[new X,new X,new X,new X,new X,new X,new X,new X],B_=new X,V_=new R_,H_=new X,U_=new X,W_=new X,G_=new X,K_=new X,q_=new X,J_=new X,Y_=new X,X_=new X,Z_=new X;function Q_(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Z_.fromArray(e,a);let o=i.x*Math.abs(Z_.x)+i.y*Math.abs(Z_.y)+i.z*Math.abs(Z_.z),s=t.dot(Z_),c=n.dot(Z_),l=r.dot(Z_);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var $_=new X,ev=new hg,tv=0,nv=class extends ag{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:tv++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Wh,this.updateRanges=[],this.gpuType=Mm,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;sv.subVectors(e,this.center);let t=sv.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(sv,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(cv.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(sv.copy(e.center).add(cv)),this.expandByPoint(sv.copy(e.center).sub(cv))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},uv=0,dv=new Bg,fv=new p_,pv=new X,mv=new R_,hv=new R_,gv=new X,_v=class e extends ag{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:uv++}),this.uuid=lg(),this.name=``,this.type=`BufferGeometry`,this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Kh(e)?iv:rv)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let t=new yg().getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return dv.makeRotationFromQuaternion(e),this.applyMatrix4(dv),this}rotateX(e){return dv.makeRotationX(e),this.applyMatrix4(dv),this}rotateY(e){return dv.makeRotationY(e),this.applyMatrix4(dv),this}rotateZ(e){return dv.makeRotationZ(e),this.applyMatrix4(dv),this}translate(e,t,n){return dv.makeTranslation(e,t,n),this.applyMatrix4(dv),this}scale(e,t,n){return dv.makeScale(e,t,n),this.applyMatrix4(dv),this}lookAt(e){return fv.lookAt(e),fv.updateMatrix(),this.applyMatrix4(fv.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pv).negate(),this.translate(pv.x,pv.y,pv.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;nt.count&&eg(`BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.`),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new R_);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){tg(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new X(-1/0,-1/0,-1/0),new X(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){eg(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){eg(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},bv=new X,xv=new X,Sv=new X,Cv=new X,wv=new X,Tv=new X,Ev=new X,Dv=class{constructor(e=new X,t=new X(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,bv)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=bv.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(bv.copy(this.origin).addScaledVector(this.direction,t),bv.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){xv.copy(e).add(t).multiplyScalar(.5),Sv.copy(t).sub(e).normalize(),Cv.copy(this.origin).sub(xv);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Sv),o=Cv.dot(this.direction),s=-Cv.dot(Sv),c=Cv.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(xv).addScaledVector(Sv,d),f}intersectSphere(e,t){bv.subVectors(e.center,this.origin);let n=bv.dot(this.direction),r=bv.dot(bv)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,bv)!==null}intersectTriangle(e,t,n,r,i){wv.subVectors(t,e),Tv.subVectors(n,e),Ev.crossVectors(wv,Tv);let a=this.direction.dot(Ev),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Cv.subVectors(this.origin,e);let s=o*this.direction.dot(Tv.crossVectors(Cv,Tv));if(s<0)return null;let c=o*this.direction.dot(wv.cross(Cv));if(c<0||s+c>a)return null;let l=-o*Cv.dot(Ev);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ov=class extends yv{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new x_(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Xg,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},kv=new Bg,Av=new Dv,jv=new lv,Mv=new X,Nv=new X,Pv=new X,Fv=new X,Iv=new X,Lv=new X,Rv=new X,zv=new X,Bv=class extends p_{constructor(e=new _v,t=new Ov){super(),this.isMesh=!0,this.type=`Mesh`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(kv.copy(i).invert(),Av.copy(e.ray).applyMatrix4(kv),!(n.boundingBox!==null&&Av.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Av)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:zv.clone(),object:e}}function Hv(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,Nv),e.getVertexPosition(c,Pv),e.getVertexPosition(l,Fv);let u=Vv(e,t,n,r,Nv,Pv,Fv,Rv);if(u){let e=new X;L_.getBarycoord(Rv,Nv,Pv,Fv,e),i&&(u.uv=L_.getInterpolatedAttribute(i,s,c,l,e,new hg)),a&&(u.uv1=L_.getInterpolatedAttribute(a,s,c,l,e,new hg)),o&&(u.normal=L_.getInterpolatedAttribute(o,s,c,l,e,new X),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new X,materialIndex:0};L_.getNormal(Nv,Pv,Fv,t.normal),u.face=t,u.barycoord=e}return u}var Uv=class extends Pg{constructor(e=null,t=1,n=1,r,i,a,o,s,c=bm,l=bm,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Wv=class extends nv{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Gv=new Bg,Kv=new Bg,qv=[],Jv=new R_,Yv=new Bg,Xv=new Bv,Zv=new lv,Qv=class extends Bv{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Wv(new Float32Array(n*16),16),this.previousInstanceMatrix=null,this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e1)?null:t.copy(e.start).addScaledVector(r,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||ty.getNormalMatrix(e),r=this.coplanarPoint($v).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},ry=new lv,iy=new hg(.5,.5),ay=new X,oy=class{constructor(e=new ny,t=new ny,n=new ny,r=new ny,i=new ny,a=new ny){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Gh,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),ry.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ry.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ry)}intersectsSprite(e){return ry.center.set(0,0,0),ry.radius=.7071067811865476+iy.distanceTo(e.center),ry.applyMatrix4(e.matrixWorld),this.intersectsSphere(ry)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,ay.y=r.normal.y>0?e.max.y:e.min.y,ay.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ay)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},sy=class extends yv{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new x_(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},cy=new X,ly=new X,uy=new Bg,dy=new Dv,fy=new lv,py=new X,my=new X,hy=class extends p_{constructor(e=new _v,t=new sy){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er)return;py.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(py);if(!(ct.far))return{distance:c,point:my.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var _y=new X,vy=new X,yy=class extends hy{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type=`LineSegments`}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let e=0,r=t.count;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var Dy=class extends Pg{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Oy=class extends Pg{constructor(e,t,n=jm,r,i,a,o=bm,s=bm,c,l=Hm,u=1){if(l!==1026&&l!==1027)throw Error(`DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Ag(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},ky=class extends Oy{constructor(e,t=jm,n=301,r,i,a=bm,o=bm,s,c=Hm){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Ay=class extends Pg{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},jy=class e extends _v{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new av(c,3)),this.setAttribute(`normal`,new av(l,3)),this.setAttribute(`uv`,new av(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new X;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e.9&&Math.min(t,n,r)<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}function d(e){i.push(e.x,e.y,e.z)}function f(t,n){let r=t*3;n.x=e[r+0],n.y=e[r+1],n.z=e[r+2]}function p(){let e=new X,t=new X,n=new X,r=new X,o=new hg,s=new hg,c=new hg;for(let l=0,u=0;l0)&&f.push(t,i,c),(e!==n-1||s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Jy=class extends qy{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type=`RawShaderMaterial`}},Yy=class extends yv{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=Rh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Xy=class extends yv{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Zy(e,t){return!e||e.constructor===t?e:typeof t.BYTES_PER_ELEMENT==`number`?new t(e):Array.prototype.slice.call(e)}var Qy=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r===void 0?new t.constructor(n):r,this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],i=t[n-1];validate_interval:{seek:{let a;linear_scan:{forward_scan:if(!(e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(tg(`KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(tg(`KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){tg(`KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){tg(`KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&qh(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){tg(`KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Nh,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};rb.prototype.ValueTypeName=``,rb.prototype.TimeBufferType=Float32Array,rb.prototype.ValueBufferType=Float32Array,rb.prototype.DefaultInterpolation=Mh;var ib=class extends rb{constructor(e,t,n){super(e,t,n)}};ib.prototype.ValueTypeName=`bool`,ib.prototype.ValueBufferType=Array,ib.prototype.DefaultInterpolation=jh,ib.prototype.InterpolantFactoryMethodLinear=void 0,ib.prototype.InterpolantFactoryMethodSmooth=void 0;var ab=class extends rb{constructor(e,t,n,r){super(e,t,n,r)}};ab.prototype.ValueTypeName=`color`;var ob=class extends rb{constructor(e,t,n,r){super(e,t,n,r)}};ob.prototype.ValueTypeName=`number`;var sb=class extends Qy{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)gg.slerpFlat(i,0,a,c-o,a,c,s);return i}},cb=class extends rb{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new sb(this.times,this.values,this.getValueSize(),e)}};cb.prototype.ValueTypeName=`quaternion`,cb.prototype.InterpolantFactoryMethodSmooth=void 0;var lb=class extends rb{constructor(e,t,n){super(e,t,n)}};lb.prototype.ValueTypeName=`string`,lb.prototype.ValueBufferType=Array,lb.prototype.DefaultInterpolation=jh,lb.prototype.InterpolantFactoryMethodLinear=void 0,lb.prototype.InterpolantFactoryMethodSmooth=void 0;var ub=class extends rb{constructor(e,t,n,r){super(e,t,n,r)}};ub.prototype.ValueTypeName=`vector`;var db=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;te.start-t.start);let t=0;for(let e=1;e 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,clipping_planes_pars_fragment:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,clipping_planes_pars_vertex:`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,clipping_planes_vertex:`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,color_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,color_pars_fragment:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,color_pars_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,color_vertex:`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec4( 1.0 ); +#endif +#ifdef USE_COLOR_ALPHA + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,common:`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,cube_uv_reflection_fragment:`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,defaultnormal_vertex:`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,displacementmap_pars_vertex:`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,displacementmap_vertex:`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,emissivemap_fragment:`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,emissivemap_pars_fragment:`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,colorspace_fragment:`gl_FragColor = linearToOutputTexel( gl_FragColor );`,colorspace_pars_fragment:`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +}`,envmap_fragment:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,envmap_common_pars_fragment:`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,envmap_pars_fragment:`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,envmap_pars_vertex:`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,envmap_physical_pars_fragment:`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,envmap_vertex:`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,fog_vertex:`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,fog_pars_vertex:`#ifdef USE_FOG + varying float vFogDepth; +#endif`,fog_fragment:`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,fog_pars_fragment:`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,gradientmap_pars_fragment:`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,lightmap_pars_fragment:`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,lights_lambert_fragment:`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,lights_lambert_pars_fragment:`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,lights_pars_begin:`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,lights_toon_fragment:`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,lights_toon_pars_fragment:`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,lights_phong_fragment:`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,lights_phong_pars_fragment:`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,lights_physical_fragment:`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,lights_physical_pars_fragment:`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,lights_fragment_begin:` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,lights_fragment_maps:`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,lights_fragment_end:`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,lightprobes_pars_fragment:`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,logdepthbuf_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,logdepthbuf_pars_fragment:`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_pars_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,logdepthbuf_vertex:`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,map_fragment:`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,map_pars_fragment:`#ifdef USE_MAP + uniform sampler2D map; +#endif`,map_particle_fragment:`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,map_particle_pars_fragment:`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,metalnessmap_fragment:`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,metalnessmap_pars_fragment:`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,morphinstance_vertex:`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,morphcolor_vertex:`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,morphnormal_vertex:`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,morphtarget_pars_vertex:`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,morphtarget_vertex:`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,normal_fragment_begin:`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,normal_fragment_maps:`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,normal_pars_fragment:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_pars_vertex:`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,normal_vertex:`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,normalmap_pars_fragment:`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,clearcoat_normal_fragment_begin:`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,clearcoat_normal_fragment_maps:`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,clearcoat_pars_fragment:`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,iridescence_pars_fragment:`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,opaque_fragment:`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,packing:`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,premultiplied_alpha_fragment:`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,project_vertex:`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,dithering_fragment:`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,dithering_pars_fragment:`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,roughnessmap_fragment:`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,roughnessmap_pars_fragment:`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,shadowmap_pars_fragment:`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,shadowmap_pars_vertex:`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,shadowmap_vertex:`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,shadowmask_pars_fragment:`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,skinbase_vertex:`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,skinning_pars_vertex:`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,skinning_vertex:`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,skinnormal_vertex:`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,specularmap_fragment:`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,specularmap_pars_fragment:`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,tonemapping_fragment:`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,tonemapping_pars_fragment:`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,transmission_fragment:`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,transmission_pars_fragment:`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,uv_pars_fragment:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_pars_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,uv_vertex:`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,worldpos_vertex:`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,background_vert:`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,background_frag:`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,backgroundCube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,cube_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,cube_frag:`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,depth_vert:`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,depth_frag:`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,distance_vert:`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,distance_frag:`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,equirect_vert:`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,equirect_frag:`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,linedashed_vert:`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,linedashed_frag:`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,meshbasic_vert:`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,meshbasic_frag:`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,meshlambert_vert:`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshlambert_frag:`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshmatcap_vert:`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,meshmatcap_frag:`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,meshnormal_vert:`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,meshnormal_frag:`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,meshphong_vert:`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,meshphong_frag:`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,meshphysical_vert:`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,meshphysical_frag:`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,meshtoon_vert:`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,meshtoon_frag:`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,points_vert:`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,points_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,shadow_vert:`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,shadow_frag:`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,sprite_vert:`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,sprite_frag:`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`},Z={common:{diffuse:{value:new x_(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new yg},alphaMap:{value:null},alphaMapTransform:{value:new yg},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new yg}},envmap:{envMap:{value:null},envMapRotation:{value:new yg},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new yg}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new yg}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new yg},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new yg},normalScale:{value:new hg(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new yg},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new yg}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new yg}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new yg}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new x_(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new X},probesMax:{value:new X},probesResolution:{value:new X}},points:{diffuse:{value:new x_(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new yg},alphaTest:{value:0},uvTransform:{value:new yg}},sprite:{diffuse:{value:new x_(16777215)},opacity:{value:1},center:{value:new hg(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new yg},alphaMap:{value:null},alphaMapTransform:{value:new yg},alphaTest:{value:0}}},Wb={basic:{uniforms:By([Z.common,Z.specularmap,Z.envmap,Z.aomap,Z.lightmap,Z.fog]),vertexShader:Ub.meshbasic_vert,fragmentShader:Ub.meshbasic_frag},lambert:{uniforms:By([Z.common,Z.specularmap,Z.envmap,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.fog,Z.lights,{emissive:{value:new x_(0)},envMapIntensity:{value:1}}]),vertexShader:Ub.meshlambert_vert,fragmentShader:Ub.meshlambert_frag},phong:{uniforms:By([Z.common,Z.specularmap,Z.envmap,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.fog,Z.lights,{emissive:{value:new x_(0)},specular:{value:new x_(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ub.meshphong_vert,fragmentShader:Ub.meshphong_frag},standard:{uniforms:By([Z.common,Z.envmap,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.roughnessmap,Z.metalnessmap,Z.fog,Z.lights,{emissive:{value:new x_(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ub.meshphysical_vert,fragmentShader:Ub.meshphysical_frag},toon:{uniforms:By([Z.common,Z.aomap,Z.lightmap,Z.emissivemap,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.gradientmap,Z.fog,Z.lights,{emissive:{value:new x_(0)}}]),vertexShader:Ub.meshtoon_vert,fragmentShader:Ub.meshtoon_frag},matcap:{uniforms:By([Z.common,Z.bumpmap,Z.normalmap,Z.displacementmap,Z.fog,{matcap:{value:null}}]),vertexShader:Ub.meshmatcap_vert,fragmentShader:Ub.meshmatcap_frag},points:{uniforms:By([Z.points,Z.fog]),vertexShader:Ub.points_vert,fragmentShader:Ub.points_frag},dashed:{uniforms:By([Z.common,Z.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ub.linedashed_vert,fragmentShader:Ub.linedashed_frag},depth:{uniforms:By([Z.common,Z.displacementmap]),vertexShader:Ub.depth_vert,fragmentShader:Ub.depth_frag},normal:{uniforms:By([Z.common,Z.bumpmap,Z.normalmap,Z.displacementmap,{opacity:{value:1}}]),vertexShader:Ub.meshnormal_vert,fragmentShader:Ub.meshnormal_frag},sprite:{uniforms:By([Z.sprite,Z.fog]),vertexShader:Ub.sprite_vert,fragmentShader:Ub.sprite_frag},background:{uniforms:{uvTransform:{value:new yg},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ub.background_vert,fragmentShader:Ub.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new yg}},vertexShader:Ub.backgroundCube_vert,fragmentShader:Ub.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ub.cube_vert,fragmentShader:Ub.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ub.equirect_vert,fragmentShader:Ub.equirect_frag},distance:{uniforms:By([Z.common,Z.displacementmap,{referencePosition:{value:new X},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ub.distance_vert,fragmentShader:Ub.distance_frag},shadow:{uniforms:By([Z.lights,Z.fog,{color:{value:new x_(0)},opacity:{value:1}}]),vertexShader:Ub.shadow_vert,fragmentShader:Ub.shadow_frag}};Wb.physical={uniforms:By([Wb.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new yg},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new yg},clearcoatNormalScale:{value:new hg(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new yg},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new yg},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new yg},sheen:{value:0},sheenColor:{value:new x_(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new yg},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new yg},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new yg},transmissionSamplerSize:{value:new hg},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new yg},attenuationDistance:{value:0},attenuationColor:{value:new x_(0)},specularColor:{value:new x_(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new yg},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new yg},anisotropyVector:{value:new hg},anisotropyMap:{value:null},anisotropyMapTransform:{value:new yg}}]),vertexShader:Ub.meshphysical_vert,fragmentShader:Ub.meshphysical_frag};var Gb={r:0,b:0,g:0},Kb=new Bg,qb=new yg;qb.set(-1,0,0,0,1,0,0,0,1);function Jb(e,t,n,r,i,a){let o=new x_(0),s=i===!0?0:1,c,l,u=null,d=0,f=null;function p(e){let n=e.isScene===!0?e.background:null;if(n&&n.isTexture){let r=e.backgroundBlurriness>0;n=t.get(n,r)}return n}function m(t){let r=!1,i=p(t);i===null?g(o,s):i&&i.isColor&&(g(i,1),r=!0);let c=e.xr.getEnvironmentBlendMode();c===`additive`?n.buffers.color.setClear(0,0,0,1,a):c===`alpha-blend`&&n.buffers.color.setClear(0,0,0,0,a),(e.autoClear||r)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))}function h(t,n){let i=p(n);i&&(i.isCubeTexture||i.mapping===306)?(l===void 0&&(l=new Bv(new jy(1,1,1),new qy({name:`BackgroundCubeMaterial`,uniforms:zy(Wb.backgroundCube.uniforms),vertexShader:Wb.backgroundCube.vertexShader,fragmentShader:Wb.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute(`normal`),l.geometry.deleteAttribute(`uv`),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=i,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Kb.makeRotationFromEuler(n.backgroundRotation)).transpose(),i.isCubeTexture&&i.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(qb),l.material.toneMapped=wg.getTransfer(i.colorSpace)!==Hh,(u!==i||d!==i.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(c===void 0&&(c=new Bv(new Fy(2,2),new qy({name:`BackgroundMaterial`,uniforms:zy(Wb.background.uniforms),vertexShader:Wb.background.vertexShader,fragmentShader:Wb.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute(`normal`),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=i,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.toneMapped=wg.getTransfer(i.colorSpace)!==Hh,i.matrixAutoUpdate===!0&&i.updateMatrix(),c.material.uniforms.uvTransform.value.copy(i.matrix),(u!==i||d!==i.version||f!==e.toneMapping)&&(c.material.needsUpdate=!0,u=i,d=i.version,f=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null))}function g(t,r){t.getRGB(Gb,Uy(e)),n.buffers.color.setClear(Gb.r,Gb.g,Gb.b,r,a)}function _(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),s=t,g(o,s)},getClearAlpha:function(){return s},setClearAlpha:function(e){s=e,g(o,s)},render:m,addToRenderList:h,dispose:_}}function Yb(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},i=f(null),a=i,o=!1;function s(n,r,i,s,c){let u=!1,f=d(n,s,i,r);a!==f&&(a=f,l(a.object)),u=p(n,s,i,c),u&&m(n,s,i,c),c!==null&&t.update(c,e.ELEMENT_ARRAY_BUFFER),(u||o)&&(o=!1,b(n,r,i,s),c!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(c).buffer))}function c(){return e.createVertexArray()}function l(t){return e.bindVertexArray(t)}function u(t){return e.deleteVertexArray(t)}function d(e,t,n,i){let a=i.wireframe===!0,o=r[t.id];o===void 0&&(o={},r[t.id]=o);let s=e.isInstancedMesh===!0?e.id:0,l=o[s];l===void 0&&(l={},o[s]=l);let u=l[n.id];u===void 0&&(u={},l[n.id]=u);let d=u[a];return d===void 0&&(d=f(c()),u[a]=d),d}function f(e){let t=[],r=[],i=[];for(let e=0;e=0){let n=i[t],r=o[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;s++}return a.attributesNum!==s||a.index!==r}function m(e,t,n,r){let i={},o=t.attributes,s=0,c=n.getAttributes();for(let t in c)if(c[t].location>=0){let n=o[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,s++}a.attributes=i,a.attributesNum=s,a.index=r}function h(){let e=a.newAttributes;for(let t=0,n=e.length;t=0){let s=o[r];if(s===void 0&&(r===`instanceMatrix`&&n.instanceMatrix&&(s=n.instanceMatrix),r===`instanceColor`&&n.instanceColor&&(s=n.instanceColor)),s!==void 0){let r=s.normalized,o=s.itemSize,c=t.get(s);if(c===void 0)continue;let l=c.buffer,u=c.type,d=c.bytesPerElement,f=u===e.INT||u===e.UNSIGNED_INT||s.gpuType===1013;if(s.isInterleavedBufferAttribute){let t=s.data,c=t.stride,p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let l=n.precision===void 0?`highp`:n.precision,u=c(l);u!==l&&(eg(`WebGLRenderer:`,l,`not supported, using`,u,`instead.`),l=u);let d=n.logarithmicDepthBuffer===!0,f=n.reversedDepthBuffer===!0&&t.has(`EXT_clip_control`);n.reversedDepthBuffer===!0&&f===!1&&eg(`WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.`);let p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_TEXTURE_SIZE),g=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),_=e.getParameter(e.MAX_VERTEX_ATTRIBS),v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),y=e.getParameter(e.MAX_VARYING_VECTORS),b=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),x=e.getParameter(e.MAX_SAMPLES),S=e.getParameter(e.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:s,precision:l,logarithmicDepthBuffer:d,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:g,maxAttributes:_,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:b,maxSamples:x,samples:S}}function Qb(e){let t=this,n=null,r=0,i=!1,a=!1,o=new ny,s=new yg,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=_x(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=gx(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?l:0,l,l),c.setRenderTarget(r),p&&c.render(d,a),c.render(e,a)}c.toneMapping=u,c.autoClear=l,e.background=m}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=_x()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=gx());let i=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=i;let o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;px(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,rx)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodMeshes.length;for(let t=1;td-$b?n-d+$b:0),m=4*(this._cubeSize-f);s.envMap.value=e.texture,s.roughness.value=u,s.mipInt.value=d-t,px(i,p,m,3*f,2*f),r.setRenderTarget(i),r.render(o,rx),s.envMap.value=i.texture,s.roughness.value=0,s.mipInt.value=d-n,px(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,rx)}_blur(e,t,n,r,i){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,`latitudinal`,i),this._halfBlur(a,e,n,n,r,`longitudinal`,i)}_halfBlur(e,t,n,r,i,a,o){let s=this._renderer,c=this._blurMaterial;a!==`latitudinal`&&a!==`longitudinal`&&tg(`blur direction must be either latitudinal or longitudinal!`);let l=this._lodMeshes[r];l.material=c;let u=c.uniforms,d=this._sizeLods[n]-1,f=isFinite(i)?Math.PI/(2*d):2*Math.PI/(2*tx-1),p=i/f,m=isFinite(i)?1+Math.floor(3*p):tx;m>tx&&eg(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${tx}`);let h=[],g=0;for(let e=0;e_-$b?r-_+$b:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,rx)}};function dx(e){let t=[],n=[],r=[],i=e,a=e-$b+1+ex.length;for(let o=0;oe-$b?s=ex[o-e+$b-1]:o===0&&(s=0),n.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new _v;h.setAttribute(`position`,new nv(f,3)),h.setAttribute(`uv`,new nv(p,2)),h.setAttribute(`faceIndex`,new nv(m,1)),r.push(new Bv(h,null)),i>$b&&i--}return{lodMeshes:r,sizeLods:t,sigmas:n}}function fx(e,t,n){let r=new Lg(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function px(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function mx(e,t,n){return new qy({name:`PMREMGGXConvolution`,defines:{GGX_SAMPLES:nx,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vx(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:0,depthTest:!1,depthWrite:!1})}function hx(e,t,n){let r=new Float32Array(tx),i=new X(0,1,0);return new qy({name:`SphericalGaussianBlur`,defines:{n:tx,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:vx(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function gx(){return new qy({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:vx(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function _x(){return new qy({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vx(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function vx(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}var yx=class extends Lg{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Dy(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},r=new jy(5,5,5),i=new qy({name:`CubemapFromEquirect`,uniforms:zy(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new Bv(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=Cm),new wb(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}};function bx(e){let t=new WeakMap,n=new WeakMap,r=null;function i(e,t=!1){return e==null?null:t?o(e):a(e)}function a(n){if(n&&n.isTexture){let r=n.mapping;if(r===303||r===304)if(t.has(n)){let e=t.get(n).texture;return s(e,n.mapping)}else{let r=n.image;if(r&&r.height>0){let i=new yx(r.height);return i.fromEquirectangularTexture(e,n),t.set(n,i),n.addEventListener(`dispose`,l),s(i.texture,n.mapping)}else return null}}return n}function o(t){if(t&&t.isTexture){let i=t.mapping,a=i===303||i===304,o=i===301||i===302;if(a||o){let i=n.get(t),s=i===void 0?0:i.texture.pmremVersion;if(t.isRenderTargetTexture&&t.pmremVersion!==s)return r===null&&(r=new ux(e)),i=a?r.fromEquirectangular(t,i):r.fromCubemap(t,i),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),i.texture;if(i!==void 0)return i.texture;{let s=t.image;return a&&s&&s.height>0||o&&s&&c(s)?(r===null&&(r=new ux(e)),i=a?r.fromEquirectangular(t):r.fromCubemap(t),i.texture.pmremVersion=t.pmremVersion,n.set(t,i),t.addEventListener(`dispose`,u),i.texture):null}}}return t}function s(e,t){return t===303?e.mapping=301:t===304&&(e.mapping=302),e}function c(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function l(e){let n=e.target;n.removeEventListener(`dispose`,l);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function u(e){let t=e.target;t.removeEventListener(`dispose`,u);let r=n.get(t);r!==void 0&&(n.delete(t),r.dispose())}function d(){t=new WeakMap,n=new WeakMap,r!==null&&(r.dispose(),r=null)}return{get:i,dispose:d}}function xx(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r=e.getExtension(n);return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(){n(`EXT_color_buffer_float`),n(`WEBGL_clip_cull_distance`),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`),n(`WEBGL_render_shared_exponent`)},get:function(e){let t=n(e);return t===null&&ng(`WebGLRenderer: `+e+` extension not supported.`),t}}}function Sx(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener(`dispose`,o),delete i[s.id];let c=a.get(s);c&&(t.remove(c),a.delete(s)),r.releaseStatesOfGeometry(s),s.isInstancedBufferGeometry===!0&&delete s._maxInstanceCount,n.memory.geometries--}function s(e,t){return i[t.id]===!0?t:(t.addEventListener(`dispose`,o),i[t.id]=!0,n.memory.geometries++,t)}function c(n){let r=n.attributes;for(let n in r)t.update(r[n],e.ARRAY_BUFFER)}function l(e){let n=[],r=e.index,i=e.attributes.position,o=0;if(i===void 0)return;if(r!==null){let e=r.array;o=r.version;for(let t=0,r=e.length;t=65535?iv:rv)(n,1);s.version=o;let c=a.get(e);c&&t.remove(c),a.set(e,s)}function u(e){let t=a.get(e);if(t){let n=e.index;n!==null&&t.versiont.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*u),g=new Rg(h,p,m,u);g.type=Mm,g.needsUpdate=!0;let _=f*4;for(let t=0;t + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),l=new Bv(s,c),u=new xb(-1,1,1,-1,0,1),d=null,f=null,p=!1,m,h=null,g=[],_=!1;this.setSize=function(e,t){a.setSize(e,t),o.setSize(e,t);for(let n=0;n0&&g[0].isRenderPass===!0;let t=a.width,n=a.height;for(let e=0;e0)return e;let i=t*n,a=Px[i];if(a===void 0&&(a=new Float32Array(i),Px[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function Bx(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0&&(this.seq=r.concat(i))}setValue(e,t,n,r){let i=this.map[t];i!==void 0&&i.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){let a=t[i],o=n[a.id];o.needsUpdate!==!1&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,i=e.length;r!==i;++r){let i=e[r];i.id in t&&n.push(i)}return n}};function IS(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}var LS=37297,RS=0;function zS(e,t){let n=e.split(` +`),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e`:` `} ${i}: ${n[e]}`)}return r.join(` +`)}var BS=new yg;function VS(e){wg._getMatrix(BS,wg.workingColorSpace,e);let t=`mat3( ${BS.elements.map(e=>e.toFixed(4))} )`;switch(wg.getTransfer(e)){case Vh:return[t,`LinearTransferOETF`];case Hh:return[t,`sRGBTransferOETF`];default:return eg(`WebGLProgram: Unsupported color space: `,e),[t,`LinearTransferOETF`]}}function HS(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=(e.getShaderInfoLog(t)||``).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` + +`+i+` + +`+zS(e.getShaderSource(t),r)}else return i}function US(e,t){let n=VS(t);return[`vec4 ${e}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,`}`].join(` +`)}var WS={1:`Linear`,2:`Reinhard`,3:`Cineon`,4:`ACESFilmic`,6:`AgX`,7:`Neutral`,5:`Custom`};function GS(e,t){let n=WS[t];return n===void 0?(eg(`WebGLProgram: Unsupported toneMapping:`,t),`vec3 `+e+`( vec3 color ) { return LinearToneMapping( color ); }`):`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}var KS=new X;function qS(){return wg.getLuminanceCoefficients(KS),[`float luminance( const in vec3 rgb ) {`,` const vec3 weights = vec3( ${KS.x.toFixed(4)}, ${KS.y.toFixed(4)}, ${KS.z.toFixed(4)} );`,` return dot( weights, rgb );`,`}`].join(` +`)}function JS(e){return[e.extensionClipCullDistance?`#extension GL_ANGLE_clip_cull_distance : require`:``,e.extensionMultiDraw?`#extension GL_ANGLE_multi_draw : require`:``].filter(ZS).join(` +`)}function YS(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` +`)}function XS(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function tC(e){return e.replace(eC,rC)}var nC=new Map;function rC(e,t){let n=Ub[t];if(n===void 0){let e=nC.get(t);if(e!==void 0)n=Ub[e],eg(`WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return tC(n)}var iC=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function aC(e){return e.replace(iC,oC)}function oC(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` +`),_=[`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(ZS).join(` +`),_.length>0&&(_+=` +`)):(g=[sC(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.extensionClipCullDistance?`#define USE_CLIP_DISTANCE`:``,n.batching?`#define USE_BATCHING`:``,n.batchingColor?`#define USE_BATCHING_COLOR`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.instancingMorph?`#define USE_INSTANCING_MORPH`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexNormals?`#define HAS_NORMAL`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`#ifdef USE_INSTANCING_MORPH`,` uniform sampler2D morphTexture;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` +`].filter(ZS).join(` +`),_=[sC(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.alphaToCoverage?`#define ALPHA_TO_COVERAGE`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.packedNormalMap?`#define USE_PACKED_NORMALMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.dispersion?`#define USE_DISPERSION`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas||n.batchingColor?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.numLightProbeGrids>0?`#define USE_LIGHT_PROBES_GRID`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.decodeVideoTextureEmissive?`#define DECODE_VIDEO_TEXTURE_EMISSIVE`:``,n.logarithmicDepthBuffer?`#define USE_LOGARITHMIC_DEPTH_BUFFER`:``,n.reversedDepthBuffer?`#define USE_REVERSED_DEPTH_BUFFER`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:Ub.tonemapping_pars_fragment,n.toneMapping===0?``:GS(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,Ub.colorspace_pars_fragment,US(`linearToOutputTexel`,n.outputColorSpace),qS(),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(ZS).join(` +`)),o=tC(o),o=QS(o,n),o=$S(o,n),s=tC(s),s=QS(s,n),s=$S(s,n),o=aC(o),s=aC(s),n.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=[p,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` +`)+` +`+g,_=[`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#define gl_FragColor pc_fragColor`,`#define gl_FragDepthEXT gl_FragDepth`,`#define texture2D texture`,`#define textureCube texture`,`#define texture2DProj textureProj`,`#define texture2DLodEXT textureLod`,`#define texture2DProjLodEXT textureProjLod`,`#define textureCubeLodEXT textureLod`,`#define texture2DGradEXT textureGrad`,`#define texture2DProjGradEXT textureProjGrad`,`#define textureCubeGradEXT textureGrad`].join(` +`)+` +`+_);let y=v+g+o,b=v+_+s,x=IS(i,i.VERTEX_SHADER,y),S=IS(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h)||``,r=i.getShaderInfoLog(x)||``,a=i.getShaderInfoLog(S)||``,o=n.trim(),s=r.trim(),c=a.trim(),l=!0,u=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(l=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=HS(i,x,`vertex`),n=HS(i,S,`fragment`);tg(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` + +Material Name: `+t.name+` +Material Type: `+t.type+` + +Program Info Log: `+o+` +`+e+` +`+n)}else o===``?(s===``||c===``)&&(u=!1):eg(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:g},fragmentShader:{log:c,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new FS(i,h),T=XS(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,LS)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=RS++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var vC=0,yC=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new bC(e),t.set(e,n)),n}},bC=class{constructor(e){this.id=vC++,this.code=e,this.usedTimes=0}};function xC(e){return e===1030||e===37490||e===36285}function SC(e,t,n,r,i,a){let o=new Zg,s=new yC,c=new Set,l=[],u=new Map,d=r.logarithmicDepthBuffer,f=r.precision,p={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distance`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function m(e){return c.add(e),e===0?`uv`:`uv${e}`}function h(i,o,l,u,h,g){let _=u.fog,v=h.geometry,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,b=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,x=t.get(i.envMap||y,b),S=x&&x.mapping===306?x.image.height:null,C=p[i.type];i.precision!==null&&(f=r.getMaxPrecision(i.precision),f!==i.precision&&eg(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,f,`instead.`));let w=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,T=w===void 0?0:w.length,E=0;v.morphAttributes.position!==void 0&&(E=1),v.morphAttributes.normal!==void 0&&(E=2),v.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=Wb[C];D=e.vertexShader,O=e.fragmentShader}else D=i.vertexShader,O=i.fragmentShader,s.update(i),k=s.getVertexShaderID(i),A=s.getFragmentShaderID(i);let j=e.getRenderTarget(),M=e.state.buffers.depth.getReversed(),N=h.isInstancedMesh===!0,ee=h.isBatchedMesh===!0,P=!!i.map,F=!!i.matcap,I=!!x,te=!!i.aoMap,L=!!i.lightMap,ne=!!i.bumpMap,R=!!i.normalMap,z=!!i.displacementMap,B=!!i.emissiveMap,re=!!i.metalnessMap,ie=!!i.roughnessMap,ae=i.anisotropy>0,oe=i.clearcoat>0,se=i.dispersion>0,ce=i.iridescence>0,le=i.sheen>0,ue=i.transmission>0,de=ae&&!!i.anisotropyMap,fe=oe&&!!i.clearcoatMap,V=oe&&!!i.clearcoatNormalMap,H=oe&&!!i.clearcoatRoughnessMap,pe=ce&&!!i.iridescenceMap,me=ce&&!!i.iridescenceThicknessMap,he=le&&!!i.sheenColorMap,U=le&&!!i.sheenRoughnessMap,ge=!!i.specularMap,_e=!!i.specularColorMap,ve=!!i.specularIntensityMap,ye=ue&&!!i.transmissionMap,W=ue&&!!i.thicknessMap,be=!!i.gradientMap,xe=!!i.alphaMap,Se=i.alphaTest>0,Ce=!!i.alphaHash,we=!!i.extensions,Te=0;i.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(Te=e.toneMapping);let Ee={shaderID:C,shaderType:i.type,shaderName:i.name,vertexShader:D,fragmentShader:O,defines:i.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:f,batching:ee,batchingColor:ee&&h._colorsTexture!==null,instancing:N,instancingColor:N&&h.instanceColor!==null,instancingMorph:N&&h.morphTexture!==null,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:wg.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:P,matcap:F,envMap:I,envMapMode:I&&x.mapping,envMapCubeUVHeight:S,aoMap:te,lightMap:L,bumpMap:ne,normalMap:R,displacementMap:z,emissiveMap:B,normalMapObjectSpace:R&&i.normalMapType===1,normalMapTangentSpace:R&&i.normalMapType===0,packedNormalMap:R&&i.normalMapType===0&&xC(i.normalMap.format),metalnessMap:re,roughnessMap:ie,anisotropy:ae,anisotropyMap:de,clearcoat:oe,clearcoatMap:fe,clearcoatNormalMap:V,clearcoatRoughnessMap:H,dispersion:se,iridescence:ce,iridescenceMap:pe,iridescenceThicknessMap:me,sheen:le,sheenColorMap:he,sheenRoughnessMap:U,specularMap:ge,specularColorMap:_e,specularIntensityMap:ve,transmission:ue,transmissionMap:ye,thicknessMap:W,gradientMap:be,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:xe,alphaTest:Se,alphaHash:Ce,combine:i.combine,mapUv:P&&m(i.map.channel),aoMapUv:te&&m(i.aoMap.channel),lightMapUv:L&&m(i.lightMap.channel),bumpMapUv:ne&&m(i.bumpMap.channel),normalMapUv:R&&m(i.normalMap.channel),displacementMapUv:z&&m(i.displacementMap.channel),emissiveMapUv:B&&m(i.emissiveMap.channel),metalnessMapUv:re&&m(i.metalnessMap.channel),roughnessMapUv:ie&&m(i.roughnessMap.channel),anisotropyMapUv:de&&m(i.anisotropyMap.channel),clearcoatMapUv:fe&&m(i.clearcoatMap.channel),clearcoatNormalMapUv:V&&m(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:H&&m(i.clearcoatRoughnessMap.channel),iridescenceMapUv:pe&&m(i.iridescenceMap.channel),iridescenceThicknessMapUv:me&&m(i.iridescenceThicknessMap.channel),sheenColorMapUv:he&&m(i.sheenColorMap.channel),sheenRoughnessMapUv:U&&m(i.sheenRoughnessMap.channel),specularMapUv:ge&&m(i.specularMap.channel),specularColorMapUv:_e&&m(i.specularColorMap.channel),specularIntensityMapUv:ve&&m(i.specularIntensityMap.channel),transmissionMapUv:ye&&m(i.transmissionMap.channel),thicknessMapUv:W&&m(i.thicknessMap.channel),alphaMapUv:xe&&m(i.alphaMap.channel),vertexTangents:!!v.attributes.tangent&&(R||ae),vertexNormals:!!v.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!v.attributes.color&&v.attributes.color.itemSize===4,pointsUvs:h.isPoints===!0&&!!v.attributes.uv&&(P||xe),fog:!!_,useFog:i.fog===!0,fogExp2:!!_&&_.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||v.attributes.normal===void 0&&R===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:M,skinning:h.isSkinnedMesh===!0,morphTargets:v.morphAttributes.position!==void 0,morphNormals:v.morphAttributes.normal!==void 0,morphColors:v.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:g.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:Te,decodeVideoTexture:P&&i.map.isVideoTexture===!0&&wg.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:B&&i.emissiveMap.isVideoTexture===!0&&wg.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:we&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(we&&i.extensions.multiDraw===!0||ee)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ee.vertexUv1s=c.has(1),Ee.vertexUv2s=c.has(2),Ee.vertexUv3s=c.has(3),c.clear(),Ee}function g(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(_(n,t),v(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function _(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function v(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),e.push(o.mask)}function y(e){let t=p[e.type],n;if(t){let e=Wb[t];n=Wy.clone(e.uniforms)}else n=e.uniforms;return n}function b(t,n){let r=u.get(n);return r===void 0?(r=new _C(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function x(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function S(e){s.remove(e)}function C(){s.dispose()}return{getParameters:h,getProgramCacheKey:g,getUniforms:y,acquireProgram:b,releaseProgram:x,releaseShaderCache:S,programs:l,dispose:C}}function CC(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function wC(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function TC(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function EC(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||wC),r.length>1&&r.sort(t||TC),i.length>1&&i.sort(t||TC)}function d(){for(let n=t,r=e.length;n=r.length?(i=new EC,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function OC(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new X,color:new x_};break;case`SpotLight`:n={position:new X,direction:new X,color:new x_,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new X,color:new x_,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new X,skyColor:new x_,groundColor:new x_};break;case`RectAreaLight`:n={color:new x_,position:new X,halfWidth:new X,halfHeight:new X};break}return e[t.id]=n,n}}}function kC(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new hg};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new hg};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new hg,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var AC=0;function jC(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function MC(e){let t=new OC,n=kC(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new X);let i=new X,a=new Bg,o=new Bg;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;i.sort(jC);for(let e=0,y=i.length;e0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=Z.LTC_FLOAT_1,r.rectAreaLTC2=Z.LTC_FLOAT_2):(r.rectAreaLTC1=Z.LTC_HALF_1,r.rectAreaLTC2=Z.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let y=r.hash;(y.directionalLength!==c||y.pointLength!==l||y.spotLength!==u||y.rectAreaLength!==d||y.hemiLength!==f||y.numDirectionalShadows!==p||y.numPointShadows!==m||y.numSpotShadows!==h||y.numSpotMaps!==g||y.numLightProbes!==v)&&(r.directional.length=c,r.spot.length=u,r.rectArea.length=d,r.point.length=l,r.hemi.length=f,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=m,r.pointShadowMap.length=m,r.spotShadow.length=h,r.spotShadowMap.length=h,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=m,r.spotLightMatrix.length=h+g-_,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=_,r.numLightProbes=v,y.directionalLength=c,y.pointLength=l,y.spotLength=u,y.rectAreaLength=d,y.hemiLength=f,y.numDirectionalShadows=p,y.numPointShadows=m,y.numSpotShadows=h,y.numSpotMaps=g,y.numLightProbes=v,r.version=AC++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=i.length?(a=new NC(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var FC=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,IC=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); + gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); +}`,LC=[new X(1,0,0),new X(-1,0,0),new X(0,1,0),new X(0,-1,0),new X(0,0,1),new X(0,0,-1)],RC=[new X(0,-1,0),new X(0,-1,0),new X(0,0,1),new X(0,0,-1),new X(0,-1,0),new X(0,-1,0)],zC=new Bg,BC=new X,VC=new X;function HC(e,t,n){let r=new oy,i=new hg,a=new hg,o=new Fg,s=new Yy,c=new Xy,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new qy({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new hg},radius:{value:4}},vertexShader:FC,fragmentShader:IC}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new _v;m.setAttribute(`position`,new nv(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Bv(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(eg(`WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){eg(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new Lg(i.x,i.y,{format:Km,type:Nm,minFilter:Cm,magFilter:Cm,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new Oy(i.x,i.y,Mm),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=Hm,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=bm,d.map.depthTexture.magFilter=bm}else l.isPointLight?(d.map=new yx(i.x),d.map.depthTexture=new ky(i.x,jm)):(d.map=new Lg(i.x,i.y),d.map.depthTexture=new Oy(i.x,i.y,jm)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=Hm,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=Cm,d.map.depthTexture.magFilter=Cm):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=bm,d.map.depthTexture.magFilter=bm);d.camera.updateProjectionMatrix()}let g=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(ee=parseFloat(/^WebGL (\d)/.exec(P)[1]),N=ee>=1);let F=null,I={},te=e.getParameter(e.SCISSOR_BOX),L=e.getParameter(e.VIEWPORT),ne=new Fg().fromArray(te),R=new Fg().fromArray(L);function z(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new hg,u=new WeakMap,d=new Set,f,p=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function h(e,t){return m?new OffscreenCanvas(e,t):Jh(`canvas`)}function g(e,t,n){let r=1,i=_e(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=h(n,a));let o=t?h(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),eg(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}else return`data`in e&&eg(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e;return e}function _(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function y(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function b(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];eg(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||eg(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?Vh:wg.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function x(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,eg(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function S(e,t){return _(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function C(e){let t=e.target;t.removeEventListener(`dispose`,C),T(t),t.isVideoTexture&&u.delete(t),t.isHTMLTexture&&d.delete(t)}function w(e){let t=e.target;t.removeEventListener(`dispose`,w),D(t)}function T(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&E(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function E(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function D(t){let n=r.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),r.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r=i.maxTextures&&eg(`WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+i.maxTextures),O+=1,e}function N(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function ee(t,i){let a=r.get(t);if(t.isVideoTexture&&U(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)eg(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)eg(`WebGLRenderer: Texture marked for update but image is incomplete`);else{ie(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function P(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){ie(a,t,i);return}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function F(t,i){let a=r.get(t);if(t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){ie(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function I(t,i){let a=r.get(t);if(t.isCubeDepthTexture!==!0&&t.version>0&&a.__version!==t.version){ae(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let te={[_m]:e.REPEAT,[vm]:e.CLAMP_TO_EDGE,[ym]:e.MIRRORED_REPEAT},L={[bm]:e.NEAREST,[xm]:e.NEAREST_MIPMAP_NEAREST,[Sm]:e.NEAREST_MIPMAP_LINEAR,[Cm]:e.LINEAR,[wm]:e.LINEAR_MIPMAP_NEAREST,[Tm]:e.LINEAR_MIPMAP_LINEAR},ne={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function R(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&eg(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,te[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,te[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,te[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,L[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,L[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,ne[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function z(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,C));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=N(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&E(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function B(e,t,n){return Math.floor(Math.floor(e/n)/t)}function re(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e0){C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let t=zb(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}o.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0);else eg(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`);else C?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data)}else{C&&w&&n.texStorage2D(e.TEXTURE_2D,E,m,y[0].width,y[0].height);for(let t=0,i=y.length;t0){let i=zb(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isData3DTexture)C?(w&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(w)if(C)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t>=1,a>>=1}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}let r=e.RGBA,i=e.RGBA,a=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,r,i,a,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(y.length>0){if(C&&w){let t=_e(y[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=y.length;t0&&D++;let t=_e(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,D,C,t.width,t.height)}for(let t=0;t<6;t++)if(p){w?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,y,x,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,C,m[t].width,m[t].height,0,y,x,m[t].data);for(let r=0;r>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),he(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,me(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function se(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=x(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;he(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,me(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,me(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)ce(i.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?ce(i.__webglFramebuffer[0],t,0):ce(i.__webglFramebuffer,t,0)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),se(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let r=t.texture.mipmaps;if(r&&r.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),se(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}function ue(t,n,i){let a=r.get(t);n!==void 0&&oe(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&le(t)}function de(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,w);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps&&i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n0){s.__webglFramebuffer=[];for(let t=0;t0&&he(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0){if(he(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function U(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function ge(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(wg.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&eg(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):tg(`WebGLTextures: Unsupported texture color space:`,n)),t}function _e(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=M,this.resetTextureUnits=k,this.getTextureUnits=A,this.setTextureUnits=j,this.setTexture2D=ee,this.setTexture2DArray=P,this.setTexture3D=F,this.setTextureCube=I,this.rebindTextures=ue,this.setupRenderTarget=de,this.updateRenderTargetMipmap=fe,this.updateMultisampleRenderTarget=pe,this.setupDepthRenderbuffer=le,this.setupFrameBufferTexture=oe,this.useMultisampledRTT=he,this.isReversedDepthBuffer=function(){return n.buffers.depth.getReversed()}}function GC(e,t){function n(n,r=``){let i,a=wg.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(a===`srgb`)if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491)if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var KC=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,qC=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`,JC=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ay(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new qy({vertexShader:KC,fragmentShader:qC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Bv(new Fy(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},YC=class extends ag{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new JC,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new hg,C=null,w=new bb;w.viewport=new Fg;let T=new bb;T.viewport=new Fg;let E=[w,T],D=new Tb,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new g_,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new g_,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new g_,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let N=new X,ee=new X;function P(e,t,n){N.setFromMatrixPosition(t.matrixWorld),ee.setFromMatrixPosition(n.matrixWorld);let r=N.distanceTo(ee),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function F(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&-5,T.layers.mask=D.layers.mask&-3;let i=e.parent,a=D.cameras;F(D,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(XC.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(ZC),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function $C(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?eg(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(t.boundary=16,t.storage=e.byteLength):eg(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var ew=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),tw=null;function nw(){return tw===null&&(tw=new Uv(ew,16,16,Km,Nm),tw.name=`DFG_LUT`,tw.minFilter=Cm,tw.magFilter=Cm,tw.wrapS=vm,tw.wrapT=vm,tw.generateMipmaps=!1,tw.needsUpdate=!0),tw}var rw=class{constructor(e={}){let{canvas:t=Yh(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Em}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([Jm,qm,Gm]),g=new Set([Em,jm,km,Im,Pm,Fm]),_=new Uint32Array(4),v=new Int32Array(4),y=new X,b=null,x=null,S=[],C=[],w=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null;this._outputColorSpace=zh;let O=0,k=0,A=null,j=-1,M=null,N=new Fg,ee=new Fg,P=null,F=new x_(0),I=0,te=t.width,L=t.height,ne=1,R=null,z=null,B=new Fg(0,0,te,L),re=new Fg(0,0,te,L),ie=!1,ae=new oy,oe=!1,se=!1,ce=new Bg,le=new X,ue=new Fg,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},fe=!1;function V(){return A===null?ne:1}let H=n;function pe(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r184`),t.addEventListener(`webglcontextlost`,Le,!1),t.addEventListener(`webglcontextrestored`,Re,!1),t.addEventListener(`webglcontextcreationerror`,ze,!1),H===null){let t=`webgl2`;if(H=pe(t,e),H===null)throw pe(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw tg(`WebGLRenderer: `+e.message),e}let me,he,U,ge,_e,ve,ye,W,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe;function Fe(){me=new xx(H),me.init(),Me=new GC(H,me),he=new Zb(H,me,e,Me),U=new UC(H,me),he.reversedDepthBuffer&&d&&U.buffers.depth.setReversed(!0),ge=new wx(H),_e=new CC,ve=new WC(H,me,U,_e,he,Me,ge),ye=new bx(T),W=new Hb(H),Ne=new Yb(H,W),be=new Sx(H,W,ge,Ne),xe=new Ex(H,be,W,Ne,ge),ke=new Tx(H,he,ve),Ee=new Qb(_e),Se=new SC(T,ye,me,he,Ne,Ee),Ce=new QC(T,_e),we=new DC,Te=new PC(me),Oe=new Jb(T,ye,U,xe,p,s),De=new HC(T,xe,he),Pe=new $C(H,ge,he,U),Ae=new Xb(H,me,ge),je=new Cx(H,me,ge),ge.programs=Se.programs,T.capabilities=he,T.extensions=me,T.properties=_e,T.renderLists=we,T.shadowMap=De,T.state=U,T.info=ge}Fe(),m!==1009&&(w=new Ox(m,t.width,t.height,r,i));let Ie=new YC(T,H);this.xr=Ie,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let e=me.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=me.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(e){e!==void 0&&(ne=e,this.setSize(te,L,!1))},this.getSize=function(e){return e.set(te,L)},this.setSize=function(e,n,r=!0){if(Ie.isPresenting){eg(`WebGLRenderer: Can't change size while VR device is presenting.`);return}te=e,L=n,t.width=Math.floor(e*ne),t.height=Math.floor(n*ne),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(te*ne,L*ne).floor()},this.setDrawingBufferSize=function(e,n,r){te=e,L=n,ne=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009){tg(`THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);return}if(e){for(let t=0;t{function n(){if(r.forEach(function(e){_e.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}me.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let We=null;function Ge(e){We&&We(e)}function Ke(){Je.stop()}function qe(){Je.start()}let Je=new Vb;Je.setAnimationLoop(Ge),typeof self<`u`&&Je.setContext(self),this.setAnimationLoop=function(e){We=e,Ie.setAnimationLoop(e),e===null?Je.stop():Je.start()},Ie.addEventListener(`sessionstart`,Ke),Ie.addEventListener(`sessionend`,qe),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){tg(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Ie.enabled===!0&&Ie.isPresenting===!0,r=w!==null&&(A===null||n)&&w.begin(T,A);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ie.enabled===!0&&Ie.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Ie.cameraAutoUpdate===!0&&Ie.updateCamera(t),t=Ie.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,A),x=Te.get(e,C.length),x.init(t),x.state.textureUnits=ve.getTextureUnits(),C.push(x),ce.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),ae.setFromProjectionMatrix(ce,Gh,t.reversedDepth),se=this.localClippingEnabled,oe=Ee.init(this.clippingPlanes,se),b=we.get(e,S.length),b.init(),S.push(b),Ie.enabled===!0&&Ie.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&Ye(e,t,-1/0,T.sortObjects)}Ye(e,t,0,T.sortObjects),b.finish(),T.sortObjects===!0&&b.sort(R,z),fe=Ie.enabled===!1||Ie.isPresenting===!1||Ie.hasDepthSensing()===!1,fe&&Oe.addToRenderList(b,e),this.info.render.frame++,oe===!0&&Ee.beginShadows();let i=x.state.shadowsArray;if(De.render(i,e,t),oe===!0&&Ee.endShadows(),this.info.autoReset===!0&&this.info.reset(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t0&&Ze(n,r,e,t),fe&&Oe.render(e),Xe(b,e,t)}A!==null&&k===0&&(ve.updateMultisampleRenderTarget(A),ve.updateRenderTargetMipmap(A)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),Ne.resetDefaultState(),j=-1,M=null,C.pop(),C.length>0?(x=C[C.length-1],ve.setTextureUnits(x.state.textureUnits),oe===!0&&Ee.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function Ye(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLightProbeGrid)x.pushLightProbeGrid(e);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||ae.intersectsSprite(e)){r&&ue.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ce);let t=xe.update(e),i=e.material;i.visible&&b.push(e,t,i,n,ue.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ae.intersectsObject(e))){let t=xe.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ue.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ue.copy(e.boundingSphere.center)),ue.applyMatrix4(e.matrixWorld).applyMatrix4(ce)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&Qe(i,t,n),a.length>0&&Qe(a,t,n),o.length>0&&Qe(o,t,n),U.buffers.depth.setTest(!0),U.buffers.depth.setMask(!0),U.buffers.color.setMask(!0),U.setPolygonOffset(!1)}function Ze(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=me.has(`EXT_color_buffer_half_float`)||me.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new Lg(1,1,{generateMipmaps:!0,type:e?Nm:Em,minFilter:Tm,samples:Math.max(4,he.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:wg.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||N;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(F),I=T.getClearAlpha(),I<1&&T.setClearColor(16777215,.5),T.clear(),fe&&Oe.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),oe===!0&&Ee.setGlobalState(T.clippingPlanes,r),Qe(e,n,r),ve.updateMultisampleRenderTarget(a),ve.updateRenderTargetMipmap(a),me.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0,r.currentProgram=d,r.uniformsList=null,d}function tt(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=FS.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function nt(e,t){let n=_e.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function rt(e,t){if(e.length===0)return null;if(e.length===1)return e[0].texture===null?null:e[0];y.setFromMatrixPosition(t.matrixWorld);for(let t=0,n=e.length;t0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=_e.get(r),y=x.state.lights;if(oe===!0&&(se===!0||e!==M)){let t=e===M&&r.id===j;Ee.setState(r,e,t)}let b=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==y.state.version?b=!0:v.outputColorSpace===s?i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?b=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ee.numPlanes||v.numIntersection!==Ee.numIntersection)?b=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.toneMapping===h&&v.morphTargetsCount===_?!!v.lightProbeGrid!=x.state.lightProbeGridArray.length>0&&(b=!0):b=!0:b=!0:b=!0:(b=!0,v.__version=r.version);let S=v.currentProgram;b===!0&&(S=et(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,S,v));let C=!1,w=!1,E=!1,O=S.getUniforms(),k=v.uniforms;if(U.useProgram(S.program)&&(C=!0,w=!0,E=!0),r.id!==j&&(j=r.id,w=!0),v.needsLights){let e=rt(x.state.lightProbeGridArray,i);v.lightProbeGrid!==e&&(v.lightProbeGrid=e,w=!0)}if(C||M!==e){U.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(H,`projectionMatrix`,e.projectionMatrix),O.setValue(H,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(H,le.setFromMatrixPosition(e.matrixWorld)),he.logarithmicDepthBuffer&&O.setValue(H,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(H,`isOrthographic`,e.isOrthographicCamera===!0),M!==e&&(M=e,w=!0,E=!0)}if(v.needsLights&&(y.state.directionalShadowMap.length>0&&O.setValue(H,`directionalShadowMap`,y.state.directionalShadowMap,ve),y.state.spotShadowMap.length>0&&O.setValue(H,`spotShadowMap`,y.state.spotShadowMap,ve),y.state.pointShadowMap.length>0&&O.setValue(H,`pointShadowMap`,y.state.pointShadowMap,ve)),i.isSkinnedMesh){O.setOptional(H,i,`bindMatrix`),O.setOptional(H,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(H,`boneTexture`,e.boneTexture,ve))}i.isBatchedMesh&&(O.setOptional(H,i,`batchingTexture`),O.setValue(H,`batchingTexture`,i._matricesTexture,ve),O.setOptional(H,i,`batchingIdTexture`),O.setValue(H,`batchingIdTexture`,i._indirectTexture,ve),O.setOptional(H,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(H,`batchingColorTexture`,i._colorsTexture,ve));let N=n.morphAttributes;if((N.position!==void 0||N.normal!==void 0||N.color!==void 0)&&ke.update(i,n,S),(w||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,O.setValue(H,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),k.dfgLUT!==void 0&&(k.dfgLUT.value=nw()),w){if(O.setValue(H,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&at(k,E),a&&r.fog===!0&&Ce.refreshFogUniforms(k,a),Ce.refreshMaterialUniforms(k,r,ne,L,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.lightProbeGrid){let e=v.lightProbeGrid;k.probesSH.value=e.texture,k.probesMin.value.copy(e.boundingBox.min),k.probesMax.value.copy(e.boundingBox.max),k.probesResolution.value.copy(e.resolution)}FS.upload(H,tt(v),k,ve)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(FS.upload(H,tt(v),k,ve),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(H,`center`,i.center),O.setValue(H,`modelViewMatrix`,i.modelViewMatrix),O.setValue(H,`normalMatrix`,i.normalMatrix),O.setValue(H,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&ve.useMultisampledRTT(e)===!1?_e.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,N.copy(e.viewport),ee.copy(e.scissor),P=e.scissorTest}else N.copy(B).multiplyScalar(ne).floor(),ee.copy(re).multiplyScalar(ne).floor(),P=ie;if(n!==0&&(r=st),U.bindFramebuffer(H.FRAMEBUFFER,r)&&U.drawBuffers(e,r),U.viewport(N),U.scissor(ee),U.setScissorTest(P),i){let r=_e.get(e.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t1&&H.readBuffer(H.COLOR_ATTACHMENT0+s),!he.textureFormatReadable(c)){tg(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!he.textureTypeReadable(l)){tg(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&H.readPixels(t,n,r,i,Me.convert(c),Me.convert(l),a)}finally{let e=A===null?null:_e.get(A).__webglFramebuffer;U.bindFramebuffer(H.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=_e.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){U.bindFramebuffer(H.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(e.textures.length>1&&H.readBuffer(H.COLOR_ATTACHMENT0+s),!he.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!he.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,d),H.bufferData(H.PIXEL_PACK_BUFFER,a.byteLength,H.STREAM_READ),H.readPixels(t,n,r,i,Me.convert(l),Me.convert(u),0);let f=A===null?null:_e.get(A).__webglFramebuffer;U.bindFramebuffer(H.FRAMEBUFFER,f);let p=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await rg(H,p,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,d),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,a),H.deleteBuffer(d),H.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;ve.setTexture2D(e,0),H.copyTexSubImage2D(H.TEXTURE_2D,n,0,0,o,s,i,a),U.unbindTexture()};let ct=H.createFramebuffer(),lt=H.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=Me.convert(t.format),_=Me.convert(t.type),v;t.isData3DTexture?(ve.setTexture3D(t,0),v=H.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ve.setTexture2DArray(t,0),v=H.TEXTURE_2D_ARRAY):(ve.setTexture2D(t,0),v=H.TEXTURE_2D),U.activeTexture(H.TEXTURE0),U.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,t.flipY),U.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),U.pixelStorei(H.UNPACK_ALIGNMENT,t.unpackAlignment);let y=U.getParameter(H.UNPACK_ROW_LENGTH),b=U.getParameter(H.UNPACK_IMAGE_HEIGHT),x=U.getParameter(H.UNPACK_SKIP_PIXELS),S=U.getParameter(H.UNPACK_SKIP_ROWS),C=U.getParameter(H.UNPACK_SKIP_IMAGES);U.pixelStorei(H.UNPACK_ROW_LENGTH,h.width),U.pixelStorei(H.UNPACK_IMAGE_HEIGHT,h.height),U.pixelStorei(H.UNPACK_SKIP_PIXELS,l),U.pixelStorei(H.UNPACK_SKIP_ROWS,u),U.pixelStorei(H.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=_e.get(e),r=_e.get(t),h=_e.get(n.__renderTarget),g=_e.get(r.__renderTarget);U.bindFramebuffer(H.READ_FRAMEBUFFER,h.__webglFramebuffer),U.bindFramebuffer(H.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n{let t=e;if(t.geometry&&t.geometry.dispose(),t.material){let e=t.material;Array.isArray(e)?e.forEach(e=>e.dispose()):e.dispose()}})}function dw(){sw.forEach(e=>{uw(e),aw&&aw.remove(e)}),sw=[]}var fw=(e,t,n)=>{if(iw||(iw=new rw({alpha:!0,antialias:!0,preserveDrawingBuffer:!0}),iw.setPixelRatio(Math.min(devicePixelRatio,2)),iw.setClearColor(0,0)),iw.setSize(e,t),!aw||cw!==n.threejsScene){aw&&dw(),aw=new C_,ow=new bb(75,e/t,.1,1e3),ow.position.set(0,0,5),cw=n.threejsScene;let r=n.threejsScene??`stars`;switch(lw.set(n.threejsColor??`#a855f7`),r){case`cubes`:{let e=new jy;for(let t=0;t<20;t++){let t=new Bv(e,new Ov({color:lw,wireframe:!0}));t.position.set((Math.random()-.5)*10,(Math.random()-.5)*10,(Math.random()-.5)*10),aw.add(t),sw.push(t)}break}case`waves`:{let e=new Fy(20,20,32,32),t=Float32Array.from(e.attributes.position.array);e.userData.origPos=t;let n=new Bv(e,new Ov({color:lw,wireframe:!0}));n.rotation.x=-Math.PI/2,aw.add(n),sw.push(n);break}case`particles`:{let e=5e3,t=new Float32Array(e*3);for(let n=0;nt%3==1));n.userData.origY=r;let i=new Bv(n,new Ov({color:lw,transparent:!0,opacity:.15+t*.05,side:2}));i.position.set(0,2+t*.6,-3-t*.5),i.rotation.x=-.3,e.add(i)}aw.add(e),sw.push(e);let t=1e3,n=new Float32Array(t*3);for(let e=0;e{if(fw(t,n,r),!iw||!aw||!ow)return null;let i=r.threejsSpeed??1,a=e*i,o=r.threejsScene??`stars`;switch(lw.set(r.threejsColor??`#a855f7`),sw.forEach(e=>{e.userData.keepColor||e.traverse(e=>{if(e.userData.keepColor)return;let t=e;t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(e=>{e.color&&e.color.copy(lw)})})}),o){case`cubes`:sw.forEach((e,t)=>{e.rotation.x=a*.5+t,e.rotation.y=a*.5+t});break;case`waves`:{let e=sw[0],t=e.geometry.attributes.position,n=t.array,r=e.geometry.userData.origPos,i=t.count;for(let e=0;e{if(!(e instanceof Bv))return;let n=e.geometry.attributes.position,r=n.array,i=e.geometry.userData.origY,o=t*.7,s=n.count;for(let e=0;e{e.rotation.y=a*(.03+t*.015),e.rotation.x=Math.sin(a*.1+t)*.1});break;case`rings`:{let e=sw[0];e.children[0]&&(e.children[0].rotation.y=a*.3,e.children[0].rotation.x=a*.1);for(let t=1;t{let r=(a*5+n*1.5)%t;e.position.z=5-r;let i=Math.max(0,(1-r/(t*.9))*.8);e.material.opacity=i});break}case`warp`:{let e=sw[0],t=e.geometry.attributes.position,n=t.array,{TAIL:r}=e.userData,a=t.count/2,o=3*i;for(let e=0;e5&&(t-=100),n[e*6+2]=t,n[e*6+5]=t+r}t.needsUpdate=!0;break}case`cybergrid`:{let e=sw[0],t=a*5%100;e.children.forEach(e=>{let n=e.userData.tileIndex;e.position.z=-n*100+t});break}case`vortex`:{let e=sw[0],t=e.geometry.attributes.position,n=t.array,{angles:r,radii:a,heights:o}=e.userData,s=10/5*.01*i,c=.05*i,l=t.count;for(let e=0;e10&&(o[e]-=20),n[e*3]=Math.cos(r[e])*a[e],n[e*3+1]=o[e],n[e*3+2]=Math.sin(r[e])*a[e];t.needsUpdate=!0;break}case`crystals`:sw[0].children.forEach(e=>{let{rotSpeed:t}=e.userData;e.rotation.x+=t.x*i,e.rotation.y+=t.y*i,e.rotation.z+=t.z*i,e.position.y+=Math.sin(a+e.position.x)*.005});break;default:{let e=sw[0];e&&(e.rotation.x=a*.05,e.rotation.y=a*.05,e.rotation.z=a*.01);break}}return r.threejsBgColor?iw.setClearColor(new x_(r.threejsBgColor),1):iw.setClearColor(0,0),r.threejsCameraMovement?gw(ow,o,a):hw(ow,o),iw.render(aw,ow),iw.domElement},vw=()=>{dw(),iw&&=(iw.dispose(),null),aw=null,ow=null,cw=void 0},yw=({isPlaying:e,currentTime:t,config:n})=>{let r=(0,w.useRef)(null),i=(0,w.useRef)(null),a=(0,w.useRef)(e),o=(0,w.useRef)(t),s=(0,w.useRef)(n);return(0,w.useEffect)(()=>{a.current=e},[e]),(0,w.useEffect)(()=>{o.current=t},[t]),(0,w.useEffect)(()=>{s.current=n},[n]),(0,w.useEffect)(()=>{let e,t=performance.now(),n=o.current,c=l=>{let u=(l-t)/1e3;t=l,a.current?n+=u:n=o.current;let d=r.current,f=d&&d.clientWidth||1280,p=d&&d.clientHeight||720,m=_w(n,f,p,s.current);m&&d&&i.current!==m&&(d.innerHTML=``,d.appendChild(m),i.current=m,m.style.width=`100%`,m.style.height=`100%`,m.style.objectFit=`cover`,m.style.display=`block`),e=requestAnimationFrame(c)};return e=requestAnimationFrame(c),()=>{cancelAnimationFrame(e),vw(),i.current=null}},[]),(0,K.jsx)(`div`,{ref:r,className:`absolute inset-0 pointer-events-none`})};function bw(e){let t=e?.lyricDisplayMode;return t===`static-all`||t===`static-compact`||t===`static-compact-comma`||t===`static-compact-clean`}function xw(e,t,n,r,i={}){if(!(n?.showLyrics??!0))return!1;let a=r.length>0&&r.every(e=>e.time===0&&(e.endTime===void 0||e.endTime===0)),o=bw(n),s=a?-1:tt(r,e),c=!1,l=s;if(n?.lyricVisibilityMode===`auto`&&!a&&!o&&r.length>0){let n=mt(r,e,t);c=n.autoHideLyrics,l=c?-1:n.displayIdx}let u=l===-1&&e<5&&(n?.showIntro??!0)&&(n?.introMode!==`manual`||(i.isFirstSongInPlaylist??!0))&&(r.length===0||e0||o&&r.length>0)}function Sw(e,t,n,r=[],i={}){if(!n?.showFloatingNotes)return!1;switch(n.floatingNotesVisibilityMode??`all`){case`all`:return!0;case`from-start`:{let t=n.floatingNotesFromStartDuration??10;return e>=0&&e=Math.max(0,t-r)&&e<=t}case`from-start-and-end`:{let r=n.floatingNotesFromStartDuration??10,i=e>=0&&e=Math.max(0,t-a)&&e<=t;return i||o}case`specific`:{let t=G(n.floatingNotesSpecificStart??`0:00`),r=n.floatingNotesSpecificEnd;if(!r||!r.trim())return e>=t;let i=G(r);return i<=t?e>=t:e>=t&&e{let y=e=>{let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:{r:255,g:255,b:255}},b=r=>{let i=0,a=0;if(r instanceof ImageBitmap?(i=r.width,a=r.height):r instanceof HTMLVideoElement?(i=r.videoWidth,a=r.videoHeight):(i=r.width,a=r.height),i&&a){let o=Math.max(t/i,n/a),s=t/2-i/2*o,c=n/2-a/2*o;e.drawImage(r,s,c,i*o,a*o)}},x=(e,t,n)=>{if(t.includes(` +`))return t.split(` +`).flatMap(t=>x(e,t,n));let r=t.split(` `),i=[],a=r[0]||``;for(let t=1;t{if(i===`vhs`&&e instanceof CanvasRenderingContext2D)e.save(),e.globalCompositeOperation=`screen`,e.fillStyle=`#ff0000`,e.fillText(t,n-2,r),e.fillStyle=`#00ff00`,e.fillText(t,n,r),e.fillStyle=`#0000ff`,e.fillText(t,n+2,r),e.restore();else if(i===`3d`){let i=e.fillStyle;e.fillStyle=`rgba(0,0,0,0.5)`;for(let i=1;i<=4;i++)e.fillText(t,n+i,r+i);e.fillStyle=i,e.fillText(t,n,r)}else if(i===`neon`)e.shadowColor=e.fillStyle,e.shadowBlur=20,e.fillText(t,n,r),e.shadowBlur=40,e.fillText(t,n,r);else if(i===`outline`)e.strokeText(t,n,r),e.fillText(t,n,r);else if(i===`gradient`){let i=e.createLinearGradient(n,r-20,n,r+20);i.addColorStop(0,e.fillStyle),i.addColorStop(1,`#ffffff`),e.fillStyle=i,e.fillText(t,n,r)}else if(i===`fire`)e.save(),e.shadowBlur=5,e.shadowColor=`#ff0000`,e.fillStyle=`#ff4500`,e.fillText(t,n,r),e.shadowBlur=2,e.shadowColor=`#ffff00`,e.fillStyle=`#ffcc00`,e.fillText(t,n+1,r-1),e.restore();else if(i===`emboss`)e.fillStyle=`rgba(255,255,255,0.7)`,e.fillText(t,n-1,r-1),e.fillStyle=`rgba(0,0,0,0.7)`,e.fillText(t,n+1,r+1),e.fillStyle=`rgba(128,128,128,0.5)`,e.fillText(t,n,r);else if(i===`mirror`)e.fillText(t,n,r),e.save(),e.translate(n,r),e.scale(1,-1),e.translate(-n,-r),e.globalAlpha*=.2,e.fillText(t,n,r-40),e.restore();else if(i===`neon-multi`)e.fillStyle,e.shadowBlur=10,e.shadowColor=`#fff`,e.fillText(t,n,r),e.shadowBlur=20,e.shadowColor=`#ff00de`,e.fillText(t,n,r),e.shadowBlur=35,e.shadowColor=`#00ffff`,e.fillText(t,n,r);else if(i===`gold`){let i=e.createLinearGradient(n,r-20,n,r+20);i.addColorStop(0,`#d4af37`),i.addColorStop(1,`#C5A028`),e.fillStyle=i,e.fillText(t,n,r)}else if(i===`chrome`){let i=e.createLinearGradient(n,r-20,n,r+20);i.addColorStop(0,`#ebebeb`),i.addColorStop(.5,`#616161`),i.addColorStop(.51,`#ebebeb`),i.addColorStop(1,`#ebebeb`),e.fillStyle=i,e.fillText(t,n,r)}else if(i===`frozen`)e.shadowColor=`#03A9F4`,e.shadowBlur=20,e.fillStyle=`#ffffff`,e.fillText(t,n,r);else if(i===`rainbow`){let i=e.createLinearGradient(n-100,r,n+100,r);i.addColorStop(0,`violet`),i.addColorStop(.16,`indigo`),i.addColorStop(.32,`blue`),i.addColorStop(.48,`green`),i.addColorStop(.64,`yellow`),i.addColorStop(.8,`orange`),i.addColorStop(1,`red`),e.fillStyle=i,e.fillText(t,n,r)}else if(i===`retro`)e.fillStyle=`#ff00ff`,e.shadowColor=`#00ffff`,e.shadowBlur=0,e.shadowOffsetX=4,e.shadowOffsetY=4,e.fillText(t,n,r);else if(i===`cyberpunk`)e.save(),e.fillStyle=`#05d9e8`,e.fillText(t,n-1,r-1),e.restore(),e.save(),e.fillStyle=`#000000`,e.fillText(t,n+2,r+2),e.restore(),e.save(),e.fillStyle=`#fcee0a`,e.fillText(t,n,r),e.restore();else if(i===`glitch-text`){let i=(Math.random()-.5)*5,a=(Math.random()-.5)*2;e.save(),e.fillStyle=`red`,e.fillText(t,n+i,r+a),e.restore(),e.save(),e.fillStyle=`cyan`,e.fillText(t,n-i,r-a),e.restore(),e.fillStyle=`#ffffff`,e.fillText(t,n,r)}else i===`hologram`?(e.fillStyle=`rgba(0, 255, 255, 0.7)`,e.shadowColor=`rgba(0,255,255,0.5)`,e.shadowBlur=10,e.fillText(t,n,r)):i===`comic`?(e.lineWidth=3,e.strokeStyle=`#000000`,e.strokeText(t,n,r),e.fillStyle=`#ffcc00`,e.fillText(t,n,r)):e.fillText(t,n,r);if(a&&a!==`none`){let i=e.measureText(t).width,o=n;if(e.textAlign===`center`?o=n-i/2:e.textAlign===`right`&&(o=n-i),e.save(),e.beginPath(),e.lineWidth=Math.max(2,4*O),e.strokeStyle=e.fillStyle,a.includes(`line-through`)&&(e.moveTo(o,r),e.lineTo(o+i,r)),a.includes(`underline`)){let t=e.font.match(/(\d+(\.\d+)?)px/),n=r+(t?parseFloat(t[1]):50)*.4;e.moveTo(o,n),e.lineTo(o+i,n)}e.stroke(),e.restore()}},C=(e,t,n,r,i,a,o,s,c,u,d,f,p)=>{let m=s?.textCase||`none`,h=(e,t)=>{if(!e)return e;if(m===`upper`)return e.toUpperCase();if(m===`lower`)return e.toLowerCase();if(m===`title`)return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());if(m===`sentence`){let n=e.toLowerCase();return t?n.charAt(0).toUpperCase()+n.slice(1):n}return m===`invert`?e.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase()):e},g=t.words||[];if(g.length===0){let e=t.text.split(` +`);g=[],e.forEach((n,r)=>{let i=n.split(` `).map(e=>({text:e,startTime:t.time,endTime:t.endTime||t.time+3}));g.push(...i),re.text===` +`||e.text.trim().length>0).map((e,t)=>({...e,text:e.text===` +`?` +`:h(e.text,t===0).trim()}));(s?.highlightEffect?.includes(`cyberpunk`)||s?.textEffect===`cyberpunk`)&&(c=`'Orbitron', sans-serif`),e.font=`${f} ${d} ${u}px ${c}`;let v=[],y=[],b=0,x=.3;[`default`,`custom`].includes(l)?x=.25:l===`monospace`&&(x=.5);let C=e.measureText(`M`).width*x;_.forEach((t,n)=>{if(t.text===` +`){y.length>0&&v.push(y),y=[],b=0;return}let r=e.measureText(t.text).width,a=!t.text.endsWith(` `),o=/[-‐‑‒–—―]$/,s=/^[-‐‑‒–—―]/;o.test(t.text.trim())&&(a=!1);let c=_[n+1];c&&(s.test(c.text.trim())||c.text===` +`)&&(a=!1);let l=a?C:0;b+r>i&&y.length>0&&(v.push(y),y=[],b=0),y.push(t),b+=r+l}),y.length>0&&v.push(y);let w=r-(v.length-1)*a/2,T=s.highlightColor||`#fb923c`,E=s.highlightBackground||`#ffffff`,D=s.highlightEffect||`none`;s.useCustomHighlightColors||(D.includes(`blue`)||D.includes(`cyan`)?(T=`#3b82f6`,E=`#3b82f6`):D.includes(`purple`)?(T=`#a855f7`,E=`#a855f7`):D.includes(`green`)?(T=`#22c55e`,E=`#22c55e`):D.includes(`pink`)?(T=`#ec4899`,E=`#ec4899`):D.includes(`neon`)?(T=`#ffffff`,E=`#ffffff`):D.includes(`gold`)?(T=`#FFD700`,E=`#B8860B`):D.includes(`chrome`)?(T=`#E0E0E0`,E=`#757575`):D.includes(`fire`)?(T=`#FF4500`,E=`#FF0000`):D.includes(`glass`)?(T=`#ffffff`,E=`rgba(255,255,255,0.1)`):D===`karaoke`&&(T=`#fb923c`,E=`#fb923c`));let O=s.fontColor||`#ffffff`;s.highlightEffect===`karaoke-smooth-white`&&(O=`#ffffff`),v.forEach((t,r)=>{let i=w+r*a,c=0;t.forEach((n,r)=>{if(c+=e.measureText(n.text).width,r{let c=e.measureText(n.text).width,d=o>=n.startTime,f=o>=n.startTime&&o.3&&e<.45)&&(b=1.15,x=1.15)}else if(D.includes(`flash`))w=.5+Math.sin(o*10)*.5;else if(D.includes(`tada`)){let e=o*2%1;e<.1?(y=-.05,b=.9):e<.2&&(y=.05,b=1.1)}else D.includes(`swing`)?y=Math.sin(o*4)*.15:D.includes(`glitch`)&&Math.sin(o*15)>.8&&(v+=(Math.random()-.5)*10,_+=(Math.random()-.5)*10);let t=.3;if(e1-(1-e)**3)(n);if(D.includes(`fade`))w=n;else if(D.includes(`slide`))_+=(1-r)*30*p,w=r;else if(D.includes(`drop`))_-=(1-r)*50*p,w=r;else if(D.includes(`zoom`)||D.includes(`scale`)){let e=.5+.5*r;b*=e,x*=e}else if(D.includes(`elastic`)){let e=n===0?0:n===1?1:2**(-10*n)*Math.sin((n*10-.75)*(2*Math.PI)/3)+1;b*=e,x*=e}else if(D.includes(`flip`))x*=r;else if(D.includes(`rotate-in`))y+=(1-r)*-1,w=r;else if(D.includes(`roll`))v-=(1-r)*50*p,y-=(1-r)*Math.PI,w=r;else if(D.includes(`lightspeed`))v+=(1-r)*100*p,w=r;else if(D.includes(`blur`))k=(1-r)*10,w=r;else if(D.includes(`shatter`)){let e=1+(1-r)*2;b*=e,x*=e,k=(1-r)*10,w=r}else D.includes(`spiral`)&&(b*=r,x*=r,y+=(1-r)*Math.PI*2)}else D.includes(`scale`)&&(b*=1.3,x*=1.3)}if(e.save(),w<1&&(e.globalAlpha*=w),k>0&&(e.filter=`blur(${k}px)`),y!==0||b!==1||x!==1){let t=v+c/2,n=_;e.translate(t,n),e.rotate(y),e.scale(b,x),e.translate(-t,-n)}if(g){if(D===`karaoke-smooth-plus`){let t=s.textEffect||`none`;if(f){let r=n.endTime-n.startTime,i=o-n.startTime,l=Math.max(0,Math.min(1,i/r)),d=v+c*l,f=s?.textDecoration||`none`,h=t=>{if(f!==`none`){e.lineWidth=Math.max(2,3*p),e.strokeStyle=t,e.beginPath();let n=_+u*.45;f.includes(`underline`)&&(e.moveTo(v,n),e.lineTo(v+c,n)),f.includes(`line-through`)&&(e.moveTo(v,_),e.lineTo(v+c,_)),e.stroke()}};e.save(),e.beginPath(),e.rect(v-50,_-a,d-(v-50),a*2),e.clip(),e.fillStyle=T,S(e,n.text,v,_,t),h(T),e.restore(),e.save(),e.beginPath(),e.rect(d,_-a,v+c+50-d,a*2),e.clip(),e.fillStyle=O,e.fillText(n.text,v,_),h(O),e.restore(),m=`rgba(0,0,0,0)`}else e.fillStyle=T,S(e,n.text,v,_,t),m=T}else if(D.includes(`gradient`)||D.includes(`chrome`)||D.includes(`gold`)){let t=e.createLinearGradient(v,_-a/2,v,_+a/2);D.includes(`gold`)?(t.addColorStop(0,`#d4af37`),t.addColorStop(1,`#C5A028`)):D.includes(`chrome`)?(t.addColorStop(0,`#ebebeb`),t.addColorStop(.5,`#616161`),t.addColorStop(.51,`#ebebeb`),t.addColorStop(1,`#ebebeb`)):(t.addColorStop(0,T),t.addColorStop(1,E)),e.fillStyle=t}if(D.includes(`shadow`)&&(e.save(),e.fillStyle=`#000000`,e.fillText(n.text,v+2*p,_+2*p),e.restore()),D.includes(`3d`)){let t=e.fillStyle;e.fillStyle=`rgba(0,0,0,0.5)`;for(let t=1;t<=3;t++)e.fillText(n.text,v+t*p,_+t*p);e.fillStyle=t}if(D.includes(`neon-multi`))e.shadowBlur=10,e.shadowColor=`#fff`,e.fillText(n.text,v,_),e.shadowBlur=20,e.shadowColor=`#ff00de`,e.fillText(n.text,v,_),e.shadowBlur=35,e.shadowColor=`#00ffff`,e.fillText(n.text,v,_);else if(D.includes(`cyberpunk`))e.save(),e.fillStyle=`#05d9e8`,e.fillText(n.text,v-1,_-1),e.restore(),e.save(),e.fillStyle=`#000000`,e.fillText(n.text,v+2,_+2),e.restore(),e.fillStyle=`#fcee0a`,e.fillText(n.text,v,_);else if(D.includes(`glitch-text`)){let t=(Math.random()-.5)*5,r=(Math.random()-.5)*2;e.save(),e.fillStyle=`red`,e.fillText(n.text,v+t,_+r),e.restore(),e.save(),e.fillStyle=`cyan`,e.fillText(n.text,v-t,_-r),e.restore(),e.fillStyle=`#ffffff`,e.fillText(n.text,v,_)}else if(D.includes(`retro`)||D.includes(`vhs`)){let t=Math.sin(o*5)*2*p,r=Math.random()>.95?(Math.random()-.5)*5:0;e.globalCompositeOperation=`screen`,e.fillStyle=`#ff0000`,e.fillText(n.text,v-3*p+t,_+r),e.fillStyle=`#00ff00`,e.fillText(n.text,v+r,_-t),e.fillStyle=`#0000ff`,e.fillText(n.text,v+3*p-t,_+r)}else if(D.includes(`fire`)){let t=Math.abs(Math.sin(o*15))*5,r=Math.sin(o*20)*1*p;e.shadowBlur=5+t,e.shadowColor=`#ff0000`,e.fillStyle=`#ff4500`,e.fillText(n.text,v,_+r),e.shadowBlur=2,e.shadowColor=`#ffff00`,e.fillStyle=`#ffcc00`,e.fillText(n.text,v+Math.sin(o*25)*1*p,_-1*p+r)}else if(D.includes(`typewriter`)){let t=o-n.startTime,r=n.endTime-n.startTime,i=Math.min(1,Math.max(0,t/r)),a=Math.floor(n.text.length*i),s=n.text.substring(0,a);D.includes(`outline`)?(e.strokeStyle=T,e.strokeText(s,v,_)):e.fillText(s,v,_)}else !D.includes(`neon-multi`)&&!D.includes(`retro`)&&!D.includes(`vhs`)&&!D.includes(`fire`)&&(D.includes(`outline`)?(e.strokeStyle=T,e.lineWidth=2*p,e.strokeText(n.text,v,_)):e.fillText(n.text,v,_))}else e.fillText(n.text,v,_);let A=s?.textDecoration||`none`;if(A!==`none`){if(e.lineWidth=Math.max(2,3*p),e.strokeStyle=m,e.beginPath(),A.includes(`underline`)&&!D.includes(`underline`)){let t=_+u*.45;e.moveTo(v,t),e.lineTo(v+c,t)}A.includes(`line-through`)&&(e.moveTo(v,_),e.lineTo(v+c,_)),e.stroke()}e.restore(),e.restore();let j=!n.text.endsWith(` `),M=/[-‐‑‒–—―]$/,N=/^[-‐‑‒–—―]/;M.test(n.text.trim())&&(j=!1);let ee=t[r+1];ee&&N.test(ee.text.trim())&&(j=!1),l+=c+(j?C:0)}),e.restore()})},w=(e,t,n,r,i,a,o,s)=>{let c=x(e,t,i),l=r-(c.length-1)*a/2;c.forEach((t,r)=>{let i=l+r*a;if(o===`glass`){let r=e.measureText(t).width;e.save(),e.fillStyle=`rgba(255, 255, 255, 0.1)`,e.beginPath(),e.roundRect?e.roundRect(n-(e.textAlign===`center`?r/2:e.textAlign===`right`?r:0)-10,i-a/2,r+20,a,8):e.rect(n-(e.textAlign===`center`?r/2:e.textAlign===`right`?r:0)-10,i-a/2,r+20,a),e.fill(),e.strokeStyle=`rgba(255, 255, 255, 0.2)`,e.stroke(),e.restore()}S(e,t,n,i,o,s)})},T=`ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`,E=T;l===`classic`?E=`ui-serif, Georgia, Cambria, "Times New Roman", Times, serif`:l===`monospace`?E=`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`:l===`metal`?E=`"Metal Mania", cursive`:l===`kids`?E=`"Fredoka One", cursive`:l===`sad`?E=`"Shadows Into Light", cursive`:l===`romantic`?E=`"Dancing Script", cursive`:l===`tech`?E=`"Orbitron", sans-serif`:l===`gothic`?E=`"UnifrakturMaguntia", cursive`:l===`custom`&&(E=m?.fontFamily||T),u&&(E=`CustomFont, sans-serif`),m&&m.fontFamily!==`sans-serif`&&(E=m.fontFamily);let D=t<=n,O=Math.min(t,n)/1080;if(m&&(m.backgroundSource===`color`||m.backgroundSource===`smart-gradient`)?e.fillStyle=m.backgroundColor||`#000000`:m&&m.backgroundSource===`threejs`?e.fillStyle=m.threejsBgColor||`#000000`:e.fillStyle=`#000000`,e.fillRect(0,0,t,n),m?.backgroundSource===`gradient`&&m.backgroundGradient)e.fillStyle=m.backgroundGradient,e.fillRect(0,0,t,n);else if(m?.backgroundSource===`smart-gradient`){let r=m.backgroundColor||`#312e81`,i=y(r),a=e.createLinearGradient(0,0,t,n);a.addColorStop(0,r),a.addColorStop(.5,`rgb(${Math.floor(i.r*.6)}, ${Math.floor(i.g*.6)}, ${Math.floor(i.b*.6)})`),a.addColorStop(1,`#000000`),e.fillStyle=a,e.fillRect(0,0,t,n)}else if(m?.backgroundSource===`image`&&m.backgroundImage){let e=s.get(`__custom_bg__`);e&&b(e)}else if(m?.backgroundSource===`video`&&m.backgroundVideo){let e=c.get(`__custom_bg_video__`);e&&b(e)}else if(m?.backgroundSource===`threejs`){let i=_w(r,t,n,m);i&&e.drawImage(i,0,0,t,n)}if(m&&m.backgroundBlurStrength>0?e.filter=`blur(${m.backgroundBlurStrength}px)`:f&&(e.filter=`blur(12px)`),!m||m.backgroundSource===`timeline`||m.backgroundSource===`custom`){let t=m?m.backgroundSource===`timeline`:!1,n=!1;if(t){let t=m?.visualTransitionType||`none`,i=m?.visualTransitionDuration||1,a=o.filter(e=>e.type===`audio`?!1:r>=e.startTime&&r=e.endTime&&r{let n=(e.layer||0)-(t.layer||0);return n===0?e.startTime-t.startTime:n}),a.length>0&&(a.forEach(n=>{let a=n.layer||0;if(m&&m.layerVisibility?.visual?.[a]===!1)return;let l=n.type===`video`?c.get(n.id):null,u=n.type===`video`?null:s.get(n.id),d=1;if(t!==`none`){if(r=n.endTime){let e=!1;if(t===`crossfade`&&(e=o.some(e=>e.id!==n.id&&(e.layer||0)===(n.layer||0)&&e.startTime>=n.endTime-.1&&e.startTimen.endTime-i){let e=(n.endTime-r)/i;d=Math.min(d,Math.max(0,Math.min(1,e)))}}d>0&&(e.save(),e.globalAlpha=d,l?b(l):u&&b(u),e.restore())}),n=!0)}let i=m?.backgroundSource||`custom`,l=i===`custom`||i===`timeline`&&o.length===0;if(!n&&a.coverUrl&&l){let e=a.backgroundType===`video`?c.get(`background`):null,t=s.get(`cover`);e?b(e):t&&b(t)}}if((m&&m.backgroundBlurStrength>0||f)&&(e.filter=`none`),![`just_video`,`none`].includes(l)&&!m?.useRealColorMedia&&(e.fillStyle=m&&(m.backgroundSource===`color`||m.backgroundSource===`gradient`)?`rgba(0, 0, 0, 0.2)`:`rgba(0, 0, 0, 0.5)`,e.fillRect(0,0,t,n)),m?.enableGradientOverlay){let r=e.createLinearGradient(0,n,0,0);r.addColorStop(0,`rgba(0, 0, 0, 0.95)`),r.addColorStop(.35,`rgba(0, 0, 0, 0.6)`),r.addColorStop(.7,`rgba(0, 0, 0, 0)`),e.fillStyle=r,e.fillRect(0,0,t,n)}if(m?.showVisualization&&_&&_.length>0){e.save();let i=Vp(m);Hp(e,_,v||null,t,n,i,r*1e3),e.restore()}if(l===`just_video`||l===`none`)return;let k=tt(i,r),A=i.length>0&&i.every(e=>e.time===0&&(e.endTime===void 0||e.endTime===0)),j=m?.lyricVisibilityMode===`auto`,M=!1,N=A?-1:k,ee=m?.lyricDisplayMode===`static-all`||m?.lyricDisplayMode===`static-compact`||m?.lyricDisplayMode===`static-compact-comma`||m?.lyricDisplayMode===`static-compact-clean`,P=N;if(j&&!A&&!ee&&i.length>0){let e=mt(i,r,p);M=e.autoHideLyrics,M?(N=-1,P=e.virtualActiveIdx):(N=e.displayIdx,P=e.virtualActiveIdx)}else if(!ee&&P===-1&&i.length>0)if(re.time>r);P=e===-1?i.length-1:e}let F=m?.introMode===`manual`&&m.introText?m.introText:`${a.title}\n${a.artist}`,I=N===-1&&r<5&&(m?.showIntro??!0)&&(m?.introMode!==`manual`||g)&&(i.length===0||r0||ee&&i.length>0)){let a=n/2;m?.contentPosition===`top`?a=n*(.15*(m.marginTopScale??1)):m?.contentPosition===`bottom`&&(a=n*(1-.1*(m.marginBottomScale??1)));let o=0,s=[`large`,`large_upper`,`big_center`,`metal`,`kids`,`sad`,`romantic`,`tech`,`gothic`,`testing`,`testing_up`,`one_line`,`one_line_up`,`custom`].includes(l);if(s||l===`slideshow`||l===`subtitle`){let n=I?{time:0,text:F}:i[N]||i[P];if(n){e.font=`900 ${te}px ${E}`;let r=x(e,[`large_upper`,`big_center`,`metal`,`tech`,`testing_up`,`one_line_up`].includes(l)?n.text.toUpperCase():n.text,t*.9);r.length>1&&(o=(r.length-1)*(te*1.2)/2)}}if(ee&&i.length>0){let r=t*.85,o=40*O,s=n*.75;m?.contentPosition===`top`&&(s=n*.6),m?.contentPosition===`bottom`&&(s=n*.6),e.textAlign=m?.textAlign||`center`,e.textBaseline=`middle`,e.fillStyle=m?.fontColor||`#ffffff`;let c=m?.fontWeight||`bold`,l=m?.fontStyle||`normal`,u=m?.textDecoration||`none`,d=m?.textEffect===`preset`?`none`:m?.textEffect||`none`,f=m?.lyricDisplayMode;if(f===`static-compact`||f===`static-compact-comma`||f===`static-compact-clean`){let n=``,p=[],h=[];for(let e=0;e0&&(p.push(h),h=[]):h.push(t)}h.length>0&&p.push(h);let g=m?.textCase||`none`,_=e=>{if(!e)return e;if(g===`upper`)return e.toUpperCase();if(g===`lower`)return e.toLowerCase();if(g===`title`)return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());if(g===`sentence`){let t=e.toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}return g===`invert`?e.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase()):e};n=f===`static-compact`?p.map(e=>_(e.join(` / `))).join(` // `):f===`static-compact-comma`?p.map(e=>_(e.join(`, `))+`.`).join(` +`):p.map(e=>_(e.join(` `))+`.`).join(` +`);let v=te*.6,y=14*O,b=1.5;for(;v>=y&&(e.font=`${l} ${c} ${v}px ${E}`,!(x(e,n,r).length*v*b<=s));v-=1*O);v=Math.max(v,y),e.font=`${l} ${c} ${v}px ${E}`;let C=x(e,n,r),w=v*b,T=C.length*w,D=a-T/2+w/2,k=t/2;e.textAlign===`left`?k=o:e.textAlign===`right`&&(k=t-o),C.forEach((t,n)=>{let r=D+n*w;S(e,t,k,r,d,u)})}else{let n=i.filter(e=>e.text.trim()!==``),f=L,p=12*O,h=8*O;for(;f>=p;f-=1*O){e.font=`${l} ${c} ${f}px ${E}`;let t=0;for(let i of n){let n=i.text,a=m?.textCase||`none`;a===`upper`?n=n.toUpperCase():a===`lower`&&(n=n.toLowerCase());let o=x(e,n,r);t+=o.length*f*1.3+h}if(t-=h,t<=s)break}f=Math.max(f,p),e.font=`${l} ${c} ${f}px ${E}`;let g=0,_=[];for(let t of n){let n=t.text,i=m?.textCase||`none`;i===`upper`?n=n.toUpperCase():i===`lower`?n=n.toLowerCase():i===`title`?n=n.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()):i===`sentence`?n=n.charAt(0).toUpperCase()+n.slice(1).toLowerCase():i===`invert`&&(n=n.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase()));let a=x(e,n,r),o=a.length*f*1.3;_.push({text:n,wrappedLines:a,blockH:o}),g+=o+h}g-=h;let v=a-g/2,y=t/2;e.textAlign===`left`?y=o:e.textAlign===`right`&&(y=t-o);for(let t of _){let n=f*1.3,r=v+n/2;t.wrappedLines.forEach((t,i)=>{let a=r+i*n;S(e,t,y,a,d,u)}),v+=t.blockH+h}}e.restore?.()}else{let c=s?-1:-2,u=s?1:2,d=e=>j?dt(i,P,e):P+e;m?.lyricDisplayMode===`active-only`?(c=0,u=0):m?.lyricDisplayMode===`next-only`?(c=0,u=1):m?.lyricDisplayMode===`previous-next`?(c=-1,u=1):m?.lyricDisplayMode===`all`&&(c=-i.length,u=i.length);let f=new Map,p=new Map;{let n=Math.max((D?30:40)*O,ne-te);for(let n=c;n<=u;n++){let r=0,a=!1;if(I&&n===0){let e=te*1.2,t=L*1.2;r=e+(F.split(` +`).length>1?t:0),a=!0}else{let o=d(n);if(o>=0&&oe.charAt(0).toUpperCase()+e.substr(1).toLowerCase()):f===`sentence`?d=d.charAt(0).toUpperCase()+d.slice(1).toLowerCase():f===`invert`&&(d=d.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase())),r=x(e,d,t*.9).length*(s*1.2)}}p.set(n,r)}f.set(0,a);for(let e=1;e<=u;e++){let t=f.get(e-1)??a,r=p.get(e-1)??0,i=p.get(e)??0;f.set(e,t+r/2+n+i/2)}for(let e=-1;e>=c;e--){let t=f.get(e+1)??a,r=p.get(e+1)??0,i=p.get(e)??0;f.set(e,t-r/2-n-i/2)}}for(let s=c;s<=u;s++){let c=null,u=!1;if(I)s===0&&(c={time:0,text:F},u=!0);else{let e=d(s);if(e>=0&&e1+2.70158*(e-1)**3+1.70158*(e-1)**2,r=e=>{let t=2*Math.PI/3;return e===0?0:e===1?1:2**(-10*e)*Math.sin((e*10-.75)*t)+1};if(_===`slide`)b=(1-i)*(e0&&(e.filter=`blur(${D}px)`);let A=u&&m?.textAnimation||`none`,j=c.text,M=m?.textCase||`none`;M===`none`&&u&&[`large_upper`,`big_center`,`metal`,`tech`,`testing_up`,`one_line_up`].includes(l)&&(M=`upper`),M===`upper`?j=j.toUpperCase():M===`lower`?j=j.toLowerCase():M===`title`?j=j.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()):M===`sentence`?j=j.charAt(0).toUpperCase()+j.slice(1).toLowerCase():M===`invert`&&(j=j.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase()));let N=0,ee=0,P=1,F=1,R=0;if(u&&A!==`none`)if(A===`bounce`)ee=Math.sin(r*6)*15*O;else if(A===`pulse`){let e=1+Math.sin(r*4)*.08;P=e,F=e}else if(A===`wave`)ee=Math.sin(r*4)*20*O,R=Math.sin(r*4)*.05;else if(A===`glitch`)Math.sin(r*10)>.8&&(N=(Math.random()-.5)*15*O,ee=(Math.random()-.5)*15*O);else if(A===`shake`)N=(Math.random()-.5)*5*O,ee=(Math.random()-.5)*5*O;else if(A===`typewriter`){let e=Math.floor((r-c.time)*30);j=j.substring(0,Math.max(0,e))}else if(A===`wobble`){R=Math.sin(r*5)*.05;let e=1+Math.sin(r*3)*.05;P=e,F=e}else if(A===`breathe`){let e=1+Math.sin(r*2)*.03;P=e,F=e}else if(A===`rotate`)R=Math.sin(r*2)*.05;else if(A===`sway`)R=Math.sin(r*2)*.08;else if(A===`flicker`)e.globalAlpha=v*(.8+Math.random()*.2);else if(A===`jello`)P=1+Math.sin(r*6)*.1,F=1-Math.sin(r*6)*.1;else if(A===`spin`)R=r%2*Math.PI;else if(A===`heartbeat`){let e=r*1.5%1;(e<.1||e>.3&&e<.4)&&(P=1.1,F=1.1)}else if(A===`tada`){let e=r*1.5%1;e<.1?(P=.9,F=.9,R=-.05):e<.2?(P=1.1,F=1.1,R=.05):(P=1,F=1,R=0)}else A===`swing`&&(R=Math.sin(r*3)*.1);let z=0;f.has(s)?z=f.get(s)+(s===0?b:0):(z=l===`subtitle`&&s===0&&m?.lyricDisplayMode!==`all`?n-140*O:a+s*ne+(s===0?b:0),l!==`custom`&&(s<0?z-=o:s>0&&(z+=o))),z+=ee;let B=t/2;e.textAlign===`left`?B=60*O:e.textAlign===`right`&&(B=t-60*O),B+=x+N;let re=S*P,ie=T*F,ae=k+R;(re!==1||ie!==1||ae!==0)&&(e.translate(B,z),e.rotate(ae),e.scale(re,ie),e.translate(-B,-z));let oe=u?m?.textEffect||`preset`:`none`;if(I&&s===0&&m?.introMode!==`manual`){let n=j.split(` +`),r=n[0],i=n.slice(1).join(` +`),a=te*1.2,o=L*1.2,s=20*O,c=z;i&&(c=z-o/2-s/2);let u=z+a/2+s/2;if(e.font=`${h} ${p} ${te}px ${E}`,w(e,r,B,c,t*.9,a,oe,g),i){let n=l===`custom`&&m?.fontWeight?m.fontWeight:`400`;e.font=`${h} ${n} ${L}px ${E}`,w(e,i,B,u,t*.9,o,oe,g)}}else{let n=u?te:L;m&&m.highlightEffect&&m.highlightEffect,u&&c?C(e,c,B,z,t*.9,n*(m?.lyricLineHeight||1.2),r,m,E,n,p,h,O):w(e,j,B,z,t*.9,n*(m?.lyricLineHeight||1.2),oe,g)}e.restore()}}}}if(![`subtitle`,`just_video`,`none`].includes(l)){let r=m?m.showTitle||m.showArtist:!0,i=m?m.showCover:!0;if(r||i)if(l===`custom`||l==="default"){let r=m?.infoPosition||`top-left`,o=m?.infoStyle||`classic`,l=o===`box`,u=l?16*O:12*O,d=40*O*(m?.infoMarginScale??1),f=`left`,p=`top`;f=r.includes(`left`)?`left`:r.includes(`right`)?`right`:`center`,r.includes(`top`)?p=`top`:r.includes(`bottom`)?p=`bottom`:r.includes(`middle`)&&(p=`middle`);let h=m?.infoSizeScale??1,g=(o===`minimal`||o===`modern`?0:100*O)*h,_=i&&g>0&&a.coverUrl!==null,v=_?a.backgroundType===`video`?c.get(`background`):s.get(`cover`):null,y=(o===`minimal`?20:o===`modern`||o===`modern_art`?40:28)*O,b=(o===`minimal`?14:o===`modern`||o===`modern_art`?24:18)*O,x=y*h,S=b*h,C=m?.infoFontFamily||E,w=m?.infoFontWeight||`bold`,T=m?.infoFontStyle||`normal`,D=`${T} ${w} ${x}px ${C}`,k=`${T} ${w} ${S}px ${C}`,A=20*O,j=l?24*O:0,M=m?.infoFontColor||`#ffffff`,N=o===`modern`||o===`modern_art`?M:m?.infoFontColor||`#d4d4d8`;e.font=D;let ee=e.measureText(a.title),P=m?.showTitle?ee.width:0;e.font=k;let F=e.measureText(a.artist),I=m?.showArtist?F.width:0,te=0,L=0;if(f===`center`){te=Math.max(_&&v?g:0,P,I)+j*2;let e=0;_&&v&&(e+=g),(m?.showTitle??!0)&&(e+=(_&&v?A:0)+x),(m?.showArtist??!0)&&(e+=(_&&v||(m?.showTitle??!0)?5*O:0)+S),L=e+j*2}else{let e=Math.max(P,I);te=(_&&v?g+A:0)+e+j*2;let t=(m?.showTitle?x:0)+(m?.showArtist?S+5*O:0);L=Math.max(t,_&&v?g:0)+j*2}let ne=0,R=0;ne=f===`left`?d:f===`right`?t-d:t/2,R=p===`top`?d:p===`bottom`?n-d:n/2;let z=0,B=0;z=f===`left`?ne:f===`right`?ne-te:ne-te/2,B=p===`top`?R:p===`bottom`?R-L:R-L/2,l&&(e.save(),e.fillStyle=`rgba(0, 0, 0, 0.6)`,e.shadowColor=`rgba(0,0,0,0.5)`,e.shadowBlur=20,e.beginPath(),e.roundRect(z,B,te,L,u),e.fill(),e.restore());let re=z+j,ie=B+j,ae=te-j*2,oe=L-j*2;if(f===`center`){let t=ie,n=re+ae/2;if(e.textAlign=`center`,p!==`bottom`){if(_&&v){e.save(),e.beginPath();let r=n-g/2;o===`circle_art`?e.arc(n,t+g/2,g/2,0,Math.PI*2):e.roundRect(r,t,g,g,u/2),e.clip(),e.drawImage(v,r,t,g,g),e.restore(),t+=g+A}(m?.showTitle??!0)&&(e.fillStyle=M,e.font=D,e.textBaseline=`top`,e.fillText(a.title,n,t),t+=x+5*O),(m?.showArtist??!0)&&(e.fillStyle=N,e.font=k,e.textBaseline=`top`,e.fillText(a.artist,n,t))}else{if(_&&v){e.save(),e.beginPath();let r=n-g/2;o===`circle_art`?e.arc(n,t+g/2,g/2,0,Math.PI*2):e.roundRect(r,t,g,g,u/2),e.clip(),e.drawImage(v,r,t,g,g),e.restore(),t+=g+A}(m?.showTitle??!0)&&(e.fillStyle=M,e.font=D,e.textBaseline=`top`,e.fillText(a.title,n,t),t+=x+5*O),(m?.showArtist??!0)&&(e.fillStyle=N,e.font=k,e.textBaseline=`top`,e.fillText(a.artist,n,t))}}else{let t=f===`right`,n=ie+oe/2,r=re;if(t&&(r=re+ae),_&&v){let i=n-g/2,a=t?r-g:r;e.save(),e.beginPath(),o===`circle_art`?e.arc(a+g/2,i+g/2,g/2,0,Math.PI*2):e.roundRect(a,i,g,g,u/2),e.clip(),e.drawImage(v,a,i,g,g),e.restore(),t?r-=g+A:r+=g+A}let i=n-((m?.showTitle?x:0)+(m?.showArtist?S+5*O:0))/2;e.textAlign=t?`right`:`left`,e.textBaseline=`top`,(m?.showTitle??!0)&&(e.fillStyle=M,e.font=D,e.fillText(a.title,r,i),i+=x+5*O),(m?.showArtist??!0)&&(e.fillStyle=N,e.font=k,e.fillText(a.artist,r,i))}}else if([`big_center`,`metal`,`kids`,`sad`,`romantic`,`tech`,`gothic`,`testing`,`testing_up`,`one_line`,`one_line_up`,`slideshow`,`subtitle`].includes(l)){if(r){e.textAlign=`center`,e.textBaseline=`middle`;let r=80*O;[`testing`,`testing_up`,`one_line`,`one_line_up`].includes(l)&&(r=120*O),(m?.showTitle??!0)&&(e.font=`bold ${20*O}px ${E}`,e.fillStyle=`#ffffff`,e.fillText(l===`tech`?a.title.toUpperCase():a.title,t/2,n-r-30*O)),(m?.showArtist??!0)&&(e.font=`${16*O}px ${E}`,e.fillStyle=`#d4d4d8`,e.fillText(a.artist,t/2,n-r))}}else{let o=40*O*(m?.infoMarginScale??1),c=t===n,l=(D?c?110:150:100)*O,u=a.coverUrl?s.get(`cover`):null,d=12*O;if(D){let n=o*(c?1.5:3),s=t/2,f=s-l/2,p=n;if(i&&(e.save(),e.beginPath(),e.roundRect(f,p,l,l,d),e.clip(),u?e.drawImage(u,f,p,l,l):(e.fillStyle=`#27272a`,e.fillRect(f,p,l,l)),e.restore()),r){e.textAlign=`center`,e.textBaseline=`top`;let t=p+(i?l+25*O:0),n=m?.infoFontFamily||E,r=m?.infoFontColor||`#ffffff`,o=m?.infoFontColor||`#d4d4d8`,u=m?.infoFontWeight||`bold`,d=m?.infoFontStyle||`normal`;(m?.showTitle??!0)&&(e.font=`${d} ${u} ${(c?26:36)*O}px ${n}`,e.fillStyle=r,e.fillText(a.title,s,t)),(m?.showArtist??!0)&&(e.font=`${d} ${u} ${(c?18:24)*O}px ${n}`,e.fillStyle=o,e.fillText(a.artist,s,t+(m?.showTitle??!0?(c?30:40)*O:0)))}}else{let t=o,n=o;if(i&&(e.save(),e.beginPath(),e.roundRect(t,n,l,l,d),e.clip(),u?e.drawImage(u,t,n,l,l):(e.fillStyle=`#27272a`,e.fillRect(t,n,l,l)),e.restore()),r){e.textAlign=`left`,e.textBaseline=`top`;let r=m?.infoFontFamily||E,o=m?.infoFontColor||`#ffffff`,s=m?.infoFontColor||`#d4d4d8`,c=m?.infoFontWeight||`bold`,u=m?.infoFontStyle||`normal`,d=t+(i?l+25*O:0),f=28*O,p=n+l/2-f;(m?.showTitle??!0)&&(e.font=`${u} ${c} ${f}px ${r}`,e.fillStyle=o,e.fillText(a.title,d,p)),(m?.showArtist??!0)&&(e.font=`${u} ${c} ${18*O}px ${r}`,e.fillStyle=s,e.fillText(a.artist,d,p+(m?.showTitle??!0?f+5*O:0)))}}}}if(m?.showChannelInfo&&![`subtitle`,`just_video`,`none`].includes(l)){let r=m.channelInfoPosition||`bottom-right`,i=m.channelInfoStyle||`classic`,a=m.channelInfoSizeScale??1,o=m.channelInfoMarginScale??1,c=s.get(`__channel_info__`),l=m.channelInfoText;if(!(!c&&!l)&&!(i===`logo`&&!c)&&!(i===`minimal`&&!l)){e.save();let u=40*O*o,d=80*O*a,f=i===`modern`||i===`logo`?d*1.2:d,p=20*O*a,h=s.get(`__channel_info_text_svg__`),g=!!h,_=0,v=p;if(g&&h){v=p*1.5;let e=h.width/h.height;_=v*e}else{let t=m.channelInfoFontWeight||`bold`;e.font=`${m.channelInfoFontStyle||`normal`} ${t} ${p}px ${m.channelInfoFontFamily||`sans-serif`}`,l&&i!==`logo`&&(_=e.measureText(l).width)}let y=12*O*a,b=12*O*a,x=8*O*a,S=0,C=0,w=!!c&&i!==`minimal`,T=!!l&&i!==`logo`;i===`modern`?(S=Math.max(w?f:0,T?_+b*2:0),C=(w?f:0)+(w&&T?y:0)+(T?v+x*2:0)):i===`box`?(S=(w?f:0)+(w&&T?y:0)+(T?_:0)+b*2,C=Math.max(w?f:0,T?v:0)+x*2):i===`minimal`?(S=T?_+b*2:0,C=T?v+x*2:0):i===`logo`?(S=f,C=f):(S=(w?f:0)+(w&&T?y:0)+(T?_+b*2:0),C=Math.max(w?f:0,T?v+x*2:0));let E=0,D=0;r.includes(`left`)?E=u:r.includes(`right`)?E=t-u-S:r.includes(`center`)&&(E=(t-S)/2),r.includes(`top`)?D=u:r.includes(`bottom`)?D=n-u-C:r.includes(`middle`)&&(D=(n-C)/2),i===`box`&&(e.fillStyle=`rgba(0, 0, 0, 0.4)`,e.shadowColor=`rgba(0,0,0,0.5)`,e.shadowBlur=10,e.roundRect?(e.beginPath(),e.roundRect(E,D,S,C,12*O*a),e.fill()):e.fillRect(E,D,S,C),e.shadowColor=`transparent`,e.shadowBlur=0);let k=(t,n,r,o,s)=>{if(i!==`box`&&i!==`minimal`&&(e.fillStyle=`rgba(0, 0, 0, 0.2)`,e.roundRect?(e.beginPath(),e.roundRect(t,n,r,o,8*O*a),e.fill()):e.fillRect(t,n,r,o)),g&&h){let i=t+(r-_)/2,a=n+(o-v)/2;e.drawImage(h,i,a,_,v)}else{e.fillStyle=m.channelInfoFontColor||`#ffffff`,e.textAlign=`left`,e.textBaseline=`top`,e.shadowColor=`rgba(0,0,0,0.5)`,e.shadowBlur=4;let i=t+(r-_)/2,a=n+(o-v)/2+v*.1;e.fillText(s,i,a),e.shadowColor=`transparent`}};if(i===`modern`){let t=D;if(w){let n=E+(S-f)/2;e.drawImage(c,n,t,f,f),t+=f+y}if(T){let e=_+b*2,n=v+x*2;k(E+(S-e)/2,t,e,n,l)}}else{let t=r.includes(`right`),n=E+(i===`box`?b:0),a=D+C/2;if(t&&(i===`classic`||i===`circle`)){if(T){let e=_+b*2,t=v+x*2;k(n,a-t/2,e,t,l),n+=e+y}w&&(i===`circle`?(e.save(),e.beginPath(),e.arc(n+f/2,a,f/2,0,Math.PI*2),e.closePath(),e.clip(),e.drawImage(c,n,a-f/2,f,f),e.restore()):e.drawImage(c,n,a-f/2,f,f))}else if(w&&(i===`circle`?(e.save(),e.beginPath(),e.arc(n+f/2,a,f/2,0,Math.PI*2),e.closePath(),e.clip(),e.drawImage(c,n,a-f/2,f,f),e.restore()):e.drawImage(c,n,a-f/2,f,f),n+=f+y),T){let t=_+(i===`box`?0:b*2),r=v+(i===`box`?0:x*2);i===`box`?g&&h?(e.shadowColor=`rgba(0,0,0,0.5)`,e.shadowBlur=4,e.drawImage(h,n,a-v/2,_,v),e.shadowColor=`transparent`):(e.fillStyle=m.channelInfoFontColor||`#ffffff`,e.textAlign=`left`,e.textBaseline=`middle`,e.shadowColor=`rgba(0,0,0,0.5)`,e.shadowBlur=4,e.fillText(l,n,a+v*.1),e.shadowColor=`transparent`):k(n,a-r/2,t,r,l)}}e.restore()}}if(Sw(r,p,m,i,{isFirstSongInPlaylist:g})){let r=m.floatingNotesPosition||`bottom-left`,i=m.floatingNotesLayout||`text-only`,a=m.floatingNotesShape||`rounded`,o=m.floatingNotesOpacity??.8,l=m.floatingNotesMarginScale??1,u=(m.floatingNotesWidth||300)*O,d=(m.floatingNotesHeight||150)*O,f=s.get(`__floating_notes_media__`),p=c.get(`__floating_notes_media__`),h=m.floatingNotesText,g=!!f||!!p,_=!!h&&i!==`media-only`;if(g||_){e.save(),e.globalAlpha=o;let s=40*O*l,c=0,v=0;if(r.includes(`left`)?c=s:r.includes(`right`)?c=t-s-u:r.includes(`center`)&&(c=(t-u)/2),r.includes(`top`)?v=s:r.includes(`bottom`)?v=n-s-d:r.includes(`middle`)&&(v=(n-d)/2),a!==`none`){e.fillStyle=m.floatingNotesFillColor||`#000000`,e.beginPath(),a===`rounded`&&e.roundRect?e.roundRect(c,v,u,d,12*O):e.rect(c,v,u,d),e.fill();let t=ww(m)*O;t>0&&(e.strokeStyle=m.floatingNotesOutlineColor||`#ffffff`,e.lineWidth=t,e.stroke())}let y=16*O,{mediaBox:b,textBox:S}=Dw(i,c+y,v+y,u-y*2,d-y*2,O,g,_,Tw(m));if(g&&b.w>0&&b.h>0){let t=f||p;if(t){e.save(),e.beginPath(),e.rect(b.x,b.y,b.w,b.h),e.clip();let n=0,r=0;t instanceof HTMLVideoElement?(n=t.videoWidth||b.w,r=t.videoHeight||b.h):t instanceof ImageBitmap?(n=t.width,r=t.height):(n=t.naturalWidth||b.w,r=t.naturalHeight||b.h);let a=n/r,o=b.w/b.h,s=b.w,c=b.h,l=b.x,u=b.y;a>o?s=b.h*a:c=b.w/a;let d=jw(i,b,s,c);l=d.drawX,u=d.drawY,e.drawImage(t,l,u,s,c),e.restore()}}if(_&&S.w>0&&S.h>0){e.save();let t=m.floatingNotesFontFamily||`sans-serif`,n=m.floatingNotesFontStyle||`normal`,r=m.floatingNotesFontWeight||`normal`,i=m.floatingNotesFontColor||`#ffffff`,a=14*O*Ew(m);e.font=`${n} ${r} ${a}px ${t}`,e.fillStyle=i;let o=m.floatingNotesTextAlign||`left`;e.textAlign=o,e.textBaseline=`top`;let s=x(e,h,S.w),c=a*1.3,l=S.y;for(let t of s){if(l+c>S.y+S.h)break;let n=S.x;o===`center`?n=S.x+S.w/2:o===`right`&&(n=S.x+S.w),e.fillText(t,n,l),l+=c}e.restore()}e.restore()}}},Nw;(function(e){e.LOAD=`LOAD`,e.EXEC=`EXEC`,e.FFPROBE=`FFPROBE`,e.WRITE_FILE=`WRITE_FILE`,e.READ_FILE=`READ_FILE`,e.DELETE_FILE=`DELETE_FILE`,e.RENAME=`RENAME`,e.CREATE_DIR=`CREATE_DIR`,e.LIST_DIR=`LIST_DIR`,e.DELETE_DIR=`DELETE_DIR`,e.ERROR=`ERROR`,e.DOWNLOAD=`DOWNLOAD`,e.PROGRESS=`PROGRESS`,e.LOG=`LOG`,e.MOUNT=`MOUNT`,e.UNMOUNT=`UNMOUNT`})(Nw||={});var Pw=(()=>{let e=0;return()=>e++})(),Fw=Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),Iw=Error(`called FFmpeg.terminate()`),Lw=class{#e=null;#t={};#n={};#r=[];#i=[];loaded=!1;#a=()=>{this.#e&&(this.#e.onmessage=({data:{id:e,type:t,data:n}})=>{switch(t){case Nw.LOAD:this.loaded=!0,this.#t[e](n);break;case Nw.MOUNT:case Nw.UNMOUNT:case Nw.EXEC:case Nw.FFPROBE:case Nw.WRITE_FILE:case Nw.READ_FILE:case Nw.DELETE_FILE:case Nw.RENAME:case Nw.CREATE_DIR:case Nw.LIST_DIR:case Nw.DELETE_DIR:this.#t[e](n);break;case Nw.LOG:this.#r.forEach(e=>e(n));break;case Nw.PROGRESS:this.#i.forEach(e=>e(n));break;case Nw.ERROR:this.#n[e](n);break}delete this.#t[e],delete this.#n[e]})};#o=({type:e,data:t},n=[],r)=>this.#e?new Promise((i,a)=>{let o=Pw();this.#e&&this.#e.postMessage({id:o,type:e,data:t},n),this.#t[o]=i,this.#n[o]=a,r?.addEventListener(`abort`,()=>{a(new DOMException(`Message # ${o} was aborted`,`AbortError`))},{once:!0})}):Promise.reject(Fw);on(e,t){e===`log`?this.#r.push(t):e===`progress`&&this.#i.push(t)}off(e,t){e===`log`?this.#r=this.#r.filter(e=>e!==t):e===`progress`&&(this.#i=this.#i.filter(e=>e!==t))}load=({classWorkerURL:e,...t}={},{signal:n}={})=>(this.#e||(this.#e=e?new Worker(new URL(e,import.meta.url),{type:`module`}):new Worker(new URL(`/assets/worker-BzdDEeh7.js`,``+import.meta.url),{type:`module`}),this.#a()),this.#o({type:Nw.LOAD,data:t},void 0,n));exec=(e,t=-1,{signal:n}={})=>this.#o({type:Nw.EXEC,data:{args:e,timeout:t}},void 0,n);ffprobe=(e,t=-1,{signal:n}={})=>this.#o({type:Nw.FFPROBE,data:{args:e,timeout:t}},void 0,n);terminate=()=>{let e=Object.keys(this.#n);for(let t of e)this.#n[t](Iw),delete this.#n[t],delete this.#t[t];this.#e&&(this.#e.terminate(),this.#e=null,this.loaded=!1)};writeFile=(e,t,{signal:n}={})=>{let r=[];return t instanceof Uint8Array&&r.push(t.buffer),this.#o({type:Nw.WRITE_FILE,data:{path:e,data:t}},r,n)};mount=(e,t,n)=>this.#o({type:Nw.MOUNT,data:{fsType:e,options:t,mountPoint:n}},[]);unmount=e=>this.#o({type:Nw.UNMOUNT,data:{mountPoint:e}},[]);readFile=(e,t=`binary`,{signal:n}={})=>this.#o({type:Nw.READ_FILE,data:{path:e,encoding:t}},void 0,n);deleteFile=(e,{signal:t}={})=>this.#o({type:Nw.DELETE_FILE,data:{path:e}},void 0,t);rename=(e,t,{signal:n}={})=>this.#o({type:Nw.RENAME,data:{oldPath:e,newPath:t}},void 0,n);createDir=(e,{signal:t}={})=>this.#o({type:Nw.CREATE_DIR,data:{path:e}},void 0,t);listDir=(e,{signal:t}={})=>this.#o({type:Nw.LIST_DIR,data:{path:e}},void 0,t);deleteDir=(e,{signal:t}={})=>this.#o({type:Nw.DELETE_DIR,data:{path:e}},void 0,t)},Rw;(function(e){e.MEMFS=`MEMFS`,e.NODEFS=`NODEFS`,e.NODERAWFS=`NODERAWFS`,e.IDBFS=`IDBFS`,e.WORKERFS=`WORKERFS`,e.PROXYFS=`PROXYFS`})(Rw||={});var zw=Error(`failed to get response body reader`),Bw=Error(`failed to complete download`),Vw=async(e,t)=>{let n=await fetch(e),r;try{let i=parseInt(n.headers.get(`Content-Length`)||`-1`),a=n.body?.getReader();if(!a)throw zw;let o=[],s=0;for(;;){let{done:n,value:r}=await a.read(),c=r?r.length:0;if(n){if(i!=-1&&i!==s)throw Bw;t&&t({url:e,total:i,received:s,delta:c,done:n});break}o.push(r),s+=c,t&&t({url:e,total:i,received:s,delta:c,done:n})}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;r=c.buffer}catch(i){console.log(`failed to send download progress event: `,i),r=await n.arrayBuffer(),t&&t({url:e,total:r.byteLength,received:r.byteLength,delta:0,done:!0})}return r},Hw=async(e,t,n=!1,r)=>{let i=n?await Vw(e,r):await(await fetch(e)).arrayBuffer(),a=new Blob([i],{type:t});return URL.createObjectURL(a)};async function Uw(e,t){if(e.sampleRate===t)return e;let n=new OfflineAudioContext(e.numberOfChannels,Math.ceil(e.duration*t),t),r=n.createBufferSource();return r.buffer=e,r.connect(n.destination),r.start(0),n.startRendering()}async function Ww(e,t,n){let r=e.filter(e=>e.type===`audio`);if(r.length===0)return[];let i=new(window.AudioContext||window.webkitAudioContext),a=[];for(let e of r)try{let n=await(await fetch(e.url)).arrayBuffer(),r=await i.decodeAudioData(n.slice(0));r.sampleRate!==t&&(r=await Uw(r,t)),a.push({slide:e,buffer:r})}catch(t){n?.(`[TimelineAudio] Failed to decode "${e.name}": ${t.message}`)}return i.close(),a}async function Gw(e,t,n,r=0,i){let a=t.filter(({slide:t})=>{let i=t.layer||0;return n.layerVisibility?.audio?.[i]===!1||t.isMuted===!0?!1:t.endTime>r&&t.startTime=t.duration)continue;let f=Math.min(s*i,t.duration-d);if(f<=0)continue;let p=u.createGain();p.gain.value=n,p.connect(u.destination);let m=u.createBufferSource();m.buffer=t,m.playbackRate.value=i,m.connect(p),m.start(c,d,f)}return i?.(`[TimelineAudio] Mixed ${a.length} timeline audio clip(s)`),u.startRendering()}function Kw(e){let t=e.numberOfChannels,n=e.sampleRate,r=16/8*t,i=e.length*r,a=new ArrayBuffer(44+i),o=new DataView(a),s=(e,t)=>{for(let n=0;nsetTimeout(e,100));if(qw&&Jw)return qw}Yw=!0;try{let t=new Lw;if(t.on(`log`,({message:t})=>{e?.(`[FFmpeg] ${t}`),console.log(`[FFmpeg]`,t)}),t.on(`progress`,({progress:t,time:n})=>{e?.(`[FFmpeg Progress] ${(t*100).toFixed(1)}% (${n}s)`)}),typeof window<`u`&&window.crossOriginIsolated){e?.(`[FFmpeg] Cross-Origin Isolated: YES. Using Multi-Threaded Core 🚀`);let n=`https://unpkg.com/@ffmpeg/core-mt@0.12.10/dist/esm`,r,i,a,o=async(t,n,r)=>{let i=`${t.endsWith(`/`)?t:`${t}/`}${n}`;try{let t=await fetch(i,{cache:`no-cache`,mode:`same-origin`});if(!t.ok)throw Error(`HTTP ${t.status}`);let a=t.headers.get(`Content-Type`)||``,o=await t.arrayBuffer(),s=new Uint8Array(o);if(s[0]===60||a.includes(`text/html`)){let t=new TextDecoder().decode(s.slice(0,100));throw e?.(`[FFmpeg] Error: Path ${i} returned HTML instead of binary. Check if file exists in public/ffmpeg.`),console.debug(`[FFmpeg] Received HTML: ${t}...`),Error(`Server returned HTML (SPA Redirect) at ${i}`)}if(n.endsWith(`.wasm`)&&(s[0]!==0||s[1]!==97||s[2]!==115||s[3]!==109))throw Error(`File version mismatch or invalid WASM binary (Check for partial downloads)`);return URL.createObjectURL(new Blob([o],{type:r}))}catch(e){throw Error(`[${n}] ${e.message}`)}},s=window.location.origin;try{e?.(`[FFmpeg] Initializing (Offline Support: ${navigator.onLine?`OFF`:`ACTIVE`})...`);let t=[`/`.endsWith(`/`)?`/ffmpeg`:`//ffmpeg`,`/ffmpeg`,`./ffmpeg`,`ffmpeg`,s+`/ffmpeg`].filter((e,t,n)=>n.indexOf(e)===t),n=!1;for(let s of t)try{e?.(`[FFmpeg] Probing ${s}...`);let t=await o(s,`ffmpeg-core.js`,`text/javascript`),[c,l]=await Promise.all([o(s,`ffmpeg-core.wasm`,`application/wasm`),o(s,`ffmpeg-core.worker.js`,`text/javascript`)]);r=t,i=c,a=l,e?.(`[FFmpeg] Success! Core verified at ${s} 🚀`),n=!0;break}catch(e){console.debug(`[FFmpeg] Path ${s} skipped:`,e.message)}if(!n)throw Error(`Could not find valid local binaries`)}catch(t){e?.(`[FFmpeg] Local load failed: ${t.message}. Falling back to CDN.`),console.warn(`[FFmpeg] Falling back to remote CDN:`,t),[r,i,a]=await Promise.all([Hw(`${n}/ffmpeg-core.js`,`text/javascript`),Hw(`${n}/ffmpeg-core.wasm`,`application/wasm`),Hw(`${n}/ffmpeg-core.worker.js`,`text/javascript`)])}await t.load({coreURL:r,wasmURL:i,workerURL:a})}else{e?.(`[FFmpeg] Cross-Origin Isolated: NO. Using Single-Threaded Core 🐢`);let n=`https://unpkg.com/@ffmpeg/core@0.12.10/dist/esm`,r,i,a=async(e,t,n)=>{let r=`${e.endsWith(`/`)?e:`${e}/`}${t}?v=${Date.now()}`;try{let e=await fetch(r);if(!e.ok||e.headers.get(`Content-Type`)?.includes(`text/html`))throw Error(`404`);let t=await e.blob();if((await t.slice(0,10).text()).trim().startsWith(`<`))throw Error(`HTML Content`);return URL.createObjectURL(new Blob([t],{type:n}))}catch(e){throw e}};try{e?.(`[FFmpeg] Searching for local ST core files...`);let t=!1,n=[`/ffmpeg`,`./ffmpeg`,`ffmpeg`,window.location.pathname.replace(/\/[^\/]*$/,``)+`/ffmpeg`];for(let o of n)try{r=await a(o,`ffmpeg-core.js`,`text/javascript`),i=await a(o,`ffmpeg-core.wasm`,`application/wasm`),e?.(`[FFmpeg] Success! ST core verified at local ${o} 🐢`),t=!0;break}catch{}if(!t)throw Error(`NotFound`)}catch{e?.(`[FFmpeg] Local ST core failure. Using CDN.`),r=await Hw(`${n}/ffmpeg-core.js`,`text/javascript`),i=await Hw(`${n}/ffmpeg-core.wasm`,`application/wasm`)}await t.load({coreURL:r,wasmURL:i})}return qw=t,Jw=!0,e?.(`[FFmpeg] Loaded successfully`),t}finally{Yw=!1}}function Zw(){return!0}function Qw(e,t,n){let r=n===`1080p`,i={low:r?28:30,med:r?23:25,high:r?18:20}[t];switch(e){case`h265`:return{vcodec:`libx265`,args:[`-crf`,i.toString(),`-preset`,`medium`,`-tag:v`,`hvc1`],format:`mp4`,ext:`mp4`};case`vp9`:return{vcodec:`libvpx-vp9`,args:[`-crf`,i.toString(),`-b:v`,`0`,`-deadline`,`good`,`-cpu-used`,`2`],format:`webm`,ext:`webm`};case`av1`:return{vcodec:`libaom-av1`,args:[`-crf`,(i+10).toString(),`-b:v`,`0`,`-cpu-used`,`4`,`-strict`,`experimental`],format:`mp4`,ext:`mp4`};default:return{vcodec:`libx264`,args:[`-crf`,i.toString(),`-preset`,`medium`,`-profile:v`,`high`,`-level`,`4.2`],format:`mp4`,ext:`mp4`}}}async function $w(e){let{canvas:t,audioFile:n,lyrics:r,metadata:i,visualSlides:a,imageMap:o,videoMap:s,preset:c,customFontName:l,renderConfig:u,fps:d,quality:f,codec:p,aspectRatio:m,onProgress:h,onLog:g,abortSignal:_,isFirstSong:v=!0,isLastSong:y=!0,startTimeOffset:b=0}=e;h(0,`Loading FFmpeg...`);let x=await Xw(g),S=()=>_?.aborted===!0||_?.current===!0;if(S())throw Error(`Render aborted`);if(i.coverUrl&&(i.backgroundType===`video`?(g?.(`[FFmpeg] Loading video background from metadata...`),await rT(`background`,i.coverUrl,s)):(g?.(`[FFmpeg] Loading cover art from metadata...`),await nT(`cover`,i.coverUrl,o))),g?.(`[FFmpeg] VideoMap keys: ${Array.from(s.keys()).join(`, `)}`),g?.(`[FFmpeg] RenderConfig Source: ${u.backgroundSource}`),s.has(`__custom_bg_video__`)){let e=s.get(`__custom_bg_video__`);g?.(`[FFmpeg] Custom Video: ReadyState=${e?.readyState}, Size=${e?.videoWidth}x${e?.videoHeight}, Duration=${e?.duration}`),e&&(e.muted=!0)}else u.backgroundSource===`video`&&g?.(`[FFmpeg] WARNING: backgroundSource is 'video' but '__custom_bg_video__' is missing from map!`);h(5,`Preparing audio...`);let C=await n.arrayBuffer(),w=new(window.AudioContext||window.webkitAudioContext),T=await w.decodeAudioData(C.slice(0)),E=await Ww(a,T.sampleRate,g);E.length>0&&(g?.(`[FFmpeg] Mixing timeline audio tracks...`),T=await Gw(T,E,u,b,g));let D=T.duration;w.close();let O=Math.ceil(D*d),k=t.getContext(`2d`);if(!k)throw Error(`Failed to get canvas context`);h(10,`Rendering frames...`),await x.writeFile(`audio_src`,new Uint8Array(Kw(T)));let A=null,j=T.sampleRate;u.showVisualization&&(A=T.getChannelData(0),g?.(`[FFmpeg] Audio decoded: ${D.toFixed(1)}s @ ${j}Hz`));let M=Math.max(6,O.toString().length);for(let e=0;e0,D,u,y,v,p,m);let g=await(await new Promise((e,n)=>{t.toBlob(t=>t?e(t):n(Error(`Failed to create blob`)),`image/jpeg`,f===`high`?.98:f===`med`?.92:.85)})).arrayBuffer(),_=`frame_${e.toString().padStart(M,`0`)}.jpg`;await x.writeFile(_,new Uint8Array(g)),h(10+e/O*70,`Rendering frame ${e+1}/${O}`)}if(S())throw await iT(x,O,M),Error(`Render aborted`);h(80,`Encoding video...`);let N=Qw(p,f,e.resolution),ee=`output.${N.ext}`,P=[`-framerate`,d.toString(),`-i`,`frame_%0${M}d.jpg`,`-i`,`audio_src`,`-c:v`,N.vcodec,...N.args,`-c:a`,`aac`,`-b:a`,`192k`,`-ar`,`44100`,`-ac`,`2`,`-pix_fmt`,`yuv420p`,`-movflags`,`+faststart`,`-shortest`,`-y`,ee];g?.(`[FFmpeg] Running: ffmpeg ${P.join(` `)}`);try{await x.exec(P)}catch(e){throw console.error(`FFmpeg encoding failed:`,e),await iT(x,O,M),Error(`FFmpeg encoding failed: ${e}`)}h(95,`Finalizing...`);let F=await x.readFile(ee),I=F instanceof Uint8Array?new Uint8Array(F):new TextEncoder().encode(F),te=new Blob([I],{type:N.format===`webm`?`video/webm`:`video/mp4`});await iT(x,O,M);try{await x.deleteFile(`audio_src`),await x.deleteFile(ee)}catch{}return h(100,`Complete!`),{blob:te,duration:D,format:N.ext}}async function eT(e,t,n){let r=await Xw(t.onLog),i=[],a=0;for(let o=0;o{n(o,e.length,t,r)},startTimeOffset:a}),d=`segment_${o}.${u.format}`,f=await u.blob.arrayBuffer();await r.writeFile(d,new Uint8Array(f)),i.push(d),a+=u.duration}if(e.length===1){let e=await r.readFile(i[0]),t=i[0].split(`.`).pop()||`mp4`;await r.deleteFile(i[0]);let n=e instanceof Uint8Array?new Uint8Array(e):new TextEncoder().encode(e);return{blob:new Blob([n],{type:t===`webm`?`video/webm`:`video/mp4`}),duration:a,format:t}}n(e.length,e.length,0,`Concatenating tracks...`);let o=i.map(e=>`file '${e}'`).join(` +`);await r.writeFile(`concat.txt`,new TextEncoder().encode(o));let s=i[0].split(`.`).pop()||`mp4`,c=`final_output.${s}`;await r.exec([`-f`,`concat`,`-safe`,`0`,`-i`,`concat.txt`,`-c`,`copy`,`-y`,c]);let l=await r.readFile(c),u=l instanceof Uint8Array?new Uint8Array(l):new TextEncoder().encode(l),d=new Blob([u],{type:s===`webm`?`video/webm`:`video/mp4`});for(let e of i)try{await r.deleteFile(e)}catch{}try{await r.deleteFile(`concat.txt`),await r.deleteFile(c)}catch{}return n(e.length,e.length,100,`Complete!`),{blob:d,duration:a,format:s}}async function tT(e,t,n,r){let i=[];e.forEach((e,a)=>{let o=-1;if(a===`__custom_bg_video__`){let t=e.duration||1;t>0&&(o=r%t)}else if(a===`__floating_notes_media__`){let t=e.duration||1;t>0&&(o=n%t)}else if(a===`background`){let t=e.duration||1;t>0&&(o=n%t)}else{let r=t.find(e=>e.id===a);if(r&&r.type===`video`&&n>=r.startTime&&n0&&i>=a&&(i%=a),o=i}}if(o>=0){if(e.readyState===0)return;Math.abs(e.currentTime-o)>.05&&i.push(new Promise(t=>{let n=!1,r=()=>{n||(n=!0,e.removeEventListener(`seeked`,r),t())};e.addEventListener(`seeked`,r),e.currentTime=o,setTimeout(()=>{n||(n=!0,e.removeEventListener(`seeked`,r),t())},500)}))}}),i.length>0&&await Promise.all(i)}async function nT(e,t,n){if(!(n.has(e)&&n.get(e)?.src===t))return new Promise(r=>{let i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{n.set(e,i),r()},i.onerror=()=>{console.warn(`Failed to load background image:`,t),r()},i.src=t})}async function rT(e,t,n){if(!(n.has(e)&&n.get(e)?.src===t))return new Promise(r=>{let i=document.createElement(`video`);i.crossOrigin=`anonymous`,i.muted=!0,i.playsInline=!0,i.preload=`auto`;let a=!1,o=()=>{a||(a=!0,n.set(e,i),r())};i.oncanplay=()=>{a||(i.currentTime=.001)},i.onseeked=()=>o(),i.onerror=()=>{console.warn(`Failed to load background video:`,t),o()},setTimeout(()=>o(),1e4),i.src=t,i.load()})}async function iT(e,t,n){for(let r=0;r{if(!t.has(e))throw TypeError(`Cannot `+n)},Q=(e,t,n)=>(aT(e,t,`read from private field`),n?n.call(e):t.get(e)),oT=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},sT=(e,t,n,r)=>(aT(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),cT=(e,t,n,r)=>({set _(r){sT(e,t,r,n)},get _(){return Q(e,t,r)}}),lT=(e,t,n)=>(aT(e,t,`access private method`),n),uT=new Uint8Array(8),dT=new DataView(uT.buffer),fT=e=>[(e%256+256)%256],pT=e=>(dT.setUint16(0,e,!1),[uT[0],uT[1]]),mT=e=>(dT.setInt16(0,e,!1),[uT[0],uT[1]]),hT=e=>(dT.setUint32(0,e,!1),[uT[1],uT[2],uT[3]]),$=e=>(dT.setUint32(0,e,!1),[uT[0],uT[1],uT[2],uT[3]]),gT=e=>(dT.setInt32(0,e,!1),[uT[0],uT[1],uT[2],uT[3]]),_T=e=>(dT.setUint32(0,Math.floor(e/2**32),!1),dT.setUint32(4,e,!1),[uT[0],uT[1],uT[2],uT[3],uT[4],uT[5],uT[6],uT[7]]),vT=e=>(dT.setInt16(0,2**8*e,!1),[uT[0],uT[1]]),yT=e=>(dT.setInt32(0,2**16*e,!1),[uT[0],uT[1],uT[2],uT[3]]),bT=e=>(dT.setInt32(0,2**30*e,!1),[uT[0],uT[1],uT[2],uT[3]]),xT=(e,t=!1)=>{let n=Array(e.length).fill(null).map((t,n)=>e.charCodeAt(n));return t&&n.push(0),n},ST=e=>e&&e[e.length-1],CT=e=>{let t;for(let n of e)(!t||n.presentationTimestamp>t.presentationTimestamp)&&(t=n);return t},wT=(e,t,n=!0)=>{let r=e*t;return n?Math.round(r):r},TT=e=>{let t=Math.PI/180*e,n=Math.cos(t),r=Math.sin(t);return[n,r,0,-r,n,0,0,0,1]},ET=TT(0),DT=e=>[yT(e[0]),yT(e[1]),bT(e[2]),yT(e[3]),yT(e[4]),bT(e[5]),yT(e[6]),yT(e[7]),bT(e[8])],OT=e=>!e||typeof e!=`object`?e:Array.isArray(e)?e.map(OT):Object.fromEntries(Object.entries(e).map(([e,t])=>[e,OT(t)])),kT=e=>e>=0&&e<2**32,AT=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),jT=(e,t,n,r,i)=>AT(e,[fT(t),hT(n),r??[]],i),MT=e=>e.fragmented?AT(`ftyp`,[xT(`iso5`),$(512),xT(`iso5`),xT(`iso6`),xT(`mp41`)]):AT(`ftyp`,[xT(`isom`),$(512),xT(`isom`),e.holdsAvc?xT(`avc1`):[],xT(`mp41`)]),NT=e=>({type:`mdat`,largeSize:e}),PT=e=>({type:`free`,size:e}),FT=(e,t,n=!1)=>AT(`moov`,null,[IT(t,e),...e.map(e=>LT(e,t)),n?mE(e):null]),IT=(e,t)=>{let n=wT(Math.max(0,...t.filter(e=>e.samples.length>0).map(e=>{let t=CT(e.samples);return t.presentationTimestamp+t.duration})),sD),r=Math.max(...t.map(e=>e.id))+1,i=!kT(e)||!kT(n),a=i?_T:$;return jT(`mvhd`,+i,0,[a(e),a(e),$(sD),a(n),yT(1),vT(1),Array(10).fill(0),DT(ET),Array(24).fill(0),$(r)])},LT=(e,t)=>AT(`trak`,null,[RT(e,t),zT(e,t)]),RT=(e,t)=>{let n=CT(e.samples),r=wT(n?n.presentationTimestamp+n.duration:0,sD),i=!kT(t)||!kT(r),a=i?_T:$,o;return o=e.info.type===`video`?typeof e.info.rotation==`number`?TT(e.info.rotation):e.info.rotation:ET,jT(`tkhd`,+i,3,[a(t),a(t),$(e.id),$(0),a(r),Array(8).fill(0),pT(0),pT(0),vT(+(e.info.type===`audio`)),pT(0),DT(o),yT(e.info.type===`video`?e.info.width:0),yT(e.info.type===`video`?e.info.height:0)])},zT=(e,t)=>AT(`mdia`,null,[BT(e,t),VT(e.info.type===`video`?`vide`:`soun`),HT(e)]),BT=(e,t)=>{let n=CT(e.samples),r=wT(n?n.presentationTimestamp+n.duration:0,e.timescale),i=!kT(t)||!kT(r),a=i?_T:$;return jT(`mdhd`,+i,0,[a(t),a(t),$(e.timescale),a(r),pT(21956),pT(0)])},VT=e=>jT(`hdlr`,0,0,[xT(`mhlr`),xT(e),$(0),$(0),$(0),xT(`mp4-muxer-hdlr`,!0)]),HT=e=>AT(`minf`,null,[e.info.type===`video`?UT():WT(),GT(),JT(e)]),UT=()=>jT(`vmhd`,0,1,[pT(0),pT(0),pT(0),pT(0)]),WT=()=>jT(`smhd`,0,0,[pT(0),pT(0)]),GT=()=>AT(`dinf`,null,[KT()]),KT=()=>jT(`dref`,0,0,[$(1)],[qT()]),qT=()=>jT(`url `,0,1),JT=e=>{let t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(e=>e.sampleCompositionTimeOffset!==0);return AT(`stbl`,null,[YT(e),cE(e),lE(e),uE(e),dE(e),fE(e),t?pE(e):null])},YT=e=>jT(`stsd`,0,0,[$(1)],[e.info.type===`video`?XT(EE[e.info.codec],e):aE(OE[e.info.codec],e)]),XT=(e,t)=>AT(e,[[,,,,,,].fill(0),pT(1),pT(0),pT(0),Array(12).fill(0),pT(t.info.width),pT(t.info.height),$(4718592),$(4718592),$(0),pT(1),Array(32).fill(0),pT(24),mT(65535)],[DE[t.info.codec](t),t.info.decoderConfig.colorSpace?eE(t):null]),ZT={bt709:1,bt470bg:5,smpte170m:6},QT={bt709:1,smpte170m:6,"iec61966-2-1":13},$T={rgb:0,bt709:1,bt470bg:5,smpte170m:6},eE=e=>AT(`colr`,[xT(`nclx`),pT(ZT[e.info.decoderConfig.colorSpace.primaries]),pT(QT[e.info.decoderConfig.colorSpace.transfer]),pT($T[e.info.decoderConfig.colorSpace.matrix]),fT(!!e.info.decoderConfig.colorSpace.fullRange<<7)]),tE=e=>e.info.decoderConfig&&AT(`avcC`,[...new Uint8Array(e.info.decoderConfig.description)]),nE=e=>e.info.decoderConfig&&AT(`hvcC`,[...new Uint8Array(e.info.decoderConfig.description)]),rE=e=>{if(!e.info.decoderConfig)return null;let t=e.info.decoderConfig;if(!t.colorSpace)throw Error(`'colorSpace' is required in the decoder config for VP9.`);let n=t.codec.split(`.`),r=Number(n[1]),i=Number(n[2]),a=(Number(n[3])<<4)+0+Number(t.colorSpace.fullRange);return jT(`vpcC`,1,0,[fT(r),fT(i),fT(a),fT(2),fT(2),fT(2),pT(0)])},iE=()=>AT(`av1C`,[129,0,0,0]),aE=(e,t)=>AT(e,[[,,,,,,].fill(0),pT(1),pT(0),pT(0),$(0),pT(t.info.numberOfChannels),pT(16),pT(0),pT(0),yT(t.info.sampleRate)],[kE[t.info.codec](t)]),oE=e=>{let t=new Uint8Array(e.info.decoderConfig.description);return jT(`esds`,0,0,[$(58753152),fT(32+t.byteLength),pT(1),fT(0),$(75530368),fT(18+t.byteLength),fT(64),fT(21),hT(0),$(130071),$(130071),$(92307584),fT(t.byteLength),...t,$(109084800),fT(1),fT(2)])},sE=e=>{let t=3840,n=0,r=e.info.decoderConfig?.description;if(r){if(r.byteLength<18)throw TypeError(`Invalid decoder description provided for Opus; must be at least 18 bytes long.`);let e=ArrayBuffer.isView(r)?new DataView(r.buffer,r.byteOffset,r.byteLength):new DataView(r);t=e.getUint16(10,!0),n=e.getInt16(14,!0)}return AT(`dOps`,[fT(0),fT(e.info.numberOfChannels),pT(t),$(e.info.sampleRate),vT(n),fT(0)])},cE=e=>jT(`stts`,0,0,[$(e.timeToSampleTable.length),e.timeToSampleTable.map(e=>[$(e.sampleCount),$(e.sampleDelta)])]),lE=e=>{if(e.samples.every(e=>e.type===`key`))return null;let t=[...e.samples.entries()].filter(([,e])=>e.type===`key`);return jT(`stss`,0,0,[$(t.length),t.map(([e])=>$(e+1))])},uE=e=>jT(`stsc`,0,0,[$(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(e=>[$(e.firstChunk),$(e.samplesPerChunk),$(1)])]),dE=e=>jT(`stsz`,0,0,[$(0),$(e.samples.length),e.samples.map(e=>$(e.size))]),fE=e=>e.finalizedChunks.length>0&&ST(e.finalizedChunks).offset>=2**32?jT(`co64`,0,0,[$(e.finalizedChunks.length),e.finalizedChunks.map(e=>_T(e.offset))]):jT(`stco`,0,0,[$(e.finalizedChunks.length),e.finalizedChunks.map(e=>$(e.offset))]),pE=e=>jT(`ctts`,0,0,[$(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(e=>[$(e.sampleCount),$(e.sampleCompositionTimeOffset)])]),mE=e=>AT(`mvex`,null,e.map(hE)),hE=e=>jT(`trex`,0,0,[$(e.id),$(1),$(0),$(0),$(0)]),gE=(e,t)=>AT(`moof`,null,[_E(e),...t.map(yE)]),_E=e=>jT(`mfhd`,0,0,[$(e)]),vE=e=>{let t=0,n=0,r=e.type===`delta`;return n|=+r,r?t|=1:t|=2,t<<24|n<<16|0},yE=e=>AT(`traf`,null,[bE(e),xE(e),SE(e)]),bE=e=>{let t=0;t|=8,t|=16,t|=32,t|=131072;let n=e.currentChunk.samples[1]??e.currentChunk.samples[0],r={duration:n.timescaleUnitsToNextSample,size:n.size,flags:vE(n)};return jT(`tfhd`,0,t,[$(e.id),$(r.duration),$(r.size),$(r.flags)])},xE=e=>jT(`tfdt`,1,0,[_T(wT(e.currentChunk.startTimestamp,e.timescale))]),SE=e=>{let t=e.currentChunk.samples.map(e=>e.timescaleUnitsToNextSample),n=e.currentChunk.samples.map(e=>e.size),r=e.currentChunk.samples.map(vE),i=e.currentChunk.samples.map(t=>wT(t.presentationTimestamp-t.decodeTimestamp,e.timescale)),a=new Set(t),o=new Set(n),s=new Set(r),c=new Set(i),l=s.size===2&&r[0]!==r[1],u=a.size>1,d=o.size>1,f=!l&&s.size>1,p=c.size>1||[...c].some(e=>e!==0),m=0;return m|=1,m|=4*l,m|=256*u,m|=512*d,m|=1024*f,m|=2048*p,jT(`trun`,1,m,[$(e.currentChunk.samples.length),$(e.currentChunk.offset-e.currentChunk.moofOffset||0),l?$(r[0]):[],e.currentChunk.samples.map((e,a)=>[u?$(t[a]):[],d?$(n[a]):[],f?$(r[a]):[],p?gT(i[a]):[]])])},CE=e=>AT(`mfra`,null,[...e.map(wE),TE()]),wE=(e,t)=>jT(`tfra`,1,0,[$(e.id),$(63),$(e.finalizedChunks.length),e.finalizedChunks.map(n=>[_T(wT(n.startTimestamp,e.timescale)),_T(n.moofOffset),$(t+1),$(1),$(1)])]),TE=()=>jT(`mfro`,0,0,[$(0)]),EE={avc:`avc1`,hevc:`hvc1`,vp9:`vp09`,av1:`av01`},DE={avc:tE,hevc:nE,vp9:rE,av1:iE},OE={aac:`mp4a`,opus:`Opus`},kE={aac:oE,opus:sE},AE=class{},jE=class extends AE{constructor(){super(...arguments),this.buffer=null}},ME=class extends AE{constructor(e){if(super(),this.options=e,typeof e!=`object`)throw TypeError(`StreamTarget requires an options object to be passed to its constructor.`);if(e.onData){if(typeof e.onData!=`function`)throw TypeError(`options.onData, when provided, must be a function.`);if(e.onData.length<2)throw TypeError(`options.onData, when provided, must be a function that takes in at least two arguments (data and position). Ignoring the position argument, which specifies the byte offset at which the data is to be written, can lead to broken outputs.`)}if(e.chunked!==void 0&&typeof e.chunked!=`boolean`)throw TypeError(`options.chunked, when provided, must be a boolean.`);if(e.chunkSize!==void 0&&(!Number.isInteger(e.chunkSize)||e.chunkSize<1024))throw TypeError(`options.chunkSize, when provided, must be an integer and not smaller than 1024.`)}},NE=class extends AE{constructor(e,t){if(super(),this.stream=e,this.options=t,!(e instanceof FileSystemWritableFileStream))throw TypeError(`FileSystemWritableFileStreamTarget requires a FileSystemWritableFileStream instance.`);if(t!==void 0&&typeof t!=`object`)throw TypeError(`FileSystemWritableFileStreamTarget's options, when provided, must be an object.`);if(t&&t.chunkSize!==void 0&&(!Number.isInteger(t.chunkSize)||t.chunkSize<=0))throw TypeError(`options.chunkSize, when provided, must be a positive integer`)}},PE,FE,IE=class{constructor(){this.pos=0,oT(this,PE,new Uint8Array(8)),oT(this,FE,new DataView(Q(this,PE).buffer)),this.offsets=new WeakMap}seek(e){this.pos=e}writeU32(e){Q(this,FE).setUint32(0,e,!1),this.write(Q(this,PE).subarray(0,4))}writeU64(e){Q(this,FE).setUint32(0,Math.floor(e/2**32),!1),Q(this,FE).setUint32(4,e,!1),this.write(Q(this,PE).subarray(0,8))}writeAscii(e){for(let t=0;te.start-t.start);e.push({start:t[0].start,size:t[0].data.byteLength});for(let n=1;ne.start<=t&&tGE){for(let e=0;e=e.written[i+1].start;)e.written[i].end=Math.max(e.written[i].end,e.written[i+1].end),e.written.splice(i+1,1)},tD=new WeakSet,nD=function(e){let t={start:Math.floor(e/Q(this,YE))*Q(this,YE),data:new Uint8Array(Q(this,YE)),written:[],shouldFlush:!1};return Q(this,XE).push(t),Q(this,XE).sort((e,t)=>e.start-t.start),Q(this,XE).indexOf(t)},rD=new WeakSet,iD=function(e=!1){for(let t=0;te.stream.write({type:`write`,data:t,position:n}),chunked:!0,chunkSize:e.options?.chunkSize}))}},sD=1e3,cD=[`avc`,`hevc`,`vp9`,`av1`],lD=[`aac`,`opus`],uD=2082844800,dD=[`strict`,`offset`,`cross-track-offset`],fD,pD,mD,hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD,ED,DD,OD,kD,AD,jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD,JD=class{constructor(e){if(oT(this,wD),oT(this,ED),oT(this,OD),oT(this,AD),oT(this,MD),oT(this,PD),oT(this,ID),oT(this,RD),oT(this,BD),oT(this,HD),oT(this,WD),oT(this,KD),oT(this,fD,void 0),oT(this,pD,void 0),oT(this,mD,void 0),oT(this,hD,void 0),oT(this,gD,null),oT(this,_D,null),oT(this,vD,Math.floor(Date.now()/1e3)+uD),oT(this,yD,[]),oT(this,bD,1),oT(this,xD,[]),oT(this,SD,[]),oT(this,CD,!1),lT(this,wD,TD).call(this,e),e.video=OT(e.video),e.audio=OT(e.audio),e.fastStart=OT(e.fastStart),this.target=e.target,sT(this,fD,{firstTimestampBehavior:`strict`,...e}),e.target instanceof jE)sT(this,pD,new UE(e.target));else if(e.target instanceof ME)sT(this,pD,new aD(e.target));else if(e.target instanceof NE)sT(this,pD,new oD(e.target));else throw Error(`Invalid target: ${e.target}`);lT(this,AD,jD).call(this),lT(this,ED,DD).call(this)}addVideoChunk(e,t,n,r){if(!(e instanceof EncodedVideoChunk))throw TypeError(`addVideoChunk's first argument (sample) must be of type EncodedVideoChunk.`);if(t&&typeof t!=`object`)throw TypeError(`addVideoChunk's second argument (meta), when provided, must be an object.`);if(n!==void 0&&(!Number.isFinite(n)||n<0))throw TypeError(`addVideoChunk's third argument (timestamp), when provided, must be a non-negative real number.`);if(r!==void 0&&!Number.isFinite(r))throw TypeError(`addVideoChunk's fourth argument (compositionTimeOffset), when provided, must be a real number.`);let i=new Uint8Array(e.byteLength);e.copyTo(i),this.addVideoChunkRaw(i,e.type,n??e.timestamp,e.duration,t,r)}addVideoChunkRaw(e,t,n,r,i,a){if(!(e instanceof Uint8Array))throw TypeError(`addVideoChunkRaw's first argument (data) must be an instance of Uint8Array.`);if(t!==`key`&&t!==`delta`)throw TypeError(`addVideoChunkRaw's second argument (type) must be either 'key' or 'delta'.`);if(!Number.isFinite(n)||n<0)throw TypeError(`addVideoChunkRaw's third argument (timestamp) must be a non-negative real number.`);if(!Number.isFinite(r)||r<0)throw TypeError(`addVideoChunkRaw's fourth argument (duration) must be a non-negative real number.`);if(i&&typeof i!=`object`)throw TypeError(`addVideoChunkRaw's fifth argument (meta), when provided, must be an object.`);if(a!==void 0&&!Number.isFinite(a))throw TypeError(`addVideoChunkRaw's sixth argument (compositionTimeOffset), when provided, must be a real number.`);if(lT(this,KD,qD).call(this),!Q(this,fD).video)throw Error(`No video track declared.`);if(typeof Q(this,fD).fastStart==`object`&&Q(this,gD).samples.length===Q(this,fD).fastStart.expectedVideoChunks)throw Error(`Cannot add more video chunks than specified in 'fastStart' (${Q(this,fD).fastStart.expectedVideoChunks}).`);let o=lT(this,PD,FD).call(this,Q(this,gD),e,t,n,r,i,a);if(Q(this,fD).fastStart===`fragmented`&&Q(this,_D)){for(;Q(this,SD).length>0&&Q(this,SD)[0].decodeTimestamp<=o.decodeTimestamp;){let e=Q(this,SD).shift();lT(this,ID,LD).call(this,Q(this,_D),e)}o.decodeTimestamp<=Q(this,_D).lastDecodeTimestamp?lT(this,ID,LD).call(this,Q(this,gD),o):Q(this,xD).push(o)}else lT(this,ID,LD).call(this,Q(this,gD),o)}addAudioChunk(e,t,n){if(!(e instanceof EncodedAudioChunk))throw TypeError(`addAudioChunk's first argument (sample) must be of type EncodedAudioChunk.`);if(t&&typeof t!=`object`)throw TypeError(`addAudioChunk's second argument (meta), when provided, must be an object.`);if(n!==void 0&&(!Number.isFinite(n)||n<0))throw TypeError(`addAudioChunk's third argument (timestamp), when provided, must be a non-negative real number.`);let r=new Uint8Array(e.byteLength);e.copyTo(r),this.addAudioChunkRaw(r,e.type,n??e.timestamp,e.duration,t)}addAudioChunkRaw(e,t,n,r,i){if(!(e instanceof Uint8Array))throw TypeError(`addAudioChunkRaw's first argument (data) must be an instance of Uint8Array.`);if(t!==`key`&&t!==`delta`)throw TypeError(`addAudioChunkRaw's second argument (type) must be either 'key' or 'delta'.`);if(!Number.isFinite(n)||n<0)throw TypeError(`addAudioChunkRaw's third argument (timestamp) must be a non-negative real number.`);if(!Number.isFinite(r)||r<0)throw TypeError(`addAudioChunkRaw's fourth argument (duration) must be a non-negative real number.`);if(i&&typeof i!=`object`)throw TypeError(`addAudioChunkRaw's fifth argument (meta), when provided, must be an object.`);if(lT(this,KD,qD).call(this),!Q(this,fD).audio)throw Error(`No audio track declared.`);if(typeof Q(this,fD).fastStart==`object`&&Q(this,_D).samples.length===Q(this,fD).fastStart.expectedAudioChunks)throw Error(`Cannot add more audio chunks than specified in 'fastStart' (${Q(this,fD).fastStart.expectedAudioChunks}).`);let a=lT(this,PD,FD).call(this,Q(this,_D),e,t,n,r,i);if(Q(this,fD).fastStart===`fragmented`&&Q(this,gD)){for(;Q(this,xD).length>0&&Q(this,xD)[0].decodeTimestamp<=a.decodeTimestamp;){let e=Q(this,xD).shift();lT(this,ID,LD).call(this,Q(this,gD),e)}a.decodeTimestamp<=Q(this,gD).lastDecodeTimestamp?lT(this,ID,LD).call(this,Q(this,_D),a):Q(this,SD).push(a)}else lT(this,ID,LD).call(this,Q(this,_D),a)}finalize(){if(Q(this,CD))throw Error(`Cannot finalize a muxer more than once.`);if(Q(this,fD).fastStart===`fragmented`){for(let e of Q(this,xD))lT(this,ID,LD).call(this,Q(this,gD),e);for(let e of Q(this,SD))lT(this,ID,LD).call(this,Q(this,_D),e);lT(this,HD,UD).call(this,!1)}else Q(this,gD)&&lT(this,BD,VD).call(this,Q(this,gD)),Q(this,_D)&&lT(this,BD,VD).call(this,Q(this,_D));let e=[Q(this,gD),Q(this,_D)].filter(Boolean);if(Q(this,fD).fastStart===`in-memory`){let t;for(let n=0;n<2;n++){let n=FT(e,Q(this,vD)),r=Q(this,pD).measureBox(n);t=Q(this,pD).measureBox(Q(this,hD));let i=Q(this,pD).pos+r+t;for(let e of Q(this,yD)){e.offset=i;for(let{data:n}of e.samples)i+=n.byteLength,t+=n.byteLength}if(i<2**32)break;t>=2**32&&(Q(this,hD).largeSize=!0)}let n=FT(e,Q(this,vD));Q(this,pD).writeBox(n),Q(this,hD).size=t,Q(this,pD).writeBox(Q(this,hD));for(let e of Q(this,yD))for(let t of e.samples)Q(this,pD).write(t.data),t.data=null}else if(Q(this,fD).fastStart===`fragmented`){let t=Q(this,pD).pos,n=CE(e);Q(this,pD).writeBox(n);let r=Q(this,pD).pos-t;Q(this,pD).seek(Q(this,pD).pos-4),Q(this,pD).writeU32(r)}else{let t=Q(this,pD).offsets.get(Q(this,hD)),n=Q(this,pD).pos-t;Q(this,hD).size=n,Q(this,hD).largeSize=n>=2**32,Q(this,pD).patchBox(Q(this,hD));let r=FT(e,Q(this,vD));if(typeof Q(this,fD).fastStart==`object`){Q(this,pD).seek(Q(this,mD)),Q(this,pD).writeBox(r);let e=t-Q(this,pD).pos;Q(this,pD).writeBox(PT(e))}else Q(this,pD).writeBox(r)}lT(this,WD,GD).call(this),Q(this,pD).finalize(),sT(this,CD,!0)}};fD=new WeakMap,pD=new WeakMap,mD=new WeakMap,hD=new WeakMap,gD=new WeakMap,_D=new WeakMap,vD=new WeakMap,yD=new WeakMap,bD=new WeakMap,xD=new WeakMap,SD=new WeakMap,CD=new WeakMap,wD=new WeakSet,TD=function(e){if(typeof e!=`object`)throw TypeError(`The muxer requires an options object to be passed to its constructor.`);if(!(e.target instanceof AE))throw TypeError(`The target must be provided and an instance of Target.`);if(e.video){if(!cD.includes(e.video.codec))throw TypeError(`Unsupported video codec: ${e.video.codec}`);if(!Number.isInteger(e.video.width)||e.video.width<=0)throw TypeError(`Invalid video width: ${e.video.width}. Must be a positive integer.`);if(!Number.isInteger(e.video.height)||e.video.height<=0)throw TypeError(`Invalid video height: ${e.video.height}. Must be a positive integer.`);let t=e.video.rotation;if(typeof t==`number`&&![0,90,180,270].includes(t))throw TypeError(`Invalid video rotation: ${t}. Has to be 0, 90, 180 or 270.`);if(Array.isArray(t)&&(t.length!==9||t.some(e=>typeof e!=`number`)))throw TypeError(`Invalid video transformation matrix: ${t.join()}`);if(e.video.frameRate!==void 0&&(!Number.isInteger(e.video.frameRate)||e.video.frameRate<=0))throw TypeError(`Invalid video frame rate: ${e.video.frameRate}. Must be a positive integer.`)}if(e.audio){if(!lD.includes(e.audio.codec))throw TypeError(`Unsupported audio codec: ${e.audio.codec}`);if(!Number.isInteger(e.audio.numberOfChannels)||e.audio.numberOfChannels<=0)throw TypeError(`Invalid number of audio channels: ${e.audio.numberOfChannels}. Must be a positive integer.`);if(!Number.isInteger(e.audio.sampleRate)||e.audio.sampleRate<=0)throw TypeError(`Invalid audio sample rate: ${e.audio.sampleRate}. Must be a positive integer.`)}if(e.firstTimestampBehavior&&!dD.includes(e.firstTimestampBehavior))throw TypeError(`Invalid first timestamp behavior: ${e.firstTimestampBehavior}`);if(typeof e.fastStart==`object`){if(e.video){if(e.fastStart.expectedVideoChunks===void 0)throw TypeError(`'fastStart' is an object but is missing property 'expectedVideoChunks'.`);if(!Number.isInteger(e.fastStart.expectedVideoChunks)||e.fastStart.expectedVideoChunks<0)throw TypeError(`'expectedVideoChunks' must be a non-negative integer.`)}if(e.audio){if(e.fastStart.expectedAudioChunks===void 0)throw TypeError(`'fastStart' is an object but is missing property 'expectedAudioChunks'.`);if(!Number.isInteger(e.fastStart.expectedAudioChunks)||e.fastStart.expectedAudioChunks<0)throw TypeError(`'expectedAudioChunks' must be a non-negative integer.`)}}else if(![!1,`in-memory`,`fragmented`].includes(e.fastStart))throw TypeError(`'fastStart' option must be false, 'in-memory', 'fragmented' or an object.`);if(e.minFragmentDuration!==void 0&&(!Number.isFinite(e.minFragmentDuration)||e.minFragmentDuration<0))throw TypeError(`'minFragmentDuration' must be a non-negative number.`)},ED=new WeakSet,DD=function(){if(Q(this,pD).writeBox(MT({holdsAvc:Q(this,fD).video?.codec===`avc`,fragmented:Q(this,fD).fastStart===`fragmented`})),sT(this,mD,Q(this,pD).pos),Q(this,fD).fastStart===`in-memory`)sT(this,hD,NT(!1));else if(Q(this,fD).fastStart!==`fragmented`){if(typeof Q(this,fD).fastStart==`object`){let e=lT(this,OD,kD).call(this);Q(this,pD).seek(Q(this,pD).pos+e)}sT(this,hD,NT(!0)),Q(this,pD).writeBox(Q(this,hD))}lT(this,WD,GD).call(this)},OD=new WeakSet,kD=function(){if(typeof Q(this,fD).fastStart!=`object`)return;let e=0,t=[Q(this,fD).fastStart.expectedVideoChunks,Q(this,fD).fastStart.expectedAudioChunks];for(let n of t)n&&(e+=8*Math.ceil(2/3*n),e+=4*n,e+=12*Math.ceil(2/3*n),e+=4*n,e+=8*n);return e+=4096,e},AD=new WeakSet,jD=function(){if(Q(this,fD).video&&sT(this,gD,{id:1,info:{type:`video`,codec:Q(this,fD).video.codec,width:Q(this,fD).video.width,height:Q(this,fD).video.height,rotation:Q(this,fD).video.rotation??0,decoderConfig:null},timescale:Q(this,fD).video.frameRate??57600,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),Q(this,fD).audio&&(sT(this,_D,{id:Q(this,fD).video?2:1,info:{type:`audio`,codec:Q(this,fD).audio.codec,numberOfChannels:Q(this,fD).audio.numberOfChannels,sampleRate:Q(this,fD).audio.sampleRate,decoderConfig:null},timescale:Q(this,fD).audio.sampleRate,samples:[],finalizedChunks:[],currentChunk:null,firstDecodeTimestamp:void 0,lastDecodeTimestamp:-1,timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,compactlyCodedChunkTable:[]}),Q(this,fD).audio.codec===`aac`)){let e=lT(this,MD,ND).call(this,2,Q(this,fD).audio.sampleRate,Q(this,fD).audio.numberOfChannels);Q(this,_D).info.decoderConfig={codec:Q(this,fD).audio.codec,description:e,numberOfChannels:Q(this,fD).audio.numberOfChannels,sampleRate:Q(this,fD).audio.sampleRate}}},MD=new WeakSet,ND=function(e,t,n){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(t),i=n,a=``;a+=e.toString(2).padStart(5,`0`),a+=r.toString(2).padStart(4,`0`),r===15&&(a+=t.toString(2).padStart(24,`0`)),a+=i.toString(2).padStart(4,`0`);let o=Math.ceil(a.length/8)*8;a=a.padEnd(o,`0`);let s=new Uint8Array(a.length/8);for(let e=0;e=a&&(r=!0,lT(this,HD,UD).call(this))}else r=n>=.5}r&&(e.currentChunk&&lT(this,BD,VD).call(this,e),e.currentChunk={startTimestamp:t.presentationTimestamp,samples:[]}),e.currentChunk.samples.push(t)},RD=new WeakSet,zD=function(e,t,n){let r=Q(this,fD).firstTimestampBehavior===`strict`,i=n.lastDecodeTimestamp===-1;if(r&&i&&t!==0)throw Error(`The first chunk for your media track must have a timestamp of 0 (received DTS=${t}).Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of thedocument, which is probably what you want. + +If you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options. +`);if(Q(this,fD).firstTimestampBehavior===`offset`||Q(this,fD).firstTimestampBehavior===`cross-track-offset`){n.firstDecodeTimestamp===void 0&&(n.firstDecodeTimestamp=t);let r;r=Q(this,fD).firstTimestampBehavior===`offset`?n.firstDecodeTimestamp:Math.min(Q(this,gD)?.firstDecodeTimestamp??1/0,Q(this,_D)?.firstDecodeTimestamp??1/0),t-=r,e-=r}if(te&&e.currentChunk);if(t.length===0)return;let n=cT(this,bD)._++;if(n===1){let e=FT(t,Q(this,vD),!0);Q(this,pD).writeBox(e)}let r=Q(this,pD).pos,i=gE(n,t);Q(this,pD).writeBox(i);{let e=NT(!1),n=0;for(let e of t)for(let t of e.currentChunk.samples)n+=t.size;let r=Q(this,pD).measureBox(e)+n;r>=2**32&&(e.largeSize=!0,r=Q(this,pD).measureBox(e)+n),e.size=r,Q(this,pD).writeBox(e)}for(let e of t){e.currentChunk.offset=Q(this,pD).pos,e.currentChunk.moofOffset=r;for(let t of e.currentChunk.samples)Q(this,pD).write(t.data),t.data=null}let a=Q(this,pD).pos;Q(this,pD).seek(Q(this,pD).offsets.get(i));let o=gE(n,t);Q(this,pD).writeBox(o),Q(this,pD).seek(a);for(let e of t)e.finalizedChunks.push(e.currentChunk),Q(this,yD).push(e.currentChunk),e.currentChunk=null;e&&lT(this,WD,GD).call(this)},WD=new WeakSet,GD=function(){Q(this,pD)instanceof aD&&Q(this,pD).flush()},KD=new WeakSet,qD=function(){if(Q(this,CD))throw Error(`Cannot add new video or audio chunks after the file has been finalized.`)};function YD(){return typeof window<`u`&&`VideoEncoder`in window&&`AudioEncoder`in window}async function XD(e){let t=await e.arrayBuffer(),n=new(window.AudioContext||window.webkitAudioContext),r=await n.decodeAudioData(t);return n.close(),r}async function ZD(e,t){if(e.sampleRate===t)return e;let n=new OfflineAudioContext(e.numberOfChannels,Math.ceil(e.duration*t),t),r=n.createBufferSource();return r.buffer=e,r.connect(n.destination),r.start(0),await n.startRendering()}async function QD(e,t){let n={codec:`mp4a.40.2`,sampleRate:e,numberOfChannels:t,bitrate:128e3};if(typeof AudioEncoder<`u`&&`isConfigSupported`in AudioEncoder){try{if((await AudioEncoder.isConfigSupported(n)).supported)return n}catch(e){console.warn(`AAC config check failed:`,e)}let e={codec:`opus`,sampleRate:48e3,numberOfChannels:t,bitrate:128e3};try{if((await AudioEncoder.isConfigSupported(e)).supported)return e}catch(e){console.warn(`Opus config check failed:`,e)}}return n}async function $D(e,t,n,r){let i=[];e.forEach((e,a)=>{let o=-1;if(a===`__custom_bg_video__`){let t=e.duration||1;t>0&&(o=(r===void 0?n:r)%t)}else if(a===`__floating_notes_media__`){let t=e.duration||1;t>0&&(o=n%t)}else if(a===`background`){let t=e.duration||1;t>0&&(o=n%t)}else{let r=t.find(e=>e.id===a);if(r&&r.type===`video`&&n>=r.startTime&&n0&&i>=a&&(i%=a),o=i}}if(o>=0){if(e.readyState===0)return;Math.abs(e.currentTime-o)>.05&&i.push(new Promise(t=>{let n=!1,r=()=>{n||(n=!0,e.removeEventListener(`seeked`,r),t())};e.addEventListener(`seeked`,r),e.currentTime=o,setTimeout(()=>{n||(n=!0,e.removeEventListener(`seeked`,r),t())},500)}))}}),i.length>0&&await Promise.all(i)}async function eO(e,t,n){if(!(n.has(e)&&n.get(e)?.src===t))return new Promise(r=>{let i=new Image;i.crossOrigin=`anonymous`,i.onload=()=>{n.set(e,i),r()},i.onerror=()=>{console.warn(`Failed to load background image:`,t),r()},i.src=t})}async function tO(e,t,n){if(!(n.has(e)&&n.get(e)?.src===t))return new Promise(r=>{let i=document.createElement(`video`);i.crossOrigin=`anonymous`,i.muted=!0,i.playsInline=!0,i.preload=`auto`;let a=!1,o=()=>{a||(a=!0,n.set(e,i),r())};i.oncanplay=()=>{a||(i.currentTime=.001)},i.onseeked=()=>o(),i.onerror=()=>{console.warn(`Failed to load background video:`,t),o()},setTimeout(()=>o(),1e4),i.src=t,i.load()})}async function nO(e){let{canvas:t,audioFile:n,lyrics:r,metadata:i,visualSlides:a,imageMap:o,videoMap:s,preset:c,customFontName:l,renderConfig:u,fps:d,quality:f,onProgress:p,onLog:m,abortSignal:h,isFirstSong:g=!0,isLastSong:_=!0,startTimeOffset:v=0}=e;if(!YD())throw Error(`WebCodecs API is not supported in this browser.`);let y=()=>h?.aborted===!0||h?.current===!0;p(0,`Initializing WebCodecs...`),m?.(`Decoding audio...`);let b=await XD(n),x=await Ww(a,b.sampleRate,m);x.length>0&&(m?.(`Mixing timeline audio tracks...`),b=await Gw(b,x,u,v,m));let S=await QD(b.sampleRate,b.numberOfChannels);S.codec===`opus`&&b.sampleRate!==48e3&&(m?.(`Resampling audio to 48kHz for Opus support...`),b=await ZD(b,48e3),S=await QD(b.sampleRate,b.numberOfChannels));let C=b.duration,w=Math.ceil(C*d),T=new JD({target:new jE,video:{codec:`avc`,width:t.width,height:t.height},audio:{codec:S.codec===`opus`?`opus`:`aac`,sampleRate:S.sampleRate,numberOfChannels:S.numberOfChannels},firstTimestampBehavior:`offset`,fastStart:`in-memory`}),E=(e.resolution===`1080p`?8e6:4e6)*(f===`high`?1.5:f===`low`?.5:1),D=new VideoEncoder({output:(e,n)=>{n&&!n.decoderConfig&&(n.decoderConfig={codec:`avc1.4d002a`,width:t.width,height:t.height,displayAspectWidth:t.width,displayAspectHeight:t.height}),T.addVideoChunk(e,n)},error:e=>{console.error(`VideoEncoder error:`,e),m?.(`VideoEncoder error: ${e.message}`)}});D.configure({codec:`avc1.4d002a`,width:t.width,height:t.height,bitrate:E,framerate:d});let O=new AudioEncoder({output:(e,t)=>T.addAudioChunk(e,t),error:e=>{console.error(`AudioEncoder error:`,e),m?.(`AudioEncoder error: ${e.message}`)}});O.configure(S),p(5,`Encoding Audio...`);let k=b.numberOfChannels,A=b.sampleRate,j=A,M=b.length;for(let e=0;e10;)await new Promise(e=>setTimeout(e,10))}await O.flush(),p(10,`Rendering Frames...`);let N=t.getContext(`2d`,{desynchronized:!1});if(!N)throw Error(`No canvas context`);let ee=1/d*1e6,P=u.showVisualization?b.getChannelData(0):null,F=b.sampleRate;for(let e=0;e0,C,u,_,g,f,m);let h=Math.round(e*ee),b=new VideoFrame(t,{timestamp:h,duration:Math.round(ee)});D.encode(b,{keyFrame:e%(d*2)==0}),b.close(),p(10+e/w*89,`Rendering frame ${e}/${w}`),D.encodeQueueSize>5&&await new Promise(e=>{let t=()=>D.encodeQueueSize<=2?e(null):setTimeout(t,10);t()}),e%2==0&&await new Promise(e=>setTimeout(e,0))}p(99,`Finalizing frames...`),await D.flush(),T.finalize();let{buffer:I}=T.target;return p(100,`Done!`),{blob:new Blob([I],{type:`video/mp4`}),duration:C,format:S.codec===`opus`?`mkv`:`mp4`}}async function rO(e,t){let{canvas:n,visualSlides:r,imageMap:i,videoMap:a,preset:o,customFontName:s,renderConfig:c,fps:l,quality:u,onProgress:d,onLog:f,abortSignal:p}=t;if(!YD())throw Error(`WebCodecs API is not supported in this browser.`);let m=()=>p?.aborted===!0||p?.current===!0;d(0,`Decoding first track...`);let h=await Ww(r,44100,f),g=await XD(e[0].audioFile),_=await QD(g.sampleRate,g.numberOfChannels);_.codec===`opus`&&g.sampleRate!==48e3&&(f?.(`Resampling first track audio to 48kHz for Opus support...`),g=await ZD(g,48e3),_=await QD(g.sampleRate,g.numberOfChannels));let v=g.sampleRate,y=g.numberOfChannels;d(2,`Initializing WebCodecs Playlist Render...`);let b=new JD({target:new jE,video:{codec:`avc`,width:n.width,height:n.height},audio:{codec:_.codec===`opus`?`opus`:`aac`,sampleRate:v,numberOfChannels:y},firstTimestampBehavior:`offset`,fastStart:`in-memory`}),x=(t.resolution===`1080p`?8e6:4e6)*(u===`high`?1.5:u===`low`?.5:1),S=new VideoEncoder({output:(e,t)=>{t&&!t.decoderConfig&&(t.decoderConfig={codec:`avc1.4d002a`,width:n.width,height:n.height,displayAspectWidth:n.width,displayAspectHeight:n.height}),b.addVideoChunk(e,t)},error:e=>{console.error(`VideoEncoder error:`,e),f?.(`VideoEncoder error: ${e.message}`)}});S.configure({codec:`avc1.4d002a`,width:n.width,height:n.height,bitrate:x,framerate:l});let C=new AudioEncoder({output:(e,t)=>b.addAudioChunk(e,t),error:e=>{console.error(`AudioEncoder error:`,e),f?.(`AudioEncoder error: ${e.message}`)}});C.configure(_);let w=0,T=0,E=0;for(let t=0;t0&&(b=await Gw(b,h,c,E,f));let x=b.duration;T+=x;let D=b.length,O=b.numberOfChannels,k=b.sampleRate;O!==y&&f?.(`Warning: Track ${t+1} has different channel count (${O}ch). Expected ${y}ch.`);let A=k;for(let e=0;e10&&await new Promise(e=>setTimeout(e,10))}let j=Math.ceil(x*l),M=1/l*1e6,N=n.getContext(`2d`);if(!N)throw Error(`No canvas context`);for(let f=0;f0,x,c,_,p,g,v);let y=w+Math.round(f*M),C=new VideoFrame(n,{timestamp:y,duration:Math.round(M)});S.encode(C,{keyFrame:f%(l*2)==0}),C.close();let E=f/j;d((t+E)/e.length*100,`Song ${t+1}/${e.length}: Rendering frame ${f}/${j}`),S.encodeQueueSize>5&&await new Promise(e=>{let t=()=>S.encodeQueueSize<=2?e(null):setTimeout(t,10);t()}),f%5==0&&await new Promise(e=>setTimeout(e,0))}w+=Math.round(x*1e6),E+=x}d(99,`Flushing encoders...`),C.state!==`closed`&&await C.flush(),S.state!==`closed`&&await S.flush(),b.finalize();let{buffer:D}=b.target;return d(100,`Done!`),{blob:new Blob([D],{type:`video/mp4`}),duration:T,format:_.codec===`opus`?`mkv`:`mp4`}}function iO(e){let t=e=>e[Math.floor(Math.random()*e.length)],n=e=>e.flatMap(e=>e.options.map(e=>e.value)),r=(e,t,n=2)=>Number((e+Math.random()*(t-e)).toFixed(n)),i=()=>`#`+Math.floor(Math.random()*16777215).toString(16).padStart(6,`0`),a=[`to right`,`to left`,`to bottom`,`to top`,`to bottom right`,`to bottom left`,`to top right`,`to top left`],o=()=>`linear-gradient(${t(a)}, ${i()}, ${i()}, ${i()})`,s=n(vp).filter(e=>e!==`preset`),c=n(yp),l=n(bp),u=n(Sp),d=[`custom`,`color`,`gradient`,`smart-gradient`],f=n(Ep).filter(e=>!e.startsWith(`static-`)),p=n(Op),m=n(kp),h=[...Dp],g=[`top-left`,`top-right`,`bottom-left`,`bottom-right`,`top-center`,`bottom-center`],_=[`top`,`center`,`bottom`],v=[`left`,`center`,`right`],y=[`bars`,`wave`,`circular`,`particles`,`pulse-ring`,`waveform`,`spectrogram`,`spectrum`,`stereo-field`],b=[`accent`,`gradient`,`custom`,`rainbow`],x=[`bottom`,`top`,`full`,`center`],S=Lp.flatMap(e=>e.options.map(e=>e.value)),C=t(u),w=Cp(C),T=w?.color??i(),E=w?.bg??i(),D=t(d),O=()=>Math.random()>.5,k={...e};return e.randomizeBackgroundSource!==!1&&(k.backgroundSource=D,k.backgroundColor=i(),k.backgroundGradient=o()),e.randomizeBackgroundEffects!==!1&&(k.backgroundBlurStrength=Math.random()>.6?Math.floor(Math.random()*25):0,k.enableGradientOverlay=O()),e.randomizeTypographyStyle!==!1&&(k.fontFamily=t(S),k.fontSizeScale=r(.6,2),k.fontColor=i(),k.fontWeight=t([`normal`,`bold`]),k.fontStyle=t([`normal`,`italic`]),k.textDecoration=t([`none`,`none`,`none`,`underline`,`line-through`]),k.textCase=t(h),k.lyricLineHeight=r(1,2),k.lyricStyleTarget=t([`active-only`,`all`]),k.textAlign=t(v),k.contentPosition=t(_),k.marginTopScale=r(.5,2.5),k.marginBottomScale=r(.5,2.5)),e.randomizeLyricDisplayMode!==!1&&(k.lyricDisplayMode=t(f)),e.randomizeTextEffect!==!1&&(k.textEffect=t(s)),e.randomizeTextAnimation!==!1&&(k.textAnimation=t(c)),e.randomizeTransitionEffect!==!1&&(k.transitionEffect=t(l)),e.randomizeHighlightEffect!==!1&&(k.highlightEffect=C,k.highlightColor=T,k.highlightBackground=E,k.useCustomHighlightColors=!1),e.randomizeVisibleElements!==!1&&(k.showTitle=O(),k.showArtist=O(),k.showCover=O(),k.showIntro=O(),k.showLyrics=!0),e.randomizeIntroSettings!==!1&&(k.introMode=t([`auto`,`manual`])),e.randomizeChannelInfo!==!1&&(k.showChannelInfo=Math.random()>.7,k.channelInfoPosition=t(g),k.channelInfoStyle=t(m),k.channelInfoSizeScale=r(.6,1.6),k.channelInfoMarginScale=r(.5,2),k.channelInfoFontFamily=t(S),k.channelInfoFontWeight=t([`normal`,`bold`]),k.channelInfoFontStyle=t([`normal`,`italic`]),k.channelInfoFontColor=i()),e.randomizeFloatingNotes!==!1&&(k.showFloatingNotes=Math.random()>.7,k.floatingNotesLayout=t([`text-only`,`media-only`,`media-left-text`,`media-right-text`,`media-top-text`,`media-bottom-text`]),k.floatingNotesPosition=t(g),k.floatingNotesShape=t([`none`,`sharp`,`rounded`]),k.floatingNotesFillColor=i(),k.floatingNotesOutlineColor=i(),k.floatingNotesOutlineSize=Math.floor(Math.random()*5),k.floatingNotesOpacity=r(.3,1),k.floatingNotesMarginScale=r(.5,2),k.floatingNotesWidth=Math.floor(150+Math.random()*300),k.floatingNotesHeight=Math.floor(100+Math.random()*200),k.floatingNotesMediaSizeScale=r(.2,.7),k.floatingNotesFontSizeScale=r(.8,1.8),k.floatingNotesFontFamily=t(S),k.floatingNotesFontStyle=t([`normal`,`italic`]),k.floatingNotesFontWeight=t([`normal`,`bold`]),k.floatingNotesFontColor=i(),k.floatingNotesTextAlign=t([`left`,`center`,`right`])),e.randomizeSongInfoDesign!==!1&&(k.infoPosition=t(g),k.infoStyle=t(p),k.infoMarginScale=r(.5,2),k.infoSizeScale=r(.6,1.6),k.infoFontFamily=t(S),k.infoFontWeight=t([`normal`,`bold`]),k.infoFontStyle=t([`normal`,`italic`]),k.infoFontColor=i()),e.randomizeVisualTransition!==!1&&(k.visualTransitionType=t([`none`,`crossfade`,`fade-to-black`]),k.visualTransitionDuration=r(.5,2)),e.randomizeAudioVisualizer!==!1&&(k.showVisualization=Math.random()>.6,k.visualizationType=t(y),k.visualizationColorMode=t(b),k.visualizationColor1=i(),k.visualizationColor2=i(),k.visualizationOpacity=r(.3,1),k.visualizationPosition=t(x),k.visualizationSensitivity=r(.5,3),k.visualizationBarCount=Math.floor(16+Math.random()*112)),k.renderMode=e.renderMode,k.introText=e.introText,k.introMode=e.introMode,k}function aO(){let{toast:e,confirm:t}=Ot(),n=(0,w.useRef)(null),r=(0,w.useRef)(null),i=(0,w.useRef)(null),a=(0,w.useRef)(null),o=(0,w.useRef)(null),s=(0,w.useRef)({aborted:!1}),l=(0,w.useRef)(()=>{});(0,w.useEffect)(()=>{ap()},[]);let[u,d]=(0,w.useState)(null),[f,p]=(0,w.useState)(null),[m,h]=(0,w.useState)(0),[g,_]=(0,w.useState)({title:`No Audio Loaded`,artist:`Select a file`,coverUrl:null}),[v,y]=(0,w.useState)([]),[b,x]=(0,w.useState)([]),[S,C]=(0,w.useState)(0),[T,E]=(0,w.useState)(!1),[D,O]=(0,w.useState)(`off`),[k,A]=(0,w.useState)(0),[j,M]=(0,w.useState)(0),[N,ee]=(0,w.useState)(1),[I,te]=(0,w.useState)(!1),[L,ne]=(0,w.useState)(Ze.PLAYER),[R,ie]=(0,w.useState)(!1),[se,ce]=(0,w.useState)(!1),[le,ue]=(0,w.useState)(!1),[de,fe]=(0,w.useState)(!1),[V,me]=(0,w.useState)(!1),[_e,ve]=(0,w.useState)(0),[be,xe]=(0,w.useState)(`16:9`),[Te,Ee]=(0,w.useState)(`1080p`),[De,ke]=(0,w.useState)(`default`),[Me,Ne]=(0,w.useState)(null),[Pe,Ie]=(0,w.useState)(null),[Le,Re]=(0,w.useState)(null),[Be,Ve]=(0,w.useState)(`auto`),[Ue,Je]=(0,w.useState)(30),[Ye,Xe]=(0,w.useState)(`med`),[Qe,$e]=(0,w.useState)(`webcodecs`),[tt,nt]=(0,w.useState)(`h264`),[rt,it]=(0,w.useState)(``),[at,ot]=(0,w.useState)(!1),[st,ct]=(0,w.useState)(!1),[lt,ut]=(0,w.useState)(1),[ft,pt]=(0,w.useState)(!1),ht=(0,w.useRef)(0),[G,gt]=(0,w.useState)({backgroundSource:`custom`,backgroundColor:`#581c87`,backgroundGradient:`linear-gradient(to bottom right, #312e81, #581c87, #000000)`,renderMode:`current`,textAlign:`center`,contentPosition:`center`,fontFamily:`ui-sans-serif, system-ui, sans-serif`,fontSizeScale:1,fontColor:`#ffffff`,textEffect:`preset`,textAnimation:`none`,transitionEffect:`none`,lyricDisplayMode:`all`,lyricVisibilityMode:`default`,fontWeight:`bold`,fontStyle:`normal`,lyricStyleTarget:`active-only`,textDecoration:`none`,showTitle:!0,showArtist:!0,showCover:!0,showIntro:!0,showLyrics:!0,infoPosition:`top-left`,infoStyle:`classic`,infoMarginScale:1,backgroundBlurStrength:0,introMode:`auto`,introText:``,textCase:`none`,highlightEffect:`karaoke`,lyricLineHeight:1.3,useRealColorMedia:!1,channelInfoFontWeight:`bold`,channelInfoFontStyle:`normal`,infoFontWeight:`bold`,infoFontStyle:`normal`,showFloatingNotes:!1,floatingNotesLayout:`text-only`,floatingNotesMedia:void 0,floatingNotesMediaType:`image`,floatingNotesText:`Floating Notes`,floatingNotesPosition:`bottom-left`,floatingNotesShape:`rounded`,floatingNotesFillColor:`#000000`,floatingNotesOutlineColor:`#ffffff`,floatingNotesOutlineSize:1,floatingNotesOpacity:.8,floatingNotesMarginScale:1,floatingNotesWidth:300,floatingNotesHeight:150,floatingNotesMediaSizeScale:.4,floatingNotesFontSizeScale:1,floatingNotesFontFamily:`ui-sans-serif, system-ui, sans-serif`,floatingNotesFontStyle:`normal`,floatingNotesFontWeight:`normal`,floatingNotesFontColor:`#ffffff`,floatingNotesTextAlign:`left`,floatingNotesVisibilityMode:`all`,floatingNotesFromStartDuration:10,floatingNotesFromEndDuration:10,floatingNotesSpecificStart:`0:00`,floatingNotesSpecificEnd:`0:30`,randomizeBackgroundSource:!0,randomizeBackgroundEffects:!0,randomizeAudioVisualizer:!0,randomizeLyricDisplayMode:!0,randomizeHighlightEffect:!0,randomizeVisibleElements:!0,randomizeIntroSettings:!0,randomizeTypographyStyle:!0,randomizeTextEffect:!0,randomizeTextAnimation:!0,randomizeTransitionEffect:!0,randomizeVisualTransition:!0,randomizeChannelInfo:!0,randomizeFloatingNotes:!0,randomizeSongInfoDesign:!0}),xt=(0,w.useRef)(G);(0,w.useEffect)(()=>{xt.current=G},[G]);let Ct=(0,w.useRef)(null),wt=(0,w.useRef)(null),Tt=G.backgroundBlurStrength>0,Et=(0,w.useMemo)(()=>[{label:`VP9 (WebM)`,value:`video/webm; codecs=vp9,opus`},{label:`H.264 (MP4)`,value:`video/mp4; codecs="avc1.4D401E, mp4a.40.2"`},{label:`AV1 (MP4)`,value:`video/mp4; codecs="av01.0.05M.08"`},{label:`AV1 (WebM)`,value:`video/webm; codecs=av1`},{label:`H.264 High (MP4)`,value:`video/mp4; codecs="avc1.64001E, mp4a.40.2"`}].filter(e=>MediaRecorder.isTypeSupported(e.value)),[]),[Dt,kt]=(0,w.useState)([]),[At,jt]=(0,w.useState)(-1),[Mt,Nt]=(0,w.useState)(!1),Pt=()=>{let e=Te===`1080p`;switch(be){case`9:16`:return e?{w:1080,h:1920}:{w:720,h:1280};case`3:4`:return e?{w:1080,h:1440}:{w:720,h:960};case`4:3`:return e?{w:1440,h:1080}:{w:960,h:720};case`1:1`:return e?{w:1080,h:1080}:{w:720,h:720};case`1:2`:return e?{w:1080,h:2160}:{w:720,h:1440};case`2:1`:return e?{w:2160,h:1080}:{w:1440,h:720};case`2:3`:return e?{w:1080,h:1620}:{w:720,h:1080};case`3:2`:return e?{w:1620,h:1080}:{w:1080,h:720};case`4:5`:return e?{w:1080,h:1350}:{w:720,h:900};case`20:9`:return e?{w:2400,h:1080}:{w:1600,h:720};case`21:9`:return e?{w:2560,h:1080}:{w:1720,h:720};default:return e?{w:1920,h:1080}:{w:1280,h:720}}},{w:Ft,h:It}=Pt(),[Rt,zt]=(0,w.useState)(!0),[Bt,Vt]=(0,w.useState)(!0),[Ht,q]=(0,w.useState)(!1),J=(0,w.useMemo)(()=>{let e=G.visualTransitionType||`none`,t=G.visualTransitionDuration||1;return b.filter(n=>n.type===`audio`?!1:k>=n.startTime&&k=n.endTime&&k{let n=(e.layer||0)-(t.layer||0);return n===0?e.startTime-t.startTime:n})},[b,k,G.visualTransitionType,G.visualTransitionDuration]),Y=b.filter(e=>e.type===`audio`&&k>=e.startTime&&kS===0?v:v.map(e=>({...e,time:e.time+S,endTime:e.endTime===void 0?void 0:e.endTime+S})),[v,S]),Wt=(0,w.useMemo)(()=>Ut.length===0?!1:Ut.every(e=>e.time===0&&(e.endTime===void 0||e.endTime===0)),[Ut]),Gt=Wt?-1:Ut.findIndex((e,t)=>{if(e.endTime!==void 0)return k>=e.time&&k=e.time&&(!n||kG.lyricVisibilityMode!==`auto`||Wt||Ut.length===0||Kt?null:mt(Ut,k,j),[G.lyricVisibilityMode,Wt,Ut,k,j,Kt]),Jt=qt?.autoHideLyrics??!1,Yt=Jt?-1:qt?.displayIdx??Gt,Xt=qt?.virtualActiveIdx??(Gt>=0?Gt:0),Zt=(0,w.useMemo)(()=>Sw(k,j,G,Ut,{isFirstSongInPlaylist:At<=0}),[k,j,G,Ut,At]),Qt=G.floatingNotesLayout||`text-only`,$t=Tw(G),en=Ew(G),tn=ww(G),nn=(0,w.useCallback)(e=>{if(et(Ut[e])||Yt===-1)return!1;let t=G.lyricDisplayMode,n=G.lyricVisibilityMode===`auto`&&qt!==null;if(t===`all`)return!0;if(t===`static-all`)return Ut[e].text.trim()!==``;if(t===`active-only`)return e===(n?dt(Ut,Xt,0):Yt);if(t===`next-only`){let t=n?dt(Ut,Xt,0):Yt,r=n?dt(Ut,Xt,1):Yt+1;return e===t||r!==-1&&e===r}if(t===`previous-next`){let t=n?dt(Ut,Xt,-1):Yt-1,r=n?dt(Ut,Xt,0):Yt,i=n?dt(Ut,Xt,1):Yt+1;return e===t||e===r||i!==-1&&e===i}return!0},[Ut,Yt,Xt,G.lyricDisplayMode,G.lyricVisibilityMode,qt]),rn=async(e,t)=>{u&&u.startsWith(`blob:`)&&URL.revokeObjectURL(u);let r=URL.createObjectURL(e);d(r),p(e);let a={title:e.name.replace(/\.[^/.]+$/,``),artist:`Unknown Artist`,coverUrl:null};_(a);let o=[];if(t)try{let e=await t.text(),n=t.name.split(`.`).pop()?.toLowerCase();n===`lrc`?o=vt(e):n===`srt`?o=yt(e):n===`ttml`||n===`xml`?o=bt(e):n===`vtt`&&(o=St(e))}catch(e){console.error(`Failed to parse lyrics in loadAudioFile:`,e)}let s=Math.random().toString(36).substr(2,9),l={id:s,audioFile:e,lyricFile:t,parsedLyrics:o,metadata:a,duration:0},f=e=>{y(t=>{if(t&&t.length>0)return t;let n=vt(e);if(n.length===0&&e.trim()){let t=e.split(` +`).map(e=>e.trim()),r=[];for(let e=0;e0&&r[r.length-1]!==``&&r.push(``):r.push(t[e]);r.length>0&&r[r.length-1]===``&&r.pop(),n=r.map(e=>({time:0,text:e}))}return kt(t=>t.map(t=>t.id===s?{...t,parsedLyrics:n,lyricFile:new File([e],`embedded.lrc`,{type:`text/plain`})}:t)),n})};if(!e.type.startsWith(`video/`))tp(()=>import(`./jsmediatags.min-CmKRqElg.js`).then(e=>c(e.default,1)).then(t=>{t.read(e,{onSuccess:t=>{let{title:n,artist:r,picture:i}=t.tags,o=null;if(i){let{data:e,format:t}=i,n=``;for(let t=0;te.map(e=>e.id===s?{...e,metadata:c}:e));let l=t.tags.lyrics||t.tags.LYRICS||t.tags.USLT||t.tags.SYLT||t.tags.unsyncedlyrics||t.tags.SYNCEDLYRICS||t.tags[`©lyr`],u=``;l&&(u=typeof l==`string`?l:Array.isArray(l)?l.join(` +`):l.lyrics||l.data||l.text||``),u?f(u):Gf(e).then(e=>{e.lyrics&&f(e.lyrics)}).catch(e=>console.warn(`[EmbeddedLyrics] Fallback failed:`,e))},onError:t=>{console.log(`jsmediatags has no reader for this format:`,t),Gf(e).then(e=>{(e.title||e.artist)&&_(t=>{let n={...t,title:e.title||t.title,artist:e.artist||t.artist};return kt(e=>e.map(e=>e.id===s?{...e,metadata:n}:e)),n}),e.lyrics&&f(e.lyrics)}).catch(e=>console.warn(`[EmbeddedLyrics] Fallback failed:`,e))}})}),[]);else if(e.type.startsWith(`video/`)){fe(!1);let e={...a,coverUrl:r,backgroundType:`video`};_(e),kt(t=>t.map(t=>t.id===s?{...t,metadata:e}:t))}y(o),C(0),E(!1),A(0),kt(e=>{let t=[...e,l];return jt(t.length-1),t}),h(e=>e+1),i.current&&(i.current.scrollTop=0),n.current&&n.current.load()},an=e=>{let t=e.target.files?.[0];t&&rn(t),e.target.value=``},on=e=>{let t=e.target.files?.[0];if(t){let e=URL.createObjectURL(t),n=t.type.startsWith(`video/`);n&&fe(!1),_(t=>({...t,coverUrl:e,backgroundType:n?`video`:`image`}))}e.target.value=``},sn=async t=>{try{let n=await t.text(),r=t.name.split(`.`).pop()?.toLowerCase(),i=[];r===`lrc`?i=vt(n):r===`srt`?i=yt(n):r===`ttml`||r===`xml`?i=bt(n):r===`vtt`&&(i=St(n)),i.some(e=>e.words&&e.words.length>0)&&(gt(e=>({...e,highlightEffect:`karaoke`})),e.success(`${r?.toUpperCase()} loaded with word-level timing! Karaoke mode enabled.`)),y(i),kt(e=>e.map((e,n)=>n===At?{...e,parsedLyrics:i,lyricFile:t}:e))}catch(t){console.error(`Failed to parse lyrics:`,t),e.error(`Failed to parse lyric file.`)}},cn=async e=>{let t=e.target.files?.[0];t&&await sn(t),e.target.value=``};(0,w.useEffect)(()=>{if(At!==-1&&Dt[At]){let e=Dt[At];y(e.parsedLyrics||[])}},[Dt,At]);let ln=async t=>{if(!window.FontFace||!document.fonts){e.error(`Custom fonts are not supported in this browser.`);return}try{let n=URL.createObjectURL(t),r=t.name.replace(/\.[^/.]+$/,``),i=`CustomFont`,a=new FontFace(i,`url(${n})`);await a.load(),document.fonts.add(a),Ne(r),gt(e=>({...e,fontFamily:i})),e.success(`Loaded font: ${r}`)}catch(t){console.error(`Failed to load font:`,t),e.error(`Failed to load font file.`)}},un=async e=>{let t=e.target.files?.[0];t&&await ln(t),e.target.value=``},dn=e=>{e.preventDefault(),e.stopPropagation(),!Mt&&(ht.current++,e.dataTransfer.items&&e.dataTransfer.items.length>0&&pt(!0))},fn=e=>{e.preventDefault(),e.stopPropagation(),!Mt&&(ht.current--,ht.current<=0&&(pt(!1),ht.current=0))},pn=e=>{e.preventDefault(),e.stopPropagation()},mn=async t=>{if(t.preventDefault(),t.stopPropagation(),Mt)return;pt(!1),ht.current=0;let n=Array.from(t.dataTransfer.files);if(n.length===0)return;let r=new Map,i=[],a=[],o=[`mp3`,`wav`,`flac`,`ogg`,`m4a`,`aac`,`wma`,`opus`,`mp4`,`mkv`,`webm`,`avi`,`mov`,`m4v`,`ogv`],s=[`lrc`,`srt`,`vtt`,`ttml`,`xml`],c=[`ttf`,`otf`,`woff`,`woff2`];if(n.forEach(e=>{let t=e.name.split(`.`).pop()?.toLowerCase()||``,n=e.type,l=e.name.replace(/\.[^/.]+$/,``);o.includes(t)||n.startsWith(`audio/`)||n.startsWith(`video/`)?(r.has(l)||r.set(l,{}),r.get(l).audio=e):s.includes(t)?(r.has(l)||r.set(l,{}),r.get(l).lyric=e):c.includes(t)?i.push(e):a.push(e)}),i.length>0)for(let e of i)await ln(e);for(let[e,t]of r.entries())t.audio?await rn(t.audio,t.lyric):t.lyric&&await sn(t.lyric);a.length>0&&a.forEach(t=>{e.error(`Unsupported file type: ${t.name}`)})};(0,w.useEffect)(()=>{pt(!1),ht.current=0},[Mt]);let hn=async t=>{let n=t.target.files?.[0];if(n){if(!window.FontFace||!document.fonts){e.error(`Custom fonts are not supported in this browser.`);return}try{let t=URL.createObjectURL(n),r=n.name.replace(/\.[^/.]+$/,``),i=`ChannelFont`,a=new FontFace(i,`url(${t})`);await a.load(),document.fonts.add(a),Ie(r),gt(e=>({...e,channelInfoFontFamily:i})),e.success(`Loaded Channel font: ${r}`)}catch(t){console.error(`Failed to load font:`,t),e.error(`Failed to load channel font file.`)}}t.target.value=``},gn=async t=>{let n=t.target.files?.[0];if(n){if(!window.FontFace||!document.fonts){e.error(`Custom fonts are not supported in this browser.`);return}try{let t=URL.createObjectURL(n),r=n.name.replace(/\.[^/.]+$/,``),i=`InfoFont`,a=new FontFace(i,`url(${t})`);await a.load(),document.fonts.add(a),Re(r),gt(e=>({...e,infoFontFamily:i})),e.success(`Loaded Info font: ${r}`)}catch(t){console.error(`Failed to load font:`,t),e.error(`Failed to load info font file.`)}}t.target.value=``},_n=(0,w.useCallback)(async(e,t=!0,r)=>{let a=r||Dt;if(e<0||e>=a.length)return;let o=a[e];u&&u.startsWith(`blob:`)&&URL.revokeObjectURL(u),E(!1),A(0),h(e=>e+1);let s=URL.createObjectURL(o.audioFile);d(s),p(o.audioFile);let c=o.audioFile.type.startsWith(`video/`)||o.metadata.backgroundType===`video`;if(c&&fe(!1),_({title:o.metadata.title,artist:o.metadata.artist,coverUrl:c?s:o.metadata.coverUrl||null,backgroundType:c?`video`:`image`}),y([]),o.parsedLyrics&&o.parsedLyrics.length>0)y(o.parsedLyrics);else if(o.lyricFile)try{let e=await o.lyricFile.text(),t=o.lyricFile.name.split(`.`).pop()?.toLowerCase(),n=[];t===`lrc`?n=vt(e):t===`srt`?n=yt(e):t===`ttml`||t===`xml`?n=bt(e):t===`vtt`&&(n=St(e)),y(n)}catch(e){console.error(`Failed to load lyrics`,e)}C(0),jt(e),i.current&&(i.current.scrollTop=0),t?setTimeout(()=>{n.current&&(n.current.play().catch(e=>console.log(`Autoplay failed`,e)),E(!0))},150):(E(!1),n.current&&(n.current.pause(),n.current.currentTime=0))},[Dt,u]),vn=(0,w.useCallback)(()=>{Dt.length!==0&&_n((At+1)%Dt.length)},[Dt,At,_n]),yn=(0,w.useCallback)(()=>{Dt.length!==0&&_n((At-1+Dt.length)%Dt.length)},[Dt,At,_n]),bn=()=>{n.current&&(T?(n.current.pause(),E(!1)):!u&&Dt.length>0?_n(0):(n.current.play().catch(console.error),E(!0)))},xn=(0,w.useCallback)(()=>{n.current&&(n.current.pause(),n.current.currentTime=0,E(!1),A(0))},[]),Sn=()=>{O(e=>e===`off`?`one`:e===`one`?`all`:e===`all`?`all_repeat`:`off`)},Cn=()=>{document.fullscreenElement?(document.exitFullscreen(),ie(!1)):(r.current?.requestFullscreen(),ie(!0))},wn=t=>{if(V||t&&t.target.closest(`.no-minimal-mode-toggle`))return;let n=!Ht;q(n),n&&ue(!0),e.success(`Minimal Mode: ${n?`On`:`Off`}`,{id:`minimal-mode`})},Tn=()=>{n.current&&(A(n.current.currentTime),V&&ve(n.current.currentTime/j*100))},En=()=>{n.current&&M(n.current.duration)},Dn=e=>{let t=parseFloat(e.target.value);n.current&&(n.current.currentTime=t,A(t))},On=e=>{if(!Ct.current||V||!j)return;let t=Ct.current.getBoundingClientRect(),r=Math.max(0,Math.min(e-t.left,t.width))/t.width*j;n.current&&(n.current.currentTime=r,A(r))},kn=e=>{let t=parseFloat(e.target.value);ee(t),n.current&&(n.current.volume=t),te(t===0)},An=e=>{if(!wt.current)return;let t=wt.current.getBoundingClientRect(),r=Math.max(0,Math.min(e-t.left,t.width))/t.width;ee(r),n.current&&(n.current.volume=r),te(r===0)},jn=async()=>{if(!n.current||!a.current)return;let r=G.renderMode===`playlist`&&Dt.length>0;console.log(`[Render] Starting Export. Mode: ${G.renderMode}, Playlist Items: ${Dt.length}, IsPlaylistRender: ${r}`),r?e.success(`Starting Playlist Render (${Dt.length} songs)...`):e.success(`Starting Single Track Render...`);let i=[];if(r)for(let e of Dt){let t=[];if(e.parsedLyrics&&e.parsedLyrics.length>0)t=e.parsedLyrics;else if(e.lyricFile)try{let n=await e.lyricFile.text(),r=e.lyricFile.name.split(`.`).pop()?.toLowerCase();r===`lrc`?t=vt(n):r===`srt`?t=yt(n):r===`ttml`||r===`xml`?t=bt(n):r===`vtt`&&(t=St(n))}catch(e){console.error(`Failed to parse lyrics for playlist item`,e)}let n=URL.createObjectURL(e.audioFile);i.push({audioSrc:n,lyrics:t,metadata:e.metadata,isFileSource:!0})}else{if(!u)return;i.push({audioSrc:u,lyrics:Ut,metadata:g,isFileSource:!1})}if(i.length===0)return;if(!await t(`${r?`Start rendering ALL ${i.length} songs from the playlist? This will result in one continuous video.`:`Start rendering ${be} (${Te}) video? This will play the song from start to finish.`} Please do not switch tabs during rendering.`,`Start Rendering?`)){r&&i.forEach(e=>e.isFileSource&&URL.revokeObjectURL(e.audioSrc));return}ot(!1),me(!0),ve(0);let c={aborted:!1};s.current=c,xn(),O(`off`),Ln.current&&clearTimeout(Ln.current),ce(!1),ue(!0),Gn.current&&Gn.current.pause();let l=n.current,d=De,f=new Map,p=new Map,m=new Map,_=[],v=(e,t)=>new Promise(n=>{let r=new Image;r.crossOrigin=`anonymous`,r.onload=()=>{f.set(e,r),n()},r.onerror=()=>n(),r.src=t}),y=(e,t)=>new Promise(n=>{let r=document.createElement(`video`);r.crossOrigin=`anonymous`,r.muted=!0,r.playsInline=!0,r.preload=`auto`;let i=!1,a=()=>{i||(i=!0,p.set(e,r),n())};r.oncanplay=()=>{i||(r.currentTime=.001)},r.onseeked=()=>a(),r.onerror=()=>{console.warn(`Failed to load video:`,t),a()},setTimeout(()=>a(),5e3),r.src=t,r.load()}),x=(e,t)=>new Promise(n=>{let r=document.createElement(`audio`);r.crossOrigin=`anonymous`,r.onloadedmetadata=()=>{m.set(e,r),n()},r.onerror=()=>n(),r.src=t});if(b.forEach(e=>{e.type===`video`?_.push(y(e.id,e.url)):e.type===`audio`?_.push(x(e.id,e.url)):_.push(v(e.id,e.url))}),G.showChannelInfo&&(G.channelInfoImage&&_.push(v(`__channel_info__`,G.channelInfoImage)),G.channelInfoText)){let e=G.channelInfoText.trim();if(//i.test(e))try{let t=document.createElement(`div`);t.style.position=`absolute`,t.style.visibility=`hidden`,t.style.whiteSpace=`nowrap`,t.style.fontFamily=`sans-serif`,t.style.fontWeight=`bold`,t.style.fontSize=`100px`,t.style.display=`inline-flex`,t.style.alignItems=`center`,t.style.gap=`0.25em`,t.innerHTML=e;let n=t.getElementsByTagName(`svg`);for(let e=0;e + +
+ + ${e} +
+
+ + `,o=`data:image/svg+xml;base64,${window.btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))}))}`;_.push(v(`__channel_info_text_svg__`,o))}catch(e){console.warn(`Failed to process SVG channel info`,e)}}if(G.backgroundSource===`image`&&G.backgroundImage&&_.push(v(`__custom_bg__`,G.backgroundImage)),G.backgroundSource===`video`&&G.backgroundVideo&&_.push(y(`__custom_bg_video__`,G.backgroundVideo)),G.showFloatingNotes&&G.floatingNotesMedia&&(G.floatingNotesMediaType===`video`?_.push(y(`__floating_notes_media__`,G.floatingNotesMedia)):_.push(v(`__floating_notes_media__`,G.floatingNotesMedia))),await Promise.all(_),c.aborted){me(!1),r&&i.forEach(e=>e.isFileSource&&URL.revokeObjectURL(e.audioSrc));return}let S=a.current,C=S.getContext(`2d`),w=S.captureStream(Ue),T=null;try{if(l.captureStream)T=l.captureStream();else if(l.mozCaptureStream)T=l.mozCaptureStream();else throw Error(`Audio capture not supported`)}catch{e.error(`Your browser does not support audio capture for recording.`),me(!1);return}hm();let E=cm();E.state===`suspended`&&await E.resume();let D=E.createMediaStreamDestination(),k=lm(l,E);k.disconnect(),k.connect(D);let A=null,j=null,M=null;G.showVisualization&&(A=E.createAnalyser(),A.fftSize=512,A.smoothingTimeConstant=.8,k.connect(A),j=new Uint8Array(A.frequencyBinCount),M=new Uint8Array(A.frequencyBinCount)),p.forEach(e=>{e.muted=!0;let t=lm(e,E);t.disconnect(),t.connect(D)});let N=new Map;m.forEach((e,t)=>{e.muted=!1;let n=lm(e,E);n.disconnect();let r=E.createGain();r.gain.value=0,n.connect(r),r.connect(D),N.set(t,r)}),D.stream.getAudioTracks().length>0?w.addTrack(D.stream.getAudioTracks()[0]):T&&w.addTrack(T.getAudioTracks()[0]);let ee=(()=>{if(Be!==`auto`&&MediaRecorder.isTypeSupported(Be))return Be;for(let e of[`video/webm; codecs=vp9,opus`,`video/webm; codecs=vp9`,`video/webm; codecs=av1`,`video/mp4; codecs="av01.0.05M.08"`,`video/mp4; codecs="avc1.4D401E, mp4a.40.2"`,`video/mp4; codecs="avc1.64001E, mp4a.40.2"`,`video/mp4`,`video/webm`])if(MediaRecorder.isTypeSupported(e))return e;return`video/webm`})(),P=Te===`1080p`?8e6:4e6,F=Ue>30?1.5:1,I=Ye===`high`?2:Ye===`low`?.5:1,te=P*F*I,L=new MediaRecorder(w,{mimeType:ee,videoBitsPerSecond:te});o.current=L;let ne=[];L.ondataavailable=e=>{e.data.size>0&&ne.push(e.data)},L.onstop=()=>{if(c.aborted)console.log(`Render aborted`);else{let e=new Blob(ne,{type:ee});ee.includes(`webm`),(e=>{let t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t;let a=ee.includes(`mp4`)?`mp4`:`webm`;n.download=r?`Playlist_${i.length}_Songs_${be.replace(`:`,`-`)}.${a}`:`${i[0].metadata.title||`video`}_${be.replace(`:`,`-`)}.${a}`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)})(e)}E.close(),me(!1),h(e=>e+1),r&&i.forEach(e=>e.isFileSource&&URL.revokeObjectURL(e.audioSrc))};let R=0,z=[],B=g,re=0,ie=0,ae=1e3/Ue,oe=e=>{if(c.aborted)return;(L.state===`recording`||L.state===`paused`)&&requestAnimationFrame(oe);let t=e-ie;if(t0){let e=n/re;ve(r?(R+e)/i.length*100:e*100)}p.forEach((e,t)=>{if(t===`background`||t===`__custom_bg_video__`||t===`__floating_notes_media__`){let t=e.duration||1,r=n%t,i=Math.abs(e.currentTime-r);(rt/2||i>.5)&&(e.currentTime=r),e.paused&&e.play().catch(()=>{})}else{let r=b.find(e=>e.id===t);if(r)if(n>=r.startTime&&n0&&i>=a&&(i%=a),Math.abs(e.playbackRate-t)>.01&&(e.playbackRate=t),Math.abs(e.currentTime-i)>.5&&(e.currentTime=i);let o=r.isMuted!==!1;e.muted!==o&&(e.muted=o),e.paused&&e.play().catch(()=>{})}else e.paused||e.pause(),e.muted||=!0}}),m.forEach((e,t)=>{let r=b.find(e=>e.id===t),i=N.get(t);if(r&&i){let t=r.layer||0;if(G.layerVisibility?.audio?.[t]!==!1&&n>=r.startTime&&n.01&&(e.playbackRate=t),Math.abs(e.currentTime-a)>.5&&(e.currentTime=a);let o=r.volume===void 0?1:r.volume;Math.abs(i.gain.value-o)>.01&&(i.gain.value=o),e.paused&&e.play().catch(()=>{})}else e.paused||e.pause(),i.gain.value!==0&&(i.gain.value=0)}}),C&&(A&&j&&M&&(A.getByteFrequencyData(j),A.getByteTimeDomainData(M)),Mw(C,S.width,S.height,n,z,B,b,f,p,d,Me,G.fontSizeScale,G.backgroundBlurStrength>0,re,G,G.renderMode===`current`||R===i.length-1,G.renderMode===`current`||R===0,j,M))},se=async()=>{if(c.aborted){L.stop();return}if(R>=i.length){await new Promise(e=>setTimeout(e,500)),L.stop();return}let e=i[R];L.state===`recording`&&L.pause(),z=e.lyrics,B=e.metadata,re=0,r&&jt(R),e.metadata.coverUrl&&(e.metadata.backgroundType===`video`?await y(`background`,e.metadata.coverUrl):await v(`cover`,e.metadata.coverUrl)),l.pause(),l.src=e.audioSrc,l.load(),await new Promise(e=>{let t=()=>{l.removeEventListener(`canplay`,t),e()};l.addEventListener(`canplay`,t),l.readyState>=3&&t()}),re=l.duration,L.state===`inactive`?(E.state===`suspended`&&await E.resume(),L.start(),requestAnimationFrame(oe)):L.state===`paused`&&L.resume(),await l.play(),await new Promise(e=>{let t=()=>{l.removeEventListener(`ended`,t),e()};l.addEventListener(`ended`,t)}),R++,await se()};if(console.log(`[Render] Queue prepared with ${i.length} items.`),i.length===0){e.error(`Render queue is empty!`),me(!1);return}R=0,await se()},Mn=async()=>{if(!a.current)return;let n=G.renderMode===`playlist`&&Dt.length>0;console.log(`[FFmpeg Render] Mode: ${G.renderMode}, Playlist: ${Dt.length}, IsPlaylist: ${n}`);let r=null,i=Ut,o=g;if(n&&Dt.length>0)r=Dt[0].audioFile,i=Dt[0].parsedLyrics||[],o=Dt[0].metadata;else if(Dt.length>0&&At>=0)r=Dt[At].audioFile;else if(f)r=f;else if(u)try{r=await(await fetch(u)).blob()}catch(t){console.error(`FFmpeg: Failed to fetch audio blob`,t),e.error(`Failed to load audio source for rendering.`);return}else{e.error(`Please load an audio file first.`);return}if(!r){e.error(`No audio file available for FFmpeg export.`);return}if(!Zw()){e.error(`FFmpeg requires SharedArrayBuffer. Please ensure proper server headers (COOP/COEP) or use MediaRecorder instead.`);return}if(!await t(`Start FFmpeg rendering at ${Te} (${be})? This uses frame-by-frame capture for higher quality. Rendering may take several minutes.`,`Start FFmpeg Rendering?`))return;ot(!1),me(!0),ve(0),it(`Initializing...`);let c={aborted:!1};s.current=c,xn();let l=a.current,{w:d,h:p}=Pt();l.width=d,l.height=p;let m=new Map,h=new Map,_=[],v=(e,t)=>new Promise(n=>{let r=new Image;r.crossOrigin=`anonymous`,r.onload=()=>{m.set(e,r),n()},r.onerror=()=>n(),r.src=t}),y=(e,t)=>new Promise(n=>{let r=document.createElement(`video`);r.crossOrigin=`anonymous`,r.muted=!0,r.playsInline=!0,r.preload=`auto`;let i=!1,a=()=>{i||(i=!0,h.set(e,r),n())};r.oncanplay=()=>{i||(r.currentTime=.001)},r.onseeked=()=>a(),r.onerror=()=>{console.warn(`Failed to load video:`,t),a()},setTimeout(()=>a(),5e3),r.src=t,r.load()});if(b.forEach(e=>{e.type===`video`?_.push(y(e.id,e.url)):e.type!==`audio`&&_.push(v(e.id,e.url))}),o.coverUrl&&(o.backgroundType===`video`?_.push(y(`background`,o.coverUrl)):_.push(v(`cover`,o.coverUrl))),G.backgroundSource===`image`&&G.backgroundImage&&_.push(v(`__custom_bg__`,G.backgroundImage)),G.backgroundSource===`video`&&G.backgroundVideo&&(Gn.current&&Gn.current.currentSrc&&!Gn.current.error?(h.set(`__custom_bg_video__`,Gn.current),console.log(`WebCodecs: Re-using existing background video element`)):_.push(y(`__custom_bg_video__`,G.backgroundVideo))),G.backgroundSource===`video`&&G.backgroundVideo&&(Gn.current&&Gn.current.currentSrc&&!Gn.current.error?(h.set(`__custom_bg_video__`,Gn.current),console.log(`FFmpeg: Re-using existing background video element`)):_.push(y(`__custom_bg_video__`,G.backgroundVideo))),G.showChannelInfo&&G.channelInfoImage&&_.push(v(`__channel_info__`,G.channelInfoImage)),G.showFloatingNotes&&G.floatingNotesMedia&&(G.floatingNotesMediaType===`video`?_.push(y(`__floating_notes_media__`,G.floatingNotesMedia)):_.push(v(`__floating_notes_media__`,G.floatingNotesMedia))),await Promise.all(_),c.aborted){me(!1);return}try{if(n){let t=[];for(let e of Dt){let n=[];if(e.parsedLyrics&&e.parsedLyrics.length>0)n=e.parsedLyrics;else if(e.lyricFile)try{let t=await e.lyricFile.text(),r=e.lyricFile.name.split(`.`).pop()?.toLowerCase();r===`lrc`?n=vt(t):r===`srt`?n=yt(t):r===`ttml`||r===`xml`?n=bt(t):r===`vtt`&&(n=St(t))}catch(e){console.error(`FFmpeg: Failed to parse lyrics for playlist item`,e)}t.push({audioFile:e.audioFile,lyrics:n,metadata:e.metadata})}let n=await eT(t,{canvas:l,visualSlides:b,imageMap:m,videoMap:h,preset:De,customFontName:Me,renderConfig:G,resolution:Te,aspectRatio:be,fps:Ue,quality:Ye,codec:tt,onProgress:(e,t)=>{},onLog:e=>console.log(e),abortSignal:c},(e,t,n,r)=>{ve((e+n/100)/t*100),it(`Song ${e+1}/${t}: ${r}`)}),r=`Playlist_${t.length}_Songs_${be.replace(`:`,`-`)}_ffmpeg.${n.format}`,i=URL.createObjectURL(n.blob),a=document.createElement(`a`);a.href=i,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),e.success(`Playlist exported successfully! (${n.format.toUpperCase()}, ${Math.round(n.duration)}s)`)}else{let t=await $w({canvas:l,audioFile:r,lyrics:i,metadata:o,visualSlides:b,imageMap:m,videoMap:h,preset:De,customFontName:Me,renderConfig:G,resolution:Te,aspectRatio:be,fps:Ue,quality:Ye,codec:tt,onProgress:(e,t)=>{ve(e),it(t)},onLog:e=>console.log(e),abortSignal:c,isFirstSong:!0,isLastSong:!0}),n=`${o.title||`video`}_${be.replace(`:`,`-`)}_ffmpeg.${t.format}`,a=URL.createObjectURL(t.blob),s=document.createElement(`a`);s.href=a,s.download=n,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a),e.success(`Video exported successfully! (${t.format.toUpperCase()}, ${Math.round(t.duration)}s)`)}}catch(t){t.message!==`Render aborted`&&(console.error(`FFmpeg render failed:`,t),e.error(`FFmpeg render failed: ${t.message}`))}finally{me(!1),it(``)}},Nn=async()=>{if(!a.current)return;let n=G.renderMode===`playlist`&&Dt.length>0,r=null,i=Ut,o=g;if(n&&Dt.length>0)r=Dt[0].audioFile,i=Dt[0].parsedLyrics||[],o=Dt[0].metadata;else if(Dt.length>0&&At>=0)r=Dt[At].audioFile;else if(f)r=f;else if(u)try{r=await(await fetch(u)).blob()}catch(t){console.error(`WebCodecs: Failed to fetch audio blob`,t),e.error(`Failed to load audio source for rendering.`);return}else{e.error(`Please load an audio file first.`);return}if(!r){e.error(`No audio file available for export.`);return}if(!YD()){e.error(`WebCodecs is not supported in this browser.`);return}let{w:c,h:l}=Pt();if(!await t(`Start WebCodecs rendering at ${Te} @ ${Ue}fps?\nResolution: ${c}x${l}\n\nThis uses hardware acceleration and is very fast.`,`Start WebCodecs Rendering?`))return;ot(!1),me(!0),ve(0),it(`Initializing WebCodecs...`);let d={aborted:!1};s.current=d,xn();let p=a.current;p.width=c,p.height=l;let m=new Map,h=new Map,_=[],v=(e,t)=>new Promise(n=>{let r=new Image;r.crossOrigin=`anonymous`,r.onload=()=>{m.set(e,r),n()},r.onerror=()=>n(),r.src=t}),y=(e,t)=>new Promise(n=>{let r=document.createElement(`video`);r.crossOrigin=`anonymous`,r.muted=!0,r.playsInline=!0,r.preload=`auto`;let i=!1,a=()=>{i||(i=!0,h.set(e,r),n())};r.oncanplay=()=>{i||(r.currentTime=.001)},r.onseeked=()=>a(),r.onerror=()=>{console.warn(`Failed to load video:`,t),a()},setTimeout(()=>a(),5e3),r.src=t,r.load()});if(b.forEach(e=>{e.type===`video`?_.push(y(e.id,e.url)):e.type!==`audio`&&_.push(v(e.id,e.url))}),o.coverUrl&&(o.backgroundType===`video`?_.push(y(`background`,o.coverUrl)):_.push(v(`cover`,o.coverUrl))),G.backgroundSource===`image`&&G.backgroundImage&&_.push(v(`__custom_bg__`,G.backgroundImage)),G.backgroundSource===`video`&&G.backgroundVideo&&(Gn.current&&Gn.current.currentSrc&&!Gn.current.error?(h.set(`__custom_bg_video__`,Gn.current),console.log(`WebCodecs: Re-using existing background video element`)):_.push(y(`__custom_bg_video__`,G.backgroundVideo))),G.showChannelInfo&&G.channelInfoImage&&_.push(v(`__channel_info__`,G.channelInfoImage)),G.showFloatingNotes&&G.floatingNotesMedia&&(G.floatingNotesMediaType===`video`?_.push(y(`__floating_notes_media__`,G.floatingNotesMedia)):_.push(v(`__floating_notes_media__`,G.floatingNotesMedia))),await Promise.all(_),d.aborted){me(!1);return}try{if(n){let t=[];for(let e of Dt){let n=[];if(e.parsedLyrics&&e.parsedLyrics.length>0)n=e.parsedLyrics;else if(e.lyricFile)try{let t=await e.lyricFile.text(),r=e.lyricFile.name.split(`.`).pop()?.toLowerCase();r===`lrc`?n=vt(t):r===`srt`?n=yt(t):r===`ttml`||r===`xml`?n=bt(t):r===`vtt`&&(n=St(t))}catch(e){console.error(`WebCodecs: Failed to parse lyrics for playlist item`,e)}t.push({audioFile:e.audioFile,lyrics:n,metadata:e.metadata})}let n=await rO(t,{canvas:p,visualSlides:b,imageMap:m,videoMap:h,preset:De,customFontName:Me,renderConfig:G,resolution:Te,aspectRatio:be,fps:Ue,quality:Ye,onProgress:(e,t)=>{ve(e),it(t)},onLog:e=>console.log(e),abortSignal:d}),r=`Playlist_${t.length}_Songs_${be.replace(`:`,`-`)}_webcodecs.${n.format}`,i=URL.createObjectURL(n.blob),a=document.createElement(`a`);a.href=i,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),e.success(`Playlist exported successfully! (${n.format.toUpperCase()}, ${Math.round(n.duration)}s)`)}else{let t=await nO({canvas:p,audioFile:r,lyrics:i,metadata:o,visualSlides:b,imageMap:m,videoMap:h,preset:De,customFontName:Me,renderConfig:G,resolution:Te,aspectRatio:be,fps:Ue,quality:Ye,onProgress:(e,t)=>{ve(e),it(t)},abortSignal:d,isFirstSong:!0,isLastSong:!0}),n=`${o.title||`video`}_${be.replace(`:`,`-`)}_webcodecs.${t.format}`,a=URL.createObjectURL(t.blob),s=document.createElement(`a`);s.href=a,s.download=n,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(a),e.success(`Video exported successfully! (${Math.round(t.duration)}s)`)}}catch(t){t.message!==`Render aborted`&&(console.error(`WebCodecs render failed:`,t),e.error(`Render failed: ${t.message}`))}finally{me(!1),it(``)}},Pn=async()=>{Qe===`ffmpeg`?await Mn():Qe===`webcodecs`?await Nn():await jn()};(0,w.useEffect)(()=>{l.current=Pn});let Fn=(0,w.useCallback)(()=>{s.current&&(s.current.aborted=!0),o.current&&o.current.state===`recording`?o.current.stop():me(!1),xn()},[xn]),In=(0,w.useCallback)(()=>{if(!G.lyricDisplayMode?.startsWith(`static-`)&&i.current){let e=n.current?.currentTime||0;if(Gt===-1&&e<2){i.current.scrollTo({top:0,behavior:`smooth`});return}if(Gt!==-1){let e=i.current.querySelector(`[data-lyric-active="true"]`);if(e){let t=i.current;if(e.offsetHeight===0)return;let n=e.offsetTop,r=e.offsetHeight,a=t.clientHeight,o=.5;G.contentPosition===`top`&&(o=.25),G.contentPosition===`bottom`&&(o=.75);let s=n-a*o+r/2;t.scrollTo({top:s,behavior:`smooth`})}}}},[Gt,De,G.contentPosition,G.marginTopScale,G.marginBottomScale,G.lyricDisplayMode]);(0,w.useEffect)(()=>{In()},[In]),(0,w.useEffect)(()=>{let e=setTimeout(()=>{In()},550);return()=>clearTimeout(e)},[se,le,Rt,Bt,L,Mt,In]);let Ln=(0,w.useRef)(null),Rn=(0,w.useCallback)(()=>{ce(!1),Ln.current&&clearTimeout(Ln.current),V||(Ln.current=window.setTimeout(()=>{ce(!0)},3e3))},[V]),zn=()=>{Rn()},Bn=(0,w.useRef)(0),Vn=e=>{Rn();let t=Date.now();if(t-Bn.current<300){if(e.target.closest(`.no-minimal-mode-toggle`))return;wn(e)}Bn.current=t};(0,w.useEffect)(()=>{let t=t=>{let r=t.key.toLowerCase();if(` .s.v.n.b.t.p.l.r.f.h.g.m.j.d.e.c.x.z.q.arrowleft.arrowright.arrowup.arrowdown.meta.control.shift.alt.printscreen.fn.+.-.=.8.9.0`.split(`.`).includes(r)||Rn(),!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)&&!((t.ctrlKey||t.metaKey||t.altKey)&&!(r===`e`&&t.shiftKey))){if(V){r===`escape`&&Fn();return}switch(t.key.toLowerCase()){case` `:t.preventDefault(),bn(),e.success(T?`Paused`:`Playing`,{id:`play-pause`});break;case`s`:case`v`:t.preventDefault(),xn(),e.success(`Stopped`,{id:`stop`});break;case`n`:t.preventDefault(),vn(),e.success(`Next Song`,{id:`next-song`});break;case`o`:t.preventDefault();let r=!Ht;q(r),r&&ue(!0),e.success(`Minimal Mode: ${r?`On`:`Off`}`,{id:`minimal-mode`});break;case`b`:t.preventDefault(),yn(),e.success(`Previous Song`,{id:`prev-song`});break;case`r`:t.preventDefault(),Sn();let a=D===`off`?`one`:D===`one`?`all`:D===`all`?`all_repeat`:`off`;e.success(`Repeat: ${{off:`Repeat Off`,one:`Loop One`,all:`Play All (Stop)`,all_repeat:`Loop Playlist`}[a]}`,{id:`repeat`});break;case`p`:t.preventDefault();let o=!Mt;Nt(o),o&&ne(Ze.PLAYER);break;case`h`:t.preventDefault();let s=!le;ue(s),e.success(s?`HUD: Always Visible`:`HUD: Auto-Hide`,{id:`hud-mode`});break;case`k`:t.preventDefault(),ct(e=>!e);break;case`g`:t.preventDefault();let c=Ep.flatMap(e=>e.options.map(e=>e.value)),u=xt.current.lyricDisplayMode,d=c[(c.indexOf(u)+1)%c.length];gt(e=>({...e,lyricDisplayMode:d})),e.success(`Lyric Mode: ${d.replace(`-`,` `)}`,{id:`lyric-mode`});break;case`c`:t.preventDefault();let f=Dp,p=xt.current.textCase,m=f[(f.indexOf(p)+1)%f.length];gt(e=>({...e,textCase:m})),e.success(`Text Case: ${m}`,{id:`text-case`});break;case`f`:Cn();break;case`i`:zt(e=>!e);break;case`y`:Vt(e=>!e);break;case`l`:t.preventDefault(),gt(iO(xt.current)),ke(`custom`),e.success(`🎲 Random settings generated!`,{id:`random-settings`});break;case`d`:t.preventDefault(),ot(e=>!e);break;case`t`:Mt?(Nt(!1),ne(Ze.EDITOR)):ne(e=>e===Ze.PLAYER?Ze.EDITOR:Ze.PLAYER);break;case`m`:t.preventDefault();let h=!I;te(h),e.success(h?`Muted`:`Unmuted`,{id:`mute`});break;case`x`:t.preventDefault();let g=xt.current.highlightEffect===`none`;gt(e=>({...e,highlightEffect:e.highlightEffect===`none`?`karaoke`:`none`})),e.success(`Highlight: ${g?`On (Karaoke)`:`Off`}`,{id:`highlight-toggle`});break;case`z`:t.preventDefault();let _=Sp.flatMap(e=>e.options.map(e=>e.value)),v=xt.current.highlightEffect||`none`,y=_.indexOf(v),b=_[((y===-1?0:y)+1)%_.length],x=Cp(b);gt(e=>{let t={...e,highlightEffect:b};return t.useCustomHighlightColors=!1,x&&(t.highlightColor=x.color,t.highlightBackground=x.bg),t}),e.success(`Effect: ${b.replace(/-/g,` `)}`,{id:`highlight-effect`});break;case`j`:t.preventDefault();let S=lp[(lp.indexOf(De)+1)%lp.length];ke(S);let C=cp[S];if(C){let e={fontFamily:`ui-sans-serif, system-ui, sans-serif`,fontSizeScale:1,fontColor:`#ffffff`,fontWeight:`bold`,fontStyle:`normal`,textCase:`none`,textAlign:`center`,contentPosition:`center`,textDecoration:`none`,textEffect:`preset`,textAnimation:`none`,highlightEffect:`karaoke`,highlightColor:`#fb923c`,highlightBackground:`#fb923c`,useCustomHighlightColors:!1,lyricStyleTarget:`active-only`,transitionEffect:`none`};gt(t=>({...t,...e,...C}))}let w=S;for(let e of sp){let t=e.options.find(e=>e.value===S);if(t){w=t.label;break}}e.success(`Preset: ${w}`,{id:`preset`});break;case`arrowleft`:if(t.preventDefault(),n.current){let e=Math.max(0,n.current.currentTime-5);n.current.currentTime=e,A(e)}break;case`arrowright`:if(t.preventDefault(),n.current){let e=Math.min(j,n.current.currentTime+5);n.current.currentTime=e,A(e)}break;case`arrowup`:t.preventDefault(),i.current&&i.current.scrollBy({top:-100,behavior:`smooth`});break;case`arrowdown`:t.preventDefault(),i.current&&i.current.scrollBy({top:100,behavior:`smooth`});break;case`+`:case`=`:if(t.ctrlKey||t.metaKey||t.altKey)break;t.preventDefault();let E=xt.current.fontSizeScale,O=Math.min(E+.1,3);gt(e=>({...e,fontSizeScale:O})),e.success(`Font Size: ${(O*100).toFixed(0)}%`,{id:`font-size`});break;case`-`:if(t.ctrlKey||t.metaKey||t.altKey)break;t.preventDefault();let k=xt.current.fontSizeScale,M=Math.max(k-.1,.1);gt(e=>({...e,fontSizeScale:M})),e.success(`Font Size: ${(M*100).toFixed(0)}%`,{id:`font-size`});break;case`e`:(t.ctrlKey||t.metaKey)&&t.shiftKey&&(t.preventDefault(),l.current());break;case`1`:if(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)break;t.preventDefault(),document.getElementById(`audio-file`)?.click();break;case`2`:if(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)break;t.preventDefault(),document.getElementById(`lyrics-file`)?.click();break;case`3`:if(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)break;t.preventDefault(),document.getElementById(`font-file`)?.click();break;case`8`:if(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)break;t.preventDefault(),ut(t=>{let n=Math.max(.5,Math.round((t-.05)*100)/100);return e.success(`UI Scale: ${Math.round(n*100)}%`,{id:`ui-scale`}),n});break;case`9`:if(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)break;t.preventDefault(),ut(t=>{let n=Math.min(2,Math.round((t+.05)*100)/100);return e.success(`UI Scale: ${Math.round(n*100)}%`,{id:`ui-scale`}),n});break;case`0`:if(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)break;t.preventDefault(),ut(1),e.success(`UI Scale: 100%`,{id:`ui-scale`});break;case`q`:t.preventDefault(),gt(t=>{let n=!t.showLyrics;return e.success(`Lyrics: ${n?`Visible`:`Hidden`}`,{id:`lyrics-visibility`}),{...t,showLyrics:n}});break}}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,D,L,V,Rn,Fn,Mt,vn,yn,e,Ht,De,le,I]),(0,w.useEffect)(()=>{let e,t=0,r=1e3/30,i=a=>{if(n.current&&!n.current.paused&&T){e=requestAnimationFrame(i);let o=a-t;o>r&&(t=a-o%r,A(n.current.currentTime))}};return T&&!V&&(e=requestAnimationFrame(i)),()=>{e&&cancelAnimationFrame(e)}},[T,V]);let Hn=Rt&&(!se||le)&&!V,Un=Bt&&(!se||le)&&!V&&!Ht,Wn=J.length>0?J[0]:null;Wn?`${Wn.url}`:g.coverUrl&&`${g.coverUrl}`;let Gn=(0,w.useRef)(null);return(0,w.useEffect)(()=>{if(J.forEach(e=>{let t=e.layer||0;if(G.layerVisibility?.visual?.[t]!==!1&&e.type===`video`){let t=document.getElementById(`video-preview-${e.id}`);if(t)if(V)t.paused||t.pause();else{let n=e.playbackRate||1,r=(k-e.startTime)*n+(e.mediaStartOffset||0),i=e.mediaDuration||t.duration;i&&i>0&&r>=i&&(r%=i),Math.abs(t.playbackRate-n)>.01&&(t.playbackRate=n),Math.abs(t.currentTime-r)>.2&&(t.currentTime=r);let a=e.isMuted!==!1;t.muted!==a&&(t.muted=a);let o=e.volume===void 0?1:e.volume;Math.abs(t.volume-o)>.01&&(t.volume=o),T&&t.paused?t.play().catch(()=>{}):!T&&!t.paused&&t.pause()}}}),(g.backgroundType===`video`||G.backgroundSource===`video`)&&Gn.current){let e=Gn.current;if(V)e.paused||e.pause();else{let t=k%(e.duration||1);Math.abs(e.currentTime-t)>.1&&(e.currentTime=t),T&&e.paused?e.play().catch(()=>{}):!T&&!e.paused&&e.pause()}}Y.forEach(e=>{let t=document.getElementById(`audio-preview-${e.id}`);if(t){let n=e.playbackRate||1,r=(k-e.startTime)*n+(e.mediaStartOffset||0);Math.abs(t.playbackRate-n)>.01&&(t.playbackRate=n),Math.abs(t.currentTime-r)>.2&&(t.currentTime=r);let i=e.isMuted===!0;t.muted!==i&&(t.muted=i);let a=e.volume===void 0?1:e.volume;Math.abs(t.volume-a)>.01&&(t.volume=a),T&&t.paused?t.play().catch(()=>{}):!T&&!t.paused&&t.pause()}})},[k,T,J,g,Y,G.layerVisibility]),(0,K.jsxs)(`div`,{ref:r,onMouseMove:zn,onTouchStart:Vn,onDoubleClick:wn,onDragEnter:dn,onDragLeave:fn,onDragOver:pn,onDrop:mn,className:`relative bg-black overflow-hidden flex font-sans select-none ${se&&!le?`cursor-none`:``}`,style:{width:`${100/lt}vw`,height:`${100/lt}dvh`,transform:`scale(${lt})`,transformOrigin:`top left`},children:[ft&&(0,K.jsx)(`div`,{className:`absolute inset-0 z-[100] bg-black/80 backdrop-blur-md flex items-center justify-center p-8 transition-all duration-300 pointer-events-none`,children:(0,K.jsxs)(`div`,{className:`border-2 border-dashed border-purple-500/50 bg-zinc-950/40 backdrop-blur-xl rounded-3xl p-10 max-w-2xl w-full flex flex-col items-center text-center space-y-8 animate-pulse shadow-[0_0_50px_rgba(168,85,247,0.15)] pointer-events-none`,children:[(0,K.jsx)(`div`,{className:`p-5 bg-purple-500/10 rounded-full text-purple-400 ring-4 ring-purple-500/5 animate-bounce`,children:(0,K.jsx)(He,{size:48})}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`h2`,{className:`text-3xl font-extrabold text-white tracking-tight`,children:`Drop files to load`}),(0,K.jsx)(`p`,{className:`text-zinc-400 max-w-md text-sm leading-relaxed`,children:`Release your files anywhere to instantly import them into the player and maker workspace.`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-6 w-full pt-4 border-t border-white/5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col items-center space-y-2 p-4 bg-white/5 rounded-2xl border border-white/5`,children:[(0,K.jsx)(`div`,{className:`text-purple-400 bg-purple-500/10 p-3 rounded-xl`,children:(0,K.jsx)(ge,{size:24})}),(0,K.jsx)(`span`,{className:`text-xs font-bold text-zinc-200`,children:`Audio / Video`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`MP3, WAV, FLAC, MP4...`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center space-y-2 p-4 bg-white/5 rounded-2xl border border-white/5`,children:[(0,K.jsx)(`div`,{className:`text-emerald-400 bg-emerald-500/10 p-3 rounded-xl`,children:(0,K.jsx)(ae,{size:24})}),(0,K.jsx)(`span`,{className:`text-xs font-bold text-zinc-200`,children:`Lyrics / Subtitles`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`LRC, SRT, VTT, TTML...`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center space-y-2 p-4 bg-white/5 rounded-2xl border border-white/5`,children:[(0,K.jsx)(`div`,{className:`text-pink-400 bg-pink-500/10 p-3 rounded-xl`,children:(0,K.jsx)(ze,{size:24})}),(0,K.jsx)(`span`,{className:`text-xs font-bold text-zinc-200`,children:`Custom Font`}),(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:`TTF, OTF, WOFF, WOFF2...`})]})]})]})}),(0,K.jsx)(`audio`,{ref:n,src:u||void 0,loop:D===`one`,muted:I,onTimeUpdate:Tn,onLoadedMetadata:En,onEnded:()=>{if(V)return;let e=Dt.length>0;D===`one`||(D===`all_repeat`?e?vn():n.current?.play():D===`all`&&e&&At(0,K.jsx)(`audio`,{id:`audio-preview-${e.id}`,src:e.url,className:`hidden`,playsInline:!0},e.id)),(0,K.jsx)(`canvas`,{ref:a,width:Ft,height:It,className:`absolute top-0 left-0 hidden pointer-events-none opacity-0`}),(0,K.jsxs)(`div`,{className:`absolute inset-0 bg-black overflow-hidden pointer-events-none`,children:[(G.backgroundSource===`color`||G.backgroundSource===`threejs`)&&(0,K.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundColor:G.backgroundSource===`threejs`?G.threejsBgColor||`#000000`:G.backgroundColor}}),G.backgroundSource===`gradient`&&(0,K.jsx)(`div`,{className:`absolute inset-0`,style:{background:G.backgroundGradient}}),G.backgroundSource===`image`&&G.backgroundImage&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url(${G.backgroundImage})`}}),G.backgroundSource===`video`&&G.backgroundVideo&&(0,K.jsx)(`video`,{ref:Gn,src:G.backgroundVideo,className:`absolute inset-0 w-full h-full object-cover`,muted:!0,loop:!0,playsInline:!0}),G.backgroundSource===`smart-gradient`&&(0,K.jsx)(`div`,{className:`absolute inset-0`,style:{background:(()=>{let e=G.backgroundColor||`#312e81`,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return`linear-gradient(to bottom right, rgb(${`${t},${n},${r}`}), rgb(${`${Math.floor(t*.6)},${Math.floor(n*.6)},${Math.floor(r*.6)}`}) 50%, #000000)`})()}}),(G.backgroundSource===`timeline`&&b.length===0||G.backgroundSource===`custom`)&&g.coverUrl&&(g.backgroundType===`video`?(0,K.jsx)(`video`,{ref:Gn,src:g.coverUrl,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 ${de?`opacity-60`:`opacity-0`}`,muted:!0,loop:!V,playsInline:!0,preload:`auto`,onLoadedData:()=>fe(!0)}):(0,K.jsx)(`div`,{className:`absolute inset-0 bg-cover bg-center transition-all duration-700 ease-in-out ${G.backgroundSource===`custom`||J.length===0?`opacity-60`:`opacity-0`}`,style:{backgroundImage:`url(${g.coverUrl})`}})),(G.backgroundSource===`color`||G.backgroundSource===`threejs`)&&(0,K.jsx)(`div`,{className:`absolute inset-0 transition-all duration-500`,style:{backgroundColor:G.backgroundSource===`threejs`?G.threejsBgColor||`#000000`:G.backgroundColor}}),G.backgroundSource===`gradient`&&(0,K.jsx)(`div`,{className:`absolute inset-0 transition-all duration-500`,style:{background:G.backgroundGradient}}),G.backgroundSource===`smart-gradient`&&(0,K.jsx)(`div`,{className:`absolute inset-0 transition-all duration-500`,style:{background:(()=>{let e=G.backgroundColor||`#312e81`,t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return`linear-gradient(to bottom right, rgb(${`${t},${n},${r}`}), rgb(${`${Math.floor(t*.6)},${Math.floor(n*.6)},${Math.floor(r*.6)}`}) 50%, #000000)`})()}}),!g.coverUrl&&(G.backgroundSource===`timeline`&&b.length===0||G.backgroundSource===`custom`)&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br from-indigo-900 via-purple-900 to-black opacity-80`}),G.backgroundSource===`threejs`&&!V&&(0,K.jsx)(yw,{isPlaying:T,currentTime:k,config:G}),(0,K.jsx)(`div`,{className:`absolute inset-0 pointer-events-none ${G.backgroundSource===`timeline`?`opacity-100`:`opacity-0`}`,children:G.backgroundSource===`timeline`&&J.map(e=>{let t=e.layer||0;if(G.layerVisibility?.visual?.[t]===!1)return null;let n=G.visualTransitionType||`none`,r=G.visualTransitionDuration||1,i=1;if(n!==`none`){if(k=e.endTime){let t=!1;if(n===`crossfade`&&(t=b.some(t=>t.id!==e.id&&(t.layer||0)===(e.layer||0)&&t.startTime>=e.endTime-.1&&t.startTimee.endTime-r){let t=(e.endTime-k)/r;i=Math.min(i,Math.max(0,Math.min(1,t)))}}return(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center overflow-hidden`,style:{opacity:i},children:e.type===`video`?(0,K.jsx)(`video`,{id:`video-preview-${e.id}`,src:e.url,className:`w-full h-full object-cover`,muted:e.isMuted!==!1,playsInline:!0}):(0,K.jsx)(`div`,{className:`w-full h-full bg-cover bg-center`,style:{backgroundImage:`url(${e.url})`}})},e.id)})}),(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/30 transition-all duration-700`,style:{backdropFilter:G.backgroundBlurStrength>0?`blur(${G.backgroundBlurStrength}px)`:Tt?`blur(12px)`:`none`,backgroundColor:G.useRealColorMedia?`transparent`:G.backgroundBlurStrength>0||Tt?`rgba(0,0,0,0.4)`:void 0}}),G.enableGradientOverlay&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/95 via-black/60 to-transparent pointer-events-none z-0`}),!V&&(0,K.jsx)(gm,{audioElement:n.current,config:G,isPlaying:T})]}),(0,K.jsxs)(`div`,{className:`relative z-10 flex-1 flex flex-col transition-all duration-500 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden flex flex-col`,children:[G.showChannelInfo&&Ht&&(0,K.jsxs)(`div`,{className:`absolute z-[60] flex gap-2 p-6 pointer-events-none transition-all duration-500 + ${G.channelInfoStyle===`modern`?`flex-col items-center`:`flex-row items-center`} + ${G.channelInfoStyle===`box`?`bg-black/40 backdrop-blur-md rounded-xl border border-white/10`:``} + ${G.channelInfoPosition===`top-left`?`top-0 left-0 items-start text-left`:G.channelInfoPosition===`top-right`?`top-0 right-0 items-end text-right`:G.channelInfoPosition===`top-center`?`top-0 left-1/2 items-center text-center`:G.channelInfoPosition===`left-middle`?`top-1/2 left-0 items-start text-left`:G.channelInfoPosition===`center-middle`?`top-1/2 left-1/2 items-center text-center`:G.channelInfoPosition===`right-middle`?`top-1/2 right-0 items-end text-right`:G.channelInfoPosition===`bottom-left`?`bottom-0 left-0 items-start text-left`:G.channelInfoPosition===`bottom-center`?`bottom-0 left-1/2 items-center text-center`:`bottom-0 right-0 items-end text-right`} + `,style:{transform:`${G.channelInfoPosition?.includes(`center`)?`translateX(-50%)`:``} ${G.channelInfoPosition?.includes(`middle`)?`translateY(-50%)`:``} scale(${G.channelInfoSizeScale??1})`,transformOrigin:G.channelInfoPosition?.includes(`top`)?G.channelInfoPosition?.includes(`center`)?`top center`:G.channelInfoPosition?.includes(`left`)?`top left`:`top right`:G.channelInfoPosition?.includes(`middle`)?G.channelInfoPosition?.includes(`center`)?`center center`:G.channelInfoPosition?.includes(`left`)?`center left`:`center right`:G.channelInfoPosition?.includes(`center`)?`bottom center`:G.channelInfoPosition?.includes(`left`)?`bottom left`:`bottom right`,...G.channelInfoPosition?.includes(`middle`)?G.channelInfoPosition?.includes(`left`)?{marginLeft:`${(G.channelInfoMarginScale??1)*1.5}rem`}:G.channelInfoPosition?.includes(`right`)?{marginRight:`${(G.channelInfoMarginScale??1)*1.5}rem`}:{}:G.channelInfoPosition?.includes(`center`)?G.channelInfoPosition?.includes(`top`)?{marginTop:`${(G.channelInfoMarginScale??1)*1.5}rem`}:{marginBottom:`${(G.channelInfoMarginScale??1)*1.5}rem`}:{margin:`${(G.channelInfoMarginScale??1)*1.5}rem`}},children:[G.channelInfoImage&&G.channelInfoStyle!==`minimal`&&(0,K.jsx)(`img`,{src:G.channelInfoImage,alt:`Channel`,className:`w-20 h-20 object-contain drop-shadow-lg ${G.channelInfoStyle===`circle`?`rounded-full`:``}`}),G.channelInfoText&&G.channelInfoStyle!==`logo`&&(()=>{let e=G.channelInfoText.trim();return//i.test(e)?(0,K.jsx)(`div`,{className:`font-bold drop-shadow-md text-lg inline-flex items-center gap-1 + ${G.channelInfoStyle===`minimal`||G.channelInfoStyle===`box`?``:`px-2 py-1 bg-black/20 rounded-lg backdrop-blur-sm`} + [&>svg]:w-auto [&>svg]:h-[1.5em]`,style:{fontFamily:G.channelInfoFontFamily,color:G.channelInfoFontColor||`white`,fontWeight:G.channelInfoFontWeight||`bold`,fontStyle:G.channelInfoFontStyle||`normal`},dangerouslySetInnerHTML:{__html:e}}):(0,K.jsx)(`p`,{className:`font-bold drop-shadow-md text-lg + ${G.channelInfoStyle===`minimal`||G.channelInfoStyle===`box`?``:`px-2 py-1 bg-black/20 rounded-lg backdrop-blur-sm`}`,style:{fontFamily:G.channelInfoFontFamily,color:G.channelInfoFontColor||`white`,fontWeight:G.channelInfoFontWeight||`bold`,fontStyle:G.channelInfoFontStyle||`normal`},children:G.channelInfoText})})()]}),G.showFloatingNotes&&Zt&&Ht&&(0,K.jsxs)(`div`,{className:`absolute z-[55] flex p-4 pointer-events-none transition-all duration-500 overflow-hidden + ${Qt===`media-left-text`?`flex-row items-stretch gap-3`:Qt===`media-right-text`?`flex-row-reverse items-stretch gap-3`:Qt===`media-top-text`?`flex-col items-stretch gap-3`:Qt===`media-bottom-text`?`flex-col-reverse items-stretch gap-3`:`flex-col justify-center ${G.floatingNotesTextAlign===`center`?`items-center`:G.floatingNotesTextAlign===`right`?`items-end`:`items-start`}`} + ${G.floatingNotesPosition===`top-left`?`top-0 left-0 text-left`:G.floatingNotesPosition===`top-right`?`top-0 right-0 text-right`:G.floatingNotesPosition===`top-center`?`top-0 left-1/2 text-center`:G.floatingNotesPosition===`left-middle`?`top-1/2 left-0 text-left`:G.floatingNotesPosition===`center-middle`?`top-1/2 left-1/2 text-center`:G.floatingNotesPosition===`right-middle`?`top-1/2 right-0 text-right`:G.floatingNotesPosition===`bottom-left`?`bottom-0 left-0 text-left`:G.floatingNotesPosition===`bottom-center`?`bottom-0 left-1/2 text-center`:`bottom-0 right-0 text-right`} + `,style:{width:`${G.floatingNotesWidth||300}px`,height:`${G.floatingNotesHeight||150}px`,backgroundColor:G.floatingNotesShape===`none`?`transparent`:G.floatingNotesFillColor||`#000000`,opacity:G.floatingNotesOpacity??.8,border:G.floatingNotesShape!==`none`&&tn>0?`${tn}px solid ${G.floatingNotesOutlineColor||`#ffffff`}`:`none`,borderRadius:G.floatingNotesShape===`rounded`?`12px`:`0px`,transform:`${G.floatingNotesPosition?.includes(`center`)?`translateX(-50%)`:``} ${G.floatingNotesPosition?.includes(`middle`)?`translateY(-50%)`:``}`,transformOrigin:G.floatingNotesPosition?.includes(`top`)?G.floatingNotesPosition?.includes(`center`)?`top center`:G.floatingNotesPosition?.includes(`left`)?`top left`:`top right`:G.floatingNotesPosition?.includes(`middle`)?G.floatingNotesPosition?.includes(`center`)?`center center`:G.floatingNotesPosition?.includes(`left`)?`center left`:`center right`:G.floatingNotesPosition?.includes(`center`)?`bottom center`:G.floatingNotesPosition?.includes(`left`)?`bottom left`:`bottom right`,...G.floatingNotesPosition?.includes(`middle`)?G.floatingNotesPosition?.includes(`left`)?{marginLeft:`${(G.floatingNotesMarginScale??1)*1.5}rem`}:G.floatingNotesPosition?.includes(`right`)?{marginRight:`${(G.floatingNotesMarginScale??1)*1.5}rem`}:{}:G.floatingNotesPosition?.includes(`center`)?G.floatingNotesPosition?.includes(`top`)?{marginTop:`${(G.floatingNotesMarginScale??1)*1.5}rem`}:{marginBottom:`${(G.floatingNotesMarginScale??1)*1.5}rem`}:{margin:`${(G.floatingNotesMarginScale??1)*1.5}rem`}},children:[Qt!==`text-only`&&G.floatingNotesMedia&&(0,K.jsx)(`div`,{className:Aw(Qt),style:kw(Qt,$t),children:G.floatingNotesMediaType===`video`?(0,K.jsx)(`video`,{src:G.floatingNotesMedia,className:`max-w-full max-h-full object-contain`,style:{objectPosition:Ow(Qt)},muted:!0,loop:!0,autoPlay:!0,playsInline:!0},G.floatingNotesMedia):(0,K.jsx)(`img`,{src:G.floatingNotesMedia,alt:`Notes media`,className:`max-w-full max-h-full object-contain`,style:{objectPosition:Ow(Qt)}},G.floatingNotesMedia)}),Qt!==`media-only`&&G.floatingNotesText&&(0,K.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0 overflow-y-auto whitespace-pre-wrap`,style:{fontFamily:G.floatingNotesFontFamily,color:G.floatingNotesFontColor||`white`,fontWeight:G.floatingNotesFontWeight||`normal`,fontStyle:G.floatingNotesFontStyle||`normal`,textAlign:G.floatingNotesTextAlign||`left`,fontSize:`${12*en}px`},children:G.floatingNotesText})]}),Ht&&(0,K.jsx)(`div`,{className:`absolute z-20 flex flex-col gap-2 p-6 transition-all duration-500 pointer-events-none + ${Hn?`opacity-100`:`opacity-0`} + ${G.infoPosition===`top-left`?`top-0 left-0 items-start text-left`:G.infoPosition===`top-right`?`top-0 right-0 items-end text-right`:G.infoPosition===`top-center`?`top-0 left-1/2 items-center text-center`:G.infoPosition===`left-middle`?`top-1/2 left-0 items-start text-left`:G.infoPosition===`center-middle`?`top-1/2 left-1/2 items-center text-center`:G.infoPosition===`right-middle`?`top-1/2 right-0 items-end text-right`:G.infoPosition===`bottom-left`?`bottom-0 left-0 items-start text-left`:G.infoPosition===`bottom-right`?`bottom-0 right-0 items-end text-right`:G.infoPosition===`bottom-center`?`bottom-0 left-1/2 items-center text-center`:`top-0 left-0 items-start text-left`} + `,style:{transform:`${G.infoPosition?.includes(`center`)?`translateX(-50%)`:``} ${G.infoPosition?.includes(`middle`)?`translateY(-50%)`:``} scale(${G.infoSizeScale??1})`,transformOrigin:G.infoPosition?.includes(`top`)?G.infoPosition?.includes(`center`)?`top center`:G.infoPosition?.includes(`right`)?`top right`:`top left`:G.infoPosition?.includes(`middle`)?G.infoPosition?.includes(`center`)?`center center`:G.infoPosition?.includes(`right`)?`center right`:`center left`:G.infoPosition?.includes(`center`)?`bottom center`:G.infoPosition?.includes(`right`)?`bottom right`:`bottom left`,...G.infoPosition?.includes(`middle`)?G.infoPosition?.includes(`left`)?{marginLeft:`${(G.infoMarginScale??1)*1.5}rem`}:G.infoPosition?.includes(`right`)?{marginRight:`${(G.infoMarginScale??1)*1.5}rem`}:{}:G.infoPosition?.includes(`center`)?G.infoPosition?.includes(`top`)?{marginTop:`${(G.infoMarginScale??1)*1.5}rem`}:{marginBottom:`${(G.infoMarginScale??1)*1.5}rem`}:{margin:`${(G.infoMarginScale??1)*1.5}rem`}},children:(0,K.jsxs)(`div`,{className:` + flex items-center gap-4 pointer-events-auto + ${G.infoPosition?.includes(`center`)?`flex-col justify-center`:``} + ${G.infoPosition?.includes(`right`)?`flex-row-reverse`:`flex-row`} + ${G.infoStyle===`box`?`bg-black/40 backdrop-blur-md p-4 rounded-xl border border-white/10`:``} + ${G.infoStyle===`modern`||G.infoStyle,``} + `,children:[(0,K.jsxs)(`div`,{className:`relative group shrink-0 transition-opacity duration-300 + ${!G.showCover||G.infoStyle===`minimal`||G.infoStyle===`modern`?`hidden`:`block`} + ${G.infoStyle===`circle_art`?`rounded-full`:`rounded-md`} + overflow-hidden bg-zinc-800 shadow-lg border border-white/10 + w-12 h-12 md:w-16 md:h-16 + `,children:[g.coverUrl?g.backgroundType===`video`?(0,K.jsx)(`video`,{src:g.coverUrl,className:`w-full h-full object-cover`,muted:!0,loop:!0,onMouseOver:e=>e.currentTarget.play(),onMouseOut:e=>e.currentTarget.pause()}):(0,K.jsx)(`img`,{src:g.coverUrl,alt:`Cover`,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-zinc-500`,children:(0,K.jsx)(ge,{size:24})}),(0,K.jsxs)(`label`,{className:`absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 cursor-pointer transition-opacity`,children:[(0,K.jsx)(He,{size:20,className:`text-white`}),(0,K.jsx)(`input`,{type:`file`,accept:`image/*,video/*`,className:`hidden`,onChange:on})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col justify-center ${G.infoPosition?.includes(`right`)?`items-end`:G.infoPosition?.includes(`center`)?`items-center`:`items-start`}`,children:[(0,K.jsx)(`h1`,{className:`font-bold drop-shadow-md line-clamp-1 transition-opacity duration-300 + ${G.showTitle?`opacity-100`:`opacity-0 h-0 w-0`} + ${G.infoStyle===`minimal`?`text-sm`:G.infoStyle===`modern`||G.infoStyle===`modern_art`?`text-xl`:`text-lg`} + `,style:{fontFamily:G.infoFontFamily,color:G.infoFontColor||`white`,fontWeight:G.infoFontWeight||`bold`,fontStyle:G.infoFontStyle||`normal`},children:g.title}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 transition-opacity duration-300 + ${G.showArtist?`opacity-100`:`opacity-0 h-0 w-0`} + `,children:(0,K.jsx)(`p`,{className:`drop-shadow-md + ${G.infoStyle===`minimal`?`text-[10px]`:G.infoStyle===`modern`||G.infoStyle===`modern_art`?`text-sm font-medium`:`text-xs`} + `,style:{fontFamily:G.infoFontFamily,color:G.infoFontColor||(G.infoStyle===`minimal`?`#a1a1aa`:`#d4d4d8`),fontWeight:G.infoFontWeight||`bold`,fontStyle:G.infoFontStyle||`normal`},children:g.artist})})]})]})}),(0,K.jsx)(`div`,{className:`transition-all duration-500 ease-in-out overflow-hidden ${Hn&&!Ht?`max-h-80 md:max-h-40 opacity-100`:`max-h-0 opacity-0`}`,children:(0,K.jsxs)(`div`,{className:`p-4 md:p-6 flex flex-col md:flex-row justify-between items-start gap-4 md:gap-0`,children:[(0,K.jsx)(`div`,{className:`flex gap-4`,children:(0,K.jsxs)(`div`,{className:`flex gap-4 items-center`,children:[(0,K.jsxs)(`div`,{className:`relative group w-16 h-16 rounded-md overflow-hidden bg-zinc-800 shadow-lg border border-white/10 shrink-0 transition-opacity duration-300 ${G.showCover?`opacity-100 scale-100`:`opacity-0 scale-75 pointer-events-none w-0 h-0 -ml-4`}`,children:[g.coverUrl?g.backgroundType===`video`?(0,K.jsx)(`video`,{src:g.coverUrl,className:`w-full h-full object-cover`,muted:!0,loop:!0,onMouseOver:e=>e.currentTarget.play(),onMouseOut:e=>e.currentTarget.pause()}):(0,K.jsx)(`img`,{src:g.coverUrl,alt:`Cover`,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-zinc-500`,children:(0,K.jsx)(ge,{size:24})}),(0,K.jsxs)(`label`,{className:`absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 cursor-pointer transition-opacity`,children:[(0,K.jsx)(He,{size:20,className:`text-white`}),(0,K.jsx)(`input`,{type:`file`,accept:`image/*,video/*`,className:`hidden`,onChange:on})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-xl font-bold text-white drop-shadow-md line-clamp-1 transition-opacity duration-300 ${G.showTitle?`opacity-100`:`opacity-0`}`,children:g.title}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 transition-opacity duration-300 ${G.showArtist?`opacity-100`:`opacity-0`}`,children:(0,K.jsx)(`p`,{className:`text-zinc-300 text-sm drop-shadow-md`,children:g.artist})})]})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-wrap ${Ht?`hidden`:``}`,children:[(0,K.jsx)(`a`,{href:`https://github.com/dotslashgabut/immersive-audio-player-lyric-video-maker`,target:`_blank`,rel:`noopener noreferrer`,title:`Immersive Audio Player & Lyric Video Maker | GitHub`,className:`px-3 py-2 rounded-full transition-colors bg-black/30 text-zinc-300 hover:bg-white/10 text-xs font-bold flex items-center`,children:(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`20`,height:`20`,fill:`#eee`,className:`bi bi-github`,viewBox:`0 0 16 16`,children:(0,K.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8`})})}),(0,K.jsx)(`a`,{href:`https://dotslashgabut.github.io/lyricseditor/`,target:`_blank`,rel:`noopener noreferrer`,title:`Premium Lyrics Editor - LRC, SRT, VTT, TTML & Subtitle Sync Tool`,className:`px-3 py-2 rounded-full transition-colors bg-black/30 text-zinc-300 hover:bg-white/10 text-xs font-bold flex items-center`,children:`LyricsEditor`}),(0,K.jsx)(`a`,{href:`https://dotslashgabut.github.io/lyricaleditorplus/`,target:`_blank`,rel:`noopener noreferrer`,title:`LyricalEditorPlus - Universal Lyrics/Subtitle Editor & Lyrics Generator`,className:`px-3 py-2 rounded-full transition-colors bg-black/30 text-zinc-300 hover:bg-white/10 text-xs font-bold flex items-center`,children:`LyricalEditorPlus`}),(0,K.jsx)(`button`,{onClick:()=>ue(!le),className:`p-2 rounded-full transition-colors ${le?`bg-purple-600/50 text-white`:`bg-black/30 text-zinc-300 hover:bg-white/10`}`,title:`Bypass Auto-hide (H)`,children:le?(0,K.jsx)(B,{size:20}):(0,K.jsx)(z,{size:20})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-black/30 text-zinc-300 rounded-full px-2 py-1 text-xs font-bold border border-white/5 h-9`,children:[(0,K.jsx)(`button`,{onClick:()=>ut(e=>Math.max(.5,Math.round((e-.05)*100)/100)),className:`w-5 h-5 rounded-full hover:bg-white/10 hover:text-white transition-colors flex items-center justify-center font-bold text-sm`,title:`Decrease UI Scale (8)`,children:`-`}),(0,K.jsxs)(`button`,{onClick:()=>ut(1),className:`px-1 font-bold text-[10px] hover:text-white select-none transition-colors text-center min-w-[28px]`,title:`Reset UI Scale to 100% (Click)`,children:[Math.round(lt*100),`%`]}),(0,K.jsx)(`button`,{onClick:()=>ut(e=>Math.min(2,Math.round((e+.05)*100)/100)),className:`w-5 h-5 rounded-full hover:bg-white/10 hover:text-white transition-colors flex items-center justify-center font-bold text-sm`,title:`Increase UI Scale (9)`,children:`+`})]}),(0,K.jsx)(`button`,{onClick:()=>q(!Ht),className:`p-2 rounded-full transition-colors ${Ht?`bg-purple-600 text-white`:`bg-black/30 text-zinc-300 hover:bg-white/10`}`,title:`Minimal Mode (O)`,children:Ht?(0,K.jsx)(he,{size:20}):(0,K.jsx)(U,{size:20})}),(0,K.jsx)(`button`,{onClick:()=>{let e=!Mt;Nt(e),e&&ne(Ze.PLAYER)},className:`p-2 rounded-full transition-colors ${Mt?`bg-orange-600 text-white`:`bg-black/30 text-zinc-300 hover:bg-white/10`}`,title:`Toggle Playlist (L)`,children:(0,K.jsx)(pe,{size:20})}),(0,K.jsx)(`button`,{onClick:()=>{Mt&&Nt(!1),ne(L===Ze.PLAYER?Ze.EDITOR:Ze.PLAYER)},className:`p-2 rounded-full transition-colors ${L===Ze.EDITOR&&!Mt?`bg-purple-600 text-white`:`bg-black/30 text-zinc-300 hover:bg-white/10`}`,title:`Toggle Timeline (T)`,children:(0,K.jsx)(oe,{size:20})}),(0,K.jsx)(`button`,{onMouseDown:e=>{e.stopPropagation(),ot(!at)},className:`p-2 rounded-full transition-colors ${at?`bg-purple-600 text-white`:`bg-black/30 text-zinc-300 hover:bg-white/10`}`,title:`Render Settings (D)`,children:(0,K.jsx)(Oe,{size:20})}),(0,K.jsx)(`button`,{onMouseDown:e=>{e.stopPropagation(),ct(!st)},className:`p-2 rounded-full transition-colors ${st?`bg-purple-600 text-white`:`bg-black/30 text-zinc-300 hover:bg-white/10`}`,title:`Keyboard Shortcuts (Y)`,children:(0,K.jsx)(H,{size:20})}),(0,K.jsx)(`button`,{onClick:Cn,className:`p-2 rounded-full bg-black/30 text-zinc-300 hover:bg-white/10 transition-colors`,title:`Fullscreen (F)`,children:R?(0,K.jsx)(U,{size:20}):(0,K.jsx)(he,{size:20})})]})]})}),(0,K.jsx)(`div`,{className:`flex-1 flex justify-center overflow-hidden relative ${G.contentPosition===`top`?`items-start`:G.contentPosition===`bottom`?`items-end`:`items-center`}`,style:{paddingTop:G.contentPosition===`top`?`${(G.marginTopScale??1)*10}vh`:void 0,paddingBottom:G.contentPosition===`bottom`?`${(G.marginBottomScale??1)*10}vh`:void 0},children:v.length>0?(0,K.jsxs)(`div`,{ref:i,className:`w-full max-w-5xl max-h-full overflow-y-auto no-scrollbar px-4 md:px-6 space-y-4 md:space-y-6 transition-all duration-500 lyrics-root ${G.textAlign===`left`?`text-left`:G.textAlign===`right`?`text-right`:`text-center`} ${!G.showLyrics||Jt?`opacity-0 pointer-events-none`:`opacity-100`}`,style:{maskImage:(Hn||Un)&&De!==`subtitle`?`linear-gradient(to bottom, transparent, black 10%, black 90%, transparent)`:`none`,"--fs-scale":G.fontSizeScale||1,"--l-height":G.lyricLineHeight||1.2},children:[(0,K.jsx)(`div`,{className:`transition-all duration-500 ${G.contentPosition===`center`?L===Ze.EDITOR||Mt?`h-[25vh]`:!Hn&&!Un?`h-[50vh]`:`h-[40vh]`:`h-0`}`}),[`static-compact`,`static-compact-comma`,`static-compact-clean`].includes(G.lyricDisplayMode)?(()=>{let e=G.lyricDisplayMode,t=``,n=[],r=[];for(let e=0;e0&&(n.push(r),r=[]):r.push(t)}r.length>0&&n.push(r);let i=G?.textCase||`none`,a=e=>{if(!e)return e;if(i===`upper`)return e.toUpperCase();if(i===`lower`)return e.toLowerCase();if(i===`title`)return e.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());if(i===`sentence`){let t=e.toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}return i===`invert`?e.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase()):e};return t=e===`static-compact`?n.map(e=>a(e.join(` / `))).join(` // `):e===`static-compact-comma`?n.map(e=>a(e.join(`, `))+`.`).join(` +`):n.map(e=>a(e.join(` `))+`.`).join(` +`),(0,K.jsx)(`div`,{className:`w-full text-white opacity-90 text-center select-none whitespace-pre-wrap leading-relaxed px-4 md:px-8`,style:{fontSize:`calc(1.35rem * var(--fs-scale))`,fontFamily:G.fontFamily===`CustomFont`?`CustomFont, sans-serif`:G.fontFamily,fontWeight:G.fontWeight||`bold`,fontStyle:G.fontStyle||`normal`,textAlign:G.textAlign||`center`},children:t})})():Ut.map((t,r)=>{let i=G.lyricDisplayMode===`static-all`?!1:r===(Yt>=0?Yt:Gt),a=L===Ze.EDITOR||Mt,o=[`9:16`,`3:4`,`1:1`,`1:2`,`2:3`].includes(be);if([`large`,`large_upper`,`big_center`,`metal`,`kids`,`sad`,`romantic`,`tech`,`gothic`,`testing`,`testing_up`,`one_line`,`one_line_up`,`custom`].includes(De),G.lyricDisplayMode!==`all`){if(Yt===-1&&[`active-only`,`next-only`,`previous-next`].includes(G.lyricDisplayMode)||G.lyricDisplayMode===`static-all`&&t.text.trim()===``||!nn(r))return(0,K.jsx)(`p`,{className:`hidden`},r)}else if(De===`none`||De===`just_video`)return(0,K.jsx)(`p`,{className:`hidden`},r);let s=``,c=``,l=G.transitionEffect,u=`transition-[color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,text-shadow] duration-500 cursor-pointer whitespace-pre-wrap break-words `;if(i?l===`slide`?u+=`translate-y-0 opacity-100 `:l===`zoom`?u+=`scale-100 opacity-100 `:l===`float`?u+=`translate-y-0 opacity-100 `:l===`blur`?u+=`blur-0 opacity-100 `:l===`fade`?u+=`opacity-100 `:l===`drop`?u+=`trans-drop-enter opacity-100 `:l===`lightspeed`?u+=`trans-lightspeed-enter opacity-100 `:l===`roll`?u+=`trans-roll-enter opacity-100 `:l===`elastic`?u+=`trans-elastic-enter opacity-100 `:l===`flip`?u+=`trans-flip-enter opacity-100 `:l===`rotate-in`?u+=`trans-rotate-in-enter opacity-100 `:l===`spiral`?u+=`trans-spiral-enter opacity-100 `:l===`shatter`?u+=`trans-shatter-enter opacity-100 `:u+=`opacity-100 `:(l===`slide`?u+=`translate-y-4 opacity-0 `:l===`zoom`?u+=`scale-75 opacity-0 `:l===`float`?u+=`translate-y-8 opacity-0 `:l===`blur`?u+=`blur-md opacity-0 `:l===`fade`?u+=`opacity-50 `:l===`drop`?u+=`trans-drop-exit opacity-0 `:l===`roll`?u+=`trans-roll-exit opacity-0 `:u+=`opacity-0 `,l===`none`&&(u=u.replace(`opacity-0`,`opacity-50`))),De===`large`||De===`large_upper`){let e=o?a?`text-4xl`:`text-6xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} font-black text-white ${De===`large_upper`?`uppercase`:``} tracking-tight text-left pl-4`,c=`${t} text-zinc-600/40 hover:text-zinc-400 text-left pl-4`}else if(De===`big_center`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} font-black text-white uppercase tracking-tight text-center`,c=`${t} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(De===`testing_up`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-white uppercase tracking-tight text-center`,c=`${t} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(De===`testing`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-white tracking-tight text-center`,c=`${t} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(De===`one_line_up`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-white uppercase tracking-tight text-center`,c=`${t} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(De===`one_line`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-white tracking-tight text-center`,c=`${t} text-zinc-600/40 hover:text-zinc-400 text-center`}else if(De===`metal`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-white uppercase tracking-wide text-center drop-shadow-[0_4px_6px_rgba(255,0,0,0.5)]`,c=`${t} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(De===`kids`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-white tracking-wide text-center drop-shadow-[3px_3px_0px_rgba(0,0,0,0.5)]`,c=`${t} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(De===`sad`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-7xl`,t=o?a?`text-lg`:`text-xl`:a?`text-xl`:`text-2xl`;s=`${e} text-zinc-200 tracking-wider text-center drop-shadow-md`,c=`${t} text-zinc-600/60 hover:text-zinc-400 text-center`}else if(De===`romantic`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-7xl`,t=o?a?`text-lg`:`text-xl`:a?`text-xl`:`text-2xl`;s=`${e} text-pink-100 italic tracking-wide text-center drop-shadow-[0_0_10px_rgba(236,72,153,0.5)]`,c=`${t} text-zinc-600/60 hover:text-zinc-400 text-center italic`}else if(De===`tech`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-cyan-50 font-bold uppercase tracking-widest text-center drop-shadow-[0_0_10px_rgba(34,211,238,0.8)]`,c=`${t} text-cyan-900/40 hover:text-cyan-800 text-center uppercase`}else if(De===`gothic`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-7xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`;s=`${e} text-zinc-300 tracking-normal text-center drop-shadow-[0_4px_10px_rgba(0,0,0,0.9)]`,c=`${t} text-zinc-700/60 hover:text-zinc-500 text-center`}else if(De===`monospace`){let e=o?a?`text-2xl`:`text-3xl`:a?`text-3xl`:`text-5xl`,t=o?a?`text-lg`:`text-xl`:a?`text-xl`:`text-2xl`;s=`${e} font-mono font-bold text-white scale-105 drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)]`,c=`${t} font-mono text-zinc-500/60 hover:text-zinc-300 drop-shadow-sm`}else if(De===`classic`){let e=o?a?`text-2xl`:`text-3xl`:a?`text-3xl`:`text-6xl`,t=o?a?`text-lg`:`text-xl`:a?`text-xl`:`text-2xl`;s=`${e} font-serif italic font-bold text-amber-100 drop-shadow-[0_4px_8px_rgba(0,0,0,0.9)]`,c=`${t} font-serif text-zinc-500/60 hover:text-zinc-300 italic`}else if(De===`slideshow`||De===`just_video`)s=`${o?a?`text-2xl`:`text-3xl`:a?`text-3xl`:`text-4xl`} text-white tracking-wide text-center`,c=`hidden`;else if(De===`subtitle`){s=`${o?a?`text-2xl`:`text-3xl`:a?`text-3xl`:`text-4xl`} text-white tracking-wide text-center whitespace-pre-wrap`,c=`hidden`;let e=`bottom-16`;a&&Un?e=`bottom-[560px]`:a?e=`bottom-[360px]`:Un&&(e=`bottom-[280px]`),u=u.replace(`absolute`,``).replace(`transform`,``),u+=`fixed ${e} left-1/2 -translate-x-1/2 w-full px-8 z-[100] pointer-events-none `}else if(De===`custom`){let e=o?a?`text-4xl`:`text-5xl`:a?`text-6xl`:`text-8xl`,t=o?a?`text-xl`:`text-2xl`:a?`text-2xl`:`text-3xl`,n=G.textAlign===`center`?`text-center`:G.textAlign===`right`?`text-right`:`text-left`;s=`${e} tracking-tight ${n}`,c=`${t} opacity-40 hover:opacity-100 ${n}`}else s=`${o?a?`text-2xl`:`text-3xl`:a?`text-3xl`:`text-5xl`} font-bold text-white scale-105 drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)]`;G.lyricDisplayMode===`static-all`&&(c=`${o?a?`text-base`:`text-lg`:a?`text-lg`:`text-xl`} font-semibold text-white/90 drop-shadow-sm ${G.textAlign===`center`?`text-center`:G.textAlign===`right`?`text-right`:`text-left`}`);let d=(G.lyricStyleTarget||`active-only`)===`all`||i,f={color:G.fontColor,fontWeight:d?G.fontWeight:void 0,fontStyle:d?G.fontStyle:void 0,textDecoration:d?G.textDecoration:void 0,fontFamily:G.fontFamily===`CustomFont`?`CustomFont, sans-serif`:G.fontFamily};if((De===`custom`||De==="default")&&i&&G.textEffect!==`none`){let e=G.textEffect;e===`glow`?f.textShadow=`0 0 10px ${G.fontColor}, 0 0 20px ${G.fontColor}`:e===`neon`?f.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px ${G.fontColor}, 0 0 40px ${G.fontColor}, 0 0 80px ${G.fontColor}`:e===`neon-multi`?f.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px #ff00de, 0 0 35px #00ffff, 0 0 40px #ff00de, 0 0 50px #00ffff`:e===`shadow`?f.textShadow=`3px 3px 6px rgba(0,0,0,0.7)`:e===`outline`?f.textShadow=`-1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000`:e===`3d`?f.textShadow=`1px 1px 0px #ccc, 2px 2px 0px #bbb, 3px 3px 0px #aaa, 4px 4px 0px rgba(0,0,0,0.5)`:e===`emboss`?(f.color=`#ebebeb`,f.textShadow=`1px 2px 3px rgba(255,255,255,0.8), -1px -2px 3px rgba(0,0,0,0.8)`):e===`gold`?(f.background=`linear-gradient(to bottom, #d4af37, #C5A028)`,f.WebkitBackgroundClip=`text`,f.color=`transparent`):e===`chrome`?(f.background=`linear-gradient(to bottom, #ebebeb 50%, #616161 50%, #ebebeb)`,f.WebkitBackgroundClip=`text`,f.color=`transparent`):e===`fire`?(f.color=`#fff`,f.textShadow=`0 -5px 4px #FFC107, 2px -10px 6px #FF9800, -2px -15px 11px #FF5722, 2px -25px 18px #795548`):e===`frozen`?(f.color=`#fff`,f.textShadow=`0 0 5px rgba(255,255,255,0.8), 0 0 10px rgba(255,255,255,0.5), 0 0 20px #03A9F4, 0 0 30px #03A9F4, 0 0 40px #03A9F4`):e===`vhs`?f.textShadow=`2px 0 0 rgba(255,0,0,0.7), -2px 0 0 rgba(0,0,255,0.7)`:e===`gradient`?(f.background=`linear-gradient(to right, ${G.fontColor}, #ffffff)`,f.WebkitBackgroundClip=`text`,f.color=`transparent`):e===`rainbow`?(f.background=`linear-gradient(to left, violet, indigo, blue, green, yellow, orange, red)`,f.WebkitBackgroundClip=`text`,f.color=`transparent`):e===`glass`?(f.backgroundColor=`rgba(255, 255, 255, 0.1)`,f.backdropFilter=`blur(8px)`,f.padding=`0.5rem 1rem`,f.borderRadius=`0.75rem`,f.border=`1px solid rgba(255, 255, 255, 0.2)`,f.display=`inline-block`):e===`mirror`?(f.transform=`scaleY(1.3) perspective(500px) rotateX(-10deg)`,f.textShadow=`0 15px 5px rgba(0,0,0,0.1), 0 -1px 3px rgba(0,0,0,0.3)`):e===`retro`?(f.fontFamily=`'Press Start 2P', cursive`,f.color=`#ff00ff`,f.textShadow=`4px 4px 0px #00ffff`):e===`cyberpunk`?(f.color=`#fcee0a`,f.textShadow=`2px 2px 0px #000, -1px -1px 0 #05d9e8`,f.fontFamily=`'Orbitron', sans-serif`,f.letterSpacing=`1px`):e===`glitch-text`?(f.animation=`anim-glitch 0.4s infinite linear`,f.position=`relative`):e===`hologram`?(f.color=`rgba(0, 255, 255, 0.7)`,f.textShadow=`0 0 5px rgba(0,255,255,0.5), 0 0 10px rgba(0,255,255,0.5)`,f.backgroundImage=`repeating-linear-gradient(0deg, transparent, transparent 2px, #00ffff 3px)`,f.WebkitBackgroundClip=`text`):e===`comic`&&(f.fontFamily=`'Bangers', cursive`,f.color=`#ffcc00`,f.textShadow=`2px 2px 0px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000`,f.letterSpacing=`1px`)}let p=t.text,m=G.textCase;m===`upper`?p=p.toUpperCase():m===`lower`?p=p.toLowerCase():m===`title`?p=p.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()):m===`sentence`?p=p.charAt(0).toUpperCase()+p.slice(1).toLowerCase():m===`invert`&&(p=p.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase())),p=p.replace(/\s*([-‐‑‒–—―])\s*/g,`$1`),i&&G.textAnimation===`typewriter`&&(p=p.substring(0,Math.max(0,Math.floor((k-t.time)*35))));let h=p;if(i&&G.highlightEffect!==`none`){let e=G.highlightEffect,n=t.words&&t.words.length>0;if((e===`karaoke`||e?.startsWith(`karaoke-`))&&n)h=t.words.filter(e=>e.text===` +`||e.text.trim().length>0).map((t,n,r)=>{if(t.text===` +`)return(0,K.jsx)(`br`,{},n);let i=t.text.trim();if(m===`upper`)i=i.toUpperCase();else if(m===`lower`)i=i.toLowerCase();else if(m===`title`)i=i.replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.substr(1).toLowerCase());else if(m===`sentence`){let e=i.toLowerCase();i=n===0?e.charAt(0).toUpperCase()+e.slice(1):e}else m===`invert`&&(i=i.replace(/\w\S*/g,e=>e.charAt(0).toLowerCase()+e.slice(1).toUpperCase()));let a=t.startTime+S,o=t.endTime+S,s=k>=a&&k=o,l=/[-‐‑‒–—―]$/,u=/^[-‐‑‒–—―]/,d=!i.endsWith(` `);l.test(i.trim())&&(d=!1);let f=r[n+1];f&&u.test(f.text.trim())&&(d=!1),f&&f.text===` +`&&(d=!1),n===r.length-1&&(d=!1);let p={display:`inline-block`};if(G.textDecoration&&G.textDecoration!==`none`&&(p.textDecoration=G.textDecoration),!s&&!c?(e===`karaoke-smooth-white`?(p.opacity=1,p.color=`#ffffff`):p.opacity=.5,p.transform=`scale(1)`):c&&(e===`karaoke-fill`?(p.backgroundColor=G.highlightBackground||`#fb923c`,p.color=`#000`,p.padding=`2px 6px`,p.borderRadius=`4px`,p.opacity=1):e===`karaoke-smooth`||e===`karaoke-smooth-white`?(p.color=G.highlightColor||`#fb923c`,p.opacity=1):(De===`custom`&&(p.color=G.fontColor),p.opacity=1)),s){let n=G.highlightColor||`#fb923c`,r=G.highlightBackground||`#fb923c`;if(e===`karaoke-smooth`||e===`karaoke-smooth-white`){let r=t.endTime-t.startTime,i=k-a,o=Math.min(100,Math.max(0,i/r*100));p.backgroundImage=`linear-gradient(90deg, ${n} ${o}%, ${e===`karaoke-smooth-white`?`#ffffff`:G.fontColor||`#ffffff`} ${o}%)`,p.backgroundClip=`text`,p.WebkitBackgroundClip=`text`,p.color=`transparent`,p.WebkitTextFillColor=`transparent`,p.textShadow=`none`}else e===`karaoke`||e===`color`?(p.color=n,p.textShadow=`0 0 10px ${n}`):e===`karaoke-neon`?(p.color=`#fff`,p.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px ${n}, 0 0 35px ${n}`):e===`karaoke-scale`?(p.color=n,p.transform=`scale(1.3)`):e===`karaoke-underline`?(p.color=n,p.textDecoration=(p.textDecoration||``)+` underline`,p.textDecorationColor=n,p.textUnderlineOffset=`4px`):e===`karaoke-bounce`?(p.color=n,p.transform=`translateY(-10px)`):e===`karaoke-fill`?(p.backgroundColor=r,p.color=`#000`,p.padding=`2px 6px`,p.borderRadius=`4px`):e===`karaoke-outline`?(p.color=`transparent`,p.WebkitTextStroke=`2px ${n}`):e===`karaoke-shadow`?(p.color=n,p.textShadow=`3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000`):e===`karaoke-gradient`?(p.background=`linear-gradient(90deg, ${n}, ${r})`,p.WebkitBackgroundClip=`text`,p.WebkitTextFillColor=`transparent`):e===`karaoke-wave`?(p.color=n,p.animation=`bounce 0.3s ease infinite`):e===`karaoke-pill`?(p.backgroundColor=r,p.color=`#000`,p.padding=`4px 16px`,p.borderRadius=`9999px`):e===`karaoke-box`?(p.backgroundColor=r,p.color=`#000`,p.padding=`4px 8px`,p.borderRadius=`0`):e===`karaoke-rounded`?(p.backgroundColor=r,p.color=`#000`,p.padding=`4px 12px`,p.padding=`4px 12px`,p.borderRadius=`12px`):e===`karaoke-glass`?(p.backgroundColor=`rgba(255, 255, 255, 0.1)`,p.color=`#fff`,p.padding=`4px 12px`,p.borderRadius=`8px`,p.backdropFilter=`blur(4px)`,p.border=`1px solid rgba(255, 255, 255, 0.3)`,p.boxShadow=`0 4px 6px rgba(0, 0, 0, 0.1)`):e===`karaoke-neon-multi`?(p.color=`#fff`,p.textShadow=`0 0 5px #fff, 0 0 10px #fff, 0 0 20px #ff00de, 0 0 35px #00ffff, 0 0 40px #ff00de`):e===`karaoke-soft-glow`?(p.color=n,p.textShadow=`0 0 5px ${n}, 0 0 15px ${n}, 0 0 30px ${n}`):e===`karaoke-3d`?p.textShadow=`1px 1px 0px #ccc, 2px 2px 0px #bbb, 3px 3px 0px #aaa, 4px 4px 0px rgba(0,0,0,0.5)`:e===`karaoke-emboss`?(p.color=`#ebebeb`,p.textShadow=`1px 2px 3px rgba(255,255,255,0.8), -1px -2px 3px rgba(0,0,0,0.8)`):e===`karaoke-chrome`?(p.background=`linear-gradient(to bottom, #ebebeb 50%, #616161 50%, #ebebeb)`,p.WebkitBackgroundClip=`text`,p.color=`transparent`):e===`karaoke-gold`?(p.background=`linear-gradient(to bottom, #d4af37, #C5A028)`,p.WebkitBackgroundClip=`text`,p.color=`transparent`):e===`karaoke-fire`?(p.color=`#fff`,p.textShadow=`0 -5px 4px #FFC107, 2px -10px 6px #FF9800, -2px -15px 11px #FF5722, 2px -25px 18px #795548`):e===`karaoke-frozen`?(p.color=`#fff`,p.textShadow=`0 0 5px rgba(255,255,255,0.8), 0 0 10px rgba(255,255,255,0.5), 0 0 20px #03A9F4, 0 0 30px #03A9F4`):e===`karaoke-rainbow`?(p.background=`linear-gradient(to left, violet, indigo, blue, green, yellow, orange, red)`,p.WebkitBackgroundClip=`text`,p.color=`transparent`):e===`karaoke-mirror`?(p.transform=`scaleY(1.3) perspective(500px) rotateX(-10deg)`,p.textShadow=`0 15px 5px rgba(0,0,0,0.1), 0 -1px 3px rgba(0,0,0,0.3)`):e===`karaoke-vhs`?p.textShadow=`2px 0 0 rgba(255,0,0,0.7), -2px 0 0 rgba(0,0,255,0.7)`:e===`karaoke-retro`?(p.fontFamily=`'Press Start 2P', cursive`,p.color=`#ff00ff`,p.textShadow=`4px 4px 0px #00ffff`):e===`karaoke-cyberpunk`?(p.color=`#fcee0a`,p.textShadow=`2px 2px 0px #000, -1px -1px 0 #05d9e8`,p.fontFamily=`'Orbitron', sans-serif`):e===`karaoke-hologram`?(p.color=`rgba(0, 255, 255, 0.7)`,p.textShadow=`0 0 5px rgba(0,255,255,0.5)`):e===`karaoke-comic`?(p.fontFamily=`'Bangers', cursive`,p.color=`#ffcc00`,p.textShadow=`2px 2px 0px #000, -1px -1px 0 #000`):e===`karaoke-glitch-text`?p.animation=`anim-glitch 0.4s infinite linear`:e===`karaoke-pulse`?p.animation=`anim-pulse 1s infinite ease-in-out`:e===`karaoke-breathe`?p.animation=`anim-breathe 2s infinite ease-in-out`:e===`karaoke-float`?p.animation=`anim-float 2s infinite ease-in-out`:e===`karaoke-sway`?p.animation=`anim-sway 2s infinite ease-in-out`:e===`karaoke-flicker`?p.animation=`anim-flicker 2s infinite linear`:e===`karaoke-shake`?p.animation=`anim-shake 0.2s infinite linear`:e===`karaoke-wobble`?p.animation=`anim-wobble 1s infinite ease-in-out`:e===`karaoke-jello`?p.animation=`anim-jello 1s infinite`:e===`karaoke-rubberband`?p.animation=`anim-rubberband 1s infinite`:e===`karaoke-heartbeat`?p.animation=`anim-heartbeat 1.3s infinite ease-in-out`:e===`karaoke-flash`?p.animation=`anim-flash 1s infinite`:e===`karaoke-tada`?p.animation=`anim-tada 1s infinite`:e===`karaoke-swing`?p.animation=`anim-swing 2s infinite`:e===`karaoke-rotate`?p.animation=`anim-rotate 4s infinite linear`:e===`karaoke-spin`?p.animation=`anim-rotate 1s infinite linear`:e===`karaoke-glitch`?p.animation=`anim-glitch 0.3s infinite linear`:e===`karaoke-typewriter`?(p.animation=`typewriter-reveal 0.5s steps(10, end) forwards`,p.whiteSpace=`nowrap`,p.overflow=`hidden`,p.display=`inline-block`,p.verticalAlign=`bottom`):e===`karaoke-fade`?p.animation=`trans-fade-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards`:e===`karaoke-slide`?p.animation=`trans-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards`:e===`karaoke-drop`?p.animation=`trans-drop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`:e===`karaoke-lightspeed`?p.animation=`trans-lightspeed-in 0.5s ease-out forwards`:e===`karaoke-roll`?p.animation=`trans-roll-in 0.5s ease-out forwards`:e===`karaoke-zoom`?p.animation=`trans-zoom-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards`:e===`karaoke-elastic`?p.animation=`trans-elastic-in 0.7s ease-out forwards`:e===`karaoke-scale-rotate`?p.animation=`trans-scale-rotate-in 0.5s ease-out forwards`:e===`karaoke-flip`?p.animation=`trans-flip-in 0.5s ease-out forwards`:e===`karaoke-rotate-in`?p.animation=`trans-rotate-in 0.5s ease-out forwards`:e===`karaoke-spiral`?p.animation=`trans-spiral-in 0.6s ease-out forwards`:e===`karaoke-blur`?p.animation=`trans-blur-in 0.4s ease-out forwards`:e===`karaoke-shatter`?p.animation=`trans-shatter-in 0.5s ease-out forwards`:[`karaoke-blue`,`karaoke-purple`,`karaoke-green`,`karaoke-pink`,`karaoke-cyan`,`karaoke-glow-blue`,`karaoke-glow-pink`].includes(e||``)&&(p.color=n,p.textShadow=`0 0 10px ${n}`,e?.includes(`glow`)&&(p.textShadow=`0 0 5px ${n}, 0 0 15px ${n}, 0 0 30px ${n}`))}let h=(0,K.jsx)(`span`,{className:`inline-block`,style:p,children:i},n);return d?(0,K.jsxs)(w.Fragment,{children:[h,` `]},n):h});else if(e===`karaoke`||e?.startsWith(`karaoke-`)){let t=G.highlightColor||`#fb923c`,n=G.highlightBackground||`#fb923c`;f.color=t,e===`karaoke-neon`&&(f.textShadow=`0 0 10px ${t}, 0 0 20px ${t}`),e===`karaoke-scale`&&(f.transform=(f.transform||``)+` scale(1.1)`),e===`karaoke-underline`&&(f.textDecoration=`underline`),e===`karaoke-bounce`&&(f.transform=(f.transform||``)+` translateY(-5px)`),e===`karaoke-fill`&&(f.backgroundColor=n,f.color=`#000`,f.padding=`4px 12px`,f.borderRadius=`6px`),e===`karaoke-outline`&&(f.color=`transparent`,f.WebkitTextStroke=`2px ${t}`),e===`karaoke-shadow`&&(f.textShadow=`3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000`),e===`karaoke-gradient`&&(f.background=`linear-gradient(90deg, ${t}, ${n})`,f.WebkitBackgroundClip=`text`,f.WebkitTextFillColor=`transparent`),[`karaoke-pill`,`karaoke-box`,`karaoke-rounded`].includes(e)&&(f.backgroundColor=n,f.color=`#000`,f.padding=`4px 16px`,f.borderRadius=e===`karaoke-pill`?`9999px`:e===`karaoke-rounded`?`12px`:`0`),e?.includes(`glow`)&&(f.textShadow=`0 0 10px ${t}, 0 0 20px ${t}`)}else e===`scale`?f.color=G.highlightColor||`#fb923c`:G.highlightEffect===`background`&&(f.backgroundColor=(G.highlightBackground||`#fb923c`)+`4D`,f.padding=`0 10px`,f.borderRadius=`8px`)}return(0,K.jsx)(`p`,{"data-lyric-active":i?`true`:`false`,className:`${u} ${i?s:c}`,onClick:()=>{i&&(navigator.clipboard.writeText(t.text),e.success(`Lyric copied to clipboard`,1500)),n.current&&!V&&(n.current.currentTime=t.time,A(t.time))},children:(0,K.jsx)(`span`,{className:`inline-block ${i&&G.textAnimation!==`none`&&G.textAnimation!==`typewriter`?`text-anim-${G.textAnimation}`:``}`,children:(0,K.jsx)(`span`,{style:f,className:`inline-block`,children:h})})},r)}),(0,K.jsx)(`div`,{className:`transition-all duration-500 ${G.contentPosition===`center`?L===Ze.EDITOR||Mt?`h-[25vh]`:!Hn&&!Un?`h-[50vh]`:`h-[40vh]`:`h-0`}`})]}):(0,K.jsx)(`div`,{className:`text-center text-zinc-400/50 select-none pointer-events-none`,children:!Wn&&!u&&Dt.length===0&&De!==`none`&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-4 animate-pulse`,children:[(0,K.jsx)(ge,{size:64,className:`opacity-20`}),(0,K.jsx)(`p`,{children:`Drag & drop files or load audio & lyrics to start`}),(0,K.jsx)(`p`,{className:`text-xs opacity-50`,children:`Shortcuts: 1 (Load Audio/Video), 2 (Load Lyrics), 3 (Load Font), Space (Play), S / V (Stop)`})]})})}),(0,K.jsx)(`div`,{className:`no-minimal-mode-toggle transition-all duration-500 ease-in-out overflow-hidden ${Un?`max-h-60 opacity-100 translate-y-0`:`max-h-0 opacity-0 translate-y-4`}`,children:(0,K.jsx)(`div`,{className:`bg-gradient-to-t from-black/60 via-black/30 to-transparent p-4 pb-6 lg:p-6 lg:pb-8`,children:(0,K.jsxs)(`div`,{className:`max-w-7xl mx-auto space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 group`,children:[(0,K.jsx)(`span`,{className:`text-xs text-zinc-400 font-mono w-10 text-right`,children:_t(k)}),(0,K.jsxs)(`div`,{ref:Ct,className:`flex-1 h-1 bg-zinc-700/50 rounded-full relative cursor-pointer group-hover:h-2 transition-all touch-none`,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),On(e.clientX)},onPointerMove:e=>{e.buttons===1&&On(e.clientX)},children:[(0,K.jsx)(`div`,{className:`absolute top-0 left-0 h-full bg-purple-500 rounded-full pointer-events-none`,style:{width:`${k/j*100}%`}}),(0,K.jsx)(`input`,{type:`range`,name:`progress`,id:`progress-bar`,"aria-label":`Seek Progress`,min:`0`,max:j||0,value:k,onChange:Dn,disabled:V,className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer disabled:cursor-wait pointer-events-none`})]}),(0,K.jsx)(`span`,{className:`text-xs text-zinc-400 font-mono w-10`,children:_t(j)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pl-4`,children:[(0,K.jsx)(`button`,{onClick:()=>te(!I),className:`text-zinc-400 hover:text-white`,children:I||N===0?(0,K.jsx)(Ke,{size:16}):(0,K.jsx)(Ge,{size:16})}),(0,K.jsxs)(`div`,{ref:wt,className:`w-16 h-1 bg-zinc-700/50 rounded-full relative overflow-hidden group/vol cursor-pointer touch-none`,onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),An(e.clientX)},onPointerMove:e=>{e.buttons===1&&An(e.clientX)},children:[(0,K.jsx)(`div`,{className:`absolute top-0 left-0 h-full bg-zinc-300 group-hover/vol:bg-purple-400 transition-colors pointer-events-none`,style:{width:`${I?0:N*100}%`}}),(0,K.jsx)(`input`,{type:`range`,name:`volume`,id:`volume-control`,"aria-label":`Volume Control`,min:`0`,max:`1`,step:`0.05`,value:I?0:N,onChange:kn,className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer pointer-events-none`})]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap lg:grid lg:grid-cols-[1fr_auto_1fr] items-center justify-center gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex gap-1 justify-center lg:justify-start flex-wrap order-2 lg:order-none w-auto lg:w-full`,children:[(0,K.jsxs)(`label`,{className:`p-2 rounded-lg hover:bg-white/10 text-zinc-400 hover:text-white cursor-pointer transition-colors`,title:`Load Audio or video (1)`,children:[(0,K.jsx)(ge,{size:18}),(0,K.jsx)(`input`,{type:`file`,name:`audio-file`,id:`audio-file`,accept:`audio/*,video/*`,className:`hidden`,onChange:an,disabled:V})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(`label`,{className:`p-2 rounded-lg hover:bg-white/10 cursor-pointer transition-colors ${v.length>0?`text-purple-400`:`text-zinc-400 hover:text-white`}`,title:`Load Lyrics (.lrc, .srt, .vtt, .ttml) (2)`,children:[(0,K.jsx)(ae,{size:18}),(0,K.jsx)(`input`,{type:`file`,name:`lyrics-file`,id:`lyrics-file`,accept:`.lrc,.srt,.ttml,.xml,.vtt`,className:`hidden`,onChange:cn,disabled:V})]}),v.length>0&&(0,K.jsx)(`button`,{onClick:()=>y([]),className:`p-1 rounded-full text-zinc-500 hover:text-red-400 hover:bg-white/5 transition-colors`,title:`Clear Lyrics`,disabled:V,children:(0,K.jsx)(qe,{size:14})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-zinc-800/50 rounded-lg px-2 py-1 h-9`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-zinc-300 w-12 text-center font-mono select-none border-r border-white/10 pr-2 mr-1`,children:[S>0?`+`:``,S.toFixed(1),`s`]}),(0,K.jsxs)(`div`,{className:`flex flex-col -my-1 h-full justify-center`,children:[(0,K.jsx)(`button`,{onClick:()=>C(e=>parseFloat((e+.1).toFixed(1))),className:`text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors`,title:`Increase Lyric Offset (+0.1s)`,disabled:V,children:(0,K.jsx)(F,{size:12})}),(0,K.jsx)(`button`,{onClick:()=>C(e=>parseFloat((e-.1).toFixed(1))),className:`text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors`,title:`Decrease Lyric Offset (-0.1s)`,disabled:V,children:(0,K.jsx)(P,{size:12})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(`label`,{className:`p-2 rounded-lg hover:bg-white/10 cursor-pointer transition-colors ${Me?`text-purple-400`:`text-zinc-400 hover:text-white`}`,title:Me?`Custom Font: ${Me}`:`Load Custom Font (.ttf, .otf, .woff) (3)`,children:[(0,K.jsx)(ze,{size:18}),(0,K.jsx)(`input`,{type:`file`,name:`font-file`,id:`font-file`,accept:`.ttf,.otf,.woff,.woff2`,className:`hidden`,onChange:un,disabled:V})]}),Me&&(0,K.jsx)(`button`,{onClick:()=>Ne(null),className:`p-1 rounded-full text-zinc-500 hover:text-red-400 hover:bg-white/5 transition-colors`,title:`Reset Default Font`,disabled:V,children:(0,K.jsx)(qe,{size:14})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-zinc-800/50 rounded-lg px-2 py-1 h-9`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-zinc-300 w-10 text-center font-mono select-none border-r border-white/10 pr-2 mr-1`,children:[Math.round(G.fontSizeScale*100),`%`]}),(0,K.jsxs)(`div`,{className:`flex flex-col -my-1 h-full justify-center`,children:[(0,K.jsx)(`button`,{onClick:()=>gt(e=>({...e,fontSizeScale:Math.min(e.fontSizeScale+.1,3)})),className:`text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors`,title:`Increase Font Size`,disabled:V,children:(0,K.jsx)(F,{size:12})}),(0,K.jsx)(`button`,{onClick:()=>gt(e=>({...e,fontSizeScale:Math.max(e.fontSizeScale-.1,.1)})),className:`text-zinc-400 hover:text-white flex items-center justify-center h-3.5 w-4 hover:bg-white/10 rounded-sm transition-colors`,title:`Decrease Font Size`,disabled:V,children:(0,K.jsx)(P,{size:12})})]})]}),(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsxs)(`select`,{value:De,onChange:e=>{let t=e.target.value;ke(t);let n=cp[t];if(n){let e={fontFamily:`sans-serif`,fontSizeScale:1,fontColor:`#ffffff`,fontWeight:`bold`,fontStyle:`normal`,textCase:`none`,textAlign:`center`,contentPosition:`center`,textDecoration:`none`,textEffect:`preset`,textAnimation:`none`,highlightEffect:`karaoke`,highlightColor:`#fb923c`,highlightBackground:`#fb923c`,useCustomHighlightColors:!1,lyricStyleTarget:`active-only`,transitionEffect:`none`};gt(t=>({...t,...e,...n}))}},className:`appearance-none bg-zinc-800/50 border border-white/5 text-zinc-300 text-xs rounded-lg px-3 pr-8 h-9 w-24 focus:outline-none focus:border-purple-500 cursor-pointer`,disabled:V,title:`Select Visual Preset`,name:`preset`,id:`preset-select`,"aria-label":`Visual Preset`,children:[(0,K.jsx)(`option`,{value:`custom`,className:`bg-zinc-900 font-bold text-purple-400`,children:`Custom ✨`}),(0,K.jsx)(`option`,{value:`default`,className:`bg-zinc-900`,children:`Default`}),(0,K.jsx)(`option`,{value:`large`,className:`bg-zinc-900`,children:`Big Text`}),(0,K.jsx)(`option`,{value:`large_upper`,className:`bg-zinc-900`,children:`Big Text (UP)`}),(0,K.jsx)(`option`,{value:`big_center`,className:`bg-zinc-900`,children:`Big Center`}),(0,K.jsx)(`option`,{value:`metal`,className:`bg-zinc-900`,children:`Metal`}),(0,K.jsx)(`option`,{value:`kids`,className:`bg-zinc-900`,children:`Kids`}),(0,K.jsx)(`option`,{value:`sad`,className:`bg-zinc-900`,children:`Sad`}),(0,K.jsx)(`option`,{value:`romantic`,className:`bg-zinc-900`,children:`Romantic`}),(0,K.jsx)(`option`,{value:`tech`,className:`bg-zinc-900`,children:`Tech`}),(0,K.jsx)(`option`,{value:`gothic`,className:`bg-zinc-900`,children:`Gothic`}),(0,K.jsx)(`option`,{value:`classic`,className:`bg-zinc-900`,children:`Classic Serif`}),(0,K.jsx)(`option`,{value:`monospace`,className:`bg-zinc-900`,children:`Monospace`}),(0,K.jsx)(`option`,{value:`testing_up`,className:`bg-zinc-900`,children:`Testing (UP)`}),(0,K.jsx)(`option`,{value:`testing`,className:`bg-zinc-900`,children:`Testing`}),(0,K.jsx)(`option`,{value:`one_line_up`,className:`bg-zinc-900`,children:`One Line (UP)`}),(0,K.jsx)(`option`,{value:`one_line`,className:`bg-zinc-900`,children:`One Line`}),(0,K.jsx)(`option`,{value:`slideshow`,className:`bg-zinc-900`,children:`Slideshow`}),(0,K.jsx)(`option`,{value:`just_video`,className:`bg-zinc-900`,children:`Just Video`}),(0,K.jsx)(`option`,{value:`subtitle`,className:`bg-zinc-900`,children:`Subtitle`}),(0,K.jsx)(`option`,{value:`none`,className:`bg-zinc-900`,children:`None`})]}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500`,children:(0,K.jsx)(`svg`,{className:`fill-current h-3 w-3`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,children:(0,K.jsx)(`path`,{d:`M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z`})})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 lg:gap-6 justify-center order-1 lg:order-none w-full lg:w-auto mb-2 lg:mb-0`,children:[(0,K.jsx)(`button`,{className:`text-zinc-400 hover:text-white transition-colors disabled:opacity-50`,onClick:xn,title:`Stop (S)`,disabled:V,children:(0,K.jsx)(Fe,{size:20,fill:`currentColor`})}),(0,K.jsx)(`button`,{className:`text-zinc-400 hover:text-white transition-colors disabled:opacity-50`,disabled:V||Dt.length===0,onClick:yn,title:`Previous Song`,children:(0,K.jsx)(Ae,{size:24})}),(0,K.jsx)(`button`,{className:`text-zinc-400 hover:text-white transition-colors disabled:opacity-50`,disabled:V,onClick:()=>n.current&&(n.current.currentTime-=5),title:`Rewind 5s`,children:(0,K.jsx)(we,{size:20})}),(0,K.jsx)(`button`,{onClick:bn,disabled:V,className:`w-14 h-14 flex items-center justify-center bg-white text-black rounded-full hover:scale-105 transition-transform shadow-lg shadow-purple-500/20 disabled:opacity-50 disabled:hover:scale-100`,children:T?(0,K.jsx)(ye,{size:28,fill:`currentColor`}):(0,K.jsx)(W,{size:28,fill:`currentColor`,className:`ml-1`})}),(0,K.jsx)(`button`,{className:`text-zinc-400 hover:text-white transition-colors disabled:opacity-50`,disabled:V,onClick:()=>n.current&&(n.current.currentTime+=5),title:`Fast Forward 5s`,children:(0,K.jsx)(re,{size:20})}),(0,K.jsx)(`button`,{className:`text-zinc-400 hover:text-white transition-colors disabled:opacity-50`,disabled:V||Dt.length===0,onClick:vn,title:`Next Song`,children:(0,K.jsx)(je,{size:24})}),(0,K.jsxs)(`button`,{className:`transition-colors disabled:opacity-50 ${D===`off`?`text-zinc-400 hover:text-white`:`text-green-400 hover:text-green-300`}`,onClick:Sn,title:`Repeat: ${D===`off`?`Off`:D===`one`?`One`:D===`all`?`Play All (No Repeat)`:`Loop All`} (R)`,disabled:V,children:[D===`one`&&(0,K.jsx)(Se,{size:20}),D===`all_repeat`&&(0,K.jsx)(Ce,{size:20}),D===`all`&&(0,K.jsx)(pe,{size:20}),D===`off`&&(0,K.jsx)(Ce,{size:20,className:`opacity-50`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 justify-center lg:justify-end group flex-wrap order-3 lg:order-none w-auto lg:w-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>gt(e=>({...e,lyricVisibilityMode:(e.lyricVisibilityMode??`default`)===`auto`?`default`:`auto`})),className:`bg-zinc-800/50 border border-white/5 text-[10px] font-mono rounded-lg px-2 h-9 transition-colors disabled:opacity-30 ${(G.lyricVisibilityMode??`default`)===`auto`?`text-purple-400 border-purple-500/50`:`text-zinc-300 hover:text-white`}`,title:`Lyric Visibility: ${(G.lyricVisibilityMode??`default`)===`auto`?`Auto`:`Default`}`,disabled:V,children:(G.lyricVisibilityMode??`default`)===`auto`?`AUTO`:`DEFAULT`}),(0,K.jsx)(`button`,{onClick:()=>gt(e=>({...e,backgroundBlurStrength:e.backgroundBlurStrength>0?0:12})),className:`bg-zinc-800/50 border border-white/5 text-[10px] font-mono rounded-lg px-2 h-9 transition-colors disabled:opacity-30 ${Tt?`text-purple-400 border-purple-500/50`:`text-zinc-300 hover:text-white`}`,title:`Background Blur: ${Tt?`On`:`Off`}`,disabled:V,children:Tt?`BLUR`:`SHARP`}),(0,K.jsx)(`button`,{onClick:()=>gt(e=>({...e,highlightEffect:e.highlightEffect===`none`?`karaoke`:`none`})),className:`p-2 rounded-full transition-all ${G.highlightEffect===`none`?`hover:bg-zinc-800 text-zinc-400`:`bg-orange-500 text-white shadow-[0_0_15px_rgba(249,115,22,0.5)]`}`,title:`Toggle Lyric Highlight`,children:(0,K.jsx)(ze,{size:20})}),(0,K.jsx)(`button`,{onClick:()=>Ee(e=>e===`1080p`?`720p`:`1080p`),className:`bg-zinc-800/50 border border-white/5 text-[10px] font-mono text-zinc-300 hover:text-white rounded-lg px-2 h-9 transition-colors disabled:opacity-30`,title:`Toggle Resolution (720p / 1080p)`,disabled:V,children:Te}),(0,K.jsx)(`button`,{onClick:()=>xe(e=>e===`16:9`?`9:16`:e===`9:16`?`3:4`:e===`3:4`?`1:1`:e===`1:1`?`1:2`:e===`1:2`?`2:1`:e===`2:1`?`2:3`:e===`2:3`?`3:2`:`16:9`),className:`bg-zinc-800/50 border border-white/5 text-[10px] font-mono text-zinc-300 hover:text-white rounded-lg px-2 h-9 transition-colors disabled:opacity-30`,title:`Toggle Aspect Ratio (16:9 / 9:16 / 3:4 / 1:1 / 1:2 / 2:1 / 2:3 / 3:2)`,disabled:V,children:be})]}),(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsxs)(`select`,{value:Qe,onChange:e=>$e(e.target.value),className:`appearance-none bg-zinc-800/50 border border-white/5 text-zinc-300 text-xs rounded-lg px-3 pr-8 w-26 h-9 focus:outline-none focus:border-purple-500 cursor-pointer text-ellipsis overflow-hidden`,disabled:V,title:`Select Render Engine`,name:`engine`,id:`engine-select`,"aria-label":`Render Engine`,children:[(0,K.jsx)(`option`,{value:`mediarecorder`,className:`bg-zinc-900`,children:`Realtime`}),(0,K.jsx)(`option`,{value:`webcodecs`,className:`bg-zinc-900`,children:`WebCodecs`}),(0,K.jsx)(`option`,{value:`ffmpeg`,className:`bg-zinc-900`,children:`FFMPEG`})]}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 right-0 flex items-center px-1 text-zinc-500`,children:(0,K.jsx)(`svg`,{className:`fill-current h-3 w-3`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,children:(0,K.jsx)(`path`,{d:`M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z`})})})]}),(0,K.jsx)(`button`,{onClick:Pn,disabled:V||!u,className:`p-2 rounded-lg hover:bg-white/10 text-zinc-400 hover:text-white cursor-pointer transition-colors`,title:`Export as Video (${Qe===`ffmpeg`?`FFmpeg`:`MediaRecorder`})`,children:(0,K.jsx)(We,{size:18})})]})]})]})})})]}),Mt?(0,K.jsx)(`div`,{className:`no-minimal-mode-toggle animate-slide-up border-t border-white/10 z-30 shrink-0 w-full max-w-full overflow-hidden`,children:(0,K.jsx)(np,{playlist:Dt,setPlaylist:kt,currentTrackIndex:At,setCurrentTrackIndex:jt,onPlayTrack:_n,isPlaying:T,onTogglePlay:bn,currentTime:k,onSeek:e=>{n.current&&!V&&(n.current.currentTime=e,A(e))},onClearPlaylist:()=>{xn(),d(null),y([]),jt(-1),_({title:`No Audio Loaded`,artist:`Select a file`,coverUrl:null,backgroundType:`image`})},onRemoveTrack:e=>{e===At?(xn(),d(null),y([]),jt(-1),_({title:`No Audio Loaded`,artist:`Select a file`,coverUrl:null,backgroundType:`image`})):ee-1),kt(t=>{let n=[...t];return n.splice(e,1),n})},onClose:()=>Nt(!1)})}):L===Ze.EDITOR&&(0,K.jsx)(`div`,{className:`no-minimal-mode-toggle animate-slide-up border-t border-white/10 z-30 shrink-0 w-full max-w-full overflow-hidden min-w-0`,children:(0,K.jsx)(Lt,{slides:b,setSlides:x,currentTime:k,duration:j||60,lyrics:v,onSeek:e=>{n.current&&!V&&(n.current.currentTime=e,A(e))},onClose:()=>ne(Ze.PLAYER),renderConfig:G,setRenderConfig:gt})})]}),V&&(0,K.jsxs)(`div`,{className:`absolute inset-0 z-50 bg-black/90 flex flex-col items-center justify-center p-8 text-center space-y-6`,children:[(0,K.jsx)(`div`,{className:Qe===`ffmpeg`?`animate-pulse`:`animate-bounce`,children:(0,K.jsx)(We,{size:48,className:Qe===`ffmpeg`?`text-orange-500`:`text-purple-500`})}),(0,K.jsxs)(`h2`,{className:`text-2xl font-bold text-white`,children:[Qe===`ffmpeg`?`FFmpeg Rendering`:`Rendering Video`,` (`,be,` `,Te,`)`]}),(0,K.jsx)(`p`,{className:`text-zinc-400 max-w-md`,children:Qe===`ffmpeg`?(0,K.jsxs)(K.Fragment,{children:[`Frame-by-frame capture using FFmpeg WASM.`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`span`,{className:`text-orange-400 font-medium`,children:rt||`Initializing...`}),(0,K.jsx)(`br`,{}),`This is faster than realtime - no audio playback needed.`]}):(0,K.jsxs)(K.Fragment,{children:[`Rendering in real-time using Canvas 2D engine.`,(0,K.jsx)(`br`,{}),`The audio will play during capture.`,(0,K.jsx)(`br`,{}),`Please keep this tab active for best performance.`]})}),(0,K.jsx)(`div`,{className:`w-full max-w-md h-2 bg-zinc-800 rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-300 ease-linear ${Qe===`ffmpeg`?`bg-orange-500`:`bg-purple-500`}`,style:{width:`${_e}%`}})}),(0,K.jsxs)(`p`,{className:`text-sm font-mono text-zinc-500`,children:[Math.round(_e),`%`]}),(0,K.jsxs)(`button`,{onClick:Fn,className:`mt-4 px-6 py-2 bg-red-500/20 text-red-400 hover:bg-red-500/30 hover:text-red-300 rounded-full transition-colors flex items-center gap-2 border border-red-500/50`,children:[(0,K.jsx)(Fe,{size:16,fill:`currentColor`}),`Abort Rendering`]})]}),at&&(0,K.jsx)(Rp,{config:G,setConfig:gt,preset:De,setPreset:ke,onClose:()=>ot(!1),isPlaylistMode:Mt,hasPlaylist:Dt.length>0,onRender:Pn,customFontName:Me,onFontUpload:un,onClearCustomFont:()=>{Ne(null),gt(e=>({...e,fontFamily:`ui-sans-serif, system-ui, sans-serif`}))},customChannelFontName:Pe,onChannelFontUpload:hn,onClearChannelCustomFont:()=>{Ie(null),gt(e=>({...e,channelInfoFontFamily:void 0}))},customInfoFontName:Le,onInfoFontUpload:gn,onClearInfoCustomFont:()=>{Re(null),gt(e=>({...e,infoFontFamily:void 0}))},resolution:Te,setResolution:Ee,aspectRatio:be,setAspectRatio:xe,renderCodec:Be,setRenderCodec:Ve,supportedCodecs:Et,renderQuality:Ye,setRenderQuality:Xe,renderFps:Ue,setRenderFps:Je,renderEngine:Qe,setRenderEngine:$e,ffmpegCodec:tt,setFfmpegCodec:nt}),st&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/80 backdrop-blur-sm flex items-center justify-center p-4 animate-in fade-in duration-200`,onClick:()=>ct(!1),children:(0,K.jsxs)(`div`,{className:`no-minimal-mode-toggle bg-zinc-900 border border-white/10 rounded-2xl p-6 max-w-2xl w-full max-h-[80vh] overflow-y-auto custom-scrollbar shadow-2xl relative`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{onClick:()=>ct(!1),className:`absolute top-4 right-4 p-2 rounded-full hover:bg-white/10 text-zinc-400 hover:text-white transition-colors`,children:(0,K.jsx)(qe,{size:20})}),(0,K.jsxs)(`h2`,{className:`text-2xl font-bold text-white mb-6 flex items-center gap-2`,children:[(0,K.jsx)(H,{className:`text-purple-500`}),`Keyboard Shortcuts`]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-x-12 gap-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-bold text-zinc-500 uppercase tracking-wider`,children:`Playback`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Play / Pause`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Space`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Stop`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`S / V`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Previous Song`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`B`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Next Song`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`N`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Rewind 5s`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`←`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Forward 5s`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`→`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Repeat Mode`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`R`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Mute`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`M`})]})]}),(0,K.jsx)(`h3`,{className:`text-sm font-bold text-zinc-500 uppercase tracking-wider mt-6`,children:`File Loading`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Load Audio / Video`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`1`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Load Lyrics / Sub-file`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`2`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Load Font File`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`3`})]})]}),(0,K.jsx)(`h3`,{className:`text-sm font-bold text-zinc-500 uppercase tracking-wider mt-6`,children:`Interface`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Fullscreen`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`F`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Minimal Mode`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`O`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Hold UI (No Auto-Hide)`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`H`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Header Info`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`I`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Shortcut Info`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`K`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Player`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Y`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Lyrics Visibility`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Q`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`UI Scale (Zoom / Reset)`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`8 / 9 / 0`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-bold text-zinc-500 uppercase tracking-wider`,children:`Editor & Styles`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Timeline`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`T`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Playlist`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`P`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Render Settings`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`D`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Random Settings`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`L`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Export Video`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Ctrl+Shift+E`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Font Size`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`+ / -`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Cycle Visual Preset`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`J`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Cycle Highight Effect`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Z`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Highlight`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`X`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Cycle Text Case`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`C`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Cycle Lyric Mode`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`G`})]})]}),(0,K.jsx)(`h3`,{className:`text-sm font-bold text-zinc-500 uppercase tracking-wider mt-6`,children:`Mouse & Touch`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Toggle Minimal Mode`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Double Click / Tap`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Seek to Lyric`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Click Line`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-300`,children:`Copy Active Lyric`}),` `,(0,K.jsx)(`span`,{className:`font-mono text-purple-400 bg-white/5 px-2 py-0.5 rounded`,children:`Click Active Line`})]})]})]})]}),(0,K.jsx)(`div`,{className:`mt-8 pt-6 border-t border-white/5 text-center`,children:(0,K.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:`Shortcuts are disabled during video rendering.`})})]})})]})}var oO=document.getElementById(`root`);if(!oO)throw Error(`Could not find root element to mount to`);Xe.createRoot(oO).render((0,K.jsx)(w.StrictMode,{children:(0,K.jsx)(kt,{children:(0,K.jsx)(aO,{})})}));export{l as n,o as t}; \ No newline at end of file