var K4e=Object.defineProperty;var J4e=(n,e,t)=>e in n?K4e(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ha=(n,e,t)=>J4e(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function t(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=t(i);fetch(i.href,s)}})();var kb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Zde={exports:{}},a7={},Qde={exports:{}},ls={};/** * @license React * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var PS=Symbol.for("react.element"),eSe=Symbol.for("react.portal"),tSe=Symbol.for("react.fragment"),nSe=Symbol.for("react.strict_mode"),rSe=Symbol.for("react.profiler"),iSe=Symbol.for("react.provider"),sSe=Symbol.for("react.context"),aSe=Symbol.for("react.forward_ref"),oSe=Symbol.for("react.suspense"),lSe=Symbol.for("react.memo"),cSe=Symbol.for("react.lazy"),XY=Symbol.iterator;function uSe(n){return n===null||typeof n!="object"?null:(n=XY&&n[XY]||n["@@iterator"],typeof n=="function"?n:null)}var Kde={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Jde=Object.assign,ehe={};function y3(n,e,t){this.props=n,this.context=e,this.refs=ehe,this.updater=t||Kde}y3.prototype.isReactComponent={};y3.prototype.setState=function(n,e){if(typeof n!="object"&&typeof n!="function"&&n!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,n,e,"setState")};y3.prototype.forceUpdate=function(n){this.updater.enqueueForceUpdate(this,n,"forceUpdate")};function the(){}the.prototype=y3.prototype;function Dq(n,e,t){this.props=n,this.context=e,this.refs=ehe,this.updater=t||Kde}var Oq=Dq.prototype=new the;Oq.constructor=Dq;Jde(Oq,y3.prototype);Oq.isPureReactComponent=!0;var YY=Array.isArray,nhe=Object.prototype.hasOwnProperty,jq={current:null},rhe={key:!0,ref:!0,__self:!0,__source:!0};function ihe(n,e,t){var r,i={},s=null,a=null;if(e!=null)for(r in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(s=""+e.key),e)nhe.call(e,r)&&!rhe.hasOwnProperty(r)&&(i[r]=e[r]);var o=arguments.length-2;if(o===1)i.children=t;else if(1>>1,ee=Q[fe];if(0>>1;fei(be,oe))pei(ge,be)?(Q[fe]=ge,Q[pe]=oe,fe=pe):(Q[fe]=be,Q[Ae]=oe,fe=Ae);else if(pei(ge,oe))Q[fe]=ge,Q[pe]=oe,fe=pe;else break e}}return re}function i(Q,re){var oe=Q.sortIndex-re.sortIndex;return oe!==0?oe:Q.id-re.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();n.unstable_now=function(){return a.now()-o}}var l=[],c=[],u=1,d=null,h=3,p=!1,g=!1,x=!1,_=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(Q){for(var re=t(c);re!==null;){if(re.callback===null)r(c);else if(re.startTime<=Q)r(c),re.sortIndex=re.expirationTime,e(l,re);else break;re=t(c)}}function k(Q){if(x=!1,C(Q),!g)if(t(l)!==null)g=!0,ie(B);else{var re=t(c);re!==null&&ae(k,re.startTime-Q)}}function B(Q,re){g=!1,x&&(x=!1,y(O),O=-1),p=!0;var oe=h;try{for(C(re),d=t(l);d!==null&&(!(d.expirationTime>re)||Q&&!G());){var fe=d.callback;if(typeof fe=="function"){d.callback=null,h=d.priorityLevel;var ee=fe(d.expirationTime<=re);re=n.unstable_now(),typeof ee=="function"?d.callback=ee:d===t(l)&&r(l),C(re)}else r(l);d=t(l)}if(d!==null)var me=!0;else{var Ae=t(c);Ae!==null&&ae(k,Ae.startTime-re),me=!1}return me}finally{d=null,h=oe,p=!1}}var U=!1,z=null,O=-1,V=5,$=-1;function G(){return!(n.unstable_now()-$Q||125fe?(Q.sortIndex=oe,e(c,Q),t(l)===null&&Q===t(c)&&(x?(y(O),O=-1):x=!0,ae(k,oe-fe))):(Q.sortIndex=ee,e(l,Q),g||p||(g=!0,ie(B))),Q},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(Q){var re=h;return function(){var oe=h;h=re;try{return Q.apply(this,arguments)}finally{h=oe}}}})(che);lhe.exports=che;var bSe=lhe.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var _Se=de,af=bSe;function Bn(n){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+n,t=1;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),QB=Object.prototype.hasOwnProperty,wSe=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,QY={},KY={};function SSe(n){return QB.call(KY,n)?!0:QB.call(QY,n)?!1:wSe.test(n)?KY[n]=!0:(QY[n]=!0,!1)}function TSe(n,e,t,r){if(t!==null&&t.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:t!==null?!t.acceptsBooleans:(n=n.toLowerCase().slice(0,5),n!=="data-"&&n!=="aria-");default:return!1}}function ESe(n,e,t,r){if(e===null||typeof e>"u"||TSe(n,e,t,r))return!0;if(r)return!1;if(t!==null)switch(t.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Ud(n,e,t,r,i,s,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=t,this.propertyName=n,this.type=e,this.sanitizeURL=s,this.removeEmptyString=a}var yu={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(n){yu[n]=new Ud(n,0,!1,n,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(n){var e=n[0];yu[e]=new Ud(e,1,!1,n[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(n){yu[n]=new Ud(n,2,!1,n.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(n){yu[n]=new Ud(n,2,!1,n,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(n){yu[n]=new Ud(n,3,!1,n.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(n){yu[n]=new Ud(n,3,!0,n,null,!1,!1)});["capture","download"].forEach(function(n){yu[n]=new Ud(n,4,!1,n,null,!1,!1)});["cols","rows","size","span"].forEach(function(n){yu[n]=new Ud(n,6,!1,n,null,!1,!1)});["rowSpan","start"].forEach(function(n){yu[n]=new Ud(n,5,!1,n.toLowerCase(),null,!1,!1)});var Bq=/[\-:]([a-z])/g;function Uq(n){return n[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(n){var e=n.replace(Bq,Uq);yu[e]=new Ud(e,1,!1,n,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(n){var e=n.replace(Bq,Uq);yu[e]=new Ud(e,1,!1,n,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(n){var e=n.replace(Bq,Uq);yu[e]=new Ud(e,1,!1,n,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(n){yu[n]=new Ud(n,1,!1,n.toLowerCase(),null,!1,!1)});yu.xlinkHref=new Ud("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(n){yu[n]=new Ud(n,1,!1,n.toLowerCase(),null,!0,!0)});function zq(n,e,t,r){var i=yu.hasOwnProperty(e)?yu[e]:null;(i!==null?i.type!==0:r||!(2o||i[a]!==s[o]){var l=` `+i[a].replace(" at new "," at ");return n.displayName&&l.includes("")&&(l=l.replace("",n.displayName)),l}while(1<=a&&0<=o);break}}}finally{pL=!1,Error.prepareStackTrace=t}return(n=n?n.displayName||n.name:"")?m5(n):""}function NSe(n){switch(n.tag){case 5:return m5(n.type);case 16:return m5("Lazy");case 13:return m5("Suspense");case 19:return m5("SuspenseList");case 0:case 2:case 15:return n=mL(n.type,!1),n;case 11:return n=mL(n.type.render,!1),n;case 1:return n=mL(n.type,!0),n;default:return""}}function tU(n){if(n==null)return null;if(typeof n=="function")return n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case Db:return"Fragment";case Ib:return"Portal";case KB:return"Profiler";case Vq:return"StrictMode";case JB:return"Suspense";case eU:return"SuspenseList"}if(typeof n=="object")switch(n.$$typeof){case hhe:return(n.displayName||"Context")+".Consumer";case dhe:return(n._context.displayName||"Context")+".Provider";case qq:var e=n.render;return n=n.displayName,n||(n=e.displayName||e.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case Gq:return e=n.displayName||null,e!==null?e:tU(n.type)||"Memo";case U1:e=n._payload,n=n._init;try{return tU(n(e))}catch{}}return null}function MSe(n){var e=n.type;switch(n.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return n=e.render,n=n.displayName||n.name||"",e.displayName||(n!==""?"ForwardRef("+n+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return tU(e);case 8:return e===Vq?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function kA(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function phe(n){var e=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function CSe(n){var e=phe(n)?"checked":"value",t=Object.getOwnPropertyDescriptor(n.constructor.prototype,e),r=""+n[e];if(!n.hasOwnProperty(e)&&typeof t<"u"&&typeof t.get=="function"&&typeof t.set=="function"){var i=t.get,s=t.set;return Object.defineProperty(n,e,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,s.call(this,a)}}),Object.defineProperty(n,e,{enumerable:t.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){n._valueTracker=null,delete n[e]}}}}function j6(n){n._valueTracker||(n._valueTracker=CSe(n))}function mhe(n){if(!n)return!1;var e=n._valueTracker;if(!e)return!0;var t=e.getValue(),r="";return n&&(r=phe(n)?n.checked?"true":"false":n.value),n=r,n!==t?(e.setValue(n),!0):!1}function jN(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}function nU(n,e){var t=e.checked;return Go({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:t??n._wrapperState.initialChecked})}function eZ(n,e){var t=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;t=kA(e.value!=null?e.value:t),n._wrapperState={initialChecked:r,initialValue:t,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function ghe(n,e){e=e.checked,e!=null&&zq(n,"checked",e,!1)}function rU(n,e){ghe(n,e);var t=kA(e.value),r=e.type;if(t!=null)r==="number"?(t===0&&n.value===""||n.value!=t)&&(n.value=""+t):n.value!==""+t&&(n.value=""+t);else if(r==="submit"||r==="reset"){n.removeAttribute("value");return}e.hasOwnProperty("value")?iU(n,e.type,t):e.hasOwnProperty("defaultValue")&&iU(n,e.type,kA(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(n.defaultChecked=!!e.defaultChecked)}function tZ(n,e,t){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+n._wrapperState.initialValue,t||e===n.value||(n.value=e),n.defaultValue=e}t=n.name,t!==""&&(n.name=""),n.defaultChecked=!!n._wrapperState.initialChecked,t!==""&&(n.name=t)}function iU(n,e,t){(e!=="number"||jN(n.ownerDocument)!==n)&&(t==null?n.defaultValue=""+n._wrapperState.initialValue:n.defaultValue!==""+t&&(n.defaultValue=""+t))}var g5=Array.isArray;function a_(n,e,t,r){if(n=n.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=F6.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;e.firstChild;)n.appendChild(e.firstChild)}});function N4(n,e){if(e){var t=n.firstChild;if(t&&t===n.lastChild&&t.nodeType===3){t.nodeValue=e;return}}n.textContent=e}var q5={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},PSe=["Webkit","ms","Moz","O"];Object.keys(q5).forEach(function(n){PSe.forEach(function(e){e=e+n.charAt(0).toUpperCase()+n.substring(1),q5[e]=q5[n]})});function yhe(n,e,t){return e==null||typeof e=="boolean"||e===""?"":t||typeof e!="number"||e===0||q5.hasOwnProperty(n)&&q5[n]?(""+e).trim():e+"px"}function bhe(n,e){n=n.style;for(var t in e)if(e.hasOwnProperty(t)){var r=t.indexOf("--")===0,i=yhe(t,e[t],r);t==="float"&&(t="cssFloat"),r?n.setProperty(t,i):n[t]=i}}var RSe=Go({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function oU(n,e){if(e){if(RSe[n]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Bn(137,n));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Bn(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Bn(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Bn(62))}}function lU(n,e){if(n.indexOf("-")===-1)return typeof e.is=="string";switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var cU=null;function Hq(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var uU=null,o_=null,l_=null;function iZ(n){if(n=kS(n)){if(typeof uU!="function")throw Error(Bn(280));var e=n.stateNode;e&&(e=d7(e),uU(n.stateNode,n.type,e))}}function _he(n){o_?l_?l_.push(n):l_=[n]:o_=n}function whe(){if(o_){var n=o_,e=l_;if(l_=o_=null,iZ(n),e)for(n=0;n>>=0,n===0?32:31-(VSe(n)/qSe|0)|0}var B6=64,U6=4194304;function A5(n){switch(n&-n){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: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 n&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return n&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function zN(n,e){var t=n.pendingLanes;if(t===0)return 0;var r=0,i=n.suspendedLanes,s=n.pingedLanes,a=t&268435455;if(a!==0){var o=a&~i;o!==0?r=A5(o):(s&=a,s!==0&&(r=A5(s)))}else a=t&~i,a!==0?r=A5(a):s!==0&&(r=A5(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=t&16),e=n.entangledLanes,e!==0)for(n=n.entanglements,e&=r;0t;t++)e.push(n);return e}function RS(n,e,t){n.pendingLanes|=e,e!==536870912&&(n.suspendedLanes=0,n.pingedLanes=0),n=n.eventTimes,e=31-B0(e),n[e]=t}function WSe(n,e){var t=n.pendingLanes&~e;n.pendingLanes=e,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=e,n.mutableReadLanes&=e,n.entangledLanes&=e,e=n.entanglements;var r=n.eventTimes;for(n=n.expirationTimes;0=H5),fZ=" ",pZ=!1;function qhe(n,e){switch(n){case"keyup":return b6e.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ghe(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var Ob=!1;function w6e(n,e){switch(n){case"compositionend":return Ghe(e);case"keypress":return e.which!==32?null:(pZ=!0,fZ);case"textInput":return n=e.data,n===fZ&&pZ?null:n;default:return null}}function S6e(n,e){if(Ob)return n==="compositionend"||!Jq&&qhe(n,e)?(n=zhe(),qE=Zq=iA=null,Ob=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:t,offset:e-n};n=r}e:{for(;t;){if(t.nextSibling){t=t.nextSibling;break e}t=t.parentNode}t=void 0}t=xZ(t)}}function Xhe(n,e){return n&&e?n===e?!0:n&&n.nodeType===3?!1:e&&e.nodeType===3?Xhe(n,e.parentNode):"contains"in n?n.contains(e):n.compareDocumentPosition?!!(n.compareDocumentPosition(e)&16):!1:!1}function Yhe(){for(var n=window,e=jN();e instanceof n.HTMLIFrameElement;){try{var t=typeof e.contentWindow.location.href=="string"}catch{t=!1}if(t)n=e.contentWindow;else break;e=jN(n.document)}return e}function eG(n){var e=n&&n.nodeName&&n.nodeName.toLowerCase();return e&&(e==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||e==="textarea"||n.contentEditable==="true")}function k6e(n){var e=Yhe(),t=n.focusedElem,r=n.selectionRange;if(e!==t&&t&&t.ownerDocument&&Xhe(t.ownerDocument.documentElement,t)){if(r!==null&&eG(t)){if(e=r.start,n=r.end,n===void 0&&(n=e),"selectionStart"in t)t.selectionStart=e,t.selectionEnd=Math.min(n,t.value.length);else if(n=(e=t.ownerDocument||document)&&e.defaultView||window,n.getSelection){n=n.getSelection();var i=t.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!n.extend&&s>r&&(i=r,r=s,s=i),i=vZ(t,s);var a=vZ(t,r);i&&a&&(n.rangeCount!==1||n.anchorNode!==i.node||n.anchorOffset!==i.offset||n.focusNode!==a.node||n.focusOffset!==a.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),n.removeAllRanges(),s>r?(n.addRange(e),n.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),n.addRange(e)))}}for(e=[],n=t;n=n.parentNode;)n.nodeType===1&&e.push({element:n,left:n.scrollLeft,top:n.scrollTop});for(typeof t.focus=="function"&&t.focus(),t=0;t=document.documentMode,jb=null,gU=null,W5=null,AU=!1;function yZ(n,e,t){var r=t.window===t?t.document:t.nodeType===9?t:t.ownerDocument;AU||jb==null||jb!==jN(r)||(r=jb,"selectionStart"in r&&eG(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}),W5&&k4(W5,r)||(W5=r,r=GN(gU,"onSelect"),0Ub||(n.current=wU[Ub],wU[Ub]=null,Ub--)}function Ha(n,e){Ub++,wU[Ub]=n.current,n.current=e}var IA={},od=ZA(IA),oh=ZA(!1),Wx=IA;function C_(n,e){var t=n.type.contextTypes;if(!t)return IA;var r=n.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in t)i[s]=e[s];return r&&(n=n.stateNode,n.__reactInternalMemoizedUnmaskedChildContext=e,n.__reactInternalMemoizedMaskedChildContext=i),i}function lh(n){return n=n.childContextTypes,n!=null}function $N(){lo(oh),lo(od)}function NZ(n,e,t){if(od.current!==IA)throw Error(Bn(168));Ha(od,e),Ha(oh,t)}function ife(n,e,t){var r=n.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return t;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(Bn(108,MSe(n)||"Unknown",i));return Go({},t,r)}function WN(n){return n=(n=n.stateNode)&&n.__reactInternalMemoizedMergedChildContext||IA,Wx=od.current,Ha(od,n),Ha(oh,oh.current),!0}function MZ(n,e,t){var r=n.stateNode;if(!r)throw Error(Bn(169));t?(n=ife(n,e,Wx),r.__reactInternalMemoizedMergedChildContext=n,lo(oh),lo(od),Ha(od,n)):lo(oh),Ha(oh,t)}var Zm=null,h7=!1,CL=!1;function sfe(n){Zm===null?Zm=[n]:Zm.push(n)}function H6e(n){h7=!0,sfe(n)}function QA(){if(!CL&&Zm!==null){CL=!0;var n=0,e=ga;try{var t=Zm;for(ga=1;n>=a,i-=a,ig=1<<32-B0(e)+i|t<O?(V=z,z=null):V=z.sibling;var $=h(y,z,C[O],k);if($===null){z===null&&(z=V);break}n&&z&&$.alternate===null&&e(y,z),M=s($,M,O),U===null?B=$:U.sibling=$,U=$,z=V}if(O===C.length)return t(y,z),_o&&tx(y,O),B;if(z===null){for(;OO?(V=z,z=null):V=z.sibling;var G=h(y,z,$.value,k);if(G===null){z===null&&(z=V);break}n&&z&&G.alternate===null&&e(y,z),M=s(G,M,O),U===null?B=G:U.sibling=G,U=G,z=V}if($.done)return t(y,z),_o&&tx(y,O),B;if(z===null){for(;!$.done;O++,$=C.next())$=d(y,$.value,k),$!==null&&(M=s($,M,O),U===null?B=$:U.sibling=$,U=$);return _o&&tx(y,O),B}for(z=r(y,z);!$.done;O++,$=C.next())$=p(z,y,O,$.value,k),$!==null&&(n&&$.alternate!==null&&z.delete($.key===null?O:$.key),M=s($,M,O),U===null?B=$:U.sibling=$,U=$);return n&&z.forEach(function(H){return e(y,H)}),_o&&tx(y,O),B}function _(y,M,C,k){if(typeof C=="object"&&C!==null&&C.type===Db&&C.key===null&&(C=C.props.children),typeof C=="object"&&C!==null){switch(C.$$typeof){case O6:e:{for(var B=C.key,U=M;U!==null;){if(U.key===B){if(B=C.type,B===Db){if(U.tag===7){t(y,U.sibling),M=i(U,C.props.children),M.return=y,y=M;break e}}else if(U.elementType===B||typeof B=="object"&&B!==null&&B.$$typeof===U1&&RZ(B)===U.type){t(y,U.sibling),M=i(U,C.props),M.ref=cw(y,U,C),M.return=y,y=M;break e}t(y,U);break}else e(y,U);U=U.sibling}C.type===Db?(M=Lx(C.props.children,y.mode,k,C.key),M.return=y,y=M):(k=QE(C.type,C.key,C.props,null,y.mode,k),k.ref=cw(y,M,C),k.return=y,y=k)}return a(y);case Ib:e:{for(U=C.key;M!==null;){if(M.key===U)if(M.tag===4&&M.stateNode.containerInfo===C.containerInfo&&M.stateNode.implementation===C.implementation){t(y,M.sibling),M=i(M,C.children||[]),M.return=y,y=M;break e}else{t(y,M);break}else e(y,M);M=M.sibling}M=jL(C,y.mode,k),M.return=y,y=M}return a(y);case U1:return U=C._init,_(y,M,U(C._payload),k)}if(g5(C))return g(y,M,C,k);if(iw(C))return x(y,M,C,k);W6(y,C)}return typeof C=="string"&&C!==""||typeof C=="number"?(C=""+C,M!==null&&M.tag===6?(t(y,M.sibling),M=i(M,C),M.return=y,y=M):(t(y,M),M=OL(C,y.mode,k),M.return=y,y=M),a(y)):t(y,M)}return _}var R_=cfe(!0),ufe=cfe(!1),ZN=ZA(null),QN=null,qb=null,iG=null;function sG(){iG=qb=QN=null}function aG(n){var e=ZN.current;lo(ZN),n._currentValue=e}function EU(n,e,t){for(;n!==null;){var r=n.alternate;if((n.childLanes&e)!==e?(n.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),n===t)break;n=n.return}}function u_(n,e){QN=n,iG=qb=null,n=n.dependencies,n!==null&&n.firstContext!==null&&(n.lanes&e&&(rh=!0),n.firstContext=null)}function Qf(n){var e=n._currentValue;if(iG!==n)if(n={context:n,memoizedValue:e,next:null},qb===null){if(QN===null)throw Error(Bn(308));qb=n,QN.dependencies={lanes:0,firstContext:n}}else qb=qb.next=n;return e}var Ax=null;function oG(n){Ax===null?Ax=[n]:Ax.push(n)}function dfe(n,e,t,r){var i=e.interleaved;return i===null?(t.next=t,oG(e)):(t.next=i.next,i.next=t),e.interleaved=t,Ng(n,r)}function Ng(n,e){n.lanes|=e;var t=n.alternate;for(t!==null&&(t.lanes|=e),t=n,n=n.return;n!==null;)n.childLanes|=e,t=n.alternate,t!==null&&(t.childLanes|=e),t=n,n=n.return;return t.tag===3?t.stateNode:null}var z1=!1;function lG(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function hfe(n,e){n=n.updateQueue,e.updateQueue===n&&(e.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,effects:n.effects})}function hg(n,e){return{eventTime:n,lane:e,tag:0,payload:null,callback:null,next:null}}function AA(n,e,t){var r=n.updateQueue;if(r===null)return null;if(r=r.shared,Is&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Ng(n,t)}return i=r.interleaved,i===null?(e.next=e,oG(r)):(e.next=i.next,i.next=e),r.interleaved=e,Ng(n,t)}function HE(n,e,t){if(e=e.updateQueue,e!==null&&(e=e.shared,(t&4194240)!==0)){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,Wq(n,t)}}function LZ(n,e){var t=n.updateQueue,r=n.alternate;if(r!==null&&(r=r.updateQueue,t===r)){var i=null,s=null;if(t=t.firstBaseUpdate,t!==null){do{var a={eventTime:t.eventTime,lane:t.lane,tag:t.tag,payload:t.payload,callback:t.callback,next:null};s===null?i=s=a:s=s.next=a,t=t.next}while(t!==null);s===null?i=s=e:s=s.next=e}else i=s=e;t={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},n.updateQueue=t;return}n=t.lastBaseUpdate,n===null?t.firstBaseUpdate=e:n.next=e,t.lastBaseUpdate=e}function KN(n,e,t,r){var i=n.updateQueue;z1=!1;var s=i.firstBaseUpdate,a=i.lastBaseUpdate,o=i.shared.pending;if(o!==null){i.shared.pending=null;var l=o,c=l.next;l.next=null,a===null?s=c:a.next=c,a=l;var u=n.alternate;u!==null&&(u=u.updateQueue,o=u.lastBaseUpdate,o!==a&&(o===null?u.firstBaseUpdate=c:o.next=c,u.lastBaseUpdate=l))}if(s!==null){var d=i.baseState;a=0,u=c=l=null,o=s;do{var h=o.lane,p=o.eventTime;if((r&h)===h){u!==null&&(u=u.next={eventTime:p,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var g=n,x=o;switch(h=e,p=t,x.tag){case 1:if(g=x.payload,typeof g=="function"){d=g.call(p,d,h);break e}d=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=x.payload,h=typeof g=="function"?g.call(p,d,h):g,h==null)break e;d=Go({},d,h);break e;case 2:z1=!0}}o.callback!==null&&o.lane!==0&&(n.flags|=64,h=i.effects,h===null?i.effects=[o]:h.push(o))}else p={eventTime:p,lane:h,tag:o.tag,payload:o.payload,callback:o.callback,next:null},u===null?(c=u=p,l=d):u=u.next=p,a|=h;if(o=o.next,o===null){if(o=i.shared.pending,o===null)break;h=o,o=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(u===null&&(l=d),i.baseState=l,i.firstBaseUpdate=c,i.lastBaseUpdate=u,e=i.shared.interleaved,e!==null){i=e;do a|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);Zx|=a,n.lanes=a,n.memoizedState=d}}function kZ(n,e,t){if(n=e.effects,e.effects=null,n!==null)for(e=0;et?t:4,n(!0);var r=RL.transition;RL.transition={};try{n(!1),e()}finally{ga=t,RL.transition=r}}function Cfe(){return Kf().memoizedState}function Y6e(n,e,t){var r=vA(n);if(t={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null},Pfe(n))Rfe(e,t);else if(t=dfe(n,e,t,r),t!==null){var i=Dd();U0(t,n,r,i),Lfe(t,e,r)}}function Z6e(n,e,t){var r=vA(n),i={lane:r,action:t,hasEagerState:!1,eagerState:null,next:null};if(Pfe(n))Rfe(e,i);else{var s=n.alternate;if(n.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var a=e.lastRenderedState,o=s(a,t);if(i.hasEagerState=!0,i.eagerState=o,W0(o,a)){var l=e.interleaved;l===null?(i.next=i,oG(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}finally{}t=dfe(n,e,i,r),t!==null&&(i=Dd(),U0(t,n,r,i),Lfe(t,e,r))}}function Pfe(n){var e=n.alternate;return n===Uo||e!==null&&e===Uo}function Rfe(n,e){X5=eM=!0;var t=n.pending;t===null?e.next=e:(e.next=t.next,t.next=e),n.pending=e}function Lfe(n,e,t){if(t&4194240){var r=e.lanes;r&=n.pendingLanes,t|=r,e.lanes=t,Wq(n,t)}}var tM={readContext:Qf,useCallback:Iu,useContext:Iu,useEffect:Iu,useImperativeHandle:Iu,useInsertionEffect:Iu,useLayoutEffect:Iu,useMemo:Iu,useReducer:Iu,useRef:Iu,useState:Iu,useDebugValue:Iu,useDeferredValue:Iu,useTransition:Iu,useMutableSource:Iu,useSyncExternalStore:Iu,useId:Iu,unstable_isNewReconciler:!1},Q6e={readContext:Qf,useCallback:function(n,e){return jp().memoizedState=[n,e===void 0?null:e],n},useContext:Qf,useEffect:DZ,useImperativeHandle:function(n,e,t){return t=t!=null?t.concat([n]):null,WE(4194308,4,Sfe.bind(null,e,n),t)},useLayoutEffect:function(n,e){return WE(4194308,4,n,e)},useInsertionEffect:function(n,e){return WE(4,2,n,e)},useMemo:function(n,e){var t=jp();return e=e===void 0?null:e,n=n(),t.memoizedState=[n,e],n},useReducer:function(n,e,t){var r=jp();return e=t!==void 0?t(e):e,r.memoizedState=r.baseState=e,n={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:e},r.queue=n,n=n.dispatch=Y6e.bind(null,Uo,n),[r.memoizedState,n]},useRef:function(n){var e=jp();return n={current:n},e.memoizedState=n},useState:IZ,useDebugValue:gG,useDeferredValue:function(n){return jp().memoizedState=n},useTransition:function(){var n=IZ(!1),e=n[0];return n=X6e.bind(null,n[1]),jp().memoizedState=n,[e,n]},useMutableSource:function(){},useSyncExternalStore:function(n,e,t){var r=Uo,i=jp();if(_o){if(t===void 0)throw Error(Bn(407));t=t()}else{if(t=e(),Uc===null)throw Error(Bn(349));Yx&30||gfe(r,e,t)}i.memoizedState=t;var s={value:t,getSnapshot:e};return i.queue=s,DZ(xfe.bind(null,r,s,n),[n]),r.flags|=2048,z4(9,Afe.bind(null,r,s,t,e),void 0,null),t},useId:function(){var n=jp(),e=Uc.identifierPrefix;if(_o){var t=sg,r=ig;t=(r&~(1<<32-B0(r)-1)).toString(32)+t,e=":"+e+"R"+t,t=B4++,0<\/script>",n=n.removeChild(n.firstChild)):typeof r.is=="string"?n=a.createElement(t,{is:r.is}):(n=a.createElement(t),t==="select"&&(a=n,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):n=a.createElementNS(n,t),n[Vp]=e,n[O4]=r,Vfe(n,e,!1,!1),e.stateNode=n;e:{switch(a=lU(t,r),t){case"dialog":ro("cancel",n),ro("close",n),i=r;break;case"iframe":case"object":case"embed":ro("load",n),i=r;break;case"video":case"audio":for(i=0;iI_&&(e.flags|=128,r=!0,uw(s,!1),e.lanes=4194304)}else{if(!r)if(n=JN(a),n!==null){if(e.flags|=128,r=!0,t=n.updateQueue,t!==null&&(e.updateQueue=t,e.flags|=4),uw(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!_o)return Du(e),null}else 2*Cl()-s.renderingStartTime>I_&&t!==1073741824&&(e.flags|=128,r=!0,uw(s,!1),e.lanes=4194304);s.isBackwards?(a.sibling=e.child,e.child=a):(t=s.last,t!==null?t.sibling=a:e.child=a,s.last=a)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Cl(),e.sibling=null,t=jo.current,Ha(jo,r?t&1|2:t&1),e):(Du(e),null);case 22:case 23:return _G(),r=e.memoizedState!==null,n!==null&&n.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?zh&1073741824&&(Du(e),e.subtreeFlags&6&&(e.flags|=8192)):Du(e),null;case 24:return null;case 25:return null}throw Error(Bn(156,e.tag))}function sTe(n,e){switch(nG(e),e.tag){case 1:return lh(e.type)&&$N(),n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 3:return L_(),lo(oh),lo(od),dG(),n=e.flags,n&65536&&!(n&128)?(e.flags=n&-65537|128,e):null;case 5:return uG(e),null;case 13:if(lo(jo),n=e.memoizedState,n!==null&&n.dehydrated!==null){if(e.alternate===null)throw Error(Bn(340));P_()}return n=e.flags,n&65536?(e.flags=n&-65537|128,e):null;case 19:return lo(jo),null;case 4:return L_(),null;case 10:return aG(e.type._context),null;case 22:case 23:return _G(),null;case 24:return null;default:return null}}var Y6=!1,Ku=!1,aTe=typeof WeakSet=="function"?WeakSet:Set,vr=null;function Gb(n,e){var t=n.ref;if(t!==null)if(typeof t=="function")try{t(null)}catch(r){hl(n,e,r)}else t.current=null}function DU(n,e,t){try{t()}catch(r){hl(n,e,r)}}var $Z=!1;function oTe(n,e){if(xU=VN,n=Yhe(),eG(n)){if("selectionStart"in n)var t={start:n.selectionStart,end:n.selectionEnd};else e:{t=(t=n.ownerDocument)&&t.defaultView||window;var r=t.getSelection&&t.getSelection();if(r&&r.rangeCount!==0){t=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{t.nodeType,s.nodeType}catch{t=null;break e}var a=0,o=-1,l=-1,c=0,u=0,d=n,h=null;t:for(;;){for(var p;d!==t||i!==0&&d.nodeType!==3||(o=a+i),d!==s||r!==0&&d.nodeType!==3||(l=a+r),d.nodeType===3&&(a+=d.nodeValue.length),(p=d.firstChild)!==null;)h=d,d=p;for(;;){if(d===n)break t;if(h===t&&++c===i&&(o=a),h===s&&++u===r&&(l=a),(p=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=p}t=o===-1||l===-1?null:{start:o,end:l}}else t=null}t=t||{start:0,end:0}}else t=null;for(vU={focusedElem:n,selectionRange:t},VN=!1,vr=e;vr!==null;)if(e=vr,n=e.child,(e.subtreeFlags&1028)!==0&&n!==null)n.return=e,vr=n;else for(;vr!==null;){e=vr;try{var g=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var x=g.memoizedProps,_=g.memoizedState,y=e.stateNode,M=y.getSnapshotBeforeUpdate(e.elementType===e.type?x:N0(e.type,x),_);y.__reactInternalSnapshotBeforeUpdate=M}break;case 3:var C=e.stateNode.containerInfo;C.nodeType===1?C.textContent="":C.nodeType===9&&C.documentElement&&C.removeChild(C.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Bn(163))}}catch(k){hl(e,e.return,k)}if(n=e.sibling,n!==null){n.return=e.return,vr=n;break}vr=e.return}return g=$Z,$Z=!1,g}function Y5(n,e,t){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&n)===n){var s=i.destroy;i.destroy=void 0,s!==void 0&&DU(e,t,s)}i=i.next}while(i!==r)}}function m7(n,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var t=e=e.next;do{if((t.tag&n)===n){var r=t.create;t.destroy=r()}t=t.next}while(t!==e)}}function OU(n){var e=n.ref;if(e!==null){var t=n.stateNode;switch(n.tag){case 5:n=t;break;default:n=t}typeof e=="function"?e(n):e.current=n}}function Hfe(n){var e=n.alternate;e!==null&&(n.alternate=null,Hfe(e)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(e=n.stateNode,e!==null&&(delete e[Vp],delete e[O4],delete e[_U],delete e[q6e],delete e[G6e])),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}function $fe(n){return n.tag===5||n.tag===3||n.tag===4}function WZ(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||$fe(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function jU(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.nodeType===8?t.parentNode.insertBefore(n,e):t.insertBefore(n,e):(t.nodeType===8?(e=t.parentNode,e.insertBefore(n,t)):(e=t,e.appendChild(n)),t=t._reactRootContainer,t!=null||e.onclick!==null||(e.onclick=HN));else if(r!==4&&(n=n.child,n!==null))for(jU(n,e,t),n=n.sibling;n!==null;)jU(n,e,t),n=n.sibling}function FU(n,e,t){var r=n.tag;if(r===5||r===6)n=n.stateNode,e?t.insertBefore(n,e):t.appendChild(n);else if(r!==4&&(n=n.child,n!==null))for(FU(n,e,t),n=n.sibling;n!==null;)FU(n,e,t),n=n.sibling}var cu=null,M0=!1;function m1(n,e,t){for(t=t.child;t!==null;)Wfe(n,e,t),t=t.sibling}function Wfe(n,e,t){if(em&&typeof em.onCommitFiberUnmount=="function")try{em.onCommitFiberUnmount(o7,t)}catch{}switch(t.tag){case 5:Ku||Gb(t,e);case 6:var r=cu,i=M0;cu=null,m1(n,e,t),cu=r,M0=i,cu!==null&&(M0?(n=cu,t=t.stateNode,n.nodeType===8?n.parentNode.removeChild(t):n.removeChild(t)):cu.removeChild(t.stateNode));break;case 18:cu!==null&&(M0?(n=cu,t=t.stateNode,n.nodeType===8?ML(n.parentNode,t):n.nodeType===1&&ML(n,t),R4(n)):ML(cu,t.stateNode));break;case 4:r=cu,i=M0,cu=t.stateNode.containerInfo,M0=!0,m1(n,e,t),cu=r,M0=i;break;case 0:case 11:case 14:case 15:if(!Ku&&(r=t.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&DU(t,e,a),i=i.next}while(i!==r)}m1(n,e,t);break;case 1:if(!Ku&&(Gb(t,e),r=t.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=t.memoizedProps,r.state=t.memoizedState,r.componentWillUnmount()}catch(o){hl(t,e,o)}m1(n,e,t);break;case 21:m1(n,e,t);break;case 22:t.mode&1?(Ku=(r=Ku)||t.memoizedState!==null,m1(n,e,t),Ku=r):m1(n,e,t);break;default:m1(n,e,t)}}function XZ(n){var e=n.updateQueue;if(e!==null){n.updateQueue=null;var t=n.stateNode;t===null&&(t=n.stateNode=new aTe),e.forEach(function(r){var i=gTe.bind(null,n,r);t.has(r)||(t.add(r),r.then(i,i))})}}function p0(n,e){var t=e.deletions;if(t!==null)for(var r=0;ri&&(i=a),r&=~s}if(r=i,r=Cl()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*cTe(r/1960))-r,10n?16:n,sA===null)var r=!1;else{if(n=sA,sA=null,iM=0,Is&6)throw Error(Bn(331));var i=Is;for(Is|=4,vr=n.current;vr!==null;){var s=vr,a=s.child;if(vr.flags&16){var o=s.deletions;if(o!==null){for(var l=0;lCl()-yG?Rx(n,0):vG|=t),ch(n,e)}function t0e(n,e){e===0&&(n.mode&1?(e=U6,U6<<=1,!(U6&130023424)&&(U6=4194304)):e=1);var t=Dd();n=Ng(n,e),n!==null&&(RS(n,e,t),ch(n,t))}function mTe(n){var e=n.memoizedState,t=0;e!==null&&(t=e.retryLane),t0e(n,t)}function gTe(n,e){var t=0;switch(n.tag){case 13:var r=n.stateNode,i=n.memoizedState;i!==null&&(t=i.retryLane);break;case 19:r=n.stateNode;break;default:throw Error(Bn(314))}r!==null&&r.delete(e),t0e(n,t)}var n0e;n0e=function(n,e,t){if(n!==null)if(n.memoizedProps!==e.pendingProps||oh.current)rh=!0;else{if(!(n.lanes&t)&&!(e.flags&128))return rh=!1,rTe(n,e,t);rh=!!(n.flags&131072)}else rh=!1,_o&&e.flags&1048576&&afe(e,YN,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;XE(n,e),n=e.pendingProps;var i=C_(e,od.current);u_(e,t),i=fG(null,e,r,n,i,t);var s=pG();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,lh(r)?(s=!0,WN(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,lG(e),i.updater=p7,e.stateNode=i,i._reactInternals=e,MU(e,r,n,t),e=RU(null,e,r,!0,s,t)):(e.tag=0,_o&&s&&tG(e),Td(null,e,i,t),e=e.child),e;case 16:r=e.elementType;e:{switch(XE(n,e),n=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=xTe(r),n=N0(r,n),i){case 0:e=PU(null,e,r,n,t);break e;case 1:e=qZ(null,e,r,n,t);break e;case 11:e=zZ(null,e,r,n,t);break e;case 14:e=VZ(null,e,r,N0(r.type,n),t);break e}throw Error(Bn(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:N0(r,i),PU(n,e,r,i,t);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:N0(r,i),qZ(n,e,r,i,t);case 3:e:{if(Bfe(e),n===null)throw Error(Bn(387));r=e.pendingProps,s=e.memoizedState,i=s.element,hfe(n,e),KN(e,r,null,t);var a=e.memoizedState;if(r=a.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=k_(Error(Bn(423)),e),e=GZ(n,e,r,t,i);break e}else if(r!==i){i=k_(Error(Bn(424)),e),e=GZ(n,e,r,t,i);break e}else for(Zh=gA(e.stateNode.containerInfo.firstChild),tf=e,_o=!0,C0=null,t=ufe(e,null,r,t),e.child=t;t;)t.flags=t.flags&-3|4096,t=t.sibling;else{if(P_(),r===i){e=Mg(n,e,t);break e}Td(n,e,r,t)}e=e.child}return e;case 5:return ffe(e),n===null&&TU(e),r=e.type,i=e.pendingProps,s=n!==null?n.memoizedProps:null,a=i.children,yU(r,i)?a=null:s!==null&&yU(r,s)&&(e.flags|=32),Ffe(n,e),Td(n,e,a,t),e.child;case 6:return n===null&&TU(e),null;case 13:return Ufe(n,e,t);case 4:return cG(e,e.stateNode.containerInfo),r=e.pendingProps,n===null?e.child=R_(e,null,r,t):Td(n,e,r,t),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:N0(r,i),zZ(n,e,r,i,t);case 7:return Td(n,e,e.pendingProps,t),e.child;case 8:return Td(n,e,e.pendingProps.children,t),e.child;case 12:return Td(n,e,e.pendingProps.children,t),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,a=i.value,Ha(ZN,r._currentValue),r._currentValue=a,s!==null)if(W0(s.value,a)){if(s.children===i.children&&!oh.current){e=Mg(n,e,t);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var o=s.dependencies;if(o!==null){a=s.child;for(var l=o.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=hg(-1,t&-t),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=t,l=s.alternate,l!==null&&(l.lanes|=t),EU(s.return,t,e),o.lanes|=t;break}l=l.next}}else if(s.tag===10)a=s.type===e.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(Bn(341));a.lanes|=t,o=a.alternate,o!==null&&(o.lanes|=t),EU(a,t,e),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===e){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}Td(n,e,i.children,t),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,u_(e,t),i=Qf(i),r=r(i),e.flags|=1,Td(n,e,r,t),e.child;case 14:return r=e.type,i=N0(r,e.pendingProps),i=N0(r.type,i),VZ(n,e,r,i,t);case 15:return Ofe(n,e,e.type,e.pendingProps,t);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:N0(r,i),XE(n,e),e.tag=1,lh(r)?(n=!0,WN(e)):n=!1,u_(e,t),kfe(e,r,i),MU(e,r,i,t),RU(null,e,r,!0,n,t);case 19:return zfe(n,e,t);case 22:return jfe(n,e,t)}throw Error(Bn(156,e.tag))};function r0e(n,e){return Phe(n,e)}function ATe(n,e,t,r){this.tag=n,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Uf(n,e,t,r){return new ATe(n,e,t,r)}function SG(n){return n=n.prototype,!(!n||!n.isReactComponent)}function xTe(n){if(typeof n=="function")return SG(n)?1:0;if(n!=null){if(n=n.$$typeof,n===qq)return 11;if(n===Gq)return 14}return 2}function yA(n,e){var t=n.alternate;return t===null?(t=Uf(n.tag,e,n.key,n.mode),t.elementType=n.elementType,t.type=n.type,t.stateNode=n.stateNode,t.alternate=n,n.alternate=t):(t.pendingProps=e,t.type=n.type,t.flags=0,t.subtreeFlags=0,t.deletions=null),t.flags=n.flags&14680064,t.childLanes=n.childLanes,t.lanes=n.lanes,t.child=n.child,t.memoizedProps=n.memoizedProps,t.memoizedState=n.memoizedState,t.updateQueue=n.updateQueue,e=n.dependencies,t.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},t.sibling=n.sibling,t.index=n.index,t.ref=n.ref,t}function QE(n,e,t,r,i,s){var a=2;if(r=n,typeof n=="function")SG(n)&&(a=1);else if(typeof n=="string")a=5;else e:switch(n){case Db:return Lx(t.children,i,s,e);case Vq:a=8,i|=8;break;case KB:return n=Uf(12,t,e,i|2),n.elementType=KB,n.lanes=s,n;case JB:return n=Uf(13,t,e,i),n.elementType=JB,n.lanes=s,n;case eU:return n=Uf(19,t,e,i),n.elementType=eU,n.lanes=s,n;case fhe:return A7(t,i,s,e);default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case dhe:a=10;break e;case hhe:a=9;break e;case qq:a=11;break e;case Gq:a=14;break e;case U1:a=16,r=null;break e}throw Error(Bn(130,n==null?n:typeof n,""))}return e=Uf(a,t,e,i),e.elementType=n,e.type=r,e.lanes=s,e}function Lx(n,e,t,r){return n=Uf(7,n,r,e),n.lanes=t,n}function A7(n,e,t,r){return n=Uf(22,n,r,e),n.elementType=fhe,n.lanes=t,n.stateNode={isHidden:!1},n}function OL(n,e,t){return n=Uf(6,n,null,e),n.lanes=t,n}function jL(n,e,t){return e=Uf(4,n.children!==null?n.children:[],n.key,e),e.lanes=t,e.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},e}function vTe(n,e,t,r,i){this.tag=e,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=AL(0),this.expirationTimes=AL(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=AL(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function TG(n,e,t,r,i,s,a,o,l){return n=new vTe(n,e,t,o,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Uf(3,null,null,e),n.current=s,s.stateNode=n,s.memoizedState={element:r,isDehydrated:t,cache:null,transitions:null,pendingSuspenseBoundaries:null},lG(s),n}function yTe(n,e,t){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(o0e)}catch(n){console.error(n)}}o0e(),ohe.exports=ff;var l0e=ohe.exports,c0e,nQ=l0e;c0e=nQ.createRoot,nQ.hydrateRoot;const CG=de.createContext({});function PG(n){const e=de.useRef(null);return e.current===null&&(e.current=n()),e.current}const _7=de.createContext(null),RG=de.createContext({transformPagePoint:n=>n,isStatic:!1,reducedMotion:"never"});class TTe extends de.Component{getSnapshotBeforeUpdate(e){const t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent){const r=this.props.sizeRef.current;r.height=t.offsetHeight||0,r.width=t.offsetWidth||0,r.top=t.offsetTop,r.left=t.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function ETe({children:n,isPresent:e}){const t=de.useId(),r=de.useRef(null),i=de.useRef({width:0,height:0,top:0,left:0}),{nonce:s}=de.useContext(RG);return de.useInsertionEffect(()=>{const{width:a,height:o,top:l,left:c}=i.current;if(e||!r.current||!a||!o)return;r.current.dataset.motionPopId=t;const u=document.createElement("style");return s&&(u.nonce=s),document.head.appendChild(u),u.sheet&&u.sheet.insertRule(` [data-motion-pop-id="${t}"] { position: absolute !important; width: ${a}px !important; height: ${o}px !important; top: ${l}px !important; left: ${c}px !important; } `),()=>{document.head.removeChild(u)}},[e]),f.jsx(TTe,{isPresent:e,childRef:r,sizeRef:i,children:de.cloneElement(n,{ref:r})})}const NTe=({children:n,initial:e,isPresent:t,onExitComplete:r,custom:i,presenceAffectsLayout:s,mode:a})=>{const o=PG(MTe),l=de.useId(),c=de.useCallback(d=>{o.set(d,!0);for(const h of o.values())if(!h)return;r&&r()},[o,r]),u=de.useMemo(()=>({id:l,initial:e,isPresent:t,custom:i,onExitComplete:c,register:d=>(o.set(d,!1),()=>o.delete(d))}),s?[Math.random(),c]:[t,c]);return de.useMemo(()=>{o.forEach((d,h)=>o.set(h,!1))},[t]),de.useEffect(()=>{!t&&!o.size&&r&&r()},[t]),a==="popLayout"&&(n=f.jsx(ETe,{isPresent:t,children:n})),f.jsx(_7.Provider,{value:u,children:n})};function MTe(){return new Map}function u0e(n=!0){const e=de.useContext(_7);if(e===null)return[!0,null];const{isPresent:t,onExitComplete:r,register:i}=e,s=de.useId();de.useEffect(()=>{n&&i(s)},[n]);const a=de.useCallback(()=>n&&r&&r(s),[s,r,n]);return!t&&r?[!1,a]:[!0]}const K6=n=>n.key||"";function rQ(n){const e=[];return de.Children.forEach(n,t=>{de.isValidElement(t)&&e.push(t)}),e}const LG=typeof window<"u",d0e=LG?de.useLayoutEffect:de.useEffect,Da=({children:n,custom:e,initial:t=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:s="sync",propagate:a=!1})=>{const[o,l]=u0e(a),c=de.useMemo(()=>rQ(n),[n]),u=a&&!o?[]:c.map(K6),d=de.useRef(!0),h=de.useRef(c),p=PG(()=>new Map),[g,x]=de.useState(c),[_,y]=de.useState(c);d0e(()=>{d.current=!1,h.current=c;for(let k=0;k<_.length;k++){const B=K6(_[k]);u.includes(B)?p.delete(B):p.get(B)!==!0&&p.set(B,!1)}},[_,u.length,u.join("-")]);const M=[];if(c!==g){let k=[...c];for(let B=0;B<_.length;B++){const U=_[B],z=K6(U);u.includes(z)||(k.splice(B,0,U),M.push(U))}s==="wait"&&M.length&&(k=M),y(rQ(k)),x(c);return}const{forceRender:C}=de.useContext(CG);return f.jsx(f.Fragment,{children:_.map(k=>{const B=K6(k),U=a&&!o?!1:c===_||u.includes(B),z=()=>{if(p.has(B))p.set(B,!0);else return;let O=!0;p.forEach(V=>{V||(O=!1)}),O&&(C==null||C(),y(h.current),a&&(l==null||l()),r&&r())};return f.jsx(NTe,{isPresent:U,initial:!d.current||t?void 0:!1,custom:U?void 0:e,presenceAffectsLayout:i,mode:s,onExitComplete:U?void 0:z,children:k},B)})})},nf=n=>n;let h0e=nf;function kG(n){let e;return()=>(e===void 0&&(e=n()),e)}const D_=(n,e,t)=>{const r=e-n;return r===0?1:(t-n)/r},fg=n=>n*1e3,pg=n=>n/1e3,CTe={useManualTiming:!1};function PTe(n){let e=new Set,t=new Set,r=!1,i=!1;const s=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function o(c){s.has(c)&&(l.schedule(c),n()),c(a)}const l={schedule:(c,u=!1,d=!1)=>{const p=d&&r?e:t;return u&&s.add(c),p.has(c)||p.add(c),c},cancel:c=>{t.delete(c),s.delete(c)},process:c=>{if(a=c,r){i=!0;return}r=!0,[e,t]=[t,e],e.forEach(o),e.clear(),r=!1,i&&(i=!1,l.process(c))}};return l}const J6=["read","resolveKeyframes","update","preRender","render","postRender"],RTe=40;function f0e(n,e){let t=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>t=!0,a=J6.reduce((y,M)=>(y[M]=PTe(s),y),{}),{read:o,resolveKeyframes:l,update:c,preRender:u,render:d,postRender:h}=a,p=()=>{const y=performance.now();t=!1,i.delta=r?1e3/60:Math.max(Math.min(y-i.timestamp,RTe),1),i.timestamp=y,i.isProcessing=!0,o.process(i),l.process(i),c.process(i),u.process(i),d.process(i),h.process(i),i.isProcessing=!1,t&&e&&(r=!1,n(p))},g=()=>{t=!0,r=!0,i.isProcessing||n(p)};return{schedule:J6.reduce((y,M)=>{const C=a[M];return y[M]=(k,B=!1,U=!1)=>(t||g(),C.schedule(k,B,U)),y},{}),cancel:y=>{for(let M=0;MiQ[n].some(t=>!!e[t])};function LTe(n){for(const e in n)O_[e]={...O_[e],...n[e]}}const kTe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function oM(n){return n.startsWith("while")||n.startsWith("drag")&&n!=="draggable"||n.startsWith("layout")||n.startsWith("onTap")||n.startsWith("onPan")||n.startsWith("onLayout")||kTe.has(n)}let m0e=n=>!oM(n);function ITe(n){n&&(m0e=e=>e.startsWith("on")?!oM(e):n(e))}try{ITe(require("@emotion/is-prop-valid").default)}catch{}function DTe(n,e,t){const r={};for(const i in n)i==="values"&&typeof n.values=="object"||(m0e(i)||t===!0&&oM(i)||!e&&!oM(i)||n.draggable&&i.startsWith("onDrag"))&&(r[i]=n[i]);return r}function OTe(n){if(typeof Proxy>"u")return n;const e=new Map,t=(...r)=>n(...r);return new Proxy(t,{get:(r,i)=>i==="create"?n:(e.has(i)||e.set(i,n(i)),e.get(i))})}const w7=de.createContext({});function q4(n){return typeof n=="string"||Array.isArray(n)}function S7(n){return n!==null&&typeof n=="object"&&typeof n.start=="function"}const IG=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],DG=["initial",...IG];function T7(n){return S7(n.animate)||DG.some(e=>q4(n[e]))}function g0e(n){return!!(T7(n)||n.variants)}function jTe(n,e){if(T7(n)){const{initial:t,animate:r}=n;return{initial:t===!1||q4(t)?t:void 0,animate:q4(r)?r:void 0}}return n.inherit!==!1?e:{}}function FTe(n){const{initial:e,animate:t}=jTe(n,de.useContext(w7));return de.useMemo(()=>({initial:e,animate:t}),[sQ(e),sQ(t)])}function sQ(n){return Array.isArray(n)?n.join(" "):n}const BTe=Symbol.for("motionComponentSymbol");function $b(n){return n&&typeof n=="object"&&Object.prototype.hasOwnProperty.call(n,"current")}function UTe(n,e,t){return de.useCallback(r=>{r&&n.onMount&&n.onMount(r),e&&(r?e.mount(r):e.unmount()),t&&(typeof t=="function"?t(r):$b(t)&&(t.current=r))},[e])}const OG=n=>n.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),zTe="framerAppearId",A0e="data-"+OG(zTe),{schedule:jG}=f0e(queueMicrotask,!1),x0e=de.createContext({});function VTe(n,e,t,r,i){var s,a;const{visualElement:o}=de.useContext(w7),l=de.useContext(p0e),c=de.useContext(_7),u=de.useContext(RG).reducedMotion,d=de.useRef(null);r=r||l.renderer,!d.current&&r&&(d.current=r(n,{visualState:e,parent:o,props:t,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u}));const h=d.current,p=de.useContext(x0e);h&&!h.projection&&i&&(h.type==="html"||h.type==="svg")&&qTe(d.current,t,i,p);const g=de.useRef(!1);de.useInsertionEffect(()=>{h&&g.current&&h.update(t,c)});const x=t[A0e],_=de.useRef(!!x&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,x))&&((a=window.MotionHasOptimisedAnimation)===null||a===void 0?void 0:a.call(window,x)));return d0e(()=>{h&&(g.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),jG.render(h.render),_.current&&h.animationState&&h.animationState.animateChanges())}),de.useEffect(()=>{h&&(!_.current&&h.animationState&&h.animationState.animateChanges(),_.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)===null||y===void 0||y.call(window,x)}),_.current=!1))}),h}function qTe(n,e,t,r){const{layoutId:i,layout:s,drag:a,dragConstraints:o,layoutScroll:l,layoutRoot:c}=e;n.projection=new t(n.latestValues,e["data-framer-portal-id"]?void 0:v0e(n.parent)),n.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!a||o&&$b(o),visualElement:n,animationType:typeof s=="string"?s:"both",initialPromotionConfig:r,layoutScroll:l,layoutRoot:c})}function v0e(n){if(n)return n.options.allowProjection!==!1?n.projection:v0e(n.parent)}function GTe({preloadedFeatures:n,createVisualElement:e,useRender:t,useVisualState:r,Component:i}){var s,a;n&<e(n);function o(c,u){let d;const h={...de.useContext(RG),...c,layoutId:HTe(c)},{isStatic:p}=h,g=FTe(c),x=r(c,p);if(!p&&LG){$Te();const _=WTe(h);d=_.MeasureLayout,g.visualElement=VTe(i,x,h,e,_.ProjectionNode)}return f.jsxs(w7.Provider,{value:g,children:[d&&g.visualElement?f.jsx(d,{visualElement:g.visualElement,...h}):null,t(i,c,UTe(x,g.visualElement,u),x,p,g.visualElement)]})}o.displayName=`motion.${typeof i=="string"?i:`create(${(a=(s=i.displayName)!==null&&s!==void 0?s:i.name)!==null&&a!==void 0?a:""})`}`;const l=de.forwardRef(o);return l[BTe]=i,l}function HTe({layoutId:n}){const e=de.useContext(CG).id;return e&&n!==void 0?e+"-"+n:n}function $Te(n,e){de.useContext(p0e).strict}function WTe(n){const{drag:e,layout:t}=O_;if(!e&&!t)return{};const r={...e,...t};return{MeasureLayout:e!=null&&e.isEnabled(n)||t!=null&&t.isEnabled(n)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}const XTe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function FG(n){return typeof n!="string"||n.includes("-")?!1:!!(XTe.indexOf(n)>-1||/[A-Z]/u.test(n))}function aQ(n){const e=[{},{}];return n==null||n.values.forEach((t,r)=>{e[0][r]=t.get(),e[1][r]=t.getVelocity()}),e}function BG(n,e,t,r){if(typeof e=="function"){const[i,s]=aQ(r);e=e(t!==void 0?t:n.custom,i,s)}if(typeof e=="string"&&(e=n.variants&&n.variants[e]),typeof e=="function"){const[i,s]=aQ(r);e=e(t!==void 0?t:n.custom,i,s)}return e}const qU=n=>Array.isArray(n),YTe=n=>!!(n&&typeof n=="object"&&n.mix&&n.toValue),ZTe=n=>qU(n)?n[n.length-1]||0:n,ed=n=>!!(n&&n.getVelocity);function KE(n){const e=ed(n)?n.get():n;return YTe(e)?e.toValue():e}function QTe({scrapeMotionValuesFromProps:n,createRenderState:e,onUpdate:t},r,i,s){const a={latestValues:KTe(r,i,s,n),renderState:e()};return t&&(a.onMount=o=>t({props:r,current:o,...a}),a.onUpdate=o=>t(o)),a}const y0e=n=>(e,t)=>{const r=de.useContext(w7),i=de.useContext(_7),s=()=>QTe(n,e,r,i);return t?s():PG(s)};function KTe(n,e,t,r){const i={},s=r(n,{});for(const h in s)i[h]=KE(s[h]);let{initial:a,animate:o}=n;const l=T7(n),c=g0e(n);e&&c&&!l&&n.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let u=t?t.initial===!1:!1;u=u||a===!1;const d=u?o:a;if(d&&typeof d!="boolean"&&!S7(d)){const h=Array.isArray(d)?d:[d];for(let p=0;pe=>typeof e=="string"&&e.startsWith(n),_0e=b0e("--"),JTe=b0e("var(--"),UG=n=>JTe(n)?e8e.test(n.split("/*")[0].trim()):!1,e8e=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,w0e=(n,e)=>e&&typeof n=="number"?e.transform(n):n,Cg=(n,e,t)=>t>e?e:ttypeof n=="number",parse:parseFloat,transform:n=>n},G4={...S3,transform:n=>Cg(0,1,n)},eT={...S3,default:1},DS=n=>({test:e=>typeof e=="string"&&e.endsWith(n)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${n}`}),F1=DS("deg"),nm=DS("%"),ri=DS("px"),t8e=DS("vh"),n8e=DS("vw"),oQ={...nm,parse:n=>nm.parse(n)/100,transform:n=>nm.transform(n*100)},r8e={borderWidth:ri,borderTopWidth:ri,borderRightWidth:ri,borderBottomWidth:ri,borderLeftWidth:ri,borderRadius:ri,radius:ri,borderTopLeftRadius:ri,borderTopRightRadius:ri,borderBottomRightRadius:ri,borderBottomLeftRadius:ri,width:ri,maxWidth:ri,height:ri,maxHeight:ri,top:ri,right:ri,bottom:ri,left:ri,padding:ri,paddingTop:ri,paddingRight:ri,paddingBottom:ri,paddingLeft:ri,margin:ri,marginTop:ri,marginRight:ri,marginBottom:ri,marginLeft:ri,backgroundPositionX:ri,backgroundPositionY:ri},i8e={rotate:F1,rotateX:F1,rotateY:F1,rotateZ:F1,scale:eT,scaleX:eT,scaleY:eT,scaleZ:eT,skew:F1,skewX:F1,skewY:F1,distance:ri,translateX:ri,translateY:ri,translateZ:ri,x:ri,y:ri,z:ri,perspective:ri,transformPerspective:ri,opacity:G4,originX:oQ,originY:oQ,originZ:ri},lQ={...S3,transform:Math.round},zG={...r8e,...i8e,zIndex:lQ,size:ri,fillOpacity:G4,strokeOpacity:G4,numOctaves:lQ},s8e={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},a8e=w3.length;function o8e(n,e,t){let r="",i=!0;for(let s=0;s({style:{},transform:{},transformOrigin:{},vars:{}}),S0e=()=>({...GG(),attrs:{}}),HG=n=>typeof n=="string"&&n.toLowerCase()==="svg";function T0e(n,{style:e,vars:t},r,i){Object.assign(n.style,e,i&&i.getProjectionStyles(r));for(const s in t)n.style.setProperty(s,t[s])}const E0e=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function N0e(n,e,t,r){T0e(n,e,void 0,r);for(const i in e.attrs)n.setAttribute(E0e.has(i)?i:OG(i),e.attrs[i])}const lM={};function h8e(n){Object.assign(lM,n)}function M0e(n,{layout:e,layoutId:t}){return Hv.has(n)||n.startsWith("origin")||(e||t!==void 0)&&(!!lM[n]||n==="opacity")}function $G(n,e,t){var r;const{style:i}=n,s={};for(const a in i)(ed(i[a])||e.style&&ed(e.style[a])||M0e(a,n)||((r=t==null?void 0:t.getValue(a))===null||r===void 0?void 0:r.liveStyle)!==void 0)&&(s[a]=i[a]);return s}function C0e(n,e,t){const r=$G(n,e,t);for(const i in n)if(ed(n[i])||ed(e[i])){const s=w3.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[s]=n[i]}return r}function f8e(n,e){try{e.dimensions=typeof n.getBBox=="function"?n.getBBox():n.getBoundingClientRect()}catch{e.dimensions={x:0,y:0,width:0,height:0}}}const uQ=["x","y","width","height","cx","cy","r"],p8e={useVisualState:y0e({scrapeMotionValuesFromProps:C0e,createRenderState:S0e,onUpdate:({props:n,prevProps:e,current:t,renderState:r,latestValues:i})=>{if(!t)return;let s=!!n.drag;if(!s){for(const o in i)if(Hv.has(o)){s=!0;break}}if(!s)return;let a=!e;if(e)for(let o=0;o{f8e(t,r),uo.render(()=>{qG(r,i,HG(t.tagName),n.transformTemplate),N0e(t,r)})})}})},m8e={useVisualState:y0e({scrapeMotionValuesFromProps:$G,createRenderState:GG})};function P0e(n,e,t){for(const r in e)!ed(e[r])&&!M0e(r,t)&&(n[r]=e[r])}function g8e({transformTemplate:n},e){return de.useMemo(()=>{const t=GG();return VG(t,e,n),Object.assign({},t.vars,t.style)},[e])}function A8e(n,e){const t=n.style||{},r={};return P0e(r,t,n),Object.assign(r,g8e(n,e)),r}function x8e(n,e){const t={},r=A8e(n,e);return n.drag&&n.dragListener!==!1&&(t.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=n.drag===!0?"none":`pan-${n.drag==="x"?"y":"x"}`),n.tabIndex===void 0&&(n.onTap||n.onTapStart||n.whileTap)&&(t.tabIndex=0),t.style=r,t}function v8e(n,e,t,r){const i=de.useMemo(()=>{const s=S0e();return qG(s,e,HG(r),n.transformTemplate),{...s.attrs,style:{...s.style}}},[e]);if(n.style){const s={};P0e(s,n.style,n),i.style={...s,...i.style}}return i}function y8e(n=!1){return(t,r,i,{latestValues:s},a)=>{const l=(FG(t)?v8e:x8e)(r,s,a,t),c=DTe(r,typeof t=="string",n),u=t!==de.Fragment?{...c,...l,ref:i}:{},{children:d}=r,h=de.useMemo(()=>ed(d)?d.get():d,[d]);return de.createElement(t,{...u,children:h})}}function b8e(n,e){return function(r,{forwardMotionProps:i}={forwardMotionProps:!1}){const a={...FG(r)?p8e:m8e,preloadedFeatures:n,useRender:y8e(i),createVisualElement:e,Component:r};return GTe(a)}}function R0e(n,e){if(!Array.isArray(e))return!1;const t=e.length;if(t!==n.length)return!1;for(let r=0;rwindow.ScrollTimeline!==void 0);class w8e{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}get finished(){return Promise.all(this.animations.map(e=>"finished"in e?e.finished:e))}getAll(e){return this.animations[0][e]}setAll(e,t){for(let r=0;r{if(_8e()&&i.attachTimeline)return i.attachTimeline(e);if(typeof t=="function")return t(i)});return()=>{r.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let t=0;tt[e]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class S8e extends w8e{then(e,t){return Promise.all(this.animations).then(e).catch(t)}}function WG(n,e){return n?n[e]||n.default||n:void 0}const GU=2e4;function L0e(n){let e=0;const t=50;let r=n.next(e);for(;!r.done&&e=GU?1/0:e}function XG(n){return typeof n=="function"}function dQ(n,e){n.timeline=e,n.onfinish=null}const YG=n=>Array.isArray(n)&&typeof n[0]=="number",T8e={linearEasing:void 0};function E8e(n,e){const t=kG(n);return()=>{var r;return(r=T8e[e])!==null&&r!==void 0?r:t()}}const cM=E8e(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),k0e=(n,e,t=10)=>{let r="";const i=Math.max(Math.round(e/t),2);for(let s=0;s`cubic-bezier(${n}, ${e}, ${t}, ${r})`,HU={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:v5([0,.65,.55,1]),circOut:v5([.55,0,1,.45]),backIn:v5([.31,.01,.66,-.59]),backOut:v5([.33,1.53,.69,.99])};function D0e(n,e){if(n)return typeof n=="function"&&cM()?k0e(n,e):YG(n)?v5(n):Array.isArray(n)?n.map(t=>D0e(t,e)||HU.easeOut):HU[n]}const E0={x:!1,y:!1};function O0e(){return E0.x||E0.y}function N8e(n,e,t){var r;if(n instanceof Element)return[n];if(typeof n=="string"){let i=document;const s=(r=void 0)!==null&&r!==void 0?r:i.querySelectorAll(n);return s?Array.from(s):[]}return Array.from(n)}function j0e(n,e){const t=N8e(n),r=new AbortController,i={passive:!0,...e,signal:r.signal};return[t,i,()=>r.abort()]}function hQ(n){return e=>{e.pointerType==="touch"||O0e()||n(e)}}function M8e(n,e,t={}){const[r,i,s]=j0e(n,t),a=hQ(o=>{const{target:l}=o,c=e(o);if(typeof c!="function"||!l)return;const u=hQ(d=>{c(d),l.removeEventListener("pointerleave",u)});l.addEventListener("pointerleave",u,i)});return r.forEach(o=>{o.addEventListener("pointerenter",a,i)}),s}const F0e=(n,e)=>e?n===e?!0:F0e(n,e.parentElement):!1,ZG=n=>n.pointerType==="mouse"?typeof n.button!="number"||n.button<=0:n.isPrimary!==!1,C8e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function P8e(n){return C8e.has(n.tagName)||n.tabIndex!==-1}const y5=new WeakSet;function fQ(n){return e=>{e.key==="Enter"&&n(e)}}function BL(n,e){n.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const R8e=(n,e)=>{const t=n.currentTarget;if(!t)return;const r=fQ(()=>{if(y5.has(t))return;BL(t,"down");const i=fQ(()=>{BL(t,"up")}),s=()=>BL(t,"cancel");t.addEventListener("keyup",i,e),t.addEventListener("blur",s,e)});t.addEventListener("keydown",r,e),t.addEventListener("blur",()=>t.removeEventListener("keydown",r),e)};function pQ(n){return ZG(n)&&!O0e()}function L8e(n,e,t={}){const[r,i,s]=j0e(n,t),a=o=>{const l=o.currentTarget;if(!pQ(o)||y5.has(l))return;y5.add(l);const c=e(o),u=(p,g)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",h),!(!pQ(p)||!y5.has(l))&&(y5.delete(l),typeof c=="function"&&c(p,{success:g}))},d=p=>{u(p,t.useGlobalTarget||F0e(l,p.target))},h=p=>{u(p,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",h,i)};return r.forEach(o=>{!P8e(o)&&o.getAttribute("tabindex")===null&&(o.tabIndex=0),(t.useGlobalTarget?window:o).addEventListener("pointerdown",a,i),o.addEventListener("focus",c=>R8e(c,i),i)}),s}function k8e(n){return n==="x"||n==="y"?E0[n]?null:(E0[n]=!0,()=>{E0[n]=!1}):E0.x||E0.y?null:(E0.x=E0.y=!0,()=>{E0.x=E0.y=!1})}const B0e=new Set(["width","height","top","left","right","bottom",...w3]);let JE;function I8e(){JE=void 0}const rm={now:()=>(JE===void 0&&rm.set(hu.isProcessing||CTe.useManualTiming?hu.timestamp:performance.now()),JE),set:n=>{JE=n,queueMicrotask(I8e)}};function QG(n,e){n.indexOf(e)===-1&&n.push(e)}function KG(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}class JG{constructor(){this.subscriptions=[]}add(e){return QG(this.subscriptions,e),()=>KG(this.subscriptions,e)}notify(e,t,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,t,r);else for(let s=0;s!isNaN(parseFloat(n));class O8e{constructor(e,t={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,i=!0)=>{const s=rm.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=rm.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=D8e(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new JG);const r=this.events[e].add(t);return e==="change"?()=>{r(),uo.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e,t=!0){!t||!this.passiveEffect?this.updateAndNotify(e,t):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,t,r){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-r}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=rm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>mQ)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,mQ);return U0e(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function H4(n,e){return new O8e(n,e)}function j8e(n,e,t){n.hasValue(e)?n.getValue(e).set(t):n.addValue(e,H4(t))}function F8e(n,e){const t=E7(n,e);let{transitionEnd:r={},transition:i={},...s}=t||{};s={...s,...r};for(const a in s){const o=ZTe(s[a]);j8e(n,a,o)}}function B8e(n){return!!(ed(n)&&n.add)}function $U(n,e){const t=n.getValue("willChange");if(B8e(t))return t.add(e)}function z0e(n){return n.props[A0e]}const V0e=(n,e,t)=>(((1-3*t+3*e)*n+(3*t-6*e))*n+3*e)*n,U8e=1e-7,z8e=12;function V8e(n,e,t,r,i){let s,a,o=0;do a=e+(t-e)/2,s=V0e(a,r,i)-n,s>0?t=a:e=a;while(Math.abs(s)>U8e&&++oV8e(s,0,1,n,t);return s=>s===0||s===1?s:V0e(i(s),e,r)}const q0e=n=>e=>e<=.5?n(2*e)/2:(2-n(2*(1-e)))/2,G0e=n=>e=>1-n(1-e),H0e=OS(.33,1.53,.69,.99),eH=G0e(H0e),$0e=q0e(eH),W0e=n=>(n*=2)<1?.5*eH(n):.5*(2-Math.pow(2,-10*(n-1))),tH=n=>1-Math.sin(Math.acos(n)),X0e=G0e(tH),Y0e=q0e(tH),Z0e=n=>/^0[^.\s]+$/u.test(n);function q8e(n){return typeof n=="number"?n===0:n!==null?n==="none"||n==="0"||Z0e(n):!0}const K5=n=>Math.round(n*1e5)/1e5,nH=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function G8e(n){return n==null}const H8e=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,rH=(n,e)=>t=>!!(typeof t=="string"&&H8e.test(t)&&t.startsWith(n)||e&&!G8e(t)&&Object.prototype.hasOwnProperty.call(t,e)),Q0e=(n,e,t)=>r=>{if(typeof r!="string")return r;const[i,s,a,o]=r.match(nH);return{[n]:parseFloat(i),[e]:parseFloat(s),[t]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},$8e=n=>Cg(0,255,n),UL={...S3,transform:n=>Math.round($8e(n))},vx={test:rH("rgb","red"),parse:Q0e("red","green","blue"),transform:({red:n,green:e,blue:t,alpha:r=1})=>"rgba("+UL.transform(n)+", "+UL.transform(e)+", "+UL.transform(t)+", "+K5(G4.transform(r))+")"};function W8e(n){let e="",t="",r="",i="";return n.length>5?(e=n.substring(1,3),t=n.substring(3,5),r=n.substring(5,7),i=n.substring(7,9)):(e=n.substring(1,2),t=n.substring(2,3),r=n.substring(3,4),i=n.substring(4,5),e+=e,t+=t,r+=r,i+=i),{red:parseInt(e,16),green:parseInt(t,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const WU={test:rH("#"),parse:W8e,transform:vx.transform},Wb={test:rH("hsl","hue"),parse:Q0e("hue","saturation","lightness"),transform:({hue:n,saturation:e,lightness:t,alpha:r=1})=>"hsla("+Math.round(n)+", "+nm.transform(K5(e))+", "+nm.transform(K5(t))+", "+K5(G4.transform(r))+")"},Qu={test:n=>vx.test(n)||WU.test(n)||Wb.test(n),parse:n=>vx.test(n)?vx.parse(n):Wb.test(n)?Wb.parse(n):WU.parse(n),transform:n=>typeof n=="string"?n:n.hasOwnProperty("red")?vx.transform(n):Wb.transform(n)},X8e=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function Y8e(n){var e,t;return isNaN(n)&&typeof n=="string"&&(((e=n.match(nH))===null||e===void 0?void 0:e.length)||0)+(((t=n.match(X8e))===null||t===void 0?void 0:t.length)||0)>0}const K0e="number",J0e="color",Z8e="var",Q8e="var(",gQ="${}",K8e=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function $4(n){const e=n.toString(),t=[],r={color:[],number:[],var:[]},i=[];let s=0;const o=e.replace(K8e,l=>(Qu.test(l)?(r.color.push(s),i.push(J0e),t.push(Qu.parse(l))):l.startsWith(Q8e)?(r.var.push(s),i.push(Z8e),t.push(l)):(r.number.push(s),i.push(K0e),t.push(parseFloat(l))),++s,gQ)).split(gQ);return{values:t,split:o,indexes:r,types:i}}function epe(n){return $4(n).values}function tpe(n){const{split:e,types:t}=$4(n),r=e.length;return i=>{let s="";for(let a=0;atypeof n=="number"?0:n;function eEe(n){const e=epe(n);return tpe(n)(e.map(J8e))}const OA={test:Y8e,parse:epe,createTransformer:tpe,getAnimatableNone:eEe},tEe=new Set(["brightness","contrast","saturate","opacity"]);function nEe(n){const[e,t]=n.slice(0,-1).split("(");if(e==="drop-shadow")return n;const[r]=t.match(nH)||[];if(!r)return n;const i=t.replace(r,"");let s=tEe.has(e)?1:0;return r!==t&&(s*=100),e+"("+s+i+")"}const rEe=/\b([a-z-]*)\(.*?\)/gu,XU={...OA,getAnimatableNone:n=>{const e=n.match(rEe);return e?e.map(nEe).join(" "):n}},iEe={...zG,color:Qu,backgroundColor:Qu,outlineColor:Qu,fill:Qu,stroke:Qu,borderColor:Qu,borderTopColor:Qu,borderRightColor:Qu,borderBottomColor:Qu,borderLeftColor:Qu,filter:XU,WebkitFilter:XU},iH=n=>iEe[n];function npe(n,e){let t=iH(n);return t!==XU&&(t=OA),t.getAnimatableNone?t.getAnimatableNone(e):void 0}const sEe=new Set(["auto","none","0"]);function aEe(n,e,t){let r=0,i;for(;rn===S3||n===ri,xQ=(n,e)=>parseFloat(n.split(", ")[e]),vQ=(n,e)=>(t,{transform:r})=>{if(r==="none"||!r)return 0;const i=r.match(/^matrix3d\((.+)\)$/u);if(i)return xQ(i[1],e);{const s=r.match(/^matrix\((.+)\)$/u);return s?xQ(s[1],n):0}},oEe=new Set(["x","y","z"]),lEe=w3.filter(n=>!oEe.has(n));function cEe(n){const e=[];return lEe.forEach(t=>{const r=n.getValue(t);r!==void 0&&(e.push([t,r.get()]),r.set(t.startsWith("scale")?1:0))}),e}const j_={width:({x:n},{paddingLeft:e="0",paddingRight:t="0"})=>n.max-n.min-parseFloat(e)-parseFloat(t),height:({y:n},{paddingTop:e="0",paddingBottom:t="0"})=>n.max-n.min-parseFloat(e)-parseFloat(t),top:(n,{top:e})=>parseFloat(e),left:(n,{left:e})=>parseFloat(e),bottom:({y:n},{top:e})=>parseFloat(e)+(n.max-n.min),right:({x:n},{left:e})=>parseFloat(e)+(n.max-n.min),x:vQ(4,13),y:vQ(5,14)};j_.translateX=j_.x;j_.translateY=j_.y;const kx=new Set;let YU=!1,ZU=!1;function rpe(){if(ZU){const n=Array.from(kx).filter(r=>r.needsMeasurement),e=new Set(n.map(r=>r.element)),t=new Map;e.forEach(r=>{const i=cEe(r);i.length&&(t.set(r,i),r.render())}),n.forEach(r=>r.measureInitialState()),e.forEach(r=>{r.render();const i=t.get(r);i&&i.forEach(([s,a])=>{var o;(o=r.getValue(s))===null||o===void 0||o.set(a)})}),n.forEach(r=>r.measureEndState()),n.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}ZU=!1,YU=!1,kx.forEach(n=>n.complete()),kx.clear()}function ipe(){kx.forEach(n=>{n.readKeyframes(),n.needsMeasurement&&(ZU=!0)})}function uEe(){ipe(),rpe()}class sH{constructor(e,t,r,i,s,a=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=r,this.motionValue=i,this.element=s,this.isAsync=a}scheduleResolve(){this.isScheduled=!0,this.isAsync?(kx.add(this),YU||(YU=!0,uo.read(ipe),uo.resolveKeyframes(rpe))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:t,element:r,motionValue:i}=this;for(let s=0;s/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(n),dEe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function hEe(n){const e=dEe.exec(n);if(!e)return[,];const[,t,r,i]=e;return[`--${t??r}`,i]}function ape(n,e,t=1){const[r,i]=hEe(n);if(!r)return;const s=window.getComputedStyle(e).getPropertyValue(r);if(s){const a=s.trim();return spe(a)?parseFloat(a):a}return UG(i)?ape(i,e,t+1):i}const ope=n=>e=>e.test(n),fEe={test:n=>n==="auto",parse:n=>n},lpe=[S3,ri,nm,F1,n8e,t8e,fEe],yQ=n=>lpe.find(ope(n));class cpe extends sH{constructor(e,t,r,i,s){super(e,t,r,i,s,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:t,name:r}=this;if(!t||!t.current)return;super.readKeyframes();for(let l=0;l{t.getValue(l).set(c)}),this.resolveNoneKeyframes()}}const bQ=(n,e)=>e==="zIndex"?!1:!!(typeof n=="number"||Array.isArray(n)||typeof n=="string"&&(OA.test(n)||n==="0")&&!n.startsWith("url("));function pEe(n){const e=n[0];if(n.length===1)return!0;for(let t=0;tn!==null;function N7(n,{repeat:e,repeatType:t="loop"},r){const i=n.filter(gEe),s=e&&t!=="loop"&&e%2===1?0:i.length-1;return!s||r===void 0?i[s]:r}const AEe=40;class upe{constructor({autoplay:e=!0,delay:t=0,type:r="keyframes",repeat:i=0,repeatDelay:s=0,repeatType:a="loop",...o}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=rm.now(),this.options={autoplay:e,delay:t,type:r,repeat:i,repeatDelay:s,repeatType:a,...o},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>AEe?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&uEe(),this._resolved}onKeyframesResolved(e,t){this.resolvedAt=rm.now(),this.hasAttemptedResolve=!0;const{name:r,type:i,velocity:s,delay:a,onComplete:o,onUpdate:l,isGenerator:c}=this.options;if(!c&&!mEe(e,r,i,s))if(a)this.options.duration=0;else{l&&l(N7(e,this.options,t)),o&&o(),this.resolveFinishedPromise();return}const u=this.initPlayback(e,t);u!==!1&&(this._resolved={keyframes:e,finalKeyframe:t,...u},this.onPostResolved())}onPostResolved(){}then(e,t){return this.currentFinishedPromise.then(e,t)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(e=>{this.resolveFinishedPromise=e})}}const Fo=(n,e,t)=>n+(e-n)*t;function zL(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*(2/3-t)*6:n}function xEe({hue:n,saturation:e,lightness:t,alpha:r}){n/=360,e/=100,t/=100;let i=0,s=0,a=0;if(!e)i=s=a=t;else{const o=t<.5?t*(1+e):t+e-t*e,l=2*t-o;i=zL(l,o,n+1/3),s=zL(l,o,n),a=zL(l,o,n-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(a*255),alpha:r}}function uM(n,e){return t=>t>0?e:n}const VL=(n,e,t)=>{const r=n*n,i=t*(e*e-r)+r;return i<0?0:Math.sqrt(i)},vEe=[WU,vx,Wb],yEe=n=>vEe.find(e=>e.test(n));function _Q(n){const e=yEe(n);if(!e)return!1;let t=e.parse(n);return e===Wb&&(t=xEe(t)),t}const wQ=(n,e)=>{const t=_Q(n),r=_Q(e);if(!t||!r)return uM(n,e);const i={...t};return s=>(i.red=VL(t.red,r.red,s),i.green=VL(t.green,r.green,s),i.blue=VL(t.blue,r.blue,s),i.alpha=Fo(t.alpha,r.alpha,s),vx.transform(i))},bEe=(n,e)=>t=>e(n(t)),jS=(...n)=>n.reduce(bEe),QU=new Set(["none","hidden"]);function _Ee(n,e){return QU.has(n)?t=>t<=0?n:e:t=>t>=1?e:n}function wEe(n,e){return t=>Fo(n,e,t)}function aH(n){return typeof n=="number"?wEe:typeof n=="string"?UG(n)?uM:Qu.test(n)?wQ:EEe:Array.isArray(n)?dpe:typeof n=="object"?Qu.test(n)?wQ:SEe:uM}function dpe(n,e){const t=[...n],r=t.length,i=n.map((s,a)=>aH(s)(s,e[a]));return s=>{for(let a=0;a{for(const s in r)t[s]=r[s](i);return t}}function TEe(n,e){var t;const r=[],i={color:0,var:0,number:0};for(let s=0;s{const t=OA.createTransformer(e),r=$4(n),i=$4(e);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?QU.has(n)&&!i.values.length||QU.has(e)&&!r.values.length?_Ee(n,e):jS(dpe(TEe(r,i),i.values),t):uM(n,e)};function hpe(n,e,t){return typeof n=="number"&&typeof e=="number"&&typeof t=="number"?Fo(n,e,t):aH(n)(n,e)}const NEe=5;function fpe(n,e,t){const r=Math.max(e-NEe,0);return U0e(t-n(r),e-r)}const ul={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},qL=.001;function MEe({duration:n=ul.duration,bounce:e=ul.bounce,velocity:t=ul.velocity,mass:r=ul.mass}){let i,s,a=1-e;a=Cg(ul.minDamping,ul.maxDamping,a),n=Cg(ul.minDuration,ul.maxDuration,pg(n)),a<1?(i=c=>{const u=c*a,d=u*n,h=u-t,p=KU(c,a),g=Math.exp(-d);return qL-h/p*g},s=c=>{const d=c*a*n,h=d*t+t,p=Math.pow(a,2)*Math.pow(c,2)*n,g=Math.exp(-d),x=KU(Math.pow(c,2),a);return(-i(c)+qL>0?-1:1)*((h-p)*g)/x}):(i=c=>{const u=Math.exp(-c*n),d=(c-t)*n+1;return-qL+u*d},s=c=>{const u=Math.exp(-c*n),d=(t-c)*(n*n);return u*d});const o=5/n,l=PEe(i,s,o);if(n=fg(n),isNaN(l))return{stiffness:ul.stiffness,damping:ul.damping,duration:n};{const c=Math.pow(l,2)*r;return{stiffness:c,damping:a*2*Math.sqrt(r*c),duration:n}}}const CEe=12;function PEe(n,e,t){let r=t;for(let i=1;in[t]!==void 0)}function kEe(n){let e={velocity:ul.velocity,stiffness:ul.stiffness,damping:ul.damping,mass:ul.mass,isResolvedFromDuration:!1,...n};if(!SQ(n,LEe)&&SQ(n,REe))if(n.visualDuration){const t=n.visualDuration,r=2*Math.PI/(t*1.2),i=r*r,s=2*Cg(.05,1,1-(n.bounce||0))*Math.sqrt(i);e={...e,mass:ul.mass,stiffness:i,damping:s}}else{const t=MEe(n);e={...e,...t,mass:ul.mass},e.isResolvedFromDuration=!0}return e}function ppe(n=ul.visualDuration,e=ul.bounce){const t=typeof n!="object"?{visualDuration:n,keyframes:[0,1],bounce:e}:n;let{restSpeed:r,restDelta:i}=t;const s=t.keyframes[0],a=t.keyframes[t.keyframes.length-1],o={done:!1,value:s},{stiffness:l,damping:c,mass:u,duration:d,velocity:h,isResolvedFromDuration:p}=kEe({...t,velocity:-pg(t.velocity||0)}),g=h||0,x=c/(2*Math.sqrt(l*u)),_=a-s,y=pg(Math.sqrt(l/u)),M=Math.abs(_)<5;r||(r=M?ul.restSpeed.granular:ul.restSpeed.default),i||(i=M?ul.restDelta.granular:ul.restDelta.default);let C;if(x<1){const B=KU(y,x);C=U=>{const z=Math.exp(-x*y*U);return a-z*((g+x*y*_)/B*Math.sin(B*U)+_*Math.cos(B*U))}}else if(x===1)C=B=>a-Math.exp(-y*B)*(_+(g+y*_)*B);else{const B=y*Math.sqrt(x*x-1);C=U=>{const z=Math.exp(-x*y*U),O=Math.min(B*U,300);return a-z*((g+x*y*_)*Math.sinh(O)+B*_*Math.cosh(O))/B}}const k={calculatedDuration:p&&d||null,next:B=>{const U=C(B);if(p)o.done=B>=d;else{let z=0;x<1&&(z=B===0?fg(g):fpe(C,B,U));const O=Math.abs(z)<=r,V=Math.abs(a-U)<=i;o.done=O&&V}return o.value=o.done?a:U,o},toString:()=>{const B=Math.min(L0e(k),GU),U=k0e(z=>k.next(B*z).value,B,30);return B+"ms "+U}};return k}function TQ({keyframes:n,velocity:e=0,power:t=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:a,min:o,max:l,restDelta:c=.5,restSpeed:u}){const d=n[0],h={done:!1,value:d},p=O=>o!==void 0&&Ol,g=O=>o===void 0?l:l===void 0||Math.abs(o-O)-x*Math.exp(-O/r),C=O=>y+M(O),k=O=>{const V=M(O),$=C(O);h.done=Math.abs(V)<=c,h.value=h.done?y:$};let B,U;const z=O=>{p(h.value)&&(B=O,U=ppe({keyframes:[h.value,g(h.value)],velocity:fpe(C,O,h.value),damping:i,stiffness:s,restDelta:c,restSpeed:u}))};return z(0),{calculatedDuration:null,next:O=>{let V=!1;return!U&&B===void 0&&(V=!0,k(O),z(O)),B!==void 0&&O>=B?U.next(O-B):(!V&&k(O),h)}}}const IEe=OS(.42,0,1,1),DEe=OS(0,0,.58,1),mpe=OS(.42,0,.58,1),OEe=n=>Array.isArray(n)&&typeof n[0]!="number",jEe={linear:nf,easeIn:IEe,easeInOut:mpe,easeOut:DEe,circIn:tH,circInOut:Y0e,circOut:X0e,backIn:eH,backInOut:$0e,backOut:H0e,anticipate:W0e},EQ=n=>{if(YG(n)){h0e(n.length===4);const[e,t,r,i]=n;return OS(e,t,r,i)}else if(typeof n=="string")return jEe[n];return n};function FEe(n,e,t){const r=[],i=t||hpe,s=n.length-1;for(let a=0;ae[0];if(s===2&&e[0]===e[1])return()=>e[1];const a=n[0]===n[1];n[0]>n[s-1]&&(n=[...n].reverse(),e=[...e].reverse());const o=FEe(e,r,i),l=o.length,c=u=>{if(a&&u1)for(;dc(Cg(n[0],n[s-1],u)):c}function UEe(n,e){const t=n[n.length-1];for(let r=1;r<=e;r++){const i=D_(0,e,r);n.push(Fo(t,1,i))}}function zEe(n){const e=[0];return UEe(e,n.length-1),e}function VEe(n,e){return n.map(t=>t*e)}function qEe(n,e){return n.map(()=>e||mpe).splice(0,n.length-1)}function dM({duration:n=300,keyframes:e,times:t,ease:r="easeInOut"}){const i=OEe(r)?r.map(EQ):EQ(r),s={done:!1,value:e[0]},a=VEe(t&&t.length===e.length?t:zEe(e),n),o=BEe(a,e,{ease:Array.isArray(i)?i:qEe(e,i)});return{calculatedDuration:n,next:l=>(s.value=o(l),s.done=l>=n,s)}}const GEe=n=>{const e=({timestamp:t})=>n(t);return{start:()=>uo.update(e,!0),stop:()=>DA(e),now:()=>hu.isProcessing?hu.timestamp:rm.now()}},HEe={decay:TQ,inertia:TQ,tween:dM,keyframes:dM,spring:ppe},$Ee=n=>n/100;class oH extends upe{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:l}=this.options;l&&l()};const{name:t,motionValue:r,element:i,keyframes:s}=this.options,a=(i==null?void 0:i.KeyframeResolver)||sH,o=(l,c)=>this.onKeyframesResolved(l,c);this.resolver=new a(s,o,t,r,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){const{type:t="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:s,velocity:a=0}=this.options,o=XG(t)?t:HEe[t]||dM;let l,c;o!==dM&&typeof e[0]!="number"&&(l=jS($Ee,hpe(e[0],e[1])),e=[0,100]);const u=o({...this.options,keyframes:e});s==="mirror"&&(c=o({...this.options,keyframes:[...e].reverse(),velocity:-a})),u.calculatedDuration===null&&(u.calculatedDuration=L0e(u));const{calculatedDuration:d}=u,h=d+i,p=h*(r+1)-i;return{generator:u,mirroredGenerator:c,mapPercentToKeyframes:l,calculatedDuration:d,resolvedDuration:h,totalDuration:p}}onPostResolved(){const{autoplay:e=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!e?this.pause():this.state=this.pendingPlayState}tick(e,t=!1){const{resolved:r}=this;if(!r){const{keyframes:O}=this.options;return{done:!0,value:O[O.length-1]}}const{finalKeyframe:i,generator:s,mirroredGenerator:a,mapPercentToKeyframes:o,keyframes:l,calculatedDuration:c,totalDuration:u,resolvedDuration:d}=r;if(this.startTime===null)return s.next(0);const{delay:h,repeat:p,repeatType:g,repeatDelay:x,onUpdate:_}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-u/this.speed,this.startTime)),t?this.currentTime=e:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(e-this.startTime)*this.speed;const y=this.currentTime-h*(this.speed>=0?1:-1),M=this.speed>=0?y<0:y>u;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=u);let C=this.currentTime,k=s;if(p){const O=Math.min(this.currentTime,u)/d;let V=Math.floor(O),$=O%1;!$&&O>=1&&($=1),$===1&&V--,V=Math.min(V,p+1),!!(V%2)&&(g==="reverse"?($=1-$,x&&($-=x/d)):g==="mirror"&&(k=a)),C=Cg(0,1,$)*d}const B=M?{done:!1,value:l[0]}:k.next(C);o&&(B.value=o(B.value));let{done:U}=B;!M&&c!==null&&(U=this.speed>=0?this.currentTime>=u:this.currentTime<=0);const z=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&U);return z&&i!==void 0&&(B.value=N7(l,this.options,i)),_&&_(B.value),z&&this.finish(),B}get duration(){const{resolved:e}=this;return e?pg(e.calculatedDuration):0}get time(){return pg(this.currentTime)}set time(e){e=fg(e),this.currentTime=e,this.holdTime!==null||this.speed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){const t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=pg(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:e=GEe,onPlay:t,startTime:r}=this.options;this.driver||(this.driver=e(s=>this.tick(s))),t&&t();const i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=r??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var e;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(e=this.currentTime)!==null&&e!==void 0?e:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:e}=this.options;e&&e()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}}const WEe=new Set(["opacity","clipPath","filter","transform"]);function XEe(n,e,t,{delay:r=0,duration:i=300,repeat:s=0,repeatType:a="loop",ease:o="easeInOut",times:l}={}){const c={[e]:t};l&&(c.offset=l);const u=D0e(o,i);return Array.isArray(u)&&(c.easing=u),n.animate(c,{delay:r,duration:i,easing:Array.isArray(u)?"linear":u,fill:"both",iterations:s+1,direction:a==="reverse"?"alternate":"normal"})}const YEe=kG(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),hM=10,ZEe=2e4;function QEe(n){return XG(n.type)||n.type==="spring"||!I0e(n.ease)}function KEe(n,e){const t=new oH({...e,keyframes:n,repeat:0,delay:0,isGenerator:!0});let r={done:!1,value:n[0]};const i=[];let s=0;for(;!r.done&&sthis.onKeyframesResolved(a,o),t,r,i),this.resolver.scheduleResolve()}initPlayback(e,t){let{duration:r=300,times:i,ease:s,type:a,motionValue:o,name:l,startTime:c}=this.options;if(!o.owner||!o.owner.current)return!1;if(typeof s=="string"&&cM()&&JEe(s)&&(s=gpe[s]),QEe(this.options)){const{onComplete:d,onUpdate:h,motionValue:p,element:g,...x}=this.options,_=KEe(e,x);e=_.keyframes,e.length===1&&(e[1]=e[0]),r=_.duration,i=_.times,s=_.ease,a="keyframes"}const u=XEe(o.owner.current,l,e,{...this.options,duration:r,times:i,ease:s});return u.startTime=c??this.calcStartTime(),this.pendingTimeline?(dQ(u,this.pendingTimeline),this.pendingTimeline=void 0):u.onfinish=()=>{const{onComplete:d}=this.options;o.set(N7(e,this.options,t)),d&&d(),this.cancel(),this.resolveFinishedPromise()},{animation:u,duration:r,times:i,type:a,ease:s,keyframes:e}}get duration(){const{resolved:e}=this;if(!e)return 0;const{duration:t}=e;return pg(t)}get time(){const{resolved:e}=this;if(!e)return 0;const{animation:t}=e;return pg(t.currentTime||0)}set time(e){const{resolved:t}=this;if(!t)return;const{animation:r}=t;r.currentTime=fg(e)}get speed(){const{resolved:e}=this;if(!e)return 1;const{animation:t}=e;return t.playbackRate}set speed(e){const{resolved:t}=this;if(!t)return;const{animation:r}=t;r.playbackRate=e}get state(){const{resolved:e}=this;if(!e)return"idle";const{animation:t}=e;return t.playState}get startTime(){const{resolved:e}=this;if(!e)return null;const{animation:t}=e;return t.startTime}attachTimeline(e){if(!this._resolved)this.pendingTimeline=e;else{const{resolved:t}=this;if(!t)return nf;const{animation:r}=t;dQ(r,e)}return nf}play(){if(this.isStopped)return;const{resolved:e}=this;if(!e)return;const{animation:t}=e;t.playState==="finished"&&this.updateFinishedPromise(),t.play()}pause(){const{resolved:e}=this;if(!e)return;const{animation:t}=e;t.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:e}=this;if(!e)return;const{animation:t,keyframes:r,duration:i,type:s,ease:a,times:o}=e;if(t.playState==="idle"||t.playState==="finished")return;if(this.time){const{motionValue:c,onUpdate:u,onComplete:d,element:h,...p}=this.options,g=new oH({...p,keyframes:r,duration:i,type:s,ease:a,times:o,isGenerator:!0}),x=fg(this.time);c.setWithVelocity(g.sample(x-hM).value,g.sample(x).value,hM)}const{onStop:l}=this.options;l&&l(),this.cancel()}complete(){const{resolved:e}=this;e&&e.animation.finish()}cancel(){const{resolved:e}=this;e&&e.animation.cancel()}static supports(e){const{motionValue:t,name:r,repeatDelay:i,repeatType:s,damping:a,type:o}=e;if(!t||!t.owner||!(t.owner.current instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=t.owner.getProps();return YEe()&&r&&WEe.has(r)&&!l&&!c&&!i&&s!=="mirror"&&a!==0&&o!=="inertia"}}const eNe={type:"spring",stiffness:500,damping:25,restSpeed:10},tNe=n=>({type:"spring",stiffness:550,damping:n===0?2*Math.sqrt(550):30,restSpeed:10}),nNe={type:"keyframes",duration:.8},rNe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},iNe=(n,{keyframes:e})=>e.length>2?nNe:Hv.has(n)?n.startsWith("scale")?tNe(e[1]):eNe:rNe;function sNe({when:n,delay:e,delayChildren:t,staggerChildren:r,staggerDirection:i,repeat:s,repeatType:a,repeatDelay:o,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const lH=(n,e,t,r={},i,s)=>a=>{const o=WG(r,n)||{},l=o.delay||r.delay||0;let{elapsed:c=0}=r;c=c-fg(l);let u={keyframes:Array.isArray(t)?t:[null,t],ease:"easeOut",velocity:e.getVelocity(),...o,delay:-c,onUpdate:h=>{e.set(h),o.onUpdate&&o.onUpdate(h)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:n,motionValue:e,element:s?void 0:i};sNe(o)||(u={...u,...iNe(n,u)}),u.duration&&(u.duration=fg(u.duration)),u.repeatDelay&&(u.repeatDelay=fg(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(u.duration=0,u.delay===0&&(d=!0)),d&&!s&&e.get()!==void 0){const h=N7(u.keyframes,o);if(h!==void 0)return uo.update(()=>{u.onUpdate(h),u.onComplete()}),new S8e([])}return!s&&NQ.supports(u)?new NQ(u):new oH(u)};function aNe({protectedKeys:n,needsAnimating:e},t){const r=n.hasOwnProperty(t)&&e[t]!==!0;return e[t]=!1,r}function Ape(n,e,{delay:t=0,transitionOverride:r,type:i}={}){var s;let{transition:a=n.getDefaultTransition(),transitionEnd:o,...l}=e;r&&(a=r);const c=[],u=i&&n.animationState&&n.animationState.getState()[i];for(const d in l){const h=n.getValue(d,(s=n.latestValues[d])!==null&&s!==void 0?s:null),p=l[d];if(p===void 0||u&&aNe(u,d))continue;const g={delay:t,...WG(a||{},d)};let x=!1;if(window.MotionHandoffAnimation){const y=z0e(n);if(y){const M=window.MotionHandoffAnimation(y,d,uo);M!==null&&(g.startTime=M,x=!0)}}$U(n,d),h.start(lH(d,h,p,n.shouldReduceMotion&&B0e.has(d)?{type:!1}:g,n,x));const _=h.animation;_&&c.push(_)}return o&&Promise.all(c).then(()=>{uo.update(()=>{o&&F8e(n,o)})}),c}function JU(n,e,t={}){var r;const i=E7(n,e,t.type==="exit"?(r=n.presenceContext)===null||r===void 0?void 0:r.custom:void 0);let{transition:s=n.getDefaultTransition()||{}}=i||{};t.transitionOverride&&(s=t.transitionOverride);const a=i?()=>Promise.all(Ape(n,i,t)):()=>Promise.resolve(),o=n.variantChildren&&n.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:h}=s;return oNe(n,e,u+c,d,h,t)}:()=>Promise.resolve(),{when:l}=s;if(l){const[c,u]=l==="beforeChildren"?[a,o]:[o,a];return c().then(()=>u())}else return Promise.all([a(),o(t.delay)])}function oNe(n,e,t=0,r=0,i=1,s){const a=[],o=(n.variantChildren.size-1)*r,l=i===1?(c=0)=>c*r:(c=0)=>o-c*r;return Array.from(n.variantChildren).sort(lNe).forEach((c,u)=>{c.notify("AnimationStart",e),a.push(JU(c,e,{...s,delay:t+l(u)}).then(()=>c.notify("AnimationComplete",e)))}),Promise.all(a)}function lNe(n,e){return n.sortNodePosition(e)}function cNe(n,e,t={}){n.notify("AnimationStart",e);let r;if(Array.isArray(e)){const i=e.map(s=>JU(n,s,t));r=Promise.all(i)}else if(typeof e=="string")r=JU(n,e,t);else{const i=typeof e=="function"?E7(n,e,t.custom):e;r=Promise.all(Ape(n,i,t))}return r.then(()=>{n.notify("AnimationComplete",e)})}const uNe=DG.length;function xpe(n){if(!n)return;if(!n.isControllingVariants){const t=n.parent?xpe(n.parent)||{}:{};return n.props.initial!==void 0&&(t.initial=n.props.initial),t}const e={};for(let t=0;tPromise.all(e.map(({animation:t,options:r})=>cNe(n,t,r)))}function pNe(n){let e=fNe(n),t=MQ(),r=!0;const i=l=>(c,u)=>{var d;const h=E7(n,u,l==="exit"?(d=n.presenceContext)===null||d===void 0?void 0:d.custom:void 0);if(h){const{transition:p,transitionEnd:g,...x}=h;c={...c,...x,...g}}return c};function s(l){e=l(n)}function a(l){const{props:c}=n,u=xpe(n.parent)||{},d=[],h=new Set;let p={},g=1/0;for(let _=0;_g&&k,V=!1;const $=Array.isArray(C)?C:[C];let G=$.reduce(i(y),{});B===!1&&(G={});const{prevResolvedValues:H={}}=M,K={...H,...G},W=ae=>{O=!0,h.has(ae)&&(V=!0,h.delete(ae)),M.needsAnimating[ae]=!0;const Q=n.getValue(ae);Q&&(Q.liveStyle=!1)};for(const ae in K){const Q=G[ae],re=H[ae];if(p.hasOwnProperty(ae))continue;let oe=!1;qU(Q)&&qU(re)?oe=!R0e(Q,re):oe=Q!==re,oe?Q!=null?W(ae):h.add(ae):Q!==void 0&&h.has(ae)?W(ae):M.protectedKeys[ae]=!0}M.prevProp=C,M.prevResolvedValues=G,M.isActive&&(p={...p,...G}),r&&n.blockInitialAnimation&&(O=!1),O&&(!(U&&z)||V)&&d.push(...$.map(ae=>({animation:ae,options:{type:y}})))}if(h.size){const _={};h.forEach(y=>{const M=n.getBaseTarget(y),C=n.getValue(y);C&&(C.liveStyle=!0),_[y]=M??null}),d.push({animation:_})}let x=!!d.length;return r&&(c.initial===!1||c.initial===c.animate)&&!n.manuallyAnimateOnMount&&(x=!1),r=!1,x?e(d):Promise.resolve()}function o(l,c){var u;if(t[l].isActive===c)return Promise.resolve();(u=n.variantChildren)===null||u===void 0||u.forEach(h=>{var p;return(p=h.animationState)===null||p===void 0?void 0:p.setActive(l,c)}),t[l].isActive=c;const d=a(l);for(const h in t)t[h].protectedKeys={};return d}return{animateChanges:a,setActive:o,setAnimateFunction:s,getState:()=>t,reset:()=>{t=MQ(),r=!0}}}function mNe(n,e){return typeof e=="string"?e!==n:Array.isArray(e)?!R0e(e,n):!1}function E2(n=!1){return{isActive:n,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function MQ(){return{animate:E2(!0),whileInView:E2(),whileHover:E2(),whileTap:E2(),whileDrag:E2(),whileFocus:E2(),exit:E2()}}class KA{constructor(e){this.isMounted=!1,this.node=e}update(){}}class gNe extends KA{constructor(e){super(e),e.animationState||(e.animationState=pNe(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();S7(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)===null||e===void 0||e.call(this)}}let ANe=0;class xNe extends KA{constructor(){super(...arguments),this.id=ANe++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===r)return;const i=this.node.animationState.setActive("exit",!e);t&&!e&&i.then(()=>t(this.id))}mount(){const{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}const vNe={animation:{Feature:gNe},exit:{Feature:xNe}};function W4(n,e,t,r={passive:!0}){return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t)}function FS(n){return{point:{x:n.pageX,y:n.pageY}}}const yNe=n=>e=>ZG(e)&&n(e,FS(e));function J5(n,e,t,r){return W4(n,e,yNe(t),r)}const CQ=(n,e)=>Math.abs(n-e);function bNe(n,e){const t=CQ(n.x,e.x),r=CQ(n.y,e.y);return Math.sqrt(t**2+r**2)}class vpe{constructor(e,t,{transformPagePoint:r,contextWindow:i,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const d=HL(this.lastMoveEventInfo,this.history),h=this.startEvent!==null,p=bNe(d.offset,{x:0,y:0})>=3;if(!h&&!p)return;const{point:g}=d,{timestamp:x}=hu;this.history.push({...g,timestamp:x});const{onStart:_,onMove:y}=this.handlers;h||(_&&_(this.lastMoveEvent,d),this.startEvent=this.lastMoveEvent),y&&y(this.lastMoveEvent,d)},this.handlePointerMove=(d,h)=>{this.lastMoveEvent=d,this.lastMoveEventInfo=GL(h,this.transformPagePoint),uo.update(this.updatePoint,!0)},this.handlePointerUp=(d,h)=>{this.end();const{onEnd:p,onSessionEnd:g,resumeAnimation:x}=this.handlers;if(this.dragSnapToOrigin&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const _=HL(d.type==="pointercancel"?this.lastMoveEventInfo:GL(h,this.transformPagePoint),this.history);this.startEvent&&p&&p(d,_),g&&g(d,_)},!ZG(e))return;this.dragSnapToOrigin=s,this.handlers=t,this.transformPagePoint=r,this.contextWindow=i||window;const a=FS(e),o=GL(a,this.transformPagePoint),{point:l}=o,{timestamp:c}=hu;this.history=[{...l,timestamp:c}];const{onSessionStart:u}=t;u&&u(e,HL(o,this.history)),this.removeListeners=jS(J5(this.contextWindow,"pointermove",this.handlePointerMove),J5(this.contextWindow,"pointerup",this.handlePointerUp),J5(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),DA(this.updatePoint)}}function GL(n,e){return e?{point:e(n.point)}:n}function PQ(n,e){return{x:n.x-e.x,y:n.y-e.y}}function HL({point:n},e){return{point:n,delta:PQ(n,ype(e)),offset:PQ(n,_Ne(e)),velocity:wNe(e,.1)}}function _Ne(n){return n[0]}function ype(n){return n[n.length-1]}function wNe(n,e){if(n.length<2)return{x:0,y:0};let t=n.length-1,r=null;const i=ype(n);for(;t>=0&&(r=n[t],!(i.timestamp-r.timestamp>fg(e)));)t--;if(!r)return{x:0,y:0};const s=pg(i.timestamp-r.timestamp);if(s===0)return{x:0,y:0};const a={x:(i.x-r.x)/s,y:(i.y-r.y)/s};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}const bpe=1e-4,SNe=1-bpe,TNe=1+bpe,_pe=.01,ENe=0-_pe,NNe=0+_pe;function of(n){return n.max-n.min}function MNe(n,e,t){return Math.abs(n-e)<=t}function RQ(n,e,t,r=.5){n.origin=r,n.originPoint=Fo(e.min,e.max,n.origin),n.scale=of(t)/of(e),n.translate=Fo(t.min,t.max,n.origin)-n.originPoint,(n.scale>=SNe&&n.scale<=TNe||isNaN(n.scale))&&(n.scale=1),(n.translate>=ENe&&n.translate<=NNe||isNaN(n.translate))&&(n.translate=0)}function e4(n,e,t,r){RQ(n.x,e.x,t.x,r?r.originX:void 0),RQ(n.y,e.y,t.y,r?r.originY:void 0)}function LQ(n,e,t){n.min=t.min+e.min,n.max=n.min+of(e)}function CNe(n,e,t){LQ(n.x,e.x,t.x),LQ(n.y,e.y,t.y)}function kQ(n,e,t){n.min=e.min-t.min,n.max=n.min+of(e)}function t4(n,e,t){kQ(n.x,e.x,t.x),kQ(n.y,e.y,t.y)}function PNe(n,{min:e,max:t},r){return e!==void 0&&nt&&(n=r?Fo(t,n,r.max):Math.min(n,t)),n}function IQ(n,e,t){return{min:e!==void 0?n.min+e:void 0,max:t!==void 0?n.max+t-(n.max-n.min):void 0}}function RNe(n,{top:e,left:t,bottom:r,right:i}){return{x:IQ(n.x,t,i),y:IQ(n.y,e,r)}}function DQ(n,e){let t=e.min-n.min,r=e.max-n.max;return e.max-e.minr?t=D_(e.min,e.max-r,n.min):r>i&&(t=D_(n.min,n.max-i,e.min)),Cg(0,1,t)}function INe(n,e){const t={};return e.min!==void 0&&(t.min=e.min-n.min),e.max!==void 0&&(t.max=e.max-n.min),t}const ez=.35;function DNe(n=ez){return n===!1?n=0:n===!0&&(n=ez),{x:OQ(n,"left","right"),y:OQ(n,"top","bottom")}}function OQ(n,e,t){return{min:jQ(n,e),max:jQ(n,t)}}function jQ(n,e){return typeof n=="number"?n:n[e]||0}const FQ=()=>({translate:0,scale:1,origin:0,originPoint:0}),Xb=()=>({x:FQ(),y:FQ()}),BQ=()=>({min:0,max:0}),Ml=()=>({x:BQ(),y:BQ()});function Cf(n){return[n("x"),n("y")]}function wpe({top:n,left:e,right:t,bottom:r}){return{x:{min:e,max:t},y:{min:n,max:r}}}function ONe({x:n,y:e}){return{top:e.min,right:n.max,bottom:e.max,left:n.min}}function jNe(n,e){if(!e)return n;const t=e({x:n.left,y:n.top}),r=e({x:n.right,y:n.bottom});return{top:t.y,left:t.x,bottom:r.y,right:r.x}}function $L(n){return n===void 0||n===1}function tz({scale:n,scaleX:e,scaleY:t}){return!$L(n)||!$L(e)||!$L(t)}function rx(n){return tz(n)||Spe(n)||n.z||n.rotate||n.rotateX||n.rotateY||n.skewX||n.skewY}function Spe(n){return UQ(n.x)||UQ(n.y)}function UQ(n){return n&&n!=="0%"}function fM(n,e,t){const r=n-t,i=e*r;return t+i}function zQ(n,e,t,r,i){return i!==void 0&&(n=fM(n,i,r)),fM(n,t,r)+e}function nz(n,e=0,t=1,r,i){n.min=zQ(n.min,e,t,r,i),n.max=zQ(n.max,e,t,r,i)}function Tpe(n,{x:e,y:t}){nz(n.x,e.translate,e.scale,e.originPoint),nz(n.y,t.translate,t.scale,t.originPoint)}const VQ=.999999999999,qQ=1.0000000000001;function FNe(n,e,t,r=!1){const i=t.length;if(!i)return;e.x=e.y=1;let s,a;for(let o=0;oVQ&&(e.x=1),e.yVQ&&(e.y=1)}function Yb(n,e){n.min=n.min+e,n.max=n.max+e}function GQ(n,e,t,r,i=.5){const s=Fo(n.min,n.max,i);nz(n,e,t,s,r)}function Zb(n,e){GQ(n.x,e.x,e.scaleX,e.scale,e.originX),GQ(n.y,e.y,e.scaleY,e.scale,e.originY)}function Epe(n,e){return wpe(jNe(n.getBoundingClientRect(),e))}function BNe(n,e,t){const r=Epe(n,t),{scroll:i}=e;return i&&(Yb(r.x,i.offset.x),Yb(r.y,i.offset.y)),r}const Npe=({current:n})=>n?n.ownerDocument.defaultView:null,UNe=new WeakMap;class zNe{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Ml(),this.visualElement=e}start(e,{snapToCursor:t=!1}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const i=u=>{const{dragSnapToOrigin:d}=this.getProps();d?this.pauseAnimation():this.stopAnimation(),t&&this.snapToCursor(FS(u).point)},s=(u,d)=>{const{drag:h,dragPropagation:p,onDragStart:g}=this.getProps();if(h&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=k8e(h),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Cf(_=>{let y=this.getAxisMotionValue(_).get()||0;if(nm.test(y)){const{projection:M}=this.visualElement;if(M&&M.layout){const C=M.layout.layoutBox[_];C&&(y=of(C)*(parseFloat(y)/100))}}this.originPoint[_]=y}),g&&uo.postRender(()=>g(u,d)),$U(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},a=(u,d)=>{const{dragPropagation:h,dragDirectionLock:p,onDirectionLock:g,onDrag:x}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:_}=d;if(p&&this.currentDirection===null){this.currentDirection=VNe(_),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",d.point,_),this.updateAxis("y",d.point,_),this.visualElement.render(),x&&x(u,d)},o=(u,d)=>this.stop(u,d),l=()=>Cf(u=>{var d;return this.getAnimationState(u)==="paused"&&((d=this.getAxisMotionValue(u).animation)===null||d===void 0?void 0:d.play())}),{dragSnapToOrigin:c}=this.getProps();this.panSession=new vpe(e,{onSessionStart:i,onStart:s,onMove:a,onSessionEnd:o,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:c,contextWindow:Npe(this.visualElement)})}stop(e,t){const r=this.isDragging;if(this.cancel(),!r)return;const{velocity:i}=t;this.startAnimation(i);const{onDragEnd:s}=this.getProps();s&&uo.postRender(()=>s(e,t))}cancel(){this.isDragging=!1;const{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}updateAxis(e,t,r){const{drag:i}=this.getProps();if(!r||!tT(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let a=this.originPoint[e]+r[e];this.constraints&&this.constraints[e]&&(a=PNe(a,this.constraints[e],this.elastic[e])),s.set(a)}resolveConstraints(){var e;const{dragConstraints:t,dragElastic:r}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(e=this.visualElement.projection)===null||e===void 0?void 0:e.layout,s=this.constraints;t&&$b(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=RNe(i.layoutBox,t):this.constraints=!1,this.elastic=DNe(r),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Cf(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=INe(i.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!$b(e))return!1;const r=e.current,{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=BNe(r,i.root,this.visualElement.getTransformPagePoint());let a=LNe(i.layout.layoutBox,s);if(t){const o=t(ONe(a));this.hasMutatedConstraints=!!o,o&&(a=wpe(o))}return a}startAnimation(e){const{drag:t,dragMomentum:r,dragElastic:i,dragTransition:s,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),l=this.constraints||{},c=Cf(u=>{if(!tT(u,t,this.currentDirection))return;let d=l&&l[u]||{};a&&(d={min:0,max:0});const h=i?200:1e6,p=i?40:1e7,g={type:"inertia",velocity:r?e[u]:0,bounceStiffness:h,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...s,...d};return this.startAxisValueAnimation(u,g)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){const r=this.getAxisMotionValue(e);return $U(this.visualElement,e),r.start(lH(e,r,0,t,this.visualElement,!1))}stopAnimation(){Cf(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Cf(e=>{var t;return(t=this.getAxisMotionValue(e).animation)===null||t===void 0?void 0:t.pause()})}getAnimationState(e){var t;return(t=this.getAxisMotionValue(e).animation)===null||t===void 0?void 0:t.state}getAxisMotionValue(e){const t=`_drag${e.toUpperCase()}`,r=this.visualElement.getProps(),i=r[t];return i||this.visualElement.getValue(e,(r.initial?r.initial[e]:void 0)||0)}snapToCursor(e){Cf(t=>{const{drag:r}=this.getProps();if(!tT(t,r,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(t);if(i&&i.layout){const{min:a,max:o}=i.layout.layoutBox[t];s.set(e[t]-Fo(a,o,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:t}=this.getProps(),{projection:r}=this.visualElement;if(!$b(t)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Cf(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const l=o.get();i[a]=kNe({min:l,max:l},this.constraints[a])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Cf(a=>{if(!tT(a,e,null))return;const o=this.getAxisMotionValue(a),{min:l,max:c}=this.constraints[a];o.set(Fo(l,c,i[a]))})}addListeners(){if(!this.visualElement.current)return;UNe.set(this.visualElement,this);const e=this.visualElement.current,t=J5(e,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),r=()=>{const{dragConstraints:l}=this.getProps();$b(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),uo.read(r);const a=W4(window,"resize",()=>this.scalePositionWithinConstraints()),o=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(Cf(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].translate))}),this.visualElement.render())});return()=>{a(),t(),s(),o&&o()}}getProps(){const e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:a=ez,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:r,dragPropagation:i,dragConstraints:s,dragElastic:a,dragMomentum:o}}}function tT(n,e,t){return(e===!0||e===n)&&(t===null||t===n)}function VNe(n,e=10){let t=null;return Math.abs(n.y)>e?t="y":Math.abs(n.x)>e&&(t="x"),t}class qNe extends KA{constructor(e){super(e),this.removeGroupControls=nf,this.removeListeners=nf,this.controls=new zNe(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||nf}unmount(){this.removeGroupControls(),this.removeListeners()}}const HQ=n=>(e,t)=>{n&&uo.postRender(()=>n(e,t))};class GNe extends KA{constructor(){super(...arguments),this.removePointerDownListener=nf}onPointerDown(e){this.session=new vpe(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Npe(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:t,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:HQ(e),onStart:HQ(t),onMove:r,onEnd:(s,a)=>{delete this.session,i&&uo.postRender(()=>i(s,a))}}}mount(){this.removePointerDownListener=J5(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const eN={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function $Q(n,e){return e.max===e.min?0:n/(e.max-e.min)*100}const hw={correct:(n,e)=>{if(!e.target)return n;if(typeof n=="string")if(ri.test(n))n=parseFloat(n);else return n;const t=$Q(n,e.target.x),r=$Q(n,e.target.y);return`${t}% ${r}%`}},HNe={correct:(n,{treeScale:e,projectionDelta:t})=>{const r=n,i=OA.parse(n);if(i.length>5)return r;const s=OA.createTransformer(n),a=typeof i[0]!="number"?1:0,o=t.x.scale*e.x,l=t.y.scale*e.y;i[0+a]/=o,i[1+a]/=l;const c=Fo(o,l,.5);return typeof i[2+a]=="number"&&(i[2+a]/=c),typeof i[3+a]=="number"&&(i[3+a]/=c),s(i)}};class $Ne extends de.Component{componentDidMount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:r,layoutId:i}=this.props,{projection:s}=e;h8e(WNe),s&&(t.group&&t.group.add(s),r&&r.register&&i&&r.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),eN.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:t,visualElement:r,drag:i,isPresent:s}=this.props,a=r.projection;return a&&(a.isPresent=s,i||e.layoutDependency!==t||t===void 0?a.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?a.promote():a.relegate()||uo.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),jG.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:t,switchLayoutGroup:r}=this.props,{projection:i}=e;i&&(i.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function Mpe(n){const[e,t]=u0e(),r=de.useContext(CG);return f.jsx($Ne,{...n,layoutGroup:r,switchLayoutGroup:de.useContext(x0e),isPresent:e,safeToRemove:t})}const WNe={borderRadius:{...hw,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:hw,borderTopRightRadius:hw,borderBottomLeftRadius:hw,borderBottomRightRadius:hw,boxShadow:HNe};function XNe(n,e,t){const r=ed(n)?n:H4(n);return r.start(lH("",r,e,t)),r.animation}function YNe(n){return n instanceof SVGElement&&n.tagName!=="svg"}const ZNe=(n,e)=>n.depth-e.depth;class QNe{constructor(){this.children=[],this.isDirty=!1}add(e){QG(this.children,e),this.isDirty=!0}remove(e){KG(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(ZNe),this.isDirty=!1,this.children.forEach(e)}}function KNe(n,e){const t=rm.now(),r=({timestamp:i})=>{const s=i-t;s>=e&&(DA(r),n(s-e))};return uo.read(r,!0),()=>DA(r)}const Cpe=["TopLeft","TopRight","BottomLeft","BottomRight"],JNe=Cpe.length,WQ=n=>typeof n=="string"?parseFloat(n):n,XQ=n=>typeof n=="number"||ri.test(n);function eMe(n,e,t,r,i,s){i?(n.opacity=Fo(0,t.opacity!==void 0?t.opacity:1,tMe(r)),n.opacityExit=Fo(e.opacity!==void 0?e.opacity:1,0,nMe(r))):s&&(n.opacity=Fo(e.opacity!==void 0?e.opacity:1,t.opacity!==void 0?t.opacity:1,r));for(let a=0;are?1:t(D_(n,e,r))}function ZQ(n,e){n.min=e.min,n.max=e.max}function Tf(n,e){ZQ(n.x,e.x),ZQ(n.y,e.y)}function QQ(n,e){n.translate=e.translate,n.scale=e.scale,n.originPoint=e.originPoint,n.origin=e.origin}function KQ(n,e,t,r,i){return n-=e,n=fM(n,1/t,r),i!==void 0&&(n=fM(n,1/i,r)),n}function rMe(n,e=0,t=1,r=.5,i,s=n,a=n){if(nm.test(e)&&(e=parseFloat(e),e=Fo(a.min,a.max,e/100)-a.min),typeof e!="number")return;let o=Fo(s.min,s.max,r);n===s&&(o-=e),n.min=KQ(n.min,e,t,o,i),n.max=KQ(n.max,e,t,o,i)}function JQ(n,e,[t,r,i],s,a){rMe(n,e[t],e[r],e[i],e.scale,s,a)}const iMe=["x","scaleX","originX"],sMe=["y","scaleY","originY"];function eK(n,e,t,r){JQ(n.x,e,iMe,t?t.x:void 0,r?r.x:void 0),JQ(n.y,e,sMe,t?t.y:void 0,r?r.y:void 0)}function tK(n){return n.translate===0&&n.scale===1}function Rpe(n){return tK(n.x)&&tK(n.y)}function nK(n,e){return n.min===e.min&&n.max===e.max}function aMe(n,e){return nK(n.x,e.x)&&nK(n.y,e.y)}function rK(n,e){return Math.round(n.min)===Math.round(e.min)&&Math.round(n.max)===Math.round(e.max)}function Lpe(n,e){return rK(n.x,e.x)&&rK(n.y,e.y)}function iK(n){return of(n.x)/of(n.y)}function sK(n,e){return n.translate===e.translate&&n.scale===e.scale&&n.originPoint===e.originPoint}class oMe{constructor(){this.members=[]}add(e){QG(this.members,e),e.scheduleRender()}remove(e){if(KG(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(e){const t=this.members.findIndex(i=>e===i);if(t===0)return!1;let r;for(let i=t;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1){r=s;break}}return r?(this.promote(r),!0):!1}promote(e,t){const r=this.lead;if(e!==r&&(this.prevLead=r,this.lead=e,e.show(),r)){r.instance&&r.scheduleRender(),e.scheduleRender(),e.resumeFrom=r,t&&(e.resumeFrom.preserveOpacity=!0),r.snapshot&&(e.snapshot=r.snapshot,e.snapshot.latestValues=r.animationValues||r.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:t,resumingFrom:r}=e;t.onExitComplete&&t.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function lMe(n,e,t){let r="";const i=n.x.translate/e.x,s=n.y.translate/e.y,a=(t==null?void 0:t.z)||0;if((i||s||a)&&(r=`translate3d(${i}px, ${s}px, ${a}px) `),(e.x!==1||e.y!==1)&&(r+=`scale(${1/e.x}, ${1/e.y}) `),t){const{transformPerspective:c,rotate:u,rotateX:d,rotateY:h,skewX:p,skewY:g}=t;c&&(r=`perspective(${c}px) ${r}`),u&&(r+=`rotate(${u}deg) `),d&&(r+=`rotateX(${d}deg) `),h&&(r+=`rotateY(${h}deg) `),p&&(r+=`skewX(${p}deg) `),g&&(r+=`skewY(${g}deg) `)}const o=n.x.scale*e.x,l=n.y.scale*e.y;return(o!==1||l!==1)&&(r+=`scale(${o}, ${l})`),r||"none"}const ix={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},b5=typeof window<"u"&&window.MotionDebug!==void 0,WL=["","X","Y","Z"],cMe={visibility:"hidden"},aK=1e3;let uMe=0;function XL(n,e,t,r){const{latestValues:i}=e;i[n]&&(t[n]=i[n],e.setStaticValue(n,0),r&&(r[n]=0))}function kpe(n){if(n.hasCheckedOptimisedAppear=!0,n.root===n)return;const{visualElement:e}=n.options;if(!e)return;const t=z0e(e);if(window.MotionHasOptimisedAnimation(t,"transform")){const{layout:i,layoutId:s}=n.options;window.MotionCancelOptimisedAnimation(t,"transform",uo,!(i||s))}const{parent:r}=n;r&&!r.hasCheckedOptimisedAppear&&kpe(r)}function Ipe({attachResizeListener:n,defaultParent:e,measureScroll:t,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(a={},o=e==null?void 0:e()){this.id=uMe++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,b5&&(ix.totalNodes=ix.resolvedTargetDeltas=ix.recalculatedProjection=0),this.nodes.forEach(fMe),this.nodes.forEach(xMe),this.nodes.forEach(vMe),this.nodes.forEach(pMe),b5&&window.MotionDebug.record(ix)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let l=0;lthis.root.updateBlockedByResize=!1;n(a,()=>{this.root.updateBlockedByResize=!0,d&&d(),d=KNe(h,250),eN.hasAnimatedSinceResize&&(eN.hasAnimatedSinceResize=!1,this.nodes.forEach(lK))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&u&&(l||c)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:h,hasRelativeTargetChanged:p,layout:g})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||u.getDefaultTransition()||SMe,{onLayoutAnimationStart:_,onLayoutAnimationComplete:y}=u.getProps(),M=!this.targetLayout||!Lpe(this.targetLayout,g)||p,C=!h&&p;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||C||h&&(M||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(d,C);const k={...WG(x,"layout"),onPlay:_,onComplete:y};(u.shouldReduceMotion||this.options.layoutRoot)&&(k.delay=0,k.type=!1),this.startAnimation(k)}else h||lK(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=g})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,DA(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(yMe),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&kpe(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let l=0;l{const B=k/1e3;cK(d.x,a.x,B),cK(d.y,a.y,B),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(t4(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox),_Me(this.relativeTarget,this.relativeTargetOrigin,h,B),C&&aMe(this.relativeTarget,C)&&(this.isProjectionDirty=!1),C||(C=Ml()),Tf(C,this.relativeTarget)),x&&(this.animationValues=u,eMe(u,c,this.latestValues,B,M,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=B},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(DA(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=uo.update(()=>{eN.hasAnimatedSinceResize=!0,this.currentAnimation=XNe(0,aK,{...a,onUpdate:o=>{this.mixTargetDelta(o),a.onUpdate&&a.onUpdate(o)},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(aK),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:l,layout:c,latestValues:u}=a;if(!(!o||!l||!c)){if(this!==a&&this.layout&&c&&Dpe(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||Ml();const d=of(this.layout.layoutBox.x);l.x.min=a.target.x.min,l.x.max=l.x.min+d;const h=of(this.layout.layoutBox.y);l.y.min=a.target.y.min,l.y.max=l.y.min+h}Tf(o,l),Zb(o,u),e4(this.projectionDeltaWithTransform,this.layoutCorrected,o,u)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new oMe),this.sharedNodes.get(a).add(o);const c=o.options.initialPromotionConfig;o.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var a;const{layoutId:o}=this.options;return o?((a=this.getStack())===null||a===void 0?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:o}=this.options;return o?(a=this.getStack())===null||a===void 0?void 0:a.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:l}=a;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(o=!0),!o)return;const c={};l.z&&XL("z",a,c,this.animationValues);for(let u=0;u{var o;return(o=a.currentAnimation)===null||o===void 0?void 0:o.stop()}),this.root.nodes.forEach(oK),this.root.sharedNodes.clear()}}}function dMe(n){n.updateLayout()}function hMe(n){var e;const t=((e=n.resumeFrom)===null||e===void 0?void 0:e.snapshot)||n.snapshot;if(n.isLead()&&n.layout&&t&&n.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:i}=n.layout,{animationType:s}=n.options,a=t.source!==n.layout.source;s==="size"?Cf(d=>{const h=a?t.measuredBox[d]:t.layoutBox[d],p=of(h);h.min=r[d].min,h.max=h.min+p}):Dpe(s,t.layoutBox,r)&&Cf(d=>{const h=a?t.measuredBox[d]:t.layoutBox[d],p=of(r[d]);h.max=h.min+p,n.relativeTarget&&!n.currentAnimation&&(n.isProjectionDirty=!0,n.relativeTarget[d].max=n.relativeTarget[d].min+p)});const o=Xb();e4(o,r,t.layoutBox);const l=Xb();a?e4(l,n.applyTransform(i,!0),t.measuredBox):e4(l,r,t.layoutBox);const c=!Rpe(o);let u=!1;if(!n.resumeFrom){const d=n.getClosestProjectingParent();if(d&&!d.resumeFrom){const{snapshot:h,layout:p}=d;if(h&&p){const g=Ml();t4(g,t.layoutBox,h.layoutBox);const x=Ml();t4(x,r,p.layoutBox),Lpe(g,x)||(u=!0),d.options.layoutRoot&&(n.relativeTarget=x,n.relativeTargetOrigin=g,n.relativeParent=d)}}}n.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:l,layoutDelta:o,hasLayoutChanged:c,hasRelativeTargetChanged:u})}else if(n.isLead()){const{onExitComplete:r}=n.options;r&&r()}n.options.transition=void 0}function fMe(n){b5&&ix.totalNodes++,n.parent&&(n.isProjecting()||(n.isProjectionDirty=n.parent.isProjectionDirty),n.isSharedProjectionDirty||(n.isSharedProjectionDirty=!!(n.isProjectionDirty||n.parent.isProjectionDirty||n.parent.isSharedProjectionDirty)),n.isTransformDirty||(n.isTransformDirty=n.parent.isTransformDirty))}function pMe(n){n.isProjectionDirty=n.isSharedProjectionDirty=n.isTransformDirty=!1}function mMe(n){n.clearSnapshot()}function oK(n){n.clearMeasurements()}function gMe(n){n.isLayoutDirty=!1}function AMe(n){const{visualElement:e}=n.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),n.resetTransform()}function lK(n){n.finishAnimation(),n.targetDelta=n.relativeTarget=n.target=void 0,n.isProjectionDirty=!0}function xMe(n){n.resolveTargetDelta()}function vMe(n){n.calcProjection()}function yMe(n){n.resetSkewAndRotation()}function bMe(n){n.removeLeadSnapshot()}function cK(n,e,t){n.translate=Fo(e.translate,0,t),n.scale=Fo(e.scale,1,t),n.origin=e.origin,n.originPoint=e.originPoint}function uK(n,e,t,r){n.min=Fo(e.min,t.min,r),n.max=Fo(e.max,t.max,r)}function _Me(n,e,t,r){uK(n.x,e.x,t.x,r),uK(n.y,e.y,t.y,r)}function wMe(n){return n.animationValues&&n.animationValues.opacityExit!==void 0}const SMe={duration:.45,ease:[.4,0,.1,1]},dK=n=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(n),hK=dK("applewebkit/")&&!dK("chrome/")?Math.round:nf;function fK(n){n.min=hK(n.min),n.max=hK(n.max)}function TMe(n){fK(n.x),fK(n.y)}function Dpe(n,e,t){return n==="position"||n==="preserve-aspect"&&!MNe(iK(e),iK(t),.2)}function EMe(n){var e;return n!==n.root&&((e=n.scroll)===null||e===void 0?void 0:e.wasRoot)}const NMe=Ipe({attachResizeListener:(n,e)=>W4(n,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),YL={current:void 0},Ope=Ipe({measureScroll:n=>({x:n.scrollLeft,y:n.scrollTop}),defaultParent:()=>{if(!YL.current){const n=new NMe({});n.mount(window),n.setOptions({layoutScroll:!0}),YL.current=n}return YL.current},resetTransform:(n,e)=>{n.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:n=>window.getComputedStyle(n).position==="fixed"}),MMe={pan:{Feature:GNe},drag:{Feature:qNe,ProjectionNode:Ope,MeasureLayout:Mpe}};function pK(n,e,t){const{props:r}=n;n.animationState&&r.whileHover&&n.animationState.setActive("whileHover",t==="Start");const i="onHover"+t,s=r[i];s&&uo.postRender(()=>s(e,FS(e)))}class CMe extends KA{mount(){const{current:e}=this.node;e&&(this.unmount=M8e(e,t=>(pK(this.node,t,"Start"),r=>pK(this.node,r,"End"))))}unmount(){}}class PMe extends KA{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=jS(W4(this.node.current,"focus",()=>this.onFocus()),W4(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function mK(n,e,t){const{props:r}=n;n.animationState&&r.whileTap&&n.animationState.setActive("whileTap",t==="Start");const i="onTap"+(t==="End"?"":t),s=r[i];s&&uo.postRender(()=>s(e,FS(e)))}class RMe extends KA{mount(){const{current:e}=this.node;e&&(this.unmount=L8e(e,t=>(mK(this.node,t,"Start"),(r,{success:i})=>mK(this.node,r,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const rz=new WeakMap,ZL=new WeakMap,LMe=n=>{const e=rz.get(n.target);e&&e(n)},kMe=n=>{n.forEach(LMe)};function IMe({root:n,...e}){const t=n||document;ZL.has(t)||ZL.set(t,{});const r=ZL.get(t),i=JSON.stringify(e);return r[i]||(r[i]=new IntersectionObserver(kMe,{root:n,...e})),r[i]}function DMe(n,e,t){const r=IMe(e);return rz.set(n,t),r.observe(n),()=>{rz.delete(n),r.unobserve(n)}}const OMe={some:0,all:1};class jMe extends KA{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:t,margin:r,amount:i="some",once:s}=e,a={root:t?t.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:OMe[i]},o=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,s&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),h=c?u:d;h&&h(l)};return DMe(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:t}=this.node;["amount","margin","root"].some(FMe(e,t))&&this.startObserver()}unmount(){}}function FMe({viewport:n={}},{viewport:e={}}={}){return t=>n[t]!==e[t]}const BMe={inView:{Feature:jMe},tap:{Feature:RMe},focus:{Feature:PMe},hover:{Feature:CMe}},UMe={layout:{ProjectionNode:Ope,MeasureLayout:Mpe}},iz={current:null},jpe={current:!1};function zMe(){if(jpe.current=!0,!!LG)if(window.matchMedia){const n=window.matchMedia("(prefers-reduced-motion)"),e=()=>iz.current=n.matches;n.addListener(e),e()}else iz.current=!1}const VMe=[...lpe,Qu,OA],qMe=n=>VMe.find(ope(n)),gK=new WeakMap;function GMe(n,e,t){for(const r in e){const i=e[r],s=t[r];if(ed(i))n.addValue(r,i);else if(ed(s))n.addValue(r,H4(i,{owner:n}));else if(s!==i)if(n.hasValue(r)){const a=n.getValue(r);a.liveStyle===!0?a.jump(i):a.hasAnimated||a.set(i)}else{const a=n.getStaticValue(r);n.addValue(r,H4(a!==void 0?a:i,{owner:n}))}}for(const r in t)e[r]===void 0&&n.removeValue(r);return e}const AK=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class HMe{scrapeMotionValuesFromProps(e,t,r){return{}}constructor({parent:e,props:t,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:s,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=sH,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const p=rm.now();this.renderScheduledAtthis.bindToMotionValue(r,t)),jpe.current||zMe(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:iz.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){gK.delete(this.current),this.projection&&this.projection.unmount(),DA(this.notifyUpdate),DA(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}bindToMotionValue(e,t){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const r=Hv.has(e),i=t.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&uo.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0)}),s=t.on("renderRequest",this.scheduleRender);let a;window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{i(),s(),a&&a(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in O_){const t=O_[e];if(!t)continue;const{isEnabled:r,Feature:i}=t;if(!this.features[e]&&i&&r(this.props)&&(this.features[e]=new i(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Ml()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let r=0;rt.variantChildren.delete(e)}addValue(e,t){const r=this.values.get(e);t!==r&&(r&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);const t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let r=this.values.get(e);return r===void 0&&t!==void 0&&(r=H4(t===null?void 0:t,{owner:this}),this.addValue(e,r)),r}readValue(e,t){var r;let i=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:(r=this.getBaseTargetFromProps(this.props,e))!==null&&r!==void 0?r:this.readValueFromInstance(this.current,e,this.options);return i!=null&&(typeof i=="string"&&(spe(i)||Z0e(i))?i=parseFloat(i):!qMe(i)&&OA.test(t)&&(i=npe(e,t)),this.setBaseTarget(e,ed(i)?i.get():i)),ed(i)?i.get():i}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){var t;const{initial:r}=this.props;let i;if(typeof r=="string"||typeof r=="object"){const a=BG(this.props,r,(t=this.presenceContext)===null||t===void 0?void 0:t.custom);a&&(i=a[e])}if(r&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!ed(s)?s:this.initialValues[e]!==void 0&&i===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new JG),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}}class Fpe extends HMe{constructor(){super(...arguments),this.KeyframeResolver=cpe}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){return e.style?e.style[t]:void 0}removeValueFromRenderState(e,{vars:t,style:r}){delete t[e],delete r[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;ed(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}}function $Me(n){return window.getComputedStyle(n)}class WMe extends Fpe{constructor(){super(...arguments),this.type="html",this.renderInstance=T0e}readValueFromInstance(e,t){if(Hv.has(t)){const r=iH(t);return r&&r.default||0}else{const r=$Me(e),i=(_0e(t)?r.getPropertyValue(t):r[t])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Epe(e,t)}build(e,t,r){VG(e,t,r.transformTemplate)}scrapeMotionValuesFromProps(e,t,r){return $G(e,t,r)}}class XMe extends Fpe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Ml}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Hv.has(t)){const r=iH(t);return r&&r.default||0}return t=E0e.has(t)?t:OG(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,r){return C0e(e,t,r)}build(e,t,r){qG(e,t,this.isSVGTag,r.transformTemplate)}renderInstance(e,t,r,i){N0e(e,t,r,i)}mount(e){this.isSVGTag=HG(e.tagName),super.mount(e)}}const YMe=(n,e)=>FG(n)?new XMe(e):new WMe(e,{allowProjection:n!==de.Fragment}),ZMe=b8e({...vNe,...BMe,...MMe,...UMe},YMe),Gn=OTe(ZMe);var Bpe={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},xK=ln.createContext&&ln.createContext(Bpe),QMe=["attr","size","title"];function KMe(n,e){if(n==null)return{};var t,r,i=JMe(n,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(r=0;rln.createElement(e.tag,mM({key:t},e.attr),Upe(e.child)))}function wn(n){return e=>ln.createElement(rCe,pM({attr:mM({},n.attr)},e),Upe(n.child))}function rCe(n){var e=t=>{var{attr:r,size:i,title:s}=n,a=KMe(n,QMe),o=i||t.size||"1em",l;return t.className&&(l=t.className),n.className&&(l=(l?l+" ":"")+n.className),ln.createElement("svg",pM({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,a,{className:l,style:mM(mM({color:n.color||t.color},t.style),n.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),s&&ln.createElement("title",null,s),n.children)};return xK!==void 0?ln.createElement(xK.Consumer,null,t=>e(t)):e(Bpe)}function zpe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"},child:[]}]})(n)}function Vpe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448,209.91a210.06,210.06,0,0,1-122.77-39.25V349.38A162.55,162.55,0,1,1,185,188.31V278.2a74.62,74.62,0,1,0,52.23,71.18V0l88,0a121.18,121.18,0,0,0,1.86,22.17h0A122.18,122.18,0,0,0,381,102.39a121.43,121.43,0,0,0,67,20.14Z"},child:[]}]})(n)}function qpe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"},child:[]}]})(n)}function Gpe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224.1 141c-63.6 0-114.9 51.3-114.9 114.9s51.3 114.9 114.9 114.9S339 319.5 339 255.9 287.7 141 224.1 141zm0 189.6c-41.1 0-74.7-33.5-74.7-74.7s33.5-74.7 74.7-74.7 74.7 33.5 74.7 74.7-33.6 74.7-74.7 74.7zm146.4-194.3c0 14.9-12 26.8-26.8 26.8-14.9 0-26.8-12-26.8-26.8s12-26.8 26.8-26.8 26.8 12 26.8 26.8zm76.1 27.2c-1.7-35.9-9.9-67.7-36.2-93.9-26.2-26.2-58-34.4-93.9-36.2-37-2.1-147.9-2.1-184.9 0-35.8 1.7-67.6 9.9-93.9 36.1s-34.4 58-36.2 93.9c-2.1 37-2.1 147.9 0 184.9 1.7 35.9 9.9 67.7 36.2 93.9s58 34.4 93.9 36.2c37 2.1 147.9 2.1 184.9 0 35.9-1.7 67.7-9.9 93.9-36.2 26.2-26.2 34.4-58 36.2-93.9 2.1-37 2.1-147.8 0-184.8zM398.8 388c-7.8 19.6-22.9 34.7-42.6 42.6-29.5 11.7-99.5 9-132.1 9s-102.7 2.6-132.1-9c-19.6-7.8-34.7-22.9-42.6-42.6-11.7-29.5-9-99.5-9-132.1s-2.6-102.7 9-132.1c7.8-19.6 22.9-34.7 42.6-42.6 29.5-11.7 99.5-9 132.1-9s102.7-2.6 132.1 9c19.6 7.8 34.7 22.9 42.6 42.6 11.7 29.5 9 99.5 9 132.1s2.7 102.7-9 132.1z"},child:[]}]})(n)}function Hpe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 256C504 119 393 8 256 8S8 119 8 256c0 123.78 90.69 226.38 209.25 245V327.69h-63V256h63v-54.64c0-62.15 37-96.48 93.67-96.48 27.14 0 55.52 4.84 55.52 4.84v61h-31.28c-30.8 0-40.41 19.12-40.41 38.73V256h68.78l-11 71.69h-57.78V501C413.31 482.38 504 379.78 504 256z"},child:[]}]})(n)}function jA(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M96 224c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm448 0c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm32 32h-64c-17.6 0-33.5 7.1-45.1 18.6 40.3 22.1 68.9 62 75.1 109.4h66c17.7 0 32-14.3 32-32v-32c0-35.3-28.7-64-64-64zm-256 0c61.9 0 112-50.1 112-112S381.9 32 320 32 208 82.1 208 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C179.6 288 128 339.6 128 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zm-223.7-13.4C161.5 263.1 145.6 256 128 256H64c-35.3 0-64 28.7-64 64v32c0 17.7 14.3 32 32 32h65.9c6.3-47.4 34.9-87.3 75.2-109.4z"},child:[]}]})(n)}function hm(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"},child:[]}]})(n)}function iCe(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M622.3 271.1l-115.2-45c-4.1-1.6-12.6-3.7-22.2 0l-115.2 45c-10.7 4.2-17.7 14-17.7 24.9 0 111.6 68.7 188.8 132.9 213.9 9.6 3.7 18 1.6 22.2 0C558.4 489.9 640 420.5 640 296c0-10.9-7-20.7-17.7-24.9zM496 462.4V273.3l95.5 37.3c-5.6 87.1-60.9 135.4-95.5 151.8zM224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm96 40c0-2.5.8-4.8 1.1-7.2-2.5-.1-4.9-.8-7.5-.8h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c6.8 0 13.3-1.5 19.2-4-54-42.9-99.2-116.7-99.2-212z"},child:[]}]})(n)}function sCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M383.9 308.3l23.9-62.6c4-10.5-3.7-21.7-15-21.7h-58.5c11-18.9 17.8-40.6 17.8-64v-.3c39.2-7.8 64-19.1 64-31.7 0-13.3-27.3-25.1-70.1-33-9.2-32.8-27-65.8-40.6-82.8-9.5-11.9-25.9-15.6-39.5-8.8l-27.6 13.8c-9 4.5-19.6 4.5-28.6 0L182.1 3.4c-13.6-6.8-30-3.1-39.5 8.8-13.5 17-31.4 50-40.6 82.8-42.7 7.9-70 19.7-70 33 0 12.6 24.8 23.9 64 31.7v.3c0 23.4 6.8 45.1 17.8 64H56.3c-11.5 0-19.2 11.7-14.7 22.3l25.8 60.2C27.3 329.8 0 372.7 0 422.4v44.8C0 491.9 20.1 512 44.8 512h358.4c24.7 0 44.8-20.1 44.8-44.8v-44.8c0-48.4-25.8-90.4-64.1-114.1zM176 480l-41.6-192 49.6 32 24 40-32 120zm96 0l-32-120 24-40 49.6-32L272 480zm41.7-298.5c-3.9 11.9-7 24.6-16.5 33.4-10.1 9.3-48 22.4-64-25-2.8-8.4-15.4-8.4-18.3 0-17 50.2-56 32.4-64 25-9.5-8.8-12.7-21.5-16.5-33.4-.8-2.5-6.3-5.7-6.3-5.8v-10.8c28.3 3.6 61 5.8 96 5.8s67.7-2.1 96-5.8v10.8c-.1.1-5.6 3.2-6.4 5.8z"},child:[]}]})(n)}function F_(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M624 208h-64v-64c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v64h-64c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h64v64c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-64h64c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm-400 48c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z"},child:[]}]})(n)}function cH(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M319.4 320.6L224 416l-95.4-95.4C57.1 323.7 0 382.2 0 454.4v9.6c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-9.6c0-72.2-57.1-130.7-128.6-133.8zM13.6 79.8l6.4 1.5v58.4c-7 4.2-12 11.5-12 20.3 0 8.4 4.6 15.4 11.1 19.7L3.5 242c-1.7 6.9 2.1 14 7.6 14h41.8c5.5 0 9.3-7.1 7.6-14l-15.6-62.3C51.4 175.4 56 168.4 56 160c0-8.8-5-16.1-12-20.3V87.1l66 15.9c-8.6 17.2-14 36.4-14 57 0 70.7 57.3 128 128 128s128-57.3 128-128c0-20.6-5.3-39.8-14-57l96.3-23.2c18.2-4.4 18.2-27.1 0-31.5l-190.4-46c-13-3.1-26.7-3.1-39.7 0L13.6 48.2c-18.1 4.4-18.1 27.2 0 31.6z"},child:[]}]})(n)}function $pe(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M192 256c61.9 0 112-50.1 112-112S253.9 32 192 32 80 82.1 80 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C51.6 288 0 339.6 0 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zM480 256c53 0 96-43 96-96s-43-96-96-96-96 43-96 96 43 96 96 96zm48 32h-3.8c-13.9 4.8-28.6 8-44.2 8s-30.3-3.2-44.2-8H432c-20.4 0-39.2 5.9-55.7 15.4 24.4 26.3 39.7 61.2 39.7 99.8v38.4c0 2.2-.5 4.3-.6 6.4H592c26.5 0 48-21.5 48-48 0-61.9-50.1-112-112-112z"},child:[]}]})(n)}function M7(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4zm323-128.4l-27.8-28.1c-4.6-4.7-12.1-4.7-16.8-.1l-104.8 104-45.5-45.8c-4.6-4.7-12.1-4.7-16.8-.1l-28.1 27.9c-4.7 4.6-4.7 12.1-.1 16.8l81.7 82.3c4.6 4.7 12.1 4.7 16.8.1l141.3-140.2c4.6-4.7 4.7-12.2.1-16.8z"},child:[]}]})(n)}function gM(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(n)}function aCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M212.333 224.333H12c-6.627 0-12-5.373-12-12V12C0 5.373 5.373 0 12 0h48c6.627 0 12 5.373 12 12v78.112C117.773 39.279 184.26 7.47 258.175 8.007c136.906.994 246.448 111.623 246.157 248.532C504.041 393.258 393.12 504 256.333 504c-64.089 0-122.496-24.313-166.51-64.215-5.099-4.622-5.334-12.554-.467-17.42l33.967-33.967c4.474-4.474 11.662-4.717 16.401-.525C170.76 415.336 211.58 432 256.333 432c97.268 0 176-78.716 176-176 0-97.267-78.716-176-176-176-58.496 0-110.28 28.476-142.274 72.333h98.274c6.627 0 12 5.373 12 12v48c0 6.627-5.373 12-12 12z"},child:[]}]})(n)}function z0(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z"},child:[]}]})(n)}function oCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M32 464a48 48 0 0 0 48 48h288a48 48 0 0 0 48-48V128H32zm272-256a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zm-96 0a16 16 0 0 1 32 0v224a16 16 0 0 1-32 0zM432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16z"},child:[]}]})(n)}function lCe(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M372 0h-79c-10.7 0-16 12.9-8.5 20.5l16.9 16.9-80.7 80.7C198.5 104.1 172.2 96 144 96 64.5 96 0 160.5 0 240c0 68.5 47.9 125.9 112 140.4V408H76c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h36v28c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-28h36c6.6 0 12-5.4 12-12v-40c0-6.6-5.4-12-12-12h-36v-27.6c64.1-14.6 112-71.9 112-140.4 0-28.2-8.1-54.5-22.1-76.7l80.7-80.7 16.9 16.9c7.6 7.6 20.5 2.2 20.5-8.5V12c0-6.6-5.4-12-12-12zM144 320c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"},child:[]}]})(n)}function $a(n){return wn({attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"},child:[]}]})(n)}function cCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"},child:[]}]})(n)}function uCe(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M257.981 272.971L63.638 467.314c-9.373 9.373-24.569 9.373-33.941 0L7.029 444.647c-9.357-9.357-9.375-24.522-.04-33.901L161.011 256 6.99 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L257.981 239.03c9.373 9.372 9.373 24.568 0 33.941zM640 456v-32c0-13.255-10.745-24-24-24H312c-13.255 0-24 10.745-24 24v32c0 13.255 10.745 24 24 24h304c13.255 0 24-10.745 24-24z"},child:[]}]})(n)}function AM(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M370.72 133.28C339.458 104.008 298.888 87.962 255.848 88c-77.458.068-144.328 53.178-162.791 126.85-1.344 5.363-6.122 9.15-11.651 9.15H24.103c-7.498 0-13.194-6.807-11.807-14.176C33.933 94.924 134.813 8 256 8c66.448 0 126.791 26.136 171.315 68.685L463.03 40.97C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.749zM32 296h134.059c21.382 0 32.09 25.851 16.971 40.971l-41.75 41.75c31.262 29.273 71.835 45.319 114.876 45.28 77.418-.07 144.315-53.144 162.787-126.849 1.344-5.363 6.122-9.15 11.651-9.15h57.304c7.498 0 13.194 6.807 11.807 14.176C478.067 417.076 377.187 504 256 504c-66.448 0-126.791-26.136-171.315-68.685L48.97 471.03C33.851 486.149 8 475.441 8 454.059V320c0-13.255 10.745-24 24-24z"},child:[]}]})(n)}function V0(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"},child:[]}]})(n)}function dCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M32 512h448v-64H32v64zm384-256h-66.56c-16.26 0-29.44-13.18-29.44-29.44v-9.46c0-27.37 8.88-53.41 21.46-77.72 9.11-17.61 12.9-38.39 9.05-60.42-6.77-38.78-38.47-70.7-77.26-77.45C212.62-9.04 160 37.33 160 96c0 14.16 3.12 27.54 8.69 39.58C182.02 164.43 192 194.7 192 226.49v.07c0 16.26-13.18 29.44-29.44 29.44H96c-53.02 0-96 42.98-96 96v32c0 17.67 14.33 32 32 32h448c17.67 0 32-14.33 32-32v-32c0-53.02-42.98-96-96-96z"},child:[]}]})(n)}function vu(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z"},child:[]}]})(n)}function hCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M330.17 258.91a79 79 0 0 0-55 54.17c-14.27 51.05 21.19 97.77 68.83 102.53a84.07 84.07 0 0 1-20.85 12.91c-7.57 3.4-10.8 12.47-8.18 20.34l9.9 20c2.87 8.63 12.53 13.49 20.9 9.91 58-24.76 86.25-61.61 86.25-132V336c-.02-51.21-48.4-91.34-101.85-77.09zM352 356a20 20 0 1 1 20-20 20 20 0 0 1-20 20zM304 96h16v64h-16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h96a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-16V48a16 16 0 0 0-16-16h-48a16 16 0 0 0-14.29 8.83l-16 32A16 16 0 0 0 304 96zM107.31 36.69a16 16 0 0 0-22.62 0l-80 96C-5.35 142.74 1.78 160 16 160h48v304a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V160h48c14.21 0 21.38-17.24 11.31-27.31z"},child:[]}]})(n)}function fCe(n){return wn({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm80 168c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm-160 0c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zm194.8 170.2C334.3 380.4 292.5 400 248 400s-86.3-19.6-114.8-53.8c-13.6-16.3 11-36.7 24.6-20.5 22.4 26.9 55.2 42.2 90.2 42.2s67.8-15.4 90.2-42.2c13.4-16.2 38.1 4.2 24.6 20.5z"},child:[]}]})(n)}function Wpe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M496 384H160v-16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h80v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h336c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-160h-80v-16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h336v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h80c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm0-160H288V48c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v16H16C7.2 64 0 71.2 0 80v32c0 8.8 7.2 16 16 16h208v16c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16v-16h208c8.8 0 16-7.2 16-16V80c0-8.8-7.2-16-16-16z"},child:[]}]})(n)}function X4(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M128 352H32c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h96c17.67 0 32-14.33 32-32v-96c0-17.67-14.33-32-32-32zm-24-80h192v48h48v-48h192v48h48v-57.59c0-21.17-17.23-38.41-38.41-38.41H344v-64h40c17.67 0 32-14.33 32-32V32c0-17.67-14.33-32-32-32H256c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h40v64H94.41C73.23 224 56 241.23 56 262.41V320h48v-48zm264 80h-96c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h96c17.67 0 32-14.33 32-32v-96c0-17.67-14.33-32-32-32zm240 0h-96c-17.67 0-32 14.33-32 32v96c0 17.67 14.33 32 32 32h96c17.67 0 32-14.33 32-32v-96c0-17.67-14.33-32-32-32z"},child:[]}]})(n)}function Xpe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497 273L329 441c-15 15-41 4.5-41-17v-96H152c-13.3 0-24-10.7-24-24v-96c0-13.3 10.7-24 24-24h136V88c0-21.4 25.9-32 41-17l168 168c9.3 9.4 9.3 24.6 0 34zM192 436v-40c0-6.6-5.4-12-12-12H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h84c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12H96c-53 0-96 43-96 96v192c0 53 43 96 96 96h84c6.6 0 12-5.4 12-12z"},child:[]}]})(n)}function uH(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M466.5 83.7l-192-80a48.15 48.15 0 0 0-36.9 0l-192 80C27.7 91.1 16 108.6 16 128c0 198.5 114.5 335.7 221.5 380.3 11.8 4.9 25.1 4.9 36.9 0C360.1 472.6 496 349.3 496 128c0-19.4-11.7-36.9-29.5-44.3zM256.1 446.3l-.1-381 175.9 73.3c-3.3 151.4-82.1 261.1-175.8 307.7z"},child:[]}]})(n)}function pCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M352 320c-22.608 0-43.387 7.819-59.79 20.895l-102.486-64.054a96.551 96.551 0 0 0 0-41.683l102.486-64.054C308.613 184.181 329.392 192 352 192c53.019 0 96-42.981 96-96S405.019 0 352 0s-96 42.981-96 96c0 7.158.79 14.13 2.276 20.841L155.79 180.895C139.387 167.819 118.608 160 96 160c-53.019 0-96 42.981-96 96s42.981 96 96 96c22.608 0 43.387-7.819 59.79-20.895l102.486 64.054A96.301 96.301 0 0 0 256 416c0 53.019 42.981 96 96 96s96-42.981 96-96-42.981-96-96-96z"},child:[]}]})(n)}function X0(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"},child:[]}]})(n)}function yK(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 192v32c0 6.6-5.4 12-12 12h-56v56c0 6.6-5.4 12-12 12h-32c-6.6 0-12-5.4-12-12v-56h-56c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h56v-56c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v56h56c6.6 0 12 5.4 12 12zm201 284.7L476.7 505c-9.4 9.4-24.6 9.4-33.9 0L343 405.3c-4.5-4.5-7-10.6-7-17V372c-35.3 27.6-79.7 44-128 44C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208c0 48.3-16.4 92.7-44 128h16.3c6.4 0 12.5 2.5 17 7l99.7 99.7c9.3 9.4 9.3 24.6 0 34zM344 208c0-75.2-60.8-136-136-136S72 132.8 72 208s60.8 136 136 136 136-60.8 136-136z"},child:[]}]})(n)}function mCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304 192v32c0 6.6-5.4 12-12 12H124c-6.6 0-12-5.4-12-12v-32c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm201 284.7L476.7 505c-9.4 9.4-24.6 9.4-33.9 0L343 405.3c-4.5-4.5-7-10.6-7-17V372c-35.3 27.6-79.7 44-128 44C93.1 416 0 322.9 0 208S93.1 0 208 0s208 93.1 208 208c0 48.3-16.4 92.7-44 128h16.3c6.4 0 12.5 2.5 17 7l99.7 99.7c9.3 9.4 9.3 24.6 0 34zM344 208c0-75.2-60.8-136-136-136S72 132.8 72 208s60.8 136 136 136 136-60.8 136-136z"},child:[]}]})(n)}function dH(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"},child:[]}]})(n)}function gCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M416 320h-96c-17.6 0-32-14.4-32-32s14.4-32 32-32h96s96-107 96-160-43-96-96-96-96 43-96 96c0 25.5 22.2 63.4 45.3 96H320c-52.9 0-96 43.1-96 96s43.1 96 96 96h96c17.6 0 32 14.4 32 32s-14.4 32-32 32H185.5c-16 24.8-33.8 47.7-47.3 64H416c52.9 0 96-43.1 96-96s-43.1-96-96-96zm0-256c17.7 0 32 14.3 32 32s-14.3 32-32 32-32-14.3-32-32 14.3-32 32-32zM96 256c-53 0-96 43-96 96s96 160 96 160 96-107 96-160-43-96-96-96zm0 128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"},child:[]}]})(n)}function ACe(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M32,224H64V416H32A31.96166,31.96166,0,0,1,0,384V256A31.96166,31.96166,0,0,1,32,224Zm512-48V448a64.06328,64.06328,0,0,1-64,64H160a64.06328,64.06328,0,0,1-64-64V176a79.974,79.974,0,0,1,80-80H288V32a32,32,0,0,1,64,0V96H464A79.974,79.974,0,0,1,544,176ZM264,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,264,256Zm-8,128H192v32h64Zm96,0H288v32h64ZM456,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,456,256Zm-8,128H384v32h64ZM640,256V384a31.96166,31.96166,0,0,1-32,32H576V224h32A31.96166,31.96166,0,0,1,640,256Z"},child:[]}]})(n)}function xCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M500.33 0h-47.41a12 12 0 0 0-12 12.57l4 82.76A247.42 247.42 0 0 0 256 8C119.34 8 7.9 119.53 8 256.19 8.1 393.07 119.1 504 256 504a247.1 247.1 0 0 0 166.18-63.91 12 12 0 0 0 .48-17.43l-34-34a12 12 0 0 0-16.38-.55A176 176 0 1 1 402.1 157.8l-101.53-4.87a12 12 0 0 0-12.57 12v47.41a12 12 0 0 0 12 12h200.33a12 12 0 0 0 12-12V12a12 12 0 0 0-12-12z"},child:[]}]})(n)}function vCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256.455 8c66.269.119 126.437 26.233 170.859 68.685l35.715-35.715C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.75c-30.864-28.899-70.801-44.907-113.23-45.273-92.398-.798-170.283 73.977-169.484 169.442C88.764 348.009 162.184 424 256 424c41.127 0 79.997-14.678 110.629-41.556 4.743-4.161 11.906-3.908 16.368.553l39.662 39.662c4.872 4.872 4.631 12.815-.482 17.433C378.202 479.813 319.926 504 256 504 119.034 504 8.001 392.967 8 256.002 7.999 119.193 119.646 7.755 256.455 8z"},child:[]}]})(n)}function hH(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 256h-80v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8c-88.4 0-160 71.6-160 160v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48zm-288 0H96v-64c0-35.3 28.7-64 64-64h8c13.3 0 24-10.7 24-24V56c0-13.3-10.7-24-24-24h-8C71.6 32 0 103.6 0 192v240c0 26.5 21.5 48 48 48h128c26.5 0 48-21.5 48-48V304c0-26.5-21.5-48-48-48z"},child:[]}]})(n)}function yCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M448 192V77.25c0-8.49-3.37-16.62-9.37-22.63L393.37 9.37c-6-6-14.14-9.37-22.63-9.37H96C78.33 0 64 14.33 64 32v160c-35.35 0-64 28.65-64 64v112c0 8.84 7.16 16 16 16h48v96c0 17.67 14.33 32 32 32h320c17.67 0 32-14.33 32-32v-96h48c8.84 0 16-7.16 16-16V256c0-35.35-28.65-64-64-64zm-64 256H128v-96h256v96zm0-224H128V64h192v48c0 8.84 7.16 16 16 16h48v96zm48 72c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"},child:[]}]})(n)}function bCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M267.429 488.563C262.286 507.573 242.858 512 224 512c-18.857 0-38.286-4.427-43.428-23.437C172.927 460.134 160 388.898 160 355.75c0-35.156 31.142-43.75 64-43.75s64 8.594 64 43.75c0 32.949-12.871 104.179-20.571 132.813zM156.867 288.554c-18.693-18.308-29.958-44.173-28.784-72.599 2.054-49.724 42.395-89.956 92.124-91.881C274.862 121.958 320 165.807 320 220c0 26.827-11.064 51.116-28.866 68.552-2.675 2.62-2.401 6.986.628 9.187 9.312 6.765 16.46 15.343 21.234 25.363 1.741 3.654 6.497 4.66 9.449 1.891 28.826-27.043 46.553-65.783 45.511-108.565-1.855-76.206-63.595-138.208-139.793-140.369C146.869 73.753 80 139.215 80 220c0 41.361 17.532 78.7 45.55 104.989 2.953 2.771 7.711 1.77 9.453-1.887 4.774-10.021 11.923-18.598 21.235-25.363 3.029-2.2 3.304-6.566.629-9.185zM224 0C100.204 0 0 100.185 0 224c0 89.992 52.602 165.647 125.739 201.408 4.333 2.118 9.267-1.544 8.535-6.31-2.382-15.512-4.342-30.946-5.406-44.339-.146-1.836-1.149-3.486-2.678-4.512-47.4-31.806-78.564-86.016-78.187-147.347.592-96.237 79.29-174.648 175.529-174.899C320.793 47.747 400 126.797 400 224c0 61.932-32.158 116.49-80.65 147.867-.999 14.037-3.069 30.588-5.624 47.23-.732 4.767 4.203 8.429 8.535 6.31C395.227 389.727 448 314.187 448 224 448 100.205 347.815 0 224 0zm0 160c-35.346 0-64 28.654-64 64s28.654 64 64 64 64-28.654 64-64-28.654-64-64-64z"},child:[]}]})(n)}function P0(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"},child:[]}]})(n)}function _Ce(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"},child:[]}]})(n)}function wCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M493.4 24.6l-104-24c-11.3-2.6-22.9 3.3-27.5 13.9l-48 112c-4.2 9.8-1.4 21.3 6.9 28l60.6 49.6c-36 76.7-98.9 140.5-177.2 177.2l-49.6-60.6c-6.8-8.3-18.2-11.1-28-6.9l-112 48C3.9 366.5-2 378.1.6 389.4l24 104C27.1 504.2 36.7 512 48 512c256.1 0 464-207.5 464-464 0-11.2-7.7-20.9-18.6-23.4z"},child:[]}]})(n)}function SCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M136.6 138.79a64.003 64.003 0 0 0-43.31 41.35L0 460l14.69 14.69L164.8 324.58c-2.99-6.26-4.8-13.18-4.8-20.58 0-26.51 21.49-48 48-48s48 21.49 48 48-21.49 48-48 48c-7.4 0-14.32-1.81-20.58-4.8L37.31 497.31 52 512l279.86-93.29a64.003 64.003 0 0 0 41.35-43.31L416 224 288 96l-151.4 42.79zm361.34-64.62l-60.11-60.11c-18.75-18.75-49.16-18.75-67.91 0l-56.55 56.55 128.02 128.02 56.55-56.55c18.75-18.75 18.75-49.15 0-67.91z"},child:[]}]})(n)}function TCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z"},child:[]}]})(n)}function Ype(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M476 3.2L12.5 270.6c-18.1 10.4-15.8 35.6 2.2 43.2L121 358.4l287.3-253.2c5.5-4.9 13.3 2.6 8.6 8.3L176 407v80.5c0 23.6 28.5 32.9 42.5 15.8L282 426l124.6 52.2c14.2 6 30.4-2.9 33-18.2l72-432C515 7.8 493.3-6.8 476 3.2z"},child:[]}]})(n)}function sz(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M552 64H88c-13.255 0-24 10.745-24 24v8H24c-13.255 0-24 10.745-24 24v272c0 30.928 25.072 56 56 56h472c26.51 0 48-21.49 48-48V88c0-13.255-10.745-24-24-24zM56 400a8 8 0 0 1-8-8V144h16v248a8 8 0 0 1-8 8zm236-16H140c-6.627 0-12-5.373-12-12v-8c0-6.627 5.373-12 12-12h152c6.627 0 12 5.373 12 12v8c0 6.627-5.373 12-12 12zm208 0H348c-6.627 0-12-5.373-12-12v-8c0-6.627 5.373-12 12-12h152c6.627 0 12 5.373 12 12v8c0 6.627-5.373 12-12 12zm-208-96H140c-6.627 0-12-5.373-12-12v-8c0-6.627 5.373-12 12-12h152c6.627 0 12 5.373 12 12v8c0 6.627-5.373 12-12 12zm208 0H348c-6.627 0-12-5.373-12-12v-8c0-6.627 5.373-12 12-12h152c6.627 0 12 5.373 12 12v8c0 6.627-5.373 12-12 12zm0-96H140c-6.627 0-12-5.373-12-12v-40c0-6.627 5.373-12 12-12h360c6.627 0 12 5.373 12 12v40c0 6.627-5.373 12-12 12z"},child:[]}]})(n)}function BS(n){return wn({attr:{viewBox:"0 0 352 512"},child:[{tag:"path",attr:{d:"M176 352c53.02 0 96-42.98 96-96V96c0-53.02-42.98-96-96-96S80 42.98 80 96v160c0 53.02 42.98 96 96 96zm160-160h-16c-8.84 0-16 7.16-16 16v48c0 74.8-64.49 134.82-140.79 127.38C96.71 376.89 48 317.11 48 250.3V208c0-8.84-7.16-16-16-16H16c-8.84 0-16 7.16-16 16v40.16c0 89.64 63.97 169.55 152 181.69V464H96c-8.84 0-16 7.16-16 16v16c0 8.84 7.16 16 16 16h160c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16h-56v-33.77C285.71 418.47 352 344.9 352 256v-48c0-8.84-7.16-16-16-16z"},child:[]}]})(n)}function bA(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M172.268 501.67C26.97 291.031 0 269.413 0 192 0 85.961 85.961 0 192 0s192 85.961 192 192c0 77.413-26.97 99.031-172.268 309.67-9.535 13.774-29.93 13.773-39.464 0zM192 272c44.183 0 80-35.817 80-80s-35.817-80-80-80-80 35.817-80 80 35.817 80 80 80z"},child:[]}]})(n)}function ECe(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M288 0c-69.59 0-126 56.41-126 126 0 56.26 82.35 158.8 113.9 196.02 6.39 7.54 17.82 7.54 24.2 0C331.65 284.8 414 182.26 414 126 414 56.41 357.59 0 288 0zm0 168c-23.2 0-42-18.8-42-42s18.8-42 42-42 42 18.8 42 42-18.8 42-42 42zM20.12 215.95A32.006 32.006 0 0 0 0 245.66v250.32c0 11.32 11.43 19.06 21.94 14.86L160 448V214.92c-8.84-15.98-16.07-31.54-21.25-46.42L20.12 215.95zM288 359.67c-14.07 0-27.38-6.18-36.51-16.96-19.66-23.2-40.57-49.62-59.49-76.72v182l192 64V266c-18.92 27.09-39.82 53.52-59.49 76.72-9.13 10.77-22.44 16.95-36.51 16.95zm266.06-198.51L416 224v288l139.88-55.95A31.996 31.996 0 0 0 576 426.34V176.02c0-11.32-11.43-19.06-21.94-14.86z"},child:[]}]})(n)}function NCe(n){return wn({attr:{viewBox:"0 0 192 512"},child:[{tag:"path",attr:{d:"M96 0c35.346 0 64 28.654 64 64s-28.654 64-64 64-64-28.654-64-64S60.654 0 96 0m48 144h-11.36c-22.711 10.443-49.59 10.894-73.28 0H48c-26.51 0-48 21.49-48 48v136c0 13.255 10.745 24 24 24h16v136c0 13.255 10.745 24 24 24h64c13.255 0 24-10.745 24-24V352h16c13.255 0 24-10.745 24-24V192c0-26.51-21.49-48-48-48z"},child:[]}]})(n)}function ld(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M224 96l16-32 32-16-32-16-16-32-16 32-32 16 32 16 16 32zM80 160l26.66-53.33L160 80l-53.34-26.67L80 0 53.34 53.33 0 80l53.34 26.67L80 160zm352 128l-26.66 53.33L352 368l53.34 26.67L432 448l26.66-53.33L512 368l-53.34-26.67L432 288zm70.62-193.77L417.77 9.38C411.53 3.12 403.34 0 395.15 0c-8.19 0-16.38 3.12-22.63 9.38L9.38 372.52c-12.5 12.5-12.5 32.76 0 45.25l84.85 84.85c6.25 6.25 14.44 9.37 22.62 9.37 8.19 0 16.38-3.12 22.63-9.37l363.14-363.15c12.5-12.48 12.5-32.75 0-45.24zM359.45 203.46l-50.91-50.91 86.6-86.6 50.91 50.91-86.6 86.6z"},child:[]}]})(n)}function MCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"},child:[]}]})(n)}function CCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"},child:[]}]})(n)}function xM(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"},child:[]}]})(n)}function PCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 110c23.196 0 42 18.804 42 42s-18.804 42-42 42-42-18.804-42-42 18.804-42 42-42zm56 254c0 6.627-5.373 12-12 12h-88c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h12v-64h-12c-6.627 0-12-5.373-12-12v-24c0-6.627 5.373-12 12-12h64c6.627 0 12 5.373 12 12v100h12c6.627 0 12 5.373 12 12v24z"},child:[]}]})(n)}function Zpe(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M480 416v16c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V176c0-26.51 21.49-48 48-48h16v208c0 44.112 35.888 80 80 80h336zm96-80V80c0-26.51-21.49-48-48-48H144c-26.51 0-48 21.49-48 48v256c0 26.51 21.49 48 48 48h384c26.51 0 48-21.49 48-48zM256 128c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-96 144l55.515-55.515c4.686-4.686 12.284-4.686 16.971 0L272 256l135.515-135.515c4.686-4.686 12.284-4.686 16.971 0L512 208v112H160v-48z"},child:[]}]})(n)}function fH(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(n)}function RCe(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M528 32H48C21.5 32 0 53.5 0 80v16h576V80c0-26.5-21.5-48-48-48zM0 432c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V128H0v304zm352-232c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zm0 64c0-4.4 3.6-8 8-8h144c4.4 0 8 3.6 8 8v16c0 4.4-3.6 8-8 8H360c-4.4 0-8-3.6-8-8v-16zM176 192c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zM67.1 396.2C75.5 370.5 99.6 352 128 352h8.2c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h8.2c28.4 0 52.5 18.5 60.9 44.2 3.2 9.9-5.2 19.8-15.6 19.8H82.7c-10.4 0-18.8-10-15.6-19.8z"},child:[]}]})(n)}function LCe(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M336 0H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V48c0-26.5-21.5-48-48-48zM144 32h96c8.8 0 16 7.2 16 16s-7.2 16-16 16h-96c-8.8 0-16-7.2-16-16s7.2-16 16-16zm48 128c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64zm112 236.8c0 10.6-10 19.2-22.4 19.2H102.4C90 416 80 407.4 80 396.8v-19.2c0-31.8 30.1-57.6 67.2-57.6h5c12.3 5.1 25.7 8 39.8 8s27.6-2.9 39.8-8h5c37.1 0 67.2 25.8 67.2 57.6v19.2z"},child:[]}]})(n)}function kCe(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M360 0H24C10.745 0 0 10.745 0 24v16c0 13.255 10.745 24 24 24 0 90.965 51.016 167.734 120.842 192C75.016 280.266 24 357.035 24 448c-13.255 0-24 10.745-24 24v16c0 13.255 10.745 24 24 24h336c13.255 0 24-10.745 24-24v-16c0-13.255-10.745-24-24-24 0-90.965-51.016-167.734-120.842-192C308.984 231.734 360 154.965 360 64c13.255 0 24-10.745 24-24V24c0-13.255-10.745-24-24-24zm-75.078 384H99.08c17.059-46.797 52.096-80 92.92-80 40.821 0 75.862 33.196 92.922 80zm.019-256H99.078C91.988 108.548 88 86.748 88 64h208c0 22.805-3.987 44.587-11.059 64z"},child:[]}]})(n)}function tN(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"},child:[]}]})(n)}function pH(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 255.531c.253 136.64-111.18 248.372-247.82 248.468-59.015.042-113.223-20.53-155.822-54.911-11.077-8.94-11.905-25.541-1.839-35.607l11.267-11.267c8.609-8.609 22.353-9.551 31.891-1.984C173.062 425.135 212.781 440 256 440c101.705 0 184-82.311 184-184 0-101.705-82.311-184-184-184-48.814 0-93.149 18.969-126.068 49.932l50.754 50.754c10.08 10.08 2.941 27.314-11.313 27.314H24c-8.837 0-16-7.163-16-16V38.627c0-14.254 17.234-21.393 27.314-11.314l49.372 49.372C129.209 34.136 189.552 8 256 8c136.81 0 247.747 110.78 248 247.531zm-180.912 78.784l9.823-12.63c8.138-10.463 6.253-25.542-4.21-33.679L288 256.349V152c0-13.255-10.745-24-24-24h-16c-13.255 0-24 10.745-24 24v135.651l65.409 50.874c10.463 8.137 25.541 6.253 33.679-4.21z"},child:[]}]})(n)}function Y0(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"},child:[]}]})(n)}function mH(n){return wn({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M248 8C111.03 8 0 119.03 0 256s111.03 248 248 248 248-111.03 248-248S384.97 8 248 8zm82.29 357.6c-3.9 3.88-7.99 7.95-11.31 11.28-2.99 3-5.1 6.7-6.17 10.71-1.51 5.66-2.73 11.38-4.77 16.87l-17.39 46.85c-13.76 3-28 4.69-42.65 4.69v-27.38c1.69-12.62-7.64-36.26-22.63-51.25-6-6-9.37-14.14-9.37-22.63v-32.01c0-11.64-6.27-22.34-16.46-27.97-14.37-7.95-34.81-19.06-48.81-26.11-11.48-5.78-22.1-13.14-31.65-21.75l-.8-.72a114.792 114.792 0 0 1-18.06-20.74c-9.38-13.77-24.66-36.42-34.59-51.14 20.47-45.5 57.36-82.04 103.2-101.89l24.01 12.01C203.48 89.74 216 82.01 216 70.11v-11.3c7.99-1.29 16.12-2.11 24.39-2.42l28.3 28.3c6.25 6.25 6.25 16.38 0 22.63L264 112l-10.34 10.34c-3.12 3.12-3.12 8.19 0 11.31l4.69 4.69c3.12 3.12 3.12 8.19 0 11.31l-8 8a8.008 8.008 0 0 1-5.66 2.34h-8.99c-2.08 0-4.08.81-5.58 2.27l-9.92 9.65a8.008 8.008 0 0 0-1.58 9.31l15.59 31.19c2.66 5.32-1.21 11.58-7.15 11.58h-5.64c-1.93 0-3.79-.7-5.24-1.96l-9.28-8.06a16.017 16.017 0 0 0-15.55-3.1l-31.17 10.39a11.95 11.95 0 0 0-8.17 11.34c0 4.53 2.56 8.66 6.61 10.69l11.08 5.54c9.41 4.71 19.79 7.16 30.31 7.16s22.59 27.29 32 32h66.75c8.49 0 16.62 3.37 22.63 9.37l13.69 13.69a30.503 30.503 0 0 1 8.93 21.57 46.536 46.536 0 0 1-13.72 32.98zM417 274.25c-5.79-1.45-10.84-5-14.15-9.97l-17.98-26.97a23.97 23.97 0 0 1 0-26.62l19.59-29.38c2.32-3.47 5.5-6.29 9.24-8.15l12.98-6.49C440.2 193.59 448 223.87 448 256c0 8.67-.74 17.16-1.82 25.54L417 274.25z"},child:[]}]})(n)}function bK(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.694 292.093L500.27 416.248A63.997 63.997 0 0 1 444.989 448H45.025c-18.523 0-30.064-20.093-20.731-36.093l72.424-124.155A64 64 0 0 1 152 256h399.964c18.523 0 30.064 20.093 20.73 36.093zM152 224h328v-48c0-26.51-21.49-48-48-48H272l-64-64H48C21.49 64 0 85.49 0 112v278.046l69.077-118.418C86.214 242.25 117.989 224 152 224z"},child:[]}]})(n)}function gH(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.976 0H24.028C2.71 0-8.047 25.866 7.058 40.971L192 225.941V432c0 7.831 3.821 15.17 10.237 19.662l80 55.98C298.02 518.69 320 507.493 320 487.98V225.941l184.947-184.97C520.021 25.896 509.338 0 487.976 0z"},child:[]}]})(n)}function ICe(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm65.18 216.01H224v80c0 8.84-7.16 16-16 16h-32c-8.84 0-16-7.16-16-16v-80H94.82c-14.28 0-21.41-17.29-11.27-27.36l96.42-95.7c6.65-6.61 17.39-6.61 24.04 0l96.42 95.7c10.15 10.07 3.03 27.36-11.25 27.36zM377 105L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z"},child:[]}]})(n)}function DCe(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(n)}function Qpe(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm64 236c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-64c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-72v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm96-114.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"},child:[]}]})(n)}function OCe(n){return wn({attr:{viewBox:"0 0 256 512"},child:[{tag:"path",attr:{d:"M128 0c35.346 0 64 28.654 64 64s-28.654 64-64 64c-35.346 0-64-28.654-64-64S92.654 0 128 0m119.283 354.179l-48-192A24 24 0 0 0 176 144h-11.36c-22.711 10.443-49.59 10.894-73.28 0H80a24 24 0 0 0-23.283 18.179l-48 192C4.935 369.305 16.383 384 32 384h56v104c0 13.255 10.745 24 24 24h32c13.255 0 24-10.745 24-24V384h56c15.591 0 27.071-14.671 23.283-29.821z"},child:[]}]})(n)}function jCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M512 0C460.22 3.56 96.44 38.2 71.01 287.61c-3.09 26.66-4.84 53.44-5.99 80.24l178.87-178.69c6.25-6.25 16.4-6.25 22.65 0s6.25 16.38 0 22.63L7.04 471.03c-9.38 9.37-9.38 24.57 0 33.94 9.38 9.37 24.59 9.37 33.98 0l57.13-57.07c42.09-.14 84.15-2.53 125.96-7.36 53.48-5.44 97.02-26.47 132.58-56.54H255.74l146.79-48.88c11.25-14.89 21.37-30.71 30.45-47.12h-81.14l106.54-53.21C500.29 132.86 510.19 26.26 512 0z"},child:[]}]})(n)}function Kpe(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M572.52 241.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400a144 144 0 1 1 144-144 143.93 143.93 0 0 1-144 144zm0-240a95.31 95.31 0 0 0-25.31 3.79 47.85 47.85 0 0 1-66.9 66.9A95.78 95.78 0 1 0 288 160z"},child:[]}]})(n)}function nN(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"},child:[]}]})(n)}function vM(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},child:[]}]})(n)}function FCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M0 168v-16c0-13.255 10.745-24 24-24h360V80c0-21.367 25.899-32.042 40.971-16.971l80 80c9.372 9.373 9.372 24.569 0 33.941l-80 80C409.956 271.982 384 261.456 384 240v-48H24c-13.255 0-24-10.745-24-24zm488 152H128v-48c0-21.314-25.862-32.08-40.971-16.971l-80 80c-9.372 9.373-9.372 24.569 0 33.941l80 80C102.057 463.997 128 453.437 128 432v-48h360c13.255 0 24-10.745 24-24v-16c0-13.255-10.745-24-24-24z"},child:[]}]})(n)}function AH(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"},child:[]}]})(n)}function Pg(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M402.6 83.2l90.2 90.2c3.8 3.8 3.8 10 0 13.8L274.4 405.6l-92.8 10.3c-12.4 1.4-22.9-9.1-21.5-21.5l10.3-92.8L388.8 83.2c3.8-3.8 10-3.8 13.8 0zm162-22.9l-48.8-48.8c-15.2-15.2-39.9-15.2-55.2 0l-35.4 35.4c-3.8 3.8-3.8 10 0 13.8l90.2 90.2c3.8 3.8 10 3.8 13.8 0l35.4-35.4c15.2-15.3 15.2-40 0-55.2zM384 346.2V448H64V128h229.8c3.2 0 6.2-1.3 8.5-3.5l40-40c7.6-7.6 2.2-20.5-8.5-20.5H48C21.5 64 0 85.5 0 112v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V306.2c0-10.7-12.9-16-20.5-8.5l-40 40c-2.2 2.3-3.5 5.3-3.5 8.5z"},child:[]}]})(n)}function T3(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(n)}function _K(n){return wn({attr:{viewBox:"0 0 640 512"},child:[{tag:"path",attr:{d:"M528 448H112c-8.8 0-16 7.2-16 16v32c0 8.8 7.2 16 16 16h416c8.8 0 16-7.2 16-16v-32c0-8.8-7.2-16-16-16zm64-320c-26.5 0-48 21.5-48 48 0 7.1 1.6 13.7 4.4 19.8L476 239.2c-15.4 9.2-35.3 4-44.2-11.6L350.3 85C361 76.2 368 63 368 48c0-26.5-21.5-48-48-48s-48 21.5-48 48c0 15 7 28.2 17.7 37l-81.5 142.6c-8.9 15.6-28.9 20.8-44.2 11.6l-72.3-43.4c2.7-6 4.4-12.7 4.4-19.8 0-26.5-21.5-48-48-48S0 149.5 0 176s21.5 48 48 48c2.6 0 5.2-.4 7.7-.8L128 416h384l72.3-192.8c2.5.4 5.1.8 7.7.8 26.5 0 48-21.5 48-48s-21.5-48-48-48z"},child:[]}]})(n)}function BCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M500 224h-30.364C455.724 130.325 381.675 56.276 288 42.364V12c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v30.364C130.325 56.276 56.276 130.325 42.364 224H12c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h30.364C56.276 381.675 130.325 455.724 224 469.636V500c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12v-30.364C381.675 455.724 455.724 381.675 469.636 288H500c6.627 0 12-5.373 12-12v-40c0-6.627-5.373-12-12-12zM288 404.634V364c0-6.627-5.373-12-12-12h-40c-6.627 0-12 5.373-12 12v40.634C165.826 392.232 119.783 346.243 107.366 288H148c6.627 0 12-5.373 12-12v-40c0-6.627-5.373-12-12-12h-40.634C119.768 165.826 165.757 119.783 224 107.366V148c0 6.627 5.373 12 12 12h40c6.627 0 12-5.373 12-12v-40.634C346.174 119.768 392.217 165.757 404.634 224H364c-6.627 0-12 5.373-12 12v40c0 6.627 5.373 12 12 12h40.634C392.232 346.174 346.243 392.217 288 404.634zM288 256c0 17.673-14.327 32-32 32s-32-14.327-32-32c0-17.673 14.327-32 32-32s32 14.327 32 32z"},child:[]}]})(n)}function UCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M200 288H88c-21.4 0-32.1 25.8-17 41l32.9 31-99.2 99.3c-6.2 6.2-6.2 16.4 0 22.6l25.4 25.4c6.2 6.2 16.4 6.2 22.6 0L152 408l31.1 33c15.1 15.1 40.9 4.4 40.9-17V312c0-13.3-10.7-24-24-24zm112-64h112c21.4 0 32.1-25.9 17-41l-33-31 99.3-99.3c6.2-6.2 6.2-16.4 0-22.6L481.9 4.7c-6.2-6.2-16.4-6.2-22.6 0L360 104l-31.1-33C313.8 55.9 288 66.6 288 88v112c0 13.3 10.7 24 24 24zm96 136l33-31.1c15.1-15.1 4.4-40.9-17-40.9H312c-13.3 0-24 10.7-24 24v112c0 21.4 25.9 32.1 41 17l31-32.9 99.3 99.3c6.2 6.2 16.4 6.2 22.6 0l25.4-25.4c6.2-6.2 6.2-16.4 0-22.6L408 360zM183 71.1L152 104 52.7 4.7c-6.2-6.2-16.4-6.2-22.6 0L4.7 30.1c-6.2 6.2-6.2 16.4 0 22.6L104 152l-33 31.1C55.9 198.2 66.6 224 88 224h112c13.3 0 24-10.7 24-24V88c0-21.3-25.9-32-41-16.9z"},child:[]}]})(n)}function zCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 32C114.6 32 0 125.1 0 240c0 49.6 21.4 95 57 130.7C44.5 421.1 2.7 466 2.2 466.5c-2.2 2.3-2.8 5.7-1.5 8.7S4.8 480 8 480c66.3 0 116-31.8 140.6-51.4 32.7 12.3 69 19.4 107.4 19.4 141.4 0 256-93.1 256-208S397.4 32 256 32z"},child:[]}]})(n)}function VCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 32C114.6 32 0 125.1 0 240c0 49.6 21.4 95 57 130.7C44.5 421.1 2.7 466 2.2 466.5c-2.2 2.3-2.8 5.7-1.5 8.7S4.8 480 8 480c66.3 0 116-31.8 140.6-51.4 32.7 12.3 69 19.4 107.4 19.4 141.4 0 256-93.1 256-208S397.4 32 256 32zM128 272c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 0c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 0c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"},child:[]}]})(n)}function qCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256,8C119,8,8,119,8,256S119,504,256,504,504,393,504,256,393,8,256,8Zm92.49,313h0l-20,25a16,16,0,0,1-22.49,2.5h0l-67-49.72a40,40,0,0,1-15-31.23V112a16,16,0,0,1,16-16h32a16,16,0,0,1,16,16V256l58,42.5A16,16,0,0,1,348.49,321Z"},child:[]}]})(n)}function Jpe(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M120 72c0-39.765 32.235-72 72-72s72 32.235 72 72c0 39.764-32.235 72-72 72s-72-32.236-72-72zm254.627 1.373c-12.496-12.497-32.758-12.497-45.254 0L242.745 160H141.254L54.627 73.373c-12.496-12.497-32.758-12.497-45.254 0-12.497 12.497-12.497 32.758 0 45.255L104 213.254V480c0 17.673 14.327 32 32 32h16c17.673 0 32-14.327 32-32V368h16v112c0 17.673 14.327 32 32 32h16c17.673 0 32-14.327 32-32V213.254l94.627-94.627c12.497-12.497 12.497-32.757 0-45.254z"},child:[]}]})(n)}function N2(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M240.971 130.524l194.343 194.343c9.373 9.373 9.373 24.569 0 33.941l-22.667 22.667c-9.357 9.357-24.522 9.375-33.901.04L224 227.495 69.255 381.516c-9.379 9.335-24.544 9.317-33.901-.04l-22.667-22.667c-9.373-9.373-9.373-24.569 0-33.941L207.03 130.525c9.372-9.373 24.568-9.373 33.941-.001z"},child:[]}]})(n)}function _A(n){return wn({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"},child:[]}]})(n)}function n4(n){return wn({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"},child:[]}]})(n)}function B1(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z"},child:[]}]})(n)}function yM(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"},child:[]}]})(n)}function td(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"},child:[]}]})(n)}function eme(n){return wn({attr:{viewBox:"0 0 544 512"},child:[{tag:"path",attr:{d:"M527.79 288H290.5l158.03 158.03c6.04 6.04 15.98 6.53 22.19.68 38.7-36.46 65.32-85.61 73.13-140.86 1.34-9.46-6.51-17.85-16.06-17.85zm-15.83-64.8C503.72 103.74 408.26 8.28 288.8.04 279.68-.59 272 7.1 272 16.24V240h223.77c9.14 0 16.82-7.68 16.19-16.8zM224 288V50.71c0-9.55-8.39-17.4-17.84-16.06C86.99 51.49-4.1 155.6.14 280.37 4.5 408.51 114.83 513.59 243.03 511.98c50.4-.63 96.97-16.87 135.26-44.03 7.9-5.6 8.42-17.23 1.57-24.08L224 288z"},child:[]}]})(n)}function GCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M332.8 320h38.4c6.4 0 12.8-6.4 12.8-12.8V172.8c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h38.4c6.4 0 12.8-6.4 12.8-12.8V76.8c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-288 0h38.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h38.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-38.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zM496 384H64V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-32c0-8.84-7.16-16-16-16z"},child:[]}]})(n)}function HCe(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M458.622 255.92l45.985-45.005c13.708-12.977 7.316-36.039-10.664-40.339l-62.65-15.99 17.661-62.015c4.991-17.838-11.829-34.663-29.661-29.671l-61.994 17.667-15.984-62.671C337.085.197 313.765-6.276 300.99 7.228L256 53.57 211.011 7.229c-12.63-13.351-36.047-7.234-40.325 10.668l-15.984 62.671-61.995-17.667C74.87 57.907 58.056 74.738 63.046 92.572l17.661 62.015-62.65 15.99C.069 174.878-6.31 197.944 7.392 210.915l45.985 45.005-45.985 45.004c-13.708 12.977-7.316 36.039 10.664 40.339l62.65 15.99-17.661 62.015c-4.991 17.838 11.829 34.663 29.661 29.671l61.994-17.667 15.984 62.671c4.439 18.575 27.696 24.018 40.325 10.668L256 458.61l44.989 46.001c12.5 13.488 35.987 7.486 40.325-10.668l15.984-62.671 61.994 17.667c17.836 4.994 34.651-11.837 29.661-29.671l-17.661-62.015 62.65-15.99c17.987-4.302 24.366-27.367 10.664-40.339l-45.984-45.004z"},child:[]}]})(n)}function fm(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M512 144v288c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V144c0-26.5 21.5-48 48-48h88l12.3-32.9c7-18.7 24.9-31.1 44.9-31.1h125.5c20 0 37.9 12.4 44.9 31.1L376 96h88c26.5 0 48 21.5 48 48zM376 288c0-66.2-53.8-120-120-120s-120 53.8-120 120 53.8 120 120 120 120-53.8 120-120zm-32 0c0 48.5-39.5 88-88 88s-88-39.5-88-88 39.5-88 88-88 88 39.5 88 88z"},child:[]}]})(n)}function wK(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm436-44v-36c0-26.5-21.5-48-48-48h-48V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H160V12c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v52H48C21.5 64 0 85.5 0 112v36c0 6.6 5.4 12 12 12h424c6.6 0 12-5.4 12-12z"},child:[]}]})(n)}function $Ce(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M436 160H12c-6.6 0-12-5.4-12-12v-36c0-26.5 21.5-48 48-48h48V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h128V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h48c26.5 0 48 21.5 48 48v36c0 6.6-5.4 12-12 12zM12 192h424c6.6 0 12 5.4 12 12v260c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V204c0-6.6 5.4-12 12-12zm316 140c0-6.6-5.4-12-12-12h-60v-60c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v60h-60c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h60v60c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12v-60h60c6.6 0 12-5.4 12-12v-40z"},child:[]}]})(n)}function B_(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V192H0v272zm320-196c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM192 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40zM64 268c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zm0 128c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H76c-6.6 0-12-5.4-12-12v-40zM400 64h-48V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H160V16c0-8.8-7.2-16-16-16h-32c-8.8 0-16 7.2-16 16v48H48C21.5 64 0 85.5 0 112v48h448v-48c0-26.5-21.5-48-48-48z"},child:[]}]})(n)}function Wp(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M320 336c0 8.84-7.16 16-16 16h-96c-8.84 0-16-7.16-16-16v-48H0v144c0 25.6 22.4 48 48 48h416c25.6 0 48-22.4 48-48V288H320v48zm144-208h-80V80c0-25.6-22.4-48-48-48H176c-25.6 0-48 22.4-48 48v48H48c-25.6 0-48 22.4-48 48v80h512v-80c0-25.6-22.4-48-48-48zm-144 0H192V96h128v32z"},child:[]}]})(n)}function bM(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z"},child:[]}]})(n)}function xH(n){return wn({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M542.22 32.05c-54.8 3.11-163.72 14.43-230.96 55.59-4.64 2.84-7.27 7.89-7.27 13.17v363.87c0 11.55 12.63 18.85 23.28 13.49 69.18-34.82 169.23-44.32 218.7-46.92 16.89-.89 30.02-14.43 30.02-30.66V62.75c.01-17.71-15.35-31.74-33.77-30.7zM264.73 87.64C197.5 46.48 88.58 35.17 33.78 32.05 15.36 31.01 0 45.04 0 62.75V400.6c0 16.24 13.13 29.78 30.02 30.66 49.49 2.6 149.59 12.11 218.77 46.95 10.62 5.35 23.21-1.94 23.21-13.46V100.63c0-5.29-2.62-10.14-7.27-12.99z"},child:[]}]})(n)}function vH(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M448 384c-28.02 0-31.26-32-74.5-32-43.43 0-46.825 32-74.75 32-27.695 0-31.454-32-74.75-32-42.842 0-47.218 32-74.5 32-28.148 0-31.202-32-74.75-32-43.547 0-46.653 32-74.75 32v-80c0-26.5 21.5-48 48-48h16V112h64v144h64V112h64v144h64V112h64v144h16c26.5 0 48 21.5 48 48v80zm0 128H0v-96c43.356 0 46.767-32 74.75-32 27.951 0 31.253 32 74.75 32 42.843 0 47.217-32 74.5-32 28.148 0 31.201 32 74.75 32 43.357 0 46.767-32 74.75-32 27.488 0 31.252 32 74.5 32v96zM96 96c-17.75 0-32-14.25-32-32 0-31 32-23 32-64 12 0 32 29.5 32 56s-14.25 40-32 40zm128 0c-17.75 0-32-14.25-32-32 0-31 32-23 32-64 12 0 32 29.5 32 56s-14.25 40-32 40zm128 0c-17.75 0-32-14.25-32-32 0-31 32-23 32-64 12 0 32 29.5 32 56s-14.25 40-32 40z"},child:[]}]})(n)}function r4(n){return wn({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M192 160c44.2 0 80-35.8 80-80S236.2 0 192 0s-80 35.8-80 80 35.8 80 80 80zm-53.4 248.8l25.6-32-61.5-51.2L56.8 383c-11.4 14.2-11.7 34.4-.8 49l48 64c7.9 10.5 19.9 16 32 16 8.3 0 16.8-2.6 24-8 17.7-13.2 21.2-38.3 8-56l-29.4-39.2zm142.7-83.2l-61.5 51.2 25.6 32L216 448c-13.2 17.7-9.7 42.8 8 56 7.2 5.4 15.6 8 24 8 12.2 0 24.2-5.5 32-16l48-64c10.9-14.6 10.6-34.8-.8-49l-45.9-57.4zM376.7 145c-12.7-18.1-37.6-22.4-55.7-9.8l-40.6 28.5c-52.7 37-124.2 37-176.8 0L63 135.3C44.9 122.6 20 127 7.3 145-5.4 163.1-1 188 17 200.7l40.6 28.5c17 11.9 35.4 20.9 54.4 27.9V288h160v-30.8c19-7 37.4-16 54.4-27.9l40.6-28.5c18.1-12.8 22.4-37.7 9.7-55.8z"},child:[]}]})(n)}function WCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"},child:[]}]})(n)}function SK(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"},child:[]}]})(n)}function C7(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z"},child:[]}]})(n)}function XCe(n){return wn({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"},child:[]}]})(n)}function YCe(n){return wn({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M177 255.7l136 136c9.4 9.4 9.4 24.6 0 33.9l-22.6 22.6c-9.4 9.4-24.6 9.4-33.9 0L160 351.9l-96.4 96.4c-9.4 9.4-24.6 9.4-33.9 0L7 425.7c-9.4-9.4-9.4-24.6 0-33.9l136-136c9.4-9.5 24.6-9.5 34-.1zm-34-192L7 199.7c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l96.4-96.4 96.4 96.4c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9l-136-136c-9.2-9.4-24.4-9.4-33.8 0z"},child:[]}]})(n)}function ZCe(n){return wn({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M143 256.3L7 120.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0L313 86.3c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.4 9.5-24.6 9.5-34 .1zm34 192l136-136c9.4-9.4 9.4-24.6 0-33.9l-22.6-22.6c-9.4-9.4-24.6-9.4-33.9 0L160 352.1l-96.4-96.4c-9.4-9.4-24.6-9.4-33.9 0L7 278.3c-9.4 9.4-9.4 24.6 0 33.9l136 136c9.4 9.5 24.6 9.5 34 .1z"},child:[]}]})(n)}function QCe(n,e){if(n.match(/^[a-z]+:\/\//i))return n;if(n.match(/^\/\//))return window.location.protocol+n;if(n.match(/^[a-z]+:/i))return n;const t=document.implementation.createHTMLDocument(),r=t.createElement("base"),i=t.createElement("a");return t.head.appendChild(r),t.body.appendChild(i),e&&(r.href=e),i.href=n,i.href}const KCe=(()=>{let n=0;const e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(n+=1,`u${e()}${n}`)})();function wA(n){const e=[];for(let t=0,r=n.length;tMh||n.height>Mh)&&(n.width>Mh&&n.height>Mh?n.width>n.height?(n.height*=Mh/n.width,n.width=Mh):(n.width*=Mh/n.height,n.height=Mh):n.width>Mh?(n.height*=Mh/n.width,n.width=Mh):(n.width*=Mh/n.height,n.height=Mh))}function wM(n){return new Promise((e,t)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>e(r))})},r.onerror=t,r.crossOrigin="anonymous",r.decoding="async",r.src=n})}async function r7e(n){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(n)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function i7e(n,e,t){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${e}`),i.setAttribute("height",`${t}`),i.setAttribute("viewBox",`0 0 ${e} ${t}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(n),r7e(i)}const uh=(n,e)=>{if(n instanceof e)return!0;const t=Object.getPrototypeOf(n);return t===null?!1:t.constructor.name===e.name||uh(t,e)};function s7e(n){const e=n.getPropertyValue("content");return`${n.cssText} content: '${e.replace(/'|"/g,"")}';`}function a7e(n,e){return tme(e).map(t=>{const r=n.getPropertyValue(t),i=n.getPropertyPriority(t);return`${t}: ${r}${i?" !important":""};`}).join(" ")}function o7e(n,e,t,r){const i=`.${n}:${e}`,s=t.cssText?s7e(t):a7e(t,r);return document.createTextNode(`${i}{${s}}`)}function TK(n,e,t,r){const i=window.getComputedStyle(n,t),s=i.getPropertyValue("content");if(s===""||s==="none")return;const a=KCe();try{e.className=`${e.className} ${a}`}catch{return}const o=document.createElement("style");o.appendChild(o7e(a,t,i,r)),e.appendChild(o)}function l7e(n,e,t){TK(n,e,":before",t),TK(n,e,":after",t)}const EK="application/font-woff",NK="image/jpeg",c7e={woff:EK,woff2:EK,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:NK,jpeg:NK,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function u7e(n){const e=/\.([^./]*?)$/g.exec(n);return e?e[1]:""}function yH(n){const e=u7e(n).toLowerCase();return c7e[e]||""}function d7e(n){return n.split(/,/)[1]}function az(n){return n.search(/^(data:)/)!==-1}function h7e(n,e){return`data:${e};base64,${n}`}async function rme(n,e,t){const r=await fetch(n,e);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,a)=>{const o=new FileReader;o.onerror=a,o.onloadend=()=>{try{s(t({res:r,result:o.result}))}catch(l){a(l)}},o.readAsDataURL(i)})}const QL={};function f7e(n,e,t){let r=n.replace(/\?.*/,"");return t&&(r=n),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),e?`[${e}]${r}`:r}async function bH(n,e,t){const r=f7e(n,e,t.includeQueryParams);if(QL[r]!=null)return QL[r];t.cacheBust&&(n+=(/\?/.test(n)?"&":"?")+new Date().getTime());let i;try{const s=await rme(n,t.fetchRequestInit,({res:a,result:o})=>(e||(e=a.headers.get("Content-Type")||""),d7e(o)));i=h7e(s,e)}catch(s){i=t.imagePlaceholder||"";let a=`Failed to fetch resource: ${n}`;s&&(a=typeof s=="string"?s:s.message),a&&console.warn(a)}return QL[r]=i,i}async function p7e(n){const e=n.toDataURL();return e==="data:,"?n.cloneNode(!1):wM(e)}async function m7e(n,e){if(n.currentSrc){const s=document.createElement("canvas"),a=s.getContext("2d");s.width=n.clientWidth,s.height=n.clientHeight,a==null||a.drawImage(n,0,0,s.width,s.height);const o=s.toDataURL();return wM(o)}const t=n.poster,r=yH(t),i=await bH(t,r,e);return wM(i)}async function g7e(n,e){var t;try{if(!((t=n==null?void 0:n.contentDocument)===null||t===void 0)&&t.body)return await P7(n.contentDocument.body,e,!0)}catch{}return n.cloneNode(!1)}async function A7e(n,e){return uh(n,HTMLCanvasElement)?p7e(n):uh(n,HTMLVideoElement)?m7e(n,e):uh(n,HTMLIFrameElement)?g7e(n,e):n.cloneNode(ime(n))}const x7e=n=>n.tagName!=null&&n.tagName.toUpperCase()==="SLOT",ime=n=>n.tagName!=null&&n.tagName.toUpperCase()==="SVG";async function v7e(n,e,t){var r,i;if(ime(e))return e;let s=[];return x7e(n)&&n.assignedNodes?s=wA(n.assignedNodes()):uh(n,HTMLIFrameElement)&&(!((r=n.contentDocument)===null||r===void 0)&&r.body)?s=wA(n.contentDocument.body.childNodes):s=wA(((i=n.shadowRoot)!==null&&i!==void 0?i:n).childNodes),s.length===0||uh(n,HTMLVideoElement)||await s.reduce((a,o)=>a.then(()=>P7(o,t)).then(l=>{l&&e.appendChild(l)}),Promise.resolve()),e}function y7e(n,e,t){const r=e.style;if(!r)return;const i=window.getComputedStyle(n);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):tme(t).forEach(s=>{let a=i.getPropertyValue(s);s==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),uh(n,HTMLIFrameElement)&&s==="display"&&a==="inline"&&(a="block"),s==="d"&&e.getAttribute("d")&&(a=`path(${e.getAttribute("d")})`),r.setProperty(s,a,i.getPropertyPriority(s))})}function b7e(n,e){uh(n,HTMLTextAreaElement)&&(e.innerHTML=n.value),uh(n,HTMLInputElement)&&e.setAttribute("value",n.value)}function _7e(n,e){if(uh(n,HTMLSelectElement)){const t=e,r=Array.from(t.children).find(i=>n.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function w7e(n,e,t){return uh(e,Element)&&(y7e(n,e,t),l7e(n,e,t),b7e(n,e),_7e(n,e)),e}async function S7e(n,e){const t=n.querySelectorAll?n.querySelectorAll("use"):[];if(t.length===0)return n;const r={};for(let s=0;sA7e(r,e)).then(r=>v7e(n,r,e)).then(r=>w7e(n,r,e)).then(r=>S7e(r,e))}const sme=/url\((['"]?)([^'"]+?)\1\)/g,T7e=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,E7e=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function N7e(n){const e=n.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function M7e(n){const e=[];return n.replace(sme,(t,r,i)=>(e.push(i),t)),e.filter(t=>!az(t))}async function C7e(n,e,t,r,i){try{const s=t?QCe(e,t):e,a=yH(e);let o;return i||(o=await bH(s,a,r)),n.replace(N7e(e),`$1${o}$3`)}catch{}return n}function P7e(n,{preferredFontFormat:e}){return e?n.replace(E7e,t=>{for(;;){const[r,,i]=T7e.exec(t)||[];if(!i)return"";if(i===e)return`src: ${r};`}}):n}function ame(n){return n.search(sme)!==-1}async function ome(n,e,t){if(!ame(n))return n;const r=P7e(n,t);return M7e(r).reduce((s,a)=>s.then(o=>C7e(o,a,e,t)),Promise.resolve(r))}async function wy(n,e,t){var r;const i=(r=e.style)===null||r===void 0?void 0:r.getPropertyValue(n);if(i){const s=await ome(i,null,t);return e.style.setProperty(n,s,e.style.getPropertyPriority(n)),!0}return!1}async function R7e(n,e){await wy("background",n,e)||await wy("background-image",n,e),await wy("mask",n,e)||await wy("-webkit-mask",n,e)||await wy("mask-image",n,e)||await wy("-webkit-mask-image",n,e)}async function L7e(n,e){const t=uh(n,HTMLImageElement);if(!(t&&!az(n.src))&&!(uh(n,SVGImageElement)&&!az(n.href.baseVal)))return;const r=t?n.src:n.href.baseVal,i=await bH(r,yH(r),e);await new Promise((s,a)=>{n.onload=s,n.onerror=e.onImageErrorHandler?(...l)=>{try{s(e.onImageErrorHandler(...l))}catch(c){a(c)}}:a;const o=n;o.decode&&(o.decode=s),o.loading==="lazy"&&(o.loading="eager"),t?(n.srcset="",n.src=i):n.href.baseVal=i})}async function k7e(n,e){const r=wA(n.childNodes).map(i=>lme(i,e));await Promise.all(r).then(()=>n)}async function lme(n,e){uh(n,Element)&&(await R7e(n,e),await L7e(n,e),await k7e(n,e))}function I7e(n,e){const{style:t}=n;e.backgroundColor&&(t.backgroundColor=e.backgroundColor),e.width&&(t.width=`${e.width}px`),e.height&&(t.height=`${e.height}px`);const r=e.style;return r!=null&&Object.keys(r).forEach(i=>{t[i]=r[i]}),n}const MK={};async function CK(n){let e=MK[n];if(e!=null)return e;const r=await(await fetch(n)).text();return e={url:n,cssText:r},MK[n]=e,e}async function PK(n,e){let t=n.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(t.match(/url\([^)]+\)/g)||[]).map(async a=>{let o=a.replace(r,"$1");return o.startsWith("https://")||(o=new URL(o,n.url).href),rme(o,e.fetchRequestInit,({result:l})=>(t=t.replace(a,`url(${l})`),[a,l]))});return Promise.all(s).then(()=>t)}function RK(n){if(n==null)return[];const e=[],t=/(\/\*[\s\S]*?\*\/)/gi;let r=n.replace(t,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=i.exec(r);if(l===null)break;e.push(l[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",o=new RegExp(a,"gi");for(;;){let l=s.exec(r);if(l===null){if(l=o.exec(r),l===null)break;s.lastIndex=o.lastIndex}else o.lastIndex=s.lastIndex;e.push(l[0])}return e}async function D7e(n,e){const t=[],r=[];return n.forEach(i=>{if("cssRules"in i)try{wA(i.cssRules||[]).forEach((s,a)=>{if(s.type===CSSRule.IMPORT_RULE){let o=a+1;const l=s.href,c=CK(l).then(u=>PK(u,e)).then(u=>RK(u).forEach(d=>{try{i.insertRule(d,d.startsWith("@import")?o+=1:i.cssRules.length)}catch(h){console.error("Error inserting rule from remote css",{rule:d,error:h})}})).catch(u=>{console.error("Error loading remote css",u.toString())});r.push(c)}})}catch(s){const a=n.find(o=>o.href==null)||document.styleSheets[0];i.href!=null&&r.push(CK(i.href).then(o=>PK(o,e)).then(o=>RK(o).forEach(l=>{a.insertRule(l,a.cssRules.length)})).catch(o=>{console.error("Error loading remote stylesheet",o)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(n.forEach(i=>{if("cssRules"in i)try{wA(i.cssRules||[]).forEach(s=>{t.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),t))}function O7e(n){return n.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>ame(e.style.getPropertyValue("src")))}async function j7e(n,e){if(n.ownerDocument==null)throw new Error("Provided element is not within a Document");const t=wA(n.ownerDocument.styleSheets),r=await D7e(t,e);return O7e(r)}function cme(n){return n.trim().replace(/["']/g,"")}function F7e(n){const e=new Set;function t(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{e.add(cme(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&t(s)})}return t(n),e}async function B7e(n,e){const t=await j7e(n,e),r=F7e(n);return(await Promise.all(t.filter(s=>r.has(cme(s.style.fontFamily))).map(s=>{const a=s.parentStyleSheet?s.parentStyleSheet.href:null;return ome(s.cssText,a,e)}))).join(` `)}async function U7e(n,e){const t=e.fontEmbedCSS!=null?e.fontEmbedCSS:e.skipFonts?null:await B7e(n,e);if(t){const r=document.createElement("style"),i=document.createTextNode(t);r.appendChild(i),n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r)}}async function ume(n,e={}){const{width:t,height:r}=nme(n,e),i=await P7(n,e,!0);return await U7e(i,e),await lme(i,e),I7e(i,e),await i7e(i,t,r)}async function z7e(n,e={}){const{width:t,height:r}=nme(n,e),i=await ume(n,e),s=await wM(i),a=document.createElement("canvas"),o=a.getContext("2d"),l=e.pixelRatio||t7e(),c=e.canvasWidth||t,u=e.canvasHeight||r;return a.width=c*l,a.height=u*l,e.skipAutoScale||n7e(a),a.style.width=`${c}`,a.style.height=`${u}`,e.backgroundColor&&(o.fillStyle=e.backgroundColor,o.fillRect(0,0,a.width,a.height)),o.drawImage(s,0,0,a.width,a.height),a}async function dme(n,e={}){return(await z7e(n,e)).toDataURL()}const V7e=ln.forwardRef(({person:n,API_URL:e},t)=>{var s,a;if(!n)return null;const r=n.photo_url||n.photo,i=r?r.startsWith("/")?`${e}${r}`:r:null;return f.jsx("div",{style:{position:"absolute",left:"-9999px",top:"-9999px"},children:f.jsxs("div",{ref:t,style:{width:"800px",height:"1130px",backgroundColor:"#fff",padding:"60px",boxSizing:"border-box",fontFamily:"'Outfit', sans-serif",position:"relative",overflow:"hidden",background:"linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%)",color:"#1e293b"},children:[f.jsx("div",{style:{position:"absolute",top:"-100px",left:"-100px",width:"400px",height:"400px",backgroundColor:"rgba(16, 185, 129, 0.1)",borderRadius:"50%",filter:"blur(50px)"}}),f.jsx("div",{style:{position:"absolute",bottom:"-100px",right:"-100px",width:"400px",height:"400px",backgroundColor:"rgba(99, 102, 241, 0.1)",borderRadius:"50%",filter:"blur(50px)"}}),f.jsxs("div",{style:{border:"2px solid rgba(148, 163, 184, 0.3)",borderRadius:"40px",height:"100%",padding:"40px",display:"flex",flexDirection:"column",alignItems:"center",backgroundColor:"rgba(255, 255, 255, 0.6)",backdropFilter:"blur(20px)",boxShadow:"0 20px 50px rgba(0,0,0,0.05)"},children:[f.jsxs("div",{style:{textAlign:"center",marginBottom:"40px"},children:[f.jsx("h1",{style:{fontSize:"64px",fontWeight:"900",margin:"0",lineHeight:"1"},children:n.prenom}),f.jsx("h2",{style:{fontSize:"48px",fontWeight:"800",color:"#64748b",textTransform:"uppercase",margin:"10px 0 0 0"},children:n.nom}),n.profession&&f.jsx("p",{style:{fontSize:"24px",fontWeight:"700",color:"#059669",textTransform:"uppercase",letterSpacing:"4px",margin:"20px 0 0 0"},children:n.profession})]}),f.jsx("div",{style:{width:"350px",height:"350px",borderRadius:"50%",border:"8px solid white",boxShadow:"0 20px 40px rgba(0,0,0,0.1)",overflow:"hidden",marginBottom:"50px",backgroundColor:"#0f172a",display:"flex",alignItems:"center",justifyContent:"center"},children:i?f.jsx("img",{src:i,alt:"Portrait",style:{width:"100%",height:"100%",objectFit:"cover"},crossOrigin:"anonymous"}):f.jsxs("span",{style:{fontSize:"100px",fontWeight:"900",color:"#fff"},children:[(s=n.prenom)==null?void 0:s[0],(a=n.nom)==null?void 0:a[0]]})}),f.jsxs("div",{style:{display:"flex",width:"100%",gap:"30px",marginBottom:"40px"},children:[n.date_naissance&&f.jsxs("div",{style:{flex:1,backgroundColor:"rgba(16, 185, 129, 0.1)",padding:"20px",borderRadius:"20px",textAlign:"center"},children:[f.jsx("p",{style:{fontSize:"16px",fontWeight:"800",color:"#94a3b8",textTransform:"uppercase",margin:"0 0 10px 0"},children:"Date de naissance"}),f.jsx("p",{style:{fontSize:"24px",fontWeight:"700",margin:"0"},children:n.date_naissance})]}),n.lieu_naissance&&f.jsxs("div",{style:{flex:1,backgroundColor:"rgba(99, 102, 241, 0.1)",padding:"20px",borderRadius:"20px",textAlign:"center"},children:[f.jsx("p",{style:{fontSize:"16px",fontWeight:"800",color:"#94a3b8",textTransform:"uppercase",margin:"0 0 10px 0"},children:"Lieu de naissance"}),f.jsx("p",{style:{fontSize:"24px",fontWeight:"700",margin:"0"},children:n.lieu_naissance})]})]}),(()=>{const o=u=>u?Array.isArray(u)?u:typeof u=="string"?u.split(",").map(d=>d.trim()).filter(Boolean):[String(u)]:[],l=o(n.traits_personnalite),c=o(n.hobbies);return l.length===0&&c.length===0?null:f.jsxs("div",{style:{width:"100%",marginTop:"auto"},children:[l.length>0&&f.jsxs("div",{style:{marginBottom:"20px"},children:[f.jsx("p",{style:{fontSize:"18px",fontWeight:"800",color:"#64748b",textTransform:"uppercase",margin:"0 0 15px 0"},children:"Traits de Caractère"}),f.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"10px"},children:l.map((u,d)=>f.jsx("span",{style:{padding:"8px 20px",backgroundColor:"#e0e7ff",color:"#4f46e5",borderRadius:"30px",fontSize:"18px",fontWeight:"600"},children:u},d))})]}),c.length>0&&f.jsxs("div",{children:[f.jsx("p",{style:{fontSize:"18px",fontWeight:"800",color:"#64748b",textTransform:"uppercase",margin:"0 0 15px 0"},children:"Passions"}),f.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"10px"},children:c.map((u,d)=>f.jsx("span",{style:{padding:"8px 20px",backgroundColor:"#ccfbf1",color:"#0f766e",borderRadius:"30px",fontSize:"18px",fontWeight:"600"},children:u},d))})]})]})})(),f.jsx("div",{style:{marginTop:"auto",paddingTop:"40px",opacity:.5,textAlign:"center"},children:f.jsx("p",{style:{fontSize:"20px",fontWeight:"800",margin:0},children:"Famille History ✨"})})]})]})})});function q7e({current:n,onNavigate:e}){const t=[{id:"membres",icon:jA,label:"Membres"},{id:"arbre",icon:X4,label:"Arbre"},{id:"timeline",icon:pH,label:"Frise"},{id:"carte",icon:mH,label:"Carte"},{id:"journal",icon:bM,label:"Journal"},{id:"studio_ia",icon:ld,label:"IA"},{id:"medias",icon:Zpe,label:"Médias"},{id:"stats",icon:eme,label:"Stats"}];return f.jsx("div",{className:"md:hidden fixed bottom-[calc(0.5rem+env(safe-area-inset-bottom))] left-1/2 -translate-x-1/2 px-2 py-1.5 rounded-2xl flex gap-1 z-50 w-[96%] max-w-md overflow-x-auto no-scrollbar justify-between items-center shadow-[0_20px_50px_rgba(0,0,0,0.8)] border border-amber-500/20 backdrop-blur-2xl bg-[#0b0f19]/95 ring-1 ring-white/10",children:t.map(r=>{const i=r.icon,s=n===r.id;return f.jsxs(Gn.button,{onClick:()=>e(r.id),whileHover:{scale:1.06},whileTap:{scale:.94},className:`relative flex flex-col items-center justify-center min-w-[4.2rem] sm:min-w-[4.8rem] h-13 sm:h-14 rounded-xl transition-all duration-300 shrink-0 ${s?"text-amber-300":"text-slate-400 hover:text-amber-100"}`,children:[f.jsx(i,{size:s?20:17,className:`transition-all duration-300 ${s?"drop-shadow-[0_0_10px_rgba(245,158,11,0.8)] mb-1":"mb-1 opacity-70"}`}),f.jsx("span",{className:`text-[9px] sm:text-[10px] tracking-wider uppercase font-serif transition-all duration-300 ${s?"opacity-100 font-extrabold text-amber-200":"opacity-60"}`,children:r.label}),s&&f.jsx(Gn.div,{layoutId:"nav-indicator",className:"absolute -bottom-1.5 w-7 sm:w-8 h-[3px] bg-gradient-to-r from-amber-500 via-amber-300 to-amber-500 rounded-full shadow-[0_0_10px_rgba(245,158,11,0.9)]",initial:!1,transition:{type:"spring",stiffness:500,damping:32}})]},r.id)})})}const LK="https://famille.ravin-cloud.fr",M2={FaBirthdayCake:f.jsx(vH,{className:"w-8 h-8"}),FaHeart:f.jsx(Y0,{className:"w-8 h-8"}),FaBriefcase:f.jsx(Wp,{className:"w-8 h-8"}),FaUserGraduate:f.jsx(cH,{className:"w-8 h-8"}),FaBaby:f.jsx(r4,{className:"w-8 h-8"}),default:f.jsx(V0,{className:"w-8 h-8"})};function G7e(n,e){if(e&&M2[e])return M2[e];const t=(n||"").toLowerCase();return t.includes("naissance")?M2.FaBaby:t.includes("mariage")?M2.FaHeart:t.includes("travail")||t.includes("emploi")?M2.FaBriefcase:t.includes("étude")||t.includes("diplôme")?M2.FaUserGraduate:t.includes("déménagement")||t.includes("habite")?f.jsx(bA,{className:"w-8 h-8"}):M2.default}function H7e({person:n,refreshKey:e}){const[t,r]=de.useState([]),[i,s]=de.useState(!0);return de.useEffect(()=>{n&&(async()=>{s(!0);try{const c=((await(await fetch(`${LK}/api/timeline`,{credentials:"include"})).json()).events||[]).filter(h=>h.slug===(n==null?void 0:n.slug)),u={birth:10,event:20,marriage:30,union:30,journal:35,child:40,child_marriage:50,grandchild:60,great_grandchild:70,death:90},d=h=>{if(!h||h==="À préciser")return 9999;const p=String(h).match(/\d{4}/);return p?parseInt(p[0],10):9999};c.sort((h,p)=>{const g=d(h.date),x=d(p.date);if(g!==x)return g-x;const _=h.priority||u[h.type]||25,y=p.priority||u[p.type]||25;return _!==y?_-y:(h.date||"").localeCompare(p.date||"")}),r(c||[])}catch(o){console.error("Failed to fetch timeline:",o)}finally{s(!1)}})()},[n,e]),n?f.jsxs("div",{className:"h-full flex flex-col p-4 md:p-8 bg-slate-50 overflow-y-auto relative",children:[f.jsxs("div",{className:"sticky top-0 bg-slate-50/90 backdrop-blur-md pb-4 z-10 mb-6 border-b border-slate-200 flex justify-between items-end",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-3xl font-extrabold text-slate-800 tracking-tight",children:"Histoire de vie"}),f.jsxs("p",{className:"text-lg text-slate-500 font-medium",children:[n.prenom," ",n.nom]})]}),f.jsx("div",{className:"text-sm font-medium text-emerald-600 bg-emerald-100 px-3 py-1 rounded-full animate-pulse",children:"Mise à jour en direct..."})]}),i&&(t||[]).length===0?f.jsx("div",{className:"flex justify-center items-center h-40",children:f.jsx("div",{className:"w-12 h-12 border-4 border-emerald-200 border-t-emerald-600 rounded-full animate-spin"})}):(t||[]).length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center text-center p-10 bg-white rounded-3xl shadow-sm border-2 border-dashed border-slate-200 mt-10",children:[f.jsx(V0,{className:"w-16 h-16 text-slate-300 mb-4"}),f.jsx("h3",{className:"text-2xl font-bold text-slate-700 mb-2",children:"Aucun événement"}),f.jsxs("p",{className:"text-lg text-slate-500 max-w-md",children:["Commencez à parler pour que l'IA rédige automatiquement les événements marquants de la vie de ",n.prenom,"."]})]}):f.jsx("div",{className:"relative space-y-8 before:absolute before:inset-0 before:ml-10 before:-translate-x-px md:before:mx-auto md:before:translate-x-0 before:h-full before:w-1 before:bg-gradient-to-b before:from-emerald-400 before:to-emerald-100",children:f.jsx(Da,{children:t.map((a,o)=>f.jsxs(Gn.div,{initial:{opacity:0,x:50,scale:.9},animate:{opacity:1,x:0,scale:1},transition:{duration:.5,type:"spring",bounce:.4},className:"relative flex items-center justify-between md:justify-normal md:odd:flex-row-reverse group is-active",children:[f.jsx("div",{className:"flex items-center justify-center w-20 h-20 rounded-full border-4 border-white bg-emerald-500 text-white shadow-xl shrink-0 md:order-1 md:group-odd:-translate-x-1/2 md:group-even:translate-x-1/2 z-10 transition-transform duration-300 hover:scale-110",children:G7e(a.title,a.icon)}),f.jsx("div",{className:"w-[calc(100%-6rem)] md:w-[calc(50%-4rem)] p-6 rounded-3xl shadow-lg bg-white border border-slate-100 hover:shadow-xl transition-shadow",children:f.jsxs("div",{className:"flex flex-col gap-2",children:[a.date&&a.date!=="À préciser"?f.jsx("span",{className:"inline-block px-4 py-1.5 font-bold text-emerald-800 bg-emerald-100 rounded-full w-fit text-lg",children:a.date}):f.jsxs("span",{className:"inline-flex items-center gap-2 px-4 py-1.5 font-bold text-amber-700 bg-amber-50 border border-amber-200 rounded-full w-fit text-base",children:[f.jsx("span",{children:"📅"})," Date à préciser"]}),f.jsx("h3",{className:"text-2xl font-extrabold text-slate-800",children:a.title}),a.description&&f.jsx("div",{className:"text-lg text-slate-600 leading-relaxed mt-4",children:a.description.split(` `).map((l,c)=>{const u=l.match(/!\[(.*?)\]\((.*?)\)/);if(u){const d=u[2].startsWith("/")?`${LK}${u[2]}`:u[2];return f.jsx("img",{src:d,alt:u[1],className:"max-h-64 rounded-xl shadow-md my-4 object-cover w-full"},c)}return f.jsx("p",{className:"mb-2",children:l},c)})})]})})]},`${a.date}-${a.title}-${o}`))})})]}):null}function $7e({onAddPerson:n,onToggleChat:e,onOpenScanner:t,onOpenIngestion:r}){const[i,s]=de.useState(!1),a=[{icon:f.jsx(ld,{className:"text-indigo-400 text-base"}),label:"Ingestion & Dépôt IA",desc:"Glisser-déposer lettres, photos, récits",badge:"Nouveau",onClick:r||e},{icon:f.jsx(VCe,{className:"text-emerald-400 text-base"}),label:"Studio Conversationnel",desc:"Discuter avec l’IA & enrichir les fiches",onClick:e},{icon:f.jsx(fm,{className:"text-cyan-400 text-base"}),label:"Scan Intelligent",desc:"Scanner CNI, acte ou portrait d’époque",onClick:t},{icon:f.jsx(F_,{className:"text-amber-400 text-base"}),label:"Ajouter un Membre",desc:"Créer manuellement une nouvelle fiche",onClick:n}];return f.jsxs("div",{className:"fixed bottom-24 md:bottom-8 right-4 md:right-8 z-50 flex flex-col items-end gap-3",children:[f.jsx(Da,{children:i&&f.jsx(Gn.div,{className:"flex flex-col items-end gap-2.5 mb-1",initial:{opacity:0,y:15,scale:.9},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:15,scale:.9},children:a.map(o=>f.jsxs(Gn.button,{whileHover:{scale:1.03,x:-3},whileTap:{scale:.97},onClick:()=>{o.onClick(),s(!1)},className:"flex items-center gap-3 bg-slate-900/95 hover:bg-slate-800 text-slate-200 border border-slate-700/80 hover:border-indigo-400/50 shadow-2xl rounded-2xl px-4 py-2.5 text-xs font-semibold backdrop-blur-xl transition-all group",children:[f.jsxs("div",{className:"text-right",children:[f.jsxs("div",{className:"flex items-center justify-end gap-1.5 font-bold text-white group-hover:text-indigo-300 transition-colors",children:[o.label,o.badge&&f.jsx("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.2 bg-indigo-500/30 text-indigo-300 border border-indigo-400/40 rounded-full font-mono",children:o.badge})]}),f.jsx("div",{className:"text-[10px] text-slate-400 font-normal",children:o.desc})]}),f.jsx("div",{className:"w-9 h-9 rounded-xl bg-slate-800 border border-slate-700 flex items-center justify-center shrink-0 shadow-inner group-hover:border-indigo-500/50",children:o.icon})]},o.label))})}),f.jsxs(Gn.button,{onClick:()=>s(!i),whileHover:{scale:1.08},whileTap:{scale:.94},className:"relative w-14 h-14 md:w-16 md:h-16 rounded-full bg-gradient-to-r from-indigo-600 via-purple-600 to-pink-600 text-white shadow-[0_10px_25px_rgba(99,102,241,0.5)] flex items-center justify-center border-2 border-white/20 hover:border-white/40 transition-all",title:"Ouvrir le menu d'actions rapides et IA",children:[f.jsx(Da,{initial:!1,mode:"wait",children:i?f.jsx(Gn.div,{initial:{rotate:-90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:90,opacity:0},transition:{duration:.15},children:f.jsx($a,{size:22})},"times"):f.jsx(Gn.div,{initial:{rotate:90,opacity:0},animate:{rotate:0,opacity:1},exit:{rotate:-90,opacity:0},transition:{duration:.15},className:"flex items-center justify-center",children:f.jsx(ld,{size:22,className:"animate-pulse"})},"magic")}),!i&&f.jsxs("span",{className:"absolute -top-1 -right-1 flex h-4 w-4",children:[f.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),f.jsx("span",{className:"relative inline-flex rounded-full h-4 w-4 bg-emerald-500 border-2 border-slate-900"})]})]})]})}const W7e="https://famille.ravin-cloud.fr",kK=new Set(["alexandre","pierre","antoine","guillaume","philippe","stephane","stéphane","christophe","claude","dominique","jerome","jérôme","maxime","etienne","étienne","jacques","gilles","charles","eugene","eugène","emile","émile","andre","andré","rene","rené","baptiste","adrien","julien","louis","lucas","nicolas","thomas","mathieu","matthieu","hugues","yves","blaise","georges","hervé","herve","patrice","aime","aimé","tanguy","thierry","serge","jean","paul","marc","michel","alain","bernard","christian","daniel","david","denis","eric","éric","francois","françois","frederic","frédéric","gerard","gérard","guy","henri","laurent","luc","maurice","olivier","pascal","patrick","robert","roland","sebastien","sébastien","vincent","xavier","yves","kevin","kévin","malo"]);function Rg(n){if(!n)return!1;let e="",t="";if(typeof n=="string")e=n.split(" ")[0].trim().toLowerCase();else{if(t=(n.sexe||n.gender||"").trim().toUpperCase(),t==="F"||t==="FEMME"||t==="FEMININ")return!0;if(t==="M"||t==="HOMME"||t==="MASCULIN")return!1;e=(n.prenom||(n.name?n.name.split(" ")[0]:"")).trim().toLowerCase()}if(!e)return!1;const r=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"");return kK.has(e)||kK.has(r)?!1:["a","ie","ette","ine","elle","ane","ence","ance","ise","isse","ose","ille"].some(s=>r.endsWith(s))}function X7e(n="",e=""){const t=(n||"").trim(),r=(e||"").trim(),i=t?t[0].toUpperCase():"",s=r?r[0].toUpperCase():"";return`${i}${s}`||"•"}function q0({person:n={},className:e="w-12 h-12",rounded:t="rounded-full",showInitials:r=!0,showGenderBadge:i=!1,dark:s=!1,onClick:a,alt:o=""}){const[l,c]=de.useState(!1),u=(n==null?void 0:n.photo_url)||(n==null?void 0:n.photo)||null;let d=null;u&&!l&&(d=u.startsWith("/")?`${W7e}${u}`:u);const h=Rg(n),p=X7e(n==null?void 0:n.prenom,n==null?void 0:n.nom),g=`${(n==null?void 0:n.prenom)||""} ${(n==null?void 0:n.nom)||""}`.trim();if(d)return f.jsxs("div",{className:`relative shrink-0 select-none ${e}`,children:[f.jsx("div",{onClick:a,className:`w-full h-full overflow-hidden ${t} ${a?"cursor-pointer":""}`,title:g,children:f.jsx("img",{src:d,alt:o||g||"Photo de famille",className:"w-full h-full object-cover",onError:()=>c(!0),loading:"lazy"})}),i&&f.jsx("span",{className:`absolute -bottom-1 -right-1 w-4 h-4 rounded-full flex items-center justify-center text-[10px] font-black border shadow-xs z-10 ${h?"bg-rose-100 border-rose-300 text-rose-700":"bg-sky-100 border-sky-300 text-sky-700"}`,title:h?"Femme (♀)":"Homme (♂)",children:h?"♀":"♂"})]});const x=h?"/avatar_female.png":"/avatar_male.png";return f.jsxs("div",{onClick:a,className:`relative overflow-hidden shrink-0 select-none flex items-center justify-center ${e} ${t} ${a?"cursor-pointer":""} ${h?"bg-gradient-to-b from-rose-100 to-pink-200 border-2 border-rose-300 shadow-md":"bg-gradient-to-b from-sky-100 to-blue-200 border-2 border-sky-300 shadow-md"}`,title:g,children:[f.jsx("img",{src:x,alt:g||(h?"Femme":"Homme"),className:"w-full h-full object-cover",onError:_=>{_.target.style.display="none"},loading:"lazy"}),r&&f.jsx("span",{className:`absolute bottom-0.5 right-1 text-[9px] font-black tracking-tight font-serif px-1 py-0.2 rounded-md ${h?"bg-rose-950/80 text-rose-200 border border-rose-400/50 backdrop-blur-xs":"bg-slate-950/80 text-sky-200 border border-sky-400/50 backdrop-blur-xs"}`,children:p})]})}const IK={hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.04}}},Y7e={hidden:{y:10,opacity:0},visible:{y:0,opacity:1}};function KL(n){if(!n)return null;const e=String(n).trim();if(!e)return null;const t=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(t){const[r,i,s,a]=t;return`${a}/${s}/${i}`}if(e.includes("T")){const r=new Date(e);if(!isNaN(r.getTime())){const i=String(r.getDate()).padStart(2,"0"),s=String(r.getMonth()+1).padStart(2,"0");return`${i}/${s}/${r.getFullYear()}`}}return e}function Z7e(n){if(!n)return{count:0,score:0,photos:0};let e=0;(n.date_naissance||n.annee_naissance||n.lieu_naissance)&&e++,n.parents&&n.parents.length>0&&(e+=n.parents.length),(n.date_mariage||n.lieu_mariage||n.conjoint)&&e++,n.profession&&e++,(n.date_deces||n.lieu_deces)&&e++;const t=Array.isArray(n.evenements_marquants)?n.evenements_marquants.length:n.evenements_marquants?1:0;t>0&&(e+=t);const r=Array.isArray(n.galerie_photos)?n.galerie_photos.length:0;r>0&&(e+=r),n.biographie&&n.biographie.length>15&&e++,n.hobbies&&(Array.isArray(n.hobbies)?n.hobbies.length>0:n.hobbies)&&e++,n.notes&&n.notes.length>10&&e++;let i=0;return n.date_naissance&&(i+=20),n.lieu_naissance&&(i+=10),n.parents&&n.parents.length>0&&(i+=20),n.profession&&(i+=15),(n.photo||n.photo_url)&&(i+=15),(n.biographie||n.hobbies&&(Array.isArray(n.hobbies)?n.hobbies.length>0:n.hobbies))&&(i+=10),(n.conjoint||n.date_mariage||t>0)&&(i+=10),i=Math.min(100,Math.max(15,i)),{count:Math.max(1,e),score:i,photos:r,evts:t}}function Q7e(n){if(n.biographie&&n.biographie.trim().length>0){const s=n.biographie.trim().replace(/^[#\s\*-]+/,"").replace(/\n+/g," ");return s.length>70?s.slice(0,70)+"...":s}const e=[];n.profession&&e.push(`💼 ${n.profession}`);const t=s=>s?Array.isArray(s)?s:typeof s=="string"?s.split(",").map(a=>a.trim()).filter(Boolean):[String(s)]:[],r=t(n.traits_personnalite),i=t(n.hobbies);return r.length>0?e.push(r.slice(0,2).join(", ")):i.length>0&&e.push(i.slice(0,2).join(", ")),e.length>0?e.join(" • "):"Fiche mémoire généalogique"}function K7e({items:n,onSelect:e,onCreate:t,onEditPerson:r}){return f.jsxs(Gn.div,{className:"rounded-[2rem] p-5 bg-white/70 backdrop-blur-2xl shadow-[0_8px_30px_rgba(0,0,0,0.04)] border border-white/50 flex flex-col",variants:IK,initial:"hidden",animate:"visible",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4 px-2",children:[f.jsxs("h2",{className:"text-xl font-bold bg-gradient-to-r from-emerald-800 to-emerald-500 bg-clip-text text-transparent",children:["Membres (",(n==null?void 0:n.length)||0,")"]}),f.jsxs("button",{onClick:t,className:"px-4 py-2 rounded-full bg-emerald-600 hover:bg-emerald-500 text-white font-medium shadow-md shadow-emerald-500/30 transition-all active:scale-95 flex items-center gap-2 text-sm",children:[f.jsx("span",{children:"+"})," Nouveau"]})]}),!n||n.length===0?f.jsxs("div",{className:"text-slate-400 text-center py-10",children:["Aucune personne trouvée. Cliquez sur ",f.jsx("b",{children:"+ Nouveau"})," pour créer une fiche."]}):f.jsx("div",{className:"overflow-y-auto max-h-[calc(100vh-280px)] pr-2 pb-24 no-scrollbar",children:f.jsx(Gn.div,{className:"grid grid-cols-1 sm:grid-cols-2 gap-3.5",variants:IK,children:n.map(i=>{const s=KL(i.date_naissance||i.annee_naissance),a=KL(i.date_deces||i.annee_deces),o=KL(i.date_mariage),l=Q7e(i),c=!i.date_naissance||!i.lieu_naissance||!i.profession||!(i.photo_url||i.photo),u=Rg(i),d=Z7e(i);return f.jsxs(Gn.div,{className:`group relative p-4 rounded-2xl border backdrop-blur-md shadow-xs hover:shadow-xl transition-all duration-300 flex flex-col gap-2.5 cursor-pointer ${u?"border-rose-200/80 bg-gradient-to-br from-rose-50/40 via-white to-pink-50/20 hover:border-rose-300 hover:bg-rose-50/60 shadow-rose-100/30":"border-sky-200/80 bg-gradient-to-br from-sky-50/40 via-white to-blue-50/20 hover:border-sky-300 hover:bg-sky-50/60 shadow-sky-100/30"}`,variants:Y7e,whileHover:{scale:1.01},whileTap:{scale:.99},onClick:()=>e(i),children:[c&&f.jsxs("div",{className:"absolute -top-2 -right-2 px-2.5 py-0.5 rounded-full bg-gradient-to-r from-orange-500 to-amber-500 text-white font-black text-[9px] shadow-md flex items-center gap-1 border border-orange-400 z-10",children:[f.jsx("span",{children:"⚠️"})," Incomplet"]}),f.jsxs("div",{className:"flex items-start justify-between gap-3 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[f.jsx(q0,{person:i,className:"w-12 h-12",rounded:"rounded-2xl shadow-xs",showGenderBadge:!0}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 font-extrabold text-slate-900 truncate group-hover:text-emerald-700 transition-colors text-sm sm:text-base",children:[u?f.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full bg-rose-100 border border-rose-300 text-rose-700 text-xs font-black shrink-0 shadow-2xs",title:"Femme (♀)",children:"♀"}):f.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full bg-sky-100 border border-sky-300 text-sky-700 text-xs font-black shrink-0 shadow-2xs",title:"Homme (♂)",children:"♂"}),f.jsxs("span",{className:"truncate",children:[i.prenom," ",f.jsx("span",{className:"uppercase text-emerald-800 font-black",children:i.nom})]})]}),(i.nom_jeune_fille||i.nom_naissance)&&(i.nom_jeune_fille||i.nom_naissance).toUpperCase()!==(i.nom||"").toUpperCase()&&f.jsxs("div",{className:"text-[11px] text-pink-600 font-semibold italic truncate",children:["(née ",i.nom_jeune_fille||i.nom_naissance,")"]}),i.surnom&&f.jsxs("div",{className:"text-[10px] text-purple-600 font-bold truncate",children:["« ",i.surnom," »"]})]})]}),f.jsx("div",{className:"flex items-center gap-1 shrink-0",children:r&&f.jsxs("button",{onClick:h=>{h.stopPropagation(),r(i)},title:"Modifier la fiche",className:"px-2.5 py-1.5 rounded-xl bg-amber-50 hover:bg-amber-100 border border-amber-300 text-amber-800 font-bold text-xs flex items-center gap-1 transition-all shadow-xs hover:scale-105",children:[f.jsx(Pg,{size:12,className:"text-amber-600"}),f.jsx("span",{children:"Modifier"})]})})]}),f.jsxs("div",{className:"flex flex-col gap-1 text-[11px] font-semibold",children:[s?f.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-900 bg-emerald-50/80 px-2 py-0.5 rounded-lg border border-emerald-200/60 w-fit",children:[f.jsx("span",{className:"font-black text-[9px] text-emerald-950 bg-emerald-200 px-1 py-0.2 rounded shrink-0",children:"N"}),f.jsx("span",{className:"font-bold",children:s}),i.lieu_naissance&&f.jsxs("span",{className:"text-slate-500 font-normal truncate max-w-[130px]",children:["(",i.lieu_naissance,")"]})]}):f.jsxs("div",{className:"flex items-center gap-1.5 text-orange-800 bg-orange-50 px-2 py-0.5 rounded-lg border border-orange-200/80 w-fit",children:[f.jsx("span",{className:"font-black text-[9px] text-orange-900 bg-orange-200 px-1 rounded shrink-0",children:"N"}),f.jsx("span",{className:"italic text-[10px] text-orange-700",children:"Date de naissance inconnue"})]}),o&&f.jsxs("div",{className:"flex items-center gap-1.5 text-rose-900 bg-rose-50/80 px-2 py-0.5 rounded-lg border border-rose-200/60 w-fit",children:[f.jsx("span",{className:"font-black text-[9px] text-rose-950 bg-rose-200 px-1 py-0.2 rounded shrink-0",children:"M"}),f.jsx("span",{className:"font-bold",children:o})]}),a&&f.jsxs("div",{className:"flex items-center gap-1.5 text-slate-800 bg-slate-100 px-2 py-0.5 rounded-lg border border-slate-300/80 w-fit",children:[f.jsx("span",{className:"font-black text-[9px] text-slate-900 bg-slate-300 px-1 py-0.2 rounded shrink-0",children:"D"}),f.jsx("span",{className:"font-bold",children:a}),i.lieu_deces&&f.jsxs("span",{className:"text-slate-500 font-normal truncate max-w-[130px]",children:["(",i.lieu_deces,")"]})]}),i.profession?f.jsxs("div",{className:"text-slate-600 text-[11px] font-medium flex items-center gap-1 truncate",children:[f.jsx("span",{children:"💼"})," ",i.profession]}):f.jsx("div",{className:"text-orange-600/90 text-[10px] italic",children:"⚠️ Profession non renseignée"})]}),f.jsxs("div",{className:"pt-2 border-t border-slate-100 flex flex-col gap-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[f.jsxs("span",{className:"font-bold text-slate-700 flex items-center gap-1.5",children:[f.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-emerald-500/15 border border-emerald-500/30 text-emerald-700 font-extrabold text-[10px] flex items-center gap-1",children:[f.jsx("span",{children:"🎯"})," ",d.count," étape",d.count>1?"s":""," clé",d.count>1?"s":""]}),d.photos>0&&f.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-indigo-500/15 border border-indigo-500/30 text-indigo-700 font-extrabold text-[10px] flex items-center gap-1",children:[f.jsx("span",{children:"📸"})," ",d.photos," photo",d.photos>1?"s":""]})]}),f.jsxs("span",{className:"text-[10px] font-black px-2 py-0.5 rounded-full bg-emerald-100/80 text-emerald-800 border border-emerald-300 shadow-2xs",children:[d.score,"% enrichi"]})]}),f.jsx("div",{className:"w-full bg-slate-100 h-1.5 rounded-full overflow-hidden border border-slate-200/50",children:f.jsx("div",{className:"h-full bg-gradient-to-r from-emerald-500 via-teal-400 to-indigo-500 rounded-full transition-all duration-500",style:{width:`${Math.max(12,d.score)}%`}})})]}),f.jsxs("div",{className:"pt-1.5 border-t border-purple-100 flex items-center gap-1.5 text-[11px] text-slate-600 min-w-0",children:[f.jsx("span",{className:"shrink-0 px-2 py-0.5 rounded-full bg-gradient-to-r from-purple-600 via-fuchsia-600 to-indigo-600 text-white font-extrabold text-[9px] shadow-sm flex items-center gap-1 border border-purple-300/40",children:"✨ Résumé IA"}),f.jsx("span",{className:"truncate italic text-purple-900/80 font-medium",children:l})]})]},i.slug)})})})]})}let J7e={data:""},ePe=n=>{if(typeof window=="object"){let e=(n?n.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return e.nonce=window.__nonce__,e.parentNode||(n||document.head).appendChild(e),e.firstChild}return n||J7e},tPe=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,nPe=/\/\*[^]*?\*\/| +/g,DK=/\n+/g,Y1=(n,e)=>{let t="",r="",i="";for(let s in n){let a=n[s];s[0]=="@"?s[1]=="i"?t=s+" "+a+";":r+=s[1]=="f"?Y1(a,s):s+"{"+Y1(a,s[1]=="k"?"":e)+"}":typeof a=="object"?r+=Y1(a,e?e.replace(/([^,])+/g,o=>s.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,l=>/&/.test(l)?l.replace(/&/g,o):o?o+" "+l:l)):s):a!=null&&(s=/^--/.test(s)?s:s.replace(/[A-Z]/g,"-$&").toLowerCase(),i+=Y1.p?Y1.p(s,a):s+":"+a+";")}return t+(e&&i?e+"{"+i+"}":i)+r},Lm={},hme=n=>{if(typeof n=="object"){let e="";for(let t in n)e+=t+hme(n[t]);return e}return n},rPe=(n,e,t,r,i)=>{let s=hme(n),a=Lm[s]||(Lm[s]=(l=>{let c=0,u=11;for(;c>>0;return"go"+u})(s));if(!Lm[a]){let l=s!==n?n:(c=>{let u,d,h=[{}];for(;u=tPe.exec(c.replace(nPe,""));)u[4]?h.shift():u[3]?(d=u[3].replace(DK," ").trim(),h.unshift(h[0][d]=h[0][d]||{})):h[0][u[1]]=u[2].replace(DK," ").trim();return h[0]})(n);Lm[a]=Y1(i?{["@keyframes "+a]:l}:l,t?"":"."+a)}let o=t&&Lm.g?Lm.g:null;return t&&(Lm.g=Lm[a]),((l,c,u,d)=>{d?c.data=c.data.replace(d,l):c.data.indexOf(l)===-1&&(c.data=u?l+c.data:c.data+l)})(Lm[a],e,r,o),a},iPe=(n,e,t)=>n.reduce((r,i,s)=>{let a=e[s];if(a&&a.call){let o=a(t),l=o&&o.props&&o.props.className||/^go/.test(o)&&o;a=l?"."+l:o&&typeof o=="object"?o.props?"":Y1(o,""):o===!1?"":o}return r+i+(a??"")},"");function R7(n){let e=this||{},t=n.call?n(e.p):n;return rPe(t.unshift?t.raw?iPe(t,[].slice.call(arguments,1),e.p):t.reduce((r,i)=>Object.assign(r,i&&i.call?i(e.p):i),{}):t,ePe(e.target),e.g,e.o,e.k)}let fme,oz,lz;R7.bind({g:1});let Lg=R7.bind({k:1});function sPe(n,e,t,r){Y1.p=e,fme=n,oz=t,lz=r}function JA(n,e){let t=this||{};return function(){let r=arguments;function i(s,a){let o=Object.assign({},s),l=o.className||i.className;t.p=Object.assign({theme:oz&&oz()},o),t.o=/ *go\d+/.test(l),o.className=R7.apply(t,r)+(l?" "+l:"");let c=n;return n[0]&&(c=o.as||n,delete o.as),lz&&c[0]&&lz(o),fme(c,o)}return i}}var aPe=n=>typeof n=="function",SM=(n,e)=>aPe(n)?n(e):n,oPe=(()=>{let n=0;return()=>(++n).toString()})(),pme=(()=>{let n;return()=>{if(n===void 0&&typeof window<"u"){let e=matchMedia("(prefers-reduced-motion: reduce)");n=!e||e.matches}return n}})(),lPe=20,_H="default",mme=(n,e)=>{let{toastLimit:t}=n.settings;switch(e.type){case 0:return{...n,toasts:[e.toast,...n.toasts].slice(0,t)};case 1:return{...n,toasts:n.toasts.map(a=>a.id===e.toast.id?{...a,...e.toast}:a)};case 2:let{toast:r}=e;return mme(n,{type:n.toasts.find(a=>a.id===r.id)?1:0,toast:r});case 3:let{toastId:i}=e;return{...n,toasts:n.toasts.map(a=>a.id===i||i===void 0?{...a,dismissed:!0,visible:!1}:a)};case 4:return e.toastId===void 0?{...n,toasts:[]}:{...n,toasts:n.toasts.filter(a=>a.id!==e.toastId)};case 5:return{...n,pausedAt:e.time};case 6:let s=e.time-(n.pausedAt||0);return{...n,pausedAt:void 0,toasts:n.toasts.map(a=>({...a,pauseDuration:a.pauseDuration+s}))}}},rN=[],gme={toasts:[],pausedAt:void 0,settings:{toastLimit:lPe}},Xp={},Ame=(n,e=_H)=>{Xp[e]=mme(Xp[e]||gme,n),rN.forEach(([t,r])=>{t===e&&r(Xp[e])})},xme=n=>Object.keys(Xp).forEach(e=>Ame(n,e)),cPe=n=>Object.keys(Xp).find(e=>Xp[e].toasts.some(t=>t.id===n)),L7=(n=_H)=>e=>{Ame(e,n)},uPe={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},dPe=(n={},e=_H)=>{let[t,r]=de.useState(Xp[e]||gme),i=de.useRef(Xp[e]);de.useEffect(()=>(i.current!==Xp[e]&&r(Xp[e]),rN.push([e,r]),()=>{let a=rN.findIndex(([o])=>o===e);a>-1&&rN.splice(a,1)}),[e]);let s=t.toasts.map(a=>{var o,l,c;return{...n,...n[a.type],...a,removeDelay:a.removeDelay||((o=n[a.type])==null?void 0:o.removeDelay)||(n==null?void 0:n.removeDelay),duration:a.duration||((l=n[a.type])==null?void 0:l.duration)||(n==null?void 0:n.duration)||uPe[a.type],style:{...n.style,...(c=n[a.type])==null?void 0:c.style,...a.style}}});return{...t,toasts:s}},hPe=(n,e="blank",t)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:e,ariaProps:{role:"status","aria-live":"polite"},message:n,pauseDuration:0,...t,id:(t==null?void 0:t.id)||oPe()}),US=n=>(e,t)=>{let r=hPe(e,n,t);return L7(r.toasterId||cPe(r.id))({type:2,toast:r}),r.id},li=(n,e)=>US("blank")(n,e);li.error=US("error");li.success=US("success");li.loading=US("loading");li.custom=US("custom");li.dismiss=(n,e)=>{let t={type:3,toastId:n};e?L7(e)(t):xme(t)};li.dismissAll=n=>li.dismiss(void 0,n);li.remove=(n,e)=>{let t={type:4,toastId:n};e?L7(e)(t):xme(t)};li.removeAll=n=>li.remove(void 0,n);li.promise=(n,e,t)=>{let r=li.loading(e.loading,{...t,...t==null?void 0:t.loading});return typeof n=="function"&&(n=n()),n.then(i=>{let s=e.success?SM(e.success,i):void 0;return s?li.success(s,{id:r,...t,...t==null?void 0:t.success}):li.dismiss(r),i}).catch(i=>{let s=e.error?SM(e.error,i):void 0;s?li.error(s,{id:r,...t,...t==null?void 0:t.error}):li.dismiss(r)}),n};var fPe=1e3,pPe=(n,e="default")=>{let{toasts:t,pausedAt:r}=dPe(n,e),i=de.useRef(new Map).current,s=de.useCallback((d,h=fPe)=>{if(i.has(d))return;let p=setTimeout(()=>{i.delete(d),a({type:4,toastId:d})},h);i.set(d,p)},[]);de.useEffect(()=>{if(r)return;let d=Date.now(),h=t.map(p=>{if(p.duration===1/0)return;let g=(p.duration||0)+p.pauseDuration-(d-p.createdAt);if(g<0){p.visible&&li.dismiss(p.id);return}return setTimeout(()=>li.dismiss(p.id,e),g)});return()=>{h.forEach(p=>p&&clearTimeout(p))}},[t,r,e]);let a=de.useCallback(L7(e),[e]),o=de.useCallback(()=>{a({type:5,time:Date.now()})},[a]),l=de.useCallback((d,h)=>{a({type:1,toast:{id:d,height:h}})},[a]),c=de.useCallback(()=>{r&&a({type:6,time:Date.now()})},[r,a]),u=de.useCallback((d,h)=>{let{reverseOrder:p=!1,gutter:g=8,defaultPosition:x}=h||{},_=t.filter(C=>(C.position||x)===(d.position||x)&&C.height),y=_.findIndex(C=>C.id===d.id),M=_.filter((C,k)=>kC.visible).slice(...p?[M+1]:[0,M]).reduce((C,k)=>C+(k.height||0)+g,0)},[t]);return de.useEffect(()=>{t.forEach(d=>{if(d.dismissed)s(d.id,d.removeDelay);else{let h=i.get(d.id);h&&(clearTimeout(h),i.delete(d.id))}})},[t,s]),{toasts:t,handlers:{updateHeight:l,startPause:o,endPause:c,calculateOffset:u}}},mPe=Lg` from { transform: scale(0) rotate(45deg); opacity: 0; } to { transform: scale(1) rotate(45deg); opacity: 1; }`,gPe=Lg` from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; }`,APe=Lg` from { transform: scale(0) rotate(90deg); opacity: 0; } to { transform: scale(1) rotate(90deg); opacity: 1; }`,xPe=JA("div")` width: 20px; opacity: 0; height: 20px; border-radius: 10px; background: ${n=>n.primary||"#ff4b4b"}; position: relative; transform: rotate(45deg); animation: ${mPe} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; animation-delay: 100ms; &:after, &:before { content: ''; animation: ${gPe} 0.15s ease-out forwards; animation-delay: 150ms; position: absolute; border-radius: 3px; opacity: 0; background: ${n=>n.secondary||"#fff"}; bottom: 9px; left: 4px; height: 2px; width: 12px; } &:before { animation: ${APe} 0.15s ease-out forwards; animation-delay: 180ms; transform: rotate(90deg); } `,vPe=Lg` from { transform: rotate(0deg); } to { transform: rotate(360deg); } `,yPe=JA("div")` width: 12px; height: 12px; box-sizing: border-box; border: 2px solid; border-radius: 100%; border-color: ${n=>n.secondary||"#e0e0e0"}; border-right-color: ${n=>n.primary||"#616161"}; animation: ${vPe} 1s linear infinite; `,bPe=Lg` from { transform: scale(0) rotate(45deg); opacity: 0; } to { transform: scale(1) rotate(45deg); opacity: 1; }`,_Pe=Lg` 0% { height: 0; width: 0; opacity: 0; } 40% { height: 0; width: 6px; opacity: 1; } 100% { opacity: 1; height: 10px; }`,wPe=JA("div")` width: 20px; opacity: 0; height: 20px; border-radius: 10px; background: ${n=>n.primary||"#61d345"}; position: relative; transform: rotate(45deg); animation: ${bPe} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; animation-delay: 100ms; &:after { content: ''; box-sizing: border-box; animation: ${_Pe} 0.2s ease-out forwards; opacity: 0; animation-delay: 200ms; position: absolute; border-right: 2px solid; border-bottom: 2px solid; border-color: ${n=>n.secondary||"#fff"}; bottom: 6px; left: 6px; height: 10px; width: 6px; } `,SPe=JA("div")` position: absolute; `,TPe=JA("div")` position: relative; display: flex; justify-content: center; align-items: center; min-width: 20px; min-height: 20px; `,EPe=Lg` from { transform: scale(0.6); opacity: 0.4; } to { transform: scale(1); opacity: 1; }`,NPe=JA("div")` position: relative; transform: scale(0.6); opacity: 0.4; min-width: 20px; animation: ${EPe} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; `,MPe=({toast:n})=>{let{icon:e,type:t,iconTheme:r}=n;return e!==void 0?typeof e=="string"?de.createElement(NPe,null,e):e:t==="blank"?null:de.createElement(TPe,null,de.createElement(yPe,{...r}),t!=="loading"&&de.createElement(SPe,null,t==="error"?de.createElement(xPe,{...r}):de.createElement(wPe,{...r})))},CPe=n=>` 0% {transform: translate3d(0,${n*-200}%,0) scale(.6); opacity:.5;} 100% {transform: translate3d(0,0,0) scale(1); opacity:1;} `,PPe=n=>` 0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;} 100% {transform: translate3d(0,${n*-150}%,-1px) scale(.6); opacity:0;} `,RPe="0%{opacity:0;} 100%{opacity:1;}",LPe="0%{opacity:1;} 100%{opacity:0;}",kPe=JA("div")` display: flex; align-items: center; background: #fff; color: #363636; line-height: 1.3; will-change: transform; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05); max-width: 350px; pointer-events: auto; padding: 8px 10px; border-radius: 8px; `,IPe=JA("div")` display: flex; justify-content: center; margin: 4px 10px; color: inherit; flex: 1 1 auto; white-space: pre-line; `,DPe=(n,e)=>{let t=n.includes("top")?1:-1,[r,i]=pme()?[RPe,LPe]:[CPe(t),PPe(t)];return{animation:e?`${Lg(r)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${Lg(i)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},OPe=de.memo(({toast:n,position:e,style:t,children:r})=>{let i=n.height?DPe(n.position||e||"top-center",n.visible):{opacity:0},s=de.createElement(MPe,{toast:n}),a=de.createElement(IPe,{...n.ariaProps},SM(n.message,n));return de.createElement(kPe,{className:n.className,style:{...i,...t,...n.style}},typeof r=="function"?r({icon:s,message:a}):de.createElement(de.Fragment,null,s,a))});sPe(de.createElement);var jPe=({id:n,className:e,style:t,onHeightUpdate:r,children:i})=>{let s=de.useCallback(a=>{if(a){let o=()=>{let l=a.getBoundingClientRect().height;r(n,l)};o(),new MutationObserver(o).observe(a,{subtree:!0,childList:!0,characterData:!0})}},[n,r]);return de.createElement("div",{ref:s,className:e,style:t},i)},FPe=(n,e)=>{let t=n.includes("top"),r=t?{top:0}:{bottom:0},i=n.includes("center")?{justifyContent:"center"}:n.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:pme()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${e*(t?1:-1)}px)`,...r,...i}},BPe=R7` z-index: 9999; > * { pointer-events: auto; } `,nT=16,UPe=({reverseOrder:n,position:e="top-center",toastOptions:t,gutter:r,children:i,toasterId:s,containerStyle:a,containerClassName:o})=>{let{toasts:l,handlers:c}=pPe(t,s);return de.createElement("div",{"data-rht-toaster":s||"",style:{position:"fixed",zIndex:9999,top:nT,left:nT,right:nT,bottom:nT,pointerEvents:"none",...a},className:o,onMouseEnter:c.startPause,onMouseLeave:c.endPause},l.map(u=>{let d=u.position||e,h=c.calculateOffset(u,{reverseOrder:n,gutter:r,defaultPosition:e}),p=FPe(d,h);return de.createElement(jPe,{id:u.id,key:u.id,onHeightUpdate:c.updateHeight,className:u.visible?BPe:"",style:p},u.type==="custom"?SM(u.message,u):i?i(u):de.createElement(OPe,{toast:u,position:d}))}))},jt=li;const zPe="https://famille.ravin-cloud.fr";function VPe({onIntent:n}){const[e,t]=de.useState(!1),[r,i]=de.useState(!1),s=de.useRef(null),a=de.useRef([]),o=async()=>{if(!r)if(e)s.current&&(s.current.stop(),t(!1),i(!0));else try{const c=await navigator.mediaDevices.getUserMedia({audio:!0}),u={mimeType:"audio/webm"},d=new MediaRecorder(c,MediaRecorder.isTypeSupported("audio/webm")?u:void 0);s.current=d,a.current=[],d.ondataavailable=h=>{h.data.size>0&&a.current.push(h.data)},d.onstop=async()=>{c.getTracks().forEach(p=>p.stop());const h=new Blob(a.current,{type:d.mimeType});await l(h)},d.start(),t(!0)}catch(c){console.error("Microphone access denied or error:",c),jt.error("Erreur d'accès au microphone")}},l=async c=>{const u=new FormData;u.append("audio",c,"recording.webm");try{const d=await fetch(`${zPe}/api/voice/intent`,{method:"POST",body:u,credentials:"include"});if(!d.ok)throw new Error("Erreur réseau");const h=await d.json();if(h.error)throw new Error(h.error);n?n(h):jt.success(`Intent: ${h.intent}`)}catch(d){console.error("Audio processing error",d),jt.error("Impossible de comprendre la voix")}finally{i(!1)}};return f.jsxs("div",{className:"fixed bottom-40 md:bottom-26 right-4 md:right-8 z-50",children:[f.jsx(Gn.button,{onClick:o,whileTap:{scale:.92},whileHover:{scale:1.06},title:"🎙️ Dictée vocale / Push-to-Talk",className:`w-14 h-14 md:w-16 md:h-16 rounded-full shadow-[0_8px_20px_rgba(0,0,0,0.4)] flex items-center justify-center text-white border-2 border-white/20 ${e?"bg-rose-600 animate-pulse border-rose-400 ring-4 ring-rose-500/30":r?"bg-slate-600 border-slate-400":"bg-gradient-to-r from-sky-600 to-indigo-600 hover:from-sky-500 hover:to-indigo-500"} transition-all duration-200`,children:f.jsx(Da,{mode:"wait",children:r?f.jsx(Gn.div,{initial:{opacity:0,rotate:-90},animate:{opacity:1,rotate:0},exit:{opacity:0,rotate:90},className:"animate-spin",children:f.jsx(vu,{size:24})},"spinner"):f.jsx(Gn.div,{initial:{opacity:0,scale:.5},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.5},children:f.jsx(BS,{size:24})},"mic")})}),e&&f.jsx("span",{className:"absolute -top-8 left-1/2 -translate-x-1/2 whitespace-nowrap text-xs font-bold text-red-500 bg-white px-2 py-1 rounded shadow",children:"Écoute..."})]})}const qPe="https://famille.ravin-cloud.fr";function GPe({onAnalyzeResult:n,onClose:e}){const t=de.useRef(null),r=de.useRef(null),[i,s]=de.useState(null),[a,o]=de.useState(!1);de.useEffect(()=>(l(),()=>c()),[]);const l=async()=>{try{const d=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}});s(d),t.current&&(t.current.srcObject=d)}catch(d){console.error("Erreur caméra:",d),jt.error("Impossible d'accéder à la caméra")}},c=()=>{i&&i.getTracks().forEach(d=>d.stop())},u=async()=>{if(!t.current||!r.current)return;o(!0);const d=r.current,h=t.current;d.width=h.videoWidth,d.height=h.videoHeight,d.getContext("2d").drawImage(h,0,0,d.width,d.height),d.toBlob(async g=>{const x=new FormData;x.append("image",g,"capture.jpg");try{const _=await fetch(`${qPe}/api/vision/analyze`,{method:"POST",body:x,credentials:"include"});if(!_.ok)throw new Error("Erreur réseau");const y=await _.json();n(y)}catch(_){console.error("Analyse error",_),jt.error("Erreur lors de l'analyse de l'image")}finally{o(!1)}},"image/jpeg",.8)};return f.jsxs("div",{className:"fixed inset-0 z-[100] bg-black flex flex-col",children:[f.jsxs("div",{className:"flex justify-between items-center p-4 bg-black bg-opacity-50 text-white z-10",children:[f.jsx("h2",{className:"font-bold text-lg",children:"Scan Intelligent"}),f.jsx("button",{onClick:()=>{c(),e()},className:"p-2 rounded-full bg-white bg-opacity-20 hover:bg-opacity-40 transition-colors",children:f.jsx($a,{size:20})})]}),f.jsxs("div",{className:"relative flex-1 flex items-center justify-center bg-black overflow-hidden",children:[f.jsx("video",{ref:t,autoPlay:!0,playsInline:!0,className:"min-w-full min-h-full object-cover"}),f.jsx("canvas",{ref:r,className:"hidden"}),f.jsx("div",{className:"absolute inset-0 border-[40px] border-black border-opacity-50 pointer-events-none flex items-center justify-center",children:f.jsx("div",{className:"w-full h-full border-2 border-dashed border-emerald-500 opacity-50"})}),a&&f.jsxs("div",{className:"absolute inset-0 bg-black bg-opacity-70 flex flex-col items-center justify-center text-white z-20",children:[f.jsx(vu,{className:"animate-spin mb-4",size:40}),f.jsx("p",{className:"font-semibold tracking-wider",children:"Analyse par l'IA en cours..."})]})]}),f.jsx("div",{className:"h-32 bg-black flex items-center justify-center pb-8",children:f.jsx(Gn.button,{whileTap:{scale:.9},onClick:u,disabled:a,className:"w-20 h-20 rounded-full border-4 border-white flex items-center justify-center bg-transparent",children:f.jsx("div",{className:"w-16 h-16 rounded-full bg-white flex items-center justify-center text-slate-800",children:f.jsx(fm,{size:24})})})})]})}function HPe({data:n,onSave:e,onCancel:t}){const[r,i]=de.useState({prenom:(n==null?void 0:n.prenom)||"",nom:(n==null?void 0:n.nom)||"",date_naissance:(n==null?void 0:n.date_naissance)||"",lieu_naissance:(n==null?void 0:n.lieu_naissance)||"",sexe:(n==null?void 0:n.sexe)||""}),s=o=>{i({...r,[o.target.name]:o.target.value})},a=o=>{o.preventDefault(),e(r)};return f.jsx("div",{className:"fixed inset-0 z-[110] flex items-center justify-center bg-black bg-opacity-60 p-4",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"bg-white rounded-2xl shadow-2xl p-6 w-full max-w-md",children:[f.jsx("h2",{className:"text-2xl font-bold text-slate-800 mb-2",children:"Validation des données"}),f.jsx("p",{className:"text-sm text-slate-500 mb-6",children:"Vérifiez les informations extraites par l'IA avant de créer la fiche."}),f.jsxs("form",{onSubmit:a,className:"space-y-4",children:[f.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"Prénom"}),f.jsx("input",{type:"text",name:"prenom",value:r.prenom,onChange:s,className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 outline-none",required:!0})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"Nom"}),f.jsx("input",{type:"text",name:"nom",value:r.nom,onChange:s,className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 outline-none",required:!0})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"Date de naissance"}),f.jsx("input",{type:"date",name:"date_naissance",value:r.date_naissance,onChange:s,className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 outline-none"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"Sexe (H/F)"}),f.jsx("input",{type:"text",name:"sexe",value:r.sexe,onChange:s,className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 outline-none"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"Lieu de naissance"}),f.jsx("input",{type:"text",name:"lieu_naissance",value:r.lieu_naissance,onChange:s,className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 outline-none"})]}),f.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[f.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-slate-600 hover:bg-slate-100 rounded-lg font-medium transition-colors",children:"Annuler"}),f.jsx("button",{type:"submit",className:"px-6 py-2 bg-emerald-600 hover:bg-emerald-700 text-white rounded-lg font-medium shadow-md transition-colors",children:"Enregistrer"})]})]})]})})}const nu="https://famille.ravin-cloud.fr",JL={FaBirthdayCake:f.jsx(vH,{className:"w-5 h-5 text-pink-500"}),FaHeart:f.jsx(Y0,{className:"w-5 h-5 text-rose-500"}),FaBriefcase:f.jsx(Wp,{className:"w-5 h-5 text-amber-500"}),FaUserGraduate:f.jsx(cH,{className:"w-5 h-5 text-indigo-500"}),FaBaby:f.jsx(r4,{className:"w-5 h-5 text-emerald-500"}),FaEdit:f.jsx(Pg,{className:"w-5 h-5 text-purple-500"}),default:f.jsx(V0,{className:"w-5 h-5 text-amber-400"})};function e9(n,e,t){if(t==="birth")return f.jsx(r4,{className:"w-5 h-5 text-emerald-500"});if(t==="marriage"||t==="union")return f.jsx(Y0,{className:"w-5 h-5 text-rose-500"});if(t==="death")return f.jsx(V0,{className:"w-5 h-5 text-slate-400"});if(t==="journal")return f.jsx(bM,{className:"w-5 h-5 text-purple-500"});if(t==="child")return f.jsx(r4,{className:"w-5 h-5 text-indigo-500"});if(e&&JL[e])return JL[e];const r=(n||"").toLowerCase();return r.includes("naissance")?f.jsx(r4,{className:"w-5 h-5 text-emerald-500"}):r.includes("mariage")||r.includes("union")||r.includes("pacs")?f.jsx(Y0,{className:"w-5 h-5 text-rose-500"}):r.includes("décès")||r.includes("mort")?f.jsx(V0,{className:"w-5 h-5 text-slate-400"}):r.includes("travail")||r.includes("emploi")||r.includes("profession")?f.jsx(Wp,{className:"w-5 h-5 text-amber-500"}):r.includes("étude")||r.includes("diplôme")||r.includes("école")?f.jsx(cH,{className:"w-5 h-5 text-indigo-500"}):r.includes("déménagement")||r.includes("habite")?f.jsx(bA,{className:"w-5 h-5 text-teal-500"}):r.includes("journal")?f.jsx(bM,{className:"w-5 h-5 text-purple-500"}):JL.default}function rT(n,e){const t=(e||"").toLowerCase();return n==="birth"||t.includes("naissance")?{label:"Naissance",bg:"bg-emerald-50 text-emerald-700 border-emerald-200"}:n==="marriage"||n==="union"||t.includes("mariage")||t.includes("union")?{label:"Union / Mariage",bg:"bg-rose-50 text-rose-700 border-rose-200"}:n==="death"||t.includes("décès")?{label:"Décès",bg:"bg-slate-100 text-slate-700 border-slate-300"}:n==="journal"||t.includes("journal")?{label:"Journal Intime",bg:"bg-purple-50 text-purple-700 border-purple-200"}:t.includes("arrière-petit-enfant")?{label:"Arrière-petit-enfant",bg:"bg-teal-50 text-teal-700 border-teal-200"}:t.includes("petit-enfant")?{label:"Petit-enfant",bg:"bg-pink-50 text-pink-700 border-pink-200"}:n==="child"||t.includes("enfant")?{label:"Enfant",bg:"bg-indigo-50 text-indigo-700 border-indigo-200"}:{label:"Événement",bg:"bg-amber-50 text-amber-700 border-amber-200"}}function $Pe(n){if(!n)return null;const e=n.match(/(?:naissance|adoption|accueil|arrivée).*?(?:de\s+|d['’])\s*([^.,:;]+)/i);return e&&e[1]?e[1].split(/\s+(?:à|en|le|la|les|pour)\s+/i)[0].trim():null}function WPe(n){if(!n)return"?";const e=n.trim().split(/\s+/);return e.length===1?e[0].substring(0,2).toUpperCase():(e[0][0]+e[e.length-1][0]).toUpperCase()}const iT={1:"janvier",2:"février",3:"mars",4:"avril",5:"mai",6:"juin",7:"juillet",8:"août",9:"septembre",10:"octobre",11:"novembre",12:"décembre"},sT={1:"janv.",2:"févr.",3:"mars",4:"avr.",5:"mai",6:"juin",7:"juil.",8:"août",9:"sept.",10:"oct.",11:"nov.",12:"déc."};function vme(n){if(!n||n==="À préciser"||n==="Inconnue")return{year:"",dayMonth:"",full:n||"Date à préciser"};const e=String(n).trim().replace(/^['"]+|['"]+$/g,""),t=e.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/);if(t){const a=t[1],o=parseInt(t[2],10),l=parseInt(t[3],10),c=l===1?"1er":String(l),u=sT[o]||t[2];return{year:a,dayMonth:`${c} ${u}`,full:`${c} ${iT[o]||o} ${a}`}}const r=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);if(r){const a=parseInt(r[1],10),o=parseInt(r[2],10),l=r[3],c=a===1?"1er":String(a),u=sT[o]||r[2];return{year:l,dayMonth:`${c} ${u}`,full:`${c} ${iT[o]||o} ${l}`}}const i=e.match(/^(\d{4})-(\d{1,2})$/);if(i){const a=i[1],o=parseInt(i[2],10),l=sT[o]||i[2];return{year:a,dayMonth:l,full:`${iT[o]||o} ${a}`}}if(e.includes("GMT")||e.includes("UTC")||e.includes("T")||e.includes(",")){const a=new Date(e);if(!isNaN(a.getTime())){const o=a.getUTCDate(),l=a.getUTCMonth()+1,c=String(a.getUTCFullYear()),u=o===1?"1er":String(o),d=sT[l]||l;return{year:c,dayMonth:`${u} ${d}`,full:`${u} ${iT[l]||l} ${c}`}}}const s=e.match(/\b(1\d{3}|20\d{2})\b/);return s?{year:s[1],dayMonth:"",full:s[1]}:{year:"",dayMonth:"",full:e}}function XPe(n,e){if(!n||!e)return null;const t=String(n).match(/\d{4}/),r=String(e).match(/\d{4}/);if(!t||!r)return null;const i=parseInt(t[0],10),s=parseInt(r[0],10),a=i-s;return a<0?null:a===0?"Naissance":`${a} an${a>1?"s":""}`}function fw(n){return!n||n==="À préciser"||n==="Inconnue"?n||"Date à préciser":vme(n).full||n}function OK(n){if(!n||n==="À préciser")return"9999-99-99";const e=String(n).trim().replace(/^['"]+|['"]+$/g,"");if(/^\d{4}-\d{2}-\d{2}$/.test(e))return e;const t=e.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);if(t){const s=t[1].padStart(2,"0"),a=t[2].padStart(2,"0");return`${t[3]}-${a}-${s}`}const r=e.match(/^(\d{4})-(\d{1,2})$/);if(r)return`${r[1]}-${r[2].padStart(2,"0")}-01`;const i=e.match(/\b(1\d{3}|20\d{2})\b/);return i?`${i[1]}-01-01`:"9999-99-99"}function yme({person:n=null,people:e=[],refreshKey:t,onEventEdited:r,onSelectPerson:i,onEditPerson:s,onNavigateToPerson:a}){const[o,l]=de.useState([]),[c,u]=de.useState(!0),[d,h]=de.useState(n?n.slug:"all"),[p,g]=de.useState(""),[x,_]=de.useState("all"),[y,M]=de.useState(null),[C,k]=de.useState({date:"",title:"",description:""}),[B,U]=de.useState(null),[z,O]=de.useState(null),[V,$]=de.useState("panoramic"),[G,H]=de.useState(.75),[K,W]=de.useState(!1),J=de.useRef(null),ie=Pe=>{if(!Pe)return!1;const nt=(Pe.type||"").toLowerCase();if(["birth","marriage","union","child","grandchild","great_grandchild","death"].includes(nt))return!1;const qe=(Pe.source||"").toLowerCase(),yt=(Pe.title||"").toLowerCase(),Qt=(Pe.description||"").toLowerCase();return!!(nt==="famileo"||nt==="photo"||nt==="social"||qe.includes("famileo")||qe.includes("facebook")||qe.includes("instagram")||qe.includes("tiktok")||qe.includes("réseau")||qe.includes("social")||qe.includes("album")||yt.includes("famileo")||yt.includes("gazette")||Qt.includes("gazette famileo")||(Pe.photo||Pe.event_photo||"").includes("/uploads/famileo")||(Pe.photo||Pe.event_photo||"").includes("/uploads/fb_avatars"))};de.useEffect(()=>{n&&n.slug&&h(n.slug)},[n]);const ae=async()=>{u(!0);try{const nt=await(await fetch(`${nu}/api/timeline`,{credentials:"include"})).json();l(nt.events||[])}catch(Pe){console.error("Failed to fetch timeline:",Pe),l([])}finally{u(!1)}};de.useEffect(()=>{ae()},[t]);const Q=de.useMemo(()=>d==="all"?null:(e||[]).find(Pe=>Pe.slug===d)||((n==null?void 0:n.slug)===d?n:null),[d,e,n]),re=de.useMemo(()=>{if(!Q)return null;const Pe=(Q.parents||[]).map(zt=>(e||[]).find(Yt=>Yt.slug===zt)).filter(Boolean),nt=Q.conjoint?(e||[]).find(zt=>zt.slug===Q.conjoint):null,qe=(e||[]).filter(zt=>Array.isArray(zt.parents)&&zt.parents.includes(Q.slug)),yt=qe.map(zt=>zt.slug),Qt=(e||[]).filter(zt=>Array.isArray(zt.parents)&&zt.parents.some(Yt=>yt.includes(Yt)));let Be="";const pt=String(Q.date_naissance||"").match(/\d{4}/),rt=String(Q.date_deces||"").match(/\d{4}/);if(pt){const zt=parseInt(pt[0],10);if(rt){const Yt=parseInt(rt[0],10),Bt=Yt-zt;Be=`${zt} – ${Yt} (${Bt} ans)`}else{const Bt=new Date().getFullYear()-zt;Be=`Né(e) en ${zt} (${Bt} ans)`}}return{parents:Pe,conjoint:nt,children:qe,grandchildren:Qt,lifespanText:Be}},[Q,e]),oe=de.useMemo(()=>{let Pe=o||[];if(d!=="all"&&(Pe=Pe.filter(qe=>qe.slug===d)),x!=="all"&&(Pe=Pe.filter(qe=>{const yt=rT(qe.type,qe.title);return x==="birth"?qe.type==="birth"||qe.type==="child"||yt.label==="Naissance"||yt.label==="Enfant"||yt.label==="Petit-enfant"||yt.label==="Arrière-petit-enfant":x==="marriage"?qe.type==="marriage"||qe.type==="union"||yt.label==="Union / Mariage":x==="journal"?qe.type==="journal"||yt.label==="Journal Intime":x==="death"?qe.type==="death"||yt.label==="Décès":x==="event"?qe.type==="event"||yt.label==="Événement":!0})),p.trim()){const qe=p.toLowerCase().trim();Pe=Pe.filter(yt=>yt.title&&yt.title.toLowerCase().includes(qe)||yt.description&&yt.description.toLowerCase().includes(qe)||yt.person&&yt.person.toLowerCase().includes(qe)||yt.date&&String(yt.date).toLowerCase().includes(qe)||yt.slug&&yt.slug.toLowerCase().includes(qe))}const nt={birth:10,event:20,marriage:30,union:30,journal:35,child:40,child_marriage:50,grandchild:60,great_grandchild:70,death:90};return[...Pe].sort((qe,yt)=>{const Qt=OK(qe.date),Be=OK(yt.date);if(Qt!==Be)return Qt.localeCompare(Be);const pt=qe.priority||nt[qe.type]||25,rt=yt.priority||nt[yt.type]||25;return pt!==rt?pt-rt:(qe.title||"").localeCompare(yt.title||"")})},[o,d,x,p]),{majorCount:fe,mediaCount:ee}=de.useMemo(()=>{let Pe=0,nt=0;return(oe||[]).forEach(qe=>{ie(qe)?nt++:Pe++}),{majorCount:Pe,mediaCount:nt}},[oe]),me=de.useMemo(()=>{if(!oe||oe.length===0)return[];const Pe=qe=>{if(!qe||qe==="À préciser")return null;const yt=String(qe).match(/\d{4}/);return yt?parseInt(yt[0],10):null},nt=new Map;return oe.forEach((qe,yt)=>{const Qt=Pe(qe.date);if(Qt){const Be=Math.floor(Qt/10)*10,pt=`${Be}`;nt.has(pt)?nt.get(pt).count+=1:nt.set(pt,{id:pt,decade:Be,label:`${Be}s`,firstIndex:yt,count:1})}}),Array.from(nt.values()).sort((qe,yt)=>qe.decade-yt.decade)},[oe]),[Ae,be]=de.useState(null),[pe,ge]=de.useState(null),Te=()=>{if(!J.current||oe.length===0)return;const nt=Math.round(V==="panoramic"?270*G:360*G),qe=Math.round(56*G),yt=J.current.scrollLeft;let Qt=0,Be=0;for(let rt=0;rt=yt+100){Be=rt;break}}const pt=oe[Be]||oe[0];if(pt&&pt.date){const rt=String(pt.date).match(/\d{4}/);if(rt){const zt=parseInt(rt[0],10);be(zt),ge(Math.floor(zt/10)*10)}}},ze=Pe=>{if(!J.current)return;const qe=Math.round(V==="panoramic"?270*G:360*G),yt=Math.round(56*G);let Qt=0;for(let Be=0;Be{J.current&&oe.length>0&&(J.current.scrollLeft=0,Te())},[d,x]);const[Xe,Qe]=de.useState(!1),[ot,bt]=de.useState(0),[ht,Ce]=de.useState(0),lt=Pe=>{J.current&&(Qe(!0),bt(Pe.pageX-J.current.offsetLeft),Ce(J.current.scrollLeft))},ft=()=>Qe(!1),et=Pe=>{if(!Xe||!J.current)return;Pe.preventDefault();const qe=(Pe.pageX-J.current.offsetLeft-ot)*1.5;J.current.scrollLeft=ht-qe},[At,Lt]=de.useState(!1),[st,Ht]=de.useState(!1),[Se,_t]=de.useState({slug:"",date:"",title:"",description:"",photo:""}),It=async(Pe,nt=!1)=>{var yt;if(!Pe)return;Ht(!0);const qe=jt.loading("Envoi de la photo de l'événement...");try{const Qt=new FormData;Qt.append("photo",Pe);const Be=nt?Se.slug||"event":((yt=C.originalEvent)==null?void 0:yt.slug)||"event";Qt.append("slug",Be);const pt=await fetch(`${nu}/api/timeline/events/upload_photo`,{method:"POST",credentials:"include",body:Qt}),rt=await pt.json();if(!pt.ok)throw new Error(rt.error||"Erreur d'upload");nt?_t(zt=>({...zt,photo:rt.photo_url})):k(zt=>({...zt,photo:rt.photo_url,event_photo:rt.photo_url})),jt.success("Photo ajoutée à l'événement !",{id:qe})}catch(Qt){jt.error(Qt.message||"Impossible d'uploader la photo",{id:qe})}finally{Ht(!1)}},De=(Pe,nt)=>{M(Pe),k({date:nt.date||"",title:nt.title||"",description:nt.description||"",photo:nt.event_photo||nt.photo_url||"",originalEvent:nt})},ue=()=>M(null),Ve=async Pe=>{var yt,Qt;const nt=oe[Pe],qe=jt.loading("Sauvegarde...");try{const Be=nt==null?void 0:nt.slug;if(Be&&Be!=="journal"){const pt=await fetch(`${nu}/api/timeline/events/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({slug:Be,date:C.date,title:C.title,description:C.description,photo:C.photo||C.event_photo||"",original_title:(yt=C.originalEvent)==null?void 0:yt.title,original_date:(Qt=C.originalEvent)==null?void 0:Qt.date})}),rt=await pt.json();if(!pt.ok)throw new Error(rt.error||"Erreur de sauvegarde");const zt=[...o],Yt=zt.findIndex(Bt=>Bt===nt||Bt.slug===(nt==null?void 0:nt.slug)&&Bt.title===(nt==null?void 0:nt.title)&&Bt.date===(nt==null?void 0:nt.date));Yt!==-1&&(zt[Yt]={...zt[Yt],date:C.date,title:C.title,description:C.description,event_photo:C.photo||C.event_photo||zt[Yt].event_photo},l(zt)),M(null),jt.success("Événement enregistré avec succès !",{id:qe}),r&&r()}}catch(Be){jt.error(Be.message||"Erreur lors de la sauvegarde",{id:qe})}},We=async Pe=>{if(Pe.preventDefault(),!Se.slug){jt.error("Veuillez sélectionner une personne.");return}if(!Se.title.trim()){jt.error("Veuillez saisir un titre pour l'événement.");return}const nt=jt.loading("Création de l'événement...");try{const qe=await fetch(`${nu}/api/timeline/events/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(Se)}),yt=await qe.json();if(!qe.ok)throw new Error(yt.error||"Erreur de création");const Qt=(e||[]).find(pt=>pt.slug===Se.slug),Be={slug:Se.slug,person:Qt?`${Qt.prenom} ${Qt.nom}`:Se.slug,photo:(Qt==null?void 0:Qt.photo)||"",date:Se.date||"À préciser",title:Se.title,description:Se.description,event_photo:Se.photo||"",type:"event",priority:20};l(pt=>[Be,...pt]),Lt(!1),_t({slug:"",date:"",title:"",description:"",photo:""}),jt.success("Événement ajouté avec succès !",{id:nt}),r&&r()}catch(qe){jt.error(qe.message||"Erreur lors de l'ajout",{id:nt})}},ct=async Pe=>{const nt=oe[Pe];if(!nt||!window.confirm(`Supprimer définitivement "${nt.title||"cet événement"}" de la frise chronologique ?`))return;const qe=jt.loading("Suppression en cours...");try{const yt=await fetch(`${nu}/api/timeline/events/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({slug:nt.slug||(n?n.slug:""),title:nt.title,date:nt.date,photo:nt.photo||nt.event_photo||""})}),Qt=await yt.json();if(!yt.ok||Qt.error)throw new Error(Qt.error||"Erreur lors de la suppression");l(Be=>Be.filter(pt=>pt!==nt)),jt.success("Événement définitivement supprimé !",{id:qe}),r&&r()}catch(yt){jt.error(yt.message||"Erreur lors de la suppression",{id:qe})}},vt=Pe=>{jt.success(`Navigation vers ${Pe}...`),a?a(Pe):window.dispatchEvent(new CustomEvent("timeline-navigate",{detail:{target_person:Pe}}))},Ut=Pe=>{if(J.current){const nt=window.innerWidth*.45;J.current.scrollBy({left:Pe==="left"?-nt:nt,behavior:"smooth"})}},dt=Pe=>{if(!Pe||Pe==="journal")return;let nt=null;if(typeof Pe=="string"){const qe=Pe.toLowerCase().trim();nt=(e||[]).find(yt=>yt.slug===qe||yt.slug===qe.replace(/\s+/g,"-")||`${yt.prenom||""} ${yt.nom||""}`.toLowerCase().trim()===qe||yt.prenom&&yt.prenom.toLowerCase()===qe)}else Pe.slug&&(nt=(e||[]).find(qe=>qe.slug===Pe.slug));nt&&(h(nt.slug),i&&i(nt),a&&a(nt.slug),jt(`Fiche de ${nt.prenom} ${nt.nom} sélectionnée`,{icon:"👤"}))},mt=Pe=>{Pe.slug&&Pe.slug!=="journal"?dt(Pe.slug):Pe.person&&dt(Pe.person)},Ft=Pe=>{if(!Pe||typeof Pe!="string"||!e||e.length===0)return Pe;const nt=[];e.forEach(rt=>{rt.prenom&&rt.prenom.trim().length>=3&&(nt.push({name:`${rt.prenom.trim()} ${rt.nom?rt.nom.trim():""}`.trim(),slug:rt.slug,person:rt}),nt.push({name:rt.prenom.trim(),slug:rt.slug,person:rt}))});const qe=[],yt=new Set;if(nt.sort((rt,zt)=>zt.name.length-rt.name.length).forEach(rt=>{const zt=rt.name.toLowerCase();yt.has(zt)||(yt.add(zt),qe.push(rt))}),qe.length===0)return Pe;const Qt=qe.map(rt=>rt.name.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),Be=new RegExp(`(\\b(?:${Qt})\\b)`,"gi");return Pe.split(Be).map((rt,zt)=>{if(!rt)return null;const Yt=qe.find(Bt=>Bt.name.toLowerCase()===rt.toLowerCase());return Yt?f.jsxs("button",{onClick:Bt=>{Bt.stopPropagation(),dt(Yt.slug)},className:"inline-flex items-center gap-0.5 px-1.5 py-0.2 mx-0.5 bg-amber-100/90 hover:bg-amber-200 text-amber-950 font-black rounded-md border border-amber-300 transition text-inherit align-baseline hover:scale-105 cursor-pointer shadow-2xs",title:`Cliquer pour ouvrir la fiche de ${Yt.name}`,children:[f.jsx("span",{className:"text-[10px]",children:"👤"}),f.jsx("span",{className:"underline decoration-amber-500/60 font-serif font-bold",children:rt})]},zt):rt})},tt=[{id:"all",label:"Tous",icon:"✨",title:"Tous les événements",desc:"Affiche l'intégralité des événements de vie, naissances, mariages, récits du journal et hommages."},{id:"birth",label:"Naissances",icon:"🍼",title:"Naissances & Enfants",desc:"Filtre sur les naissances, baptêmes et naissances des enfants de la famille."},{id:"marriage",label:"Unions",icon:"💍",title:"Unions & Mariages",desc:"Met en avant les mariages civils, religieux, pacs et célébrations d'unions."},{id:"event",label:"Marquants",icon:"🌟",title:"Faits Marquants",desc:"Retrace les grands moments : métiers, voyages, diplômes, distinctions et événements historiques."},{id:"journal",label:"Journal",icon:"📖",title:"Journal & Récits",desc:"Affiche les mémoires, récits intimes et chroniques rédigées dans le journal familial."},{id:"death",label:"Décès",icon:"🕊️",title:"Hommages & Décès",desc:"Moments de souvenir et dates de disparition des proches et ancêtres."}];return f.jsxs("div",{className:"w-full flex flex-col bg-slate-50/80 rounded-3xl shadow-xl border border-slate-200/80 overflow-hidden relative",children:[f.jsxs("div",{className:"bg-white/95 backdrop-blur-md px-4 py-2.5 border-b border-slate-200 shadow-xs space-y-2 z-30",children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2.5 shrink-0",children:[f.jsx("div",{className:"w-8 h-8 rounded-xl bg-gradient-to-br from-amber-500 to-amber-700 text-white flex items-center justify-center shadow-md shadow-amber-500/20 font-bold text-xs shrink-0",children:"⏳"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h2",{className:"text-sm sm:text-base font-black text-slate-900 tracking-tight font-serif leading-none",children:"Frise Chronologique"}),f.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-amber-100/90 text-amber-950 font-black text-[10px] border border-amber-300 shrink-0 flex items-center gap-1.5",children:[f.jsxs("span",{children:["🌟 ",fe," ",fe>1?"marquants":"marquant"]}),ee>0&&f.jsxs("span",{className:"text-amber-800/80 font-semibold hidden sm:inline",children:["• 📸 ",ee," photos"]})]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-wrap sm:flex-nowrap shrink-0",children:[f.jsxs("button",{onClick:()=>{h("all"),i&&i(null)},className:`px-3 py-1.5 rounded-xl text-xs font-black transition-all flex items-center gap-1.5 border shadow-2xs cursor-pointer ${d==="all"?"bg-amber-600 text-white border-amber-600 shadow-amber-500/20":"bg-white text-slate-700 border-slate-200 hover:bg-slate-50"}`,title:"Afficher la chronologie globale croisée de toute la famille",children:[f.jsx(jA,{className:"text-xs"}),f.jsx("span",{children:"Famille"})]}),f.jsxs("div",{className:"relative",children:[f.jsxs("select",{value:d,onChange:Pe=>{const nt=Pe.target.value;if(h(nt),nt!=="all"){const qe=(e||[]).find(yt=>yt.slug===nt);qe&&i&&i(qe)}else i&&i(null)},className:`pl-7 pr-7 py-1.5 rounded-xl text-xs font-bold border transition-all appearance-none cursor-pointer focus:outline-none focus:ring-2 focus:ring-amber-500 shadow-xs max-w-[150px] truncate ${d!=="all"?"bg-amber-50 border-amber-300 text-amber-900 font-black":"bg-white border-slate-200 text-slate-700 hover:bg-slate-50"}`,children:[f.jsx("option",{value:"all",children:"👤 Membre..."}),(e||[]).map(Pe=>f.jsxs("option",{value:Pe.slug,children:[Pe.prenom," ",Pe.nom," ",Pe.surnom?`(${Pe.surnom})`:""]},Pe.slug))]}),f.jsx(hm,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-400 text-[10px] pointer-events-none"})]}),f.jsxs("div",{className:"relative",children:[f.jsx("input",{type:"text",placeholder:"Rechercher...",value:p,onChange:Pe=>g(Pe.target.value),className:"pl-7 pr-6 py-1.5 rounded-xl text-xs font-medium border border-slate-200 bg-white placeholder-slate-400 text-slate-800 focus:outline-none focus:ring-2 focus:ring-amber-500 w-28 sm:w-36 shadow-xs"}),f.jsx(X0,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-400 text-[10px]"}),p&&f.jsx("button",{onClick:()=>g(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 text-xs",children:"✕"})]}),f.jsxs("button",{onClick:()=>{var Pe;_t({slug:d!=="all"?d:e&&((Pe=e[0])==null?void 0:Pe.slug)||"",date:"",title:"",description:"",photo:""}),Lt(!0)},className:"px-3 py-1.5 rounded-xl text-xs font-black transition-all flex items-center gap-1.5 bg-emerald-600 hover:bg-emerald-700 text-white shadow-xs shrink-0 cursor-pointer",title:"Ajouter un événement personnalisé avec photo",children:[f.jsx(P0,{className:"text-[10px]"}),f.jsx("span",{children:"Événement"})]})]})]}),f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1 border-t border-slate-100",children:[f.jsxs("div",{className:"flex items-center gap-1.5 overflow-x-auto no-scrollbar pb-0.5 text-xs font-bold",children:[f.jsxs("span",{className:"text-slate-400 flex items-center gap-1 mr-1 text-[10px] uppercase tracking-wider font-extrabold shrink-0",children:[f.jsx(gH,{className:"text-[9px]"})," Filtres :"]}),tt.map(Pe=>f.jsxs("div",{className:"relative inline-flex",onMouseEnter:()=>U(Pe.id),onMouseLeave:()=>{B===Pe.id&&U(null)},children:[f.jsxs("button",{onClick:()=>_(Pe.id),className:`px-2.5 py-1 rounded-xl transition-all whitespace-nowrap flex items-center gap-1.5 border shadow-2xs text-xs font-bold shrink-0 cursor-pointer ${x===Pe.id?"bg-slate-900 text-amber-300 border-slate-900 shadow-xs":"bg-white text-slate-600 border-slate-200 hover:bg-slate-100 hover:text-slate-900"}`,children:[f.jsx("span",{children:Pe.icon}),f.jsx("span",{children:Pe.label})]}),f.jsx(Da,{children:B===Pe.id&&f.jsxs(Gn.div,{initial:{opacity:0,y:6,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,scale:.96},transition:{duration:.15},className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 z-50 w-60 p-3 bg-slate-950/95 backdrop-blur-xl border border-slate-700 text-white rounded-2xl shadow-2xl text-left pointer-events-auto",children:[f.jsxs("div",{className:"flex items-center justify-between pb-1 mb-1 border-b border-slate-800",children:[f.jsxs("span",{className:"font-extrabold text-xs text-amber-300 flex items-center gap-1",children:[f.jsx("span",{children:Pe.icon})," ",Pe.title]}),f.jsx("button",{type:"button",onClick:nt=>{nt.stopPropagation(),U(null)},className:"text-slate-400 hover:text-white p-0.5 text-xs rounded hover:bg-slate-800 leading-none cursor-pointer",title:"Fermer",children:"✕"})]}),f.jsx("p",{className:"text-[11px] text-slate-300 leading-relaxed font-normal",children:Pe.desc}),f.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 -mt-1 w-2 h-2 bg-slate-950 border-r border-b border-slate-700 rotate-45"})]})})]},Pe.id)),f.jsx("div",{className:"flex items-center gap-1.5 pl-1.5 border-l border-slate-200 shrink-0",children:f.jsxs("button",{type:"button",onClick:()=>W(!K),className:`px-2.5 py-1 rounded-xl text-xs font-bold transition-all flex items-center gap-1.5 border shadow-2xs select-none cursor-pointer ${K?"bg-gradient-to-r from-amber-600 to-amber-700 text-white border-amber-600 shadow-sm ring-2 ring-amber-400/40":"bg-white hover:bg-slate-50 text-slate-700 border-slate-200"}`,title:K?"Mode photos déplié actif":"Afficher les photos et flux quotidien",children:[f.jsx("span",{children:K?"📰":"📸"}),f.jsx("span",{children:"Photos"}),ee>0&&f.jsx("span",{className:`px-1.5 py-0.2 rounded-full text-[10px] font-mono font-black ${K?"bg-slate-950 text-amber-300":"bg-amber-100 text-amber-900"}`,children:ee})]})})]}),f.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[f.jsxs("div",{className:"flex items-center bg-slate-100 p-0.5 rounded-xl border border-slate-200",children:[f.jsxs("button",{onClick:()=>$("panoramic"),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition flex items-center gap-1 cursor-pointer ${V==="panoramic"?"bg-white text-slate-900 shadow-xs border border-slate-200/80":"text-slate-600 hover:text-slate-900"}`,title:"Vue d'ensemble horizontale complète et condensée",children:[f.jsx("span",{children:"⚡"}),f.jsx("span",{className:"hidden md:inline",children:"Panoramique"})]}),f.jsxs("button",{onClick:()=>$("cards"),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition flex items-center gap-1 cursor-pointer ${V==="cards"?"bg-white text-slate-900 shadow-xs border border-slate-200/80":"text-slate-600 hover:text-slate-900"}`,title:"Grandes cartes détaillées horizontales",children:[f.jsx("span",{children:"🌟"}),f.jsx("span",{className:"hidden md:inline",children:"Détaillée"})]}),f.jsxs("button",{onClick:()=>$("vertical"),className:`px-2.5 py-1 rounded-lg text-xs font-bold transition flex items-center gap-1 cursor-pointer ${V==="vertical"?"bg-white text-amber-900 shadow-xs border border-amber-300 font-black":"text-slate-600 hover:text-slate-900"}`,title:"Ligne de vie chronologique verticale avec calcul de l'âge (style Geneanet)",children:[f.jsx("span",{children:"📜"}),f.jsx("span",{children:"Ligne de Vie"})]})]}),f.jsxs("div",{className:"flex items-center bg-slate-100 px-1 py-0.5 rounded-xl border border-slate-200",children:[f.jsx("button",{onClick:()=>H(Pe=>Math.max(.75,+(Pe-.15).toFixed(2))),className:"px-1.5 py-0.5 rounded-lg text-slate-600 hover:bg-white text-xs font-black transition cursor-pointer",title:"Dézoomer",children:"-"}),f.jsxs("span",{className:"text-[10px] font-bold text-slate-500 w-7 text-center select-none",children:[Math.round(G*100),"%"]}),f.jsx("button",{onClick:()=>H(Pe=>Math.min(1.4,+(Pe+.15).toFixed(2))),className:"px-1.5 py-0.5 rounded-lg text-slate-600 hover:bg-white text-xs font-black transition cursor-pointer",title:"Zoomer",children:"+"})]})]})]})]}),Q&&f.jsxs("div",{className:"bg-gradient-to-r from-amber-500/10 via-amber-500/5 to-transparent px-4 py-2.5 border-b border-amber-200/60 flex flex-col md:flex-row items-start md:items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f.jsx("div",{className:"w-10 h-10 rounded-xl bg-white border-2 border-amber-300 shadow-xs overflow-hidden flex items-center justify-center shrink-0",children:Q.photo?f.jsx("img",{src:Q.photo.startsWith("/")?`${nu}${Q.photo}`:Q.photo,alt:Q.prenom,className:"w-full h-full object-cover"}):f.jsx("span",{className:"font-serif font-black text-amber-800 text-sm",children:WPe(`${Q.prenom} ${Q.nom}`)})}),f.jsxs("div",{className:"min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsxs("span",{className:"font-black text-slate-900 text-sm font-serif",children:[Q.prenom," ",Q.nom]}),Q.surnom&&f.jsxs("span",{className:"text-xs text-amber-800/80 font-serif italic",children:["« ",Q.surnom," »"]}),(re==null?void 0:re.lifespanText)&&f.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-amber-100 text-amber-950 font-black border border-amber-300/80",children:re.lifespanText}),Q.profession&&f.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-slate-100 text-slate-800 font-bold border border-slate-200",children:["💼 ",Q.profession]})]}),f.jsxs("div",{className:"text-xs text-slate-600 font-medium flex items-center gap-3 flex-wrap mt-0.5",children:[Q.date_naissance&&f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsxs("span",{children:["👶 Né(e) le ",fw(Q.date_naissance)]}),Q.lieu_naissance&&f.jsxs("span",{className:"text-slate-500 font-normal",children:["à ",Q.lieu_naissance]})]}),Q.date_deces&&f.jsxs("span",{className:"flex items-center gap-1 text-slate-700",children:[f.jsxs("span",{children:["🕊️ Décédé(e) le ",fw(Q.date_deces)]}),Q.lieu_deces&&f.jsxs("span",{className:"text-slate-500 font-normal",children:["à ",Q.lieu_deces]})]}),(re==null?void 0:re.conjoint)&&f.jsxs("button",{onClick:()=>{h(re.conjoint.slug),i&&i(re.conjoint)},className:"hover:text-rose-600 font-bold text-slate-700 hover:underline inline-flex items-center gap-1 cursor-pointer",title:"Voir la ligne de vie du conjoint",children:["💍 Conjoint : ",re.conjoint.prenom," ",re.conjoint.nom]}),(re==null?void 0:re.children)&&re.children.length>0&&f.jsxs("span",{className:"inline-flex items-center gap-1 font-bold text-indigo-700",children:["🍼 ",re.children.length," enfant(s) :",re.children.slice(0,3).map(Pe=>f.jsx("button",{onClick:()=>{h(Pe.slug),i&&i(Pe)},className:"px-1.5 py-0.2 bg-indigo-50 hover:bg-indigo-100 rounded text-[11px] border border-indigo-200 cursor-pointer",title:`Voir la ligne de vie de ${Pe.prenom}`,children:Pe.prenom},Pe.slug)),re.children.length>3&&f.jsxs("span",{className:"text-slate-500 text-[10px]",children:["+",re.children.length-3]})]})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 self-end md:self-center",children:[a&&f.jsxs("button",{onClick:()=>a(Q.slug),className:"px-2.5 py-1 bg-white hover:bg-slate-50 text-slate-700 text-xs font-black rounded-lg border border-slate-200 shadow-2xs flex items-center gap-1.5 transition cursor-pointer",title:"Ouvrir la fiche complète dans l'onglet Membres",children:[f.jsx("span",{children:"👁️ Consulter"}),f.jsx(nN,{className:"text-[10px]"})]}),s&&f.jsx("button",{onClick:()=>s(Q),className:"px-2.5 py-1 bg-emerald-50 hover:bg-emerald-100 text-emerald-800 text-xs font-black rounded-lg border border-emerald-300 shadow-2xs flex items-center gap-1.5 transition cursor-pointer",title:"Modifier les informations de cette personne",children:f.jsx("span",{children:"✏️ Modifier"})}),f.jsx("button",{onClick:()=>{h("all"),i&&i(null)},className:"px-2.5 py-1 bg-amber-100 hover:bg-amber-200 text-amber-900 text-xs font-bold rounded-lg border border-amber-300 transition flex items-center gap-1 cursor-pointer",title:"Revenir à la vue d'ensemble de toute la famille",children:f.jsx("span",{children:"✕ Vue Globale"})})]})]}),me.length>0&&!c&&oe.length>0&&f.jsxs("div",{className:"bg-slate-900/95 backdrop-blur-md px-4 py-2 border-b border-slate-800 flex items-center justify-between gap-3 text-white z-20 overflow-x-auto no-scrollbar shadow-inner",children:[f.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[f.jsxs("span",{className:"text-[11px] font-black uppercase tracking-wider text-amber-400 flex items-center gap-1.5",children:[f.jsx("span",{children:"⏱️"}),f.jsx("span",{className:"hidden md:inline",children:"Époques :"})]}),f.jsxs("button",{onClick:()=>{var Pe;ze(0),ge((Pe=me[0])==null?void 0:Pe.decade)},className:"px-2.5 py-1 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white text-[11px] font-bold transition flex items-center gap-1 border border-slate-700 hover:border-amber-400/50 cursor-pointer",title:"Aller aux événements les plus anciens",children:[f.jsx("span",{children:"⏮️"}),f.jsx("span",{className:"hidden sm:inline",children:"Origines"})]})]}),f.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto no-scrollbar py-0.5",children:me.map(Pe=>{const nt=pe===Pe.decade;return f.jsxs("button",{onClick:()=>{ze(Pe.firstIndex),ge(Pe.decade)},className:`px-2.5 py-1 rounded-xl text-xs font-black transition-all shrink-0 flex items-center gap-1.5 cursor-pointer ${nt?"bg-gradient-to-r from-amber-500 to-amber-600 text-slate-950 shadow-md shadow-amber-500/30 scale-105 border border-amber-300":"bg-slate-800/90 hover:bg-slate-700 text-slate-300 hover:text-white border border-slate-700/80 hover:border-amber-400/50"}`,title:`Sauter aux années ${Pe.label} (${Pe.count} événements)`,children:[f.jsx("span",{children:Pe.label}),f.jsx("span",{className:`text-[9px] px-1.5 py-0.2 rounded-full font-mono font-bold ${nt?"bg-black/20 text-slate-950":"bg-slate-900 text-amber-400"}`,children:Pe.count})]},Pe.id)})}),f.jsx("div",{className:"flex items-center gap-2 shrink-0",children:f.jsxs("button",{onClick:()=>{var Pe;ze(oe.length-1),ge((Pe=me[me.length-1])==null?void 0:Pe.decade)},className:"px-2.5 py-1 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white text-[11px] font-bold transition flex items-center gap-1 border border-slate-700 hover:border-amber-400/50 cursor-pointer",title:"Aller aux événements les plus récents",children:[f.jsx("span",{className:"hidden sm:inline",children:"Récents"}),f.jsx("span",{children:"⏭️"})]})})]}),V==="vertical"?f.jsx("div",{className:"w-full bg-slate-50/50 py-8 px-4 sm:px-8 border-t border-slate-100",children:f.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[f.jsxs("div",{className:"bg-gradient-to-r from-amber-500/10 via-amber-500/5 to-transparent p-4 rounded-2xl border border-amber-200/80 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-xl bg-slate-900 text-amber-300 flex items-center justify-center text-lg font-black shadow-sm",children:"📜"}),f.jsxs("div",{children:[f.jsx("h3",{className:"font-serif font-black text-slate-900 text-base",children:Q?`Ligne de vie de ${Q.prenom} ${Q.nom}`:"Ligne de vie chronologique de la famille"}),f.jsxs("p",{className:"text-xs text-slate-600 font-medium",children:[oe.length," événements répertoriés • Défilement chronologique avec calcul de l'âge"]})]})]}),Q&&f.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-black bg-amber-100 text-amber-900 border border-amber-300 shadow-2xs",children:(re==null?void 0:re.lifespanText)||`Né(e) en ${Q.date_naissance||"?"}`})]}),c?f.jsxs("div",{className:"py-16 flex flex-col items-center justify-center gap-3",children:[f.jsx("div",{className:"w-12 h-12 border-4 border-amber-200 border-t-amber-600 rounded-full animate-spin"}),f.jsx("p",{className:"text-xs font-bold text-slate-500",children:"Chargement de la chronologie..."})]}):oe.length===0?f.jsxs("div",{className:"py-16 flex flex-col items-center justify-center text-center p-8 bg-white rounded-3xl border border-slate-200",children:[f.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 flex items-center justify-center text-3xl mb-3",children:"🍃"}),f.jsx("h3",{className:"text-lg font-bold text-slate-800 mb-1",children:"Aucun événement trouvé"}),f.jsx("p",{className:"text-xs text-slate-500 max-w-md",children:"Modifiez vos critères de recherche ou réinitialisez les filtres."})]}):f.jsx("div",{className:"relative pl-2 sm:pl-4 before:absolute before:left-[92px] sm:before:left-[116px] before:top-4 before:bottom-4 before:w-0.5 before:bg-gradient-to-b before:from-amber-400 before:via-slate-300 before:to-amber-400",children:oe.map((Pe,nt)=>{const qe=vme(Pe.date),yt=(Q==null?void 0:Q.date_naissance)||(Pe.slug===d?Q==null?void 0:Q.date_naissance:null),Qt=XPe(Pe.date,yt),Be=rT(Pe.type,Pe.title);return f.jsxs("div",{className:"relative flex items-start gap-3 sm:gap-5 mb-6 group",children:[f.jsxs("div",{className:"w-18 sm:w-24 shrink-0 text-right pt-1.5",children:[f.jsx("div",{className:"font-serif font-black text-slate-900 text-base sm:text-lg leading-tight",children:qe.year||"—"}),qe.dayMonth&&f.jsx("div",{className:"text-[11px] sm:text-xs font-bold text-slate-500",children:qe.dayMonth}),Qt&&f.jsx("div",{className:"mt-1",children:f.jsx("span",{className:`inline-block px-2 py-0.5 rounded-full text-[10px] font-black shadow-2xs ${Qt==="Naissance"?"bg-emerald-100 text-emerald-900 border border-emerald-300":"bg-amber-100 text-amber-900 border border-amber-300"}`,children:Qt})})]}),f.jsx("div",{className:"relative z-10 shrink-0 mt-1",children:f.jsx("div",{className:"w-8 h-8 rounded-full bg-white border-2 border-amber-400 text-slate-800 flex items-center justify-center shadow-md group-hover:scale-110 group-hover:bg-amber-500 group-hover:border-white group-hover:text-slate-950 transition-all cursor-pointer",onClick:()=>O(Pe),title:"Cliquer pour voir les détails de l'événement",children:e9(Pe.title,Pe.icon,Pe.type)})}),f.jsxs("div",{className:"flex-1 bg-white p-4 sm:p-5 rounded-2xl border border-slate-200/90 hover:border-amber-400 shadow-xs hover:shadow-md transition",children:[f.jsxs("div",{className:"flex items-start justify-between gap-2 flex-wrap mb-1.5",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-extrabold uppercase tracking-wide border ${Be.bg}`,children:Be.label}),f.jsx("h4",{className:"text-base font-black text-slate-900 font-serif",children:Ft(Pe.title)})]}),Pe.slug&&Pe.slug!=="journal"&&f.jsx("button",{onClick:()=>dt(Pe.slug),className:"text-xs font-bold text-slate-600 hover:text-amber-800 hover:underline flex items-center gap-1 cursor-pointer bg-slate-50 hover:bg-amber-50 px-2 py-1 rounded-lg border border-slate-200 transition",title:`Voir la ligne de vie de ${Pe.person}`,children:f.jsxs("span",{children:["👤 ",Pe.person]})})]}),Pe.description&&f.jsx("p",{className:"text-sm text-slate-700 leading-relaxed font-sans mb-2",children:Ft(Pe.description)}),Pe.event_photo&&f.jsx("div",{className:"mt-2 mb-2 max-w-sm rounded-xl overflow-hidden border border-slate-200 shadow-xs",children:f.jsx("img",{src:Pe.event_photo.startsWith("/")?`${nu}${Pe.event_photo}`:Pe.event_photo,alt:Pe.title,className:"w-full h-40 object-cover cursor-pointer hover:scale-105 transition duration-300",onClick:()=>O(Pe)})}),(Pe.source||Pe.sources)&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-slate-100 flex items-center gap-2 text-xs text-slate-500 font-medium flex-wrap",children:[f.jsx("span",{className:"font-bold text-slate-700",children:"Source :"}),String(Pe.source||Pe.sources).startsWith("http")?f.jsxs("a",{href:Pe.source||Pe.sources,target:"_blank",rel:"noopener noreferrer",className:"text-amber-800 hover:underline inline-flex items-center gap-1 font-bold",children:[f.jsx("span",{children:Pe.source||Pe.sources}),f.jsx(nN,{className:"text-[10px]"})]}):f.jsx("span",{children:Pe.source||Pe.sources})]})]})]},`${Pe.slug}-${Pe.date}-${Pe.title}-${nt}`)})})]})}):f.jsxs("div",{className:"min-h-[500px] h-[64vh] max-h-[640px] w-full relative overflow-hidden group/timeline flex flex-col justify-center",children:[oe.length>0&&!c&&f.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-30 pointer-events-none",children:f.jsxs("div",{className:"px-3.5 py-1 rounded-full bg-slate-950/90 backdrop-blur-md text-amber-300 text-xs font-black border border-amber-400/40 shadow-2xl flex items-center gap-2",children:[f.jsx("span",{className:"animate-pulse",children:"⏳"}),f.jsx("span",{children:Ae?`Période : ${Ae} • Années ${Math.floor(Ae/10)*10}s`:"Voyage Temporel"})]})}),f.jsx("button",{onClick:()=>Ut("left"),"aria-label":"Défiler vers le passé",className:"absolute left-3 top-1/2 -translate-y-1/2 z-40 bg-white/95 p-3.5 rounded-full shadow-xl hover:bg-amber-50 text-amber-800 border border-amber-200/90 transition-all hover:scale-110 flex items-center justify-center cursor-pointer",children:f.jsx(C7,{size:16})}),f.jsx("button",{onClick:()=>Ut("right"),"aria-label":"Défiler vers le futur",className:"absolute right-3 top-1/2 -translate-y-1/2 z-40 bg-white/95 p-3.5 rounded-full shadow-xl hover:bg-amber-50 text-amber-800 border border-amber-200/90 transition-all hover:scale-110 flex items-center justify-center cursor-pointer",children:f.jsx(SK,{size:16})}),f.jsx("div",{className:"absolute left-16 top-4 z-20 pointer-events-none",children:f.jsx("span",{className:"text-[10px] uppercase tracking-widest font-black text-slate-400 bg-white/80 px-2.5 py-1 rounded-md border border-slate-200",children:"👈 Passé"})}),f.jsx("div",{className:"absolute right-16 top-4 z-20 pointer-events-none",children:f.jsx("span",{className:"text-[10px] uppercase tracking-widest font-black text-slate-400 bg-white/80 px-2.5 py-1 rounded-md border border-slate-200",children:"Futur 👉"})}),c?f.jsxs("div",{className:"flex-1 flex flex-col justify-center items-center gap-3",children:[f.jsx("div",{className:"w-12 h-12 border-4 border-amber-200 border-t-amber-600 rounded-full animate-spin"}),f.jsx("p",{className:"text-xs font-bold text-slate-500",children:"Chargement de la chronologie..."})]}):oe.length===0?f.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[f.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 flex items-center justify-center text-3xl mb-3",children:"🍃"}),f.jsx("h3",{className:"text-xl font-bold text-slate-800 mb-1",children:"Aucun événement trouvé"}),f.jsx("p",{className:"text-sm text-slate-500 max-w-md mb-4",children:p||x!=="all"?"Aucun résultat pour les critères de filtres actuels. Essayez de réinitialiser la recherche.":"Ajoutez des dates de naissance, d'union ou des anecdotes dans les fiches ou le journal."}),(p||x!=="all"||d!=="all")&&f.jsx("button",{onClick:()=>{g(""),_("all"),h("all")},className:"px-4 py-2 bg-slate-900 text-white text-xs font-bold rounded-xl hover:bg-slate-800 transition",children:"Réinitialiser les filtres"})]}):f.jsx("div",{ref:J,onScroll:Te,onMouseDown:lt,onMouseLeave:ft,onMouseUp:ft,onMouseMove:et,className:"flex-1 overflow-x-auto overflow-y-hidden pb-8 pt-12 px-12 cursor-grab active:cursor-grabbing custom-scrollbar select-none flex items-center",children:f.jsxs("div",{className:"relative min-w-max h-full flex items-center",children:[f.jsx("div",{className:"absolute left-0 right-0 h-1 bg-gradient-to-r from-slate-200 via-amber-300 to-slate-200 rounded-full top-1/2 -translate-y-1/2"}),f.jsx(Da,{children:oe.map((Pe,nt)=>{var Ot,nn;const qe=ie(Pe),yt=!K&&qe,Qt=nt%2===0,Be=$Pe(Pe.title),pt=rT(Pe.type,Pe.title),rt=V==="panoramic",zt=Math.round(rt?270*G:360*G),Yt=Nt=>{if(!Nt||Nt==="À préciser")return null;const m=String(Nt).match(/\d{4}/);return m?parseInt(m[0],10):null},Bt=Yt(Pe.date),$e=nt>0?Yt((Ot=oe[nt-1])==null?void 0:Ot.date):null,ut=Bt?Math.floor(Bt/10)*10:null,Gt=$e?Math.floor($e/10)*10:null,it=ut&&(!Gt||ut!==Gt);return f.jsxs(ln.Fragment,{children:[it&&f.jsxs("div",{className:"relative shrink-0 flex flex-col items-center justify-center px-4 z-15 select-none pointer-events-none",children:[f.jsxs("div",{className:"px-3 py-1.5 rounded-2xl bg-gradient-to-r from-amber-500 to-amber-700 text-slate-950 font-black text-xs shadow-lg border border-amber-300 flex items-center gap-1.5 whitespace-nowrap",children:[f.jsx("span",{children:"🏛️"}),f.jsxs("span",{children:["Années ",ut,"s"]})]}),f.jsx("div",{className:"w-0.5 h-14 bg-gradient-to-b from-amber-400 to-transparent mt-1"})]}),yt?f.jsxs(Gn.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.6},transition:{duration:.2,delay:Math.min(nt*.015,.3)},className:"relative shrink-0 flex flex-col items-center justify-center px-1 z-20 group/minidot cursor-pointer select-none",style:{width:`${Math.round(52*G)}px`,height:"max(56vh, 400px)"},onClick:()=>O(Pe),title:`${Pe.title||"Photo / Souvenir"} (${Pe.date||"Date"}) - Cliquez pour ouvrir`,children:[f.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 w-4 h-4 rounded-full bg-slate-900 border-2 border-amber-400 shadow-md group-hover/minidot:scale-135 group-hover/minidot:bg-amber-500 group-hover/minidot:border-white transition-all z-20 flex items-center justify-center",children:f.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-300"})}),f.jsx("div",{className:`absolute left-1/2 -translate-x-1/2 w-px border-l-2 border-dotted border-amber-400/80 ${Qt?"bottom-1/2 h-10 group-hover/minidot:h-12":"top-1/2 h-10 group-hover/minidot:h-12"} transition-all`}),f.jsxs("div",{className:`absolute left-1/2 -translate-x-1/2 ${Qt?"bottom-[calc(50%+11px)]":"top-[calc(50%+11px)]"} flex flex-col items-center group-hover/minidot:scale-110 transition-transform`,children:[f.jsxs("div",{className:"px-1.5 py-0.5 rounded-lg bg-slate-900/90 hover:bg-slate-950 text-amber-300 border border-slate-700/90 shadow-md flex items-center gap-1 text-[9px] font-black whitespace-nowrap backdrop-blur-md",children:[f.jsx("span",{className:"text-[10px]",children:Pe.type==="famileo"||Pe.source&&Pe.source.toLowerCase().includes("famileo")?"📰":"📸"}),f.jsx("span",{className:"font-mono text-[8px] text-slate-200",children:Pe.date?((nn=String(Pe.date).match(/\d{4}/))==null?void 0:nn[0])||Pe.date:"Photo"})]}),!!(Pe.event_photo&&Pe.event_photo.startsWith("/uploads/"))&&f.jsx("div",{className:"w-4 h-4 rounded-full overflow-hidden border border-amber-400 shadow-xs mt-0.5 bg-slate-950",children:f.jsx("img",{src:Pe.event_photo.startsWith("/")?`${nu}${Pe.event_photo}`:Pe.event_photo,alt:"mini preview",className:"w-full h-full object-cover"})})]}),f.jsxs("div",{className:`absolute left-1/2 -translate-x-1/2 ${Qt?"bottom-[calc(50%+55px)]":"top-[calc(50%+55px)]"} hidden group-hover/minidot:flex flex-col w-56 p-3 bg-slate-950 text-white rounded-2xl shadow-2xl border border-slate-700 pointer-events-none z-50 text-left backdrop-blur-xl animate-in fade-in zoom-in-95 duration-150`,children:[!!(Pe.event_photo&&Pe.event_photo.startsWith("/uploads/"))&&f.jsx("img",{src:Pe.event_photo.startsWith("/")?`${nu}${Pe.event_photo}`:Pe.event_photo,alt:"preview",className:"w-full h-28 object-cover rounded-xl mb-2 border border-slate-800"}),f.jsxs("div",{className:"flex items-center justify-between text-[9px] text-amber-300 font-bold mb-1",children:[f.jsxs("span",{children:["📅 ",fw(Pe.date)]}),f.jsx("span",{className:"px-1.5 py-0.2 rounded-full bg-slate-800 text-slate-300 font-normal",children:Pe.source||"Famileo / Réseau"})]}),f.jsx("p",{className:"text-[11px] font-black text-slate-100 line-clamp-2 leading-tight",children:Pe.title}),Pe.description&&f.jsx("p",{className:"text-[10px] text-slate-400 line-clamp-2 mt-1 leading-snug",children:Pe.description}),f.jsxs("div",{className:"mt-2 pt-1 border-t border-slate-800/80 flex items-center justify-between text-[9px] text-amber-400 font-bold",children:[f.jsx("span",{children:"🔍 Cliquer pour agrandir"}),f.jsx("span",{children:"✨ Souvenir"})]})]})]}):f.jsxs(Gn.div,{initial:{opacity:0,y:Qt?-20:20},animate:{opacity:1,y:0},exit:{opacity:0,scale:.8},transition:{duration:.3,delay:Math.min(nt*.02,.4)},className:`relative flex flex-col shrink-0 px-2.5 sm:px-3 group ${Qt?"justify-end pb-10 sm:pb-14":"justify-start pt-10 sm:pt-14"}`,style:{width:`${zt}px`,height:"max(56vh, 400px)"},children:[f.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 top-1/2 -translate-y-1/2 w-4 h-4 rounded-full bg-amber-600 border-3 border-white shadow-md z-10 group-hover:scale-125 group-hover:bg-amber-500 transition-all"}),f.jsx("div",{className:`absolute left-1/2 -translate-x-1/2 w-0.5 bg-amber-200/80 ${Qt?"bottom-1/2 h-10 sm:h-14 group-hover:bg-amber-400 transition-colors":"top-1/2 h-10 sm:h-14 group-hover:bg-amber-400 transition-colors"}`}),f.jsxs("div",{onClick:()=>O(Pe),className:`relative bg-white rounded-2xl shadow-md border border-slate-100 hover:shadow-2xl hover:border-amber-300 transition-all z-20 cursor-pointer ${rt?"p-3.5":"p-5"}`,children:[f.jsx("div",{className:`absolute left-1/2 -translate-x-1/2 rounded-full border-3 border-white bg-slate-900 shadow-md flex items-center justify-center ${rt?"w-8 h-8 -top-4 text-xs":Qt?"w-11 h-11 -bottom-5":"w-11 h-11 -top-5"}`,children:e9(Pe.title,Pe.icon,Pe.type)}),y===nt?f.jsxs("div",{className:"space-y-2.5 relative z-30",onClick:Nt=>Nt.stopPropagation(),children:[f.jsx("input",{type:"text",value:C.date,onChange:Nt=>k({...C,date:Nt.target.value}),className:"w-full p-2 border rounded-lg font-bold text-slate-700 text-xs",placeholder:"Date (ex: 1985 ou 15/06/1985)"}),f.jsx("input",{type:"text",value:C.title,onChange:Nt=>k({...C,title:Nt.target.value}),className:"w-full p-2 border rounded-lg font-bold text-xs",placeholder:"Titre de l'événement"}),f.jsx("textarea",{value:C.description,onChange:Nt=>k({...C,description:Nt.target.value}),className:"w-full p-2 border rounded-lg text-slate-600 text-xs",placeholder:"Description...",rows:2}),f.jsxs("div",{className:"p-2 bg-slate-50 border border-slate-200 rounded-xl space-y-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("span",{className:"text-[10px] font-bold text-slate-600 flex items-center gap-1",children:[f.jsx(fm,{className:"text-amber-600"})," Photo de l'événement :"]}),f.jsxs("label",{className:"cursor-pointer px-2 py-0.5 bg-amber-100 hover:bg-amber-200 text-amber-900 rounded-lg text-[10px] font-bold transition flex items-center gap-1",children:[st?f.jsx(vu,{className:"animate-spin"}):f.jsx(gM,{size:9}),f.jsx("span",{children:st?"Envoi...":"Choisir photo"}),f.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:st,onChange:Nt=>{var m;return((m=Nt.target.files)==null?void 0:m[0])&&It(Nt.target.files[0],!1)}})]})]}),f.jsx("input",{type:"text",value:C.photo||"",onChange:Nt=>k({...C,photo:Nt.target.value,event_photo:Nt.target.value}),className:"w-full p-1.5 border rounded-lg text-[11px] font-mono text-slate-700 bg-white",placeholder:"URL ou /uploads/events/..."}),C.photo&&f.jsxs("div",{className:"relative w-16 h-12 rounded-lg overflow-hidden border border-amber-300",children:[f.jsx("img",{src:C.photo.startsWith("/")?`${nu}${C.photo}`:C.photo,alt:"preview",className:"w-full h-full object-cover"}),f.jsx("button",{type:"button",onClick:()=>k(Nt=>({...Nt,photo:"",event_photo:""})),className:"absolute top-0 right-0 bg-black/70 text-white text-[9px] w-4 h-4 flex items-center justify-center rounded-bl",children:"✕"})]})]}),f.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[f.jsxs("button",{onClick:ue,className:"px-2.5 py-1 text-slate-500 hover:bg-slate-100 rounded-lg text-xs font-bold flex items-center gap-1",children:[f.jsx($a,{})," Annuler"]}),f.jsxs("button",{onClick:()=>Ve(nt),className:"px-3 py-1 text-white bg-emerald-600 hover:bg-emerald-700 rounded-lg text-xs font-bold flex items-center gap-1 shadow-xs",children:[f.jsx(yM,{})," Enregistrer"]})]})]}):f.jsxs("div",{className:`relative z-30 ${rt?"mt-1":"mt-2"}`,children:[f.jsxs("div",{className:"flex items-center justify-between gap-1 mb-1.5 flex-wrap",children:[Pe.date&&Pe.date!=="À préciser"?f.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-amber-100/90 text-amber-900 border border-amber-200/60 rounded-full text-[10px] font-black",children:[f.jsx(B_,{className:"text-[9px] text-amber-700"}),fw(Pe.date)]}):f.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-slate-100 text-slate-600 border border-slate-200 rounded-full text-[9px] font-bold",children:[f.jsx("span",{children:"📅"})," Date à préciser"]}),f.jsx("span",{className:`px-1.5 py-0.2 rounded-full text-[9px] font-black border ${pt.bg}`,children:pt.label})]}),Pe.person&&f.jsxs("button",{onClick:Nt=>{Nt.stopPropagation(),mt(Pe)},className:"inline-flex items-center gap-1 px-2 py-0.5 mb-1.5 bg-slate-50 hover:bg-amber-50 text-slate-700 hover:text-amber-900 rounded-lg border border-slate-200/80 transition text-[11px] font-bold max-w-full truncate group/btn",title:"Filtrer sur cette personne",children:[Pe.photo?f.jsx("img",{src:Pe.photo.startsWith("/")?`${nu}${Pe.photo}`:Pe.photo,alt:Pe.person,className:"w-3.5 h-3.5 rounded-full object-cover shrink-0"}):f.jsx("span",{className:"w-3.5 h-3.5 rounded-full bg-slate-200 text-slate-700 text-[8px] font-bold flex items-center justify-center shrink-0",children:"👤"}),f.jsx("span",{className:"truncate",children:Pe.person})]}),f.jsx("h3",{className:`font-black text-slate-900 leading-snug mb-1 ${rt?"text-xs line-clamp-2":"text-sm sm:text-base"}`,children:Ft(Pe.title)}),!!(Pe.event_photo&&Pe.event_photo.startsWith("/uploads/"))&&f.jsxs("div",{className:"my-2 rounded-xl overflow-hidden border border-slate-200 bg-slate-900 shadow-xs relative group/img",children:[f.jsx("img",{src:Pe.event_photo.startsWith("/")?`${nu}${Pe.event_photo}`:Pe.event_photo,alt:Pe.title,className:`w-full object-cover transition-transform duration-300 group-hover/img:scale-105 ${rt?"h-24":"h-36"}`,loading:"lazy"}),Array.isArray(Pe.photos)&&Pe.photos.length>1&&f.jsxs("span",{className:"absolute bottom-1.5 right-1.5 px-2 py-0.5 rounded-md bg-black/75 backdrop-blur-md text-amber-300 text-[10px] font-bold",children:["📸 +",Pe.photos.length," photos"]})]}),Pe.description&&f.jsx("div",{className:`text-[11px] leading-relaxed text-slate-600 overflow-hidden ${rt?"line-clamp-2 mb-1.5":"mb-3"}`,children:Pe.description.split(` `).map((Nt,m)=>{const Ie=Nt.match(/!\[(.*?)\]\((.*?)\)/);if(Ie){if(rt)return null;const An=Ie[2].startsWith("/")?`${nu}${Ie[2]}`:Ie[2];return f.jsx("img",{src:An,alt:Ie[1],className:"max-h-32 rounded-lg shadow-xs my-1.5 object-cover w-full"},m)}return f.jsx("p",{className:"mb-0.5",children:Ft(Nt)},m)})}),Be&&f.jsxs(Gn.button,{whileHover:{scale:1.02},whileTap:{scale:.98},onClick:Nt=>{Nt.stopPropagation(),vt(Be)},className:"mt-1.5 w-full py-1 px-2 bg-indigo-50 text-indigo-700 rounded-lg text-[10px] font-bold flex items-center justify-center gap-1 border border-indigo-100 hover:bg-indigo-100 transition shadow-2xs",children:[f.jsxs("span",{children:["Branche (",Be,")"]}),f.jsx(SK,{size:9})]}),f.jsxs("div",{className:"flex items-center justify-between gap-1.5 mt-2 pt-1.5 border-t border-slate-100",children:[f.jsx("span",{className:"text-[10px] text-amber-700/80 font-bold hover:underline",children:"🔍 Voir détails"}),f.jsxs("div",{className:"flex items-center gap-1 opacity-60 group-hover:opacity-100 transition-opacity",onClick:Nt=>Nt.stopPropagation(),children:[f.jsx("button",{onClick:()=>De(nt,Pe),className:"text-slate-400 hover:text-blue-600 transition-colors p-1",title:"Modifier",children:f.jsx(Pg,{size:11})}),f.jsx("button",{onClick:()=>ct(nt),className:"text-slate-400 hover:text-red-500 transition-colors p-1",title:"Masquer",children:f.jsx(z0,{size:11})})]})]})]})]}),Be&&f.jsx("div",{className:"absolute right-0 top-1/2 w-8 h-px bg-indigo-300 border-t-2 border-dashed border-indigo-400 z-0 opacity-50"})]})]},`${Pe.slug}-${Pe.date}-${Pe.title}-${nt}`)})}),f.jsx("div",{className:"w-24 shrink-0 flex items-center justify-center opacity-40",children:f.jsx("div",{className:"w-3 h-3 rounded-full bg-slate-400"})})]})})]}),f.jsxs(Da,{children:[z&&f.jsx("div",{className:"fixed inset-0 z-50 bg-slate-950/60 backdrop-blur-md flex items-center justify-center p-4",onClick:()=>O(null),children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},onClick:Pe=>Pe.stopPropagation(),className:"bg-white rounded-3xl shadow-2xl border border-slate-200 w-full max-w-lg overflow-hidden flex flex-col max-h-[85vh]",children:[f.jsxs("div",{className:"bg-gradient-to-r from-amber-500/20 via-amber-500/10 to-transparent p-5 border-b border-amber-200/70 flex items-start justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-2xl bg-slate-900 text-white flex items-center justify-center shadow-md shrink-0",children:e9(z.title,z.icon,z.type)}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-amber-900/80 bg-amber-100/90 px-2 py-0.5 rounded-full border border-amber-300/80",children:rT(z.type,z.title).label}),f.jsx("h3",{className:"text-base font-black text-slate-900 mt-1 font-serif",children:Ft(z.title)})]})]}),f.jsx("button",{onClick:()=>O(null),className:"w-8 h-8 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-600 flex items-center justify-center transition",title:"Fermer",children:"✕"})]}),f.jsxs("div",{className:"p-6 overflow-y-auto space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 p-3 rounded-2xl bg-slate-50 border border-slate-200/80",children:[f.jsxs("span",{className:"text-xs font-bold text-slate-500 flex items-center gap-1.5",children:[f.jsx(B_,{className:"text-amber-600"}),f.jsx("span",{children:"Date :"}),f.jsx("strong",{className:"text-slate-900 font-extrabold",children:fw(z.date)})]}),z.slug&&f.jsxs("button",{onClick:()=>{const Pe=z.slug;O(null),dt(Pe)},className:"px-3 py-1 bg-white hover:bg-amber-50 text-slate-700 hover:text-amber-900 rounded-xl border border-slate-200 text-xs font-black transition flex items-center gap-1.5 shadow-2xs",children:[f.jsx("span",{children:"👁️ Voir la fiche"}),f.jsx(nN,{className:"text-[9px]"})]})]}),z.person&&f.jsxs("div",{onClick:()=>{const Pe=z.slug||z.person;O(null),dt(Pe)},className:"flex items-center gap-3 p-3 rounded-2xl bg-amber-50 hover:bg-amber-100/80 border border-amber-200 transition cursor-pointer group/modalpers",title:`Cliquer pour ouvrir la fiche de ${z.person}`,children:[z.photo?f.jsx("img",{src:z.photo.startsWith("/")?`${nu}${z.photo}`:z.photo,alt:z.person,className:"w-10 h-10 rounded-full object-cover border border-amber-300 shadow-2xs group-hover/modalpers:scale-105 transition-transform"}):f.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-200 text-amber-900 font-bold flex items-center justify-center text-sm",children:"👤"}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("p",{className:"text-[11px] text-slate-500 font-bold flex items-center gap-1",children:[f.jsx("span",{children:"Personne concernée"}),f.jsx("span",{className:"text-amber-700 text-[10px] font-black group-hover/modalpers:underline",children:"↗ Ouvrir fiche"})]}),f.jsx("p",{className:"text-sm font-black text-slate-900 truncate font-serif",children:z.person})]})]}),!!(z.event_photo&&z.event_photo.startsWith("/uploads/"))&&f.jsx("div",{className:"rounded-2xl overflow-hidden border border-slate-200 bg-slate-950 shadow-sm",children:f.jsx("img",{src:z.event_photo.startsWith("/")?`${nu}${z.event_photo}`:z.event_photo,alt:z.title,className:"w-full max-h-80 object-contain mx-auto"})}),z.description&&f.jsx("div",{className:"space-y-2 text-sm text-slate-700 leading-relaxed bg-slate-50/40 p-4 rounded-2xl border border-slate-100",children:z.description.split(` `).map((Pe,nt)=>{const qe=Pe.match(/!\[(.*?)\]\((.*?)\)/);if(qe){const yt=qe[2].startsWith("/")?`${nu}${qe[2]}`:qe[2];return f.jsxs("div",{className:"my-3",children:[f.jsx("img",{src:yt,alt:qe[1],className:"max-h-64 rounded-2xl shadow-md object-cover w-full border border-slate-200"}),qe[1]&&f.jsx("p",{className:"text-center text-xs text-slate-500 italic mt-1",children:qe[1]})]},nt)}return f.jsx("p",{children:Ft(Pe)},nt)})})]}),f.jsxs("div",{className:"p-4 bg-slate-50 border-t border-slate-200 flex items-center justify-between gap-2",children:[f.jsx("button",{onClick:()=>{const Pe=z.slug;if(O(null),Pe){h(Pe);const nt=(e||[]).find(qe=>qe.slug===Pe);nt&&i&&i(nt)}},className:"px-4 py-2 bg-amber-600 hover:bg-amber-500 text-white text-xs font-black rounded-xl transition shadow-sm",children:"⚡ Centrer la frise sur cette personne"}),f.jsx("button",{onClick:()=>O(null),className:"px-4 py-2 bg-slate-200 hover:bg-slate-300 text-slate-800 text-xs font-bold rounded-xl transition",children:"Fermer"})]})]})}),At&&f.jsx("div",{className:"fixed inset-0 z-50 bg-slate-950/60 backdrop-blur-md flex items-center justify-center p-4",onClick:()=>Lt(!1),children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},onClick:Pe=>Pe.stopPropagation(),className:"bg-white rounded-3xl shadow-2xl border border-slate-200 w-full max-w-lg overflow-hidden flex flex-col",children:[f.jsxs("div",{className:"bg-gradient-to-r from-emerald-600 to-teal-700 text-white p-5 flex items-center justify-between",children:[f.jsxs("h3",{className:"text-base font-black flex items-center gap-2",children:[f.jsx(P0,{})," Ajouter un événement à la chronologie"]}),f.jsx("button",{onClick:()=>Lt(!1),className:"w-8 h-8 rounded-full bg-white/20 hover:bg-white/30 text-white flex items-center justify-center transition",children:"✕"})]}),f.jsxs("form",{onSubmit:We,className:"p-6 space-y-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-black text-slate-700 mb-1",children:"Personne concernée *"}),f.jsxs("select",{value:Se.slug,onChange:Pe=>_t({...Se,slug:Pe.target.value}),className:"w-full p-2.5 border border-slate-300 rounded-xl text-xs font-bold bg-white text-slate-800 focus:ring-2 focus:ring-emerald-500",required:!0,children:[f.jsx("option",{value:"",children:"-- Sélectionner un membre --"}),(e||[]).map(Pe=>f.jsxs("option",{value:Pe.slug,children:[Pe.prenom," ",Pe.nom]},Pe.slug))]})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-black text-slate-700 mb-1",children:"Date"}),f.jsx("input",{type:"text",value:Se.date,onChange:Pe=>_t({...Se,date:Pe.target.value}),placeholder:"ex: 1990 ou 14/07/1990",className:"w-full p-2 border border-slate-300 rounded-xl text-xs"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-black text-slate-700 mb-1",children:"Titre de l'événement *"}),f.jsx("input",{type:"text",value:Se.title,onChange:Pe=>_t({...Se,title:Pe.target.value}),placeholder:"ex: Diplôme, Mariage, Voyage...",className:"w-full p-2 border border-slate-300 rounded-xl text-xs font-bold",required:!0})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-black text-slate-700 mb-1",children:"Description / Récit"}),f.jsx("textarea",{value:Se.description,onChange:Pe=>_t({...Se,description:Pe.target.value}),placeholder:"Détails du souvenir, anecdotes...",rows:3,className:"w-full p-2.5 border border-slate-300 rounded-xl text-xs text-slate-700"})]}),f.jsxs("div",{className:"p-3 bg-slate-50 border border-slate-200 rounded-2xl space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("span",{className:"text-xs font-bold text-slate-700 flex items-center gap-1.5",children:[f.jsx(fm,{className:"text-emerald-600"})," Photo d'illustration (optionnelle)"]}),f.jsxs("label",{className:"cursor-pointer px-3 py-1 bg-emerald-50 hover:bg-emerald-100 text-emerald-800 rounded-xl text-xs font-bold transition flex items-center gap-1.5 border border-emerald-200",children:[st?f.jsx(vu,{className:"animate-spin"}):f.jsx(gM,{size:10}),f.jsx("span",{children:st?"Upload...":"Importer photo"}),f.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:st,onChange:Pe=>{var nt;return((nt=Pe.target.files)==null?void 0:nt[0])&&It(Pe.target.files[0],!0)}})]})]}),f.jsx("input",{type:"text",value:Se.photo,onChange:Pe=>_t({...Se,photo:Pe.target.value}),placeholder:"URL ou /uploads/events/...",className:"w-full p-2 border border-slate-200 rounded-xl text-xs font-mono bg-white"}),Se.photo&&f.jsxs("div",{className:"relative w-24 h-16 rounded-xl overflow-hidden border border-emerald-300",children:[f.jsx("img",{src:Se.photo.startsWith("/")?`${nu}${Se.photo}`:Se.photo,alt:"preview",className:"w-full h-full object-cover"}),f.jsx("button",{type:"button",onClick:()=>_t(Pe=>({...Pe,photo:""})),className:"absolute top-0.5 right-0.5 bg-black/75 text-white text-[10px] w-5 h-5 flex items-center justify-center rounded-full",children:"✕"})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-100",children:[f.jsx("button",{type:"button",onClick:()=>Lt(!1),className:"px-4 py-2 text-slate-600 hover:bg-slate-100 rounded-xl text-xs font-bold transition",children:"Annuler"}),f.jsxs("button",{type:"submit",className:"px-5 py-2 bg-emerald-600 hover:bg-emerald-700 text-white rounded-xl text-xs font-black shadow-md shadow-emerald-600/20 transition flex items-center gap-1.5",children:[f.jsx(yM,{})," Enregistrer l'événement"]})]})]})]})})]}),f.jsx("style",{dangerouslySetInnerHTML:{__html:` .custom-scrollbar::-webkit-scrollbar { height: 7px; } .custom-scrollbar::-webkit-scrollbar-track { background: #f8fafc; border-radius: 4px; } .custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; } .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #94a3b8; } `}})]})}function wH({engine:n,setEngine:e}){const t=()=>{const r=n==="vertex"?"azure":"vertex";e(r),localStorage.setItem("preferred_ai_engine",r)};return f.jsxs("div",{className:"flex items-center space-x-2 bg-slate-100 p-1 rounded-full cursor-pointer shadow-inner w-fit",onClick:t,children:[f.jsx(Gn.div,{className:`px-3 py-1 text-sm font-medium rounded-full z-10 transition-colors ${n==="vertex"?"text-white":"text-slate-500"}`,children:"Gemini (Vertex)"}),f.jsx(Gn.div,{className:`px-3 py-1 text-sm font-medium rounded-full z-10 transition-colors ${n==="azure"?"text-white":"text-slate-500"}`,children:"ChatGPT (Azure)"}),f.jsx(Gn.div,{className:"absolute h-7 rounded-full bg-brand-500 shadow",layout:!0,transition:{type:"spring",stiffness:500,damping:30},style:{width:n==="vertex"?"120px":"130px",x:n==="vertex"?0:120}})]})}const jK="https://famille.ravin-cloud.fr",YPe=()=>{const[n,e]=de.useState(0),t=["Je réfléchis...","Consultation des archives...","Structuration de la réponse..."];return de.useEffect(()=>{const r=setInterval(()=>{e(i=>(i+1)%t.length)},2e3);return()=>clearInterval(r)},[]),f.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[f.jsx(Gn.div,{className:"w-4 h-4 rounded-full bg-emerald-400",animate:{scale:[1,1.5,1],opacity:[.5,1,.5]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},style:{boxShadow:"0 0 15px 5px rgba(52, 211, 153, 0.5)"}}),f.jsx(Gn.span,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},exit:{opacity:0,y:-5},className:"text-xs text-emerald-600 font-medium tracking-widest uppercase",children:t[n]},n)]})},aT=({role:n,engine:e})=>{const t=e==="azure",r=n==="user"?"bg-slate-700":t?"bg-emerald-600":"bg-blue-600";return f.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-white ${r} shadow-md`,children:n==="user"?f.jsx(hm,{size:14}):t?f.jsx("span",{className:"font-bold text-sm",children:"A"}):f.jsx("span",{className:"font-bold text-sm",children:"G"})})};function ZPe({person:n,onAdded:e,onItemSaved:t,onClose:r}){const[i,s]=de.useState(!1),[a,o]=de.useState(!1),[l,c]=de.useState([]),[u,d]=de.useState(""),[h,p]=de.useState(()=>localStorage.getItem("preferred_ai_engine")||"azure");de.useRef(null),de.useRef(null),de.useRef(null),de.useRef(null),de.useRef(0);const g=de.useRef(null),[x,_]=de.useState(""),[y,M]=de.useState(!1),[C,k]=de.useState(null),B=de.useRef(null),U=H=>{const K=H.target.files[0];if(K){if(K.size>8*1024*1024){jt.error("L'image est trop volumineuse (max 8 Mo).");return}const W=new FileReader;W.onloadend=()=>{k({data:W.result,type:K.type,name:K.name})},W.readAsDataURL(K)}},z=H=>{var W,J;const K=(J=H.clipboardData||((W=H.originalEvent)==null?void 0:W.clipboardData))==null?void 0:J.items;if(K){for(const ie of K)if(ie.type&&ie.type.startsWith("image/")){H.preventDefault();const ae=ie.getAsFile();if(ae){if(ae.size>8*1024*1024){jt.error("L'image collée est trop volumineuse (max 8 Mo).");return}const Q=new FileReader;Q.onloadend=()=>{k({data:Q.result,type:ae.type,name:ae.name||"capture.png"}),jt.success("📸 Image collée depuis le presse-papier !")},Q.readAsDataURL(ae)}break}}};de.useEffect(()=>{const H=K=>{z(K)};return window.addEventListener("paste",H),()=>window.removeEventListener("paste",H)},[]),de.useEffect(()=>{c(n?[]:[{role:"assistant",content:`👋 Bonjour ! Bienvenue dans l'espace Mémoire & Ingestion Familiale. Vous pouvez déposer ici librement vos souvenirs, anecdotes, dates de mariage ou liens de parenté (ex: *« Vasanthy et Robert se sont mariés en 1984 à Pondichéry... »*). 📸 Vous pouvez également coller directement une photo avec **Ctrl+V** pour l'associer à une personne ! 🧠 L'IA analyse instantanément vos récits et photos pour mettre à jour les fiches familiales !`}])},[n]),de.useEffect(()=>{g.current&&(g.current.scrollTop=g.current.scrollHeight)},[l,u]);const O=async H=>{var J,ie;if(H&&H.preventDefault(),!x.trim()&&!C||y)return;const K=x.trim()||(C?"Voici une photo de famille. Analyse-la en détail et associe-la à la fiche de la bonne personne.":"");_("");const W={role:"user",content:K};if(C&&(W.image=C.data,W.mime_type=C.type,k(null)),c(ae=>[...ae,W]),M(!0),!n&&!W.image)try{const ae=await fetch(`${jK}/api/chat/ingest_memory`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({text:K})}),Q=await ae.json();if(ae.ok&&Q.success){let re=Q.summary||"Informations enregistrées avec succès !";((J=Q.updated_people)==null?void 0:J.length)>0&&(re+=` ✅ **Fiches mises à jour :** ${Q.updated_people.join(", ")}`),((ie=Q.created_people)==null?void 0:ie.length)>0&&(re+=` ✨ **Nouvelles personnes créées :** ${Q.created_people.join(", ")}`),c(oe=>[...oe,{role:"assistant",content:re}]),jt.success("🧠 Fiches familiales mises à jour !"),e&&e(),t&&t(re),M(!1);return}}catch(ae){console.error("Ingest error, falling back to regular chat:",ae)}try{const ae=await fetch(`${jK}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({message:K,image:W.image||null,mime_type:W.mime_type||null,prenom:(n==null?void 0:n.prenom)||"",nom:(n==null?void 0:n.nom)||"",history:l.map(ee=>({role:ee.role,content:ee.content})),engine:h})});if(!ae.ok)throw new Error("Erreur de connexion");const Q=ae.body.getReader(),re=new TextDecoder;let oe="",fe="";for(;;){const{done:ee,value:me}=await Q.read();if(ee)break;fe+=re.decode(me,{stream:!0});const Ae=fe.split(` `);fe=Ae.pop();for(const be of Ae)if(be.trim().startsWith("data: ")){const pe=be.replace("data: ","").trim();if(pe&&pe!=="[DONE]")try{const ge=JSON.parse(pe);ge.error?jt.error("Erreur IA: "+ge.error):ge.service_event?(jt.success(ge.message),(ge.service_event==="person_created"||ge.service_event==="relation_linked")&&e&&e(),ge.service_event==="item_saved"&&t&&t(ge.message)):ge.choices&&ge.choices[0].delta&&ge.choices[0].delta.content&&(oe+=ge.choices[0].delta.content,d(oe))}catch{}}}oe.trim()!==""&&c(ee=>[...ee,{role:"assistant",content:oe}]),d("")}catch{jt.error("Le serveur IA ne répond pas.")}finally{M(!1)}},V=de.useRef(null);de.useEffect(()=>{if("webkitSpeechRecognition"in window||"SpeechRecognition"in window){const H=window.SpeechRecognition||window.webkitSpeechRecognition,K=new H;K.continuous=!0,K.interimResults=!0,K.lang="fr-FR",K.onstart=()=>o(!0),K.onend=()=>o(!1),K.onerror=W=>{console.error("Speech recognition error",W.error),o(!1),jt.error("Erreur de microphone")},K.onresult=W=>{let J="",ie="";for(let ae=W.resultIndex;aeae+" "+J.trim())},V.current=K}},[]);const $=()=>{V.current?(_(""),V.current.start(),jt("🎙️ Écoute en cours...",{icon:"👂",duration:2e3})):jt.error("La reconnaissance vocale n'est pas supportée par votre navigateur.")},G=()=>{V.current&&a&&V.current.stop()};return f.jsxs("div",{className:"h-full flex flex-col p-4 bg-slate-950 text-slate-100 relative",children:[f.jsxs("div",{className:"flex justify-between items-center pb-4 border-b border-slate-800 mb-4 flex-shrink-0 bg-slate-900/90 backdrop-blur-md p-4 shadow-xl rounded-2xl border border-slate-800",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("button",{onClick:r,className:"p-3 bg-slate-800/80 rounded-full hover:bg-slate-700 text-slate-300 transition-colors shadow-sm border border-slate-700",children:f.jsx(C7,{size:18})}),f.jsxs("div",{children:[f.jsxs("h3",{className:"font-bold text-white flex items-center gap-2 text-lg",children:["Assistant IA",f.jsx(ACe,{className:h==="azure"?"text-emerald-400":"text-blue-400"})]}),f.jsx("p",{className:"text-sm text-slate-400",children:n?`Discussion avec l'archiviste de ${n.prenom}`:"Créez une nouvelle fiche ou déposez des souvenirs"})]})]}),f.jsx("div",{className:"flex items-center gap-4",children:f.jsx(wH,{engine:h,setEngine:p})})]}),f.jsxs("div",{ref:g,className:"flex-grow p-3 overflow-y-auto space-y-5 pb-44",children:[l.map((H,K)=>f.jsxs("div",{className:`flex items-start gap-3 ${H.role==="user"?"justify-end":"justify-start"}`,children:[H.role==="assistant"&&f.jsx(aT,{role:"assistant",engine:h}),f.jsxs("div",{className:`p-4 rounded-2xl max-w-[85%] ${H.role==="user"?"bg-gradient-to-r from-emerald-600 to-teal-600 text-white rounded-br-sm shadow-lg shadow-emerald-950/40 border border-emerald-500/30":"bg-slate-900 text-slate-100 border border-slate-700/80 rounded-bl-sm shadow-md"}`,children:[H.image&&f.jsx("img",{src:H.image,alt:"Upload",className:"max-w-full max-h-72 object-contain rounded-xl mb-3 border border-slate-700 shadow-md"}),f.jsx("p",{className:"whitespace-pre-wrap leading-relaxed text-sm md:text-base",children:H.content})]}),H.role==="user"&&f.jsx(aT,{role:"user",engine:h})]},K)),u&&f.jsxs("div",{className:"flex items-start gap-3 justify-start",children:[f.jsx(aT,{role:"assistant",engine:h}),f.jsx("div",{className:"p-4 rounded-2xl max-w-[85%] bg-slate-900 text-slate-100 border border-slate-700/80 rounded-bl-sm shadow-md",children:f.jsx("p",{className:"whitespace-pre-wrap leading-relaxed text-sm md:text-base",children:u})})]}),y&&!u&&f.jsxs("div",{className:"flex items-start gap-3 justify-start",children:[f.jsx(aT,{role:"assistant",engine:h}),f.jsx("div",{className:"p-3 rounded-2xl bg-slate-900 border border-slate-700/80 rounded-bl-sm shadow-md",children:f.jsx(YPe,{})})]})]}),f.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-slate-950/95 backdrop-blur-md border-t border-slate-800/80 shadow-[0_-10px_30px_rgba(0,0,0,0.5)] z-20",children:[C&&f.jsxs("div",{className:"mb-3 flex items-center gap-3 bg-slate-900 p-2.5 rounded-xl border border-emerald-500/40 w-max shadow-lg",children:[f.jsx("img",{src:C.data,alt:"Preview",className:"w-12 h-12 object-cover rounded-lg border border-slate-700"}),f.jsxs("div",{className:"flex flex-col",children:[f.jsx("span",{className:"text-xs text-emerald-400 font-semibold",children:C.name||"Photo sélectionnée"}),f.jsx("span",{className:"text-[11px] text-slate-400",children:"Prête à être envoyée ou analysée"})]}),f.jsx("button",{type:"button",onClick:()=>k(null),className:"text-rose-400 hover:text-rose-300 p-1.5 transition-colors ml-2",title:"Supprimer",children:f.jsx(cCe,{size:18})})]}),f.jsxs("form",{onSubmit:O,className:"flex items-center gap-3",children:[f.jsx("input",{type:"file",accept:"image/*",className:"hidden",ref:B,onChange:U}),f.jsx("button",{type:"button",onClick:()=>{var H;return(H=B.current)==null?void 0:H.click()},className:"p-3.5 rounded-2xl bg-slate-800 text-slate-300 hover:text-white hover:bg-slate-700 transition-colors border border-slate-700 shadow-sm shrink-0",title:"Joindre une photo (ou Ctrl+V)",children:f.jsx(fH,{size:20})}),f.jsx("button",{type:"button",onMouseDown:$,onMouseUp:G,onTouchStart:$,onTouchEnd:G,className:`p-3.5 rounded-2xl transition-all duration-300 shadow-sm shrink-0 ${a?"bg-rose-500 animate-pulse text-white shadow-rose-500/50":"bg-slate-800 text-slate-300 hover:text-white hover:bg-slate-700 border border-slate-700"}`,title:"Maintenir pour parler",children:f.jsx(BS,{size:20})}),f.jsx("input",{type:"text",value:x,onChange:H=>_(H.target.value),onPaste:z,placeholder:a?"Je vous écoute...":n?`Message ou collez une photo de ${n.prenom} (Ctrl+V)...`:"Racontez une histoire ou collez une photo (Ctrl+V)...",className:"flex-grow p-3.5 rounded-2xl border border-slate-700 bg-slate-900 text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500 transition-colors shadow-inner",disabled:y}),f.jsx("button",{type:"submit",disabled:!x.trim()&&!C||y,className:"px-6 py-3.5 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white font-bold rounded-2xl disabled:opacity-40 transition-all shrink-0 shadow-lg shadow-emerald-950/40",children:"Envoyer"})]}),a&&f.jsx("p",{className:"text-xs text-center text-rose-400 mt-2 font-medium",children:"Relâchez pour terminer l'enregistrement vocal"})]})]})}function QPe({person:n,people:e,onSelectPerson:t,onClose:r,onDataUpdate:i}){const[s,a]=de.useState(0);de.useEffect(()=>{const l=c=>{c.key==="Escape"&&r()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[r]);const o=l=>{a(c=>c+1),i&&i(l)};return f.jsxs("div",{className:"fixed inset-0 z-[100] flex flex-col bg-slate-900 text-slate-100 overflow-hidden font-sans",children:[f.jsxs("header",{className:"h-14 bg-slate-900/95 backdrop-blur-md border-b border-slate-800 px-4 flex items-center justify-between shrink-0 z-50",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-3 py-1.5 bg-slate-800 hover:bg-slate-700 text-white rounded-xl text-xs font-bold transition border border-slate-700 shadow-sm hover:scale-105 active:scale-95",title:"Revenir au portail familial (Échap)",children:[f.jsx(C7,{className:"text-emerald-400"}),f.jsx("span",{children:"← Revenir au Portail"})]}),f.jsxs("div",{className:"hidden sm:flex items-center gap-2 text-xs text-slate-400",children:[f.jsx("span",{children:"/"}),f.jsx("span",{className:"font-semibold text-slate-200",children:"🎙️ Salon d'Interview & Mémoire Familiale"})]})]}),f.jsxs("div",{className:"flex items-center gap-3",children:[e&&f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xs text-slate-400 hidden md:inline",children:"Personne :"}),f.jsxs("select",{className:"text-xs bg-slate-800 text-white border border-slate-700 rounded-lg px-2.5 py-1.5 focus:outline-none focus:ring-1 focus:ring-emerald-500 max-w-[160px] sm:max-w-[220px]",value:(n==null?void 0:n.slug)||"",onChange:l=>{const c=l.target.value,u=e.find(d=>d.slug===c);u&&t&&t(u)},children:[f.jsx("option",{value:"",children:"-- Sans personne (Général) --"}),e.map(l=>f.jsxs("option",{value:l.slug,children:[l.prenom," ",l.nom]},l.slug))]})]}),f.jsxs("button",{onClick:r,className:"p-2 bg-rose-500/15 hover:bg-rose-500/30 text-rose-300 border border-rose-500/30 rounded-xl transition shadow-sm hover:scale-105 active:scale-95 text-xs flex items-center gap-1.5 font-bold",title:"Fermer le chat (Échap)",children:[f.jsx($a,{size:14}),f.jsx("span",{className:"hidden sm:inline",children:"Fermer"})]})]})]}),f.jsxs("div",{className:"flex flex-col lg:flex-row flex-1 overflow-hidden bg-slate-950",children:[f.jsx("div",{className:"w-full lg:w-1/3 xl:w-2/5 h-1/2 lg:h-full border-b lg:border-b-0 lg:border-r border-slate-800 shadow-2xl z-20 relative flex flex-col bg-slate-950",children:f.jsx("div",{className:"flex-grow overflow-hidden relative",children:f.jsx(ZPe,{person:n,onAdded:o,onItemSaved:o,onClose:r})})}),f.jsx("div",{className:"w-full lg:w-2/3 xl:w-3/5 h-1/2 lg:h-full bg-slate-900 relative overflow-hidden flex flex-col",children:n?f.jsx(H7e,{person:n,refreshKey:s}):f.jsxs("div",{className:"flex items-center justify-center h-full text-slate-400 p-8 text-center flex-col space-y-4",children:[f.jsx("div",{className:"w-20 h-20 rounded-3xl bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center text-3xl",children:"🎙️"}),f.jsx("h2",{className:"text-xl font-bold text-slate-200 max-w-md",children:"Espace d'interview & narration libre"}),f.jsx("p",{className:"text-sm text-slate-400 max-w-lg leading-relaxed",children:"Racontez des souvenirs, dictez des anecdotes ou posez des questions à l'archiviste IA dans le volet de gauche. Sélectionnez une personne en haut pour voir sa timeline synchronisée en temps réel."})]})})]})]})}function cz({onSubmit:n,onCancel:e}){const[t,r]=de.useState(""),[i,s]=de.useState(""),[a,o]=de.useState("M"),[l,c]=de.useState(!1),[u,d]=de.useState(!1),h=de.useRef(null),p=y=>{y.preventDefault(),n(t,i,a)},g=async()=>{if(!t){alert("Veuillez d'abord saisir un prénom.");return}d(!0);try{const M=await fetch("https://famille.ravin-cloud.fr/api/utils/infer-details",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({prenom:t,nom:i})});if(!M.ok)throw new Error("Erreur API");const C=await M.json();C.sexe&&o(C.sexe),C.nom_propose&&!i&&s(C.nom_propose)}catch(y){console.error(y),alert("Impossible de déduire les informations.")}finally{d(!1)}},x=()=>{var y;(y=h.current)==null||y.click()},_=async y=>{const M=y.target.files[0];if(!M)return;c(!0);const C=new FormData;C.append("file",M);try{const B=await fetch("https://famille.ravin-cloud.fr/api/media/analyze",{method:"POST",credentials:"include",body:C});if(!B.ok)throw new Error("Erreur lors de l'analyse");const U=await B.json();if(U.personnes_identifiees&&U.personnes_identifiees.length>0){const z=U.personnes_identifiees[0];r(z.prenom||""),s(z.nom||""),z.sexe&&o(z.sexe)}else alert("Aucune personne n'a pu être identifiée sur cette image.")}catch(k){console.error(k),alert("Erreur lors de la numérisation de la carte d'identité.")}finally{c(!1),h.current&&(h.current.value="")}};return f.jsx(Gn.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4",onClick:e,children:f.jsxs(Gn.form,{initial:{y:-50,opacity:0},animate:{y:0,opacity:1},exit:{y:50,opacity:0},transition:{type:"spring",stiffness:300,damping:30},className:"bg-white rounded-2xl shadow-xl p-6 w-full max-w-sm space-y-4",onClick:y=>y.stopPropagation(),onSubmit:p,children:[f.jsx("h2",{className:"text-xl font-bold text-slate-800",children:"Nouveau Membre"}),f.jsxs("div",{className:"w-full flex justify-center mb-4",children:[f.jsx("input",{type:"file",accept:"image/*",capture:"environment",ref:h,onChange:_,className:"hidden"}),f.jsx("button",{type:"button",onClick:x,disabled:l,className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-indigo-50 hover:bg-indigo-100 text-indigo-700 rounded-xl font-medium border border-indigo-200 transition-colors",children:l?f.jsxs(f.Fragment,{children:[f.jsx(vu,{className:"animate-spin"})," Analyse en cours..."]}):f.jsxs(f.Fragment,{children:[f.jsx(RCe,{size:20})," Scanner une Carte d'Identité"]})})]}),f.jsxs("div",{className:"relative flex items-center py-2",children:[f.jsx("div",{className:"flex-grow border-t border-slate-200"}),f.jsx("span",{className:"flex-shrink-0 mx-4 text-slate-400 text-sm",children:"OU SAISIR MANUELLEMENT"}),f.jsx("div",{className:"flex-grow border-t border-slate-200"})]}),f.jsxs("div",{children:[f.jsx("label",{htmlFor:"prenom",className:"block text-sm font-medium text-slate-600 mb-1",children:"Prénom"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{id:"prenom",type:"text",value:t,onChange:y=>r(y.target.value),className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500",required:!0}),f.jsx("button",{type:"button",onClick:g,disabled:u,className:"px-3 bg-purple-100 text-purple-700 rounded-lg hover:bg-purple-200 transition-colors flex items-center justify-center whitespace-nowrap border border-purple-200",title:"Déduire Sexe et Nom avec l'IA",children:u?f.jsx(vu,{className:"animate-spin"}):"✨ IA"})]})]}),f.jsxs("div",{children:[f.jsx("label",{htmlFor:"nom",className:"block text-sm font-medium text-slate-600 mb-1",children:"Nom"}),f.jsx("input",{id:"nom",type:"text",value:i,onChange:y=>s(y.target.value),className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500",required:!0})]}),f.jsxs("div",{children:[f.jsx("label",{htmlFor:"sexe",className:"block text-sm font-medium text-slate-600 mb-1",children:"Sexe"}),f.jsxs("select",{id:"sexe",value:a,onChange:y=>o(y.target.value),className:"w-full p-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-emerald-500 focus:border-emerald-500 bg-white",children:[f.jsx("option",{value:"M",children:"Homme"}),f.jsx("option",{value:"F",children:"Femme"})]})]}),f.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[f.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 rounded-lg text-slate-600 bg-slate-100 hover:bg-slate-200",children:"Annuler"}),f.jsx("button",{type:"submit",className:"px-4 py-2 rounded-lg text-white bg-emerald-600 hover:bg-emerald-700",children:"Créer"})]})]})})}function bu(n){if(typeof n=="string"||typeof n=="number")return""+n;let e="";if(Array.isArray(n))for(let t=0,r;t"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?sRe:iRe;Sme.useSyncExternalStore=U_.useSyncExternalStore!==void 0?U_.useSyncExternalStore:aRe;wme.exports=Sme;var oRe=wme.exports;/** * @license React * use-sync-external-store-shim/with-selector.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var k7=de,lRe=oRe;function cRe(n,e){return n===e&&(n!==0||1/n===1/e)||n!==n&&e!==e}var uRe=typeof Object.is=="function"?Object.is:cRe,dRe=lRe.useSyncExternalStore,hRe=k7.useRef,fRe=k7.useEffect,pRe=k7.useMemo,mRe=k7.useDebugValue;_me.useSyncExternalStoreWithSelector=function(n,e,t,r,i){var s=hRe(null);if(s.current===null){var a={hasValue:!1,value:null};s.current=a}else a=s.current;s=pRe(function(){function l(p){if(!c){if(c=!0,u=p,p=r(p),i!==void 0&&a.hasValue){var g=a.value;if(i(g,p))return d=g}return d=p}if(g=d,uRe(u,p))return g;var x=r(p);return i!==void 0&&i(g,x)?(u=p,g):(u=p,d=x)}var c=!1,u,d,h=t===void 0?null:t;return[function(){return l(e())},h===null?void 0:function(){return l(h())}]},[e,t,r,i]);var o=dRe(n,s[0],s[1]);return fRe(function(){a.hasValue=!0,a.value=o},[o]),mRe(o),o};bme.exports=_me;var gRe=bme.exports;const ARe=Vv(gRe),xRe={},FK=n=>{let e;const t=new Set,r=(u,d)=>{const h=typeof u=="function"?u(e):u;if(!Object.is(h,e)){const p=e;e=d??(typeof h!="object"||h===null)?h:Object.assign({},e,h),t.forEach(g=>g(e,p))}},i=()=>e,l={setState:r,getState:i,getInitialState:()=>c,subscribe:u=>(t.add(u),()=>t.delete(u)),destroy:()=>{(xRe?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),t.clear()}},c=e=n(r,i,l);return l},vRe=n=>n?FK(n):FK,{useDebugValue:yRe}=ln,{useSyncExternalStoreWithSelector:bRe}=ARe,_Re=n=>n;function Tme(n,e=_Re,t){const r=bRe(n.subscribe,n.getState,n.getServerState||n.getInitialState,e,t);return yRe(r),r}const BK=(n,e)=>{const t=vRe(n),r=(i,s=e)=>Tme(t,i,s);return Object.assign(r,t),r},wRe=(n,e)=>n?BK(n,e):BK;function qc(n,e){if(Object.is(n,e))return!0;if(typeof n!="object"||n===null||typeof e!="object"||e===null)return!1;if(n instanceof Map&&e instanceof Map){if(n.size!==e.size)return!1;for(const[r,i]of n)if(!Object.is(i,e.get(r)))return!1;return!0}if(n instanceof Set&&e instanceof Set){if(n.size!==e.size)return!1;for(const r of n)if(!e.has(r))return!1;return!0}const t=Object.keys(n);if(t.length!==Object.keys(e).length)return!1;for(const r of t)if(!Object.prototype.hasOwnProperty.call(e,r)||!Object.is(n[r],e[r]))return!1;return!0}var SRe={value:()=>{}};function I7(){for(var n=0,e=arguments.length,t={},r;n=0&&(r=t.slice(i+1),t=t.slice(0,i)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}})}iN.prototype=I7.prototype={constructor:iN,on:function(n,e){var t=this._,r=TRe(n+"",t),i,s=-1,a=r.length;if(arguments.length<2){for(;++s0)for(var t=new Array(i),r=0,i,s;r=0&&(e=n.slice(0,t))!=="xmlns"&&(n=n.slice(t+1)),zK.hasOwnProperty(e)?{space:zK[e],local:n}:n}function NRe(n){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===uz&&e.documentElement.namespaceURI===uz?e.createElement(n):e.createElementNS(t,n)}}function MRe(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function Eme(n){var e=D7(n);return(e.local?MRe:NRe)(e)}function CRe(){}function SH(n){return n==null?CRe:function(){return this.querySelector(n)}}function PRe(n){typeof n!="function"&&(n=SH(n));for(var e=this._groups,t=e.length,r=new Array(t),i=0;i=C&&(C=M+1);!(B=_[C])&&++C=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function tLe(n){n||(n=nLe);function e(d,h){return d&&h?n(d.__data__,h.__data__):!d-!h}for(var t=this._groups,r=t.length,i=new Array(r),s=0;se?1:n>=e?0:NaN}function rLe(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function iLe(){return Array.from(this)}function sLe(){for(var n=this._groups,e=0,t=n.length;e1?this.each((e==null?gLe:typeof e=="function"?xLe:ALe)(n,e,t??"")):z_(this.node(),n)}function z_(n,e){return n.style.getPropertyValue(e)||Rme(n).getComputedStyle(n,null).getPropertyValue(e)}function yLe(n){return function(){delete this[n]}}function bLe(n,e){return function(){this[n]=e}}function _Le(n,e){return function(){var t=e.apply(this,arguments);t==null?delete this[n]:this[n]=t}}function wLe(n,e){return arguments.length>1?this.each((e==null?yLe:typeof e=="function"?_Le:bLe)(n,e)):this.node()[n]}function Lme(n){return n.trim().split(/^|\s+/)}function TH(n){return n.classList||new kme(n)}function kme(n){this._node=n,this._names=Lme(n.getAttribute("class")||"")}kme.prototype={add:function(n){var e=this._names.indexOf(n);e<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var e=this._names.indexOf(n);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function Ime(n,e){for(var t=TH(n),r=-1,i=e.length;++r=0&&(t=e.slice(r+1),e=e.slice(0,r)),{type:e,name:t}})}function QLe(n){return function(){var e=this.__on;if(e){for(var t=0,r=-1,i=e.length,s;t()=>n;function dz(n,{sourceEvent:e,subject:t,target:r,identifier:i,active:s,x:a,y:o,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:o,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}dz.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function o9e(n){return!n.ctrlKey&&!n.button}function l9e(){return this.parentNode}function c9e(n,e){return e??{x:n.x,y:n.y}}function u9e(){return navigator.maxTouchPoints||"ontouchstart"in this}function d9e(){var n=o9e,e=l9e,t=c9e,r=u9e,i={},s=I7("start","drag","end"),a=0,o,l,c,u,d=0;function h(k){k.on("mousedown.drag",p).filter(r).on("touchstart.drag",_).on("touchmove.drag",y,a9e).on("touchend.drag touchcancel.drag",M).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(k,B){if(!(u||!n.call(this,k,B))){var U=C(this,e.call(this,k,B),k,B,"mouse");U&&(Xh(k.view).on("mousemove.drag",g,Y4).on("mouseup.drag",x,Y4),Fme(k.view),n9(k),c=!1,o=k.clientX,l=k.clientY,U("start",k))}}function g(k){if(h_(k),!c){var B=k.clientX-o,U=k.clientY-l;c=B*B+U*U>d}i.mouse("drag",k)}function x(k){Xh(k.view).on("mousemove.drag mouseup.drag",null),Bme(k.view,c),h_(k),i.mouse("end",k)}function _(k,B){if(n.call(this,k,B)){var U=k.changedTouches,z=e.call(this,k,B),O=U.length,V,$;for(V=0;V>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?lT(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?lT(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=f9e.exec(n))?new ih(e[1],e[2],e[3],1):(e=p9e.exec(n))?new ih(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=m9e.exec(n))?lT(e[1],e[2],e[3],e[4]):(e=g9e.exec(n))?lT(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=A9e.exec(n))?XK(e[1],e[2]/100,e[3]/100,1):(e=x9e.exec(n))?XK(e[1],e[2]/100,e[3]/100,e[4]):VK.hasOwnProperty(n)?HK(VK[n]):n==="transparent"?new ih(NaN,NaN,NaN,0):null}function HK(n){return new ih(n>>16&255,n>>8&255,n&255,1)}function lT(n,e,t,r){return r<=0&&(n=e=t=NaN),new ih(n,e,t,r)}function b9e(n){return n instanceof VS||(n=kg(n)),n?(n=n.rgb(),new ih(n.r,n.g,n.b,n.opacity)):new ih}function hz(n,e,t,r){return arguments.length===1?b9e(n):new ih(n,e,t,r??1)}function ih(n,e,t,r){this.r=+n,this.g=+e,this.b=+t,this.opacity=+r}EH(ih,hz,Ume(VS,{brighter(n){return n=n==null?EM:Math.pow(EM,n),new ih(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?Z4:Math.pow(Z4,n),new ih(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new ih(Ix(this.r),Ix(this.g),Ix(this.b),NM(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$K,formatHex:$K,formatHex8:_9e,formatRgb:WK,toString:WK}));function $K(){return`#${yx(this.r)}${yx(this.g)}${yx(this.b)}`}function _9e(){return`#${yx(this.r)}${yx(this.g)}${yx(this.b)}${yx((isNaN(this.opacity)?1:this.opacity)*255)}`}function WK(){const n=NM(this.opacity);return`${n===1?"rgb(":"rgba("}${Ix(this.r)}, ${Ix(this.g)}, ${Ix(this.b)}${n===1?")":`, ${n})`}`}function NM(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function Ix(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function yx(n){return n=Ix(n),(n<16?"0":"")+n.toString(16)}function XK(n,e,t,r){return r<=0?n=e=t=NaN:t<=0||t>=1?n=e=NaN:e<=0&&(n=NaN),new L0(n,e,t,r)}function zme(n){if(n instanceof L0)return new L0(n.h,n.s,n.l,n.opacity);if(n instanceof VS||(n=kg(n)),!n)return new L0;if(n instanceof L0)return n;n=n.rgb();var e=n.r/255,t=n.g/255,r=n.b/255,i=Math.min(e,t,r),s=Math.max(e,t,r),a=NaN,o=s-i,l=(s+i)/2;return o?(e===s?a=(t-r)/o+(t0&&l<1?0:a,new L0(a,o,l,n.opacity)}function w9e(n,e,t,r){return arguments.length===1?zme(n):new L0(n,e,t,r??1)}function L0(n,e,t,r){this.h=+n,this.s=+e,this.l=+t,this.opacity=+r}EH(L0,w9e,Ume(VS,{brighter(n){return n=n==null?EM:Math.pow(EM,n),new L0(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?Z4:Math.pow(Z4,n),new L0(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,e=isNaN(n)||isNaN(this.s)?0:this.s,t=this.l,r=t+(t<.5?t:1-t)*e,i=2*t-r;return new ih(r9(n>=240?n-240:n+120,i,r),r9(n,i,r),r9(n<120?n+240:n-120,i,r),this.opacity)},clamp(){return new L0(YK(this.h),cT(this.s),cT(this.l),NM(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=NM(this.opacity);return`${n===1?"hsl(":"hsla("}${YK(this.h)}, ${cT(this.s)*100}%, ${cT(this.l)*100}%${n===1?")":`, ${n})`}`}}));function YK(n){return n=(n||0)%360,n<0?n+360:n}function cT(n){return Math.max(0,Math.min(1,n||0))}function r9(n,e,t){return(n<60?e+(t-e)*n/60:n<180?t:n<240?e+(t-e)*(240-n)/60:e)*255}const NH=n=>()=>n;function S9e(n,e){return function(t){return n+t*e}}function T9e(n,e,t){return n=Math.pow(n,t),e=Math.pow(e,t)-n,t=1/t,function(r){return Math.pow(n+r*e,t)}}function E9e(n){return(n=+n)==1?Vme:function(e,t){return t-e?T9e(e,t,n):NH(isNaN(e)?t:e)}}function Vme(n,e){var t=e-n;return t?S9e(n,t):NH(isNaN(n)?e:n)}const MM=function n(e){var t=E9e(e);function r(i,s){var a=t((i=hz(i)).r,(s=hz(s)).r),o=t(i.g,s.g),l=t(i.b,s.b),c=Vme(i.opacity,s.opacity);return function(u){return i.r=a(u),i.g=o(u),i.b=l(u),i.opacity=c(u),i+""}}return r.gamma=n,r}(1);function qme(n,e){e||(e=[]);var t=n?Math.min(e.length,n.length):0,r=e.slice(),i;return function(s){for(i=0;it&&(s=e.slice(t,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Ff(r,i)})),t=i9.lastIndex;return t180?u+=360:u-c>180&&(c+=360),h.push({i:d.push(i(d)+"rotate(",null,r)-2,x:Ff(c,u)})):u&&d.push(i(d)+"rotate("+u+r)}function o(c,u,d,h){c!==u?h.push({i:d.push(i(d)+"skewX(",null,r)-2,x:Ff(c,u)}):u&&d.push(i(d)+"skewX("+u+r)}function l(c,u,d,h,p,g){if(c!==d||u!==h){var x=p.push(i(p)+"scale(",null,",",null,")");g.push({i:x-4,x:Ff(c,d)},{i:x-2,x:Ff(u,h)})}else(d!==1||h!==1)&&p.push(i(p)+"scale("+d+","+h+")")}return function(c,u){var d=[],h=[];return c=n(c),u=n(u),s(c.translateX,c.translateY,u.translateX,u.translateY,d,h),a(c.rotate,u.rotate,d,h),o(c.skewX,u.skewX,d,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,h),c=u=null,function(p){for(var g=-1,x=h.length,_;++g=0&&n._call.call(void 0,e),n=n._next;--V_}function KK(){Kx=(PM=K4.now())+O7,V_=_5=0;try{V9e()}finally{V_=0,G9e(),Kx=0}}function q9e(){var n=K4.now(),e=n-PM;e>Yme&&(O7-=e,PM=n)}function G9e(){for(var n,e=CM,t,r=1/0;e;)e._call?(r>e._time&&(r=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:CM=t);w5=n,mz(r)}function mz(n){if(!V_){_5&&(_5=clearTimeout(_5));var e=n-Kx;e>24?(n<1/0&&(_5=setTimeout(KK,n-K4.now()-O7)),pw&&(pw=clearInterval(pw))):(pw||(PM=K4.now(),pw=setInterval(q9e,Yme)),V_=1,Zme(KK))}}function JK(n,e,t){var r=new RM;return e=e==null?0:+e,r.restart(i=>{r.stop(),n(i+e)},e,t),r}var H9e=I7("start","end","cancel","interrupt"),$9e=[],Kme=0,eJ=1,gz=2,sN=3,tJ=4,Az=5,aN=6;function j7(n,e,t,r,i,s){var a=n.__transition;if(!a)n.__transition={};else if(t in a)return;W9e(n,t,{name:e,index:r,group:i,on:H9e,tween:$9e,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Kme})}function PH(n,e){var t=np(n,e);if(t.state>Kme)throw new Error("too late; already scheduled");return t}function bm(n,e){var t=np(n,e);if(t.state>sN)throw new Error("too late; already running");return t}function np(n,e){var t=n.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function W9e(n,e,t){var r=n.__transition,i;r[e]=t,t.timer=Qme(s,0,t.time);function s(c){t.state=eJ,t.timer.restart(a,t.delay,t.time),t.delay<=c&&a(c-t.delay)}function a(c){var u,d,h,p;if(t.state!==eJ)return l();for(u in r)if(p=r[u],p.name===t.name){if(p.state===sN)return JK(a);p.state===tJ?(p.state=aN,p.timer.stop(),p.on.call("interrupt",n,n.__data__,p.index,p.group),delete r[u]):+ugz&&r.state=0&&(e=e.slice(0,t)),!e||e==="start"})}function wke(n,e,t){var r,i,s=_ke(e)?PH:bm;return function(){var a=s(this,n),o=a.on;o!==r&&(i=(r=o).copy()).on(e,t),a.on=i}}function Ske(n,e){var t=this._id;return arguments.length<2?np(this.node(),t).on.on(n):this.each(wke(t,n,e))}function Tke(n){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==n)return;e&&e.removeChild(this)}}function Eke(){return this.on("end.remove",Tke(this._id))}function Nke(n){var e=this._name,t=this._id;typeof n!="function"&&(n=SH(n));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a()=>n;function Kke(n,{sourceEvent:e,target:t,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ag(n,e,t){this.k=n,this.x=e,this.y=t}ag.prototype={constructor:ag,scale:function(n){return n===1?this:new ag(this.k*n,this.x,this.y)},translate:function(n,e){return n===0&e===0?this:new ag(this.k,this.x+this.k*n,this.y+this.k*e)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var mg=new ag(1,0,0);ag.prototype;function s9(n){n.stopImmediatePropagation()}function mw(n){n.preventDefault(),n.stopImmediatePropagation()}function Jke(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function eIe(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function nJ(){return this.__zoom||mg}function tIe(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function nIe(){return navigator.maxTouchPoints||"ontouchstart"in this}function rIe(n,e,t){var r=n.invertX(e[0][0])-t[0][0],i=n.invertX(e[1][0])-t[1][0],s=n.invertY(e[0][1])-t[0][1],a=n.invertY(e[1][1])-t[1][1];return n.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function nge(){var n=Jke,e=eIe,t=rIe,r=tIe,i=nIe,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=U9e,c=I7("start","zoom","end"),u,d,h,p=500,g=150,x=0,_=10;function y(W){W.property("__zoom",nJ).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",V).on("dblclick.zoom",$).filter(i).on("touchstart.zoom",G).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",K).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(W,J,ie,ae){var Q=W.selection?W.selection():W;Q.property("__zoom",nJ),W!==Q?B(W,J,ie,ae):Q.interrupt().each(function(){U(this,arguments).event(ae).start().zoom(null,typeof J=="function"?J.apply(this,arguments):J).end()})},y.scaleBy=function(W,J,ie,ae){y.scaleTo(W,function(){var Q=this.__zoom.k,re=typeof J=="function"?J.apply(this,arguments):J;return Q*re},ie,ae)},y.scaleTo=function(W,J,ie,ae){y.transform(W,function(){var Q=e.apply(this,arguments),re=this.__zoom,oe=ie==null?k(Q):typeof ie=="function"?ie.apply(this,arguments):ie,fe=re.invert(oe),ee=typeof J=="function"?J.apply(this,arguments):J;return t(C(M(re,ee),oe,fe),Q,a)},ie,ae)},y.translateBy=function(W,J,ie,ae){y.transform(W,function(){return t(this.__zoom.translate(typeof J=="function"?J.apply(this,arguments):J,typeof ie=="function"?ie.apply(this,arguments):ie),e.apply(this,arguments),a)},null,ae)},y.translateTo=function(W,J,ie,ae,Q){y.transform(W,function(){var re=e.apply(this,arguments),oe=this.__zoom,fe=ae==null?k(re):typeof ae=="function"?ae.apply(this,arguments):ae;return t(mg.translate(fe[0],fe[1]).scale(oe.k).translate(typeof J=="function"?-J.apply(this,arguments):-J,typeof ie=="function"?-ie.apply(this,arguments):-ie),re,a)},ae,Q)};function M(W,J){return J=Math.max(s[0],Math.min(s[1],J)),J===W.k?W:new ag(J,W.x,W.y)}function C(W,J,ie){var ae=J[0]-ie[0]*W.k,Q=J[1]-ie[1]*W.k;return ae===W.x&&Q===W.y?W:new ag(W.k,ae,Q)}function k(W){return[(+W[0][0]+ +W[1][0])/2,(+W[0][1]+ +W[1][1])/2]}function B(W,J,ie,ae){W.on("start.zoom",function(){U(this,arguments).event(ae).start()}).on("interrupt.zoom end.zoom",function(){U(this,arguments).event(ae).end()}).tween("zoom",function(){var Q=this,re=arguments,oe=U(Q,re).event(ae),fe=e.apply(Q,re),ee=ie==null?k(fe):typeof ie=="function"?ie.apply(Q,re):ie,me=Math.max(fe[1][0]-fe[0][0],fe[1][1]-fe[0][1]),Ae=Q.__zoom,be=typeof J=="function"?J.apply(Q,re):J,pe=l(Ae.invert(ee).concat(me/Ae.k),be.invert(ee).concat(me/be.k));return function(ge){if(ge===1)ge=be;else{var Te=pe(ge),ze=me/Te[2];ge=new ag(ze,ee[0]-Te[0]*ze,ee[1]-Te[1]*ze)}oe.zoom(null,ge)}})}function U(W,J,ie){return!ie&&W.__zooming||new z(W,J)}function z(W,J){this.that=W,this.args=J,this.active=0,this.sourceEvent=null,this.extent=e.apply(W,J),this.taps=0}z.prototype={event:function(W){return W&&(this.sourceEvent=W),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(W,J){return this.mouse&&W!=="mouse"&&(this.mouse[1]=J.invert(this.mouse[0])),this.touch0&&W!=="touch"&&(this.touch0[1]=J.invert(this.touch0[0])),this.touch1&&W!=="touch"&&(this.touch1[1]=J.invert(this.touch1[0])),this.that.__zoom=J,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(W){var J=Xh(this.that).datum();c.call(W,this.that,new Kke(W,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:c}),J)}};function O(W,...J){if(!n.apply(this,arguments))return;var ie=U(this,J).event(W),ae=this.__zoom,Q=Math.max(s[0],Math.min(s[1],ae.k*Math.pow(2,r.apply(this,arguments)))),re=Df(W);if(ie.wheel)(ie.mouse[0][0]!==re[0]||ie.mouse[0][1]!==re[1])&&(ie.mouse[1]=ae.invert(ie.mouse[0]=re)),clearTimeout(ie.wheel);else{if(ae.k===Q)return;ie.mouse=[re,ae.invert(re)],oN(this),ie.start()}mw(W),ie.wheel=setTimeout(oe,g),ie.zoom("mouse",t(C(M(ae,Q),ie.mouse[0],ie.mouse[1]),ie.extent,a));function oe(){ie.wheel=null,ie.end()}}function V(W,...J){if(h||!n.apply(this,arguments))return;var ie=W.currentTarget,ae=U(this,J,!0).event(W),Q=Xh(W.view).on("mousemove.zoom",ee,!0).on("mouseup.zoom",me,!0),re=Df(W,ie),oe=W.clientX,fe=W.clientY;Fme(W.view),s9(W),ae.mouse=[re,this.__zoom.invert(re)],oN(this),ae.start();function ee(Ae){if(mw(Ae),!ae.moved){var be=Ae.clientX-oe,pe=Ae.clientY-fe;ae.moved=be*be+pe*pe>x}ae.event(Ae).zoom("mouse",t(C(ae.that.__zoom,ae.mouse[0]=Df(Ae,ie),ae.mouse[1]),ae.extent,a))}function me(Ae){Q.on("mousemove.zoom mouseup.zoom",null),Bme(Ae.view,ae.moved),mw(Ae),ae.event(Ae).end()}}function $(W,...J){if(n.apply(this,arguments)){var ie=this.__zoom,ae=Df(W.changedTouches?W.changedTouches[0]:W,this),Q=ie.invert(ae),re=ie.k*(W.shiftKey?.5:2),oe=t(C(M(ie,re),ae,Q),e.apply(this,J),a);mw(W),o>0?Xh(this).transition().duration(o).call(B,oe,ae,W):Xh(this).call(y.transform,oe,ae,W)}}function G(W,...J){if(n.apply(this,arguments)){var ie=W.touches,ae=ie.length,Q=U(this,J,W.changedTouches.length===ae).event(W),re,oe,fe,ee;for(s9(W),oe=0;oe"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:n=>`Node type "${n}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:n=>`The old edge with id=${n} does not exist.`,error009:n=>`Marker type "${n}" doesn't exist.`,error008:(n,e)=>`Couldn't create edge for ${n?"target":"source"} handle id: "${n?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:n=>`Edge type "${n}" not found. Using fallback type "default".`,error012:n=>`Node with id "${n}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},rge=Dg.error001();function Xa(n,e){const t=de.useContext(F7);if(t===null)throw new Error(rge);return Tme(t,n,e)}const gc=()=>{const n=de.useContext(F7);if(n===null)throw new Error(rge);return de.useMemo(()=>({getState:n.getState,setState:n.setState,subscribe:n.subscribe,destroy:n.destroy}),[n])},sIe=n=>n.userSelectionActive?"none":"all";function p_({position:n,children:e,className:t,style:r,...i}){const s=Xa(sIe),a=`${n}`.split("-");return ln.createElement("div",{className:bu(["react-flow__panel",t,...a]),style:{...r,pointerEvents:s},...i},e)}function aIe({proOptions:n,position:e="bottom-right"}){return n!=null&&n.hideAttribution?null:ln.createElement(p_,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},ln.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const oIe=({x:n,y:e,label:t,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:s={},labelBgPadding:a=[2,4],labelBgBorderRadius:o=2,children:l,className:c,...u})=>{const d=de.useRef(null),[h,p]=de.useState({x:0,y:0,width:0,height:0}),g=bu(["react-flow__edge-textwrapper",c]);return de.useEffect(()=>{if(d.current){const x=d.current.getBBox();p({x:x.x,y:x.y,width:x.width,height:x.height})}},[t]),typeof t>"u"||!t?null:ln.createElement("g",{transform:`translate(${n-h.width/2} ${e-h.height/2})`,className:g,visibility:h.width?"visible":"hidden",...u},i&&ln.createElement("rect",{width:h.width+2*a[0],x:-a[0],y:-a[1],height:h.height+2*a[1],className:"react-flow__edge-textbg",style:s,rx:o,ry:o}),ln.createElement("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:d,style:r},t),l)};var lIe=de.memo(oIe);const LH=n=>({width:n.offsetWidth,height:n.offsetHeight}),q_=(n,e=0,t=1)=>Math.min(Math.max(n,e),t),kH=(n={x:0,y:0},e)=>({x:q_(n.x,e[0][0],e[1][0]),y:q_(n.y,e[0][1],e[1][1])}),rJ=(n,e,t)=>nt?-q_(Math.abs(n-t),1,50)/50:0,ige=(n,e)=>{const t=rJ(n.x,35,e.width-35)*20,r=rJ(n.y,35,e.height-35)*20;return[t,r]},sge=n=>{var e;return((e=n.getRootNode)==null?void 0:e.call(n))||(window==null?void 0:window.document)},age=(n,e)=>({x:Math.min(n.x,e.x),y:Math.min(n.y,e.y),x2:Math.max(n.x2,e.x2),y2:Math.max(n.y2,e.y2)}),J4=({x:n,y:e,width:t,height:r})=>({x:n,y:e,x2:n+t,y2:e+r}),oge=({x:n,y:e,x2:t,y2:r})=>({x:n,y:e,width:t-n,height:r-e}),iJ=n=>({...n.positionAbsolute||{x:0,y:0},width:n.width||0,height:n.height||0}),cIe=(n,e)=>oge(age(J4(n),J4(e))),xz=(n,e)=>{const t=Math.max(0,Math.min(n.x+n.width,e.x+e.width)-Math.max(n.x,e.x)),r=Math.max(0,Math.min(n.y+n.height,e.y+e.height)-Math.max(n.y,e.y));return Math.ceil(t*r)},uIe=n=>zf(n.width)&&zf(n.height)&&zf(n.x)&&zf(n.y),zf=n=>!isNaN(n)&&isFinite(n),Al=Symbol.for("internals"),lge=["Enter"," ","Escape"],dIe=(n,e)=>{},hIe=n=>"nativeEvent"in n;function vz(n){var i,s;const e=hIe(n)?n.nativeEvent:n,t=((s=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:s[0])||n.target;return["INPUT","SELECT","TEXTAREA"].includes(t==null?void 0:t.nodeName)||(t==null?void 0:t.hasAttribute("contenteditable"))||!!(t!=null&&t.closest(".nokey"))}const cge=n=>"clientX"in n,SA=(n,e)=>{var s,a;const t=cge(n),r=t?n.clientX:(s=n.touches)==null?void 0:s[0].clientX,i=t?n.clientY:(a=n.touches)==null?void 0:a[0].clientY;return{x:r-((e==null?void 0:e.left)??0),y:i-((e==null?void 0:e.top)??0)}},LM=()=>{var n;return typeof navigator<"u"&&((n=navigator==null?void 0:navigator.userAgent)==null?void 0:n.indexOf("Mac"))>=0},qS=({id:n,path:e,labelX:t,labelY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:h,interactionWidth:p=20})=>ln.createElement(ln.Fragment,null,ln.createElement("path",{id:n,style:u,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:h}),p&&ln.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}),i&&zf(t)&&zf(r)?ln.createElement(lIe,{x:t,y:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c}):null);qS.displayName="BaseEdge";function gw(n,e,t){return t===void 0?t:r=>{const i=e().edges.find(s=>s.id===n);i&&t(r,{...i})}}function uge({sourceX:n,sourceY:e,targetX:t,targetY:r}){const i=Math.abs(t-n)/2,s=t{const[_,y,M]=hge({sourceX:n,sourceY:e,sourcePosition:i,targetX:t,targetY:r,targetPosition:s});return ln.createElement(qS,{path:_,labelX:y,labelY:M,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:h,markerEnd:p,markerStart:g,interactionWidth:x})});IH.displayName="SimpleBezierEdge";const aJ={[Tr.Left]:{x:-1,y:0},[Tr.Right]:{x:1,y:0},[Tr.Top]:{x:0,y:-1},[Tr.Bottom]:{x:0,y:1}},fIe=({source:n,sourcePosition:e=Tr.Bottom,target:t})=>e===Tr.Left||e===Tr.Right?n.xMath.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2));function pIe({source:n,sourcePosition:e=Tr.Bottom,target:t,targetPosition:r=Tr.Top,center:i,offset:s}){const a=aJ[e],o=aJ[r],l={x:n.x+a.x*s,y:n.y+a.y*s},c={x:t.x+o.x*s,y:t.y+o.y*s},u=fIe({source:l,sourcePosition:e,target:c}),d=u.x!==0?"x":"y",h=u[d];let p=[],g,x;const _={x:0,y:0},y={x:0,y:0},[M,C,k,B]=uge({sourceX:n.x,sourceY:n.y,targetX:t.x,targetY:t.y});if(a[d]*o[d]===-1){g=i.x??M,x=i.y??C;const z=[{x:g,y:l.y},{x:g,y:c.y}],O=[{x:l.x,y:x},{x:c.x,y:x}];a[d]===h?p=d==="x"?z:O:p=d==="x"?O:z}else{const z=[{x:l.x,y:c.y}],O=[{x:c.x,y:l.y}];if(d==="x"?p=a.x===h?O:z:p=a.y===h?z:O,e===r){const K=Math.abs(n[d]-t[d]);if(K<=s){const W=Math.min(s-1,s-K);a[d]===h?_[d]=(l[d]>n[d]?-1:1)*W:y[d]=(c[d]>t[d]?-1:1)*W}}if(e!==r){const K=d==="x"?"y":"x",W=a[d]===o[K],J=l[K]>c[K],ie=l[K]=H?(g=(V.x+$.x)/2,x=p[0].y):(g=p[0].x,x=(V.y+$.y)/2)}return[[n,{x:l.x+_.x,y:l.y+_.y},...p,{x:c.x+y.x,y:c.y+y.y},t],g,x,k,B]}function mIe(n,e,t,r){const i=Math.min(oJ(n,e)/2,oJ(e,t)/2,r),{x:s,y:a}=e;if(n.x===s&&s===t.x||n.y===a&&a===t.y)return`L${s} ${a}`;if(n.y===a){const c=n.x{let C="";return M>0&&M{const[y,M,C]=yz({sourceX:n,sourceY:e,sourcePosition:d,targetX:t,targetY:r,targetPosition:h,borderRadius:x==null?void 0:x.borderRadius,offset:x==null?void 0:x.offset});return ln.createElement(qS,{path:y,labelX:M,labelY:C,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:p,markerStart:g,interactionWidth:_})});B7.displayName="SmoothStepEdge";const DH=de.memo(n=>{var e;return ln.createElement(B7,{...n,pathOptions:de.useMemo(()=>{var t;return{borderRadius:0,offset:(t=n.pathOptions)==null?void 0:t.offset}},[(e=n.pathOptions)==null?void 0:e.offset])})});DH.displayName="StepEdge";function gIe({sourceX:n,sourceY:e,targetX:t,targetY:r}){const[i,s,a,o]=uge({sourceX:n,sourceY:e,targetX:t,targetY:r});return[`M ${n},${e}L ${t},${r}`,i,s,a,o]}const OH=de.memo(({sourceX:n,sourceY:e,targetX:t,targetY:r,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:h,interactionWidth:p})=>{const[g,x,_]=gIe({sourceX:n,sourceY:e,targetX:t,targetY:r});return ln.createElement(qS,{path:g,labelX:x,labelY:_,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,style:u,markerEnd:d,markerStart:h,interactionWidth:p})});OH.displayName="StraightEdge";function hT(n,e){return n>=0?.5*n:e*25*Math.sqrt(-n)}function lJ({pos:n,x1:e,y1:t,x2:r,y2:i,c:s}){switch(n){case Tr.Left:return[e-hT(e-r,s),t];case Tr.Right:return[e+hT(r-e,s),t];case Tr.Top:return[e,t-hT(t-i,s)];case Tr.Bottom:return[e,t+hT(i-t,s)]}}function fge({sourceX:n,sourceY:e,sourcePosition:t=Tr.Bottom,targetX:r,targetY:i,targetPosition:s=Tr.Top,curvature:a=.25}){const[o,l]=lJ({pos:t,x1:n,y1:e,x2:r,y2:i,c:a}),[c,u]=lJ({pos:s,x1:r,y1:i,x2:n,y2:e,c:a}),[d,h,p,g]=dge({sourceX:n,sourceY:e,targetX:r,targetY:i,sourceControlX:o,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${n},${e} C${o},${l} ${c},${u} ${r},${i}`,d,h,p,g]}const kM=de.memo(({sourceX:n,sourceY:e,targetX:t,targetY:r,sourcePosition:i=Tr.Bottom,targetPosition:s=Tr.Top,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:h,markerEnd:p,markerStart:g,pathOptions:x,interactionWidth:_})=>{const[y,M,C]=fge({sourceX:n,sourceY:e,sourcePosition:i,targetX:t,targetY:r,targetPosition:s,curvature:x==null?void 0:x.curvature});return ln.createElement(qS,{path:y,labelX:M,labelY:C,label:a,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,style:h,markerEnd:p,markerStart:g,interactionWidth:_})});kM.displayName="BezierEdge";const jH=de.createContext(null),AIe=jH.Provider;jH.Consumer;const xIe=()=>de.useContext(jH),vIe=n=>"id"in n&&"source"in n&&"target"in n,yIe=({source:n,sourceHandle:e,target:t,targetHandle:r})=>`reactflow__edge-${n}${e||""}-${t}${r||""}`,bz=(n,e)=>typeof n>"u"?"":typeof n=="string"?n:`${e?`${e}__`:""}${Object.keys(n).sort().map(r=>`${r}=${n[r]}`).join("&")}`,bIe=(n,e)=>e.some(t=>t.source===n.source&&t.target===n.target&&(t.sourceHandle===n.sourceHandle||!t.sourceHandle&&!n.sourceHandle)&&(t.targetHandle===n.targetHandle||!t.targetHandle&&!n.targetHandle)),_Ie=(n,e)=>{if(!n.source||!n.target)return e;let t;return vIe(n)?t={...n}:t={...n,id:yIe(n)},bIe(t,e)?e:e.concat(t)},_z=({x:n,y:e},[t,r,i],s,[a,o])=>{const l={x:(n-t)/i,y:(e-r)/i};return s?{x:a*Math.round(l.x/a),y:o*Math.round(l.y/o)}:l},pge=({x:n,y:e},[t,r,i])=>({x:n*i+t,y:e*i+r}),Dx=(n,e=[0,0])=>{if(!n)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const t=(n.width??0)*e[0],r=(n.height??0)*e[1],i={x:n.position.x-t,y:n.position.y-r};return{...i,positionAbsolute:n.positionAbsolute?{x:n.positionAbsolute.x-t,y:n.positionAbsolute.y-r}:i}},GS=(n,e=[0,0])=>{if(n.length===0)return{x:0,y:0,width:0,height:0};const t=n.reduce((r,i)=>{const{x:s,y:a}=Dx(i,e).positionAbsolute;return age(r,J4({x:s,y:a,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return oge(t)},mge=(n,e,[t,r,i]=[0,0,1],s=!1,a=!1,o=[0,0])=>{const l={x:(e.x-t)/i,y:(e.y-r)/i,width:e.width/i,height:e.height/i},c=[];return n.forEach(u=>{const{width:d,height:h,selectable:p=!0,hidden:g=!1}=u;if(a&&!p||g)return!1;const{positionAbsolute:x}=Dx(u,o),_={x:x.x,y:x.y,width:d||0,height:h||0},y=xz(l,_),M=typeof d>"u"||typeof h>"u"||d===null||h===null,C=s&&y>0,k=(d||0)*(h||0);(M||C||y>=k||u.dragging)&&c.push(u)}),c},gge=(n,e)=>{const t=n.map(r=>r.id);return e.filter(r=>t.includes(r.source)||t.includes(r.target))},Age=(n,e,t,r,i,s=.1)=>{const a=e/(n.width*(1+s)),o=t/(n.height*(1+s)),l=Math.min(a,o),c=q_(l,r,i),u=n.x+n.width/2,d=n.y+n.height/2,h=e/2-u*c,p=t/2-d*c;return{x:h,y:p,zoom:c}},sx=(n,e=0)=>n.transition().duration(e);function cJ(n,e,t,r){return(e[t]||[]).reduce((i,s)=>{var a,o;return`${n.id}-${s.id}-${t}`!==r&&i.push({id:s.id||null,type:t,nodeId:n.id,x:(((a=n.positionAbsolute)==null?void 0:a.x)??0)+s.x+s.width/2,y:(((o=n.positionAbsolute)==null?void 0:o.y)??0)+s.y+s.height/2}),i},[])}function wIe(n,e,t,r,i,s){const{x:a,y:o}=SA(n),c=e.elementsFromPoint(a,o).find(g=>g.classList.contains("react-flow__handle"));if(c){const g=c.getAttribute("data-nodeid");if(g){const x=FH(void 0,c),_=c.getAttribute("data-handleid"),y=s({nodeId:g,id:_,type:x});if(y){const M=i.find(C=>C.nodeId===g&&C.type===x&&C.id===_);return{handle:{id:_,type:x,nodeId:g,x:(M==null?void 0:M.x)||t.x,y:(M==null?void 0:M.y)||t.y},validHandleResult:y}}}}let u=[],d=1/0;if(i.forEach(g=>{const x=Math.sqrt((g.x-t.x)**2+(g.y-t.y)**2);if(x<=r){const _=s(g);x<=d&&(xg.isValid),p=u.some(({handle:g})=>g.type==="target");return u.find(({handle:g,validHandleResult:x})=>p?g.type==="target":h?x.isValid:!0)||u[0]}const SIe={source:null,target:null,sourceHandle:null,targetHandle:null},xge=()=>({handleDomNode:null,isValid:!1,connection:SIe,endHandle:null});function vge(n,e,t,r,i,s,a){const o=i==="target",l=a.querySelector(`.react-flow__handle[data-id="${n==null?void 0:n.nodeId}-${n==null?void 0:n.id}-${n==null?void 0:n.type}"]`),c={...xge(),handleDomNode:l};if(l){const u=FH(void 0,l),d=l.getAttribute("data-nodeid"),h=l.getAttribute("data-handleid"),p=l.classList.contains("connectable"),g=l.classList.contains("connectableend"),x={source:o?d:t,sourceHandle:o?h:r,target:o?t:d,targetHandle:o?r:h};c.connection=x,p&&g&&(e===Jx.Strict?o&&u==="source"||!o&&u==="target":d!==t||h!==r)&&(c.endHandle={nodeId:d,handleId:h,type:u},c.isValid=s(x))}return c}function TIe({nodes:n,nodeId:e,handleId:t,handleType:r}){return n.reduce((i,s)=>{if(s[Al]){const{handleBounds:a}=s[Al];let o=[],l=[];a&&(o=cJ(s,a,"source",`${e}-${t}-${r}`),l=cJ(s,a,"target",`${e}-${t}-${r}`)),i.push(...o,...l)}return i},[])}function FH(n,e){return n||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function a9(n){n==null||n.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function EIe(n,e){let t=null;return e?t="valid":n&&!e&&(t="invalid"),t}function yge({event:n,handleId:e,nodeId:t,onConnect:r,isTarget:i,getState:s,setState:a,isValidConnection:o,edgeUpdaterType:l,onReconnectEnd:c}){const u=sge(n.target),{connectionMode:d,domNode:h,autoPanOnConnect:p,connectionRadius:g,onConnectStart:x,panBy:_,getNodes:y,cancelConnection:M}=s();let C=0,k;const{x:B,y:U}=SA(n),z=u==null?void 0:u.elementFromPoint(B,U),O=FH(l,z),V=h==null?void 0:h.getBoundingClientRect();if(!V||!O)return;let $,G=SA(n,V),H=!1,K=null,W=!1,J=null;const ie=TIe({nodes:y(),nodeId:t,handleId:e,handleType:O}),ae=()=>{if(!p)return;const[oe,fe]=ige(G,V);_({x:oe,y:fe}),C=requestAnimationFrame(ae)};a({connectionPosition:G,connectionStatus:null,connectionNodeId:t,connectionHandleId:e,connectionHandleType:O,connectionStartHandle:{nodeId:t,handleId:e,type:O},connectionEndHandle:null}),x==null||x(n,{nodeId:t,handleId:e,handleType:O});function Q(oe){const{transform:fe}=s();G=SA(oe,V);const{handle:ee,validHandleResult:me}=wIe(oe,u,_z(G,fe,!1,[1,1]),g,ie,Ae=>vge(Ae,d,t,e,i?"target":"source",o,u));if(k=ee,H||(ae(),H=!0),J=me.handleDomNode,K=me.connection,W=me.isValid,a({connectionPosition:k&&W?pge({x:k.x,y:k.y},fe):G,connectionStatus:EIe(!!k,W),connectionEndHandle:me.endHandle}),!k&&!W&&!J)return a9($);K.source!==K.target&&J&&(a9($),$=J,J.classList.add("connecting","react-flow__handle-connecting"),J.classList.toggle("valid",W),J.classList.toggle("react-flow__handle-valid",W))}function re(oe){var fe,ee;(k||J)&&K&&W&&(r==null||r(K)),(ee=(fe=s()).onConnectEnd)==null||ee.call(fe,oe),l&&(c==null||c(oe)),a9($),M(),cancelAnimationFrame(C),H=!1,W=!1,K=null,J=null,u.removeEventListener("mousemove",Q),u.removeEventListener("mouseup",re),u.removeEventListener("touchmove",Q),u.removeEventListener("touchend",re)}u.addEventListener("mousemove",Q),u.addEventListener("mouseup",re),u.addEventListener("touchmove",Q),u.addEventListener("touchend",re)}const uJ=()=>!0,NIe=n=>({connectionStartHandle:n.connectionStartHandle,connectOnClick:n.connectOnClick,noPanClassName:n.noPanClassName}),MIe=(n,e,t)=>r=>{const{connectionStartHandle:i,connectionEndHandle:s,connectionClickStartHandle:a}=r;return{connecting:(i==null?void 0:i.nodeId)===n&&(i==null?void 0:i.handleId)===e&&(i==null?void 0:i.type)===t||(s==null?void 0:s.nodeId)===n&&(s==null?void 0:s.handleId)===e&&(s==null?void 0:s.type)===t,clickConnecting:(a==null?void 0:a.nodeId)===n&&(a==null?void 0:a.handleId)===e&&(a==null?void 0:a.type)===t}},bge=de.forwardRef(({type:n="source",position:e=Tr.Top,isValidConnection:t,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:s=!0,id:a,onConnect:o,children:l,className:c,onMouseDown:u,onTouchStart:d,...h},p)=>{var V,$;const g=a||null,x=n==="target",_=gc(),y=xIe(),{connectOnClick:M,noPanClassName:C}=Xa(NIe,qc),{connecting:k,clickConnecting:B}=Xa(MIe(y,g,n),qc);y||($=(V=_.getState()).onError)==null||$.call(V,"010",Dg.error010());const U=G=>{const{defaultEdgeOptions:H,onConnect:K,hasDefaultEdges:W}=_.getState(),J={...H,...G};if(W){const{edges:ie,setEdges:ae}=_.getState();ae(_Ie(J,ie))}K==null||K(J),o==null||o(J)},z=G=>{if(!y)return;const H=cge(G);i&&(H&&G.button===0||!H)&&yge({event:G,handleId:g,nodeId:y,onConnect:U,isTarget:x,getState:_.getState,setState:_.setState,isValidConnection:t||_.getState().isValidConnection||uJ}),H?u==null||u(G):d==null||d(G)},O=G=>{const{onClickConnectStart:H,onClickConnectEnd:K,connectionClickStartHandle:W,connectionMode:J,isValidConnection:ie}=_.getState();if(!y||!W&&!i)return;if(!W){H==null||H(G,{nodeId:y,handleId:g,handleType:n}),_.setState({connectionClickStartHandle:{nodeId:y,type:n,handleId:g}});return}const ae=sge(G.target),Q=t||ie||uJ,{connection:re,isValid:oe}=vge({nodeId:y,id:g,type:n},J,W.nodeId,W.handleId||null,W.type,Q,ae);oe&&U(re),K==null||K(G),_.setState({connectionClickStartHandle:null})};return ln.createElement("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":e,"data-id":`${y}-${g}-${n}`,className:bu(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",C,c,{source:!x,target:x,connectable:r,connectablestart:i,connectableend:s,connecting:B,connectionindicator:r&&(i&&!k||s&&k)}]),onMouseDown:z,onTouchStart:z,onClick:M?O:void 0,ref:p,...h},l)});bge.displayName="Handle";var Fp=de.memo(bge);const _ge=({data:n,isConnectable:e,targetPosition:t=Tr.Top,sourcePosition:r=Tr.Bottom})=>ln.createElement(ln.Fragment,null,ln.createElement(Fp,{type:"target",position:t,isConnectable:e}),n==null?void 0:n.label,ln.createElement(Fp,{type:"source",position:r,isConnectable:e}));_ge.displayName="DefaultNode";var wz=de.memo(_ge);const wge=({data:n,isConnectable:e,sourcePosition:t=Tr.Bottom})=>ln.createElement(ln.Fragment,null,n==null?void 0:n.label,ln.createElement(Fp,{type:"source",position:t,isConnectable:e}));wge.displayName="InputNode";var Sge=de.memo(wge);const Tge=({data:n,isConnectable:e,targetPosition:t=Tr.Top})=>ln.createElement(ln.Fragment,null,ln.createElement(Fp,{type:"target",position:t,isConnectable:e}),n==null?void 0:n.label);Tge.displayName="OutputNode";var Ege=de.memo(Tge);const BH=()=>null;BH.displayName="GroupNode";const CIe=n=>({selectedNodes:n.getNodes().filter(e=>e.selected),selectedEdges:n.edges.filter(e=>e.selected).map(e=>({...e}))}),fT=n=>n.id;function PIe(n,e){return qc(n.selectedNodes.map(fT),e.selectedNodes.map(fT))&&qc(n.selectedEdges.map(fT),e.selectedEdges.map(fT))}const Nge=de.memo(({onSelectionChange:n})=>{const e=gc(),{selectedNodes:t,selectedEdges:r}=Xa(CIe,PIe);return de.useEffect(()=>{const i={nodes:t,edges:r};n==null||n(i),e.getState().onSelectionChange.forEach(s=>s(i))},[t,r,n]),null});Nge.displayName="SelectionListener";const RIe=n=>!!n.onSelectionChange;function LIe({onSelectionChange:n}){const e=Xa(RIe);return n||e?ln.createElement(Nge,{onSelectionChange:n}):null}const kIe=n=>({setNodes:n.setNodes,setEdges:n.setEdges,setDefaultNodesAndEdges:n.setDefaultNodesAndEdges,setMinZoom:n.setMinZoom,setMaxZoom:n.setMaxZoom,setTranslateExtent:n.setTranslateExtent,setNodeExtent:n.setNodeExtent,reset:n.reset});function Sy(n,e){de.useEffect(()=>{typeof n<"u"&&e(n)},[n])}function Wi(n,e,t){de.useEffect(()=>{typeof e<"u"&&t({[n]:e})},[e])}const IIe=({nodes:n,edges:e,defaultNodes:t,defaultEdges:r,onConnect:i,onConnectStart:s,onConnectEnd:a,onClickConnectStart:o,onClickConnectEnd:l,nodesDraggable:c,nodesConnectable:u,nodesFocusable:d,edgesFocusable:h,edgesUpdatable:p,elevateNodesOnSelect:g,minZoom:x,maxZoom:_,nodeExtent:y,onNodesChange:M,onEdgesChange:C,elementsSelectable:k,connectionMode:B,snapGrid:U,snapToGrid:z,translateExtent:O,connectOnClick:V,defaultEdgeOptions:$,fitView:G,fitViewOptions:H,onNodesDelete:K,onEdgesDelete:W,onNodeDrag:J,onNodeDragStart:ie,onNodeDragStop:ae,onSelectionDrag:Q,onSelectionDragStart:re,onSelectionDragStop:oe,noPanClassName:fe,nodeOrigin:ee,rfId:me,autoPanOnConnect:Ae,autoPanOnNodeDrag:be,onError:pe,connectionRadius:ge,isValidConnection:Te,nodeDragThreshold:ze})=>{const{setNodes:Xe,setEdges:Qe,setDefaultNodesAndEdges:ot,setMinZoom:bt,setMaxZoom:ht,setTranslateExtent:Ce,setNodeExtent:lt,reset:ft}=Xa(kIe,qc),et=gc();return de.useEffect(()=>{const At=r==null?void 0:r.map(Lt=>({...Lt,...$}));return ot(t,At),()=>{ft()}},[]),Wi("defaultEdgeOptions",$,et.setState),Wi("connectionMode",B,et.setState),Wi("onConnect",i,et.setState),Wi("onConnectStart",s,et.setState),Wi("onConnectEnd",a,et.setState),Wi("onClickConnectStart",o,et.setState),Wi("onClickConnectEnd",l,et.setState),Wi("nodesDraggable",c,et.setState),Wi("nodesConnectable",u,et.setState),Wi("nodesFocusable",d,et.setState),Wi("edgesFocusable",h,et.setState),Wi("edgesUpdatable",p,et.setState),Wi("elementsSelectable",k,et.setState),Wi("elevateNodesOnSelect",g,et.setState),Wi("snapToGrid",z,et.setState),Wi("snapGrid",U,et.setState),Wi("onNodesChange",M,et.setState),Wi("onEdgesChange",C,et.setState),Wi("connectOnClick",V,et.setState),Wi("fitViewOnInit",G,et.setState),Wi("fitViewOnInitOptions",H,et.setState),Wi("onNodesDelete",K,et.setState),Wi("onEdgesDelete",W,et.setState),Wi("onNodeDrag",J,et.setState),Wi("onNodeDragStart",ie,et.setState),Wi("onNodeDragStop",ae,et.setState),Wi("onSelectionDrag",Q,et.setState),Wi("onSelectionDragStart",re,et.setState),Wi("onSelectionDragStop",oe,et.setState),Wi("noPanClassName",fe,et.setState),Wi("nodeOrigin",ee,et.setState),Wi("rfId",me,et.setState),Wi("autoPanOnConnect",Ae,et.setState),Wi("autoPanOnNodeDrag",be,et.setState),Wi("onError",pe,et.setState),Wi("connectionRadius",ge,et.setState),Wi("isValidConnection",Te,et.setState),Wi("nodeDragThreshold",ze,et.setState),Sy(n,Xe),Sy(e,Qe),Sy(x,bt),Sy(_,ht),Sy(O,Ce),Sy(y,lt),null},dJ={display:"none"},DIe={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Mge="react-flow__node-desc",Cge="react-flow__edge-desc",OIe="react-flow__aria-live",jIe=n=>n.ariaLiveMessage;function FIe({rfId:n}){const e=Xa(jIe);return ln.createElement("div",{id:`${OIe}-${n}`,"aria-live":"assertive","aria-atomic":"true",style:DIe},e)}function BIe({rfId:n,disableKeyboardA11y:e}){return ln.createElement(ln.Fragment,null,ln.createElement("div",{id:`${Mge}-${n}`,style:dJ},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),ln.createElement("div",{id:`${Cge}-${n}`,style:dJ},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&ln.createElement(FIe,{rfId:n}))}var tS=(n=null,e={actInsideInputWithModifier:!0})=>{const[t,r]=de.useState(!1),i=de.useRef(!1),s=de.useRef(new Set([])),[a,o]=de.useMemo(()=>{if(n!==null){const c=(Array.isArray(n)?n:[n]).filter(d=>typeof d=="string").map(d=>d.split("+")),u=c.reduce((d,h)=>d.concat(...h),[]);return[c,u]}return[[],[]]},[n]);return de.useEffect(()=>{const l=typeof document<"u"?document:null,c=(e==null?void 0:e.target)||l;if(n!==null){const u=p=>{if(i.current=p.ctrlKey||p.metaKey||p.shiftKey,(!i.current||i.current&&!e.actInsideInputWithModifier)&&vz(p))return!1;const x=fJ(p.code,o);s.current.add(p[x]),hJ(a,s.current,!1)&&(p.preventDefault(),r(!0))},d=p=>{if((!i.current||i.current&&!e.actInsideInputWithModifier)&&vz(p))return!1;const x=fJ(p.code,o);hJ(a,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(p[x]),p.key==="Meta"&&s.current.clear(),i.current=!1},h=()=>{s.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",h),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",h)}}},[n,r]),t};function hJ(n,e,t){return n.filter(r=>t||r.length===e.size).some(r=>r.every(i=>e.has(i)))}function fJ(n,e){return e.includes(n)?"code":"key"}function Pge(n,e,t,r){var o,l;const i=n.parentNode||n.parentId;if(!i)return t;const s=e.get(i),a=Dx(s,r);return Pge(s,e,{x:(t.x??0)+a.x,y:(t.y??0)+a.y,z:(((o=s[Al])==null?void 0:o.z)??0)>(t.z??0)?((l=s[Al])==null?void 0:l.z)??0:t.z??0},r)}function Rge(n,e,t){n.forEach(r=>{var s;const i=r.parentNode||r.parentId;if(i&&!n.has(i))throw new Error(`Parent node ${i} not found`);if(i||t!=null&&t[r.id]){const{x:a,y:o,z:l}=Pge(r,n,{...r.position,z:((s=r[Al])==null?void 0:s.z)??0},e);r.positionAbsolute={x:a,y:o},r[Al].z=l,t!=null&&t[r.id]&&(r[Al].isParent=!0)}})}function o9(n,e,t,r){const i=new Map,s={},a=r?1e3:0;return n.forEach(o=>{var p;const l=(zf(o.zIndex)?o.zIndex:0)+(o.selected?a:0),c=e.get(o.id),u={...o,positionAbsolute:{x:o.position.x,y:o.position.y}},d=o.parentNode||o.parentId;d&&(s[d]=!0);const h=(c==null?void 0:c.type)&&(c==null?void 0:c.type)!==o.type;Object.defineProperty(u,Al,{enumerable:!1,value:{handleBounds:h||(p=c==null?void 0:c[Al])==null?void 0:p.handleBounds,z:l}}),i.set(o.id,u)}),Rge(i,t,s),i}function Lge(n,e={}){const{getNodes:t,width:r,height:i,minZoom:s,maxZoom:a,d3Zoom:o,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:u,nodeOrigin:d}=n(),h=e.initial&&!c&&u;if(o&&l&&(h||!e.initial)){const g=t().filter(_=>{var M;const y=e.includeHiddenNodes?_.width&&_.height:!_.hidden;return(M=e.nodes)!=null&&M.length?y&&e.nodes.some(C=>C.id===_.id):y}),x=g.every(_=>_.width&&_.height);if(g.length>0&&x){const _=GS(g,d),{x:y,y:M,zoom:C}=Age(_,r,i,e.minZoom??s,e.maxZoom??a,e.padding??.1),k=mg.translate(y,M).scale(C);return typeof e.duration=="number"&&e.duration>0?o.transform(sx(l,e.duration),k):o.transform(l,k),!0}}return!1}function UIe(n,e){return n.forEach(t=>{const r=e.get(t.id);r&&e.set(r.id,{...r,[Al]:r[Al],selected:t.selected})}),new Map(e)}function zIe(n,e){return e.map(t=>{const r=n.find(i=>i.id===t.id);return r&&(t.selected=r.selected),t})}function pT({changedNodes:n,changedEdges:e,get:t,set:r}){const{nodeInternals:i,edges:s,onNodesChange:a,onEdgesChange:o,hasDefaultNodes:l,hasDefaultEdges:c}=t();n!=null&&n.length&&(l&&r({nodeInternals:UIe(n,i)}),a==null||a(n)),e!=null&&e.length&&(c&&r({edges:zIe(e,s)}),o==null||o(e))}const Ty=()=>{},VIe={zoomIn:Ty,zoomOut:Ty,zoomTo:Ty,getZoom:()=>1,setViewport:Ty,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ty,fitBounds:Ty,project:n=>n,screenToFlowPosition:n=>n,flowToScreenPosition:n=>n,viewportInitialized:!1},qIe=n=>({d3Zoom:n.d3Zoom,d3Selection:n.d3Selection}),GIe=()=>{const n=gc(),{d3Zoom:e,d3Selection:t}=Xa(qIe,qc);return de.useMemo(()=>t&&e?{zoomIn:i=>e.scaleBy(sx(t,i==null?void 0:i.duration),1.2),zoomOut:i=>e.scaleBy(sx(t,i==null?void 0:i.duration),1/1.2),zoomTo:(i,s)=>e.scaleTo(sx(t,s==null?void 0:s.duration),i),getZoom:()=>n.getState().transform[2],setViewport:(i,s)=>{const[a,o,l]=n.getState().transform,c=mg.translate(i.x??a,i.y??o).scale(i.zoom??l);e.transform(sx(t,s==null?void 0:s.duration),c)},getViewport:()=>{const[i,s,a]=n.getState().transform;return{x:i,y:s,zoom:a}},fitView:i=>Lge(n.getState,i),setCenter:(i,s,a)=>{const{width:o,height:l,maxZoom:c}=n.getState(),u=typeof(a==null?void 0:a.zoom)<"u"?a.zoom:c,d=o/2-i*u,h=l/2-s*u,p=mg.translate(d,h).scale(u);e.transform(sx(t,a==null?void 0:a.duration),p)},fitBounds:(i,s)=>{const{width:a,height:o,minZoom:l,maxZoom:c}=n.getState(),{x:u,y:d,zoom:h}=Age(i,a,o,l,c,(s==null?void 0:s.padding)??.1),p=mg.translate(u,d).scale(h);e.transform(sx(t,s==null?void 0:s.duration),p)},project:i=>{const{transform:s,snapToGrid:a,snapGrid:o}=n.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),_z(i,s,a,o)},screenToFlowPosition:i=>{const{transform:s,snapToGrid:a,snapGrid:o,domNode:l}=n.getState();if(!l)return i;const{x:c,y:u}=l.getBoundingClientRect(),d={x:i.x-c,y:i.y-u};return _z(d,s,a,o)},flowToScreenPosition:i=>{const{transform:s,domNode:a}=n.getState();if(!a)return i;const{x:o,y:l}=a.getBoundingClientRect(),c=pge(i,s);return{x:c.x+o,y:c.y+l}},viewportInitialized:!0}:VIe,[e,t])};function U7(){const n=GIe(),e=gc(),t=de.useCallback(()=>e.getState().getNodes().map(x=>({...x})),[]),r=de.useCallback(x=>e.getState().nodeInternals.get(x),[]),i=de.useCallback(()=>{const{edges:x=[]}=e.getState();return x.map(_=>({..._}))},[]),s=de.useCallback(x=>{const{edges:_=[]}=e.getState();return _.find(y=>y.id===x)},[]),a=de.useCallback(x=>{const{getNodes:_,setNodes:y,hasDefaultNodes:M,onNodesChange:C}=e.getState(),k=_(),B=typeof x=="function"?x(k):x;if(M)y(B);else if(C){const U=B.length===0?k.map(z=>({type:"remove",id:z.id})):B.map(z=>({item:z,type:"reset"}));C(U)}},[]),o=de.useCallback(x=>{const{edges:_=[],setEdges:y,hasDefaultEdges:M,onEdgesChange:C}=e.getState(),k=typeof x=="function"?x(_):x;if(M)y(k);else if(C){const B=k.length===0?_.map(U=>({type:"remove",id:U.id})):k.map(U=>({item:U,type:"reset"}));C(B)}},[]),l=de.useCallback(x=>{const _=Array.isArray(x)?x:[x],{getNodes:y,setNodes:M,hasDefaultNodes:C,onNodesChange:k}=e.getState();if(C){const U=[...y(),..._];M(U)}else if(k){const B=_.map(U=>({item:U,type:"add"}));k(B)}},[]),c=de.useCallback(x=>{const _=Array.isArray(x)?x:[x],{edges:y=[],setEdges:M,hasDefaultEdges:C,onEdgesChange:k}=e.getState();if(C)M([...y,..._]);else if(k){const B=_.map(U=>({item:U,type:"add"}));k(B)}},[]),u=de.useCallback(()=>{const{getNodes:x,edges:_=[],transform:y}=e.getState(),[M,C,k]=y;return{nodes:x().map(B=>({...B})),edges:_.map(B=>({...B})),viewport:{x:M,y:C,zoom:k}}},[]),d=de.useCallback(({nodes:x,edges:_})=>{const{nodeInternals:y,getNodes:M,edges:C,hasDefaultNodes:k,hasDefaultEdges:B,onNodesDelete:U,onEdgesDelete:z,onNodesChange:O,onEdgesChange:V}=e.getState(),$=(x||[]).map(J=>J.id),G=(_||[]).map(J=>J.id),H=M().reduce((J,ie)=>{const ae=ie.parentNode||ie.parentId,Q=!$.includes(ie.id)&&ae&&J.find(oe=>oe.id===ae);return(typeof ie.deletable=="boolean"?ie.deletable:!0)&&($.includes(ie.id)||Q)&&J.push(ie),J},[]),K=C.filter(J=>typeof J.deletable=="boolean"?J.deletable:!0),W=K.filter(J=>G.includes(J.id));if(H||W){const J=gge(H,K),ie=[...W,...J],ae=ie.reduce((Q,re)=>(Q.includes(re.id)||Q.push(re.id),Q),[]);if((B||k)&&(B&&e.setState({edges:C.filter(Q=>!ae.includes(Q.id))}),k&&(H.forEach(Q=>{y.delete(Q.id)}),e.setState({nodeInternals:new Map(y)}))),ae.length>0&&(z==null||z(ie),V&&V(ae.map(Q=>({id:Q,type:"remove"})))),H.length>0&&(U==null||U(H),O)){const Q=H.map(re=>({id:re.id,type:"remove"}));O(Q)}}},[]),h=de.useCallback(x=>{const _=uIe(x),y=_?null:e.getState().nodeInternals.get(x.id);return!_&&!y?[null,null,_]:[_?x:iJ(y),y,_]},[]),p=de.useCallback((x,_=!0,y)=>{const[M,C,k]=h(x);return M?(y||e.getState().getNodes()).filter(B=>{if(!k&&(B.id===C.id||!B.positionAbsolute))return!1;const U=iJ(B),z=xz(U,M);return _&&z>0||z>=M.width*M.height}):[]},[]),g=de.useCallback((x,_,y=!0)=>{const[M]=h(x);if(!M)return!1;const C=xz(M,_);return y&&C>0||C>=M.width*M.height},[]);return de.useMemo(()=>({...n,getNodes:t,getNode:r,getEdges:i,getEdge:s,setNodes:a,setEdges:o,addNodes:l,addEdges:c,toObject:u,deleteElements:d,getIntersectingNodes:p,isNodeIntersecting:g}),[n,t,r,i,s,a,o,l,c,u,d,p,g])}const HIe={actInsideInputWithModifier:!1};var $Ie=({deleteKeyCode:n,multiSelectionKeyCode:e})=>{const t=gc(),{deleteElements:r}=U7(),i=tS(n,HIe),s=tS(e);de.useEffect(()=>{if(i){const{edges:a,getNodes:o}=t.getState(),l=o().filter(u=>u.selected),c=a.filter(u=>u.selected);r({nodes:l,edges:c}),t.setState({nodesSelectionActive:!1})}},[i]),de.useEffect(()=>{t.setState({multiSelectionActive:s})},[s])};function WIe(n){const e=gc();de.useEffect(()=>{let t;const r=()=>{var s,a;if(!n.current)return;const i=LH(n.current);(i.height===0||i.width===0)&&((a=(s=e.getState()).onError)==null||a.call(s,"004",Dg.error004())),e.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),n.current&&(t=new ResizeObserver(()=>r()),t.observe(n.current)),()=>{window.removeEventListener("resize",r),t&&n.current&&t.unobserve(n.current)}},[])}const UH={position:"absolute",width:"100%",height:"100%",top:0,left:0},XIe=(n,e)=>n.x!==e.x||n.y!==e.y||n.zoom!==e.k,mT=n=>({x:n.x,y:n.y,zoom:n.k}),Ey=(n,e)=>n.target.closest(`.${e}`),pJ=(n,e)=>e===2&&Array.isArray(n)&&n.includes(2),mJ=n=>{const e=n.ctrlKey&&LM()?10:1;return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*e},YIe=n=>({d3Zoom:n.d3Zoom,d3Selection:n.d3Selection,d3ZoomHandler:n.d3ZoomHandler,userSelectionActive:n.userSelectionActive}),ZIe=({onMove:n,onMoveStart:e,onMoveEnd:t,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:s=!0,panOnScroll:a=!1,panOnScrollSpeed:o=.5,panOnScrollMode:l=bx.Free,zoomOnDoubleClick:c=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:h,translateExtent:p,minZoom:g,maxZoom:x,zoomActivationKeyCode:_,preventScrolling:y=!0,children:M,noWheelClassName:C,noPanClassName:k})=>{const B=de.useRef(),U=gc(),z=de.useRef(!1),O=de.useRef(!1),V=de.useRef(null),$=de.useRef({x:0,y:0,zoom:0}),{d3Zoom:G,d3Selection:H,d3ZoomHandler:K,userSelectionActive:W}=Xa(YIe,qc),J=tS(_),ie=de.useRef(0),ae=de.useRef(!1),Q=de.useRef();return WIe(V),de.useEffect(()=>{if(V.current){const re=V.current.getBoundingClientRect(),oe=nge().scaleExtent([g,x]).translateExtent(p),fe=Xh(V.current).call(oe),ee=mg.translate(h.x,h.y).scale(q_(h.zoom,g,x)),me=[[0,0],[re.width,re.height]],Ae=oe.constrain()(ee,me,p);oe.transform(fe,Ae),oe.wheelDelta(mJ),U.setState({d3Zoom:oe,d3Selection:fe,d3ZoomHandler:fe.on("wheel.zoom"),transform:[Ae.x,Ae.y,Ae.k],domNode:V.current.closest(".react-flow")})}},[]),de.useEffect(()=>{H&&G&&(a&&!J&&!W?H.on("wheel.zoom",re=>{if(Ey(re,C))return!1;re.preventDefault(),re.stopImmediatePropagation();const oe=H.property("__zoom").k||1;if(re.ctrlKey&&s){const Te=Df(re),ze=mJ(re),Xe=oe*Math.pow(2,ze);G.scaleTo(H,Xe,Te,re);return}const fe=re.deltaMode===1?20:1;let ee=l===bx.Vertical?0:re.deltaX*fe,me=l===bx.Horizontal?0:re.deltaY*fe;!LM()&&re.shiftKey&&l!==bx.Vertical&&(ee=re.deltaY*fe,me=0),G.translateBy(H,-(ee/oe)*o,-(me/oe)*o,{internal:!0});const Ae=mT(H.property("__zoom")),{onViewportChangeStart:be,onViewportChange:pe,onViewportChangeEnd:ge}=U.getState();clearTimeout(Q.current),ae.current||(ae.current=!0,e==null||e(re,Ae),be==null||be(Ae)),ae.current&&(n==null||n(re,Ae),pe==null||pe(Ae),Q.current=setTimeout(()=>{t==null||t(re,Ae),ge==null||ge(Ae),ae.current=!1},150))},{passive:!1}):typeof K<"u"&&H.on("wheel.zoom",function(re,oe){if(!y&&re.type==="wheel"&&!re.ctrlKey||Ey(re,C))return null;re.preventDefault(),K.call(this,re,oe)},{passive:!1}))},[W,a,l,H,G,K,J,s,y,C,e,n,t]),de.useEffect(()=>{G&&G.on("start",re=>{var ee,me;if(!re.sourceEvent||re.sourceEvent.internal)return null;ie.current=(ee=re.sourceEvent)==null?void 0:ee.button;const{onViewportChangeStart:oe}=U.getState(),fe=mT(re.transform);z.current=!0,$.current=fe,((me=re.sourceEvent)==null?void 0:me.type)==="mousedown"&&U.setState({paneDragging:!0}),oe==null||oe(fe),e==null||e(re.sourceEvent,fe)})},[G,e]),de.useEffect(()=>{G&&(W&&!z.current?G.on("zoom",null):W||G.on("zoom",re=>{var fe;const{onViewportChange:oe}=U.getState();if(U.setState({transform:[re.transform.x,re.transform.y,re.transform.k]}),O.current=!!(r&&pJ(d,ie.current??0)),(n||oe)&&!((fe=re.sourceEvent)!=null&&fe.internal)){const ee=mT(re.transform);oe==null||oe(ee),n==null||n(re.sourceEvent,ee)}}))},[W,G,n,d,r]),de.useEffect(()=>{G&&G.on("end",re=>{if(!re.sourceEvent||re.sourceEvent.internal)return null;const{onViewportChangeEnd:oe}=U.getState();if(z.current=!1,U.setState({paneDragging:!1}),r&&pJ(d,ie.current??0)&&!O.current&&r(re.sourceEvent),O.current=!1,(t||oe)&&XIe($.current,re.transform)){const fe=mT(re.transform);$.current=fe,clearTimeout(B.current),B.current=setTimeout(()=>{oe==null||oe(fe),t==null||t(re.sourceEvent,fe)},a?150:0)}})},[G,a,d,t,r]),de.useEffect(()=>{G&&G.filter(re=>{const oe=J||i,fe=s&&re.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&re.button===1&&re.type==="mousedown"&&(Ey(re,"react-flow__node")||Ey(re,"react-flow__edge")))return!0;if(!d&&!oe&&!a&&!c&&!s||W||!c&&re.type==="dblclick"||Ey(re,C)&&re.type==="wheel"||Ey(re,k)&&(re.type!=="wheel"||a&&re.type==="wheel"&&!J)||!s&&re.ctrlKey&&re.type==="wheel"||!oe&&!a&&!fe&&re.type==="wheel"||!d&&(re.type==="mousedown"||re.type==="touchstart")||Array.isArray(d)&&!d.includes(re.button)&&re.type==="mousedown")return!1;const ee=Array.isArray(d)&&d.includes(re.button)||!re.button||re.button<=1;return(!re.ctrlKey||re.type==="wheel")&&ee})},[W,G,i,s,a,c,d,u,J]),ln.createElement("div",{className:"react-flow__renderer",ref:V,style:UH},M)},QIe=n=>({userSelectionActive:n.userSelectionActive,userSelectionRect:n.userSelectionRect});function KIe(){const{userSelectionActive:n,userSelectionRect:e}=Xa(QIe,qc);return n&&e?ln.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function gJ(n,e){const t=e.parentNode||e.parentId,r=n.find(i=>i.id===t);if(r){const i=e.position.x+e.width-r.width,s=e.position.y+e.height-r.height;if(i>0||s>0||e.position.x<0||e.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,i>0&&(r.style.width+=i),s>0&&(r.style.height+=s),e.position.x<0){const a=Math.abs(e.position.x);r.position.x=r.position.x-a,r.style.width+=a,e.position.x=0}if(e.position.y<0){const a=Math.abs(e.position.y);r.position.y=r.position.y-a,r.style.height+=a,e.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function kge(n,e){if(n.some(r=>r.type==="reset"))return n.filter(r=>r.type==="reset").map(r=>r.item);const t=n.filter(r=>r.type==="add").map(r=>r.item);return e.reduce((r,i)=>{const s=n.filter(o=>o.id===i.id);if(s.length===0)return r.push(i),r;const a={...i};for(const o of s)if(o)switch(o.type){case"select":{a.selected=o.selected;break}case"position":{typeof o.position<"u"&&(a.position=o.position),typeof o.positionAbsolute<"u"&&(a.positionAbsolute=o.positionAbsolute),typeof o.dragging<"u"&&(a.dragging=o.dragging),a.expandParent&&gJ(r,a);break}case"dimensions":{typeof o.dimensions<"u"&&(a.width=o.dimensions.width,a.height=o.dimensions.height),typeof o.updateStyle<"u"&&(a.style={...a.style||{},...o.dimensions}),typeof o.resizing=="boolean"&&(a.resizing=o.resizing),a.expandParent&&gJ(r,a);break}case"remove":return r}return r.push(a),r},t)}function Ige(n,e){return kge(n,e)}function JIe(n,e){return kge(n,e)}const V1=(n,e)=>({id:n,type:"select",selected:e});function Qb(n,e){return n.reduce((t,r)=>{const i=e.includes(r.id);return!r.selected&&i?(r.selected=!0,t.push(V1(r.id,!0))):r.selected&&!i&&(r.selected=!1,t.push(V1(r.id,!1))),t},[])}const l9=(n,e)=>t=>{t.target===e.current&&(n==null||n(t))},eDe=n=>({userSelectionActive:n.userSelectionActive,elementsSelectable:n.elementsSelectable,dragging:n.paneDragging}),Dge=de.memo(({isSelecting:n,selectionMode:e=eS.Full,panOnDrag:t,onSelectionStart:r,onSelectionEnd:i,onPaneClick:s,onPaneContextMenu:a,onPaneScroll:o,onPaneMouseEnter:l,onPaneMouseMove:c,onPaneMouseLeave:u,children:d})=>{const h=de.useRef(null),p=gc(),g=de.useRef(0),x=de.useRef(0),_=de.useRef(),{userSelectionActive:y,elementsSelectable:M,dragging:C}=Xa(eDe,qc),k=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,x.current=0},B=K=>{s==null||s(K),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},U=K=>{if(Array.isArray(t)&&(t!=null&&t.includes(2))){K.preventDefault();return}a==null||a(K)},z=o?K=>o(K):void 0,O=K=>{const{resetSelectedElements:W,domNode:J}=p.getState();if(_.current=J==null?void 0:J.getBoundingClientRect(),!M||!n||K.button!==0||K.target!==h.current||!_.current)return;const{x:ie,y:ae}=SA(K,_.current);W(),p.setState({userSelectionRect:{width:0,height:0,startX:ie,startY:ae,x:ie,y:ae}}),r==null||r(K)},V=K=>{const{userSelectionRect:W,nodeInternals:J,edges:ie,transform:ae,onNodesChange:Q,onEdgesChange:re,nodeOrigin:oe,getNodes:fe}=p.getState();if(!n||!_.current||!W)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const ee=SA(K,_.current),me=W.startX??0,Ae=W.startY??0,be={...W,x:ee.xXe.id),ze=ge.map(Xe=>Xe.id);if(g.current!==ze.length){g.current=ze.length;const Xe=Qb(pe,ze);Xe.length&&(Q==null||Q(Xe))}if(x.current!==Te.length){x.current=Te.length;const Xe=Qb(ie,Te);Xe.length&&(re==null||re(Xe))}p.setState({userSelectionRect:be})},$=K=>{if(K.button!==0)return;const{userSelectionRect:W}=p.getState();!y&&W&&K.target===h.current&&(B==null||B(K)),p.setState({nodesSelectionActive:g.current>0}),k(),i==null||i(K)},G=K=>{y&&(p.setState({nodesSelectionActive:g.current>0}),i==null||i(K)),k()},H=M&&(n||y);return ln.createElement("div",{className:bu(["react-flow__pane",{dragging:C,selection:n}]),onClick:H?void 0:l9(B,h),onContextMenu:l9(U,h),onWheel:l9(z,h),onMouseEnter:H?void 0:l,onMouseDown:H?O:void 0,onMouseMove:H?V:c,onMouseUp:H?$:void 0,onMouseLeave:H?G:u,ref:h,style:UH},d,ln.createElement(KIe,null))});Dge.displayName="Pane";function Oge(n,e){const t=n.parentNode||n.parentId;if(!t)return!1;const r=e.get(t);return r?r.selected?!0:Oge(r,e):!1}function AJ(n,e,t){let r=n;do{if(r!=null&&r.matches(e))return!0;if(r===t.current)return!1;r=r.parentElement}while(r);return!1}function tDe(n,e,t,r){return Array.from(n.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||i.parentId||!Oge(i,n))&&(i.draggable||e&&typeof i.draggable>"u")).map(i=>{var s,a;return{id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:t.x-(((s=i.positionAbsolute)==null?void 0:s.x)??0),y:t.y-(((a=i.positionAbsolute)==null?void 0:a.y)??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode||i.parentId,parentId:i.parentNode||i.parentId,width:i.width,height:i.height,expandParent:i.expandParent}})}function nDe(n,e){return!e||e==="parent"?e:[e[0],[e[1][0]-(n.width||0),e[1][1]-(n.height||0)]]}function jge(n,e,t,r,i=[0,0],s){const a=nDe(n,n.extent||r);let o=a;const l=n.parentNode||n.parentId;if(n.extent==="parent"&&!n.expandParent)if(l&&n.width&&n.height){const d=t.get(l),{x:h,y:p}=Dx(d,i).positionAbsolute;o=d&&zf(h)&&zf(p)&&zf(d.width)&&zf(d.height)?[[h+n.width*i[0],p+n.height*i[1]],[h+d.width-n.width+n.width*i[0],p+d.height-n.height+n.height*i[1]]]:o}else s==null||s("005",Dg.error005()),o=a;else if(n.extent&&l&&n.extent!=="parent"){const d=t.get(l),{x:h,y:p}=Dx(d,i).positionAbsolute;o=[[n.extent[0][0]+h,n.extent[0][1]+p],[n.extent[1][0]+h,n.extent[1][1]+p]]}let c={x:0,y:0};if(l){const d=t.get(l);c=Dx(d,i).positionAbsolute}const u=o&&o!=="parent"?kH(e,o):e;return{position:{x:u.x-c.x,y:u.y-c.y},positionAbsolute:u}}function c9({nodeId:n,dragItems:e,nodeInternals:t}){const r=e.map(i=>({...t.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[n?r.find(i=>i.id===n):r[0],r]}const xJ=(n,e,t,r)=>{const i=e.querySelectorAll(n);if(!i||!i.length)return null;const s=Array.from(i),a=e.getBoundingClientRect(),o={x:a.width*r[0],y:a.height*r[1]};return s.map(l=>{const c=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),position:l.getAttribute("data-handlepos"),x:(c.left-a.left-o.x)/t,y:(c.top-a.top-o.y)/t,...LH(l)}})};function Aw(n,e,t){return t===void 0?t:r=>{const i=e().nodeInternals.get(n);i&&t(r,{...i})}}function Sz({id:n,store:e,unselect:t=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:s,multiSelectionActive:a,nodeInternals:o,onError:l}=e.getState(),c=o.get(n);if(!c){l==null||l("012",Dg.error012(n));return}e.setState({nodesSelectionActive:!1}),c.selected?(t||c.selected&&a)&&(s({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):i([n])}function rDe(){const n=gc();return de.useCallback(({sourceEvent:t})=>{const{transform:r,snapGrid:i,snapToGrid:s}=n.getState(),a=t.touches?t.touches[0].clientX:t.clientX,o=t.touches?t.touches[0].clientY:t.clientY,l={x:(a-r[0])/r[2],y:(o-r[1])/r[2]};return{xSnapped:s?i[0]*Math.round(l.x/i[0]):l.x,ySnapped:s?i[1]*Math.round(l.y/i[1]):l.y,...l}},[])}function u9(n){return(e,t,r)=>n==null?void 0:n(e,r)}function Fge({nodeRef:n,disabled:e=!1,noDragClassName:t,handleSelector:r,nodeId:i,isSelectable:s,selectNodesOnDrag:a}){const o=gc(),[l,c]=de.useState(!1),u=de.useRef([]),d=de.useRef({x:null,y:null}),h=de.useRef(0),p=de.useRef(null),g=de.useRef({x:0,y:0}),x=de.useRef(null),_=de.useRef(!1),y=de.useRef(!1),M=de.useRef(!1),C=rDe();return de.useEffect(()=>{if(n!=null&&n.current){const k=Xh(n.current),B=({x:O,y:V})=>{const{nodeInternals:$,onNodeDrag:G,onSelectionDrag:H,updateNodePositions:K,nodeExtent:W,snapGrid:J,snapToGrid:ie,nodeOrigin:ae,onError:Q}=o.getState();d.current={x:O,y:V};let re=!1,oe={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&W){const ee=GS(u.current,ae);oe=J4(ee)}if(u.current=u.current.map(ee=>{const me={x:O-ee.distance.x,y:V-ee.distance.y};ie&&(me.x=J[0]*Math.round(me.x/J[0]),me.y=J[1]*Math.round(me.y/J[1]));const Ae=[[W[0][0],W[0][1]],[W[1][0],W[1][1]]];u.current.length>1&&W&&!ee.extent&&(Ae[0][0]=ee.positionAbsolute.x-oe.x+W[0][0],Ae[1][0]=ee.positionAbsolute.x+(ee.width??0)-oe.x2+W[1][0],Ae[0][1]=ee.positionAbsolute.y-oe.y+W[0][1],Ae[1][1]=ee.positionAbsolute.y+(ee.height??0)-oe.y2+W[1][1]);const be=jge(ee,me,$,Ae,ae,Q);return re=re||ee.position.x!==be.position.x||ee.position.y!==be.position.y,ee.position=be.position,ee.positionAbsolute=be.positionAbsolute,ee}),!re)return;K(u.current,!0,!0),c(!0);const fe=i?G:u9(H);if(fe&&x.current){const[ee,me]=c9({nodeId:i,dragItems:u.current,nodeInternals:$});fe(x.current,ee,me)}},U=()=>{if(!p.current)return;const[O,V]=ige(g.current,p.current);if(O!==0||V!==0){const{transform:$,panBy:G}=o.getState();d.current.x=(d.current.x??0)-O/$[2],d.current.y=(d.current.y??0)-V/$[2],G({x:O,y:V})&&B(d.current)}h.current=requestAnimationFrame(U)},z=O=>{var ae;const{nodeInternals:V,multiSelectionActive:$,nodesDraggable:G,unselectNodesAndEdges:H,onNodeDragStart:K,onSelectionDragStart:W}=o.getState();y.current=!0;const J=i?K:u9(W);(!a||!s)&&!$&&i&&((ae=V.get(i))!=null&&ae.selected||H()),i&&s&&a&&Sz({id:i,store:o,nodeRef:n});const ie=C(O);if(d.current=ie,u.current=tDe(V,G,ie,i),J&&u.current){const[Q,re]=c9({nodeId:i,dragItems:u.current,nodeInternals:V});J(O.sourceEvent,Q,re)}};if(e)k.on(".drag",null);else{const O=d9e().on("start",V=>{const{domNode:$,nodeDragThreshold:G}=o.getState();G===0&&z(V),M.current=!1;const H=C(V);d.current=H,p.current=($==null?void 0:$.getBoundingClientRect())||null,g.current=SA(V.sourceEvent,p.current)}).on("drag",V=>{var K,W;const $=C(V),{autoPanOnNodeDrag:G,nodeDragThreshold:H}=o.getState();if(V.sourceEvent.type==="touchmove"&&V.sourceEvent.touches.length>1&&(M.current=!0),!M.current){if(!_.current&&y.current&&G&&(_.current=!0,U()),!y.current){const J=$.xSnapped-(((K=d==null?void 0:d.current)==null?void 0:K.x)??0),ie=$.ySnapped-(((W=d==null?void 0:d.current)==null?void 0:W.y)??0);Math.sqrt(J*J+ie*ie)>H&&z(V)}(d.current.x!==$.xSnapped||d.current.y!==$.ySnapped)&&u.current&&y.current&&(x.current=V.sourceEvent,g.current=SA(V.sourceEvent,p.current),B($))}}).on("end",V=>{if(!(!y.current||M.current)&&(c(!1),_.current=!1,y.current=!1,cancelAnimationFrame(h.current),u.current)){const{updateNodePositions:$,nodeInternals:G,onNodeDragStop:H,onSelectionDragStop:K}=o.getState(),W=i?H:u9(K);if($(u.current,!1,!1),W){const[J,ie]=c9({nodeId:i,dragItems:u.current,nodeInternals:G});W(V.sourceEvent,J,ie)}}}).filter(V=>{const $=V.target;return!V.button&&(!t||!AJ($,`.${t}`,n))&&(!r||AJ($,r,n))});return k.call(O),()=>{k.on(".drag",null)}}}},[n,e,t,r,s,o,i,a,C]),l}function Bge(){const n=gc();return de.useCallback(t=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:s,getNodes:a,snapToGrid:o,snapGrid:l,onError:c,nodesDraggable:u}=n.getState(),d=a().filter(M=>M.selected&&(M.draggable||u&&typeof M.draggable>"u")),h=o?l[0]:5,p=o?l[1]:5,g=t.isShiftPressed?4:1,x=t.x*h*g,_=t.y*p*g,y=d.map(M=>{if(M.positionAbsolute){const C={x:M.positionAbsolute.x+x,y:M.positionAbsolute.y+_};o&&(C.x=l[0]*Math.round(C.x/l[0]),C.y=l[1]*Math.round(C.y/l[1]));const{positionAbsolute:k,position:B}=jge(M,C,r,i,void 0,c);M.position=B,M.positionAbsolute=k}return M});s(y,!0,!1)},[])}const m_={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var xw=n=>{const e=({id:t,type:r,data:i,xPos:s,yPos:a,xPosOrigin:o,yPosOrigin:l,selected:c,onClick:u,onMouseEnter:d,onMouseMove:h,onMouseLeave:p,onContextMenu:g,onDoubleClick:x,style:_,className:y,isDraggable:M,isSelectable:C,isConnectable:k,isFocusable:B,selectNodesOnDrag:U,sourcePosition:z,targetPosition:O,hidden:V,resizeObserver:$,dragHandle:G,zIndex:H,isParent:K,noDragClassName:W,noPanClassName:J,initialized:ie,disableKeyboardA11y:ae,ariaLabel:Q,rfId:re,hasHandleBounds:oe})=>{const fe=gc(),ee=de.useRef(null),me=de.useRef(null),Ae=de.useRef(z),be=de.useRef(O),pe=de.useRef(r),ge=C||M||u||d||h||p,Te=Bge(),ze=Aw(t,fe.getState,d),Xe=Aw(t,fe.getState,h),Qe=Aw(t,fe.getState,p),ot=Aw(t,fe.getState,g),bt=Aw(t,fe.getState,x),ht=ft=>{const{nodeDragThreshold:et}=fe.getState();if(C&&(!U||!M||et>0)&&Sz({id:t,store:fe,nodeRef:ee}),u){const At=fe.getState().nodeInternals.get(t);At&&u(ft,{...At})}},Ce=ft=>{if(!vz(ft)&&!ae)if(lge.includes(ft.key)&&C){const et=ft.key==="Escape";Sz({id:t,store:fe,unselect:et,nodeRef:ee})}else M&&c&&Object.prototype.hasOwnProperty.call(m_,ft.key)&&(fe.setState({ariaLiveMessage:`Moved selected node ${ft.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~a}`}),Te({x:m_[ft.key].x,y:m_[ft.key].y,isShiftPressed:ft.shiftKey}))};de.useEffect(()=>()=>{me.current&&($==null||$.unobserve(me.current),me.current=null)},[]),de.useEffect(()=>{if(ee.current&&!V){const ft=ee.current;(!ie||!oe||me.current!==ft)&&(me.current&&($==null||$.unobserve(me.current)),$==null||$.observe(ft),me.current=ft)}},[V,ie,oe]),de.useEffect(()=>{const ft=pe.current!==r,et=Ae.current!==z,At=be.current!==O;ee.current&&(ft||et||At)&&(ft&&(pe.current=r),et&&(Ae.current=z),At&&(be.current=O),fe.getState().updateNodeDimensions([{id:t,nodeElement:ee.current,forceUpdate:!0}]))},[t,r,z,O]);const lt=Fge({nodeRef:ee,disabled:V||!M,noDragClassName:W,handleSelector:G,nodeId:t,isSelectable:C,selectNodesOnDrag:U});return V?null:ln.createElement("div",{className:bu(["react-flow__node",`react-flow__node-${r}`,{[J]:M},y,{selected:c,selectable:C,parent:K,dragging:lt}]),ref:ee,style:{zIndex:H,transform:`translate(${o}px,${l}px)`,pointerEvents:ge?"all":"none",visibility:ie?"visible":"hidden",..._},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:ze,onMouseMove:Xe,onMouseLeave:Qe,onContextMenu:ot,onClick:ht,onDoubleClick:bt,onKeyDown:B?Ce:void 0,tabIndex:B?0:void 0,role:B?"button":void 0,"aria-describedby":ae?void 0:`${Mge}-${re}`,"aria-label":Q},ln.createElement(AIe,{value:t},ln.createElement(n,{id:t,data:i,type:r,xPos:s,yPos:a,selected:c,isConnectable:k,sourcePosition:z,targetPosition:O,dragging:lt,dragHandle:G,zIndex:H})))};return e.displayName="NodeWrapper",de.memo(e)};const iDe=n=>{const e=n.getNodes().filter(t=>t.selected);return{...GS(e,n.nodeOrigin),transformString:`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`,userSelectionActive:n.userSelectionActive}};function sDe({onSelectionContextMenu:n,noPanClassName:e,disableKeyboardA11y:t}){const r=gc(),{width:i,height:s,x:a,y:o,transformString:l,userSelectionActive:c}=Xa(iDe,qc),u=Bge(),d=de.useRef(null);if(de.useEffect(()=>{var g;t||(g=d.current)==null||g.focus({preventScroll:!0})},[t]),Fge({nodeRef:d}),c||!i||!s)return null;const h=n?g=>{const x=r.getState().getNodes().filter(_=>_.selected);n(g,x)}:void 0,p=g=>{Object.prototype.hasOwnProperty.call(m_,g.key)&&u({x:m_[g.key].x,y:m_[g.key].y,isShiftPressed:g.shiftKey})};return ln.createElement("div",{className:bu(["react-flow__nodesselection","react-flow__container",e]),style:{transform:l}},ln.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:t?void 0:-1,onKeyDown:t?void 0:p,style:{width:i,height:s,top:o,left:a}}))}var aDe=de.memo(sDe);const oDe=n=>n.nodesSelectionActive,Uge=({children:n,onPaneClick:e,onPaneMouseEnter:t,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,deleteKeyCode:o,onMove:l,onMoveStart:c,onMoveEnd:u,selectionKeyCode:d,selectionOnDrag:h,selectionMode:p,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:_,panActivationKeyCode:y,zoomActivationKeyCode:M,elementsSelectable:C,zoomOnScroll:k,zoomOnPinch:B,panOnScroll:U,panOnScrollSpeed:z,panOnScrollMode:O,zoomOnDoubleClick:V,panOnDrag:$,defaultViewport:G,translateExtent:H,minZoom:K,maxZoom:W,preventScrolling:J,onSelectionContextMenu:ie,noWheelClassName:ae,noPanClassName:Q,disableKeyboardA11y:re})=>{const oe=Xa(oDe),fe=tS(d),ee=tS(y),me=ee||$,Ae=ee||U,be=fe||h&&me!==!0;return $Ie({deleteKeyCode:o,multiSelectionKeyCode:_}),ln.createElement(ZIe,{onMove:l,onMoveStart:c,onMoveEnd:u,onPaneContextMenu:s,elementsSelectable:C,zoomOnScroll:k,zoomOnPinch:B,panOnScroll:Ae,panOnScrollSpeed:z,panOnScrollMode:O,zoomOnDoubleClick:V,panOnDrag:!fe&&me,defaultViewport:G,translateExtent:H,minZoom:K,maxZoom:W,zoomActivationKeyCode:M,preventScrolling:J,noWheelClassName:ae,noPanClassName:Q},ln.createElement(Dge,{onSelectionStart:g,onSelectionEnd:x,onPaneClick:e,onPaneMouseEnter:t,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:me,isSelecting:!!be,selectionMode:p},n,oe&&ln.createElement(aDe,{onSelectionContextMenu:ie,noPanClassName:Q,disableKeyboardA11y:re})))};Uge.displayName="FlowRenderer";var lDe=de.memo(Uge);function cDe(n){return Xa(de.useCallback(t=>n?mge(t.nodeInternals,{x:0,y:0,width:t.width,height:t.height},t.transform,!0):t.getNodes(),[n]))}function uDe(n){const e={input:xw(n.input||Sge),default:xw(n.default||wz),output:xw(n.output||Ege),group:xw(n.group||BH)},t={},r=Object.keys(n).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,s)=>(i[s]=xw(n[s]||wz),i),t);return{...e,...r}}const dDe=({x:n,y:e,width:t,height:r,origin:i})=>!t||!r?{x:n,y:e}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:n,y:e}:{x:n-t*i[0],y:e-r*i[1]},hDe=n=>({nodesDraggable:n.nodesDraggable,nodesConnectable:n.nodesConnectable,nodesFocusable:n.nodesFocusable,elementsSelectable:n.elementsSelectable,updateNodeDimensions:n.updateNodeDimensions,onError:n.onError}),zge=n=>{const{nodesDraggable:e,nodesConnectable:t,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:s,onError:a}=Xa(hDe,qc),o=cDe(n.onlyRenderVisibleElements),l=de.useRef(),c=de.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(d=>{const h=d.map(p=>({id:p.target.getAttribute("data-id"),nodeElement:p.target,forceUpdate:!0}));s(h)});return l.current=u,u},[]);return de.useEffect(()=>()=>{var u;(u=l==null?void 0:l.current)==null||u.disconnect()},[]),ln.createElement("div",{className:"react-flow__nodes",style:UH},o.map(u=>{var B,U,z;let d=u.type||"default";n.nodeTypes[d]||(a==null||a("003",Dg.error003(d)),d="default");const h=n.nodeTypes[d]||n.nodeTypes.default,p=!!(u.draggable||e&&typeof u.draggable>"u"),g=!!(u.selectable||i&&typeof u.selectable>"u"),x=!!(u.connectable||t&&typeof u.connectable>"u"),_=!!(u.focusable||r&&typeof u.focusable>"u"),y=n.nodeExtent?kH(u.positionAbsolute,n.nodeExtent):u.positionAbsolute,M=(y==null?void 0:y.x)??0,C=(y==null?void 0:y.y)??0,k=dDe({x:M,y:C,width:u.width??0,height:u.height??0,origin:n.nodeOrigin});return ln.createElement(h,{key:u.id,id:u.id,className:u.className,style:u.style,type:d,data:u.data,sourcePosition:u.sourcePosition||Tr.Bottom,targetPosition:u.targetPosition||Tr.Top,hidden:u.hidden,xPos:M,yPos:C,xPosOrigin:k.x,yPosOrigin:k.y,selectNodesOnDrag:n.selectNodesOnDrag,onClick:n.onNodeClick,onMouseEnter:n.onNodeMouseEnter,onMouseMove:n.onNodeMouseMove,onMouseLeave:n.onNodeMouseLeave,onContextMenu:n.onNodeContextMenu,onDoubleClick:n.onNodeDoubleClick,selected:!!u.selected,isDraggable:p,isSelectable:g,isConnectable:x,isFocusable:_,resizeObserver:c,dragHandle:u.dragHandle,zIndex:((B=u[Al])==null?void 0:B.z)??0,isParent:!!((U=u[Al])!=null&&U.isParent),noDragClassName:n.noDragClassName,noPanClassName:n.noPanClassName,initialized:!!u.width&&!!u.height,rfId:n.rfId,disableKeyboardA11y:n.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!((z=u[Al])!=null&&z.handleBounds)})}))};zge.displayName="NodeRenderer";var fDe=de.memo(zge);const pDe=(n,e,t)=>t===Tr.Left?n-e:t===Tr.Right?n+e:n,mDe=(n,e,t)=>t===Tr.Top?n-e:t===Tr.Bottom?n+e:n,vJ="react-flow__edgeupdater",yJ=({position:n,centerX:e,centerY:t,radius:r=10,onMouseDown:i,onMouseEnter:s,onMouseOut:a,type:o})=>ln.createElement("circle",{onMouseDown:i,onMouseEnter:s,onMouseOut:a,className:bu([vJ,`${vJ}-${o}`]),cx:pDe(e,r,n),cy:mDe(t,r,n),r,stroke:"transparent",fill:"transparent"}),gDe=()=>!0;var Ny=n=>{const e=({id:t,className:r,type:i,data:s,onClick:a,onEdgeDoubleClick:o,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,style:_,source:y,target:M,sourceX:C,sourceY:k,targetX:B,targetY:U,sourcePosition:z,targetPosition:O,elementsSelectable:V,hidden:$,sourceHandleId:G,targetHandleId:H,onContextMenu:K,onMouseEnter:W,onMouseMove:J,onMouseLeave:ie,reconnectRadius:ae,onReconnect:Q,onReconnectStart:re,onReconnectEnd:oe,markerEnd:fe,markerStart:ee,rfId:me,ariaLabel:Ae,isFocusable:be,isReconnectable:pe,pathOptions:ge,interactionWidth:Te,disableKeyboardA11y:ze})=>{const Xe=de.useRef(null),[Qe,ot]=de.useState(!1),[bt,ht]=de.useState(!1),Ce=gc(),lt=de.useMemo(()=>`url('#${bz(ee,me)}')`,[ee,me]),ft=de.useMemo(()=>`url('#${bz(fe,me)}')`,[fe,me]);if($)return null;const et=vt=>{var Pe;const{edges:Ut,addSelectedEdges:dt,unselectNodesAndEdges:mt,multiSelectionActive:Ft}=Ce.getState(),tt=Ut.find(nt=>nt.id===t);tt&&(V&&(Ce.setState({nodesSelectionActive:!1}),tt.selected&&Ft?(mt({nodes:[],edges:[tt]}),(Pe=Xe.current)==null||Pe.blur()):dt([t])),a&&a(vt,tt))},At=gw(t,Ce.getState,o),Lt=gw(t,Ce.getState,K),st=gw(t,Ce.getState,W),Ht=gw(t,Ce.getState,J),Se=gw(t,Ce.getState,ie),_t=(vt,Ut)=>{if(vt.button!==0)return;const{edges:dt,isValidConnection:mt}=Ce.getState(),Ft=Ut?M:y,tt=(Ut?H:G)||null,Pe=Ut?"target":"source",nt=mt||gDe,qe=Ut,yt=dt.find(pt=>pt.id===t);ht(!0),re==null||re(vt,yt,Pe);const Qt=pt=>{ht(!1),oe==null||oe(pt,yt,Pe)};yge({event:vt,handleId:tt,nodeId:Ft,onConnect:pt=>Q==null?void 0:Q(yt,pt),isTarget:qe,getState:Ce.getState,setState:Ce.setState,isValidConnection:nt,edgeUpdaterType:Pe,onReconnectEnd:Qt})},It=vt=>_t(vt,!0),De=vt=>_t(vt,!1),ue=()=>ot(!0),Ve=()=>ot(!1),We=!V&&!a,ct=vt=>{var Ut;if(!ze&&lge.includes(vt.key)&&V){const{unselectNodesAndEdges:dt,addSelectedEdges:mt,edges:Ft}=Ce.getState();vt.key==="Escape"?((Ut=Xe.current)==null||Ut.blur(),dt({edges:[Ft.find(Pe=>Pe.id===t)]})):mt([t])}};return ln.createElement("g",{className:bu(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:l,animated:c,inactive:We,updating:Qe}]),onClick:et,onDoubleClick:At,onContextMenu:Lt,onMouseEnter:st,onMouseMove:Ht,onMouseLeave:Se,onKeyDown:be?ct:void 0,tabIndex:be?0:void 0,role:be?"button":"img","data-testid":`rf__edge-${t}`,"aria-label":Ae===null?void 0:Ae||`Edge from ${y} to ${M}`,"aria-describedby":be?`${Cge}-${me}`:void 0,ref:Xe},!bt&&ln.createElement(n,{id:t,source:y,target:M,selected:l,animated:c,label:u,labelStyle:d,labelShowBg:h,labelBgStyle:p,labelBgPadding:g,labelBgBorderRadius:x,data:s,style:_,sourceX:C,sourceY:k,targetX:B,targetY:U,sourcePosition:z,targetPosition:O,sourceHandleId:G,targetHandleId:H,markerStart:lt,markerEnd:ft,pathOptions:ge,interactionWidth:Te}),pe&&ln.createElement(ln.Fragment,null,(pe==="source"||pe===!0)&&ln.createElement(yJ,{position:z,centerX:C,centerY:k,radius:ae,onMouseDown:It,onMouseEnter:ue,onMouseOut:Ve,type:"source"}),(pe==="target"||pe===!0)&&ln.createElement(yJ,{position:O,centerX:B,centerY:U,radius:ae,onMouseDown:De,onMouseEnter:ue,onMouseOut:Ve,type:"target"})))};return e.displayName="EdgeWrapper",de.memo(e)};function ADe(n){const e={default:Ny(n.default||kM),straight:Ny(n.bezier||OH),step:Ny(n.step||DH),smoothstep:Ny(n.step||B7),simplebezier:Ny(n.simplebezier||IH)},t={},r=Object.keys(n).filter(i=>!["default","bezier"].includes(i)).reduce((i,s)=>(i[s]=Ny(n[s]||kM),i),t);return{...e,...r}}function bJ(n,e,t=null){const r=((t==null?void 0:t.x)||0)+e.x,i=((t==null?void 0:t.y)||0)+e.y,s=(t==null?void 0:t.width)||e.width,a=(t==null?void 0:t.height)||e.height;switch(n){case Tr.Top:return{x:r+s/2,y:i};case Tr.Right:return{x:r+s,y:i+a/2};case Tr.Bottom:return{x:r+s/2,y:i+a};case Tr.Left:return{x:r,y:i+a/2}}}function _J(n,e){return n?n.length===1||!e?n[0]:e&&n.find(t=>t.id===e)||null:null}const xDe=(n,e,t,r,i,s)=>{const a=bJ(t,n,e),o=bJ(s,r,i);return{sourceX:a.x,sourceY:a.y,targetX:o.x,targetY:o.y}};function vDe({sourcePos:n,targetPos:e,sourceWidth:t,sourceHeight:r,targetWidth:i,targetHeight:s,width:a,height:o,transform:l}){const c={x:Math.min(n.x,e.x),y:Math.min(n.y,e.y),x2:Math.max(n.x+t,e.x+i),y2:Math.max(n.y+r,e.y+s)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const u=J4({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:a/l[2],height:o/l[2]}),d=Math.max(0,Math.min(u.x2,c.x2)-Math.max(u.x,c.x)),h=Math.max(0,Math.min(u.y2,c.y2)-Math.max(u.y,c.y));return Math.ceil(d*h)>0}function wJ(n){var r,i,s,a,o;const e=((r=n==null?void 0:n[Al])==null?void 0:r.handleBounds)||null,t=e&&(n==null?void 0:n.width)&&(n==null?void 0:n.height)&&typeof((i=n==null?void 0:n.positionAbsolute)==null?void 0:i.x)<"u"&&typeof((s=n==null?void 0:n.positionAbsolute)==null?void 0:s.y)<"u";return[{x:((a=n==null?void 0:n.positionAbsolute)==null?void 0:a.x)||0,y:((o=n==null?void 0:n.positionAbsolute)==null?void 0:o.y)||0,width:(n==null?void 0:n.width)||0,height:(n==null?void 0:n.height)||0},e,!!t]}const yDe=[{level:0,isMaxLevel:!0,edges:[]}];function bDe(n,e,t=!1){let r=-1;const i=n.reduce((a,o)=>{var u,d;const l=zf(o.zIndex);let c=l?o.zIndex:0;if(t){const h=e.get(o.target),p=e.get(o.source),g=o.selected||(h==null?void 0:h.selected)||(p==null?void 0:p.selected),x=Math.max(((u=p==null?void 0:p[Al])==null?void 0:u.z)||0,((d=h==null?void 0:h[Al])==null?void 0:d.z)||0,1e3);c=(l?o.zIndex:0)+(g?x:0)}return a[c]?a[c].push(o):a[c]=[o],r=c>r?c:r,a},{}),s=Object.entries(i).map(([a,o])=>{const l=+a;return{edges:o,level:l,isMaxLevel:l===r}});return s.length===0?yDe:s}function _De(n,e,t){const r=Xa(de.useCallback(i=>n?i.edges.filter(s=>{const a=e.get(s.source),o=e.get(s.target);return(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&(o==null?void 0:o.width)&&(o==null?void 0:o.height)&&vDe({sourcePos:a.positionAbsolute||{x:0,y:0},targetPos:o.positionAbsolute||{x:0,y:0},sourceWidth:a.width,sourceHeight:a.height,targetWidth:o.width,targetHeight:o.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[n,e]));return bDe(r,e,t)}const wDe=({color:n="none",strokeWidth:e=1})=>ln.createElement("polyline",{style:{stroke:n,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),SDe=({color:n="none",strokeWidth:e=1})=>ln.createElement("polyline",{style:{stroke:n,fill:n,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),SJ={[aA.Arrow]:wDe,[aA.ArrowClosed]:SDe};function TDe(n){const e=gc();return de.useMemo(()=>{var i,s;return Object.prototype.hasOwnProperty.call(SJ,n)?SJ[n]:((s=(i=e.getState()).onError)==null||s.call(i,"009",Dg.error009(n)),null)},[n])}const EDe=({id:n,type:e,color:t,width:r=12.5,height:i=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:o="auto-start-reverse"})=>{const l=TDe(e);return l?ln.createElement("marker",{className:"react-flow__arrowhead",id:n,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:o,refX:"0",refY:"0"},ln.createElement(l,{color:t,strokeWidth:a})):null},NDe=({defaultColor:n,rfId:e})=>t=>{const r=[];return t.edges.reduce((i,s)=>([s.markerStart,s.markerEnd].forEach(a=>{if(a&&typeof a=="object"){const o=bz(a,e);r.includes(o)||(i.push({id:o,color:a.color||n,...a}),r.push(o))}}),i),[]).sort((i,s)=>i.id.localeCompare(s.id))},Vge=({defaultColor:n,rfId:e})=>{const t=Xa(de.useCallback(NDe({defaultColor:n,rfId:e}),[n,e]),(r,i)=>!(r.length!==i.length||r.some((s,a)=>s.id!==i[a].id)));return ln.createElement("defs",null,t.map(r=>ln.createElement(EDe,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};Vge.displayName="MarkerDefinitions";var MDe=de.memo(Vge);const CDe=n=>({nodesConnectable:n.nodesConnectable,edgesFocusable:n.edgesFocusable,edgesUpdatable:n.edgesUpdatable,elementsSelectable:n.elementsSelectable,width:n.width,height:n.height,connectionMode:n.connectionMode,nodeInternals:n.nodeInternals,onError:n.onError}),qge=({defaultMarkerColor:n,onlyRenderVisibleElements:e,elevateEdgesOnSelect:t,rfId:r,edgeTypes:i,noPanClassName:s,onEdgeContextMenu:a,onEdgeMouseEnter:o,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:u,onEdgeDoubleClick:d,onReconnect:h,onReconnectStart:p,onReconnectEnd:g,reconnectRadius:x,children:_,disableKeyboardA11y:y})=>{const{edgesFocusable:M,edgesUpdatable:C,elementsSelectable:k,width:B,height:U,connectionMode:z,nodeInternals:O,onError:V}=Xa(CDe,qc),$=_De(e,O,t);return B?ln.createElement(ln.Fragment,null,$.map(({level:G,edges:H,isMaxLevel:K})=>ln.createElement("svg",{key:G,style:{zIndex:G},width:B,height:U,className:"react-flow__edges react-flow__container"},K&&ln.createElement(MDe,{defaultColor:n,rfId:r}),ln.createElement("g",null,H.map(W=>{const[J,ie,ae]=wJ(O.get(W.source)),[Q,re,oe]=wJ(O.get(W.target));if(!ae||!oe)return null;let fe=W.type||"default";i[fe]||(V==null||V("011",Dg.error011(fe)),fe="default");const ee=i[fe]||i.default,me=z===Jx.Strict?re.target:(re.target??[]).concat(re.source??[]),Ae=_J(ie.source,W.sourceHandle),be=_J(me,W.targetHandle),pe=(Ae==null?void 0:Ae.position)||Tr.Bottom,ge=(be==null?void 0:be.position)||Tr.Top,Te=!!(W.focusable||M&&typeof W.focusable>"u"),ze=W.reconnectable||W.updatable,Xe=typeof h<"u"&&(ze||C&&typeof ze>"u");if(!Ae||!be)return V==null||V("008",Dg.error008(Ae,W)),null;const{sourceX:Qe,sourceY:ot,targetX:bt,targetY:ht}=xDe(J,Ae,pe,Q,be,ge);return ln.createElement(ee,{key:W.id,id:W.id,className:bu([W.className,s]),type:fe,data:W.data,selected:!!W.selected,animated:!!W.animated,hidden:!!W.hidden,label:W.label,labelStyle:W.labelStyle,labelShowBg:W.labelShowBg,labelBgStyle:W.labelBgStyle,labelBgPadding:W.labelBgPadding,labelBgBorderRadius:W.labelBgBorderRadius,style:W.style,source:W.source,target:W.target,sourceHandleId:W.sourceHandle,targetHandleId:W.targetHandle,markerEnd:W.markerEnd,markerStart:W.markerStart,sourceX:Qe,sourceY:ot,targetX:bt,targetY:ht,sourcePosition:pe,targetPosition:ge,elementsSelectable:k,onContextMenu:a,onMouseEnter:o,onMouseMove:l,onMouseLeave:c,onClick:u,onEdgeDoubleClick:d,onReconnect:h,onReconnectStart:p,onReconnectEnd:g,reconnectRadius:x,rfId:r,ariaLabel:W.ariaLabel,isFocusable:Te,isReconnectable:Xe,pathOptions:"pathOptions"in W?W.pathOptions:void 0,interactionWidth:W.interactionWidth,disableKeyboardA11y:y})})))),_):null};qge.displayName="EdgeRenderer";var PDe=de.memo(qge);const RDe=n=>`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`;function LDe({children:n}){const e=Xa(RDe);return ln.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},n)}function kDe(n){const e=U7(),t=de.useRef(!1);de.useEffect(()=>{!t.current&&e.viewportInitialized&&n&&(setTimeout(()=>n(e),1),t.current=!0)},[n,e.viewportInitialized])}const IDe={[Tr.Left]:Tr.Right,[Tr.Right]:Tr.Left,[Tr.Top]:Tr.Bottom,[Tr.Bottom]:Tr.Top},Gge=({nodeId:n,handleType:e,style:t,type:r=Z1.Bezier,CustomComponent:i,connectionStatus:s})=>{var U,z,O;const{fromNode:a,handleId:o,toX:l,toY:c,connectionMode:u}=Xa(de.useCallback(V=>({fromNode:V.nodeInternals.get(n),handleId:V.connectionHandleId,toX:(V.connectionPosition.x-V.transform[0])/V.transform[2],toY:(V.connectionPosition.y-V.transform[1])/V.transform[2],connectionMode:V.connectionMode}),[n]),qc),d=(U=a==null?void 0:a[Al])==null?void 0:U.handleBounds;let h=d==null?void 0:d[e];if(u===Jx.Loose&&(h=h||(d==null?void 0:d[e==="source"?"target":"source"])),!a||!h)return null;const p=o?h.find(V=>V.id===o):h[0],g=p?p.x+p.width/2:(a.width??0)/2,x=p?p.y+p.height/2:a.height??0,_=(((z=a.positionAbsolute)==null?void 0:z.x)??0)+g,y=(((O=a.positionAbsolute)==null?void 0:O.y)??0)+x,M=p==null?void 0:p.position,C=M?IDe[M]:null;if(!M||!C)return null;if(i)return ln.createElement(i,{connectionLineType:r,connectionLineStyle:t,fromNode:a,fromHandle:p,fromX:_,fromY:y,toX:l,toY:c,fromPosition:M,toPosition:C,connectionStatus:s});let k="";const B={sourceX:_,sourceY:y,sourcePosition:M,targetX:l,targetY:c,targetPosition:C};return r===Z1.Bezier?[k]=fge(B):r===Z1.Step?[k]=yz({...B,borderRadius:0}):r===Z1.SmoothStep?[k]=yz(B):r===Z1.SimpleBezier?[k]=hge(B):k=`M${_},${y} ${l},${c}`,ln.createElement("path",{d:k,fill:"none",className:"react-flow__connection-path",style:t})};Gge.displayName="ConnectionLine";const DDe=n=>({nodeId:n.connectionNodeId,handleType:n.connectionHandleType,nodesConnectable:n.nodesConnectable,connectionStatus:n.connectionStatus,width:n.width,height:n.height});function ODe({containerStyle:n,style:e,type:t,component:r}){const{nodeId:i,handleType:s,nodesConnectable:a,width:o,height:l,connectionStatus:c}=Xa(DDe,qc);return!(i&&s&&o&&a)?null:ln.createElement("svg",{style:n,width:o,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},ln.createElement("g",{className:bu(["react-flow__connection",c])},ln.createElement(Gge,{nodeId:i,handleType:s,style:e,type:t,CustomComponent:r,connectionStatus:c})))}function TJ(n,e){return de.useRef(null),gc(),de.useMemo(()=>e(n),[n])}const Hge=({nodeTypes:n,edgeTypes:e,onMove:t,onMoveStart:r,onMoveEnd:i,onInit:s,onNodeClick:a,onEdgeClick:o,onNodeDoubleClick:l,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:p,onSelectionContextMenu:g,onSelectionStart:x,onSelectionEnd:_,connectionLineType:y,connectionLineStyle:M,connectionLineComponent:C,connectionLineContainerStyle:k,selectionKeyCode:B,selectionOnDrag:U,selectionMode:z,multiSelectionKeyCode:O,panActivationKeyCode:V,zoomActivationKeyCode:$,deleteKeyCode:G,onlyRenderVisibleElements:H,elementsSelectable:K,selectNodesOnDrag:W,defaultViewport:J,translateExtent:ie,minZoom:ae,maxZoom:Q,preventScrolling:re,defaultMarkerColor:oe,zoomOnScroll:fe,zoomOnPinch:ee,panOnScroll:me,panOnScrollSpeed:Ae,panOnScrollMode:be,zoomOnDoubleClick:pe,panOnDrag:ge,onPaneClick:Te,onPaneMouseEnter:ze,onPaneMouseMove:Xe,onPaneMouseLeave:Qe,onPaneScroll:ot,onPaneContextMenu:bt,onEdgeContextMenu:ht,onEdgeMouseEnter:Ce,onEdgeMouseMove:lt,onEdgeMouseLeave:ft,onReconnect:et,onReconnectStart:At,onReconnectEnd:Lt,reconnectRadius:st,noDragClassName:Ht,noWheelClassName:Se,noPanClassName:_t,elevateEdgesOnSelect:It,disableKeyboardA11y:De,nodeOrigin:ue,nodeExtent:Ve,rfId:We})=>{const ct=TJ(n,uDe),vt=TJ(e,ADe);return kDe(s),ln.createElement(lDe,{onPaneClick:Te,onPaneMouseEnter:ze,onPaneMouseMove:Xe,onPaneMouseLeave:Qe,onPaneContextMenu:bt,onPaneScroll:ot,deleteKeyCode:G,selectionKeyCode:B,selectionOnDrag:U,selectionMode:z,onSelectionStart:x,onSelectionEnd:_,multiSelectionKeyCode:O,panActivationKeyCode:V,zoomActivationKeyCode:$,elementsSelectable:K,onMove:t,onMoveStart:r,onMoveEnd:i,zoomOnScroll:fe,zoomOnPinch:ee,zoomOnDoubleClick:pe,panOnScroll:me,panOnScrollSpeed:Ae,panOnScrollMode:be,panOnDrag:ge,defaultViewport:J,translateExtent:ie,minZoom:ae,maxZoom:Q,onSelectionContextMenu:g,preventScrolling:re,noDragClassName:Ht,noWheelClassName:Se,noPanClassName:_t,disableKeyboardA11y:De},ln.createElement(LDe,null,ln.createElement(PDe,{edgeTypes:vt,onEdgeClick:o,onEdgeDoubleClick:c,onlyRenderVisibleElements:H,onEdgeContextMenu:ht,onEdgeMouseEnter:Ce,onEdgeMouseMove:lt,onEdgeMouseLeave:ft,onReconnect:et,onReconnectStart:At,onReconnectEnd:Lt,reconnectRadius:st,defaultMarkerColor:oe,noPanClassName:_t,elevateEdgesOnSelect:!!It,disableKeyboardA11y:De,rfId:We},ln.createElement(ODe,{style:M,type:y,component:C,containerStyle:k})),ln.createElement("div",{className:"react-flow__edgelabel-renderer"}),ln.createElement(fDe,{nodeTypes:ct,onNodeClick:a,onNodeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:p,selectNodesOnDrag:W,onlyRenderVisibleElements:H,noPanClassName:_t,noDragClassName:Ht,disableKeyboardA11y:De,nodeOrigin:ue,nodeExtent:Ve,rfId:We})))};Hge.displayName="GraphView";var jDe=de.memo(Hge);const Tz=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],g1={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Tz,nodeExtent:Tz,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Jx.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:dIe,isValidConnection:void 0},FDe=()=>wRe((n,e)=>({...g1,setNodes:t=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:s}=e();n({nodeInternals:o9(t,r,i,s)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:t=>{const{defaultEdgeOptions:r={}}=e();n({edges:t.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(t,r)=>{const i=typeof t<"u",s=typeof r<"u",a=i?o9(t,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;n({nodeInternals:a,edges:s?r:[],hasDefaultNodes:i,hasDefaultEdges:s})},updateNodeDimensions:t=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:s,fitViewOnInitDone:a,fitViewOnInitOptions:o,domNode:l,nodeOrigin:c}=e(),u=l==null?void 0:l.querySelector(".react-flow__viewport");if(!u)return;const d=window.getComputedStyle(u),{m22:h}=new window.DOMMatrixReadOnly(d.transform),p=t.reduce((x,_)=>{const y=i.get(_.id);if(y!=null&&y.hidden)i.set(y.id,{...y,[Al]:{...y[Al],handleBounds:void 0}});else if(y){const M=LH(_.nodeElement);!!(M.width&&M.height&&(y.width!==M.width||y.height!==M.height||_.forceUpdate))&&(i.set(y.id,{...y,[Al]:{...y[Al],handleBounds:{source:xJ(".source",_.nodeElement,h,c),target:xJ(".target",_.nodeElement,h,c)}},...M}),x.push({id:y.id,type:"dimensions",dimensions:M}))}return x},[]);Rge(i,c);const g=a||s&&!a&&Lge(e,{initial:!0,...o});n({nodeInternals:new Map(i),fitViewOnInitDone:g}),(p==null?void 0:p.length)>0&&(r==null||r(p))},updateNodePositions:(t,r=!0,i=!1)=>{const{triggerNodeChanges:s}=e(),a=t.map(o=>{const l={id:o.id,type:"position",dragging:i};return r&&(l.positionAbsolute=o.positionAbsolute,l.position=o.position),l});s(a)},triggerNodeChanges:t=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:s,nodeOrigin:a,getNodes:o,elevateNodesOnSelect:l}=e();if(t!=null&&t.length){if(s){const c=Ige(t,o()),u=o9(c,i,a,l);n({nodeInternals:u})}r==null||r(t)}},addSelectedNodes:t=>{const{multiSelectionActive:r,edges:i,getNodes:s}=e();let a,o=null;r?a=t.map(l=>V1(l,!0)):(a=Qb(s(),t),o=Qb(i,[])),pT({changedNodes:a,changedEdges:o,get:e,set:n})},addSelectedEdges:t=>{const{multiSelectionActive:r,edges:i,getNodes:s}=e();let a,o=null;r?a=t.map(l=>V1(l,!0)):(a=Qb(i,t),o=Qb(s(),[])),pT({changedNodes:o,changedEdges:a,get:e,set:n})},unselectNodesAndEdges:({nodes:t,edges:r}={})=>{const{edges:i,getNodes:s}=e(),a=t||s(),o=r||i,l=a.map(u=>(u.selected=!1,V1(u.id,!1))),c=o.map(u=>V1(u.id,!1));pT({changedNodes:l,changedEdges:c,get:e,set:n})},setMinZoom:t=>{const{d3Zoom:r,maxZoom:i}=e();r==null||r.scaleExtent([t,i]),n({minZoom:t})},setMaxZoom:t=>{const{d3Zoom:r,minZoom:i}=e();r==null||r.scaleExtent([i,t]),n({maxZoom:t})},setTranslateExtent:t=>{var r;(r=e().d3Zoom)==null||r.translateExtent(t),n({translateExtent:t})},resetSelectedElements:()=>{const{edges:t,getNodes:r}=e(),s=r().filter(o=>o.selected).map(o=>V1(o.id,!1)),a=t.filter(o=>o.selected).map(o=>V1(o.id,!1));pT({changedNodes:s,changedEdges:a,get:e,set:n})},setNodeExtent:t=>{const{nodeInternals:r}=e();r.forEach(i=>{i.positionAbsolute=kH(i.position,t)}),n({nodeExtent:t,nodeInternals:new Map(r)})},panBy:t=>{const{transform:r,width:i,height:s,d3Zoom:a,d3Selection:o,translateExtent:l}=e();if(!a||!o||!t.x&&!t.y)return!1;const c=mg.translate(r[0]+t.x,r[1]+t.y).scale(r[2]),u=[[0,0],[i,s]],d=a==null?void 0:a.constrain()(c,u,l);return a.transform(o,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>n({connectionNodeId:g1.connectionNodeId,connectionHandleId:g1.connectionHandleId,connectionHandleType:g1.connectionHandleType,connectionStatus:g1.connectionStatus,connectionStartHandle:g1.connectionStartHandle,connectionEndHandle:g1.connectionEndHandle}),reset:()=>n({...g1})}),Object.is),zH=({children:n})=>{const e=de.useRef(null);return e.current||(e.current=FDe()),ln.createElement(iIe,{value:e.current},n)};zH.displayName="ReactFlowProvider";const $ge=({children:n})=>de.useContext(F7)?ln.createElement(ln.Fragment,null,n):ln.createElement(zH,null,n);$ge.displayName="ReactFlowWrapper";const BDe={input:Sge,default:wz,output:Ege,group:BH},UDe={default:kM,straight:OH,step:DH,smoothstep:B7,simplebezier:IH},zDe=[0,0],VDe=[15,15],qDe={x:0,y:0,zoom:1},GDe={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Wge=de.forwardRef(({nodes:n,edges:e,defaultNodes:t,defaultEdges:r,className:i,nodeTypes:s=BDe,edgeTypes:a=UDe,onNodeClick:o,onEdgeClick:l,onInit:c,onMove:u,onMoveStart:d,onMoveEnd:h,onConnect:p,onConnectStart:g,onConnectEnd:x,onClickConnectStart:_,onClickConnectEnd:y,onNodeMouseEnter:M,onNodeMouseMove:C,onNodeMouseLeave:k,onNodeContextMenu:B,onNodeDoubleClick:U,onNodeDragStart:z,onNodeDrag:O,onNodeDragStop:V,onNodesDelete:$,onEdgesDelete:G,onSelectionChange:H,onSelectionDragStart:K,onSelectionDrag:W,onSelectionDragStop:J,onSelectionContextMenu:ie,onSelectionStart:ae,onSelectionEnd:Q,connectionMode:re=Jx.Strict,connectionLineType:oe=Z1.Bezier,connectionLineStyle:fe,connectionLineComponent:ee,connectionLineContainerStyle:me,deleteKeyCode:Ae="Backspace",selectionKeyCode:be="Shift",selectionOnDrag:pe=!1,selectionMode:ge=eS.Full,panActivationKeyCode:Te="Space",multiSelectionKeyCode:ze=LM()?"Meta":"Control",zoomActivationKeyCode:Xe=LM()?"Meta":"Control",snapToGrid:Qe=!1,snapGrid:ot=VDe,onlyRenderVisibleElements:bt=!1,selectNodesOnDrag:ht=!0,nodesDraggable:Ce,nodesConnectable:lt,nodesFocusable:ft,nodeOrigin:et=zDe,edgesFocusable:At,edgesUpdatable:Lt,elementsSelectable:st,defaultViewport:Ht=qDe,minZoom:Se=.5,maxZoom:_t=2,translateExtent:It=Tz,preventScrolling:De=!0,nodeExtent:ue,defaultMarkerColor:Ve="#b1b1b7",zoomOnScroll:We=!0,zoomOnPinch:ct=!0,panOnScroll:vt=!1,panOnScrollSpeed:Ut=.5,panOnScrollMode:dt=bx.Free,zoomOnDoubleClick:mt=!0,panOnDrag:Ft=!0,onPaneClick:tt,onPaneMouseEnter:Pe,onPaneMouseMove:nt,onPaneMouseLeave:qe,onPaneScroll:yt,onPaneContextMenu:Qt,children:Be,onEdgeContextMenu:pt,onEdgeDoubleClick:rt,onEdgeMouseEnter:zt,onEdgeMouseMove:Yt,onEdgeMouseLeave:Bt,onEdgeUpdate:$e,onEdgeUpdateStart:ut,onEdgeUpdateEnd:Gt,onReconnect:it,onReconnectStart:Ot,onReconnectEnd:nn,reconnectRadius:Nt=10,edgeUpdaterRadius:m=10,onNodesChange:Ie,onEdgesChange:An,noDragClassName:Ln="nodrag",noWheelClassName:Rn="nowheel",noPanClassName:Mn="nopan",fitView:Cn=!1,fitViewOptions:Hn,connectOnClick:lr=!0,attributionPosition:jr,proOptions:Qr,defaultEdgeOptions:Os,elevateNodesOnSelect:la=!0,elevateEdgesOnSelect:Pi=!1,disableKeyboardA11y:ra=!1,autoPanOnConnect:cs=!0,autoPanOnNodeDrag:Jn=!0,connectionRadius:wa=20,isValidConnection:Ii,onError:Ge,style:wt,id:_e,nodeDragThreshold:Dt,...Xt},vn)=>{const Sn=_e||"1";return ln.createElement("div",{...Xt,style:{...wt,...GDe},ref:vn,className:bu(["react-flow",i]),"data-testid":"rf__wrapper",id:_e},ln.createElement($ge,null,ln.createElement(jDe,{onInit:c,onMove:u,onMoveStart:d,onMoveEnd:h,onNodeClick:o,onEdgeClick:l,onNodeMouseEnter:M,onNodeMouseMove:C,onNodeMouseLeave:k,onNodeContextMenu:B,onNodeDoubleClick:U,nodeTypes:s,edgeTypes:a,connectionLineType:oe,connectionLineStyle:fe,connectionLineComponent:ee,connectionLineContainerStyle:me,selectionKeyCode:be,selectionOnDrag:pe,selectionMode:ge,deleteKeyCode:Ae,multiSelectionKeyCode:ze,panActivationKeyCode:Te,zoomActivationKeyCode:Xe,onlyRenderVisibleElements:bt,selectNodesOnDrag:ht,defaultViewport:Ht,translateExtent:It,minZoom:Se,maxZoom:_t,preventScrolling:De,zoomOnScroll:We,zoomOnPinch:ct,zoomOnDoubleClick:mt,panOnScroll:vt,panOnScrollSpeed:Ut,panOnScrollMode:dt,panOnDrag:Ft,onPaneClick:tt,onPaneMouseEnter:Pe,onPaneMouseMove:nt,onPaneMouseLeave:qe,onPaneScroll:yt,onPaneContextMenu:Qt,onSelectionContextMenu:ie,onSelectionStart:ae,onSelectionEnd:Q,onEdgeContextMenu:pt,onEdgeDoubleClick:rt,onEdgeMouseEnter:zt,onEdgeMouseMove:Yt,onEdgeMouseLeave:Bt,onReconnect:it??$e,onReconnectStart:Ot??ut,onReconnectEnd:nn??Gt,reconnectRadius:Nt??m,defaultMarkerColor:Ve,noDragClassName:Ln,noWheelClassName:Rn,noPanClassName:Mn,elevateEdgesOnSelect:Pi,rfId:Sn,disableKeyboardA11y:ra,nodeOrigin:et,nodeExtent:ue}),ln.createElement(IIe,{nodes:n,edges:e,defaultNodes:t,defaultEdges:r,onConnect:p,onConnectStart:g,onConnectEnd:x,onClickConnectStart:_,onClickConnectEnd:y,nodesDraggable:Ce,nodesConnectable:lt,nodesFocusable:ft,edgesFocusable:At,edgesUpdatable:Lt,elementsSelectable:st,elevateNodesOnSelect:la,minZoom:Se,maxZoom:_t,nodeExtent:ue,onNodesChange:Ie,onEdgesChange:An,snapToGrid:Qe,snapGrid:ot,connectionMode:re,translateExtent:It,connectOnClick:lr,defaultEdgeOptions:Os,fitView:Cn,fitViewOptions:Hn,onNodesDelete:$,onEdgesDelete:G,onNodeDragStart:z,onNodeDrag:O,onNodeDragStop:V,onSelectionDrag:W,onSelectionDragStart:K,onSelectionDragStop:J,noPanClassName:Mn,nodeOrigin:et,rfId:Sn,autoPanOnConnect:cs,autoPanOnNodeDrag:Jn,onError:Ge,connectionRadius:wa,isValidConnection:Ii,nodeDragThreshold:Dt}),ln.createElement(LIe,{onSelectionChange:H}),Be,ln.createElement(aIe,{proOptions:Qr,position:jr}),ln.createElement(BIe,{rfId:Sn,disableKeyboardA11y:ra})))});Wge.displayName="ReactFlow";const Xge=({id:n,x:e,y:t,width:r,height:i,style:s,color:a,strokeColor:o,strokeWidth:l,className:c,borderRadius:u,shapeRendering:d,onClick:h,selected:p})=>{const{background:g,backgroundColor:x}=s||{},_=a||g||x;return ln.createElement("rect",{className:bu(["react-flow__minimap-node",{selected:p},c]),x:e,y:t,rx:u,ry:u,width:r,height:i,fill:_,stroke:o,strokeWidth:l,shapeRendering:d,onClick:h?y=>h(y,n):void 0})};Xge.displayName="MiniMapNode";var HDe=de.memo(Xge);const $De=n=>n.nodeOrigin,WDe=n=>n.getNodes().filter(e=>!e.hidden&&e.width&&e.height),d9=n=>n instanceof Function?n:()=>n;function XDe({nodeStrokeColor:n="transparent",nodeColor:e="#e2e2e2",nodeClassName:t="",nodeBorderRadius:r=5,nodeStrokeWidth:i=2,nodeComponent:s=HDe,onClick:a}){const o=Xa(WDe,qc),l=Xa($De),c=d9(e),u=d9(n),d=d9(t),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ln.createElement(ln.Fragment,null,o.map(p=>{const{x:g,y:x}=Dx(p,l).positionAbsolute;return ln.createElement(s,{key:p.id,x:g,y:x,width:p.width,height:p.height,style:p.style,selected:p.selected,className:d(p),color:c(p),borderRadius:r,strokeColor:u(p),strokeWidth:i,shapeRendering:h,onClick:a,id:p.id})}))}var YDe=de.memo(XDe);const ZDe=200,QDe=150,KDe=n=>{const e=n.getNodes(),t={x:-n.transform[0]/n.transform[2],y:-n.transform[1]/n.transform[2],width:n.width/n.transform[2],height:n.height/n.transform[2]};return{viewBB:t,boundingRect:e.length>0?cIe(GS(e,n.nodeOrigin),t):t,rfId:n.rfId}},JDe="react-flow__minimap-desc";function Yge({style:n,className:e,nodeStrokeColor:t="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o,maskColor:l="rgb(240, 240, 240, 0.6)",maskStrokeColor:c="none",maskStrokeWidth:u=1,position:d="bottom-right",onClick:h,onNodeClick:p,pannable:g=!1,zoomable:x=!1,ariaLabel:_="React Flow mini map",inversePan:y=!1,zoomStep:M=10,offsetScale:C=5}){const k=gc(),B=de.useRef(null),{boundingRect:U,viewBB:z,rfId:O}=Xa(KDe,qc),V=(n==null?void 0:n.width)??ZDe,$=(n==null?void 0:n.height)??QDe,G=U.width/V,H=U.height/$,K=Math.max(G,H),W=K*V,J=K*$,ie=C*K,ae=U.x-(W-U.width)/2-ie,Q=U.y-(J-U.height)/2-ie,re=W+ie*2,oe=J+ie*2,fe=`${JDe}-${O}`,ee=de.useRef(0);ee.current=K,de.useEffect(()=>{if(B.current){const be=Xh(B.current),pe=ze=>{const{transform:Xe,d3Selection:Qe,d3Zoom:ot}=k.getState();if(ze.sourceEvent.type!=="wheel"||!Qe||!ot)return;const bt=-ze.sourceEvent.deltaY*(ze.sourceEvent.deltaMode===1?.05:ze.sourceEvent.deltaMode?1:.002)*M,ht=Xe[2]*Math.pow(2,bt);ot.scaleTo(Qe,ht)},ge=ze=>{const{transform:Xe,d3Selection:Qe,d3Zoom:ot,translateExtent:bt,width:ht,height:Ce}=k.getState();if(ze.sourceEvent.type!=="mousemove"||!Qe||!ot)return;const lt=ee.current*Math.max(1,Xe[2])*(y?-1:1),ft={x:Xe[0]-ze.sourceEvent.movementX*lt,y:Xe[1]-ze.sourceEvent.movementY*lt},et=[[0,0],[ht,Ce]],At=mg.translate(ft.x,ft.y).scale(Xe[2]),Lt=ot.constrain()(At,et,bt);ot.transform(Qe,Lt)},Te=nge().on("zoom",g?ge:null).on("zoom.wheel",x?pe:null);return be.call(Te),()=>{be.on("zoom",null)}}},[g,x,y,M]);const me=h?be=>{const pe=Df(be);h(be,{x:pe[0],y:pe[1]})}:void 0,Ae=p?(be,pe)=>{const ge=k.getState().nodeInternals.get(pe);p(be,ge)}:void 0;return ln.createElement(p_,{position:d,style:n,className:bu(["react-flow__minimap",e]),"data-testid":"rf__minimap"},ln.createElement("svg",{width:V,height:$,viewBox:`${ae} ${Q} ${re} ${oe}`,role:"img","aria-labelledby":fe,ref:B,onClick:me},_&&ln.createElement("title",{id:fe},_),ln.createElement(YDe,{onClick:Ae,nodeColor:r,nodeStrokeColor:t,nodeBorderRadius:s,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:o}),ln.createElement("path",{className:"react-flow__minimap-mask",d:`M${ae-ie},${Q-ie}h${re+ie*2}v${oe+ie*2}h${-re-ie*2}z M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fill:l,fillRule:"evenodd",stroke:c,strokeWidth:u,pointerEvents:"none"})))}Yge.displayName="MiniMap";var eOe=de.memo(Yge);function tOe(){return ln.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ln.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function nOe(){return ln.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ln.createElement("path",{d:"M0 0h32v4.2H0z"}))}function rOe(){return ln.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ln.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function iOe(){return ln.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ln.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function sOe(){return ln.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ln.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const S5=({children:n,className:e,...t})=>ln.createElement("button",{type:"button",className:bu(["react-flow__controls-button",e]),...t},n);S5.displayName="ControlButton";const aOe=n=>({isInteractive:n.nodesDraggable||n.nodesConnectable||n.elementsSelectable,minZoomReached:n.transform[2]<=n.minZoom,maxZoomReached:n.transform[2]>=n.maxZoom}),Zge=({style:n,showZoom:e=!0,showFitView:t=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:s,onZoomOut:a,onFitView:o,onInteractiveChange:l,className:c,children:u,position:d="bottom-left"})=>{const h=gc(),[p,g]=de.useState(!1),{isInteractive:x,minZoomReached:_,maxZoomReached:y}=Xa(aOe,qc),{zoomIn:M,zoomOut:C,fitView:k}=U7();if(de.useEffect(()=>{g(!0)},[]),!p)return null;const B=()=>{M(),s==null||s()},U=()=>{C(),a==null||a()},z=()=>{k(i),o==null||o()},O=()=>{h.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),l==null||l(!x)};return ln.createElement(p_,{className:bu(["react-flow__controls",c]),position:d,style:n,"data-testid":"rf__controls"},e&&ln.createElement(ln.Fragment,null,ln.createElement(S5,{onClick:B,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y},ln.createElement(tOe,null)),ln.createElement(S5,{onClick:U,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:_},ln.createElement(nOe,null))),t&&ln.createElement(S5,{className:"react-flow__controls-fitview",onClick:z,title:"fit view","aria-label":"fit view"},ln.createElement(rOe,null)),r&&ln.createElement(S5,{className:"react-flow__controls-interactive",onClick:O,title:"toggle interactivity","aria-label":"toggle interactivity"},x?ln.createElement(sOe,null):ln.createElement(iOe,null)),u)};Zge.displayName="Controls";var oOe=de.memo(Zge),G0;(function(n){n.Lines="lines",n.Dots="dots",n.Cross="cross"})(G0||(G0={}));function lOe({color:n,dimensions:e,lineWidth:t}){return ln.createElement("path",{stroke:n,strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})}function cOe({color:n,radius:e}){return ln.createElement("circle",{cx:e,cy:e,r:e,fill:n})}const uOe={[G0.Dots]:"#91919a",[G0.Lines]:"#eee",[G0.Cross]:"#e2e2e2"},dOe={[G0.Dots]:1,[G0.Lines]:1,[G0.Cross]:6},hOe=n=>({transform:n.transform,patternId:`pattern-${n.rfId}`});function Qge({id:n,variant:e=G0.Dots,gap:t=20,size:r,lineWidth:i=1,offset:s=2,color:a,style:o,className:l}){const c=de.useRef(null),{transform:u,patternId:d}=Xa(hOe,qc),h=a||uOe[e],p=r||dOe[e],g=e===G0.Dots,x=e===G0.Cross,_=Array.isArray(t)?t:[t,t],y=[_[0]*u[2]||1,_[1]*u[2]||1],M=p*u[2],C=x?[M,M]:y,k=g?[M/s,M/s]:[C[0]/s,C[1]/s];return ln.createElement("svg",{className:bu(["react-flow__background",l]),style:{...o,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},ln.createElement("pattern",{id:d+n,x:u[0]%y[0],y:u[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},g?ln.createElement(cOe,{color:h,radius:M/s}):ln.createElement(lOe,{dimensions:C,color:h,lineWidth:i})),ln.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+n})`}))}Qge.displayName="Background";var fOe=de.memo(Qge);function VH(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var h9,EJ;function pOe(){if(EJ)return h9;EJ=1;function n(){this.__data__=[],this.size=0}return h9=n,h9}var f9,NJ;function E3(){if(NJ)return f9;NJ=1;function n(e,t){return e===t||e!==e&&t!==t}return f9=n,f9}var p9,MJ;function z7(){if(MJ)return p9;MJ=1;var n=E3();function e(t,r){for(var i=t.length;i--;)if(n(t[i][0],r))return i;return-1}return p9=e,p9}var m9,CJ;function mOe(){if(CJ)return m9;CJ=1;var n=z7(),e=Array.prototype,t=e.splice;function r(i){var s=this.__data__,a=n(s,i);if(a<0)return!1;var o=s.length-1;return a==o?s.pop():t.call(s,a,1),--this.size,!0}return m9=r,m9}var g9,PJ;function gOe(){if(PJ)return g9;PJ=1;var n=z7();function e(t){var r=this.__data__,i=n(r,t);return i<0?void 0:r[i][1]}return g9=e,g9}var A9,RJ;function AOe(){if(RJ)return A9;RJ=1;var n=z7();function e(t){return n(this.__data__,t)>-1}return A9=e,A9}var x9,LJ;function xOe(){if(LJ)return x9;LJ=1;var n=z7();function e(t,r){var i=this.__data__,s=n(i,t);return s<0?(++this.size,i.push([t,r])):i[s][1]=r,this}return x9=e,x9}var v9,kJ;function V7(){if(kJ)return v9;kJ=1;var n=pOe(),e=mOe(),t=gOe(),r=AOe(),i=xOe();function s(a){var o=-1,l=a==null?0:a.length;for(this.clear();++o-1&&r%1==0&&r-1&&t%1==0&&t<=n}return pk=e,pk}var mk,Pee;function HOe(){if(Pee)return mk;Pee=1;var n=$v(),e=$H(),t=_m(),r="[object Arguments]",i="[object Array]",s="[object Boolean]",a="[object Date]",o="[object Error]",l="[object Function]",c="[object Map]",u="[object Number]",d="[object Object]",h="[object RegExp]",p="[object Set]",g="[object String]",x="[object WeakMap]",_="[object ArrayBuffer]",y="[object DataView]",M="[object Float32Array]",C="[object Float64Array]",k="[object Int8Array]",B="[object Int16Array]",U="[object Int32Array]",z="[object Uint8Array]",O="[object Uint8ClampedArray]",V="[object Uint16Array]",$="[object Uint32Array]",G={};G[M]=G[C]=G[k]=G[B]=G[U]=G[z]=G[O]=G[V]=G[$]=!0,G[r]=G[i]=G[_]=G[s]=G[y]=G[a]=G[o]=G[l]=G[c]=G[u]=G[d]=G[h]=G[p]=G[g]=G[x]=!1;function H(K){return t(K)&&e(K.length)&&!!G[n(K)]}return mk=H,mk}var gk,Ree;function Y7(){if(Ree)return gk;Ree=1;function n(e){return function(t){return e(t)}}return gk=n,gk}var E5={exports:{}};E5.exports;var Lee;function WH(){return Lee||(Lee=1,function(n,e){var t=Kge(),r=e&&!e.nodeType&&e,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,a=s&&t.process,o=function(){try{var l=i&&i.require&&i.require("util").types;return l||a&&a.binding&&a.binding("util")}catch{}}();n.exports=o}(E5,E5.exports)),E5.exports}var Ak,kee;function XS(){if(kee)return Ak;kee=1;var n=HOe(),e=Y7(),t=WH(),r=t&&t.isTypedArray,i=r?e(r):n;return Ak=i,Ak}var xk,Iee;function t1e(){if(Iee)return xk;Iee=1;var n=VOe(),e=WS(),t=Ql(),r=M3(),i=X7(),s=XS(),a=Object.prototype,o=a.hasOwnProperty;function l(c,u){var d=t(c),h=!d&&e(c),p=!d&&!h&&r(c),g=!d&&!h&&!p&&s(c),x=d||h||p||g,_=x?n(c.length,String):[],y=_.length;for(var M in c)(u||o.call(c,M))&&!(x&&(M=="length"||p&&(M=="offset"||M=="parent")||g&&(M=="buffer"||M=="byteLength"||M=="byteOffset")||i(M,y)))&&_.push(M);return _}return xk=l,xk}var vk,Dee;function Z7(){if(Dee)return vk;Dee=1;var n=Object.prototype;function e(t){var r=t&&t.constructor,i=typeof r=="function"&&r.prototype||n;return t===i}return vk=e,vk}var yk,Oee;function n1e(){if(Oee)return yk;Oee=1;function n(e,t){return function(r){return e(t(r))}}return yk=n,yk}var bk,jee;function $Oe(){if(jee)return bk;jee=1;var n=n1e(),e=n(Object.keys,Object);return bk=e,bk}var _k,Fee;function XH(){if(Fee)return _k;Fee=1;var n=Z7(),e=$Oe(),t=Object.prototype,r=t.hasOwnProperty;function i(s){if(!n(s))return e(s);var a=[];for(var o in Object(s))r.call(s,o)&&o!="constructor"&&a.push(o);return a}return _k=i,_k}var wk,Bee;function Kg(){if(Bee)return wk;Bee=1;var n=HS(),e=$H();function t(r){return r!=null&&e(r.length)&&!n(r)}return wk=t,wk}var Sk,Uee;function e2(){if(Uee)return Sk;Uee=1;var n=t1e(),e=XH(),t=Kg();function r(i){return t(i)?n(i):e(i)}return Sk=r,Sk}var Tk,zee;function WOe(){if(zee)return Tk;zee=1;var n=$S(),e=e2();function t(r,i){return r&&n(i,e(i),r)}return Tk=t,Tk}var Ek,Vee;function XOe(){if(Vee)return Ek;Vee=1;function n(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}return Ek=n,Ek}var Nk,qee;function YOe(){if(qee)return Nk;qee=1;var n=s0(),e=Z7(),t=XOe(),r=Object.prototype,i=r.hasOwnProperty;function s(a){if(!n(a))return t(a);var o=e(a),l=[];for(var c in a)c=="constructor"&&(o||!i.call(a,c))||l.push(c);return l}return Nk=s,Nk}var Mk,Gee;function Xv(){if(Gee)return Mk;Gee=1;var n=t1e(),e=YOe(),t=Kg();function r(i){return t(i)?n(i,!0):e(i)}return Mk=r,Mk}var Ck,Hee;function ZOe(){if(Hee)return Ck;Hee=1;var n=$S(),e=Xv();function t(r,i){return r&&n(i,e(i),r)}return Ck=t,Ck}var N5={exports:{}};N5.exports;var $ee;function r1e(){return $ee||($ee=1,function(n,e){var t=rp(),r=e&&!e.nodeType&&e,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,a=s?t.Buffer:void 0,o=a?a.allocUnsafe:void 0;function l(c,u){if(u)return c.slice();var d=c.length,h=o?o(d):new c.constructor(d);return c.copy(h),h}n.exports=l}(N5,N5.exports)),N5.exports}var Pk,Wee;function i1e(){if(Wee)return Pk;Wee=1;function n(e,t){var r=-1,i=e.length;for(t||(t=Array(i));++rp))return!1;var x=d.get(a),_=d.get(o);if(x&&_)return x==o&&_==a;var y=-1,M=!0,C=l&i?new n:void 0;for(d.set(a,o),d.set(o,a);++y0&&s(u)?i>1?t(u,i-1,s,a,o):n(o,u):a||(o[o.length]=u)}return o}return bD=t,bD}var _D,Bne;function Wje(){if(Bne)return _D;Bne=1;function n(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}return _D=n,_D}var wD,Une;function D1e(){if(Une)return wD;Une=1;var n=Wje(),e=Math.max;function t(r,i,s){return i=e(i===void 0?r.length-1:i,0),function(){for(var a=arguments,o=-1,l=e(a.length-i,0),c=Array(l);++o0){if(++s>=n)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return TD=r,TD}var ED,qne;function O1e(){if(qne)return ED;qne=1;var n=Xje(),e=Yje(),t=e(n);return ED=t,ED}var ND,Gne;function nP(){if(Gne)return ND;Gne=1;var n=Yv(),e=D1e(),t=O1e();function r(i,s){return t(e(i,s,n),i+"")}return ND=r,ND}var MD,Hne;function j1e(){if(Hne)return MD;Hne=1;function n(e,t,r,i){for(var s=e.length,a=r+(i?1:-1);i?a--:++a-1}return LD=e,LD}var kD,Zne;function eFe(){if(Zne)return kD;Zne=1;function n(e,t,r){for(var i=-1,s=e==null?0:e.length;++i=a){var y=c?null:i(l);if(y)return s(y);g=!1,h=r,_=new n}else _=c?[]:x;e:for(;++d1?p.setNode(g,d):p.setNode(g)}),this},i.prototype.setNode=function(u,d){return n.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=t,this._children[u]={},this._children[t][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},i.prototype.node=function(u){return this._nodes[u]},i.prototype.hasNode=function(u){return n.has(this._nodes,u)},i.prototype.removeNode=function(u){var d=this;if(n.has(this._nodes,u)){var h=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],n.each(this.children(u),function(p){d.setParent(p)}),delete this._children[u]),n.each(n.keys(this._in[u]),h),delete this._in[u],delete this._preds[u],n.each(n.keys(this._out[u]),h),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},i.prototype.setParent=function(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n.isUndefined(d))d=t;else{d+="";for(var h=d;!n.isUndefined(h);h=this.parent(h))if(h===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this},i.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},i.prototype.parent=function(u){if(this._isCompound){var d=this._parent[u];if(d!==t)return d}},i.prototype.children=function(u){if(n.isUndefined(u)&&(u=t),this._isCompound){var d=this._children[u];if(d)return n.keys(d)}else{if(u===t)return this.nodes();if(this.hasNode(u))return[]}},i.prototype.predecessors=function(u){var d=this._preds[u];if(d)return n.keys(d)},i.prototype.successors=function(u){var d=this._sucs[u];if(d)return n.keys(d)},i.prototype.neighbors=function(u){var d=this.predecessors(u);if(d)return n.union(d,this.successors(u))},i.prototype.isLeaf=function(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0},i.prototype.filterNodes=function(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;n.each(this._nodes,function(x,_){u(_)&&d.setNode(_,x)}),n.each(this._edgeObjs,function(x){d.hasNode(x.v)&&d.hasNode(x.w)&&d.setEdge(x,h.edge(x))});var p={};function g(x){var _=h.parent(x);return _===void 0||d.hasNode(_)?(p[x]=_,_):_ in p?p[_]:g(_)}return this._isCompound&&n.each(d.nodes(),function(x){d.setParent(x,g(x))}),d},i.prototype.setDefaultEdgeLabel=function(u){return n.isFunction(u)||(u=n.constant(u)),this._defaultEdgeLabelFn=u,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return n.values(this._edgeObjs)},i.prototype.setPath=function(u,d){var h=this,p=arguments;return n.reduce(u,function(g,x){return p.length>1?h.setEdge(g,x,d):h.setEdge(g,x),x}),this},i.prototype.setEdge=function(){var u,d,h,p,g=!1,x=arguments[0];typeof x=="object"&&x!==null&&"v"in x?(u=x.v,d=x.w,h=x.name,arguments.length===2&&(p=arguments[1],g=!0)):(u=x,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],g=!0)),u=""+u,d=""+d,n.isUndefined(h)||(h=""+h);var _=o(this._isDirected,u,d,h);if(n.has(this._edgeLabels,_))return g&&(this._edgeLabels[_]=p),this;if(!n.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[_]=g?p:this._defaultEdgeLabelFn(u,d,h);var y=l(this._isDirected,u,d,h);return u=y.v,d=y.w,Object.freeze(y),this._edgeObjs[_]=y,s(this._preds[d],u),s(this._sucs[u],d),this._in[d][_]=y,this._out[u][_]=y,this._edgeCount++,this},i.prototype.edge=function(u,d,h){var p=arguments.length===1?c(this._isDirected,arguments[0]):o(this._isDirected,u,d,h);return this._edgeLabels[p]},i.prototype.hasEdge=function(u,d,h){var p=arguments.length===1?c(this._isDirected,arguments[0]):o(this._isDirected,u,d,h);return n.has(this._edgeLabels,p)},i.prototype.removeEdge=function(u,d,h){var p=arguments.length===1?c(this._isDirected,arguments[0]):o(this._isDirected,u,d,h),g=this._edgeObjs[p];return g&&(u=g.v,d=g.w,delete this._edgeLabels[p],delete this._edgeObjs[p],a(this._preds[d],u),a(this._sucs[u],d),delete this._in[d][p],delete this._out[u][p],this._edgeCount--),this},i.prototype.inEdges=function(u,d){var h=this._in[u];if(h){var p=n.values(h);return d?n.filter(p,function(g){return g.v===d}):p}},i.prototype.outEdges=function(u,d){var h=this._out[u];if(h){var p=n.values(h);return d?n.filter(p,function(g){return g.w===d}):p}},i.prototype.nodeEdges=function(u,d){var h=this.inEdges(u,d);if(h)return h.concat(this.outEdges(u,d))};function s(u,d){u[d]?u[d]++:u[d]=1}function a(u,d){--u[d]||delete u[d]}function o(u,d,h,p){var g=""+d,x=""+h;if(!u&&g>x){var _=g;g=x,x=_}return g+r+x+r+(n.isUndefined(p)?e:p)}function l(u,d,h,p){var g=""+d,x=""+h;if(!u&&g>x){var _=g;g=x,x=_}var y={v:g,w:x};return p&&(y.name=p),y}function c(u,d){return o(u,d.v,d.w,d.name)}return VD}var qD,are;function aFe(){return are||(are=1,qD="2.1.8"),qD}var GD,ore;function oFe(){return ore||(ore=1,GD={Graph:i$(),version:aFe()}),GD}var HD,lre;function lFe(){if(lre)return HD;lre=1;var n=a0(),e=i$();HD={write:t,read:s};function t(a){var o={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:r(a),edges:i(a)};return n.isUndefined(a.graph())||(o.value=n.clone(a.graph())),o}function r(a){return n.map(a.nodes(),function(o){var l=a.node(o),c=a.parent(o),u={v:o};return n.isUndefined(l)||(u.value=l),n.isUndefined(c)||(u.parent=c),u})}function i(a){return n.map(a.edges(),function(o){var l=a.edge(o),c={v:o.v,w:o.w};return n.isUndefined(o.name)||(c.name=o.name),n.isUndefined(l)||(c.value=l),c})}function s(a){var o=new e(a.options).setGraph(a.value);return n.each(a.nodes,function(l){o.setNode(l.v,l.value),l.parent&&o.setParent(l.v,l.parent)}),n.each(a.edges,function(l){o.setEdge({v:l.v,w:l.w,name:l.name},l.value)}),o}return HD}var $D,cre;function cFe(){if(cre)return $D;cre=1;var n=a0();$D=e;function e(t){var r={},i=[],s;function a(o){n.has(r,o)||(r[o]=!0,s.push(o),n.each(t.successors(o),a),n.each(t.predecessors(o),a))}return n.each(t.nodes(),function(o){s=[],a(o),s.length&&i.push(s)}),i}return $D}var WD,ure;function U1e(){if(ure)return WD;ure=1;var n=a0();WD=e;function e(){this._arr=[],this._keyIndices={}}return e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(t){return n.has(this._keyIndices,t)},e.prototype.priority=function(t){var r=this._keyIndices[t];if(r!==void 0)return this._arr[r].priority},e.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(t,r){var i=this._keyIndices;if(t=String(t),!n.has(i,t)){var s=this._arr,a=s.length;return i[t]=a,s.push({key:t,priority:r}),this._decrease(a),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,r){var i=this._keyIndices[t];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)},e.prototype._heapify=function(t){var r=this._arr,i=2*t,s=i+1,a=t;i>1,!(r[s].priority0&&(d=u.removeMin(),h=c[d],h.distance!==Number.POSITIVE_INFINITY);)l(d).forEach(p);return c}return XD}var YD,hre;function uFe(){if(hre)return YD;hre=1;var n=z1e(),e=a0();YD=t;function t(r,i,s){return e.transform(r.nodes(),function(a,o){a[o]=n(r,o,i,s)},{})}return YD}var ZD,fre;function V1e(){if(fre)return ZD;fre=1;var n=a0();ZD=e;function e(t){var r=0,i=[],s={},a=[];function o(l){var c=s[l]={onStack:!0,lowlink:r,index:r++};if(i.push(l),t.successors(l).forEach(function(h){n.has(s,h)?s[h].onStack&&(c.lowlink=Math.min(c.lowlink,s[h].index)):(o(h),c.lowlink=Math.min(c.lowlink,s[h].lowlink))}),c.lowlink===c.index){var u=[],d;do d=i.pop(),s[d].onStack=!1,u.push(d);while(l!==d);a.push(u)}}return t.nodes().forEach(function(l){n.has(s,l)||o(l)}),a}return ZD}var QD,pre;function dFe(){if(pre)return QD;pre=1;var n=a0(),e=V1e();QD=t;function t(r){return n.filter(e(r),function(i){return i.length>1||i.length===1&&r.hasEdge(i[0],i[0])})}return QD}var KD,mre;function hFe(){if(mre)return KD;mre=1;var n=a0();KD=t;var e=n.constant(1);function t(i,s,a){return r(i,s||e,a||function(o){return i.outEdges(o)})}function r(i,s,a){var o={},l=i.nodes();return l.forEach(function(c){o[c]={},o[c][c]={distance:0},l.forEach(function(u){c!==u&&(o[c][u]={distance:Number.POSITIVE_INFINITY})}),a(c).forEach(function(u){var d=u.v===c?u.w:u.v,h=s(u);o[c][d]={distance:h,predecessor:c}})}),l.forEach(function(c){var u=o[c];l.forEach(function(d){var h=o[d];l.forEach(function(p){var g=h[c],x=u[p],_=h[p],y=g.distance+x.distance;y<_.distance&&(_.distance=y,_.predecessor=x.predecessor)})})}),o}return KD}var JD,gre;function q1e(){if(gre)return JD;gre=1;var n=a0();JD=e,e.CycleException=t;function e(r){var i={},s={},a=[];function o(l){if(n.has(s,l))throw new t;n.has(i,l)||(s[l]=!0,i[l]=!0,n.each(r.predecessors(l),o),delete s[l],a.push(l))}if(n.each(r.sinks(),o),n.size(i)!==r.nodeCount())throw new t;return a}function t(){}return t.prototype=new Error,JD}var eO,Are;function fFe(){if(Are)return eO;Are=1;var n=q1e();eO=e;function e(t){try{n(t)}catch(r){if(r instanceof n.CycleException)return!1;throw r}return!0}return eO}var tO,xre;function G1e(){if(xre)return tO;xre=1;var n=a0();tO=e;function e(r,i,s){n.isArray(i)||(i=[i]);var a=(r.isDirected()?r.successors:r.neighbors).bind(r),o=[],l={};return n.each(i,function(c){if(!r.hasNode(c))throw new Error("Graph does not have node: "+c);t(r,c,s==="post",l,a,o)}),o}function t(r,i,s,a,o,l){n.has(a,i)||(a[i]=!0,s||l.push(i),n.each(o(i),function(c){t(r,c,s,a,o,l)}),s&&l.push(i))}return tO}var nO,vre;function pFe(){if(vre)return nO;vre=1;var n=G1e();nO=e;function e(t,r){return n(t,r,"post")}return nO}var rO,yre;function mFe(){if(yre)return rO;yre=1;var n=G1e();rO=e;function e(t,r){return n(t,r,"pre")}return rO}var iO,bre;function gFe(){if(bre)return iO;bre=1;var n=a0(),e=i$(),t=U1e();iO=r;function r(i,s){var a=new e,o={},l=new t,c;function u(h){var p=h.v===c?h.w:h.v,g=l.priority(p);if(g!==void 0){var x=s(h);x0;){if(c=l.removeMin(),n.has(o,c))a.setEdge(c,o[c]);else{if(d)throw new Error("Input graph is not connected: "+i);d=!0}i.nodeEdges(c).forEach(u)}return a}return iO}var sO,_re;function AFe(){return _re||(_re=1,sO={components:cFe(),dijkstra:z1e(),dijkstraAll:uFe(),findCycles:dFe(),floydWarshall:hFe(),isAcyclic:fFe(),postorder:pFe(),preorder:mFe(),prim:gFe(),tarjan:V1e(),topsort:q1e()}),sO}var aO,wre;function xFe(){if(wre)return aO;wre=1;var n=oFe();return aO={Graph:n.Graph,json:lFe(),alg:AFe(),version:n.version},aO}var IM;if(typeof VH=="function")try{IM=xFe()}catch{}IM||(IM=window.graphlib);var ip=IM,oO,Sre;function vFe(){if(Sre)return oO;Sre=1;var n=m1e(),e=1,t=4;function r(i){return n(i,e|t)}return oO=r,oO}var lO,Tre;function rP(){if(Tre)return lO;Tre=1;var n=E3(),e=Kg(),t=X7(),r=s0();function i(s,a,o){if(!r(o))return!1;var l=typeof a;return(l=="number"?e(o)&&t(a,o.length):l=="string"&&a in o)?n(o[a],s):!1}return lO=i,lO}var cO,Ere;function yFe(){if(Ere)return cO;Ere=1;var n=nP(),e=E3(),t=rP(),r=Xv(),i=Object.prototype,s=i.hasOwnProperty,a=n(function(o,l){o=Object(o);var c=-1,u=l.length,d=u>2?l[2]:void 0;for(d&&t(l[0],l[1],d)&&(u=1);++c-1?l[c?s[u]:u]:void 0}}return uO=r,uO}var dO,Mre;function _Fe(){if(Mre)return dO;Mre=1;var n=/\s/;function e(t){for(var r=t.length;r--&&n.test(t.charAt(r)););return r}return dO=e,dO}var hO,Cre;function wFe(){if(Cre)return hO;Cre=1;var n=_Fe(),e=/^\s+/;function t(r){return r&&r.slice(0,n(r)+1).replace(e,"")}return hO=t,hO}var fO,Pre;function SFe(){if(Pre)return fO;Pre=1;var n=wFe(),e=s0(),t=P3(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,o=parseInt;function l(c){if(typeof c=="number")return c;if(t(c))return r;if(e(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=e(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=n(c);var d=s.test(c);return d||a.test(c)?o(c.slice(2),d?2:8):i.test(c)?r:+c}return fO=l,fO}var pO,Rre;function H1e(){if(Rre)return pO;Rre=1;var n=SFe(),e=1/0,t=17976931348623157e292;function r(i){if(!i)return i===0?i:0;if(i=n(i),i===e||i===-e){var s=i<0?-1:1;return s*t}return i===i?i:0}return pO=r,pO}var mO,Lre;function TFe(){if(Lre)return mO;Lre=1;var n=H1e();function e(t){var r=n(t),i=r%1;return r===r?i?r-i:r:0}return mO=e,mO}var gO,kre;function EFe(){if(kre)return gO;kre=1;var n=j1e(),e=Jg(),t=TFe(),r=Math.max;function i(s,a,o){var l=s==null?0:s.length;if(!l)return-1;var c=o==null?0:t(o);return c<0&&(c=r(l+c,0)),n(s,e(a,3),c)}return gO=i,gO}var AO,Ire;function NFe(){if(Ire)return AO;Ire=1;var n=bFe(),e=EFe(),t=n(e);return AO=t,AO}var xO,Dre;function $1e(){if(Dre)return xO;Dre=1;var n=r$();function e(t){var r=t==null?0:t.length;return r?n(t,1):[]}return xO=e,xO}var vO,Ore;function MFe(){if(Ore)return vO;Ore=1;var n=JH(),e=g1e(),t=Xv();function r(i,s){return i==null?i:n(i,e(s),t)}return vO=r,vO}var yO,jre;function CFe(){if(jre)return yO;jre=1;function n(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}return yO=n,yO}var bO,Fre;function PFe(){if(Fre)return bO;Fre=1;var n=$7(),e=e$(),t=Jg();function r(i,s){var a={};return s=t(s,3),e(i,function(o,l,c){n(a,l,s(o,l,c))}),a}return bO=r,bO}var _O,Bre;function s$(){if(Bre)return _O;Bre=1;var n=P3();function e(t,r,i){for(var s=-1,a=t.length;++st}return wO=n,wO}var SO,zre;function LFe(){if(zre)return SO;zre=1;var n=s$(),e=RFe(),t=Yv();function r(i){return i&&i.length?n(i,t,e):void 0}return SO=r,SO}var TO,Vre;function W1e(){if(Vre)return TO;Vre=1;var n=$7(),e=E3();function t(r,i,s){(s!==void 0&&!e(r[i],s)||s===void 0&&!(i in r))&&n(r,i,s)}return TO=t,TO}var EO,qre;function kFe(){if(qre)return EO;qre=1;var n=$v(),e=Q7(),t=_m(),r="[object Object]",i=Function.prototype,s=Object.prototype,a=i.toString,o=s.hasOwnProperty,l=a.call(Object);function c(u){if(!t(u)||n(u)!=r)return!1;var d=e(u);if(d===null)return!0;var h=o.call(d,"constructor")&&d.constructor;return typeof h=="function"&&h instanceof h&&a.call(h)==l}return EO=c,EO}var NO,Gre;function X1e(){if(Gre)return NO;Gre=1;function n(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return NO=n,NO}var MO,Hre;function IFe(){if(Hre)return MO;Hre=1;var n=$S(),e=Xv();function t(r){return n(r,e(r))}return MO=t,MO}var CO,$re;function DFe(){if($re)return CO;$re=1;var n=W1e(),e=r1e(),t=h1e(),r=i1e(),i=p1e(),s=WS(),a=Ql(),o=F1e(),l=M3(),c=HS(),u=s0(),d=kFe(),h=XS(),p=X1e(),g=IFe();function x(_,y,M,C,k,B,U){var z=p(_,M),O=p(y,M),V=U.get(O);if(V){n(_,M,V);return}var $=B?B(z,O,M+"",_,y,U):void 0,G=$===void 0;if(G){var H=a(O),K=!H&&l(O),W=!H&&!K&&h(O);$=O,H||K||W?a(z)?$=z:o(z)?$=r(z):K?(G=!1,$=e(O,!0)):W?(G=!1,$=t(O,!0)):$=[]:d(O)||s(O)?($=z,s(z)?$=g(z):(!u(z)||c(z))&&($=i(O))):G=!1}G&&(U.set(O,$),k($,O,C,B,U),U.delete(O)),n(_,M,$)}return CO=x,CO}var PO,Wre;function OFe(){if(Wre)return PO;Wre=1;var n=H7(),e=W1e(),t=JH(),r=DFe(),i=s0(),s=Xv(),a=X1e();function o(l,c,u,d,h){l!==c&&t(c,function(p,g){if(h||(h=new n),i(p))r(l,c,g,u,o,d,h);else{var x=d?d(a(l,g),p,g+"",l,c,h):void 0;x===void 0&&(x=p),e(l,g,x)}},s)}return PO=o,PO}var RO,Xre;function jFe(){if(Xre)return RO;Xre=1;var n=nP(),e=rP();function t(r){return n(function(i,s){var a=-1,o=s.length,l=o>1?s[o-1]:void 0,c=o>2?s[2]:void 0;for(l=r.length>3&&typeof l=="function"?(o--,l):void 0,c&&e(s[0],s[1],c)&&(l=o<3?void 0:l,o=1),i=Object(i);++ar||o&&l&&u&&!c&&!d||s&&l&&u||!i&&u||!a)return 1;if(!s&&!o&&!d&&t=c)return u;var d=i[s];return u*(d=="desc"?-1:1)}}return t.index-r.index}return WO=e,WO}var XO,die;function JFe(){if(die)return XO;die=1;var n=J7(),e=tP(),t=Jg(),r=L1e(),i=ZFe(),s=Y7(),a=KFe(),o=Yv(),l=Ql();function c(u,d,h){d.length?d=n(d,function(x){return l(x)?function(_){return e(_,x.length===1?x[0]:x)}:x}):d=[o];var p=-1;d=n(d,s(t));var g=r(u,function(x,_,y){var M=n(d,function(C){return C(x)});return{criteria:M,index:++p,value:x}});return i(g,function(x,_){return a(x,_,h)})}return XO=c,XO}var YO,hie;function eBe(){if(hie)return YO;hie=1;var n=r$(),e=JFe(),t=nP(),r=rP(),i=t(function(s,a){if(s==null)return[];var o=a.length;return o>1&&r(s,a[0],a[1])?a=[]:o>2&&r(a[0],a[1],a[2])&&(a=[a[0]]),e(s,n(a,1),[])});return YO=i,YO}var ZO,fie;function tBe(){if(fie)return ZO;fie=1;var n=T1e(),e=0;function t(r){var i=++e;return n(r)+i}return ZO=t,ZO}var QO,pie;function nBe(){if(pie)return QO;pie=1;function n(e,t,r){for(var i=-1,s=e.length,a=t.length,o={};++i0;--o)if(a=e[o].dequeue(),a){r=r.concat(JO(n,e,t,a,!0));break}}}return r}function JO(n,e,t,r,i){var s=i?[]:void 0;return og.forEach(n.inEdges(r.v),function(a){var o=n.edge(a),l=n.node(a.v);i&&s.push({v:a.v,w:a.w}),l.out-=o,Ez(e,t,l)}),og.forEach(n.outEdges(r.v),function(a){var o=n.edge(a),l=a.w,c=n.node(l);c.in-=o,Ez(e,t,c)}),n.removeNode(r.v),s}function hBe(n,e){var t=new aBe,r=0,i=0;og.forEach(n.nodes(),function(o){t.setNode(o,{v:o,in:0,out:0})}),og.forEach(n.edges(),function(o){var l=t.edge(o.v,o.w)||0,c=e(o),u=l+c;t.setEdge(o.v,o.w,u),i=Math.max(i,t.node(o.v).out+=c),r=Math.max(r,t.node(o.w).in+=c)});var s=og.range(i+r+3).map(function(){return new oBe}),a=r+1;return og.forEach(t.nodes(),function(o){Ez(s,a,t.node(o))}),{graph:t,buckets:s,zeroIdx:a}}function Ez(n,e,t){t.out?t.in?n[t.out-t.in+e].enqueue(t):n[n.length-1].enqueue(t):n[0].enqueue(t)}var _x=Mo,fBe=lBe,pBe={run:mBe,undo:ABe};function mBe(n){var e=n.graph().acyclicer==="greedy"?fBe(n,t(n)):gBe(n);_x.forEach(e,function(r){var i=n.edge(r);n.removeEdge(r),i.forwardName=r.name,i.reversed=!0,n.setEdge(r.w,r.v,i,_x.uniqueId("rev"))});function t(r){return function(i){return r.edge(i).weight}}}function gBe(n){var e=[],t={},r={};function i(s){_x.has(r,s)||(r[s]=!0,t[s]=!0,_x.forEach(n.outEdges(s),function(a){_x.has(t,a.w)?e.push(a):i(a.w)}),delete t[s])}return _x.forEach(n.nodes(),i),e}function ABe(n){_x.forEach(n.edges(),function(e){var t=n.edge(e);if(t.reversed){n.removeEdge(e);var r=t.forwardName;delete t.reversed,delete t.forwardName,n.setEdge(e.w,e.v,t,r)}})}var Js=Mo,Q1e=ip.Graph,fh={addDummyNode:K1e,simplify:xBe,asNonCompoundGraph:vBe,successorWeights:yBe,predecessorWeights:bBe,intersectRect:_Be,buildLayerMatrix:wBe,normalizeRanks:SBe,removeEmptyRanks:TBe,addBorderNode:EBe,maxRank:J1e,partition:NBe,time:MBe,notime:CBe};function K1e(n,e,t,r){var i;do i=Js.uniqueId(r);while(n.hasNode(i));return t.dummy=e,n.setNode(i,t),i}function xBe(n){var e=new Q1e().setGraph(n.graph());return Js.forEach(n.nodes(),function(t){e.setNode(t,n.node(t))}),Js.forEach(n.edges(),function(t){var r=e.edge(t.v,t.w)||{weight:0,minlen:1},i=n.edge(t);e.setEdge(t.v,t.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),e}function vBe(n){var e=new Q1e({multigraph:n.isMultigraph()}).setGraph(n.graph());return Js.forEach(n.nodes(),function(t){n.children(t).length||e.setNode(t,n.node(t))}),Js.forEach(n.edges(),function(t){e.setEdge(t,n.edge(t))}),e}function yBe(n){var e=Js.map(n.nodes(),function(t){var r={};return Js.forEach(n.outEdges(t),function(i){r[i.w]=(r[i.w]||0)+n.edge(i).weight}),r});return Js.zipObject(n.nodes(),e)}function bBe(n){var e=Js.map(n.nodes(),function(t){var r={};return Js.forEach(n.inEdges(t),function(i){r[i.v]=(r[i.v]||0)+n.edge(i).weight}),r});return Js.zipObject(n.nodes(),e)}function _Be(n,e){var t=n.x,r=n.y,i=e.x-t,s=e.y-r,a=n.width/2,o=n.height/2;if(!i&&!s)throw new Error("Not possible to find intersection inside of the rectangle");var l,c;return Math.abs(s)*a>Math.abs(i)*o?(s<0&&(o=-o),l=o*i/s,c=o):(i<0&&(a=-a),l=a,c=a*s/i),{x:t+l,y:r+c}}function wBe(n){var e=Js.map(Js.range(J1e(n)+1),function(){return[]});return Js.forEach(n.nodes(),function(t){var r=n.node(t),i=r.rank;Js.isUndefined(i)||(e[i][r.order]=t)}),e}function SBe(n){var e=Js.min(Js.map(n.nodes(),function(t){return n.node(t).rank}));Js.forEach(n.nodes(),function(t){var r=n.node(t);Js.has(r,"rank")&&(r.rank-=e)})}function TBe(n){var e=Js.min(Js.map(n.nodes(),function(s){return n.node(s).rank})),t=[];Js.forEach(n.nodes(),function(s){var a=n.node(s).rank-e;t[a]||(t[a]=[]),t[a].push(s)});var r=0,i=n.graph().nodeRankFactor;Js.forEach(t,function(s,a){Js.isUndefined(s)&&a%i!==0?--r:r&&Js.forEach(s,function(o){n.node(o).rank+=r})})}function EBe(n,e,t,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=t,i.order=r),K1e(n,"border",i,e)}function J1e(n){return Js.max(Js.map(n.nodes(),function(e){var t=n.node(e).rank;if(!Js.isUndefined(t))return t}))}function NBe(n,e){var t={lhs:[],rhs:[]};return Js.forEach(n,function(r){e(r)?t.lhs.push(r):t.rhs.push(r)}),t}function MBe(n,e){var t=Js.now();try{return e()}finally{console.log(n+" time: "+(Js.now()-t)+"ms")}}function CBe(n,e){return e()}var eAe=Mo,PBe=fh,RBe={run:LBe,undo:IBe};function LBe(n){n.graph().dummyChains=[],eAe.forEach(n.edges(),function(e){kBe(n,e)})}function kBe(n,e){var t=e.v,r=n.node(t).rank,i=e.w,s=n.node(i).rank,a=e.name,o=n.edge(e),l=o.labelRank;if(s!==r+1){n.removeEdge(e);var c,u,d;for(d=0,++r;ra.lim&&(o=a,l=!0);var c=Og.filter(e.edges(),function(u){return l===gie(n,n.node(u.v),o)&&l!==gie(n,n.node(u.w),o)});return Og.minBy(c,function(u){return qBe(e,u)})}function aAe(n,e,t,r){var i=t.v,s=t.w;n.removeEdge(i,s),n.setEdge(r.v,r.w,{}),o$(n),a$(n,e),ZBe(n,e)}function ZBe(n,e){var t=Og.find(n.nodes(),function(i){return!e.node(i).parent}),r=HBe(n,t);r=r.slice(1),Og.forEach(r,function(i){var s=n.node(i).parent,a=e.edge(i,s),o=!1;a||(a=e.edge(s,i),o=!0),e.node(i).rank=e.node(s).rank+(o?a.minlen:-a.minlen)})}function QBe(n,e,t){return n.hasEdge(e,t)}function gie(n,e,t){return t.low<=e.lim&&e.lim<=t.lim}var KBe=sP,oAe=KBe.longestPath,JBe=tAe,eUe=XBe,tUe=nUe;function nUe(n){switch(n.graph().ranker){case"network-simplex":Aie(n);break;case"tight-tree":iUe(n);break;case"longest-path":rUe(n);break;default:Aie(n)}}var rUe=oAe;function iUe(n){oAe(n),JBe(n)}function Aie(n){eUe(n)}var Nz=Mo,sUe=aUe;function aUe(n){var e=lUe(n);Nz.forEach(n.graph().dummyChains,function(t){for(var r=n.node(t),i=r.edgeObj,s=oUe(n,e,i.v,i.w),a=s.path,o=s.lca,l=0,c=a[l],u=!0;t!==i.w;){if(r=n.node(t),u){for(;(c=a[l])!==o&&n.node(c).maxRanka||o>e[l].lim));for(c=l,l=r;(l=n.parent(l))!==c;)s.push(l);return{path:i.concat(s.reverse()),lca:c}}function lUe(n){var e={},t=0;function r(i){var s=t;Nz.forEach(n.children(i),r),e[i]={low:s,lim:t++}}return Nz.forEach(n.children(),r),e}var lg=Mo,Mz=fh,cUe={run:uUe,cleanup:fUe};function uUe(n){var e=Mz.addDummyNode(n,"root",{},"_root"),t=dUe(n),r=lg.max(lg.values(t))-1,i=2*r+1;n.graph().nestingRoot=e,lg.forEach(n.edges(),function(a){n.edge(a).minlen*=i});var s=hUe(n)+1;lg.forEach(n.children(),function(a){lAe(n,e,i,s,r,t,a)}),n.graph().nodeRankFactor=i}function lAe(n,e,t,r,i,s,a){var o=n.children(a);if(!o.length){a!==e&&n.setEdge(e,a,{weight:0,minlen:t});return}var l=Mz.addBorderNode(n,"_bt"),c=Mz.addBorderNode(n,"_bb"),u=n.node(a);n.setParent(l,a),u.borderTop=l,n.setParent(c,a),u.borderBottom=c,lg.forEach(o,function(d){lAe(n,e,t,r,i,s,d);var h=n.node(d),p=h.borderTop?h.borderTop:d,g=h.borderBottom?h.borderBottom:d,x=h.borderTop?r:2*r,_=p!==g?1:i-s[a]+1;n.setEdge(l,p,{weight:x,minlen:_,nestingEdge:!0}),n.setEdge(g,c,{weight:x,minlen:_,nestingEdge:!0})}),n.parent(a)||n.setEdge(e,l,{weight:0,minlen:i+s[a]})}function dUe(n){var e={};function t(r,i){var s=n.children(r);s&&s.length&&lg.forEach(s,function(a){t(a,i+1)}),e[r]=i}return lg.forEach(n.children(),function(r){t(r,1)}),e}function hUe(n){return lg.reduce(n.edges(),function(e,t){return e+n.edge(t).weight},0)}function fUe(n){var e=n.graph();n.removeNode(e.nestingRoot),delete e.nestingRoot,lg.forEach(n.edges(),function(t){var r=n.edge(t);r.nestingEdge&&n.removeEdge(t)})}var ej=Mo,pUe=fh,mUe=gUe;function gUe(n){function e(t){var r=n.children(t),i=n.node(t);if(r.length&&ej.forEach(r,e),ej.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var s=i.minRank,a=i.maxRank+1;s0;)u%2&&(d+=o[u+1]),u=u-1>>1,o[u]+=c.weight;l+=c.weight*d})),l}var yie=Mo,NUe=MUe;function MUe(n,e){return yie.map(e,function(t){var r=n.inEdges(t);if(r.length){var i=yie.reduce(r,function(s,a){var o=n.edge(a),l=n.node(a.v);return{sum:s.sum+o.weight*l.order,weight:s.weight+o.weight}},{sum:0,weight:0});return{v:t,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:t}})}var Gh=Mo,CUe=PUe;function PUe(n,e){var t={};Gh.forEach(n,function(i,s){var a=t[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:s};Gh.isUndefined(i.barycenter)||(a.barycenter=i.barycenter,a.weight=i.weight)}),Gh.forEach(e.edges(),function(i){var s=t[i.v],a=t[i.w];!Gh.isUndefined(s)&&!Gh.isUndefined(a)&&(a.indegree++,s.out.push(t[i.w]))});var r=Gh.filter(t,function(i){return!i.indegree});return RUe(r)}function RUe(n){var e=[];function t(s){return function(a){a.merged||(Gh.isUndefined(a.barycenter)||Gh.isUndefined(s.barycenter)||a.barycenter>=s.barycenter)&&LUe(s,a)}}function r(s){return function(a){a.in.push(s),--a.indegree===0&&n.push(a)}}for(;n.length;){var i=n.pop();e.push(i),Gh.forEach(i.in.reverse(),t(i)),Gh.forEach(i.out,r(i))}return Gh.map(Gh.filter(e,function(s){return!s.merged}),function(s){return Gh.pick(s,["vs","i","barycenter","weight"])})}function LUe(n,e){var t=0,r=0;n.weight&&(t+=n.barycenter*n.weight,r+=n.weight),e.weight&&(t+=e.barycenter*e.weight,r+=e.weight),n.vs=e.vs.concat(n.vs),n.barycenter=t/r,n.weight=r,n.i=Math.min(e.i,n.i),e.merged=!0}var M5=Mo,kUe=fh,IUe=DUe;function DUe(n,e){var t=kUe.partition(n,function(u){return M5.has(u,"barycenter")}),r=t.lhs,i=M5.sortBy(t.rhs,function(u){return-u.i}),s=[],a=0,o=0,l=0;r.sort(OUe(!!e)),l=bie(s,i,l),M5.forEach(r,function(u){l+=u.vs.length,s.push(u.vs),a+=u.barycenter*u.weight,o+=u.weight,l=bie(s,i,l)});var c={vs:M5.flatten(s,!0)};return o&&(c.barycenter=a/o,c.weight=o),c}function bie(n,e,t){for(var r;e.length&&(r=M5.last(e)).i<=t;)e.pop(),n.push(r.vs),t++;return t}function OUe(n){return function(e,t){return e.barycentert.barycenter?1:n?t.i-e.i:e.i-t.i}}var Q1=Mo,jUe=NUe,FUe=CUe,BUe=IUe,UUe=uAe;function uAe(n,e,t,r){var i=n.children(e),s=n.node(e),a=s?s.borderLeft:void 0,o=s?s.borderRight:void 0,l={};a&&(i=Q1.filter(i,function(g){return g!==a&&g!==o}));var c=jUe(n,i);Q1.forEach(c,function(g){if(n.children(g.v).length){var x=uAe(n,g.v,t,r);l[g.v]=x,Q1.has(x,"barycenter")&&VUe(g,x)}});var u=FUe(c,t);zUe(u,l);var d=BUe(u,r);if(a&&(d.vs=Q1.flatten([a,d.vs,o],!0),n.predecessors(a).length)){var h=n.node(n.predecessors(a)[0]),p=n.node(n.predecessors(o)[0]);Q1.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+h.order+p.order)/(d.weight+2),d.weight+=2}return d}function zUe(n,e){Q1.forEach(n,function(t){t.vs=Q1.flatten(t.vs.map(function(r){return e[r]?e[r].vs:r}),!0)})}function VUe(n,e){Q1.isUndefined(n.barycenter)?(n.barycenter=e.barycenter,n.weight=e.weight):(n.barycenter=(n.barycenter*n.weight+e.barycenter*e.weight)/(n.weight+e.weight),n.weight+=e.weight)}var C5=Mo,qUe=ip.Graph,GUe=HUe;function HUe(n,e,t){var r=$Ue(n),i=new qUe({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(s){return n.node(s)});return C5.forEach(n.nodes(),function(s){var a=n.node(s),o=n.parent(s);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(s),i.setParent(s,o||r),C5.forEach(n[t](s),function(l){var c=l.v===s?l.w:l.v,u=i.edge(c,s),d=C5.isUndefined(u)?0:u.weight;i.setEdge(c,s,{weight:n.edge(l).weight+d})}),C5.has(a,"minRank")&&i.setNode(s,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))}),i}function $Ue(n){for(var e;n.hasNode(e=C5.uniqueId("_root")););return e}var WUe=Mo,XUe=YUe;function YUe(n,e,t){var r={},i;WUe.forEach(t,function(s){for(var a=n.parent(s),o,l;a;){if(o=n.parent(a),o?(l=r[o],r[o]=a):(l=i,i=a),l&&l!==a){e.setEdge(l,a);return}a=o}})}var TA=Mo,ZUe=_Ue,QUe=SUe,KUe=UUe,JUe=GUe,eze=XUe,tze=ip.Graph,_ie=fh,nze=rze;function rze(n){var e=_ie.maxRank(n),t=wie(n,TA.range(1,e+1),"inEdges"),r=wie(n,TA.range(e-1,-1,-1),"outEdges"),i=ZUe(n);Sie(n,i);for(var s=Number.POSITIVE_INFINITY,a,o=0,l=0;l<4;++o,++l){ize(o%2?t:r,o%4>=2),i=_ie.buildLayerMatrix(n);var c=QUe(n,i);cc)&&dAe(t,h,u)})})}function i(s,a){var o=-1,l,c=0;return yi.forEach(a,function(u,d){if(n.node(u).dummy==="border"){var h=n.predecessors(u);h.length&&(l=n.node(h[0]).order,r(a,c,d,o,l),c=d,o=l)}r(a,c,a.length,l,s.length)}),a}return yi.reduce(e,i),t}function uze(n,e){if(n.node(e).dummy)return yi.find(n.predecessors(e),function(t){return n.node(t).dummy})}function dAe(n,e,t){if(e>t){var r=e;e=t,t=r}var i=n[e];i||(n[e]=i={}),i[t]=!0}function dze(n,e,t){if(e>t){var r=e;e=t,t=r}return yi.has(n[e],t)}function hze(n,e,t,r){var i={},s={},a={};return yi.forEach(e,function(o){yi.forEach(o,function(l,c){i[l]=l,s[l]=l,a[l]=c})}),yi.forEach(e,function(o){var l=-1;yi.forEach(o,function(c){var u=r(c);if(u.length){u=yi.sortBy(u,function(x){return a[x]});for(var d=(u.length-1)/2,h=Math.floor(d),p=Math.ceil(d);h<=p;++h){var g=u[h];s[c]===c&&l0){const a=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(t.map(c=>{if(c=dVe(c,r),c in Pie)return;Pie[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!r)for(let g=a.length-1;g>=0;g--){const x=a[g];if(x.href===c&&(!u||x.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":uVe,u||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((g,x)=>{p.addEventListener("load",g),p.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&s(o.reason);return e().catch(s)})};function pa(n){"@babel/helpers - typeof";return pa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pa(n)}var Z0=Uint8Array,Qh=Uint16Array,l$=Int32Array,c$=new Z0([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),u$=new Z0([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Rie=new Z0([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fAe=function(n,e){for(var t=new Qh(31),r=0;r<31;++r)t[r]=e+=1<>1|(so&21845)<<1;x1=(x1&52428)>>2|(x1&13107)<<2,x1=(x1&61680)>>4|(x1&3855)<<4,Pz[so]=((x1&65280)>>8|(x1&255)<<8)>>1}var i4=function(n,e,t){for(var r=n.length,i=0,s=new Qh(e);i>l]=c}else for(o=new Qh(r),i=0;i>15-n[i]);return o},ev=new Z0(288);for(var so=0;so<144;++so)ev[so]=8;for(var so=144;so<256;++so)ev[so]=9;for(var so=256;so<280;++so)ev[so]=7;for(var so=280;so<288;++so)ev[so]=8;var FM=new Z0(32);for(var so=0;so<32;++so)FM[so]=5;var pVe=i4(ev,9,0),mVe=i4(FM,5,0),mAe=function(n){return(n+7)/8|0},gVe=function(n,e,t){return(t==null||t>n.length)&&(t=n.length),new Z0(n.subarray(e,t))},Dm=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8},vw=function(n,e,t){t<<=e&7;var r=e/8|0;n[r]|=t,n[r+1]|=t>>8,n[r+2]|=t>>16},aj=function(n,e){for(var t=[],r=0;rh&&(h=s[r].s);var p=new Qh(h+1),g=Rz(t[u-1],p,0);if(g>e){var r=0,x=0,_=g-e,y=1<<_;for(s.sort(function(U,z){return p[z.s]-p[U.s]||U.f-z.f});re)x+=y-(1<>=_;x>0;){var C=s[r].s;p[C]=0&&x;--r){var k=s[r].s;p[k]==e&&(--p[k],++x)}g=e}return{t:new Z0(p),l:g}},Rz=function(n,e,t){return n.s==-1?Math.max(Rz(n.l,e,t+1),Rz(n.r,e,t+1)):e[n.s]=t},kie=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new Qh(++e),r=0,i=n[0],s=1,a=function(l){t[r++]=l},o=1;o<=e;++o)if(n[o]==i&&o!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(i),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(i);s=1,i=n[o]}return{c:t.subarray(0,r),n:e}},yw=function(n,e){for(var t=0,r=0;r>8,n[i+2]=n[i]^255,n[i+3]=n[i+1]^255;for(var s=0;s4&&!$[Rie[H-1]];--H);var K=c+5<<3,W=yw(i,ev)+yw(s,FM)+a,J=yw(i,h)+yw(s,x)+a+14+3*H+yw(z,$)+2*z[16]+3*z[17]+7*z[18];if(l>=0&&K<=W&&K<=J)return gAe(e,u,n.subarray(l,l+c));var ie,ae,Q,re;if(Dm(e,u,1+(J15&&(Dm(e,u,me[O]>>5&127),u+=me[O]>>12)}}else ie=pVe,ae=ev,Q=mVe,re=FM;for(var O=0;O255){var Ae=be>>18&31;vw(e,u,ie[Ae+257]),u+=ae[Ae+257],Ae>7&&(Dm(e,u,be>>23&31),u+=c$[Ae]);var pe=be&31;vw(e,u,Q[pe]),u+=re[pe],pe>3&&(vw(e,u,be>>5&8191),u+=u$[pe])}else vw(e,u,ie[be]),u+=ae[be]}return vw(e,u,ie[256]),u+ae[256]},AVe=new l$([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),AAe=new Z0(0),xVe=function(n,e,t,r,i,s){var a=s.z||n.length,o=new Z0(r+a+5*(1+Math.ceil(a/7e3))+i),l=o.subarray(r,o.length-i),c=s.l,u=(s.r||0)&7;if(e){u&&(l[0]=s.r>>3);for(var d=AVe[e-1],h=d>>13,p=d&8191,g=(1<7e3||$>24576)&&(ie>423||!c)){u=Iie(n,l,0,k,B,U,O,$,H,V-H,u),$=z=O=0,H=V;for(var ae=0;ae<286;++ae)B[ae]=0;for(var ae=0;ae<30;++ae)U[ae]=0}var Q=2,re=0,oe=p,fe=W-J&32767;if(ie>2&&K==C(V-fe))for(var ee=Math.min(h,ie)-1,me=Math.min(32767,V),Ae=Math.min(258,ie);fe<=me&&--oe&&W!=J;){if(n[V+Q]==n[V+Q-fe]){for(var be=0;beQ){if(Q=be,re=fe,be>ee)break;for(var pe=Math.min(fe,be-2),ge=0,ae=0;aege&&(ge=Xe,J=Te)}}}W=J,J=x[W],fe+=W-J&32767}if(re){k[$++]=268435456|Cz[Q]<<18|Lie[re];var Qe=Cz[Q]&31,ot=Lie[re]&31;O+=c$[Qe]+u$[ot],++B[257+Qe],++U[ot],G=V+Q,++z}else k[$++]=n[V],++B[n[V]]}}for(V=Math.max(V,G);V=a&&(l[u/8|0]=c,bt=a),u=gAe(l,u+1,n.subarray(V,bt))}s.i=a}return gVe(o,0,r+mAe(u)+i)},xAe=function(){var n=1,e=0;return{p:function(t){for(var r=n,i=e,s=t.length|0,a=0;a!=s;){for(var o=Math.min(a+2655,s);a>16),i=(i&65535)+15*(i>>16)}n=r,e=i},d:function(){return n%=65521,e%=65521,(n&255)<<24|(n&65280)<<8|(e&255)<<8|e>>8}}},vVe=function(n,e,t,r,i){if(!i&&(i={l:1},e.dictionary)){var s=e.dictionary.subarray(-32768),a=new Z0(s.length+n.length);a.set(s),a.set(n,s.length),n=a,i.w=s.length}return xVe(n,e.level==null?6:e.level,e.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(n.length)))*1.5):20:12+e.mem,t,r,i)},vAe=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8},yVe=function(n,e){var t=e.level,r=t==0?0:t<6?1:t==9?3:2;if(n[0]=120,n[1]=r<<6|(e.dictionary&&32),n[1]|=31-(n[0]<<8|n[1])%31,e.dictionary){var i=xAe();i.p(e.dictionary),vAe(n,2,i.d())}};function Lz(n,e){e||(e={});var t=xAe();t.p(n);var r=vVe(n,e,e.dictionary?6:2,4);return yVe(r,e),vAe(r,r.length-4,t.d()),r}var bVe=typeof TextDecoder<"u"&&new TextDecoder,_Ve=0;try{bVe.decode(AAe,{stream:!0}),_Ve=1}catch{}function wVe(n){if(Array.isArray(n))return n}function SVe(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,i,s,a,o=[],l=!0,c=!1;try{if(s=(t=t.call(n)).next,e!==0)for(;!(l=(r=s.call(t)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}function Die(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t{const n=new Uint8Array(4),e=new Uint32Array(n.buffer);return!((e[0]=1)&n[0])})(),oj={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class d${constructor(e=CVe,t={}){ha(this,"buffer");ha(this,"byteLength");ha(this,"byteOffset");ha(this,"length");ha(this,"offset");ha(this,"lastWrittenByte");ha(this,"littleEndian");ha(this,"_data");ha(this,"_mark");ha(this,"_marks");let r=!1;typeof e=="number"?e=new ArrayBuffer(e):(r=!0,this.lastWrittenByte=e.byteLength);const i=t.offset?t.offset>>>0:0,s=e.byteLength-i;let a=i;(ArrayBuffer.isView(e)||e instanceof d$)&&(e.byteLength!==e.buffer.byteLength&&(a=e.byteOffset+i),e=e.buffer),r?this.lastWrittenByte=s:this.lastWrittenByte=0,this.buffer=e,this.length=s,this.byteLength=s,this.byteOffset=a,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,a,s),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const r=(this.offset+e)*2,i=new Uint8Array(r);i.set(new Uint8Array(this.buffer)),this.buffer=i.buffer,this.length=r,this.byteLength=r,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,t){const r=oj[t].BYTES_PER_ELEMENT*e,i=this.byteOffset+this.offset,s=this.buffer.slice(i,i+r);if(this.littleEndian===PVe&&t!=="uint8"&&t!=="int8"){const o=new Uint8Array(this.buffer.slice(i,i+r));o.reverse();const l=new oj[t](o.buffer);return this.offset+=r,l.reverse(),l}const a=new oj[t](s);return this.offset+=r,a}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t="";for(let r=0;rthis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function R3(n){let e=n.length;for(;--e>=0;)n[e]=0}const RVe=3,LVe=258,yAe=29,kVe=256,IVe=kVe+1+yAe,bAe=30,DVe=512,OVe=new Array((IVe+2)*2);R3(OVe);const jVe=new Array(bAe*2);R3(jVe);const FVe=new Array(DVe);R3(FVe);const BVe=new Array(LVe-RVe+1);R3(BVe);const UVe=new Array(yAe);R3(UVe);const zVe=new Array(bAe);R3(zVe);const VVe=(n,e,t,r)=>{let i=n&65535|0,s=n>>>16&65535|0,a=0;for(;t!==0;){a=t>2e3?2e3:t,t-=a;do i=i+e[r++]|0,s=s+i|0;while(--a);i%=65521,s%=65521}return i|s<<16|0};var kz=VVe;const qVe=()=>{let n,e=[];for(var t=0;t<256;t++){n=t;for(var r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return e},GVe=new Uint32Array(qVe()),HVe=(n,e,t,r)=>{const i=GVe,s=r+t;n^=-1;for(let a=r;a>>8^i[(n^e[a])&255];return n^-1};var vp=HVe,Iz={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},_Ae={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const $Ve=(n,e)=>Object.prototype.hasOwnProperty.call(n,e);var WVe=function(n){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const r in t)$Ve(t,r)&&(n[r]=t[r])}}return n},XVe=n=>{let e=0;for(let r=0,i=n.length;r=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;nS[254]=nS[254]=1;var YVe=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let e,t,r,i,s,a=n.length,o=0;for(i=0;i>>6,e[s++]=128|t&63):t<65536?(e[s++]=224|t>>>12,e[s++]=128|t>>>6&63,e[s++]=128|t&63):(e[s++]=240|t>>>18,e[s++]=128|t>>>12&63,e[s++]=128|t>>>6&63,e[s++]=128|t&63);return e};const ZVe=(n,e)=>{if(e<65534&&n.subarray&&SAe)return String.fromCharCode.apply(null,n.length===e?n:n.subarray(0,e));let t="";for(let r=0;r{const t=e||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,e));let r,i;const s=new Array(t*2);for(i=0,r=0;r4){s[i++]=65533,r+=o-1;continue}for(a&=o===2?31:o===3?15:7;o>1&&r1){s[i++]=65533;continue}a<65536?s[i++]=a:(a-=65536,s[i++]=55296|a>>10&1023,s[i++]=56320|a&1023)}return ZVe(s,i)},KVe=(n,e)=>{e=e||n.length,e>n.length&&(e=n.length);let t=e-1;for(;t>=0&&(n[t]&192)===128;)t--;return t<0||t===0?e:t+nS[n[t]]>e?t:e},Dz={string2buf:YVe,buf2string:QVe,utf8border:KVe};function JVe(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var eqe=JVe;const xT=16209,tqe=16191;var nqe=function(e,t){let r,i,s,a,o,l,c,u,d,h,p,g,x,_,y,M,C,k,B,U,z,O,V,$;const G=e.state;r=e.next_in,V=e.input,i=r+(e.avail_in-5),s=e.next_out,$=e.output,a=s-(t-e.avail_out),o=s+(e.avail_out-257),l=G.dmax,c=G.wsize,u=G.whave,d=G.wnext,h=G.window,p=G.hold,g=G.bits,x=G.lencode,_=G.distcode,y=(1<>>24,p>>>=k,g-=k,k=C>>>16&255,k===0)$[s++]=C&65535;else if(k&16){B=C&65535,k&=15,k&&(g>>=k,g-=k),g<15&&(p+=V[r++]<>>24,p>>>=k,g-=k,k=C>>>16&255,k&16){if(U=C&65535,k&=15,gl){e.msg="invalid distance too far back",G.mode=xT;break e}if(p>>>=k,g-=k,k=s-a,U>k){if(k=U-k,k>u&&G.sane){e.msg="invalid distance too far back",G.mode=xT;break e}if(z=0,O=h,d===0){if(z+=c-k,k2;)$[s++]=O[z++],$[s++]=O[z++],$[s++]=O[z++],B-=3;B&&($[s++]=O[z++],B>1&&($[s++]=O[z++]))}else{z=s-U;do $[s++]=$[z++],$[s++]=$[z++],$[s++]=$[z++],B-=3;while(B>2);B&&($[s++]=$[z++],B>1&&($[s++]=$[z++]))}}else if(k&64){e.msg="invalid distance code",G.mode=xT;break e}else{C=_[(C&65535)+(p&(1<>3,r-=B,g-=B<<3,p&=(1<{const l=o.bits;let c=0,u=0,d=0,h=0,p=0,g=0,x=0,_=0,y=0,M=0,C,k,B,U,z,O=null,V;const $=new Uint16Array(My+1),G=new Uint16Array(My+1);let H=null,K,W,J;for(c=0;c<=My;c++)$[c]=0;for(u=0;u=1&&$[h]===0;h--);if(p>h&&(p=h),h===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,o.bits=1,0;for(d=1;d0&&(n===Uie||h!==1))return-1;for(G[1]=0,c=1;cFie||n===zie&&y>Bie)return 1;for(;;){K=c-x,a[u]+1=V?(W=H[a[u]-V],J=O[a[u]-V]):(W=96,J=0),C=1<>x)+k]=K<<24|W<<16|J|0;while(k!==0);for(C=1<>=1;if(C!==0?(M&=C-1,M+=C):M=0,u++,--$[c]===0){if(c===h)break;c=e[t+a[u]]}if(c>p&&(M&U)!==B){for(x===0&&(x=p),z+=d,g=c-x,_=1<Fie||n===zie&&y>Bie)return 1;B=M&U,i[B]=p<<24|g<<16|z-s|0}}return M!==0&&(i[z+M]=c-x<<24|64<<16|0),o.bits=p,0};var s4=oqe;const lqe=0,TAe=1,EAe=2,{Z_FINISH:Vie,Z_BLOCK:cqe,Z_TREES:vT,Z_OK:tv,Z_STREAM_END:uqe,Z_NEED_DICT:dqe,Z_STREAM_ERROR:Jf,Z_DATA_ERROR:NAe,Z_MEM_ERROR:MAe,Z_BUF_ERROR:hqe,Z_DEFLATED:qie}=_Ae,aP=16180,Gie=16181,Hie=16182,$ie=16183,Wie=16184,Xie=16185,Yie=16186,Zie=16187,Qie=16188,Kie=16189,BM=16190,Om=16191,cj=16192,Jie=16193,uj=16194,ese=16195,tse=16196,nse=16197,rse=16198,yT=16199,bT=16200,ise=16201,sse=16202,ase=16203,ose=16204,lse=16205,dj=16206,cse=16207,use=16208,xo=16209,CAe=16210,PAe=16211,fqe=852,pqe=592,mqe=15,gqe=mqe,dse=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24);function Aqe(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Qv=n=>{if(!n)return 1;const e=n.state;return!e||e.strm!==n||e.modePAe?1:0},RAe=n=>{if(Qv(n))return Jf;const e=n.state;return n.total_in=n.total_out=e.total=0,n.msg="",e.wrap&&(n.adler=e.wrap&1),e.mode=aP,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(fqe),e.distcode=e.distdyn=new Int32Array(pqe),e.sane=1,e.back=-1,tv},LAe=n=>{if(Qv(n))return Jf;const e=n.state;return e.wsize=0,e.whave=0,e.wnext=0,RAe(n)},kAe=(n,e)=>{let t;if(Qv(n))return Jf;const r=n.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?Jf:(r.window!==null&&r.wbits!==e&&(r.window=null),r.wrap=t,r.wbits=e,LAe(n))},IAe=(n,e)=>{if(!n)return Jf;const t=new Aqe;n.state=t,t.strm=n,t.window=null,t.mode=aP;const r=kAe(n,e);return r!==tv&&(n.state=null),r},xqe=n=>IAe(n,gqe);let hse=!0,hj,fj;const vqe=n=>{if(hse){hj=new Int32Array(512),fj=new Int32Array(32);let e=0;for(;e<144;)n.lens[e++]=8;for(;e<256;)n.lens[e++]=9;for(;e<280;)n.lens[e++]=7;for(;e<288;)n.lens[e++]=8;for(s4(TAe,n.lens,0,288,hj,0,n.work,{bits:9}),e=0;e<32;)n.lens[e++]=5;s4(EAe,n.lens,0,32,fj,0,n.work,{bits:5}),hse=!1}n.lencode=hj,n.lenbits=9,n.distcode=fj,n.distbits=5},DAe=(n,e,t,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<=s.wsize?(s.window.set(e.subarray(t-s.wsize,t),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(e.subarray(t-r,t-r+i),s.wnext),r-=i,r?(s.window.set(e.subarray(t-r,t),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave{let t,r,i,s,a,o,l,c,u,d,h,p,g,x,_=0,y,M,C,k,B,U,z,O;const V=new Uint8Array(4);let $,G;const H=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Qv(n)||!n.output||!n.input&&n.avail_in!==0)return Jf;t=n.state,t.mode===Om&&(t.mode=cj),a=n.next_out,i=n.output,l=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=t.hold,u=t.bits,d=o,h=l,O=tv;e:for(;;)switch(t.mode){case aP:if(t.wrap===0){t.mode=cj;break}for(;u<16;){if(o===0)break e;o--,c+=r[s++]<>>8&255,t.check=vp(t.check,V,2,0),c=0,u=0,t.mode=Gie;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((c&255)<<8)+(c>>8))%31){n.msg="incorrect header check",t.mode=xo;break}if((c&15)!==qie){n.msg="unknown compression method",t.mode=xo;break}if(c>>>=4,u-=4,z=(c&15)+8,t.wbits===0&&(t.wbits=z),z>15||z>t.wbits){n.msg="invalid window size",t.mode=xo;break}t.dmax=1<>8&1),t.flags&512&&t.wrap&4&&(V[0]=c&255,V[1]=c>>>8&255,t.check=vp(t.check,V,2,0)),c=0,u=0,t.mode=Hie;case Hie:for(;u<32;){if(o===0)break e;o--,c+=r[s++]<>>8&255,V[2]=c>>>16&255,V[3]=c>>>24&255,t.check=vp(t.check,V,4,0)),c=0,u=0,t.mode=$ie;case $ie:for(;u<16;){if(o===0)break e;o--,c+=r[s++]<>8),t.flags&512&&t.wrap&4&&(V[0]=c&255,V[1]=c>>>8&255,t.check=vp(t.check,V,2,0)),c=0,u=0,t.mode=Wie;case Wie:if(t.flags&1024){for(;u<16;){if(o===0)break e;o--,c+=r[s++]<>>8&255,t.check=vp(t.check,V,2,0)),c=0,u=0}else t.head&&(t.head.extra=null);t.mode=Xie;case Xie:if(t.flags&1024&&(p=t.length,p>o&&(p=o),p&&(t.head&&(z=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(r.subarray(s,s+p),z)),t.flags&512&&t.wrap&4&&(t.check=vp(t.check,r,p,s)),o-=p,s+=p,t.length-=p),t.length))break e;t.length=0,t.mode=Yie;case Yie:if(t.flags&2048){if(o===0)break e;p=0;do z=r[s+p++],t.head&&z&&t.length<65536&&(t.head.name+=String.fromCharCode(z));while(z&&p>9&1,t.head.done=!0),n.adler=t.check=0,t.mode=Om;break;case Kie:for(;u<32;){if(o===0)break e;o--,c+=r[s++]<>>=u&7,u-=u&7,t.mode=dj;break}for(;u<3;){if(o===0)break e;o--,c+=r[s++]<>>=1,u-=1,c&3){case 0:t.mode=Jie;break;case 1:if(vqe(t),t.mode=yT,e===vT){c>>>=2,u-=2;break e}break;case 2:t.mode=tse;break;case 3:n.msg="invalid block type",t.mode=xo}c>>>=2,u-=2;break;case Jie:for(c>>>=u&7,u-=u&7;u<32;){if(o===0)break e;o--,c+=r[s++]<>>16^65535)){n.msg="invalid stored block lengths",t.mode=xo;break}if(t.length=c&65535,c=0,u=0,t.mode=uj,e===vT)break e;case uj:t.mode=ese;case ese:if(p=t.length,p){if(p>o&&(p=o),p>l&&(p=l),p===0)break e;i.set(r.subarray(s,s+p),a),o-=p,s+=p,l-=p,a+=p,t.length-=p;break}t.mode=Om;break;case tse:for(;u<14;){if(o===0)break e;o--,c+=r[s++]<>>=5,u-=5,t.ndist=(c&31)+1,c>>>=5,u-=5,t.ncode=(c&15)+4,c>>>=4,u-=4,t.nlen>286||t.ndist>30){n.msg="too many length or distance symbols",t.mode=xo;break}t.have=0,t.mode=nse;case nse:for(;t.have>>=3,u-=3}for(;t.have<19;)t.lens[H[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,$={bits:t.lenbits},O=s4(lqe,t.lens,0,19,t.lencode,0,t.work,$),t.lenbits=$.bits,O){n.msg="invalid code lengths set",t.mode=xo;break}t.have=0,t.mode=rse;case rse:for(;t.have>>24,M=_>>>16&255,C=_&65535,!(y<=u);){if(o===0)break e;o--,c+=r[s++]<>>=y,u-=y,t.lens[t.have++]=C;else{if(C===16){for(G=y+2;u>>=y,u-=y,t.have===0){n.msg="invalid bit length repeat",t.mode=xo;break}z=t.lens[t.have-1],p=3+(c&3),c>>>=2,u-=2}else if(C===17){for(G=y+3;u>>=y,u-=y,z=0,p=3+(c&7),c>>>=3,u-=3}else{for(G=y+7;u>>=y,u-=y,z=0,p=11+(c&127),c>>>=7,u-=7}if(t.have+p>t.nlen+t.ndist){n.msg="invalid bit length repeat",t.mode=xo;break}for(;p--;)t.lens[t.have++]=z}}if(t.mode===xo)break;if(t.lens[256]===0){n.msg="invalid code -- missing end-of-block",t.mode=xo;break}if(t.lenbits=9,$={bits:t.lenbits},O=s4(TAe,t.lens,0,t.nlen,t.lencode,0,t.work,$),t.lenbits=$.bits,O){n.msg="invalid literal/lengths set",t.mode=xo;break}if(t.distbits=6,t.distcode=t.distdyn,$={bits:t.distbits},O=s4(EAe,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,$),t.distbits=$.bits,O){n.msg="invalid distances set",t.mode=xo;break}if(t.mode=yT,e===vT)break e;case yT:t.mode=bT;case bT:if(o>=6&&l>=258){n.next_out=a,n.avail_out=l,n.next_in=s,n.avail_in=o,t.hold=c,t.bits=u,nqe(n,h),a=n.next_out,i=n.output,l=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=t.hold,u=t.bits,t.mode===Om&&(t.back=-1);break}for(t.back=0;_=t.lencode[c&(1<>>24,M=_>>>16&255,C=_&65535,!(y<=u);){if(o===0)break e;o--,c+=r[s++]<>k)],y=_>>>24,M=_>>>16&255,C=_&65535,!(k+y<=u);){if(o===0)break e;o--,c+=r[s++]<>>=k,u-=k,t.back+=k}if(c>>>=y,u-=y,t.back+=y,t.length=C,M===0){t.mode=lse;break}if(M&32){t.back=-1,t.mode=Om;break}if(M&64){n.msg="invalid literal/length code",t.mode=xo;break}t.extra=M&15,t.mode=ise;case ise:if(t.extra){for(G=t.extra;u>>=t.extra,u-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=sse;case sse:for(;_=t.distcode[c&(1<>>24,M=_>>>16&255,C=_&65535,!(y<=u);){if(o===0)break e;o--,c+=r[s++]<>k)],y=_>>>24,M=_>>>16&255,C=_&65535,!(k+y<=u);){if(o===0)break e;o--,c+=r[s++]<>>=k,u-=k,t.back+=k}if(c>>>=y,u-=y,t.back+=y,M&64){n.msg="invalid distance code",t.mode=xo;break}t.offset=C,t.extra=M&15,t.mode=ase;case ase:if(t.extra){for(G=t.extra;u>>=t.extra,u-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){n.msg="invalid distance too far back",t.mode=xo;break}t.mode=ose;case ose:if(l===0)break e;if(p=h-l,t.offset>p){if(p=t.offset-p,p>t.whave&&t.sane){n.msg="invalid distance too far back",t.mode=xo;break}p>t.wnext?(p-=t.wnext,g=t.wsize-p):g=t.wnext-p,p>t.length&&(p=t.length),x=t.window}else x=i,g=a-t.offset,p=t.length;p>l&&(p=l),l-=p,t.length-=p;do i[a++]=x[g++];while(--p);t.length===0&&(t.mode=bT);break;case lse:if(l===0)break e;i[a++]=t.length,l--,t.mode=bT;break;case dj:if(t.wrap){for(;u<32;){if(o===0)break e;o--,c|=r[s++]<{if(Qv(n))return Jf;let e=n.state;return e.window&&(e.window=null),n.state=null,tv},_qe=(n,e)=>{if(Qv(n))return Jf;const t=n.state;return t.wrap&2?(t.head=e,e.done=!1,tv):Jf},wqe=(n,e)=>{const t=e.length;let r,i,s;return Qv(n)||(r=n.state,r.wrap!==0&&r.mode!==BM)?Jf:r.mode===BM&&(i=1,i=kz(i,e,t,0),i!==r.check)?NAe:(s=DAe(n,e,t,t),s?(r.mode=CAe,MAe):(r.havedict=1,tv))};var Sqe=LAe,Tqe=kAe,Eqe=RAe,Nqe=xqe,Mqe=IAe,Cqe=yqe,Pqe=bqe,Rqe=_qe,Lqe=wqe,kqe="pako inflate (from Nodeca project)",Qm={inflateReset:Sqe,inflateReset2:Tqe,inflateResetKeep:Eqe,inflateInit:Nqe,inflateInit2:Mqe,inflate:Cqe,inflateEnd:Pqe,inflateGetHeader:Rqe,inflateSetDictionary:Lqe,inflateInfo:kqe};function Iqe(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Dqe=Iqe;const OAe=Object.prototype.toString,{Z_NO_FLUSH:Oqe,Z_FINISH:jqe,Z_OK:rS,Z_STREAM_END:pj,Z_NEED_DICT:mj,Z_STREAM_ERROR:Fqe,Z_DATA_ERROR:fse,Z_MEM_ERROR:Bqe}=_Ae;function ZS(n){this.options=wAe.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(n&&n.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new eqe,this.strm.avail_out=0;let t=Qm.inflateInit2(this.strm,e.windowBits);if(t!==rS)throw new Error(Iz[t]);if(this.header=new Dqe,Qm.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Dz.string2buf(e.dictionary):OAe.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=Qm.inflateSetDictionary(this.strm,e.dictionary),t!==rS)))throw new Error(Iz[t])}ZS.prototype.push=function(n,e){const t=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(e===~~e?a=e:a=e===!0?jqe:Oqe,OAe.call(n)==="[object ArrayBuffer]"?t.input=new Uint8Array(n):t.input=n,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(r),t.next_out=0,t.avail_out=r),s=Qm.inflate(t,a),s===mj&&i&&(s=Qm.inflateSetDictionary(t,i),s===rS?s=Qm.inflate(t,a):s===fse&&(s=mj));t.avail_in>0&&s===pj&&t.state.wrap>0&&n[t.next_in]!==0;)Qm.inflateReset(t),s=Qm.inflate(t,a);switch(s){case Fqe:case fse:case mj:case Bqe:return this.onEnd(s),this.ended=!0,!1}if(o=t.avail_out,t.next_out&&(t.avail_out===0||s===pj))if(this.options.to==="string"){let l=Dz.utf8border(t.output,t.next_out),c=t.next_out-l,u=Dz.buf2string(t.output,l);t.next_out=c,t.avail_out=r-c,c&&t.output.set(t.output.subarray(l,l+c),0),this.onData(u)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(s===rS&&o===0)){if(s===pj)return s=Qm.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};ZS.prototype.onData=function(n){this.chunks.push(n)};ZS.prototype.onEnd=function(n){n===rS&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=wAe.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Uqe(n,e){const t=new ZS(e);if(t.push(n),t.err)throw t.msg||Iz[t.err];return t.result}var zqe=ZS,Vqe=Uqe,qqe={Inflate:zqe,inflate:Vqe};const{Inflate:Gqe,inflate:Hqe}=qqe;var pse=Gqe,$qe=Hqe;const jAe=[];for(let n=0;n<256;n++){let e=n;for(let t=0;t<8;t++)e&1?e=3988292384^e>>>1:e=e>>>1;jAe[n]=e}const mse=4294967295;function Wqe(n,e,t){let r=n;for(let i=0;i>>8;return r}function Xqe(n,e){return(Wqe(mse,n,e)^mse)>>>0}function gse(n,e,t){const r=n.readUint32(),i=Xqe(new Uint8Array(n.buffer,n.byteOffset+n.offset-e-4,e),e);if(i!==r)throw new Error(`CRC mismatch for chunk ${t}. Expected ${r}, found ${i}`)}function FAe(n,e,t){for(let r=0;r>1)&255}else{for(;s>1)&255;for(;s>1)&255}}function VAe(n,e,t,r,i){let s=0;if(t.length===0){for(;s=t||U>=r))for(let z=0;z>8&255}const nGe=new Uint16Array([255]),rGe=new Uint8Array(nGe.buffer),iGe=rGe[0]===255,sGe=new Uint8Array(0);function Ase(n){const{data:e,width:t,height:r,channels:i,depth:s}=n,a=Math.ceil(s/8)*i,o=Math.ceil(s/8*i*t),l=new Uint8Array(r*o);let c=sGe,u=0,d,h;for(let p=0;p>8&255}const lN=Uint8Array.of(137,80,78,71,13,10,26,10);function xse(n){if(!oGe(n.readBytes(lN.length)))throw new Error("wrong PNG signature")}function oGe(n){if(n.length79)throw new Error("keyword length must be between 1 and 79")}const dGe=/^[\u0000-\u00FF]*$/;function hGe(n){if(!dGe.test(n))throw new Error("invalid latin1 text")}function fGe(n,e,t){const r=GAe(e);n[r]=pGe(e,t-r.length-1)}function GAe(n){for(n.mark();n.readByte()!==cGe;);const e=n.offset;n.reset();const t=qAe.decode(n.readBytes(e-n.offset-1));return n.skip(1),uGe(t),t}function pGe(n,e){return qAe.decode(n.readBytes(e))}const Ch={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},gj={UNKNOWN:-1,DEFLATE:0},vse={UNKNOWN:-1,ADAPTIVE:0},Aj={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},_T={NONE:0,BACKGROUND:1,PREVIOUS:2},xj={SOURCE:0,OVER:1};class mGe extends d${constructor(t,r={}){super(t);ha(this,"_checkCrc");ha(this,"_inflator");ha(this,"_png");ha(this,"_apng");ha(this,"_end");ha(this,"_hasPalette");ha(this,"_palette");ha(this,"_hasTransparency");ha(this,"_transparency");ha(this,"_compressionMethod");ha(this,"_filterMethod");ha(this,"_interlaceMethod");ha(this,"_colorType");ha(this,"_isAnimated");ha(this,"_numberOfFrames");ha(this,"_numberOfPlays");ha(this,"_frames");ha(this,"_writingDataChunks");const{checkCrc:i=!1}=r;this._checkCrc=i,this._inflator=new pse,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=gj.UNKNOWN,this._filterMethod=vse.UNKNOWN,this._interlaceMethod=Aj.UNKNOWN,this._colorType=Ch.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(xse(this);!this._end;){const t=this.readUint32(),r=this.readChars(4);this.decodeChunk(t,r)}return this.decodeImage(),this._png}decodeApng(){for(xse(this);!this._end;){const t=this.readUint32(),r=this.readChars(4);this.decodeApngChunk(t,r)}return this.decodeApngImage(),this._apng}decodeChunk(t,r){const i=this.offset;switch(r){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case lGe:fGe(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t);break}if(this.offset-i!==t)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?gse(this,t+4,r):this.skip(4)}decodeApngChunk(t,r){const i=this.offset;switch(r!=="fdAT"&&r!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),r){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,r),this.offset=i+t;break}if(this.offset-i!==t)throw new Error(`Length mismatch while decoding chunk ${r}`);this._checkCrc?gse(this,t+4,r):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=gGe(this.readUint8());const r=this.readUint8();this._colorType=r;let i;switch(r){case Ch.GREYSCALE:i=1;break;case Ch.TRUECOLOUR:i=3;break;case Ch.INDEXED_COLOUR:i=1;break;case Ch.GREYSCALE_ALPHA:i=2;break;case Ch.TRUECOLOUR_ALPHA:i=4;break;case Ch.UNKNOWN:default:throw new Error(`Unknown color type: ${r}`)}if(this._png.channels=i,this._compressionMethod=this.readUint8(),this._compressionMethod!==gj.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);const r=t/3;this._hasPalette=!0;const i=[];this._palette=i;for(let s=0;sthis._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let r=0;rthis._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let r=0;for(;r{const l=((a+r.yOffset)*this._png.width+r.xOffset+o)*this._png.channels,c=(a*r.width+o)*this._png.channels;return{index:l,frameIndex:c}};switch(r.blendOp){case xj.SOURCE:for(let a=0;a=200&&e.status<=299}function wT(n){try{n.dispatchEvent(new MouseEvent("click"))}catch{var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),n.dispatchEvent(e)}}var ax=hi.saveAs||((typeof window>"u"?"undefined":pa(window))!=="object"||window!==hi?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(n,e,t){var r=hi.URL||hi.webkitURL,i=document.createElement("a");e=e||n.name||"download",i.download=e,i.rel="noopener",typeof n=="string"?(i.href=n,i.origin!==location.origin?bse(i.href)?yj(n,e,t):wT(i,i.target="_blank"):wT(i)):(i.href=r.createObjectURL(n),setTimeout(function(){r.revokeObjectURL(i.href)},4e4),setTimeout(function(){wT(i)},0))}:"msSaveOrOpenBlob"in navigator?function(n,e,t){if(e=e||n.name||"download",typeof n=="string")if(bse(n))yj(n,e,t);else{var r=document.createElement("a");r.href=n,r.target="_blank",setTimeout(function(){wT(r)})}else navigator.msSaveOrOpenBlob(function(i,s){return s===void 0?s={autoBom:!1}:pa(s)!=="object"&&(Ra.warn("Deprecated: Expected third argument to be a object"),s={autoBom:!s}),s.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(i.type)?new Blob(["\uFEFF",i],{type:i.type}):i}(n,t),e)}:function(n,e,t,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),typeof n=="string")return yj(n,e,t);var i=n.type==="application/octet-stream",s=/constructor/i.test(hi.HTMLElement)||hi.safari,a=/CriOS\/[\d]+/.test(navigator.userAgent);if((a||i&&s)&&(typeof FileReader>"u"?"undefined":pa(FileReader))==="object"){var o=new FileReader;o.onloadend=function(){var u=o.result;u=a?u:u.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=u:location=u,r=null},o.readAsDataURL(n)}else{var l=hi.URL||hi.webkitURL,c=l.createObjectURL(n);r?r.location=c:location.href=c,r=null,setTimeout(function(){l.revokeObjectURL(c)},4e4)}});/** * A class to parse color values * @author Stoyan Stefanov * {@link http://www.phpied.com/rgb-color-parser-in-javascript/} * @license Use it if you like it */function HAe(n){var e;n=n||"",this.ok=!1,n.charAt(0)=="#"&&(n=n.substr(1,6)),n={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"}[n=(n=n.replace(/ /g,"")).toLowerCase()]||n;for(var t=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(o){return[parseInt(o[1]),parseInt(o[2]),parseInt(o[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(o){return[parseInt(o[1],16),parseInt(o[2],16),parseInt(o[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(o){return[parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16),parseInt(o[3]+o[3],16)]}}],r=0;r255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var o=this.r.toString(16),l=this.g.toString(16),c=this.b.toString(16);return o.length==1&&(o="0"+o),l.length==1&&(l="0"+l),c.length==1&&(c="0"+c),"#"+o+l+c}}var cN=hi.atob.bind(hi),_se=hi.btoa.bind(hi);/** * @license * Joseph Myers does not specify a particular license for his work. * * Author: Joseph Myers * Accessed from: http://www.myersdaily.org/joseph/javascript/md5.js * * Modified by: Owen Leong */function bj(n,e){var t=n[0],r=n[1],i=n[2],s=n[3];t=Ou(t,r,i,s,e[0],7,-680876936),s=Ou(s,t,r,i,e[1],12,-389564586),i=Ou(i,s,t,r,e[2],17,606105819),r=Ou(r,i,s,t,e[3],22,-1044525330),t=Ou(t,r,i,s,e[4],7,-176418897),s=Ou(s,t,r,i,e[5],12,1200080426),i=Ou(i,s,t,r,e[6],17,-1473231341),r=Ou(r,i,s,t,e[7],22,-45705983),t=Ou(t,r,i,s,e[8],7,1770035416),s=Ou(s,t,r,i,e[9],12,-1958414417),i=Ou(i,s,t,r,e[10],17,-42063),r=Ou(r,i,s,t,e[11],22,-1990404162),t=Ou(t,r,i,s,e[12],7,1804603682),s=Ou(s,t,r,i,e[13],12,-40341101),i=Ou(i,s,t,r,e[14],17,-1502002290),t=ju(t,r=Ou(r,i,s,t,e[15],22,1236535329),i,s,e[1],5,-165796510),s=ju(s,t,r,i,e[6],9,-1069501632),i=ju(i,s,t,r,e[11],14,643717713),r=ju(r,i,s,t,e[0],20,-373897302),t=ju(t,r,i,s,e[5],5,-701558691),s=ju(s,t,r,i,e[10],9,38016083),i=ju(i,s,t,r,e[15],14,-660478335),r=ju(r,i,s,t,e[4],20,-405537848),t=ju(t,r,i,s,e[9],5,568446438),s=ju(s,t,r,i,e[14],9,-1019803690),i=ju(i,s,t,r,e[3],14,-187363961),r=ju(r,i,s,t,e[8],20,1163531501),t=ju(t,r,i,s,e[13],5,-1444681467),s=ju(s,t,r,i,e[2],9,-51403784),i=ju(i,s,t,r,e[7],14,1735328473),t=Fu(t,r=ju(r,i,s,t,e[12],20,-1926607734),i,s,e[5],4,-378558),s=Fu(s,t,r,i,e[8],11,-2022574463),i=Fu(i,s,t,r,e[11],16,1839030562),r=Fu(r,i,s,t,e[14],23,-35309556),t=Fu(t,r,i,s,e[1],4,-1530992060),s=Fu(s,t,r,i,e[4],11,1272893353),i=Fu(i,s,t,r,e[7],16,-155497632),r=Fu(r,i,s,t,e[10],23,-1094730640),t=Fu(t,r,i,s,e[13],4,681279174),s=Fu(s,t,r,i,e[0],11,-358537222),i=Fu(i,s,t,r,e[3],16,-722521979),r=Fu(r,i,s,t,e[6],23,76029189),t=Fu(t,r,i,s,e[9],4,-640364487),s=Fu(s,t,r,i,e[12],11,-421815835),i=Fu(i,s,t,r,e[15],16,530742520),t=Bu(t,r=Fu(r,i,s,t,e[2],23,-995338651),i,s,e[0],6,-198630844),s=Bu(s,t,r,i,e[7],10,1126891415),i=Bu(i,s,t,r,e[14],15,-1416354905),r=Bu(r,i,s,t,e[5],21,-57434055),t=Bu(t,r,i,s,e[12],6,1700485571),s=Bu(s,t,r,i,e[3],10,-1894986606),i=Bu(i,s,t,r,e[10],15,-1051523),r=Bu(r,i,s,t,e[1],21,-2054922799),t=Bu(t,r,i,s,e[8],6,1873313359),s=Bu(s,t,r,i,e[15],10,-30611744),i=Bu(i,s,t,r,e[6],15,-1560198380),r=Bu(r,i,s,t,e[13],21,1309151649),t=Bu(t,r,i,s,e[4],6,-145523070),s=Bu(s,t,r,i,e[11],10,-1120210379),i=Bu(i,s,t,r,e[2],15,718787259),r=Bu(r,i,s,t,e[9],21,-343485551),n[0]=oA(t,n[0]),n[1]=oA(r,n[1]),n[2]=oA(i,n[2]),n[3]=oA(s,n[3])}function oP(n,e,t,r,i,s){return e=oA(oA(e,n),oA(r,s)),oA(e<>>32-i,t)}function Ou(n,e,t,r,i,s,a){return oP(e&t|~e&r,n,e,i,s,a)}function ju(n,e,t,r,i,s,a){return oP(e&r|t&~r,n,e,i,s,a)}function Fu(n,e,t,r,i,s,a){return oP(e^t^r,n,e,i,s,a)}function Bu(n,e,t,r,i,s,a){return oP(t^(e|~r),n,e,i,s,a)}function $Ae(n){var e,t=n.length,r=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=n.length;e+=64)bj(r,xGe(n.substring(e-64,e)));n=n.substring(e-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e>2]|=n.charCodeAt(e)<<(e%4<<3);if(i[e>>2]|=128<<(e%4<<3),e>55)for(bj(r,i),e=0;e<16;e++)i[e]=0;return i[14]=8*t,bj(r,i),r}function xGe(n){var e,t=[];for(e=0;e<64;e+=4)t[e>>2]=n.charCodeAt(e)+(n.charCodeAt(e+1)<<8)+(n.charCodeAt(e+2)<<16)+(n.charCodeAt(e+3)<<24);return t}var wse="0123456789abcdef".split("");function vGe(n){for(var e="",t=0;t<4;t++)e+=wse[n>>8*t+4&15]+wse[n>>8*t&15];return e}function yGe(n){return String.fromCharCode(255&n,(65280&n)>>8,(16711680&n)>>16,(4278190080&n)>>24)}function Oz(n){return $Ae(n).map(yGe).join("")}var bGe=function(n){for(var e=0;e>16)+(e>>16)+(t>>16)<<16|65535&t}return n+e&4294967295}/** * @license * FPDF is released under a permissive license: there is no usage restriction. * You may embed it freely in your application (commercial or not), with or * without modifications. * * Reference: http://www.fpdf.org/en/script/script37.php */function jz(n,e){var t,r,i,s;if(n!==t){for(var a=(i=n,s=1+(256/n.length|0),new Array(s+1).join(i)),o=[],l=0;l<256;l++)o[l]=l;var c=0;for(l=0;l<256;l++){var u=o[l];c=(c+u+a.charCodeAt(l))%256,o[l]=o[c],o[c]=u}t=n,r=o}else o=r;var d=e.length,h=0,p=0,g="";for(l=0;l€/\f©þdSiz";var s=(e+this.padding).substr(0,32),a=(t+this.padding).substr(0,32);this.O=this.processOwnerPassword(s,a),this.P=-(1+(255^i)),this.encryptionKey=Oz(s+this.O+this.lsbFirstWord(this.P)+this.hexToBytes(r)).substr(0,5),this.U=jz(this.encryptionKey,this.padding)}function Nb(n){if(/[^\u0000-\u00ff]/.test(n))throw new Error("Invalid PDF Name Object: "+n+", Only accept ASCII characters.");for(var e="",t=n.length,r=0;r126?"#"+("0"+i.toString(16)).slice(-2):n[r]}return e}function Tse(n){if(pa(n)!=="object")throw new Error("Invalid Context passed to initialize PubSub (jsPDF-module)");var e={};this.subscribe=function(t,r,i){if(i=i||!1,typeof t!="string"||typeof r!="function"||typeof i!="boolean")throw new Error("Invalid arguments passed to PubSub.subscribe (jsPDF-module)");e.hasOwnProperty(t)||(e[t]={});var s=Math.random().toString(35);return e[t][s]=[r,!!i],s},this.unsubscribe=function(t){for(var r in e)if(e[r][t])return delete e[r][t],Object.keys(e[r]).length===0&&delete e[r],!0;return!1},this.publish=function(t){if(e.hasOwnProperty(t)){var r=Array.prototype.slice.call(arguments,1),i=[];for(var s in e[t]){var a=e[t][s];try{a[0].apply(n,r)}catch(o){hi.console&&Ra.error("jsPDF PubSub Error",o.message,o)}a[1]&&i.push(s)}i.length&&i.forEach(this.unsubscribe)}},this.getTopics=function(){return e}}function UM(n){if(!(this instanceof UM))return new UM(n);var e="opacity,stroke-opacity".split(",");for(var t in n)n.hasOwnProperty(t)&&e.indexOf(t)>=0&&(this[t]=n[t]);this.id="",this.objectNumber=-1}function WAe(n,e){this.gState=n,this.matrix=e,this.id="",this.objectNumber=-1}function ux(n,e,t,r,i){if(!(this instanceof ux))return new ux(n,e,t,r,i);this.type=n==="axial"?2:3,this.coords=e,this.colors=t,WAe.call(this,r,i)}function Kb(n,e,t,r,i){if(!(this instanceof Kb))return new Kb(n,e,t,r,i);this.boundingBox=n,this.xStep=e,this.yStep=t,this.stream="",this.cloneIndex=0,WAe.call(this,r,i)}function Cr(n){var e,t=typeof arguments[0]=="string"?arguments[0]:"p",r=arguments[1],i=arguments[2],s=arguments[3],a=[],o=1,l=16,c="S",u=null;pa(n=n||{})==="object"&&(t=n.orientation,r=n.unit||r,i=n.format||i,s=n.compress||n.compressPdf||s,(u=n.encryption||null)!==null&&(u.userPassword=u.userPassword||"",u.ownerPassword=u.ownerPassword||"",u.userPermissions=u.userPermissions||[]),o=typeof n.userUnit=="number"?Math.abs(n.userUnit):1,n.precision!==void 0&&(e=n.precision),n.floatPrecision!==void 0&&(l=n.floatPrecision),c=n.defaultPathOperation||"S"),a=n.filters||(s===!0?["FlateEncode"]:a),r=r||"mm",t=(""+(t||"P")).toLowerCase();var d=n.putOnlyUsedFonts||!1,h={},p={internal:{},__private__:{}};p.__private__.PubSub=Tse;var g="1.3",x=p.__private__.getPdfVersion=function(){return g};p.__private__.setPdfVersion=function(ce){g=ce};var _={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],dl:[311.81,623.62],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224],"credit-card":[153,243]};p.__private__.getPageFormats=function(){return _};var y=p.__private__.getPageFormat=function(ce){return _[ce]};i=i||"a4";var M="compat",C="advanced",k=M;function B(){this.saveGraphicsState(),Ce(new ut(ct,0,0,-ct,0,Ws()*ct).toString()+" cm"),this.setFontSize(this.getFontSize()/ct),c="n",k=C}function U(){this.restoreGraphicsState(),c="S",k=M}var z=p.__private__.combineFontStyleAndFontWeight=function(ce,Oe){if(ce=="bold"&&Oe=="normal"||ce=="bold"&&Oe==400||ce=="normal"&&Oe=="italic"||ce=="bold"&&Oe=="italic")throw new Error("Invalid Combination of fontweight and fontstyle");return Oe&&(ce=Oe==400||Oe==="normal"?ce==="italic"?"italic":"normal":Oe!=700&&Oe!=="bold"||ce!=="normal"?(Oe==700?"bold":Oe)+""+ce:"bold"),ce};p.advancedAPI=function(ce){var Oe=k===M;return Oe&&B.call(this),typeof ce!="function"||(ce(this),Oe&&U.call(this)),this},p.compatAPI=function(ce){var Oe=k===C;return Oe&&U.call(this),typeof ce!="function"||(ce(this),Oe&&B.call(this)),this},p.isAdvancedAPI=function(){return k===C};var O,V=function(ce){if(k!==C)throw new Error(ce+" is only available in 'advanced' API mode. You need to call advancedAPI() first.")},$=p.roundToPrecision=p.__private__.roundToPrecision=function(ce,Oe){var at=e||Oe;if(isNaN(ce)||isNaN(at))throw new Error("Invalid argument passed to jsPDF.roundToPrecision");return ce.toFixed(at).replace(/0+$/,"")};O=p.hpf=p.__private__.hpf=typeof l=="number"?function(ce){if(isNaN(ce))throw new Error("Invalid argument passed to jsPDF.hpf");return $(ce,l)}:l==="smart"?function(ce){if(isNaN(ce))throw new Error("Invalid argument passed to jsPDF.hpf");return $(ce,ce>-1&&ce<1?16:5)}:function(ce){if(isNaN(ce))throw new Error("Invalid argument passed to jsPDF.hpf");return $(ce,16)};var G=p.f2=p.__private__.f2=function(ce){if(isNaN(ce))throw new Error("Invalid argument passed to jsPDF.f2");return $(ce,2)},H=p.__private__.f3=function(ce){if(isNaN(ce))throw new Error("Invalid argument passed to jsPDF.f3");return $(ce,3)},K=p.scale=p.__private__.scale=function(ce){if(isNaN(ce))throw new Error("Invalid argument passed to jsPDF.scale");return k===M?ce*ct:k===C?ce:void 0},W=function(ce){return K(function(Oe){return k===M?Ws()-Oe:k===C?Oe:void 0}(ce))};p.__private__.setPrecision=p.setPrecision=function(ce){typeof parseInt(ce,10)=="number"&&(e=parseInt(ce,10))};var J,ie="00000000000000000000000000000000",ae=p.__private__.getFileId=function(){return ie},Q=p.__private__.setFileId=function(ce){return ie=ce!==void 0&&/^[a-fA-F0-9]{32}$/.test(ce)?ce.toUpperCase():ie.split("").map(function(){return"ABCDEF0123456789".charAt(Math.floor(16*Math.random()))}).join(""),u!==null&&(In=new Eb(u.userPermissions,u.userPassword,u.ownerPassword,ie)),ie};p.setFileId=function(ce){return Q(ce),this},p.getFileId=function(){return ae()};var re=p.__private__.convertDateToPDFDate=function(ce){var Oe=ce.getTimezoneOffset(),at=Oe<0?"+":"-",Et=Math.floor(Math.abs(Oe/60)),qt=Math.abs(Oe%60),un=[at,Ae(Et),"'",Ae(qt),"'"].join("");return["D:",ce.getFullYear(),Ae(ce.getMonth()+1),Ae(ce.getDate()),Ae(ce.getHours()),Ae(ce.getMinutes()),Ae(ce.getSeconds()),un].join("")},oe=p.__private__.convertPDFDateToDate=function(ce){var Oe=parseInt(ce.substr(2,4),10),at=parseInt(ce.substr(6,2),10)-1,Et=parseInt(ce.substr(8,2),10),qt=parseInt(ce.substr(10,2),10),un=parseInt(ce.substr(12,2),10),gn=parseInt(ce.substr(14,2),10);return new Date(Oe,at,Et,qt,un,gn,0)},fe=p.__private__.setCreationDate=function(ce){var Oe;if(ce===void 0&&(ce=new Date),ce instanceof Date)Oe=re(ce);else{if(!/^D:(20[0-2][0-9]|203[0-7]|19[7-9][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])(0[0-9]|1[0-9]|2[0-3])(0[0-9]|[1-5][0-9])(0[0-9]|[1-5][0-9])(\+0[0-9]|\+1[0-4]|-0[0-9]|-1[0-1])'(0[0-9]|[1-5][0-9])'?$/.test(ce))throw new Error("Invalid argument passed to jsPDF.setCreationDate");Oe=ce}return J=Oe},ee=p.__private__.getCreationDate=function(ce){var Oe=J;return ce==="jsDate"&&(Oe=oe(J)),Oe};p.setCreationDate=function(ce){return fe(ce),this},p.getCreationDate=function(ce){return ee(ce)};var me,Ae=p.__private__.padd2=function(ce){return("0"+parseInt(ce)).slice(-2)},be=p.__private__.padd2Hex=function(ce){return("00"+(ce=ce.toString())).substr(ce.length)},pe=0,ge=[],Te=[],ze=0,Xe=[],Qe=[],ot=!1,bt=Te;p.__private__.setCustomOutputDestination=function(ce){ot=!0,bt=ce};var ht=function(ce){ot||(bt=ce)};p.__private__.resetCustomOutputDestination=function(){ot=!1,bt=Te};var Ce=p.__private__.out=function(ce){return ce=ce.toString(),ze+=ce.length+1,bt.push(ce),bt},lt=p.__private__.write=function(ce){return Ce(arguments.length===1?ce.toString():Array.prototype.join.call(arguments," "))},ft=p.__private__.getArrayBuffer=function(ce){for(var Oe=ce.length,at=new ArrayBuffer(Oe),Et=new Uint8Array(at);Oe--;)Et[Oe]=ce.charCodeAt(Oe);return at},et=[["Helvetica","helvetica","normal","WinAnsiEncoding"],["Helvetica-Bold","helvetica","bold","WinAnsiEncoding"],["Helvetica-Oblique","helvetica","italic","WinAnsiEncoding"],["Helvetica-BoldOblique","helvetica","bolditalic","WinAnsiEncoding"],["Courier","courier","normal","WinAnsiEncoding"],["Courier-Bold","courier","bold","WinAnsiEncoding"],["Courier-Oblique","courier","italic","WinAnsiEncoding"],["Courier-BoldOblique","courier","bolditalic","WinAnsiEncoding"],["Times-Roman","times","normal","WinAnsiEncoding"],["Times-Bold","times","bold","WinAnsiEncoding"],["Times-Italic","times","italic","WinAnsiEncoding"],["Times-BoldItalic","times","bolditalic","WinAnsiEncoding"],["ZapfDingbats","zapfdingbats","normal",null],["Symbol","symbol","normal",null]];p.__private__.getStandardFonts=function(){return et};var At=n.fontSize||16;p.__private__.setFontSize=p.setFontSize=function(ce){return At=k===C?ce/ct:ce,this};var Lt,st=p.__private__.getFontSize=p.getFontSize=function(){return k===M?At:At*ct},Ht=n.R2L||!1;p.__private__.setR2L=p.setR2L=function(ce){return Ht=ce,this},p.__private__.getR2L=p.getR2L=function(){return Ht};var Se,_t=p.__private__.setZoomMode=function(ce){if(/^(?:\d+\.\d*|\d*\.\d+|\d+)%$/.test(ce))Lt=ce;else if(isNaN(ce)){if([void 0,null,"fullwidth","fullheight","fullpage","original"].indexOf(ce)===-1)throw new Error('zoom must be Integer (e.g. 2), a percentage Value (e.g. 300%) or fullwidth, fullheight, fullpage, original. "'+ce+'" is not recognized.');Lt=ce}else Lt=parseInt(ce,10)};p.__private__.getZoomMode=function(){return Lt};var It,De=p.__private__.setPageMode=function(ce){if([void 0,null,"UseNone","UseOutlines","UseThumbs","FullScreen"].indexOf(ce)==-1)throw new Error('Page mode must be one of UseNone, UseOutlines, UseThumbs, or FullScreen. "'+ce+'" is not recognized.');Se=ce};p.__private__.getPageMode=function(){return Se};var ue=p.__private__.setLayoutMode=function(ce){if([void 0,null,"continuous","single","twoleft","tworight","two"].indexOf(ce)==-1)throw new Error('Layout mode must be one of continuous, single, twoleft, tworight. "'+ce+'" is not recognized.');It=ce};p.__private__.getLayoutMode=function(){return It},p.__private__.setDisplayMode=p.setDisplayMode=function(ce,Oe,at){return _t(ce),ue(Oe),De(at),this};var Ve={title:"",subject:"",author:"",keywords:"",creator:""};p.__private__.getDocumentProperty=function(ce){if(Object.keys(Ve).indexOf(ce)===-1)throw new Error("Invalid argument passed to jsPDF.getDocumentProperty");return Ve[ce]},p.__private__.getDocumentProperties=function(){return Ve},p.__private__.setDocumentProperties=p.setProperties=p.setDocumentProperties=function(ce){for(var Oe in Ve)Ve.hasOwnProperty(Oe)&&ce[Oe]&&(Ve[Oe]=ce[Oe]);return this},p.__private__.setDocumentProperty=function(ce,Oe){if(Object.keys(Ve).indexOf(ce)===-1)throw new Error("Invalid arguments passed to jsPDF.setDocumentProperty");return Ve[ce]=Oe};var We,ct,vt,Ut,dt,mt={},Ft={},tt=[],Pe={},nt={},qe={},yt={},Qt=null,Be=0,pt=[],rt=new Tse(p),zt=n.hotfixes||[],Yt={},Bt={},$e=[],ut=function ce(Oe,at,Et,qt,un,gn){if(!(this instanceof ce))return new ce(Oe,at,Et,qt,un,gn);isNaN(Oe)&&(Oe=1),isNaN(at)&&(at=0),isNaN(Et)&&(Et=0),isNaN(qt)&&(qt=1),isNaN(un)&&(un=0),isNaN(gn)&&(gn=0),this._matrix=[Oe,at,Et,qt,un,gn]};Object.defineProperty(ut.prototype,"sx",{get:function(){return this._matrix[0]},set:function(ce){this._matrix[0]=ce}}),Object.defineProperty(ut.prototype,"shy",{get:function(){return this._matrix[1]},set:function(ce){this._matrix[1]=ce}}),Object.defineProperty(ut.prototype,"shx",{get:function(){return this._matrix[2]},set:function(ce){this._matrix[2]=ce}}),Object.defineProperty(ut.prototype,"sy",{get:function(){return this._matrix[3]},set:function(ce){this._matrix[3]=ce}}),Object.defineProperty(ut.prototype,"tx",{get:function(){return this._matrix[4]},set:function(ce){this._matrix[4]=ce}}),Object.defineProperty(ut.prototype,"ty",{get:function(){return this._matrix[5]},set:function(ce){this._matrix[5]=ce}}),Object.defineProperty(ut.prototype,"a",{get:function(){return this._matrix[0]},set:function(ce){this._matrix[0]=ce}}),Object.defineProperty(ut.prototype,"b",{get:function(){return this._matrix[1]},set:function(ce){this._matrix[1]=ce}}),Object.defineProperty(ut.prototype,"c",{get:function(){return this._matrix[2]},set:function(ce){this._matrix[2]=ce}}),Object.defineProperty(ut.prototype,"d",{get:function(){return this._matrix[3]},set:function(ce){this._matrix[3]=ce}}),Object.defineProperty(ut.prototype,"e",{get:function(){return this._matrix[4]},set:function(ce){this._matrix[4]=ce}}),Object.defineProperty(ut.prototype,"f",{get:function(){return this._matrix[5]},set:function(ce){this._matrix[5]=ce}}),Object.defineProperty(ut.prototype,"rotation",{get:function(){return Math.atan2(this.shx,this.sx)}}),Object.defineProperty(ut.prototype,"scaleX",{get:function(){return this.decompose().scale.sx}}),Object.defineProperty(ut.prototype,"scaleY",{get:function(){return this.decompose().scale.sy}}),Object.defineProperty(ut.prototype,"isIdentity",{get:function(){return this.sx===1&&this.shy===0&&this.shx===0&&this.sy===1&&this.tx===0&&this.ty===0}}),ut.prototype.join=function(ce){return[this.sx,this.shy,this.shx,this.sy,this.tx,this.ty].map(O).join(ce)},ut.prototype.multiply=function(ce){var Oe=ce.sx*this.sx+ce.shy*this.shx,at=ce.sx*this.shy+ce.shy*this.sy,Et=ce.shx*this.sx+ce.sy*this.shx,qt=ce.shx*this.shy+ce.sy*this.sy,un=ce.tx*this.sx+ce.ty*this.shx+this.tx,gn=ce.tx*this.shy+ce.ty*this.sy+this.ty;return new ut(Oe,at,Et,qt,un,gn)},ut.prototype.decompose=function(){var ce=this.sx,Oe=this.shy,at=this.shx,Et=this.sy,qt=this.tx,un=this.ty,gn=Math.sqrt(ce*ce+Oe*Oe),dr=(ce/=gn)*at+(Oe/=gn)*Et;at-=ce*dr,Et-=Oe*dr;var ar=Math.sqrt(at*at+Et*Et);return dr/=ar,ce*(Et/=ar)>16&255,Et=ar>>8&255,qt=255&ar}if(Et===void 0||un===void 0&&at===Et&&Et===qt)Oe=typeof at=="string"?at+" "+gn[0]:ce.precision===2?G(at/255)+" "+gn[0]:H(at/255)+" "+gn[0];else if(un===void 0||pa(un)==="object"){if(un&&!isNaN(un.a)&&un.a===0)return["1.","1.","1.",gn[1]].join(" ");Oe=typeof at=="string"?[at,Et,qt,gn[1]].join(" "):ce.precision===2?[G(at/255),G(Et/255),G(qt/255),gn[1]].join(" "):[H(at/255),H(Et/255),H(qt/255),gn[1]].join(" ")}else Oe=typeof at=="string"?[at,Et,qt,un,gn[2]].join(" "):ce.precision===2?[G(at),G(Et),G(qt),G(un),gn[2]].join(" "):[H(at),H(Et),H(qt),H(un),gn[2]].join(" ");return Oe},Hn=p.__private__.getFilters=function(){return a},lr=p.__private__.putStream=function(ce){var Oe=(ce=ce||{}).data||"",at=ce.filters||Hn(),Et=ce.alreadyAppliedFilters||[],qt=ce.addLength1||!1,un=Oe.length,gn=ce.objectId,dr=function(Ns){return Ns};if(u!==null&&gn===void 0)throw new Error("ObjectId must be passed to putStream for file encryption");u!==null&&(dr=In.encryptor(gn,0));var ar={};at===!0&&(at=["FlateEncode"]);var Dr=ce.additionalKeyValues||[],Gr=(ar=Cr.API.processDataByFilters!==void 0?Cr.API.processDataByFilters(Oe,at):{data:Oe,reverseChain:[]}).reverseChain+(Array.isArray(Et)?Et.join(" "):Et.toString());if(ar.data.length!==0&&(Dr.push({key:"Length",value:ar.data.length}),qt===!0&&Dr.push({key:"Length1",value:un})),Gr.length!=0)if(Gr.split("/").length-1==1)Dr.push({key:"Filter",value:Gr});else{Dr.push({key:"Filter",value:"["+Gr+"]"});for(var Ni=0;Ni>"),ar.data.length!==0&&(Ce("stream"),Ce(dr(ar.data)),Ce("endstream"))},jr=p.__private__.putPage=function(ce){var Oe=ce.number,at=ce.data,Et=ce.objId,qt=ce.contentsObjId;Ie(Et,!0),Ce("<>"),Ce("endobj");var un=at.join(` `);return k===C&&(un+=` Q`),Ie(qt,!0),lr({data:un,filters:Hn(),objectId:qt}),Ce("endobj"),Et},Qr=p.__private__.putPages=function(){var ce,Oe,at=[];for(ce=1;ce<=Be;ce++)pt[ce].objId=m(),pt[ce].contentsObjId=m();for(ce=1;ce<=Be;ce++)at.push(jr({number:ce,data:Qe[ce],objId:pt[ce].objId,contentsObjId:pt[ce].contentsObjId,mediaBox:pt[ce].mediaBox,cropBox:pt[ce].cropBox,bleedBox:pt[ce].bleedBox,trimBox:pt[ce].trimBox,artBox:pt[ce].artBox,userUnit:pt[ce].userUnit,rootDictionaryObjId:Ln,resourceDictionaryObjId:Rn}));Ie(Ln,!0),Ce("<>"),Ce("endobj"),rt.publish("postPutPages")},Os=function(ce){rt.publish("putFont",{font:ce,out:Ce,newObject:Nt,putStream:lr}),ce.isAlreadyPutted!==!0&&(ce.objectNumber=Nt(),Ce("<<"),Ce("/Type /Font"),Ce("/BaseFont /"+Nb(ce.postScriptName)),Ce("/Subtype /Type1"),typeof ce.encoding=="string"&&Ce("/Encoding /"+ce.encoding),Ce("/FirstChar 32"),Ce("/LastChar 255"),Ce(">>"),Ce("endobj"))},la=function(ce){ce.objectNumber=Nt();var Oe=[];Oe.push({key:"Type",value:"/XObject"}),Oe.push({key:"Subtype",value:"/Form"}),Oe.push({key:"BBox",value:"["+[O(ce.x),O(ce.y),O(ce.x+ce.width),O(ce.y+ce.height)].join(" ")+"]"}),Oe.push({key:"Matrix",value:"["+ce.matrix.toString()+"]"});var at=ce.pages[1].join(` `);lr({data:at,additionalKeyValues:Oe,objectId:ce.objectNumber}),Ce("endobj")},Pi=function(ce,Oe){Oe||(Oe=21);var at=Nt(),Et=function(gn,dr){var ar,Dr=[],Gr=1/(dr-1);for(ar=0;ar<1;ar+=Gr)Dr.push(ar);if(Dr.push(1),gn[0].offset!=0){var Ni={offset:0,color:gn[0].color};gn.unshift(Ni)}if(gn[gn.length-1].offset!=1){var sa={offset:1,color:gn[gn.length-1].color};gn.push(sa)}for(var us="",Fi=0,Ns=0;Nsgn[Fi+1].offset;)Fi++;var ps=gn[Fi].offset,Bi=(ar-ps)/(gn[Fi+1].offset-ps),Xs=gn[Fi].color,Hr=gn[Fi+1].color;us+=be(Math.round((1-Bi)*Xs[0]+Bi*Hr[0]).toString(16))+be(Math.round((1-Bi)*Xs[1]+Bi*Hr[1]).toString(16))+be(Math.round((1-Bi)*Xs[2]+Bi*Hr[2]).toString(16))}return us.trim()}(ce.colors,Oe),qt=[];qt.push({key:"FunctionType",value:"0"}),qt.push({key:"Domain",value:"[0.0 1.0]"}),qt.push({key:"Size",value:"["+Oe+"]"}),qt.push({key:"BitsPerSample",value:"8"}),qt.push({key:"Range",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),qt.push({key:"Decode",value:"[0.0 1.0 0.0 1.0 0.0 1.0]"}),lr({data:Et,additionalKeyValues:qt,alreadyAppliedFilters:["/ASCIIHexDecode"],objectId:at}),Ce("endobj"),ce.objectNumber=Nt(),Ce("<< /ShadingType "+ce.type),Ce("/ColorSpace /DeviceRGB");var un="/Coords ["+O(parseFloat(ce.coords[0]))+" "+O(parseFloat(ce.coords[1]))+" ";ce.type===2?un+=O(parseFloat(ce.coords[2]))+" "+O(parseFloat(ce.coords[3])):un+=O(parseFloat(ce.coords[2]))+" "+O(parseFloat(ce.coords[3]))+" "+O(parseFloat(ce.coords[4]))+" "+O(parseFloat(ce.coords[5])),Ce(un+="]"),ce.matrix&&Ce("/Matrix ["+ce.matrix.toString()+"]"),Ce("/Function "+at+" 0 R"),Ce("/Extend [true true]"),Ce(">>"),Ce("endobj")},ra=function(ce,Oe){var at=m(),Et=Nt();Oe.push({resourcesOid:at,objectOid:Et}),ce.objectNumber=Et;var qt=[];qt.push({key:"Type",value:"/Pattern"}),qt.push({key:"PatternType",value:"1"}),qt.push({key:"PaintType",value:"1"}),qt.push({key:"TilingType",value:"1"}),qt.push({key:"BBox",value:"["+ce.boundingBox.map(O).join(" ")+"]"}),qt.push({key:"XStep",value:O(ce.xStep)}),qt.push({key:"YStep",value:O(ce.yStep)}),qt.push({key:"Resources",value:at+" 0 R"}),ce.matrix&&qt.push({key:"Matrix",value:"["+ce.matrix.toString()+"]"}),lr({data:ce.stream,additionalKeyValues:qt,objectId:ce.objectNumber}),Ce("endobj")},cs=function(ce){for(var Oe in ce.objectNumber=Nt(),Ce("<<"),ce)switch(Oe){case"opacity":Ce("/ca "+G(ce[Oe]));break;case"stroke-opacity":Ce("/CA "+G(ce[Oe]))}Ce(">>"),Ce("endobj")},Jn=function(ce){Ie(ce.resourcesOid,!0),Ce("<<"),Ce("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),function(){for(var Oe in Ce("/Font <<"),mt)mt.hasOwnProperty(Oe)&&(d===!1||d===!0&&h.hasOwnProperty(Oe))&&Ce("/"+Oe+" "+mt[Oe].objectNumber+" 0 R");Ce(">>")}(),function(){if(Object.keys(Pe).length>0){for(var Oe in Ce("/Shading <<"),Pe)Pe.hasOwnProperty(Oe)&&Pe[Oe]instanceof ux&&Pe[Oe].objectNumber>=0&&Ce("/"+Oe+" "+Pe[Oe].objectNumber+" 0 R");rt.publish("putShadingPatternDict"),Ce(">>")}}(),function(Oe){if(Object.keys(Pe).length>0){for(var at in Ce("/Pattern <<"),Pe)Pe.hasOwnProperty(at)&&Pe[at]instanceof p.TilingPattern&&Pe[at].objectNumber>=0&&Pe[at].objectNumber>")}}(ce.objectOid),function(){if(Object.keys(qe).length>0){var Oe;for(Oe in Ce("/ExtGState <<"),qe)qe.hasOwnProperty(Oe)&&qe[Oe].objectNumber>=0&&Ce("/"+Oe+" "+qe[Oe].objectNumber+" 0 R");rt.publish("putGStateDict"),Ce(">>")}}(),function(){for(var Oe in Ce("/XObject <<"),Yt)Yt.hasOwnProperty(Oe)&&Yt[Oe].objectNumber>=0&&Ce("/"+Oe+" "+Yt[Oe].objectNumber+" 0 R");rt.publish("putXobjectDict"),Ce(">>")}(),Ce(">>"),Ce("endobj")},wa=function(ce){Ft[ce.fontName]=Ft[ce.fontName]||{},Ft[ce.fontName][ce.fontStyle]=ce.id},Ii=function(ce,Oe,at,Et,qt){var un={id:"F"+(Object.keys(mt).length+1).toString(10),postScriptName:ce,fontName:Oe,fontStyle:at,encoding:Et,isStandardFont:qt||!1,metadata:{}};return rt.publish("addFont",{font:un,instance:this}),mt[un.id]=un,wa(un),un.id},Ge=p.__private__.pdfEscape=p.pdfEscape=function(ce,Oe){return function(at,Et){var qt,un,gn,dr,ar,Dr,Gr,Ni,sa;if(gn=(Et=Et||{}).sourceEncoding||"Unicode",ar=Et.outputEncoding,(Et.autoencode||ar)&&mt[We].metadata&&mt[We].metadata[gn]&&mt[We].metadata[gn].encoding&&(dr=mt[We].metadata[gn].encoding,!ar&&mt[We].encoding&&(ar=mt[We].encoding),!ar&&dr.codePages&&(ar=dr.codePages[0]),typeof ar=="string"&&(ar=dr[ar]),ar)){for(Gr=!1,Dr=[],qt=0,un=at.length;qt>8&&(Gr=!0);at=Dr.join("")}for(qt=at.length;Gr===void 0&&qt!==0;)at.charCodeAt(qt-1)>>8&&(Gr=!0),qt--;if(!Gr)return at;for(Dr=Et.noBOM?[]:[254,255],qt=0,un=at.length;qt>8)>>8)throw new Error("Character at position "+qt+" of string '"+at+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");Dr.push(sa),Dr.push(Ni-(sa<<8))}return String.fromCharCode.apply(void 0,Dr)}(ce,Oe).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},wt=p.__private__.beginPage=function(ce){Qe[++Be]=[],pt[Be]={objId:0,contentsObjId:0,userUnit:Number(o),artBox:null,bleedBox:null,cropBox:null,trimBox:null,mediaBox:{bottomLeftX:0,bottomLeftY:0,topRightX:Number(ce[0]),topRightY:Number(ce[1])}},Xt(Be),ht(Qe[me])},_e=function(ce,Oe){var at,Et,qt;switch(t=Oe||t,typeof ce=="string"&&(at=y(ce.toLowerCase()),Array.isArray(at)&&(Et=at[0],qt=at[1])),Array.isArray(ce)&&(Et=ce[0]*ct,qt=ce[1]*ct),isNaN(Et)&&(Et=i[0],qt=i[1]),(Et>14400||qt>14400)&&(Ra.warn("A page in a PDF can not be wider or taller than 14400 userUnit. jsPDF limits the width/height to 14400"),Et=Math.min(14400,Et),qt=Math.min(14400,qt)),i=[Et,qt],t.substr(0,1)){case"l":qt>Et&&(i=[qt,Et]);break;case"p":Et>qt&&(i=[qt,Et])}wt(i),es(Dn),Ce(Fs),yc!==0&&Ce(yc+" J"),bc!==0&&Ce(bc+" j"),rt.publish("addPage",{pageNumber:Be})},Dt=function(ce){ce>0&&ce<=Be&&(Qe.splice(ce,1),pt.splice(ce,1),Be--,me>Be&&(me=Be),this.setPage(me))},Xt=function(ce){ce>0&&ce<=Be&&(me=ce)},vn=p.__private__.getNumberOfPages=p.getNumberOfPages=function(){return Qe.length-1},Sn=function(ce,Oe,at){var Et,qt=void 0;return at=at||{},ce=ce!==void 0?ce:mt[We].fontName,Oe=Oe!==void 0?Oe:mt[We].fontStyle,Et=ce.toLowerCase(),Ft[Et]!==void 0&&Ft[Et][Oe]!==void 0?qt=Ft[Et][Oe]:Ft[ce]!==void 0&&Ft[ce][Oe]!==void 0?qt=Ft[ce][Oe]:at.disableWarning===!1&&Ra.warn("Unable to look up font label for font '"+ce+"', '"+Oe+"'. Refer to getFontList() for available fonts."),qt||at.noFallback||(qt=Ft.times[Oe])==null&&(qt=Ft.times.normal),qt},hn=p.__private__.putInfo=function(){var ce=Nt(),Oe=function(Et){return Et};for(var at in u!==null&&(Oe=In.encryptor(ce,0)),Ce("<<"),Ce("/Producer ("+Ge(Oe("jsPDF "+Cr.version))+")"),Ve)Ve.hasOwnProperty(at)&&Ve[at]&&Ce("/"+at.substr(0,1).toUpperCase()+at.substr(1)+" ("+Ge(Oe(Ve[at]))+")");Ce("/CreationDate ("+Ge(Oe(J))+")"),Ce(">>"),Ce("endobj")},Tn=p.__private__.putCatalog=function(ce){var Oe=(ce=ce||{}).rootDictionaryObjId||Ln;switch(Nt(),Ce("<<"),Ce("/Type /Catalog"),Ce("/Pages "+Oe+" 0 R"),Lt||(Lt="fullwidth"),Lt){case"fullwidth":Ce("/OpenAction [3 0 R /FitH null]");break;case"fullheight":Ce("/OpenAction [3 0 R /FitV null]");break;case"fullpage":Ce("/OpenAction [3 0 R /Fit]");break;case"original":Ce("/OpenAction [3 0 R /XYZ null null 1]");break;default:var at=""+Lt;at.substr(at.length-1)==="%"&&(Lt=parseInt(Lt)/100),typeof Lt=="number"&&Ce("/OpenAction [3 0 R /XYZ null null "+G(Lt)+"]")}switch(It||(It="continuous"),It){case"continuous":Ce("/PageLayout /OneColumn");break;case"single":Ce("/PageLayout /SinglePage");break;case"two":case"twoleft":Ce("/PageLayout /TwoColumnLeft");break;case"tworight":Ce("/PageLayout /TwoColumnRight")}Se&&Ce("/PageMode /"+Se),rt.publish("putCatalog"),Ce(">>"),Ce("endobj")},Re=p.__private__.putTrailer=function(){Ce("trailer"),Ce("<<"),Ce("/Size "+(pe+1)),Ce("/Root "+pe+" 0 R"),Ce("/Info "+(pe-1)+" 0 R"),u!==null&&Ce("/Encrypt "+In.oid+" 0 R"),Ce("/ID [ <"+ie+"> <"+ie+"> ]"),Ce(">>")},Wn=p.__private__.putHeader=function(){Ce("%PDF-"+g),Ce("%ºß¬à")},Ar=p.__private__.putXRef=function(){var ce="0000000000";Ce("xref"),Ce("0 "+(pe+1)),Ce("0000000000 65535 f ");for(var Oe=1;Oe<=pe;Oe++)typeof ge[Oe]=="function"?Ce((ce+ge[Oe]()).slice(-10)+" 00000 n "):ge[Oe]!==void 0?Ce((ce+ge[Oe]).slice(-10)+" 00000 n "):Ce("0000000000 00000 n ")},Un=p.__private__.buildDocument=function(){var ce;pe=0,ze=0,Te=[],ge=[],Xe=[],Ln=m(),Rn=m(),ht(Te),rt.publish("buildDocument"),Wn(),Qr(),function(){rt.publish("putAdditionalObjects");for(var at=0;at"),Ce("/O <"+In.toHexString(In.O)+">"),Ce("/P "+In.P),Ce(">>"),Ce("endobj")),hn(),Tn();var Oe=ze;return Ar(),Re(),Ce("startxref"),Ce(""+Oe),Ce("%%EOF"),ht(Qe[me]),Te.join(` `)},zn=p.__private__.getBlob=function(ce){return new Blob([ft(ce)],{type:"application/pdf"})},Nr=function(ce){for(;ce.firstChild;)ce.removeChild(ce.firstChild)},ii=function(ce){var Oe,at=ce.document,Et=at.documentElement,qt=at.head,un=at.body;return qt||(qt=at.createElement("head"),Et.appendChild(qt)),un||(un=at.createElement("body"),Et.appendChild(un)),Nr(qt),Nr(un),(Oe=at.createElement("style")).appendChild(at.createTextNode("html, body { padding: 0; margin: 0; } iframe { width: 100%; height: 100%; border: 0;}")),qt.appendChild(Oe),{document:at,body:un}},Kr=p.output=p.__private__.output=(nn=function(ce,Oe){switch(typeof(Oe=Oe||{})=="string"?Oe={filename:Oe}:Oe.filename=Oe.filename||"generated.pdf",ce){case void 0:return Un();case"save":p.save(Oe.filename);break;case"arraybuffer":return ft(Un());case"blob":return zn(Un());case"bloburi":case"bloburl":if(hi.URL!==void 0&&typeof hi.URL.createObjectURL=="function")return hi.URL&&hi.URL.createObjectURL(zn(Un()))||void 0;Ra.warn("bloburl is not supported by your system, because URL.createObjectURL is not supported by your browser.");break;case"datauristring":case"dataurlstring":var at="",Et=Un();try{at=_se(Et)}catch{at=_se(unescape(encodeURIComponent(Et)))}return"data:application/pdf;filename="+encodeURIComponent(Oe.filename)+";base64,"+at;case"pdfobjectnewwindow":if(Object.prototype.toString.call(hi)==="[object Window]"){var qt="https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.1.1/pdfobject.min.js",un=!Oe.pdfObjectUrl;un||(qt=Oe.pdfObjectUrl);var gn=hi.open();if(gn!==null){var dr=ii(gn),ar=dr.document.createElement("script"),Dr=this;ar.src=qt,un&&(ar.integrity="sha512-4ze/a9/4jqu+tX9dfOqJYSvyYd5M6qum/3HpCLr+/Jqf0whc37VUbkpNGHR7/8pSnCFw47T1fmIpwBV7UySh3g==",ar.crossOrigin="anonymous"),ar.onload=function(){gn.PDFObject.embed(Dr.output("dataurlstring"),Oe)},dr.body.appendChild(ar)}return gn}throw new Error("The option pdfobjectnewwindow just works in a browser-environment.");case"pdfjsnewwindow":if(Object.prototype.toString.call(hi)==="[object Window]"){var Gr=Oe.pdfJsUrl||"examples/PDF.js/web/viewer.html",Ni=hi.open();if(Ni!==null){var sa=ii(Ni),us=sa.document.createElement("iframe"),Fi=Gr.indexOf("?")===-1?"?":"&";Dr=this,us.id="pdfViewer",us.width="500px",us.height="400px",us.src=Gr+Fi+"file=&downloadName="+encodeURIComponent(Oe.filename),us.onload=function(){Ni.document.title=Oe.filename,us.contentWindow.PDFViewerApplication.open(Dr.output("bloburl"))},sa.body.appendChild(us)}return Ni}throw new Error("The option pdfjsnewwindow just works in a browser-environment.");case"dataurlnewwindow":if(Object.prototype.toString.call(hi)!=="[object Window]")throw new Error("The option dataurlnewwindow just works in a browser-environment.");var Ns=hi.open();if(Ns!==null){var ps=ii(Ns),Bi=ps.document.createElement("iframe");Bi.src=this.output("datauristring",Oe),ps.body.appendChild(Bi),Ns.document.title=Oe.filename}if(Ns||typeof safari>"u")return Ns;break;case"datauri":case"dataurl":return hi.document.location.href=this.output("datauristring",Oe);default:return null}},nn.foo=function(){try{return nn.apply(this,arguments)}catch(at){var ce=at.stack||"";~ce.indexOf(" at ")&&(ce=ce.split(" at ")[1]);var Oe="Error in function "+ce.split(` `)[0].split("<")[0]+": "+at.message;if(!hi.console)throw new Error(Oe);hi.console.error(Oe,at),hi.alert&&alert(Oe)}},nn.foo.bar=nn,nn.foo),Ir=function(ce){return Array.isArray(zt)===!0&&zt.indexOf(ce)>-1};switch(r){case"pt":ct=1;break;case"mm":ct=72/25.4;break;case"cm":ct=72/2.54;break;case"in":ct=72;break;case"px":ct=Ir("px_scaling")==1?.75:96/72;break;case"pc":case"em":ct=12;break;case"ex":ct=6;break;default:if(typeof r!="number")throw new Error("Invalid unit: "+r);ct=r}var In=null;fe(),Q();var Ri=p.__private__.getPageInfo=p.getPageInfo=function(ce){if(isNaN(ce)||ce%1!=0)throw new Error("Invalid argument passed to jsPDF.getPageInfo");return{objId:pt[ce].objId,pageNumber:ce,pageContext:pt[ce]}},sr=p.__private__.getPageInfoByObjId=function(ce){if(isNaN(ce)||ce%1!=0)throw new Error("Invalid argument passed to jsPDF.getPageInfoByObjId");for(var Oe in pt)if(pt[Oe].objId===ce)break;return Ri(Oe)},Ai=p.__private__.getCurrentPageInfo=p.getCurrentPageInfo=function(){return{objId:pt[me].objId,pageNumber:me,pageContext:pt[me]}};p.addPage=function(){return _e.apply(this,arguments),this},p.setPage=function(){return Xt.apply(this,arguments),ht.call(this,Qe[me]),this},p.insertPage=function(ce){return this.addPage(),this.movePage(me,ce),this},p.movePage=function(ce,Oe){var at,Et;if(ce>Oe){at=Qe[ce],Et=pt[ce];for(var qt=ce;qt>Oe;qt--)Qe[qt]=Qe[qt-1],pt[qt]=pt[qt-1];Qe[Oe]=at,pt[Oe]=Et,this.setPage(Oe)}else if(ce0&&(typeof ce=="string"?ce=Fi.splitTextToSize(ce,Gr):Object.prototype.toString.call(ce)==="[object Array]"&&(ce=ce.reduce(function(ts,Br){return ts.concat(Fi.splitTextToSize(Br,Gr))},[]))),un={text:ce,x:Oe,y:at,options:Et,mutex:{pdfEscape:Ge,activeFontKey:We,fonts:mt,activeFontSize:At}},rt.publish("preProcessText",un),ce=un.text,dr=(Et=un.options).angle,us instanceof ut==0&&dr&&typeof dr=="number"){dr*=Math.PI/180,Et.rotationDirection===0&&(dr=-dr),k===C&&(dr=-dr);var Co=Math.cos(dr),ms=Math.sin(dr);us=new ut(Co,ms,-ms,Co,0,0)}else dr&&dr instanceof ut&&(us=dr);k!==C||us||(us=it),(Dr=Et.charSpace||Zo)!==void 0&&(Bi+=O(K(Dr))+` Tc `,this.setCharSpace(this.getCharSpace()||0)),(sa=Et.horizontalScale)!==void 0&&(Bi+=O(100*sa)+` Tz `),Et.lang;var Ms=-1,$r=Et.renderingMode!==void 0?Et.renderingMode:Et.stroke,wc=Fi.internal.getCurrentPageInfo().pageContext;switch($r){case 0:case!1:case"fill":Ms=0;break;case 1:case!0:case"stroke":Ms=1;break;case 2:case"fillThenStroke":Ms=2;break;case 3:case"invisible":Ms=3;break;case 4:case"fillAndAddForClipping":Ms=4;break;case 5:case"strokeAndAddPathForClipping":Ms=5;break;case 6:case"fillThenStrokeAndAddToPathForClipping":Ms=6;break;case 7:case"addToPathForClipping":Ms=7}var Na=wc.usedRenderingMode!==void 0?wc.usedRenderingMode:-1;Ms!==-1?Bi+=Ms+` Tr `:Na!==-1&&(Bi+=`0 Tr `),Ms!==-1&&(wc.usedRenderingMode=Ms),ar=Et.align||"left";var po,Po=At*Xs,Ul=Fi.internal.pageSize.getWidth(),Yc=mt[We];Dr=Et.charSpace||Zo,Gr=Et.maxWidth||0,Ni=Object.assign({autoencode:!0,noBOM:!0},Et.flags);var hd=[],el=function(ts){return Fi.getStringUnitWidth(ts,{font:Yc,charSpace:Dr,fontSize:At,doKerning:!1})*At/Hr};if(Object.prototype.toString.call(ce)==="[object Array]"){var Ys;gn=_c(ce),ar!=="left"&&(po=gn.map(el));var tl,Sc=0;if(ar==="right"){Oe-=po[0],ce=[],Li=gn.length;for(var ec=0;ec0?(Gr-po[Ui])/Ro:0;Ui":")"),rl=parseFloat(gn[ua][1]),Tc=parseFloat(gn[ua][2]);break;case 0:Hi=(ps?"<":"(")+gn[ua]+(ps?">":")"),rl=Gs(Oe),Tc=Ya(at)}hd!==void 0&&hd[ua]!==void 0&&(Eu=hd[ua]+` Tw `),ua===0?ce.push(Eu+Zc(rl,Tc,us)+Hi):tc===0?ce.push(Eu+Hi):tc===1&&ce.push(Eu+Zc(rl,Tc,us)+Hi)}ce=tc===0?ce.join(` Tj T* `):ce.join(` Tj `),ce+=` Tj `;var da=`BT /`;return da+=We+" "+At+` Tf `,da+=O(At*Xs)+` TL `,da+=Hs+` `,da+=Bi,da+=ce,Ce(da+="ET"),h[We]=!0,Fi};var fs=p.__private__.clip=p.clip=function(ce){return Ce(ce==="evenodd"?"W*":"W"),this};p.clipEvenOdd=function(){return fs("evenodd")},p.__private__.discardPath=p.discardPath=function(){return Ce("n"),this};var Ki=p.__private__.isValidStyle=function(ce){var Oe=!1;return[void 0,null,"S","D","F","DF","FD","f","f*","B","B*","n"].indexOf(ce)!==-1&&(Oe=!0),Oe};p.__private__.setDefaultPathOperation=p.setDefaultPathOperation=function(ce){return Ki(ce)&&(c=ce),this};var js=p.__private__.getStyle=p.getStyle=function(ce){var Oe=c;switch(ce){case"D":case"S":Oe="S";break;case"F":Oe="f";break;case"FD":case"DF":Oe="B";break;case"f":case"f*":case"B":case"B*":Oe=ce}return Oe},oi=p.close=function(){return Ce("h"),this};p.stroke=function(){return Ce("S"),this},p.fill=function(ce){return Ei("f",ce),this},p.fillEvenOdd=function(ce){return Ei("f*",ce),this},p.fillStroke=function(ce){return Ei("B",ce),this},p.fillStrokeEvenOdd=function(ce){return Ei("B*",ce),this};var Ei=function(ce,Oe){pa(Oe)==="object"?Ji(Oe,ce):Ce(ce)},ja=function(ce){ce===null||k===C&&ce===void 0||(ce=js(ce),Ce(ce))};function fi(ce,Oe,at,Et,qt){var un=new Kb(Oe||this.boundingBox,at||this.xStep,Et||this.yStep,this.gState,qt||this.matrix);un.stream=this.stream;var gn=ce+"$$"+this.cloneIndex+++"$$";return Ot(gn,un),un}var Ji=function(ce,Oe){var at=nt[ce.key],Et=Pe[at];if(Et instanceof ux)Ce("q"),Ce(Sa(Oe)),Et.gState&&p.setGState(Et.gState),Ce(ce.matrix.toString()+" cm"),Ce("/"+at+" sh"),Ce("Q");else if(Et instanceof Kb){var qt=new ut(1,0,0,-1,0,Ws());ce.matrix&&(qt=qt.multiply(ce.matrix||it),at=fi.call(Et,ce.key,ce.boundingBox,ce.xStep,ce.yStep,qt).id),Ce("q"),Ce("/Pattern cs"),Ce("/"+at+" scn"),Et.gState&&p.setGState(Et.gState),Ce(Oe),Ce("Q")}},Sa=function(ce){switch(ce){case"f":case"F":case"n":return"W n";case"f*":return"W* n";case"B":case"S":return"W S";case"B*":return"W* S"}},Fa=p.moveTo=function(ce,Oe){return Ce(O(K(ce))+" "+O(W(Oe))+" m"),this},Wo=p.lineTo=function(ce,Oe){return Ce(O(K(ce))+" "+O(W(Oe))+" l"),this},nr=p.curveTo=function(ce,Oe,at,Et,qt,un){return Ce([O(K(ce)),O(W(Oe)),O(K(at)),O(W(Et)),O(K(qt)),O(W(un)),"c"].join(" ")),this};p.__private__.line=p.line=function(ce,Oe,at,Et,qt){if(isNaN(ce)||isNaN(Oe)||isNaN(at)||isNaN(Et)||!Ki(qt))throw new Error("Invalid arguments passed to jsPDF.line");return k===M?this.lines([[at-ce,Et-Oe]],ce,Oe,[1,1],qt||"S"):this.lines([[at-ce,Et-Oe]],ce,Oe,[1,1]).stroke()},p.__private__.lines=p.lines=function(ce,Oe,at,Et,qt,un){var gn,dr,ar,Dr,Gr,Ni,sa,us,Fi,Ns,ps,Bi;if(typeof ce=="number"&&(Bi=at,at=Oe,Oe=ce,ce=Bi),Et=Et||[1,1],un=un||!1,isNaN(Oe)||isNaN(at)||!Array.isArray(ce)||!Array.isArray(Et)||!Ki(qt)||typeof un!="boolean")throw new Error("Invalid arguments passed to jsPDF.lines");for(Fa(Oe,at),gn=Et[0],dr=Et[1],Dr=ce.length,Ns=Oe,ps=at,ar=0;ar>8&255,n>>16&255,n>>24&255)},Eb.prototype.toHexString=function(n){return n.split("").map(function(e){return("0"+(255&e.charCodeAt(0)).toString(16)).slice(-2)}).join("")},Eb.prototype.hexToBytes=function(n){for(var e=[],t=0;t>8&255,n>>16&255,255&e,e>>8&255)).substr(0,10);return function(r){return jz(t,r)}},UM.prototype.equals=function(n){var e,t="id,objectNumber,equals";if(!n||pa(n)!==pa(this))return!1;var r=0;for(e in this)if(!(t.indexOf(e)>=0)){if(this.hasOwnProperty(e)&&!n.hasOwnProperty(e)||this[e]!==n[e])return!1;r++}for(e in n)n.hasOwnProperty(e)&&t.indexOf(e)<0&&r--;return r===0},Cr.API={events:[]},Cr.version="4.2.1";var ll=Cr.API,h$=1,Kv=function(n){return n.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},Cy=function(n){return n.replace(/\\\\/g,"\\").replace(/\\\(/g,"(").replace(/\\\)/g,")")},nv=function(n){return n.toString().replace(/#/g,"#23").replace(/[\s\n\r()<>[\]{}\/%]/g,function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return"#"+(t.length===1?"0"+t:t)})},vi=function(n){return n.toFixed(2)},v1=function(n){return n.toFixed(5)};ll.__acroform__={};var vh=function(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n},Ese=function(n){return n*h$},Op=function(n){var e=new YAe,t=_r.internal.getHeight(n)||0,r=_r.internal.getWidth(n)||0;return e.BBox=[0,0,Number(vi(r)),Number(vi(t))],e},_Ge=ll.__acroform__.setBit=function(n,e){if(n=n||0,e=e||0,isNaN(n)||isNaN(e))throw new Error("Invalid arguments passed to jsPDF.API.__acroform__.setBit");return n|1<0;){e="",s--;var c,u,d=ST("3",n,s).height,h=n.multiline?a-s:(a-d)/2,p=h+=2,g=0,x=0,_=0;if(s<=0){e=`(...) Tj `,e+="% Width of Text: "+ST(e,n,s=12).width+", FieldWidth:"+o+` `;break}for(var y="",M=0,C=0;Ca)continue e;y+=i[C][_],k=!0,x=C,C--}else{y=(y+=i[C][_]+" ").substr(y.length-1)==" "?y.substr(0,y.length-1):y;var B=parseInt(C),U=l(B,y,s),z=C>=i.length-1;if(U&&!z){y+=" ",_=0;continue}if(U||z){if(z)x=B;else if(n.multiline&&(d+2)*(M+2)+2>a)continue e}else{if(!n.multiline||(d+2)*(M+2)+2>a)continue e;x=B}}for(var O="",V=g;V<=x;V++){var $=i[V];if(n.multiline){if(V===x){O+=$[_]+" ",_=(_+1)%$.length;continue}if(V===g){O+=$[$.length-1]+" ";continue}}O+=$[0]+" "}switch(O=O.substr(O.length-1)==" "?O.substr(0,O.length-1):O,u=ST(O,n,s).width,n.textAlign){case"right":c=o-u-2;break;case"center":c=(o-u)/2;break;default:c=2}e+=vi(c)+" "+vi(p)+` Td `,e+="("+Kv(O)+`) Tj `,e+=-vi(c)+` 0 Td `,p=-(s+2),u=0,g=k?x:x+1,M++,y=""}break}return r.text=e,r.fontSize=s,r},ST=function(n,e,t){var r=e.scope.internal.getFont(e.fontName,e.fontStyle),i=e.scope.getStringUnitWidth(n,{font:r,fontSize:parseFloat(t),charSpace:0})*parseFloat(t);return{height:e.scope.getStringUnitWidth("3",{font:r,fontSize:parseFloat(t),charSpace:0})*parseFloat(t)*1.5,width:i}},NGe={fields:[],xForms:[],acroFormDictionaryRoot:null,printedOut:!1,internal:null,isInitialized:!1},MGe=function(n,e){var t={type:"reference",object:n};e.internal.getPageInfo(n.page).pageContext.annotations.find(function(r){return r.type===t.type&&r.object===t.object})===void 0&&e.internal.getPageInfo(n.page).pageContext.annotations.push(t)},CGe=function(n,e){if(e.scope=n,n.internal!==void 0&&(n.internal.acroformPlugin===void 0||n.internal.acroformPlugin.isInitialized===!1)){if(sp.FieldNum=0,n.internal.acroformPlugin=JSON.parse(JSON.stringify(NGe)),n.internal.acroformPlugin.acroFormDictionaryRoot)throw new Error("Exception while creating AcroformDictionary");h$=n.internal.scaleFactor,n.internal.acroformPlugin.acroFormDictionaryRoot=new ZAe,n.internal.acroformPlugin.acroFormDictionaryRoot.scope=n,n.internal.acroformPlugin.acroFormDictionaryRoot._eventID=n.internal.events.subscribe("postPutResources",function(){(function(t){t.internal.events.unsubscribe(t.internal.acroformPlugin.acroFormDictionaryRoot._eventID),delete t.internal.acroformPlugin.acroFormDictionaryRoot._eventID,t.internal.acroformPlugin.printedOut=!0})(n)}),n.internal.events.subscribe("buildDocument",function(){(function(t){t.internal.acroformPlugin.acroFormDictionaryRoot.objId=void 0;var r=t.internal.acroformPlugin.acroFormDictionaryRoot.Fields;for(var i in r)if(r.hasOwnProperty(i)){var s=r[i];s.objId=void 0,s.hasAnnotation&&MGe(s,t)}})(n)}),n.internal.events.subscribe("putCatalog",function(){(function(t){if(t.internal.acroformPlugin.acroFormDictionaryRoot===void 0)throw new Error("putCatalogCallback: Root missing.");t.internal.write("/AcroForm "+t.internal.acroformPlugin.acroFormDictionaryRoot.objId+" 0 R")})(n)}),n.internal.events.subscribe("postPutPages",function(t){(function(r,i){var s=!r;for(var a in r||(i.internal.newObjectDeferredBegin(i.internal.acroformPlugin.acroFormDictionaryRoot.objId,!0),i.internal.acroformPlugin.acroFormDictionaryRoot.putStream()),r=r||i.internal.acroformPlugin.acroFormDictionaryRoot.Kids)if(r.hasOwnProperty(a)){var o=r[a],l=[],c=o.Rect;if(o.Rect&&(o.Rect=TGe(o.Rect,i)),i.internal.newObjectDeferredBegin(o.objId,!0),o.DA=_r.createDefaultAppearanceStream(o),pa(o)==="object"&&typeof o.getKeyValueListForStream=="function"&&(l=o.getKeyValueListForStream()),o.Rect=c,o.hasAppearanceStream&&!o.appearanceStreamContent){var u=EGe(o);l.push({key:"AP",value:"<>"}),i.internal.acroformPlugin.xForms.push(u)}if(o.appearanceStreamContent){var d="";for(var h in o.appearanceStreamContent)if(o.appearanceStreamContent.hasOwnProperty(h)){var p=o.appearanceStreamContent[h];if(d+="/"+h+" ",d+="<<",Object.keys(p).length>=1||Array.isArray(p)){for(var a in p)if(p.hasOwnProperty(a)){var g=p[a];typeof g=="function"&&(g=g.call(i,o)),d+="/"+a+" "+g+" ",i.internal.acroformPlugin.xForms.indexOf(g)>=0||i.internal.acroformPlugin.xForms.push(g)}}else typeof(g=p)=="function"&&(g=g.call(i,o)),d+="/"+a+" "+g,i.internal.acroformPlugin.xForms.indexOf(g)>=0||i.internal.acroformPlugin.xForms.push(g);d+=">>"}l.push({key:"AP",value:`<< `+d+">>"})}i.internal.putStream({additionalKeyValues:l,objectId:o.objId}),i.internal.out("endobj")}s&&function(x,_){for(var y in x)if(x.hasOwnProperty(y)){var M=y,C=x[y];_.internal.newObjectDeferredBegin(C.objId,!0),pa(C)==="object"&&typeof C.putStream=="function"&&C.putStream(),delete x[M]}}(i.internal.acroformPlugin.xForms,i)})(t,n)}),n.internal.acroformPlugin.isInitialized=!0}},XAe=ll.__acroform__.arrayToPdfArray=function(n,e,t){var r=function(a){return a};if(Array.isArray(n)){for(var i="[",s=0;s0?e:void 0}}),Object.defineProperty(this,"Fields",{enumerable:!1,configurable:!1,get:function(){return e}}),Object.defineProperty(this,"DA",{enumerable:!1,configurable:!1,get:function(){if(n){var t=function(r){return r};return this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),"("+Kv(t(n))+")"}},set:function(t){n=t}})};vh(ZAe,Zp);var sp=function n(){Zp.call(this);var e=4;Object.defineProperty(this,"F",{enumerable:!1,configurable:!1,get:function(){return e},set:function(y){if(isNaN(y))throw new Error('Invalid value "'+y+'" for attribute F supplied.');e=y}}),Object.defineProperty(this,"showWhenPrinted",{enumerable:!0,configurable:!0,get:function(){return!!Pl(e,3)},set:function(y){y?this.F=Rl(e,3):this.F=Ll(e,3)}});var t=0;Object.defineProperty(this,"Ff",{enumerable:!1,configurable:!1,get:function(){return t},set:function(y){if(isNaN(y))throw new Error('Invalid value "'+y+'" for attribute Ff supplied.');t=y}});var r=[];Object.defineProperty(this,"Rect",{enumerable:!1,configurable:!1,get:function(){if(r.length!==0)return r},set:function(y){r=y!==void 0?y:[]}}),Object.defineProperty(this,"x",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[0])?0:r[0]},set:function(y){r[0]=y}}),Object.defineProperty(this,"y",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[1])?0:r[1]},set:function(y){r[1]=y}}),Object.defineProperty(this,"width",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[2])?0:r[2]},set:function(y){r[2]=y}}),Object.defineProperty(this,"height",{enumerable:!0,configurable:!0,get:function(){return!r||isNaN(r[3])?0:r[3]},set:function(y){r[3]=y}});var i="";Object.defineProperty(this,"FT",{enumerable:!0,configurable:!1,get:function(){return i},set:function(y){switch(y){case"/Btn":case"/Tx":case"/Ch":case"/Sig":i=y;break;default:throw new Error('Invalid value "'+y+'" for attribute FT supplied.')}}});var s=null;Object.defineProperty(this,"T",{enumerable:!0,configurable:!1,get:function(){if(!s||s.length<1){if(this instanceof zM)return;s="FieldObject"+n.FieldNum++}var y=function(M){return M};return this.scope&&(y=this.scope.internal.getEncryptor(this.objId)),"("+Kv(y(s))+")"},set:function(y){s=y.toString()}}),Object.defineProperty(this,"fieldName",{configurable:!0,enumerable:!0,get:function(){return s},set:function(y){s=y}});var a="helvetica";Object.defineProperty(this,"fontName",{enumerable:!0,configurable:!0,get:function(){return a},set:function(y){a=y}});var o="normal";Object.defineProperty(this,"fontStyle",{enumerable:!0,configurable:!0,get:function(){return o},set:function(y){o=y}});var l=0;Object.defineProperty(this,"fontSize",{enumerable:!0,configurable:!0,get:function(){return l},set:function(y){l=y}});var c=void 0;Object.defineProperty(this,"maxFontSize",{enumerable:!0,configurable:!0,get:function(){return c===void 0?50/h$:c},set:function(y){c=y}});var u="black";Object.defineProperty(this,"color",{enumerable:!0,configurable:!0,get:function(){return u},set:function(y){u=y}});var d="/F1 0 Tf 0 g";Object.defineProperty(this,"DA",{enumerable:!0,configurable:!1,get:function(){if(!(!d||this instanceof zM||this instanceof Ox))return _j(d,this.objId,this.scope)},set:function(y){y=y.toString(),d=y}});var h=null;Object.defineProperty(this,"DV",{enumerable:!1,configurable:!1,get:function(){if(h)return this instanceof Oc==0?_j(h,this.objId,this.scope):h},set:function(y){y=y.toString(),h=this instanceof Oc==0?y.substr(0,1)==="("?Cy(y.substr(1,y.length-2)):Cy(y):y}}),Object.defineProperty(this,"defaultValue",{enumerable:!0,configurable:!0,get:function(){return this instanceof Oc==1?Cy(h.substr(1,h.length-1)):h},set:function(y){y=y.toString(),h=this instanceof Oc==1?"/"+nv(y):y}});var p=null;Object.defineProperty(this,"_V",{enumerable:!1,configurable:!1,get:function(){if(p)return p},set:function(y){this.V=y}}),Object.defineProperty(this,"V",{enumerable:!1,configurable:!1,get:function(){if(p)return this instanceof Oc==0?_j(p,this.objId,this.scope):p},set:function(y){y=y.toString(),p=this instanceof Oc==0?y.substr(0,1)==="("?Cy(y.substr(1,y.length-2)):Cy(y):y}}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,get:function(){return this instanceof Oc==1?Cy(p.substr(1,p.length-1)):p},set:function(y){y=y.toString(),p=this instanceof Oc==1?"/"+nv(y):y}}),Object.defineProperty(this,"hasAnnotation",{enumerable:!0,configurable:!0,get:function(){return this.Rect}}),Object.defineProperty(this,"Type",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Annot":null}}),Object.defineProperty(this,"Subtype",{enumerable:!0,configurable:!1,get:function(){return this.hasAnnotation?"/Widget":null}});var g,x=!1;Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return x},set:function(y){y=!!y,x=y}}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,get:function(){if(g)return g},set:function(y){g=y}}),Object.defineProperty(this,"readOnly",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,1)},set:function(y){y?this.Ff=Rl(this.Ff,1):this.Ff=Ll(this.Ff,1)}}),Object.defineProperty(this,"required",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,2)},set:function(y){y?this.Ff=Rl(this.Ff,2):this.Ff=Ll(this.Ff,2)}}),Object.defineProperty(this,"noExport",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,3)},set:function(y){y?this.Ff=Rl(this.Ff,3):this.Ff=Ll(this.Ff,3)}});var _=null;Object.defineProperty(this,"Q",{enumerable:!0,configurable:!1,get:function(){if(_!==null)return _},set:function(y){if([0,1,2].indexOf(y)===-1)throw new Error('Invalid value "'+y+'" for attribute Q supplied.');_=y}}),Object.defineProperty(this,"textAlign",{get:function(){var y;switch(_){case 0:default:y="left";break;case 1:y="center";break;case 2:y="right"}return y},configurable:!0,enumerable:!0,set:function(y){switch(y){case"right":case 2:_=2;break;case"center":case 1:_=1;break;default:_=0}}})};vh(sp,Zp);var g_=function(){sp.call(this),this.FT="/Ch",this.V="()",this.fontName="zapfdingbats";var n=0;Object.defineProperty(this,"TI",{enumerable:!0,configurable:!1,get:function(){return n},set:function(t){n=t}}),Object.defineProperty(this,"topIndex",{enumerable:!0,configurable:!0,get:function(){return n},set:function(t){n=t}});var e=[];Object.defineProperty(this,"Opt",{enumerable:!0,configurable:!1,get:function(){return XAe(e,this.objId,this.scope)},set:function(t){var r,i;i=[],typeof(r=t)=="string"&&(i=function(s,a,o){o||(o=1);for(var l,c=[];l=a.exec(s);)c.push(l[o]);return c}(r,/\((.*?)\)/g)),e=i}}),this.getOptions=function(){return e},this.setOptions=function(t){e=t,this.sort&&e.sort()},this.addOption=function(t){t=(t=t||"").toString(),e.push(t),this.sort&&e.sort()},this.removeOption=function(t,r){for(r=r||!1,t=(t=t||"").toString();e.indexOf(t)!==-1&&(e.splice(e.indexOf(t),1),r!==!1););},Object.defineProperty(this,"combo",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,18)},set:function(t){t?this.Ff=Rl(this.Ff,18):this.Ff=Ll(this.Ff,18)}}),Object.defineProperty(this,"edit",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,19)},set:function(t){this.combo===!0&&(t?this.Ff=Rl(this.Ff,19):this.Ff=Ll(this.Ff,19))}}),Object.defineProperty(this,"sort",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,20)},set:function(t){t?(this.Ff=Rl(this.Ff,20),e.sort()):this.Ff=Ll(this.Ff,20)}}),Object.defineProperty(this,"multiSelect",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,22)},set:function(t){t?this.Ff=Rl(this.Ff,22):this.Ff=Ll(this.Ff,22)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,23)},set:function(t){t?this.Ff=Rl(this.Ff,23):this.Ff=Ll(this.Ff,23)}}),Object.defineProperty(this,"commitOnSelChange",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,27)},set:function(t){t?this.Ff=Rl(this.Ff,27):this.Ff=Ll(this.Ff,27)}}),this.hasAppearanceStream=!1};vh(g_,sp);var A_=function(){g_.call(this),this.fontName="helvetica",this.combo=!1};vh(A_,g_);var x_=function(){A_.call(this),this.combo=!0};vh(x_,A_);var uN=function(){x_.call(this),this.edit=!0};vh(uN,x_);var Oc=function(){sp.call(this),this.FT="/Btn",Object.defineProperty(this,"noToggleToOff",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,15)},set:function(t){t?this.Ff=Rl(this.Ff,15):this.Ff=Ll(this.Ff,15)}}),Object.defineProperty(this,"radio",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,16)},set:function(t){t?this.Ff=Rl(this.Ff,16):this.Ff=Ll(this.Ff,16)}}),Object.defineProperty(this,"pushButton",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,17)},set:function(t){t?this.Ff=Rl(this.Ff,17):this.Ff=Ll(this.Ff,17)}}),Object.defineProperty(this,"radioIsUnison",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,26)},set:function(t){t?this.Ff=Rl(this.Ff,26):this.Ff=Ll(this.Ff,26)}});var n,e={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var t=function(s){return s};if(this.scope&&(t=this.scope.internal.getEncryptor(this.objId)),Object.keys(e).length!==0){var r,i=[];for(r in i.push("<<"),e)i.push("/"+r+" ("+Kv(t(e[r]))+")");return i.push(">>"),i.join(` `)}},set:function(t){pa(t)==="object"&&(e=t)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return e.CA||""},set:function(t){typeof t=="string"&&(e.CA=t)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return n},set:function(t){var r=t==null?"":t.toString();r.substr(0,1)==="/"&&(r=r.substr(1)),n="/"+nv(r)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return n.substr(1,n.length-1)},set:function(t){n="/"+nv(t)}})};vh(Oc,sp);var dN=function(){Oc.call(this),this.pushButton=!0};vh(dN,Oc);var v_=function(){Oc.call(this),this.radio=!0,this.pushButton=!1;var n=[];Object.defineProperty(this,"Kids",{enumerable:!0,configurable:!1,get:function(){return n},set:function(e){n=e!==void 0?e:[]}})};vh(v_,Oc);var zM=function(){var n,e;sp.call(this),Object.defineProperty(this,"Parent",{enumerable:!1,configurable:!1,get:function(){return n},set:function(i){n=i}}),Object.defineProperty(this,"optionName",{enumerable:!1,configurable:!0,get:function(){return e},set:function(i){e=i}});var t,r={};Object.defineProperty(this,"MK",{enumerable:!1,configurable:!1,get:function(){var i=function(o){return o};this.scope&&(i=this.scope.internal.getEncryptor(this.objId));var s,a=[];for(s in a.push("<<"),r)a.push("/"+s+" ("+Kv(i(r[s]))+")");return a.push(">>"),a.join(` `)},set:function(i){pa(i)==="object"&&(r=i)}}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,get:function(){return r.CA||""},set:function(i){typeof i=="string"&&(r.CA=i)}}),Object.defineProperty(this,"AS",{enumerable:!1,configurable:!1,get:function(){return t},set:function(i){var s=i==null?"":i.toString();s.substr(0,1)==="/"&&(s=s.substr(1)),t="/"+nv(s)}}),Object.defineProperty(this,"appearanceState",{enumerable:!0,configurable:!0,get:function(){return t.substr(1,t.length-1)},set:function(i){var s=i==null?"":i.toString();s.substr(0,1)==="/"&&(s=s.substr(1)),t="/"+nv(s)}}),this.caption="l",this.appearanceState="Off",this._AppearanceType=_r.RadioButton.Circle,this.appearanceStreamContent=this._AppearanceType.createAppearanceStream(this.optionName)};vh(zM,sp),v_.prototype.setAppearance=function(n){if(!("createAppearanceStream"in n)||!("getCA"in n))throw new Error("Couldn't assign Appearance to RadioButton. Appearance was Invalid!");for(var e in this.Kids)if(this.Kids.hasOwnProperty(e)){var t=this.Kids[e];t.appearanceStreamContent=n.createAppearanceStream(t.optionName),t.caption=n.getCA()}},v_.prototype.createOption=function(n){var e=new zM;return e.Parent=this,e.optionName=n,this.Kids.push(e),PGe.call(this.scope,e),e};var hN=function(){Oc.call(this),this.fontName="zapfdingbats",this.caption="3",this.appearanceState="On",this.value="On",this.textAlign="center",this.appearanceStreamContent=_r.CheckBox.createAppearanceStream()};vh(hN,Oc);var Ox=function(){sp.call(this),this.FT="/Tx",Object.defineProperty(this,"multiline",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,13)},set:function(e){e?this.Ff=Rl(this.Ff,13):this.Ff=Ll(this.Ff,13)}}),Object.defineProperty(this,"fileSelect",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,21)},set:function(e){e?this.Ff=Rl(this.Ff,21):this.Ff=Ll(this.Ff,21)}}),Object.defineProperty(this,"doNotSpellCheck",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,23)},set:function(e){e?this.Ff=Rl(this.Ff,23):this.Ff=Ll(this.Ff,23)}}),Object.defineProperty(this,"doNotScroll",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,24)},set:function(e){e?this.Ff=Rl(this.Ff,24):this.Ff=Ll(this.Ff,24)}}),Object.defineProperty(this,"comb",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,25)},set:function(e){e?this.Ff=Rl(this.Ff,25):this.Ff=Ll(this.Ff,25)}}),Object.defineProperty(this,"richText",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,26)},set:function(e){e?this.Ff=Rl(this.Ff,26):this.Ff=Ll(this.Ff,26)}});var n=null;Object.defineProperty(this,"MaxLen",{enumerable:!0,configurable:!1,get:function(){return n},set:function(e){n=e}}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,get:function(){return n},set:function(e){Number.isInteger(e)&&(n=e)}}),Object.defineProperty(this,"hasAppearanceStream",{enumerable:!0,configurable:!0,get:function(){return this.V||this.DV}})};vh(Ox,sp);var fN=function(){Ox.call(this),Object.defineProperty(this,"password",{enumerable:!0,configurable:!0,get:function(){return!!Pl(this.Ff,14)},set:function(n){n?this.Ff=Rl(this.Ff,14):this.Ff=Ll(this.Ff,14)}}),this.password=!0};vh(fN,Ox);var _r={CheckBox:{createAppearanceStream:function(){return{N:{On:_r.CheckBox.YesNormal},D:{On:_r.CheckBox.YesPushDown,Off:_r.CheckBox.OffPushDown}}},YesPushDown:function(n){var e=Op(n);e.scope=n.scope;var t=[],r=n.scope.internal.getFont(n.fontName,n.fontStyle).id,i=n.scope.__private__.encodeColorString(n.color),s=Fz(n,n.caption);return t.push("0.749023 g"),t.push("0 0 "+vi(_r.internal.getWidth(n))+" "+vi(_r.internal.getHeight(n))+" re"),t.push("f"),t.push("BMC"),t.push("q"),t.push("0 0 1 rg"),t.push("/"+r+" "+vi(s.fontSize)+" Tf "+i),t.push("BT"),t.push(s.text),t.push("ET"),t.push("Q"),t.push("EMC"),e.stream=t.join(` `),e},YesNormal:function(n){var e=Op(n);e.scope=n.scope;var t=n.scope.internal.getFont(n.fontName,n.fontStyle).id,r=n.scope.__private__.encodeColorString(n.color),i=[],s=_r.internal.getHeight(n),a=_r.internal.getWidth(n),o=Fz(n,n.caption);return i.push("1 g"),i.push("0 0 "+vi(a)+" "+vi(s)+" re"),i.push("f"),i.push("q"),i.push("0 0 1 rg"),i.push("0 0 "+vi(a-1)+" "+vi(s-1)+" re"),i.push("W"),i.push("n"),i.push("0 g"),i.push("BT"),i.push("/"+t+" "+vi(o.fontSize)+" Tf "+r),i.push(o.text),i.push("ET"),i.push("Q"),e.stream=i.join(` `),e},OffPushDown:function(n){var e=Op(n);e.scope=n.scope;var t=[];return t.push("0.749023 g"),t.push("0 0 "+vi(_r.internal.getWidth(n))+" "+vi(_r.internal.getHeight(n))+" re"),t.push("f"),e.stream=t.join(` `),e}},RadioButton:{Circle:{createAppearanceStream:function(n){var e={D:{Off:_r.RadioButton.Circle.OffPushDown},N:{}};return e.N[n]=_r.RadioButton.Circle.YesNormal,e.D[n]=_r.RadioButton.Circle.YesPushDown,e},getCA:function(){return"l"},YesNormal:function(n){var e=Op(n);e.scope=n.scope;var t=[],r=_r.internal.getWidth(n)<=_r.internal.getHeight(n)?_r.internal.getWidth(n)/4:_r.internal.getHeight(n)/4;r=Number((.9*r).toFixed(5));var i=_r.internal.Bezier_C,s=Number((r*i).toFixed(5));return t.push("q"),t.push("1 0 0 1 "+v1(_r.internal.getWidth(n)/2)+" "+v1(_r.internal.getHeight(n)/2)+" cm"),t.push(r+" 0 m"),t.push(r+" "+s+" "+s+" "+r+" 0 "+r+" c"),t.push("-"+s+" "+r+" -"+r+" "+s+" -"+r+" 0 c"),t.push("-"+r+" -"+s+" -"+s+" -"+r+" 0 -"+r+" c"),t.push(s+" -"+r+" "+r+" -"+s+" "+r+" 0 c"),t.push("f"),t.push("Q"),e.stream=t.join(` `),e},YesPushDown:function(n){var e=Op(n);e.scope=n.scope;var t=[],r=_r.internal.getWidth(n)<=_r.internal.getHeight(n)?_r.internal.getWidth(n)/4:_r.internal.getHeight(n)/4;r=Number((.9*r).toFixed(5));var i=Number((2*r).toFixed(5)),s=Number((i*_r.internal.Bezier_C).toFixed(5)),a=Number((r*_r.internal.Bezier_C).toFixed(5));return t.push("0.749023 g"),t.push("q"),t.push("1 0 0 1 "+v1(_r.internal.getWidth(n)/2)+" "+v1(_r.internal.getHeight(n)/2)+" cm"),t.push(i+" 0 m"),t.push(i+" "+s+" "+s+" "+i+" 0 "+i+" c"),t.push("-"+s+" "+i+" -"+i+" "+s+" -"+i+" 0 c"),t.push("-"+i+" -"+s+" -"+s+" -"+i+" 0 -"+i+" c"),t.push(s+" -"+i+" "+i+" -"+s+" "+i+" 0 c"),t.push("f"),t.push("Q"),t.push("0 g"),t.push("q"),t.push("1 0 0 1 "+v1(_r.internal.getWidth(n)/2)+" "+v1(_r.internal.getHeight(n)/2)+" cm"),t.push(r+" 0 m"),t.push(r+" "+a+" "+a+" "+r+" 0 "+r+" c"),t.push("-"+a+" "+r+" -"+r+" "+a+" -"+r+" 0 c"),t.push("-"+r+" -"+a+" -"+a+" -"+r+" 0 -"+r+" c"),t.push(a+" -"+r+" "+r+" -"+a+" "+r+" 0 c"),t.push("f"),t.push("Q"),e.stream=t.join(` `),e},OffPushDown:function(n){var e=Op(n);e.scope=n.scope;var t=[],r=_r.internal.getWidth(n)<=_r.internal.getHeight(n)?_r.internal.getWidth(n)/4:_r.internal.getHeight(n)/4;r=Number((.9*r).toFixed(5));var i=Number((2*r).toFixed(5)),s=Number((i*_r.internal.Bezier_C).toFixed(5));return t.push("0.749023 g"),t.push("q"),t.push("1 0 0 1 "+v1(_r.internal.getWidth(n)/2)+" "+v1(_r.internal.getHeight(n)/2)+" cm"),t.push(i+" 0 m"),t.push(i+" "+s+" "+s+" "+i+" 0 "+i+" c"),t.push("-"+s+" "+i+" -"+i+" "+s+" -"+i+" 0 c"),t.push("-"+i+" -"+s+" -"+s+" -"+i+" 0 -"+i+" c"),t.push(s+" -"+i+" "+i+" -"+s+" "+i+" 0 c"),t.push("f"),t.push("Q"),e.stream=t.join(` `),e}},Cross:{createAppearanceStream:function(n){var e={D:{Off:_r.RadioButton.Cross.OffPushDown},N:{}};return e.N[n]=_r.RadioButton.Cross.YesNormal,e.D[n]=_r.RadioButton.Cross.YesPushDown,e},getCA:function(){return"8"},YesNormal:function(n){var e=Op(n);e.scope=n.scope;var t=[],r=_r.internal.calculateCross(n);return t.push("q"),t.push("1 1 "+vi(_r.internal.getWidth(n)-2)+" "+vi(_r.internal.getHeight(n)-2)+" re"),t.push("W"),t.push("n"),t.push(vi(r.x1.x)+" "+vi(r.x1.y)+" m"),t.push(vi(r.x2.x)+" "+vi(r.x2.y)+" l"),t.push(vi(r.x4.x)+" "+vi(r.x4.y)+" m"),t.push(vi(r.x3.x)+" "+vi(r.x3.y)+" l"),t.push("s"),t.push("Q"),e.stream=t.join(` `),e},YesPushDown:function(n){var e=Op(n);e.scope=n.scope;var t=_r.internal.calculateCross(n),r=[];return r.push("0.749023 g"),r.push("0 0 "+vi(_r.internal.getWidth(n))+" "+vi(_r.internal.getHeight(n))+" re"),r.push("f"),r.push("q"),r.push("1 1 "+vi(_r.internal.getWidth(n)-2)+" "+vi(_r.internal.getHeight(n)-2)+" re"),r.push("W"),r.push("n"),r.push(vi(t.x1.x)+" "+vi(t.x1.y)+" m"),r.push(vi(t.x2.x)+" "+vi(t.x2.y)+" l"),r.push(vi(t.x4.x)+" "+vi(t.x4.y)+" m"),r.push(vi(t.x3.x)+" "+vi(t.x3.y)+" l"),r.push("s"),r.push("Q"),e.stream=r.join(` `),e},OffPushDown:function(n){var e=Op(n);e.scope=n.scope;var t=[];return t.push("0.749023 g"),t.push("0 0 "+vi(_r.internal.getWidth(n))+" "+vi(_r.internal.getHeight(n))+" re"),t.push("f"),e.stream=t.join(` `),e}}},createDefaultAppearanceStream:function(n){var e=n.scope.internal.getFont(n.fontName,n.fontStyle).id,t=n.scope.__private__.encodeColorString(n.color);return"/"+e+" "+n.fontSize+" Tf "+t}};_r.internal={Bezier_C:.551915024494,calculateCross:function(n){var e=_r.internal.getWidth(n),t=_r.internal.getHeight(n),r=Math.min(e,t);return{x1:{x:(e-r)/2,y:(t-r)/2+r},x2:{x:(e-r)/2+r,y:(t-r)/2},x3:{x:(e-r)/2,y:(t-r)/2},x4:{x:(e-r)/2+r,y:(t-r)/2+r}}}},_r.internal.getWidth=function(n){var e=0;return pa(n)==="object"&&(e=Ese(n.Rect[2])),e},_r.internal.getHeight=function(n){var e=0;return pa(n)==="object"&&(e=Ese(n.Rect[3])),e};var PGe=ll.addField=function(n){if(CGe(this,n),!(n instanceof sp))throw new Error("Invalid argument passed to jsPDF.addField.");var e;return(e=n).scope.internal.acroformPlugin.printedOut&&(e.scope.internal.acroformPlugin.printedOut=!1,e.scope.internal.acroformPlugin.acroFormDictionaryRoot=null),e.scope.internal.acroformPlugin.acroFormDictionaryRoot.Fields.push(e),n.page=n.scope.internal.getCurrentPageInfo().pageNumber,this};ll.AcroFormChoiceField=g_,ll.AcroFormListBox=A_,ll.AcroFormComboBox=x_,ll.AcroFormEditBox=uN,ll.AcroFormButton=Oc,ll.AcroFormPushButton=dN,ll.AcroFormRadioButton=v_,ll.AcroFormCheckBox=hN,ll.AcroFormTextField=Ox,ll.AcroFormPasswordField=fN,ll.AcroFormAppearance=_r,ll.AcroForm={ChoiceField:g_,ListBox:A_,ComboBox:x_,EditBox:uN,Button:Oc,PushButton:dN,RadioButton:v_,CheckBox:hN,TextField:Ox,PasswordField:fN,Appearance:_r},Cr.AcroForm={ChoiceField:g_,ListBox:A_,ComboBox:x_,EditBox:uN,Button:Oc,PushButton:dN,RadioButton:v_,CheckBox:hN,TextField:Ox,PasswordField:fN,Appearance:_r};Cr.AcroForm;function QAe(n){return n.reduce(function(e,t,r){return e[t]=r,e},{})}(function(n){var e="addImage_";n.__addimage__={};var t="UNKNOWN",r={PNG:[[137,80,78,71]],TIFF:[[77,77,0,42],[73,73,42,0]],JPEG:[[255,216,255,224,void 0,void 0,74,70,73,70,0],[255,216,255,225,void 0,void 0,69,120,105,102,0,0],[255,216,255,219],[255,216,255,238]],JPEG2000:[[0,0,0,12,106,80,32,32]],GIF87a:[[71,73,70,56,55,97]],GIF89a:[[71,73,70,56,57,97]],WEBP:[[82,73,70,70,void 0,void 0,void 0,void 0,87,69,66,80]],BMP:[[66,77],[66,65],[67,73],[67,80],[73,67],[80,84]]},i=n.__addimage__.getImageFileTypeByImageData=function(G,H){var K,W,J,ie,ae,Q=t;if((H=H||t)==="RGBA"||G.data!==void 0&&G.data instanceof Uint8ClampedArray&&"height"in G&&"width"in G)return"RGBA";if(U(G))for(ae in r)for(J=r[ae],K=0;K>"}),"transparency"in H&&Array.isArray(H.transparency)&&H.transparency.length>0){for(var ae="",Q=0,re=H.transparency.length;Q>",x.content=s;var C=x.objId+" 0 R";s="<>";else if(r.options.pageNumber)switch(s="<=0};n.__arabicParser__.arabicLetterHasIsolatedForm=function(x){return a(x)&&s(x)&&e[x.charCodeAt(0)].length>=1};var c=n.__arabicParser__.arabicLetterHasFinalForm=function(x){return a(x)&&s(x)&&e[x.charCodeAt(0)].length>=2};n.__arabicParser__.arabicLetterHasInitialForm=function(x){return a(x)&&s(x)&&e[x.charCodeAt(0)].length>=3};var u=n.__arabicParser__.arabicLetterHasMedialForm=function(x){return a(x)&&s(x)&&e[x.charCodeAt(0)].length==4},d=n.__arabicParser__.resolveLigatures=function(x){var _=0,y=t,M="",C=0;for(_=0;_>"),this.internal.out("endobj")}),this.internal.events.subscribe("putCatalog",function(){this.internal.out("/OpenAction "+e+" 0 R")})),this},function(n){var e=function(){var t=void 0;Object.defineProperty(this,"pdf",{get:function(){return t},set:function(o){t=o}});var r=150;Object.defineProperty(this,"width",{get:function(){return r},set:function(o){r=isNaN(o)||Number.isInteger(o)===!1||o<0?150:o,this.getContext("2d").pageWrapXEnabled&&(this.getContext("2d").pageWrapX=r+1)}});var i=300;Object.defineProperty(this,"height",{get:function(){return i},set:function(o){i=isNaN(o)||Number.isInteger(o)===!1||o<0?300:o,this.getContext("2d").pageWrapYEnabled&&(this.getContext("2d").pageWrapY=i+1)}});var s=[];Object.defineProperty(this,"childNodes",{get:function(){return s},set:function(o){s=o}});var a={};Object.defineProperty(this,"style",{get:function(){return a},set:function(o){a=o}}),Object.defineProperty(this,"parentNode",{})};e.prototype.getContext=function(t,r){var i;if((t=t||"2d")!=="2d")return null;for(i in r)this.pdf.context2d.hasOwnProperty(i)&&(this.pdf.context2d[i]=r[i]);return this.pdf.context2d._canvas=this,this.pdf.context2d},e.prototype.toDataURL=function(){throw new Error("toDataURL is not implemented.")},n.events.push(["initialized",function(){this.canvas=new e,this.canvas.pdf=this}])}(Cr.API),function(n){var e={left:0,top:0,bottom:0,right:0},t=!1,r=function(){this.internal.__cell__===void 0&&(this.internal.__cell__={},this.internal.__cell__.padding=3,this.internal.__cell__.headerFunction=void 0,this.internal.__cell__.margins=Object.assign({},e),this.internal.__cell__.margins.width=this.getPageWidth(),i.call(this))},i=function(){this.internal.__cell__.lastCell=new s,this.internal.__cell__.pages=1},s=function(){var l=arguments[0];Object.defineProperty(this,"x",{enumerable:!0,get:function(){return l},set:function(x){l=x}});var c=arguments[1];Object.defineProperty(this,"y",{enumerable:!0,get:function(){return c},set:function(x){c=x}});var u=arguments[2];Object.defineProperty(this,"width",{enumerable:!0,get:function(){return u},set:function(x){u=x}});var d=arguments[3];Object.defineProperty(this,"height",{enumerable:!0,get:function(){return d},set:function(x){d=x}});var h=arguments[4];Object.defineProperty(this,"text",{enumerable:!0,get:function(){return h},set:function(x){h=x}});var p=arguments[5];Object.defineProperty(this,"lineNumber",{enumerable:!0,get:function(){return p},set:function(x){p=x}});var g=arguments[6];return Object.defineProperty(this,"align",{enumerable:!0,get:function(){return g},set:function(x){g=x}}),this};s.prototype.clone=function(){return new s(this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align)},s.prototype.toArray=function(){return[this.x,this.y,this.width,this.height,this.text,this.lineNumber,this.align]},n.setHeaderFunction=function(l){return r.call(this),this.internal.__cell__.headerFunction=typeof l=="function"?l:void 0,this},n.getTextDimensions=function(l,c){r.call(this);var u=(c=c||{}).fontSize||this.getFontSize(),d=c.font||this.getFont(),h=c.scaleFactor||this.internal.scaleFactor,p=0,g=0,x=0,_=this;if(!Array.isArray(l)&&typeof l!="string"){if(typeof l!="number")throw new Error("getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.");l=String(l)}var y=c.maxWidth;y>0?typeof l=="string"?l=this.splitTextToSize(l,y):Object.prototype.toString.call(l)==="[object Array]"&&(l=l.reduce(function(C,k){return C.concat(_.splitTextToSize(k,y))},[])):l=Array.isArray(l)?l:[l];for(var M=0;Mthis.getPageHeight()?(this.cellAddPage(),l.y=d.top,p&&h&&(this.printHeaderRow(l.lineNumber,!0),l.y+=h[0].height)):l.y=c.y+c.height||l.y),l.text[0]!==void 0&&(this.rect(l.x,l.y,l.width,l.height,t===!0?"FD":void 0),l.align==="right"?this.text(l.text,l.x+l.width-u,l.y+u,{align:"right",baseline:"top"}):l.align==="center"?this.text(l.text,l.x+l.width/2,l.y+u,{align:"center",baseline:"top",maxWidth:l.width-u-u}):this.text(l.text,l.x+u,l.y+u,{align:"left",baseline:"top",maxWidth:l.width-u-u})),this.internal.__cell__.lastCell=l,this};n.table=function(l,c,u,d,h){if(r.call(this),!u)throw new Error("No data for PDF table.");var p,g,x,_,y=[],M=[],C=[],k={},B={},U=[],z=[],O=(h=h||{}).autoSize||!1,V=h.printHeaders!==!1,$=h.css&&h.css["font-size"]!==void 0?16*h.css["font-size"]:h.fontSize||12,G=h.margins||Object.assign({width:this.getPageWidth()},e),H=typeof h.padding=="number"?h.padding:3,K=h.headerBackgroundColor||"#c8c8c8",W=h.headerTextColor||"#000";if(i.call(this),this.internal.__cell__.printHeaders=V,this.internal.__cell__.margins=G,this.internal.__cell__.table_font_size=$,this.internal.__cell__.padding=H,this.internal.__cell__.headerBackgroundColor=K,this.internal.__cell__.headerTextColor=W,this.setFontSize($),d==null)M=y=Object.keys(u[0]),C=y.map(function(){return"left"});else if(Array.isArray(d)&&pa(d[0])==="object")for(y=d.map(function(oe){return oe.name}),M=d.map(function(oe){return oe.prompt||oe.name||""}),C=d.map(function(oe){return oe.align||"left"}),p=0;p0&&this.setTableHeaderRow(h),this.setFont(void 0,"normal"),t=!1}}(Cr.API);var KAe={italic:["italic","oblique","normal"],oblique:["oblique","italic","normal"],normal:["normal","oblique","italic"]},JAe=["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"],Bz=QAe(JAe),e2e=[100,200,300,400,500,600,700,800,900],RGe=QAe(e2e);function wj(n){var e=n.family.replace(/"|'/g,"").toLowerCase(),t=function(s){return KAe[s=s||"normal"]?s:"normal"}(n.style),r=function(s){return s?typeof s=="number"?s>=100&&s<=900&&s%100==0?s:400:/^\d00$/.test(s)?parseInt(s):s==="bold"?700:400:400}(n.weight),i=function(s){return typeof Bz[s=s||"normal"]=="number"?s:"normal"}(n.stretch);return{family:e,style:t,weight:r,stretch:i,src:n.src||[],ref:n.ref||{name:e,style:[i,t,r].join(" ")}}}function Nse(n,e,t,r){var i;for(i=t;i>=0&&i=0&&i>>1)&255}return i}function Fse(n,e,t){var r=n.length,i=[];i[0]=4;for(var s=0;s>s&a}function Bse(n,e,t,r){var i=t*r,s=Math.floor(i/8),a=16-(i-8*s+r),o=(1<>8&255;c.setUint8(u,h)}})(n,s,t2e(n,s)&~(o<>7,a=1<<1+(7&i);n[e++],n[e++];var o=null,l=null;s&&(o=e,l=a,e+=3*a);var c=!0,u=[],d=0,h=null,p=0,g=null;for(this.width=t,this.height=r;c&&e=0))throw Error("Invalid block size");if(G===0)break;e+=G}break;case 249:if(n[e++]!==4||n[e+4]!==0)throw new Error("Invalid graphics extension block.");var x=n[e++];d=n[e++]|n[e++]<<8,h=n[e++],1&x||(h=null),p=x>>2&7,e++;break;case 254:for(;;){if(!((G=n[e++])>=0))throw Error("Invalid block size");if(G===0)break;e+=G}break;default:throw new Error("Unknown graphic control label: 0x"+n[e-1].toString(16))}break;case 44:var _=n[e++]|n[e++]<<8,y=n[e++]|n[e++]<<8,M=n[e++]|n[e++]<<8,C=n[e++]|n[e++]<<8,k=n[e++],B=k>>6&1,U=1<<1+(7&k),z=o,O=l,V=!1;k>>7&&(V=!0,z=e,O=U,e+=3*U);var $=e;for(e++;;){var G;if(!((G=n[e++])>=0))throw Error("Invalid block size");if(G===0)break;e+=G}u.push({x:_,y,width:M,height:C,has_local_palette:V,palette_offset:z,palette_size:O,data_offset:$,data_length:e-$,transparent_index:h,interlaced:!!B,delay:d,disposal:p});break;case 59:c=!1;break;default:throw new Error("Unknown gif block: 0x"+n[e-1].toString(16))}this.numFrames=function(){return u.length},this.loopCount=function(){return g},this.frameInfo=function(H){if(H<0||H>=u.length)throw new Error("Frame index out of range.");return u[H]},this.decodeAndBlitFrameBGRA=function(H,K){var W=this.frameInfo(H),J=W.width*W.height;if(J>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");var ie=new Uint8Array(J);Use(n,W.data_offset,ie,J);var ae=W.palette_offset,Q=W.transparent_index;Q===null&&(Q=256);var re=W.width,oe=t-re,fe=re,ee=4*(W.y*t+W.x),me=4*((W.y+W.height)*t+W.x),Ae=ee,be=4*oe;W.interlaced===!0&&(be+=4*t*7);for(var pe=8,ge=0,Te=ie.length;ge=me&&(be=4*oe+4*t*(pe-1),Ae=ee+(re+oe)*(pe<<1),pe>>=1)),ze===Q)Ae+=4;else{var Xe=n[ae+3*ze],Qe=n[ae+3*ze+1],ot=n[ae+3*ze+2];K[Ae++]=ot,K[Ae++]=Qe,K[Ae++]=Xe,K[Ae++]=255}--fe}},this.decodeAndBlitFrameRGBA=function(H,K){var W=this.frameInfo(H),J=W.width*W.height;if(J>536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");var ie=new Uint8Array(J);Use(n,W.data_offset,ie,J);var ae=W.palette_offset,Q=W.transparent_index;Q===null&&(Q=256);var re=W.width,oe=t-re,fe=re,ee=4*(W.y*t+W.x),me=4*((W.y+W.height)*t+W.x),Ae=ee,be=4*oe;W.interlaced===!0&&(be+=4*t*7);for(var pe=8,ge=0,Te=ie.length;ge=me&&(be=4*oe+4*t*(pe-1),Ae=ee+(re+oe)*(pe<<1),pe>>=1)),ze===Q)Ae+=4;else{var Xe=n[ae+3*ze],Qe=n[ae+3*ze+1],ot=n[ae+3*ze+2];K[Ae++]=Xe,K[Ae++]=Qe,K[Ae++]=ot,K[Ae++]=255}--fe}}}function Use(n,e,t,r){for(var i=n[e++],s=1<>=l,u-=l,_!==s){if(_===a)break;for(var y=_s;)C=g[C]>>8,++M;var k=C;if(h+M+(y!==_?1:0)>r)return void Ra.log("Warning, gif stream longer than expected.");t[h++]=k;var B=h+=M;for(y!==_&&(t[h++]=k),C=y;M--;)C=g[C],t[--B]=255&C,C>>=8;x!==null&&o<4096&&(g[o++]=x<<8|k,o>=c+1&&l<12&&(++l,c=c<<1|1)),x=_}else o=a+1,c=(1<<(l=i+1))-1,x=null}return h!==r&&Ra.log("Warning, gif stream shorter than expected."),t}/** * @license Copyright (c) 2008, Adobe Systems Incorporated All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Adobe Systems Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */function Ej(n){var e,t,r,i,s,a=Math.floor,o=new Array(64),l=new Array(64),c=new Array(64),u=new Array(64),d=new Array(65535),h=new Array(65535),p=new Array(64),g=new Array(64),x=[],_=0,y=7,M=new Array(64),C=new Array(64),k=new Array(64),B=new Array(256),U=new Array(2048),z=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],O=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],V=[0,1,2,3,4,5,6,7,8,9,10,11],$=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],G=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],H=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],K=[0,1,2,3,4,5,6,7,8,9,10,11],W=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],J=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function ie(ee,me){for(var Ae=0,be=0,pe=new Array,ge=1;ge<=16;ge++){for(var Te=1;Te<=ee[ge];Te++)pe[me[be]]=[],pe[me[be]][0]=Ae,pe[me[be]][1]=ge,be++,Ae++;Ae*=2}return pe}function ae(ee){for(var me=ee[0],Ae=ee[1]-1;Ae>=0;)me&1<>8&255),Q(255&ee)}function oe(ee,me,Ae,be,pe){for(var ge,Te=pe[0],ze=pe[240],Xe=function(At,Lt){var st,Ht,Se,_t,It,De,ue,Ve,We,ct,vt=0;for(We=0;We<8;++We){st=At[vt],Ht=At[vt+1],Se=At[vt+2],_t=At[vt+3],It=At[vt+4],De=At[vt+5],ue=At[vt+6];var Ut=st+(Ve=At[vt+7]),dt=st-Ve,mt=Ht+ue,Ft=Ht-ue,tt=Se+De,Pe=Se-De,nt=_t+It,qe=_t-It,yt=Ut+nt,Qt=Ut-nt,Be=mt+tt,pt=mt-tt;At[vt]=yt+Be,At[vt+4]=yt-Be;var rt=.707106781*(pt+Qt);At[vt+2]=Qt+rt,At[vt+6]=Qt-rt;var zt=.382683433*((yt=qe+Pe)-(pt=Ft+dt)),Yt=.5411961*yt+zt,Bt=1.306562965*pt+zt,$e=.707106781*(Be=Pe+Ft),ut=dt+$e,Gt=dt-$e;At[vt+5]=Gt+Yt,At[vt+3]=Gt-Yt,At[vt+1]=ut+Bt,At[vt+7]=ut-Bt,vt+=8}for(vt=0,We=0;We<8;++We){st=At[vt],Ht=At[vt+8],Se=At[vt+16],_t=At[vt+24],It=At[vt+32],De=At[vt+40],ue=At[vt+48];var it=st+(Ve=At[vt+56]),Ot=st-Ve,nn=Ht+ue,Nt=Ht-ue,m=Se+De,Ie=Se-De,An=_t+It,Ln=_t-It,Rn=it+An,Mn=it-An,Cn=nn+m,Hn=nn-m;At[vt]=Rn+Cn,At[vt+32]=Rn-Cn;var lr=.707106781*(Hn+Mn);At[vt+16]=Mn+lr,At[vt+48]=Mn-lr;var jr=.382683433*((Rn=Ln+Ie)-(Hn=Nt+Ot)),Qr=.5411961*Rn+jr,Os=1.306562965*Hn+jr,la=.707106781*(Cn=Ie+Nt),Pi=Ot+la,ra=Ot-la;At[vt+40]=ra+Qr,At[vt+24]=ra-Qr,At[vt+8]=Pi+Os,At[vt+56]=Pi-Os,vt++}for(We=0;We<64;++We)ct=At[We]*Lt[We],p[We]=ct>0?ct+.5|0:ct-.5|0;return p}(ee,me),Qe=0;Qe<64;++Qe)g[z[Qe]]=Xe[Qe];var ot=g[0]-Ae;Ae=g[0],ot==0?ae(be[0]):(ae(be[h[ge=32767+ot]]),ae(d[ge]));for(var bt=63;bt>0&&g[bt]==0;)bt--;if(bt==0)return ae(Te),Ae;for(var ht,Ce=1;Ce<=bt;){for(var lt=Ce;g[Ce]==0&&Ce<=bt;)++Ce;var ft=Ce-lt;if(ft>=16){ht=ft>>4;for(var et=1;et<=ht;++et)ae(ze);ft&=15}ge=32767+g[Ce],ae(pe[(ft<<4)+h[ge]]),ae(d[ge]),Ce++}return bt!=63&&ae(Te),Ae}function fe(ee){ee=Math.min(Math.max(ee,1),100),s!=ee&&(function(me){for(var Ae=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],be=0;be<64;be++){var pe=a((Ae[be]*me+50)/100);pe=Math.min(Math.max(pe,1),255),o[z[be]]=pe}for(var ge=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],Te=0;Te<64;Te++){var ze=a((ge[Te]*me+50)/100);ze=Math.min(Math.max(ze,1),255),l[z[Te]]=ze}for(var Xe=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],Qe=0,ot=0;ot<8;ot++)for(var bt=0;bt<8;bt++)c[Qe]=1/(o[z[Qe]]*Xe[ot]*Xe[bt]*8),u[Qe]=1/(l[z[Qe]]*Xe[ot]*Xe[bt]*8),Qe++}(ee<50?Math.floor(5e3/ee):Math.floor(200-2*ee)),s=ee)}this.encode=function(ee,me){me&&fe(me),x=new Array,_=0,y=7,re(65496),re(65504),re(16),Q(74),Q(70),Q(73),Q(70),Q(0),Q(1),Q(1),Q(0),re(1),re(1),Q(0),Q(0),function(){re(65499),re(132),Q(0);for(var Ht=0;Ht<64;Ht++)Q(o[Ht]);Q(1);for(var Se=0;Se<64;Se++)Q(l[Se])}(),function(Ht,Se){re(65472),re(17),Q(8),re(Se),re(Ht),Q(3),Q(1),Q(17),Q(0),Q(2),Q(17),Q(1),Q(3),Q(17),Q(1)}(ee.width,ee.height),function(){re(65476),re(418),Q(0);for(var Ht=0;Ht<16;Ht++)Q(O[Ht+1]);for(var Se=0;Se<=11;Se++)Q(V[Se]);Q(16);for(var _t=0;_t<16;_t++)Q($[_t+1]);for(var It=0;It<=161;It++)Q(G[It]);Q(1);for(var De=0;De<16;De++)Q(H[De+1]);for(var ue=0;ue<=11;ue++)Q(K[ue]);Q(17);for(var Ve=0;Ve<16;Ve++)Q(W[Ve+1]);for(var We=0;We<=161;We++)Q(J[We])}(),re(65498),re(12),Q(3),Q(1),Q(0),Q(2),Q(17),Q(3),Q(17),Q(0),Q(63),Q(0);var Ae=0,be=0,pe=0;_=0,y=7,this.encode.displayName="_encode_";for(var ge,Te,ze,Xe,Qe,ot,bt,ht,Ce,lt=ee.data,ft=ee.width,et=ee.height,At=4*ft,Lt=0;Lt>3)*At+(bt=4*(7&Ce)),Lt+ht>=et&&(ot-=At*(Lt+1+ht-et)),ge+bt>=At&&(ot-=ge+bt-At+4),Te=lt[ot++],ze=lt[ot++],Xe=lt[ot++],M[Ce]=(U[Te]+U[ze+256|0]+U[Xe+512|0]>>16)-128,C[Ce]=(U[Te+768|0]+U[ze+1024|0]+U[Xe+1280|0]>>16)-128,k[Ce]=(U[Te+1280|0]+U[ze+1536|0]+U[Xe+1792|0]>>16)-128;Ae=oe(M,c,Ae,e,r),be=oe(C,u,be,t,i),pe=oe(k,u,pe,t,i),ge+=32}Lt+=8}if(y>=0){var st=[];st[1]=y+1,st[0]=(1<H;H++)if(V[$+H]!=G.charCodeAt(H))return!0;return!1}function r(V,$,G,H,K){for(var W=0;WW+1?[]:new $),!(J.length>>0;v&j;)j>>>=1;return j?(v&j-1)+j:v}function G(v,T,j,q,Z){e(!(q%j));do v[T+(q-=j)]=Z;while(0=Z),512>=Z)var te=s(512);else if((te=s(Z))==null)return 0;return function(ne,le,xe,Ee,Ue,we){var ke,je,Je=le,xt=1<ke;++ke){if(Ye[ke]>1<(Zn-=Ye[ke]))return 0;for(;0=ke;++ke,Ue<<=1){if(tn+=Zn<<=1,0>(Zn-=Ye[ke]))return 0;for(;0Rt&&!(0>=(kt-=Ye[Rt]));)++Rt,kt<<=1;xt+=On=1<<(kt=Rt-xe),ne[le+(Rt=Kt&Wt)].g=kt+xe,ne[le+Rt].value=Je-le-Rt}Ee.g=ke-xe,Ee.value=we[je++],G(ne,Je+(Kt>>xe),Ue,On,Ee),Kt=$(Kt,ke)}}return tn!=2*Ke[15]-1?0:xt}(v,T,j,q,Z,te)}function K(){this.value=this.g=0}function W(){this.value=this.g=0}function J(){this.G=a(5,K),this.H=s(5),this.jc=this.Qb=this.qb=this.nd=0,this.pd=a(Yc,W)}function ie(v,T,j,q){e(v!=null),e(T!=null),e(2147483648>q),v.Ca=254,v.I=0,v.b=-8,v.Ka=0,v.oa=T,v.pa=j,v.Jd=T,v.Yc=j+q,v.Zc=4<=q?j+q-4+1:j,Te(v)}function ae(v,T){for(var j=0;0q),v.Sb=q,v.Ra=0,v.u=0,v.h=0,4>>=8,v.Ra+=v.oa[v.pa+v.bb]<>>0,++v.bb,v.u-=8;be(v)&&(v.h=1,v.u=0)}function fe(v,T){if(e(0<=T),!v.h&&T<=el){var j=Ae(v)&hd[T];return v.u+=T,oe(v),j}return v.h=1,v.u=0}function ee(){this.b=this.Ca=this.I=0,this.oa=[],this.pa=0,this.Jd=[],this.Yc=0,this.Zc=[],this.Ka=0}function me(){this.Ra=0,this.oa=[],this.h=this.u=this.bb=this.Sb=this.pa=0}function Ae(v){return v.Ra>>>(v.u&Ys-1)>>>0}function be(v){return e(v.bb<=v.Sb),v.h||v.bb==v.Sb&&v.u>Ys}function pe(v,T){v.u=T,v.h=be(v)}function ge(v){v.u>=tl&&(e(v.u>=tl),oe(v))}function Te(v){e(v!=null&&v.oa!=null),v.pa>>0,v.b+=8):(e(v!=null&&v.oa!=null),v.pav.b&&Te(v);var q=v.b,Z=j*T>>>8,te=(v.I>>>q>Z)+0;for(te?(j-=Z,v.I-=Z+1<>>0):j=Z+1,q=j,Z=0;256<=q;)Z+=8,q>>=8;return q=7^Z+Sc[q],v.b-=q,v.Ca=(j<>24&255,v[T+1]=j>>16&255,v[T+2]=j>>8&255,v[T+3]=255&j}function ot(v,T){return v[T+0]|v[T+1]<<8}function bt(v,T){return ot(v,T)|v[T+2]<<16}function ht(v,T){return ot(v,T)|ot(v,T+2)<<16}function Ce(v,T){var j=1<=Z||0>=te?0:(j[0]=Z,q[0]=te,1)}function At(v,T){return v+(1<>>T}function Lt(v,T){return((4278255360&v)+(4278255360&T)>>>0&4278255360)+((16711935&v)+(16711935&T)>>>0&16711935)>>>0}function st(v,T){V[T]=function(j,q,Z,te,ne,le,xe){var Ee;for(Ee=0;Ee>>1)+(v&T)>>>0}function _t(v){return 0<=v&&256>v?v:0>v?0:255>1))}function De(v,T,j){return Math.abs(T-j)-Math.abs(v-j)}function ue(v,T,j,q,Z,te,ne){for(q=te[ne-1],j=0;j>8&255,xe=16711935&(xe=(xe=16711935&ne)+((le<<16)+le));q[Z+te]=(4278255360&ne)+xe>>>0}}function We(v,T){T.jd=255&v,T.hd=v>>8&255,T.ud=v>>16&255}function ct(v,T,j,q,Z,te){var ne;for(ne=0;ne>>8,Ee=le,Ue=255&(Ue=(Ue=le>>>16)+((v.jd<<24>>24)*(xe<<24>>24)>>>5));Ee=255&(Ee=(Ee+=(v.hd<<24>>24)*(xe<<24>>24)>>>5)+((v.ud<<24>>24)*(Ue<<24>>24)>>>5)),Z[te+ne]=(4278255360&le)+(Ue<<16)+Ee}}function vt(v,T,j,q,Z){V[T]=function(te,ne,le,xe,Ee,Ue,we,ke,je){for(xe=we;xe>te.b,je=te.Ea,Je=te.K[0],xt=te.w;if(8>ke)for(te=(1<>=ke}else V["VP8LMapColor"+j](xe,Ee,Je,xt,Ue,we,ne,le,je)}}function Ut(v,T,j,q,Z){for(j=T+j;T>16&255,q[Z++]=te>>8&255,q[Z++]=255&te}}function dt(v,T,j,q,Z){for(j=T+j;T>16&255,q[Z++]=te>>8&255,q[Z++]=255&te,q[Z++]=te>>24&255}}function mt(v,T,j,q,Z){for(j=T+j;T>16&240|ne>>12&15,ne=240&ne|ne>>28&15;q[Z++]=te,q[Z++]=ne}}function Ft(v,T,j,q,Z){for(j=T+j;T>16&248|ne>>13&7,ne=ne>>5&224|ne>>3&31;q[Z++]=te,q[Z++]=ne}}function tt(v,T,j,q,Z){for(j=T+j;T>8&255,q[Z++]=te>>16&255}}function Pe(v,T,j,q,Z,te){if(te==0)for(j=T+j;T>24|te[1]>>8&65280|te[2]<<8&16711680|te[3]<<24)>>>0),Z+=32;else r(q,Z,v,T,j)}function nt(v,T){V[T][0]=V[v+"0"],V[T][1]=V[v+"1"],V[T][2]=V[v+"2"],V[T][3]=V[v+"3"],V[T][4]=V[v+"4"],V[T][5]=V[v+"5"],V[T][6]=V[v+"6"],V[T][7]=V[v+"7"],V[T][8]=V[v+"8"],V[T][9]=V[v+"9"],V[T][10]=V[v+"10"],V[T][11]=V[v+"11"],V[T][12]=V[v+"12"],V[T][13]=V[v+"13"],V[T][14]=V[v+"0"],V[T][15]=V[v+"0"]}function qe(v){return v==h0||v==vd||v==ko||v==b}function yt(){this.eb=[],this.size=this.A=this.fb=0}function Qt(){this.y=[],this.f=[],this.ea=[],this.F=[],this.Tc=this.Ed=this.Cd=this.Fd=this.lb=this.Db=this.Ab=this.fa=this.J=this.W=this.N=this.O=0}function Be(){this.Rd=this.height=this.width=this.S=0,this.f={},this.f.RGBA=new yt,this.f.kb=new Qt,this.sd=null}function pt(){this.width=[0],this.height=[0],this.Pd=[0],this.Qd=[0],this.format=[0]}function rt(){this.Id=this.fd=this.Md=this.hb=this.ib=this.da=this.bd=this.cd=this.j=this.v=this.Da=this.Sd=this.ob=0}function zt(v){return alert("todo:WebPSamplerProcessPlane"),v.T}function Yt(v,T){var j=v.T,q=T.ba.f.RGBA,Z=q.eb,te=q.fb+v.ka*q.A,ne=si[T.ba.S],le=v.y,xe=v.O,Ee=v.f,Ue=v.N,we=v.ea,ke=v.W,je=T.cc,Je=T.dc,xt=T.Mc,Ye=T.Nc,Ke=v.ka,kt=v.ka+v.T,Rt=v.U,Wt=Rt+1>>1;for(Ke==0?ne(le,xe,null,null,Ee,Ue,we,ke,Ee,Ue,we,ke,Z,te,null,null,Rt):(ne(T.ec,T.fc,le,xe,je,Je,xt,Ye,Ee,Ue,we,ke,Z,te-q.A,Z,te,Rt),++j);Ke+2j,Z=j==Gd||j==Sh||j==xd||j==bf||j==12||qe(j);if(T.memory=null,T.Ib=null,T.Jb=null,T.Nd=null,!po(T.Oa,v,Z?11:12))return 0;if(Z&&qe(j)&&Hr(),v.da)alert("todo:use_scaling");else{if(q){if(T.Ib=zt,v.Kb){if(j=v.U+1>>1,T.memory=s(v.U+2*j),T.memory==null)return 0;T.ec=T.memory,T.fc=0,T.cc=T.ec,T.dc=T.fc+v.U,T.Mc=T.cc,T.Nc=T.dc+j,T.Ib=Yt,Hr()}}else alert("todo:EmitYUV");Z&&(T.Jb=Bt,q&&Bi())}if(q&&!l1){for(v=0;256>v;++v)Nh[v]=89858*(v-128)+eo>>Io,Hd[v]=-22014*(v-128)+eo,py[v]=-45773*(v-128),p2[v]=113618*(v-128)+eo>>Io;for(v=ql;v>Io,A[v-ql]=hn(T,255),w[v-ql]=hn(T+8>>4,15);l1=1}return 1}function ut(v){var T=v.ma,j=v.U,q=v.T;return e(!(1&v.ka)),0>=j||0>=q?0:(j=T.Ib(v,T),T.Jb!=null&&T.Jb(v,T,j),T.Dc+=j,1)}function Gt(v){v.ma.memory=null}function it(v,T,j,q){return fe(v,8)!=47?0:(T[0]=fe(v,14)+1,j[0]=fe(v,14)+1,q[0]=fe(v,1),fe(v,3)!=0?0:!v.h)}function Ot(v,T){if(4>v)return v+1;var j=v-2>>1;return(2+(1&v)<>4)*v+(8-(15&j)))?j:1;var j}function Nt(v,T,j){var q=Ae(j),Z=v[T+=255&q].g-8;return 0>>0,e(8>=j.g),v.g}function Ie(v,T,j){var q=v.xc;return e((T=q==0?0:v.vc[v.md*(j>>q)+(T>>q)])>On.b)*tn;xtRt&&(Qn=Rt),(0,nl[Rr[fr++]>>8&15])(ke,je+ +Kn,Ke,kt+Kn-Rt,Qn-Kn,Ke,kt+Kn),Kn=Qn}je+=Rt,kt+=Rt,++xt&Kt||(On+=tn)}we!=Ee.nc&&r(xe,le-Je,xe,le+(we-Ue-1)*Je,Je);break;case 1:for(Je=ke,Ye=je,Rt=(ke=Ee.Ea)-(kt=ke&~(Ke=(je=1<>Ee.b)*xt;Ue=Z),0te.o&&(q=te.o),j=q?j=0:(Z[0]+=4*te.v,te.ka=j-te.j,te.U=te.va-te.v,te.T=q-j,j=1),j){if(le=le[0],11>(j=v.ca).S){var Ue=j.f.RGBA,we=(q=j.S,Z=te.U,te=te.T,Ee=Ue.eb,Ue.A),ke=te;for(Ue=Ue.fb+v.Ma*Ue.A;0q){var Z=v.l.width,te=j.ca,ne=j.tb+Z*q,le=v.V,xe=v.Ba+v.c*q,Ee=v.gc;e(v.ab==1),e(Ee[0].hc==3),bl(Ee[0],q,T,le,xe,te,ne),Mn(j,q,T,te,ne,Z)}v.C=v.Ma=T}function Hn(v,T,j,q,Z,te,ne){var le=v.$/q,xe=v.$%q,Ee=v.m,Ue=v.s,we=j+v.$,ke=we;Z=j+q*Z;var je=j+q*te,Je=280+Ue.ua,xt=v.Pb?le:16777216,Ye=0=xt){var Kt=we-j;e((xt=v).Pb),xt.wd=xt.m,xt.xd=Kt,0Zn.g?(pe(Wt,Wt.u+Zn.g),Kt[tn]=Zn.value,Wt=0):(pe(Wt,Wt.u+Zn.g-256),e(256<=Zn.value),Wt=Zn.value),Wt==0&&(Rt=!0)}else Wt=Nt(kt.G[0],kt.H[0],Ee);if(Ee.h)break;if(Rt||256>Wt){if(!Rt)if(kt.nd)T[we]=(kt.qb|Wt<<8)>>>0;else{if(ge(Ee),Rt=Nt(kt.G[1],kt.H[1],Ee),ge(Ee),Kt=Nt(kt.G[2],kt.H[2],Ee),tn=Nt(kt.G[3],kt.H[3],Ee),Ee.h)break;T[we]=(tn<<24|Rt<<16|Wt<<8|Kt)>>>0}if(Rt=!1,++we,++xe>=q&&(xe=0,++le,ne!=null&&le<=te&&!(le%16)&&ne(v,le),Ye!=null))for(;ke>>Ye.Mb]=Wt}else if(280>Wt){if(Wt=Ot(Wt-256,Ee),Kt=Nt(kt.G[4],kt.H[4],Ee),ge(Ee),Kt=nn(q,Kt=Ot(Kt,Ee)),Ee.h)break;if(we-j=q;)xe-=q,++le,ne!=null&&le<=te&&!(le%16)&&ne(v,le);if(e(we<=Z),xe&Ke&&(kt=Ie(Ue,xe,le)),Ye!=null)for(;ke>>Ye.Mb]=Wt}else{if(!(Wt>>Ye.Mb]=Wt;Wt=we,e(!(Rt>>>(Kt=Ye).Xa)),T[Wt]=Kt.X[Rt],Rt=!0}Rt||e(Ee.h==be(Ee))}if(v.Pb&&Ee.h&&wete?te:le),v.a=0,v.$=we-j}return 1}return v.a=3,0}function lr(v){e(v!=null),v.vc=null,v.yc=null,v.Ya=null;var T=v.Wa;T!=null&&(T.X=null),v.vb=null,e(v!=null)}function jr(){var v=new dr;return v==null?null:(v.a=0,v.xb=Qc,nt("Predictor","VP8LPredictors"),nt("Predictor","VP8LPredictors_C"),nt("PredictorAdd","VP8LPredictorsAdd"),nt("PredictorAdd","VP8LPredictorsAdd_C"),fd=Ve,_l=ct,Ro=Ut,pd=dt,zl=mt,rl=Ft,Tc=tt,V.VP8LMapColor32b=Ui,V.VP8LMapColor8b=ys,v)}function Qr(v,T,j,q,Z){var te=1,ne=[v],le=[T],xe=q.m,Ee=q.s,Ue=null,we=0;e:for(;;){if(j)for(;te&&fe(xe,1);){var ke=ne,je=le,Je=q,xt=1,Ye=Je.m,Ke=Je.gc[Je.ab],kt=fe(Ye,2);if(Je.Oc&1<=Je.ab),kt){case 0:case 1:Ke.b=fe(Ye,3)+2,xt=Qr(At(Ke.Ea,Ke.b),At(Ke.nc,Ke.b),0,Je,Ke.K),Ke.K=Ke.K[0];break;case 3:var Rt,Wt=fe(Ye,8)+1,Kt=16>On.b),fr=s(Rr);if(fr==null)Rt=0;else{var Kn=On.K[0],Qn=On.w;for(fr[0]=On.K[0][0],tn=1;tn<1*Zn;++tn)fr[tn]=Lt(Kn[Qn+tn],fr[tn-1]);for(;tn<4*Rr;++tn)fr[tn]=0;On.K[0]=null,On.K[0]=fr,Rt=1}}xt=Rt;break;case 2:break;default:e(0)}te=xt}}if(ne=ne[0],le=le[0],te&&fe(xe,1)&&!(te=1<=(we=fe(xe,4))&&11>=we)){q.a=3;break e}var kn;if(kn=te)t:{var pi,xr,Er,_i=q,zi=ne,rs=le,Di=we,Vi=j,Wr=_i.m,Bs=_i.s,$i=[null],gs=1,za=0,Cs=Jt[Di];n:for(;;){if(Vi&&fe(Wr,1)){var Tl=fe(Wr,3)+2,$d=At(zi,Tl),to=At(rs,Tl),Pu=$d*to;if(!Qr($d,to,0,_i,$i))break n;for($i=$i[0],Bs.xc=Tl,pi=0;pi>8&65535;$i[pi]=Us,Us>=gs&&(gs=Us+1)}}if(Wr.h)break n;for(xr=0;5>xr;++xr){var Do=he[xr];!xr&&0=Fr),ws=_s;var zs=s(za);if(ws==null||zs==null||As==null){_i.a=1;break n}var Ca=As;for(pi=Er=0;pixr;++xr){Do=he[xr],Rs[xr]=Ca,Jc[xr]=Er,!xr&&0v2)break i}else _f=v2;for(Pc=0;PcYd)xy[Pc++]=Yd,Yd!=0&&(f0=Yd);else{var P6=Yd==16,ew=Yd-16,tw=X[ew],b2=fe(gp,F[ew])+tw;if(Pc+b2>v2)break i;for(var oL=P6?f0:0;0=xr){var _2,yy=zs[0];for(_2=1;_2yy&&(yy=zs[_2]);El+=yy}}if(Ps.nd=Xd,Ps.Qb=0,Xd&&(Ps.qb=(Rs[3][Jc[3]+0].value<<24|Rs[1][Jc[1]+0].value<<16|Rs[2][Jc[2]+0].value)>>>0,Wd==0&&256>Rs[0][Jc[0]+0].value&&(Ps.Qb=1,Ps.qb+=Rs[0][Jc[0]+0].value<<8)),Ps.jc=!Ps.Qb&&6>El,Ps.jc){var w2,tu=Ps;for(w2=0;w2>=m(S2,8,Lu),Ap>>=m(tu.G[1][tu.H[1]+Ap],16,Lu),Ap>>=m(tu.G[2][tu.H[2]+Ap],0,Lu),m(tu.G[3][tu.H[3]+Ap],24,Lu))}}}Bs.vc=$i,Bs.Wb=gs,Bs.Ya=ws,Bs.yc=As,kn=1;break t}kn=0}if(!(te=kn)){q.a=3;break e}if(0q+1?[]:0),!(Z.lengthv?0:v>T?T:v}function Tn(){this.T=this.U=this.ka=this.height=this.width=0,this.y=[],this.f=[],this.ea=[],this.Rc=this.fa=this.W=this.N=this.O=0,this.ma="void",this.put="VP8IoPutHook",this.ac="VP8IoSetupHook",this.bc="VP8IoTeardownHook",this.ha=this.Kb=0,this.data=[],this.hb=this.ib=this.da=this.o=this.j=this.va=this.v=this.Da=this.ob=this.w=0,this.F=[],this.J=0}function Re(){var v=new Sn;return v!=null&&(v.a=0,v.sc="OK",v.cb=0,v.Xb=0,wr||(wr=zn)),v}function Wn(v,T,j){return v.a==0&&(v.a=T,v.sc=j,v.cb=0),0}function Ar(v,T,j){return 3<=j&&v[T+0]==157&&v[T+1]==1&&v[T+2]==42}function Un(v,T){if(v==null)return 0;if(v.a=0,v.sc="OK",T==null)return Wn(v,2,"null VP8Io passed to VP8GetHeaders()");var j=T.data,q=T.w,Z=T.ha;if(4>Z)return Wn(v,7,"Truncated header.");var te=j[q+0]|j[q+1]<<8|j[q+2]<<16,ne=v.Od;if(ne.Rb=!(1&te),ne.td=te>>1&7,ne.yd=te>>4&1,ne.ub=te>>5,3Z)return Wn(v,7,"cannot parse picture header");if(!Ar(j,q,Z))return Wn(v,3,"Bad code word");le.c=16383&(j[q+4]<<8|j[q+3]),le.Td=j[q+4]>>6,le.i=16383&(j[q+6]<<8|j[q+5]),le.Ud=j[q+6]>>6,q+=7,Z-=7,v.za=le.c+15>>4,v.Ub=le.i+15>>4,T.width=le.c,T.height=le.i,T.Da=0,T.j=0,T.v=0,T.va=T.width,T.o=T.height,T.da=0,T.ib=T.width,T.hb=T.height,T.U=T.width,T.T=T.height,i((te=v.Pa).jb,0,255,te.jb.length),e((te=v.Qa)!=null),te.Cb=0,te.Bb=0,te.Fb=1,i(te.Zb,0,0,te.Zb.length),i(te.Lb,0,0,te.Lb)}if(ne.ub>Z)return Wn(v,7,"bad partition length");ie(te=v.m,j,q,ne.ub),q+=ne.ub,Z-=ne.ub,ne.Rb&&(le.Ld=ze(te),le.Kd=ze(te)),le=v.Qa;var xe,Ee=v.Pa;if(e(te!=null),e(le!=null),le.Cb=ze(te),le.Cb){if(le.Bb=ze(te),ze(te)){for(le.Fb=ze(te),xe=0;4>xe;++xe)le.Zb[xe]=ze(te)?Q(te,7):0;for(xe=0;4>xe;++xe)le.Lb[xe]=ze(te)?Q(te,6):0}if(le.Bb)for(xe=0;3>xe;++xe)Ee.jb[xe]=ze(te)?ae(te,8):255}else le.Bb=0;if(te.Ka)return Wn(v,3,"cannot parse segment header");if((le=v.ed).zd=ze(te),le.Tb=ae(te,6),le.wb=ae(te,3),le.Pc=ze(te),le.Pc&&ze(te)){for(Ee=0;4>Ee;++Ee)ze(te)&&(le.vd[Ee]=Q(te,6));for(Ee=0;4>Ee;++Ee)ze(te)&&(le.od[Ee]=Q(te,6))}if(v.L=le.Tb==0?0:le.zd?1:2,te.Ka)return Wn(v,3,"cannot parse filter header");var Ue=Z;if(Z=xe=q,q=xe+Ue,le=Ue,v.Xb=(1<le&&(we=le),ie(v.Jc[+Ue],j,xe,we),xe+=we,le-=we,Z+=3}ie(v.Jc[+Ee],j,xe,le),j=xewe;++we){if(Ue.Cb){var ke=Ue.Zb[we];Ue.Fb||(ke+=j)}else{if(0>16,8>je.Eb[1]&&(je.Eb[1]=8),je.Qc[0]=_n[hn(ke+Ee,117)],je.Qc[1]=Xn[hn(ke+xe,127)],je.lc=ke+xe}if(!ne.Rb)return Wn(v,4,"Not a key frame.");for(ze(te),ne=v.Pa,j=0;4>j;++j){for(Z=0;8>Z;++Z)for(q=0;3>q;++q)for(le=0;11>le;++le)Ee=Xe(te,Th[j][Z][q][le])?ae(te,8):bs[j][Z][q][le],ne.Wc[j][Z].Yb[q][le]=Ee;for(Z=0;17>Z;++Z)ne.Xc[j][Z]=ne.Wc[j][Pm[Z]]}return v.kc=ze(te),v.kc&&(v.Bd=ae(te,8)),v.cb=1}function zn(v,T,j,q,Z,te,ne){var le=T[Z].Yb[j];for(j=0;16>Z;++Z){if(!Xe(v,le[j+0]))return Z;for(;!Xe(v,le[j+1]);)if(le=T[++Z].Yb[0],j=0,Z==16)return 16;var xe=T[Z+1].Yb;if(Xe(v,le[j+2])){var Ee=v,Ue=0;if(Xe(Ee,(ke=le)[(we=j)+3]))if(Xe(Ee,ke[we+6])){for(le=0,we=2*(Ue=Xe(Ee,ke[we+8]))+(ke=Xe(Ee,ke[we+9+Ue])),Ue=0,ke=zr[we];ke[le];++le)Ue+=Ue+Xe(Ee,ke[le]);Ue+=3+(8<(Ee=v).b&&Te(Ee);var we,ke=Ee.b,je=(we=Ee.Ca>>1)-(Ee.I>>ke)>>31;--Ee.b,Ee.Ca+=je,Ee.Ca|=1,Ee.I-=(we+1&je)<>3),v[T+j+32*q]=-256&Z?0>Z?0:255:Z}function Kr(v,T,j,q,Z,te){ii(v,T,0,j,q+Z),ii(v,T,1,j,q+te),ii(v,T,2,j,q-te),ii(v,T,3,j,q-Z)}function Ir(v){return(20091*v>>16)+v}function In(v,T,j,q){var Z,te=0,ne=s(16);for(Z=0;4>Z;++Z){var le=v[T+0]+v[T+8],xe=v[T+0]-v[T+8],Ee=(35468*v[T+4]>>16)-Ir(v[T+12]),Ue=Ir(v[T+4])+(35468*v[T+12]>>16);ne[te+0]=le+Ue,ne[te+1]=xe+Ee,ne[te+2]=xe-Ee,ne[te+3]=le-Ue,te+=4,T++}for(Z=te=0;4>Z;++Z)le=(v=ne[te+0]+4)+ne[te+8],xe=v-ne[te+8],Ee=(35468*ne[te+4]>>16)-Ir(ne[te+12]),ii(j,q,0,0,le+(Ue=Ir(ne[te+4])+(35468*ne[te+12]>>16))),ii(j,q,1,0,xe+Ee),ii(j,q,2,0,xe-Ee),ii(j,q,3,0,le-Ue),te++,q+=32}function Ri(v,T,j,q){var Z=v[T+0]+4,te=35468*v[T+4]>>16,ne=Ir(v[T+4]),le=35468*v[T+1]>>16;Kr(j,q,0,Z+ne,v=Ir(v[T+1]),le),Kr(j,q,1,Z+te,v,le),Kr(j,q,2,Z-te,v,le),Kr(j,q,3,Z-ne,v,le)}function sr(v,T,j,q,Z){In(v,T,j,q),Z&&In(v,T+16,j,q+4)}function Ai(v,T,j,q){tc(v,T+0,j,q,1),tc(v,T+32,j,q+128,1)}function fs(v,T,j,q){var Z;for(v=v[T+0]+4,Z=0;4>Z;++Z)for(T=0;4>T;++T)ii(j,q,T,Z,v)}function Ki(v,T,j,q){v[T+0]&&ua(v,T+0,j,q),v[T+16]&&ua(v,T+16,j,q+4),v[T+32]&&ua(v,T+32,j,q+128),v[T+48]&&ua(v,T+48,j,q+128+4)}function js(v,T,j,q){var Z,te=s(16);for(Z=0;4>Z;++Z){var ne=v[T+0+Z]+v[T+12+Z],le=v[T+4+Z]+v[T+8+Z],xe=v[T+4+Z]-v[T+8+Z],Ee=v[T+0+Z]-v[T+12+Z];te[0+Z]=ne+le,te[8+Z]=ne-le,te[4+Z]=Ee+xe,te[12+Z]=Ee-xe}for(Z=0;4>Z;++Z)ne=(v=te[0+4*Z]+3)+te[3+4*Z],le=te[1+4*Z]+te[2+4*Z],xe=te[1+4*Z]-te[2+4*Z],Ee=v-te[3+4*Z],j[q+0]=ne+le>>3,j[q+16]=Ee+xe>>3,j[q+32]=ne-le>>3,j[q+48]=Ee-xe>>3,q+=64}function oi(v,T,j){var q,Z=T-32,te=sl,ne=255-v[Z-1];for(q=0;qj;++j)r(v,T+32*j,v,T-32,16)}function Sa(v,T){var j;for(j=16;0q;++q)i(T,j+32*q,v,16)}function Wo(v,T){var j,q=16;for(j=0;16>j;++j)q+=v[T-1+32*j]+v[T+j-32];Fa(q>>5,v,T)}function nr(v,T){var j,q=8;for(j=0;16>j;++j)q+=v[T-1+32*j];Fa(q>>4,v,T)}function Hc(v,T){var j,q=8;for(j=0;16>j;++j)q+=v[T+j-32];Fa(q>>4,v,T)}function Xo(v,T){Fa(128,v,T)}function Dn(v,T,j){return v+2*T+j+2>>2}function Yo(v,T){var j,q=T-32;for(q=new Uint8Array([Dn(v[q-1],v[q+0],v[q+1]),Dn(v[q+0],v[q+1],v[q+2]),Dn(v[q+1],v[q+2],v[q+3]),Dn(v[q+2],v[q+3],v[q+4])]),j=0;4>j;++j)r(v,T+32*j,q,0,q.length)}function es(v,T){var j=v[T-1],q=v[T-1+32],Z=v[T-1+64],te=v[T-1+96];Qe(v,T+0,16843009*Dn(v[T-1-32],j,q)),Qe(v,T+32,16843009*Dn(j,q,Z)),Qe(v,T+64,16843009*Dn(q,Z,te)),Qe(v,T+96,16843009*Dn(Z,te,te))}function Es(v,T){var j,q=4;for(j=0;4>j;++j)q+=v[T+j-32]+v[T-1+32*j];for(q>>=3,j=0;4>j;++j)i(v,T+32*j,q,4)}function Jl(v,T){var j=v[T-1+0],q=v[T-1+32],Z=v[T-1+64],te=v[T-1-32],ne=v[T+0-32],le=v[T+1-32],xe=v[T+2-32],Ee=v[T+3-32];v[T+0+96]=Dn(q,Z,v[T-1+96]),v[T+1+96]=v[T+0+64]=Dn(j,q,Z),v[T+2+96]=v[T+1+64]=v[T+0+32]=Dn(te,j,q),v[T+3+96]=v[T+2+64]=v[T+1+32]=v[T+0+0]=Dn(ne,te,j),v[T+3+64]=v[T+2+32]=v[T+1+0]=Dn(le,ne,te),v[T+3+32]=v[T+2+0]=Dn(xe,le,ne),v[T+3+0]=Dn(Ee,xe,le)}function Su(v,T){var j=v[T+1-32],q=v[T+2-32],Z=v[T+3-32],te=v[T+4-32],ne=v[T+5-32],le=v[T+6-32],xe=v[T+7-32];v[T+0+0]=Dn(v[T+0-32],j,q),v[T+1+0]=v[T+0+32]=Dn(j,q,Z),v[T+2+0]=v[T+1+32]=v[T+0+64]=Dn(q,Z,te),v[T+3+0]=v[T+2+32]=v[T+1+64]=v[T+0+96]=Dn(Z,te,ne),v[T+3+32]=v[T+2+64]=v[T+1+96]=Dn(te,ne,le),v[T+3+64]=v[T+2+96]=Dn(ne,le,xe),v[T+3+96]=Dn(le,xe,xe)}function Gs(v,T){var j=v[T-1+0],q=v[T-1+32],Z=v[T-1+64],te=v[T-1-32],ne=v[T+0-32],le=v[T+1-32],xe=v[T+2-32],Ee=v[T+3-32];v[T+0+0]=v[T+1+64]=te+ne+1>>1,v[T+1+0]=v[T+2+64]=ne+le+1>>1,v[T+2+0]=v[T+3+64]=le+xe+1>>1,v[T+3+0]=xe+Ee+1>>1,v[T+0+96]=Dn(Z,q,j),v[T+0+64]=Dn(q,j,te),v[T+0+32]=v[T+1+96]=Dn(j,te,ne),v[T+1+32]=v[T+2+96]=Dn(te,ne,le),v[T+2+32]=v[T+3+96]=Dn(ne,le,xe),v[T+3+32]=Dn(le,xe,Ee)}function Ya(v,T){var j=v[T+0-32],q=v[T+1-32],Z=v[T+2-32],te=v[T+3-32],ne=v[T+4-32],le=v[T+5-32],xe=v[T+6-32],Ee=v[T+7-32];v[T+0+0]=j+q+1>>1,v[T+1+0]=v[T+0+64]=q+Z+1>>1,v[T+2+0]=v[T+1+64]=Z+te+1>>1,v[T+3+0]=v[T+2+64]=te+ne+1>>1,v[T+0+32]=Dn(j,q,Z),v[T+1+32]=v[T+0+96]=Dn(q,Z,te),v[T+2+32]=v[T+1+96]=Dn(Z,te,ne),v[T+3+32]=v[T+2+96]=Dn(te,ne,le),v[T+3+64]=Dn(ne,le,xe),v[T+3+96]=Dn(le,xe,Ee)}function $c(v,T){var j=v[T-1+0],q=v[T-1+32],Z=v[T-1+64],te=v[T-1+96];v[T+0+0]=j+q+1>>1,v[T+2+0]=v[T+0+32]=q+Z+1>>1,v[T+2+32]=v[T+0+64]=Z+te+1>>1,v[T+1+0]=Dn(j,q,Z),v[T+3+0]=v[T+1+32]=Dn(q,Z,te),v[T+3+32]=v[T+1+64]=Dn(Z,te,te),v[T+3+64]=v[T+2+64]=v[T+0+96]=v[T+1+96]=v[T+2+96]=v[T+3+96]=te}function Za(v,T){var j=v[T-1+0],q=v[T-1+32],Z=v[T-1+64],te=v[T-1+96],ne=v[T-1-32],le=v[T+0-32],xe=v[T+1-32],Ee=v[T+2-32];v[T+0+0]=v[T+2+32]=j+ne+1>>1,v[T+0+32]=v[T+2+64]=q+j+1>>1,v[T+0+64]=v[T+2+96]=Z+q+1>>1,v[T+0+96]=te+Z+1>>1,v[T+3+0]=Dn(le,xe,Ee),v[T+2+0]=Dn(ne,le,xe),v[T+1+0]=v[T+3+32]=Dn(j,ne,le),v[T+1+32]=v[T+3+64]=Dn(q,j,ne),v[T+1+64]=v[T+3+96]=Dn(Z,q,j),v[T+1+96]=Dn(te,Z,q)}function Fs(v,T){var j;for(j=0;8>j;++j)r(v,T+32*j,v,T-32,8)}function xl(v,T){var j;for(j=0;8>j;++j)i(v,T,v[T-1],8),T+=32}function Hs(v,T,j){var q;for(q=0;8>q;++q)i(T,j+32*q,v,8)}function fo(v,T){var j,q=8;for(j=0;8>j;++j)q+=v[T+j-32]+v[T-1+32*j];Hs(q>>4,v,T)}function Zo(v,T){var j,q=4;for(j=0;8>j;++j)q+=v[T+j-32];Hs(q>>3,v,T)}function Qo(v,T){var j,q=4;for(j=0;8>j;++j)q+=v[T-1+32*j];Hs(q>>3,v,T)}function yc(v,T){Hs(128,v,T)}function bc(v,T,j){var q=v[T-j],Z=v[T+0],te=3*(Z-q)+wh[1020+v[T-2*j]-v[T+j]],ne=Ad[112+(te+4>>3)];v[T-j]=sl[255+q+Ad[112+(te+3>>3)]],v[T+0]=sl[255+Z-ne]}function Qa(v,T,j,q){var Z=v[T+0],te=v[T+j];return Lo[255+v[T-2*j]-v[T-j]]>q||Lo[255+te-Z]>q}function qr(v,T,j,q){return 4*Lo[255+v[T-j]-v[T+0]]+Lo[255+v[T-2*j]-v[T+j]]<=q}function Wc(v,T,j,q,Z){var te=v[T-3*j],ne=v[T-2*j],le=v[T-j],xe=v[T+0],Ee=v[T+j],Ue=v[T+2*j],we=v[T+3*j];return 4*Lo[255+le-xe]+Lo[255+ne-Ee]>q?0:Lo[255+v[T-4*j]-te]<=Z&&Lo[255+te-ne]<=Z&&Lo[255+ne-le]<=Z&&Lo[255+we-Ue]<=Z&&Lo[255+Ue-Ee]<=Z&&Lo[255+Ee-xe]<=Z}function $s(v,T,j,q){var Z=2*q+1;for(q=0;16>q;++q)qr(v,T+q,j,Z)&&bc(v,T+q,j)}function ca(v,T,j,q){var Z=2*q+1;for(q=0;16>q;++q)qr(v,T+q*j,1,Z)&&bc(v,T+q*j,1)}function ia(v,T,j,q){var Z;for(Z=3;0>7,Ke=18*kt+63>>7,kt=9*kt+63>>7;xe[Ee-3*Ue]=sl[255+xe[Ee-3*Ue]+kt],xe[Ee-2*Ue]=sl[255+we+Ke],xe[Ee-Ue]=sl[255+ke+Ye],xe[Ee+0]=sl[255+je-Ye],xe[Ee+Ue]=sl[255+Je-Ke],xe[Ee+2*Ue]=sl[255+xt-kt]}T+=q}}function Ko(v,T,j,q,Z,te,ne,le){for(te=2*te+1;0>3)],xt=Ad[112+(xt+3>>3)],Ye=Je+1>>1;xe[Ee-2*Ue]=sl[255+xe[Ee-2*Ue]+Ye],xe[Ee-Ue]=sl[255+we+xt],xe[Ee+0]=sl[255+ke-Je],xe[Ee+Ue]=sl[255+je-Ye]}T+=q}}function Tu(v,T,j,q,Z,te){Ta(v,T,j,1,16,q,Z,te)}function qd(v,T,j,q,Z,te){Ta(v,T,1,j,16,q,Z,te)}function Ea(v,T,j,q,Z,te){var ne;for(ne=3;0Ee?0:255:Ee)&255,Ee=xe,Z[te+le]=Ue}}function sa(v,T,j,q){var Z=T.width,te=T.o;if(e(v!=null&&T!=null),0>j||0>=q||j+q>te)return null;if(!v.Cc){if(v.ga==null){var ne;if(v.ga=new ar,(ne=v.ga==null)||(ne=T.width*T.o,e(v.Gb.length==0),v.Gb=s(ne),v.Uc=0,v.Gb==null?ne=0:(v.mb=v.Gb,v.nb=v.Uc,v.rc=null,ne=1),ne=!ne),!ne){ne=v.ga;var le=v.Fa,xe=v.P,Ee=v.qc,Ue=v.mb,we=v.nb,ke=xe+1,je=Ee-1,Je=ne.l;if(e(le!=null&&Ue!=null&&T!=null),ns[0]=null,ns[1]=Dr,ns[2]=Gr,ns[3]=Ni,ne.ca=Ue,ne.tb=we,ne.c=T.width,ne.i=T.height,e(0=Ee)T=0;else if(ne.$a=3&le[xe+0],ne.Z=le[xe+0]>>2&3,ne.Lc=le[xe+0]>>4&3,xe=le[xe+0]>>6&3,0>ne.$a||1=ne.c*ne.i;ne=!T}if(ne)return null;v.ga.Lc!=1?v.Ga=0:q=te-j}e(v.ga!=null),e(j+q<=te);e:{if(T=(le=v.ga).c,te=le.l.o,le.$a==0){if(ke=v.rc,je=v.Vc,Je=v.Fa,xe=v.P+1+j*T,Ee=v.mb,Ue=v.nb+j*T,e(xe<=v.P+v.qc),le.Z!=0)for(e(ns[le.Z]!=null),ne=0;ne=T)T=1;else if(le.ic||Bi(),le.ic){le=ne.V,ke=ne.Ba,je=ne.c;var xt=ne.i,Ye=(Je=1,xe=ne.$/je,Ee=ne.$%je,Ue=ne.m,we=ne.s,ne.$),Ke=je*xt,kt=je*T,Rt=we.wc,Wt=Ye(xt=Nt(Wt.G[0],Wt.H[0],Ue)))le[ke+Ye]=xt,++Ye,++Ee>=je&&(Ee=0,++xe<=T&&!(xe%16)&&Cn(ne,xe));else{if(!(280>xt)){Je=0;break t}xt=Ot(xt-256,Ue);var Kt,tn=Nt(Wt.G[4],Wt.H[4],Ue);if(ge(Ue),!(Ye>=(tn=nn(je,tn=Ot(tn,Ue)))&&Ke-Ye>=xt)){Je=0;break t}for(Kt=0;Kt=je;)Ee-=je,++xe<=T&&!(xe%16)&&Cn(ne,xe);YeT?T:xe);break t}!Je||Ue.h&&Ye=te&&(v.Cc=1),q=1}if(!q)return null;if(v.Cc&&((q=v.ga)!=null&&(q.mc=null),v.ga=null,0>23,le[xe+4*ne+1]=le[xe+4*ne+1]*we>>23,le[xe+4*ne+2]=le[xe+4*ne+2]*we>>23)}T+=te}}function Fi(v,T,j,q,Z){for(;0>4)*xe>>16;v[T+2*te+0]=(240&ne|ne>>4)*xe>>16&240|(15&ne|ne<<4)*xe>>16>>4&15,v[T+2*te+1]=240&Ee|le}T+=Z}}function Ns(v,T,j,q,Z,te,ne,le){var xe,Ee,Ue=255;for(Ee=0;Ee>8}function Bi(){Ao=us,il=Fi,Mu=Ns,gd=ps}function Xs(v,T,j){V[v]=function(q,Z,te,ne,le,xe,Ee,Ue,we,ke,je,Je,xt,Ye,Ke,kt,Rt){var Wt,Kt=Rt-1>>1,tn=le[xe+0]|Ee[Ue+0]<<16,Zn=we[ke+0]|je[Je+0]<<16;e(q!=null);var On=3*tn+Zn+131074>>2;for(T(q[Z+0],255&On,On>>16,xt,Ye),te!=null&&(On=3*Zn+tn+131074>>2,T(te[ne+0],255&On,On>>16,Ke,kt)),Wt=1;Wt<=Kt;++Wt){var Rr=le[xe+Wt]|Ee[Ue+Wt]<<16,fr=we[ke+Wt]|je[Je+Wt]<<16,Kn=tn+Rr+Zn+fr+524296,Qn=Kn+2*(Rr+Zn)>>3;On=Qn+tn>>1,tn=(Kn=Kn+2*(tn+fr)>>3)+Rr>>1,T(q[Z+2*Wt-1],255&On,On>>16,xt,Ye+(2*Wt-1)*j),T(q[Z+2*Wt-0],255&tn,tn>>16,xt,Ye+(2*Wt-0)*j),te!=null&&(On=Kn+Zn>>1,tn=Qn+fr>>1,T(te[ne+2*Wt-1],255&On,On>>16,Ke,kt+(2*Wt-1)*j),T(te[ne+2*Wt+0],255&tn,tn>>16,Ke,kt+(2*Wt+0)*j)),tn=Rr,Zn=fr}1&Rt||(On=3*tn+Zn+131074>>2,T(q[Z+Rt-1],255&On,On>>16,xt,Ye+(Rt-1)*j),te!=null&&(On=3*Zn+tn+131074>>2,T(te[ne+Rt-1],255&On,On>>16,Ke,kt+(Rt-1)*j)))}}function Hr(){si[d0]=Kc,si[Gd]=dp,si[yf]=Mc,si[Sh]=pn,si[xd]=xn,si[bf]=hp,si[up]=fy,si[h0]=dp,si[vd]=pn,si[ko]=xn,si[b]=hp}function Ka(v){return v&-16384?0>v?0:255:v>>Eh}function _c(v,T){return Ka((19077*v>>8)+(26149*T>>8)-14234)}function Ba(v,T,j){return Ka((19077*v>>8)-(6419*T>>8)-(13320*j>>8)+8708)}function Ja(v,T){return Ka((19077*v>>8)+(33050*T>>8)-17685)}function vl(v,T,j,q,Z){q[Z+0]=_c(v,j),q[Z+1]=Ba(v,T,j),q[Z+2]=Ja(v,T)}function Jo(v,T,j,q,Z){q[Z+0]=Ja(v,T),q[Z+1]=Ba(v,T,j),q[Z+2]=_c(v,j)}function Bl(v,T,j,q,Z){var te=Ba(v,T,j);T=te<<3&224|Ja(v,T)>>3,q[Z+0]=248&_c(v,j)|te>>5,q[Z+1]=T}function Li(v,T,j,q,Z){var te=240&Ja(v,T)|15;q[Z+0]=240&_c(v,j)|Ba(v,T,j)>>4,q[Z+1]=te}function Xc(v,T,j,q,Z){q[Z+0]=255,vl(v,T,j,q,Z+1)}function yl(v,T,j,q,Z){Jo(v,T,j,q,Z),q[Z+3]=255}function Co(v,T,j,q,Z){vl(v,T,j,q,Z),q[Z+3]=255}function ms(v,T,j){V[v]=function(q,Z,te,ne,le,xe,Ee,Ue,we){for(var ke=Ue+(-2&we)*j;Ue!=ke;)T(q[Z+0],te[ne+0],le[xe+0],Ee,Ue),T(q[Z+1],te[ne+0],le[xe+0],Ee,Ue+j),Z+=2,++ne,++xe,Ue+=2*j;1&we&&T(q[Z+0],te[ne+0],le[xe+0],Ee,Ue)}}function Ms(v,T,j){return j==0?v==0?T==0?6:5:T==0?4:0:j}function $r(v,T,j,q,Z){switch(v>>>30){case 3:tc(T,j,q,Z,0);break;case 2:Eu(T,j,q,Z);break;case 1:ua(T,j,q,Z)}}function wc(v,T){var j,q,Z=T.M,te=T.Nb,ne=v.oc,le=v.pc+40,xe=v.oc,Ee=v.pc+584,Ue=v.oc,we=v.pc+600;for(j=0;16>j;++j)ne[le+32*j-1]=129;for(j=0;8>j;++j)xe[Ee+32*j-1]=129,Ue[we+32*j-1]=129;for(0j;++j)r(ne,le+32*j-4,ne,le+32*j+12,4);for(j=-1;8>j;++j)r(xe,Ee+32*j-4,xe,Ee+32*j+4,4),r(Ue,we+32*j-4,Ue,we+32*j+4,4)}var je=v.Gd,Je=v.Hd+q,xt=ke.ad,Ye=ke.Hc;if(0=v.za-1?i(Ke,kt,je[Je].y[15],4):r(Ke,kt,je[Je+1].y,0,4)),j=0;4>j;j++)Ke[kt+128+j]=Ke[kt+256+j]=Ke[kt+384+j]=Ke[kt+0+j];for(j=0;16>j;++j,Ye<<=2)Ke=ne,kt=le+S[j],ds[ke.Ob[j]](Ke,kt),$r(Ye,xt,16*+j,Ke,kt)}else if(Ke=Ms(q,Z,ke.Ob[0]),Pn[Ke](ne,le),Ye!=0)for(j=0;16>j;++j,Ye<<=2)$r(Ye,xt,16*+j,ne,le+S[j]);for(j=ke.Gc,Ke=Ms(q,Z,ke.Dd),Ec[Ke](xe,Ee),Ec[Ke](Ue,we),Ye=xt,Ke=xe,kt=Ee,255&(ke=0|j)&&(170&ke?Zc(Ye,256,Ke,kt):da(Ye,256,Ke,kt)),ke=Ue,Ye=we,255&(j>>=8)&&(170&j?Zc(xt,320,ke,Ye):da(xt,320,ke,Ye)),Zj;++j)r(je,Je+j*v.R,ne,le+32*j,16);for(j=0;8>j;++j)r(xt,ke+j*v.B,xe,Ee+32*j,8),r(Ye,Ke+j*v.B,Ue,we+32*j,8)}}function Na(v,T,j,q,Z,te,ne,le,xe){var Ee=[0],Ue=[0],we=0,ke=xe!=null?xe.kd:0,je=xe??new qt;if(v==null||12>j)return 7;je.data=v,je.w=T,je.ha=j,T=[T],j=[j],je.gb=[je.gb];e:{var Je=T,xt=j,Ye=je.gb;if(e(v!=null),e(xt!=null),e(Ye!=null),Ye[0]=0,12<=xt[0]&&!t(v,Je[0],"RIFF")){if(t(v,Je[0]+8,"WEBP")){Ye=3;break e}var Ke=ht(v,Je[0]+4);if(12>Ke||4294967286xt[0]-8){Ye=7;break e}Ye[0]=Ke,Je[0]+=12,xt[0]-=12}Ye=0}if(Ye!=0)return Ye;for(Ke=0Ye[0])Ye=7;else{if(!t(kt,xt[0],"VP8X")){if(ht(kt,xt[0]+4)!=10){Ye=3;break e}if(18>Ye[0]){Ye=7;break e}var tn=ht(kt,xt[0]+8),Zn=1+bt(kt,xt[0]+12);if(2147483648<=Zn*(kt=1+bt(kt,xt[0]+15))){Ye=3;break e}Kt!=null&&(Kt[0]=tn),Rt!=null&&(Rt[0]=Zn),Wt!=null&&(Wt[0]=kt),xt[0]+=18,Ye[0]-=18,On[0]=1}Ye=0}}if(we=we[0],Je=Je[0],Ye!=0)return Ye;if(xt=!!(2&Je),!Ke&&we)return 3;if(te!=null&&(te[0]=!!(16&Je)),ne!=null&&(ne[0]=xt),le!=null&&(le[0]=0),ne=Ee[0],Je=Ue[0],we&&xt&&xe==null){Ye=0;break}if(4>j){Ye=7;break}if(Ke&&we||!Ke&&!we&&!t(v,T[0],"ALPH")){j=[j],je.na=[je.na],je.P=[je.P],je.Sa=[je.Sa];e:{tn=v,Ye=T,Ke=j;var On=je.gb;Rt=je.na,Wt=je.P,Kt=je.Sa,Zn=22,e(tn!=null),e(Ke!=null),kt=Ye[0];var Rr=Ke[0];for(e(Rt!=null),e(Kt!=null),Rt[0]=null,Wt[0]=null,Kt[0]=0;;){if(Ye[0]=kt,Ke[0]=Rr,8>Rr){Ye=7;break e}var fr=ht(tn,kt+4);if(4294967286On){Ye=3;break e}if(!t(tn,kt,"VP8 ")||!t(tn,kt,"VP8L")){Ye=0;break e}if(Rr[0]Ke[0])Ye=7;else{if(kt||Zn){if(On=ht(On,tn+4),12<=Rt&&On>Rt-12){Ye=3;break e}if(ke&&On>Ke[0]-8){Ye=7;break e}Wt[0]=On,Ye[0]+=8,Ke[0]-=8,Kt[0]=Zn}else Kt[0]=5<=Ke[0]&&On[tn+0]==47&&!(On[tn+4]>>5),Wt[0]=Ke[0];Ye=0}if(j=j[0],je.Ja=je.Ja[0],je.xa=je.xa[0],T=T[0],Ye!=0)break;if(4294967286j){Ye=7;break}le=ne,ke=Je,xt=te,v==null||5>j?v=0:5<=j&&v[T+0]==47&&!(v[T+4]>>5)?(Ke=[0],On=[0],Rt=[0],re(Wt=new me,v,T,j),it(Wt,Ke,On,Rt)?(le!=null&&(le[0]=Ke[0]),ke!=null&&(ke[0]=On[0]),xt!=null&&(xt[0]=Rt[0]),v=1):v=0):v=0}else{if(10>j){Ye=7;break}le=Je,v==null||10>j||!Ar(v,T+3,j-3)?v=0:(ke=v[T+0]|v[T+1]<<8|v[T+2]<<16,xt=16383&(v[T+7]<<8|v[T+6]),v=16383&(v[T+9]<<8|v[T+8]),1&ke||3<(ke>>1&7)||!(ke>>4&1)||ke>>5>=je.Ja||!xt||!v?v=0:(ne&&(ne[0]=xt),le&&(le[0]=v),v=1))}if(!v||(ne=ne[0],Je=Je[0],we&&(Ee[0]!=ne||Ue[0]!=Je)))return 3;xe!=null&&(xe[0]=je,xe.offset=T-xe.w,e(4294967286>T-xe.w),e(xe.offset==xe.ha-j));break}return Ye==0||Ye==7&&we&&xe==null?(te!=null&&(te[0]|=je.na!=null&&0j||(te&=-2,ne&=-2),0>te||0>ne||0>=le||0>=xe||te+le>q||ne+xe>Z))return 0;if(T.v=te,T.j=ne,T.va=te+le,T.o=ne+xe,T.U=le,T.T=xe,T.da=v!=null&&0v.S){var T=v.f.RGBA;T.fb+=(v.height-1)*T.A,T.A=-T.A}else T=v.f.kb,v=v.height,T.O+=(v-1)*T.fa,T.fa=-T.fa,T.N+=(v-1>>1)*T.Ab,T.Ab=-T.Ab,T.W+=(v-1>>1)*T.Db,T.Db=-T.Db,T.F!=null&&(T.J+=(v-1)*T.lb,T.lb=-T.lb);return 0}function Ul(v,T,j,q){if(q==null||0>=v||0>=T)return 2;if(j!=null){if(j.Da){var Z=j.cd,te=j.bd,ne=-2&j.v,le=-2&j.j;if(0>ne||0>le||0>=Z||0>=te||ne+Z>v||le+te>T)return 2;v=Z,T=te}if(j.da){if(!et(v,T,Z=[j.ib],te=[j.hb]))return 2;v=Z[0],T=te[0]}}q.width=v,q.height=T;e:{var xe=q.width,Ee=q.height;if(v=q.S,0>=xe||0>=Ee||!(v>=d0&&13>v))v=2;else{if(0>=q.Rd&&q.sd==null){ne=te=Z=T=0;var Ue=(le=xe*D[v])*Ee;if(11>v||(te=(Ee+1)/2*(T=(xe+1)/2),v==12&&(ne=(Z=xe)*Ee)),(Ee=s(Ue+2*te+ne))==null){v=1;break e}q.sd=Ee,11>v?((xe=q.f.RGBA).eb=Ee,xe.fb=0,xe.A=le,xe.size=Ue):((xe=q.f.kb).y=Ee,xe.O=0,xe.fa=le,xe.Fd=Ue,xe.f=Ee,xe.N=0+Ue,xe.Ab=T,xe.Cd=te,xe.ea=Ee,xe.W=0+Ue+te,xe.Db=T,xe.Ed=te,v==12&&(xe.F=Ee,xe.J=0+Ue+2*te),xe.Tc=ne,xe.lb=Z)}if(T=1,Z=q.S,te=q.width,ne=q.height,Z>=d0&&13>Z)if(11>Z)v=q.f.RGBA,T&=(le=Math.abs(v.A))*(ne-1)+te<=v.size,T&=le>=te*D[Z],T&=v.eb!=null;else{v=q.f.kb,le=(te+1)/2,Ue=(ne+1)/2,xe=Math.abs(v.fa),Ee=Math.abs(v.Ab);var we=Math.abs(v.Db),ke=Math.abs(v.lb),je=ke*(ne-1)+te;T&=xe*(ne-1)+te<=v.Fd,T&=Ee*(Ue-1)+le<=v.Cd,T=(T&=we*(Ue-1)+le<=v.Ed)&xe>=te&Ee>=le&we>=le,T&=v.y!=null,T&=v.f!=null,T&=v.ea!=null,Z==12&&(T&=ke>=te,T&=je<=v.Tc,T&=v.F!=null)}else T=0;v=T?0:2}}return v!=0||j!=null&&j.fd&&(v=Po(q)),v}var Yc=64,hd=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535,131071,262143,524287,1048575,2097151,4194303,8388607,16777215],el=24,Ys=32,tl=8,Sc=[0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7];st("Predictor0","PredictorAdd0"),V.Predictor0=function(){return 4278190080},V.Predictor1=function(v){return v},V.Predictor2=function(v,T,j){return T[j+0]},V.Predictor3=function(v,T,j){return T[j+1]},V.Predictor4=function(v,T,j){return T[j-1]},V.Predictor5=function(v,T,j){return Se(Se(v,T[j+1]),T[j+0])},V.Predictor6=function(v,T,j){return Se(v,T[j-1])},V.Predictor7=function(v,T,j){return Se(v,T[j+0])},V.Predictor8=function(v,T,j){return Se(T[j-1],T[j+0])},V.Predictor9=function(v,T,j){return Se(T[j+0],T[j+1])},V.Predictor10=function(v,T,j){return Se(Se(v,T[j-1]),Se(T[j+0],T[j+1]))},V.Predictor11=function(v,T,j){var q=T[j+0];return 0>=De(q>>24&255,v>>24&255,(T=T[j-1])>>24&255)+De(q>>16&255,v>>16&255,T>>16&255)+De(q>>8&255,v>>8&255,T>>8&255)+De(255&q,255&v,255&T)?q:v},V.Predictor12=function(v,T,j){var q=T[j+0];return(_t((v>>24&255)+(q>>24&255)-((T=T[j-1])>>24&255))<<24|_t((v>>16&255)+(q>>16&255)-(T>>16&255))<<16|_t((v>>8&255)+(q>>8&255)-(T>>8&255))<<8|_t((255&v)+(255&q)-(255&T)))>>>0},V.Predictor13=function(v,T,j){var q=T[j-1];return(It((v=Se(v,T[j+0]))>>24&255,q>>24&255)<<24|It(v>>16&255,q>>16&255)<<16|It(v>>8&255,q>>8&255)<<8|It(255&v,255&q))>>>0};var ec=V.PredictorAdd0;V.PredictorAdd1=ue,st("Predictor2","PredictorAdd2"),st("Predictor3","PredictorAdd3"),st("Predictor4","PredictorAdd4"),st("Predictor5","PredictorAdd5"),st("Predictor6","PredictorAdd6"),st("Predictor7","PredictorAdd7"),st("Predictor8","PredictorAdd8"),st("Predictor9","PredictorAdd9"),st("Predictor10","PredictorAdd10"),st("Predictor11","PredictorAdd11"),st("Predictor12","PredictorAdd12"),st("Predictor13","PredictorAdd13");var mo=V.PredictorAdd2;vt("ColorIndexInverseTransform","MapARGB","32b",function(v){return v>>8&255},function(v){return v}),vt("VP8LColorIndexInverseTransformAlpha","MapAlpha","8b",function(v){return v},function(v){return v>>8&255});var fd,Ma=V.ColorIndexInverseTransform,Ui=V.MapARGB,bl=V.VP8LColorIndexInverseTransformAlpha,ys=V.MapAlpha,nl=V.VP8LPredictorsAdd=[];nl.length=16,(V.VP8LPredictors=[]).length=16,(V.VP8LPredictorsAdd_C=[]).length=16,(V.VP8LPredictors_C=[]).length=16;var _l,Ro,pd,zl,rl,Tc,Hi,tc,Eu,Zc,ua,da,ts,Br,xi,Jr,wl,Nu,Ua,xf,go,_h,md,lp,Ao,il,Mu,gd,Sl=s(511),vf=s(2041),u0=s(225),Cu=s(767),cp=0,wh=vf,Ad=u0,sl=Cu,Lo=Sl,d0=0,Gd=1,yf=2,Sh=3,xd=4,bf=5,up=6,h0=7,vd=8,ko=9,b=10,F=[2,3,7],X=[3,3,11],he=[280,256,256,256,40],Me=[0,1,1,1,0],He=[17,18,0,1,2,3,4,5,16,6,7,8,9,10,11,12,13,14,15],Mt=[24,7,23,25,40,6,39,41,22,26,38,42,56,5,55,57,21,27,54,58,37,43,72,4,71,73,20,28,53,59,70,74,36,44,88,69,75,52,60,3,87,89,19,29,86,90,35,45,68,76,85,91,51,61,104,2,103,105,18,30,102,106,34,46,84,92,67,77,101,107,50,62,120,1,119,121,83,93,17,31,100,108,66,78,118,122,33,47,117,123,49,63,99,109,82,94,0,116,124,65,79,16,32,98,110,48,115,125,81,95,64,114,126,97,111,80,113,127,96,112],Jt=[2954,2956,2958,2962,2970,2986,3018,3082,3212,3468,3980,5004],rn=8,_n=[4,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,20,21,21,22,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,76,77,78,79,80,81,82,83,84,85,86,87,88,89,91,93,95,96,98,100,101,102,104,106,108,110,112,114,116,118,122,124,126,128,130,132,134,136,138,140,143,145,148,151,154,157],Xn=[4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,119,122,125,128,131,134,137,140,143,146,149,152,155,158,161,164,167,170,173,177,181,185,189,193,197,201,205,209,213,217,221,225,229,234,239,245,249,254,259,264,269,274,279,284],wr=null,zr=[[173,148,140,0],[176,155,140,135,0],[180,157,141,134,130,0],[254,254,243,230,196,177,153,140,133,130,129,0]],gi=[0,1,4,8,5,2,3,6,9,12,13,10,7,11,14,15],yn=[-0,1,-1,2,-2,3,4,6,-3,5,-4,-5,-6,7,-7,8,-8,-9],bs=[[[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]],[[253,136,254,255,228,219,128,128,128,128,128],[189,129,242,255,227,213,255,219,128,128,128],[106,126,227,252,214,209,255,255,128,128,128]],[[1,98,248,255,236,226,255,255,128,128,128],[181,133,238,254,221,234,255,154,128,128,128],[78,134,202,247,198,180,255,219,128,128,128]],[[1,185,249,255,243,255,128,128,128,128,128],[184,150,247,255,236,224,128,128,128,128,128],[77,110,216,255,236,230,128,128,128,128,128]],[[1,101,251,255,241,255,128,128,128,128,128],[170,139,241,252,236,209,255,255,128,128,128],[37,116,196,243,228,255,255,255,128,128,128]],[[1,204,254,255,245,255,128,128,128,128,128],[207,160,250,255,238,128,128,128,128,128,128],[102,103,231,255,211,171,128,128,128,128,128]],[[1,152,252,255,240,255,128,128,128,128,128],[177,135,243,255,234,225,128,128,128,128,128],[80,129,211,255,194,224,128,128,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[246,1,255,128,128,128,128,128,128,128,128],[255,128,128,128,128,128,128,128,128,128,128]]],[[[198,35,237,223,193,187,162,160,145,155,62],[131,45,198,221,172,176,220,157,252,221,1],[68,47,146,208,149,167,221,162,255,223,128]],[[1,149,241,255,221,224,255,255,128,128,128],[184,141,234,253,222,220,255,199,128,128,128],[81,99,181,242,176,190,249,202,255,255,128]],[[1,129,232,253,214,197,242,196,255,255,128],[99,121,210,250,201,198,255,202,128,128,128],[23,91,163,242,170,187,247,210,255,255,128]],[[1,200,246,255,234,255,128,128,128,128,128],[109,178,241,255,231,245,255,255,128,128,128],[44,130,201,253,205,192,255,255,128,128,128]],[[1,132,239,251,219,209,255,165,128,128,128],[94,136,225,251,218,190,255,255,128,128,128],[22,100,174,245,186,161,255,199,128,128,128]],[[1,182,249,255,232,235,128,128,128,128,128],[124,143,241,255,227,234,128,128,128,128,128],[35,77,181,251,193,211,255,205,128,128,128]],[[1,157,247,255,236,231,255,255,128,128,128],[121,141,235,255,225,227,255,255,128,128,128],[45,99,188,251,195,217,255,224,128,128,128]],[[1,1,251,255,213,255,128,128,128,128,128],[203,1,248,255,255,128,128,128,128,128,128],[137,1,177,255,224,255,128,128,128,128,128]]],[[[253,9,248,251,207,208,255,192,128,128,128],[175,13,224,243,193,185,249,198,255,255,128],[73,17,171,221,161,179,236,167,255,234,128]],[[1,95,247,253,212,183,255,255,128,128,128],[239,90,244,250,211,209,255,255,128,128,128],[155,77,195,248,188,195,255,255,128,128,128]],[[1,24,239,251,218,219,255,205,128,128,128],[201,51,219,255,196,186,128,128,128,128,128],[69,46,190,239,201,218,255,228,128,128,128]],[[1,191,251,255,255,128,128,128,128,128,128],[223,165,249,255,213,255,128,128,128,128,128],[141,124,248,255,255,128,128,128,128,128,128]],[[1,16,248,255,255,128,128,128,128,128,128],[190,36,230,255,236,255,128,128,128,128,128],[149,1,255,128,128,128,128,128,128,128,128]],[[1,226,255,128,128,128,128,128,128,128,128],[247,192,255,128,128,128,128,128,128,128,128],[240,128,255,128,128,128,128,128,128,128,128]],[[1,134,252,255,255,128,128,128,128,128,128],[213,62,250,255,255,128,128,128,128,128,128],[55,93,255,128,128,128,128,128,128,128,128]],[[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128],[128,128,128,128,128,128,128,128,128,128,128]]],[[[202,24,213,235,186,191,220,160,240,175,255],[126,38,182,232,169,184,228,174,255,187,128],[61,46,138,219,151,178,240,170,255,216,128]],[[1,112,230,250,199,191,247,159,255,255,128],[166,109,228,252,211,215,255,174,128,128,128],[39,77,162,232,172,180,245,178,255,255,128]],[[1,52,220,246,198,199,249,220,255,255,128],[124,74,191,243,183,193,250,221,255,255,128],[24,71,130,219,154,170,243,182,255,255,128]],[[1,182,225,249,219,240,255,224,128,128,128],[149,150,226,252,216,205,255,171,128,128,128],[28,108,170,242,183,194,254,223,255,255,128]],[[1,81,230,252,204,203,255,192,128,128,128],[123,102,209,247,188,196,255,233,128,128,128],[20,95,153,243,164,173,255,203,128,128,128]],[[1,222,248,255,216,213,128,128,128,128,128],[168,175,246,252,235,205,255,255,128,128,128],[47,116,215,255,211,212,255,255,128,128,128]],[[1,121,236,253,212,214,255,255,128,128,128],[141,84,213,252,201,202,255,219,128,128,128],[42,80,160,240,162,185,255,205,128,128,128]],[[1,1,255,128,128,128,128,128,128,128,128],[244,1,255,128,128,128,128,128,128,128,128],[238,1,255,128,128,128,128,128,128,128,128]]]],Vl=[[[231,120,48,89,115,113,120,152,112],[152,179,64,126,170,118,46,70,95],[175,69,143,80,85,82,72,155,103],[56,58,10,171,218,189,17,13,152],[114,26,17,163,44,195,21,10,173],[121,24,80,195,26,62,44,64,85],[144,71,10,38,171,213,144,34,26],[170,46,55,19,136,160,33,206,71],[63,20,8,114,114,208,12,9,226],[81,40,11,96,182,84,29,16,36]],[[134,183,89,137,98,101,106,165,148],[72,187,100,130,157,111,32,75,80],[66,102,167,99,74,62,40,234,128],[41,53,9,178,241,141,26,8,107],[74,43,26,146,73,166,49,23,157],[65,38,105,160,51,52,31,115,128],[104,79,12,27,217,255,87,17,7],[87,68,71,44,114,51,15,186,23],[47,41,14,110,182,183,21,17,194],[66,45,25,102,197,189,23,18,22]],[[88,88,147,150,42,46,45,196,205],[43,97,183,117,85,38,35,179,61],[39,53,200,87,26,21,43,232,171],[56,34,51,104,114,102,29,93,77],[39,28,85,171,58,165,90,98,64],[34,22,116,206,23,34,43,166,73],[107,54,32,26,51,1,81,43,31],[68,25,106,22,64,171,36,225,114],[34,19,21,102,132,188,16,76,124],[62,18,78,95,85,57,50,48,51]],[[193,101,35,159,215,111,89,46,111],[60,148,31,172,219,228,21,18,111],[112,113,77,85,179,255,38,120,114],[40,42,1,196,245,209,10,25,109],[88,43,29,140,166,213,37,43,154],[61,63,30,155,67,45,68,1,209],[100,80,8,43,154,1,51,26,71],[142,78,78,16,255,128,34,197,171],[41,40,5,102,211,183,4,1,221],[51,50,17,168,209,192,23,25,82]],[[138,31,36,171,27,166,38,44,229],[67,87,58,169,82,115,26,59,179],[63,59,90,180,59,166,93,73,154],[40,40,21,116,143,209,34,39,175],[47,15,16,183,34,223,49,45,183],[46,17,33,183,6,98,15,32,183],[57,46,22,24,128,1,54,17,37],[65,32,73,115,28,128,23,128,205],[40,3,9,115,51,192,18,6,223],[87,37,9,115,59,77,64,21,47]],[[104,55,44,218,9,54,53,130,226],[64,90,70,205,40,41,23,26,57],[54,57,112,184,5,41,38,166,213],[30,34,26,133,152,116,10,32,134],[39,19,53,221,26,114,32,73,255],[31,9,65,234,2,15,1,118,73],[75,32,12,51,192,255,160,43,51],[88,31,35,67,102,85,55,186,85],[56,21,23,111,59,205,45,37,192],[55,38,70,124,73,102,1,34,98]],[[125,98,42,88,104,85,117,175,82],[95,84,53,89,128,100,113,101,45],[75,79,123,47,51,128,81,171,1],[57,17,5,71,102,57,53,41,49],[38,33,13,121,57,73,26,1,85],[41,10,67,138,77,110,90,47,114],[115,21,2,10,102,255,166,23,6],[101,29,16,10,85,128,101,196,26],[57,18,10,102,102,213,34,20,43],[117,20,15,36,163,128,68,1,26]],[[102,61,71,37,34,53,31,243,192],[69,60,71,38,73,119,28,222,37],[68,45,128,34,1,47,11,245,171],[62,17,19,70,146,85,55,62,70],[37,43,37,154,100,163,85,160,1],[63,9,92,136,28,64,32,201,85],[75,15,9,9,64,255,184,119,16],[86,6,28,5,64,255,25,248,1],[56,8,17,132,137,255,55,116,128],[58,15,20,82,135,57,26,121,40]],[[164,50,31,137,154,133,25,35,218],[51,103,44,131,131,123,31,6,158],[86,40,64,135,148,224,45,183,128],[22,26,17,131,240,154,14,1,209],[45,16,21,91,64,222,7,1,197],[56,21,39,155,60,138,23,102,213],[83,12,13,54,192,255,68,47,28],[85,26,85,85,128,128,32,146,171],[18,11,7,63,144,171,4,4,246],[35,27,10,146,174,171,12,26,128]],[[190,80,35,99,180,80,126,54,45],[85,126,47,87,176,51,41,20,32],[101,75,128,139,118,146,116,128,85],[56,41,15,176,236,85,37,9,62],[71,30,17,119,118,255,17,18,138],[101,38,60,138,55,70,43,26,142],[146,36,19,30,171,255,97,27,20],[138,45,61,62,219,1,81,188,64],[32,41,20,117,151,142,20,21,163],[112,19,12,61,195,128,48,4,24]]],Th=[[[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[176,246,255,255,255,255,255,255,255,255,255],[223,241,252,255,255,255,255,255,255,255,255],[249,253,253,255,255,255,255,255,255,255,255]],[[255,244,252,255,255,255,255,255,255,255,255],[234,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255]],[[255,246,254,255,255,255,255,255,255,255,255],[239,253,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[251,255,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[251,254,254,255,255,255,255,255,255,255,255],[254,255,254,255,255,255,255,255,255,255,255]],[[255,254,253,255,254,255,255,255,255,255,255],[250,255,254,255,254,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[217,255,255,255,255,255,255,255,255,255,255],[225,252,241,253,255,255,254,255,255,255,255],[234,250,241,250,253,255,253,254,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[223,254,254,255,255,255,255,255,255,255,255],[238,253,254,254,255,255,255,255,255,255,255]],[[255,248,254,255,255,255,255,255,255,255,255],[249,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,255,255,255,255,255,255,255,255,255],[247,254,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[252,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[253,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[186,251,250,255,255,255,255,255,255,255,255],[234,251,244,254,255,255,255,255,255,255,255],[251,251,243,253,254,255,254,255,255,255,255]],[[255,253,254,255,255,255,255,255,255,255,255],[236,253,254,255,255,255,255,255,255,255,255],[251,253,253,254,254,255,255,255,255,255,255]],[[255,254,254,255,255,255,255,255,255,255,255],[254,254,254,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,254,255,255,255,255,255,255,255,255,255],[254,254,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]],[[[248,255,255,255,255,255,255,255,255,255,255],[250,254,252,254,255,255,255,255,255,255,255],[248,254,249,253,255,255,255,255,255,255,255]],[[255,253,253,255,255,255,255,255,255,255,255],[246,253,253,255,255,255,255,255,255,255,255],[252,254,251,254,254,255,255,255,255,255,255]],[[255,254,252,255,255,255,255,255,255,255,255],[248,254,253,255,255,255,255,255,255,255,255],[253,255,254,254,255,255,255,255,255,255,255]],[[255,251,254,255,255,255,255,255,255,255,255],[245,251,254,255,255,255,255,255,255,255,255],[253,253,254,255,255,255,255,255,255,255,255]],[[255,251,253,255,255,255,255,255,255,255,255],[252,253,254,255,255,255,255,255,255,255,255],[255,254,255,255,255,255,255,255,255,255,255]],[[255,252,255,255,255,255,255,255,255,255,255],[249,255,254,255,255,255,255,255,255,255,255],[255,255,254,255,255,255,255,255,255,255,255]],[[255,255,253,255,255,255,255,255,255,255,255],[250,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]],[[255,255,255,255,255,255,255,255,255,255,255],[254,255,255,255,255,255,255,255,255,255,255],[255,255,255,255,255,255,255,255,255,255,255]]]],Pm=[0,1,2,3,6,4,5,6,6,6,6,6,6,6,6,7,0],Pn=[],ds=[],Ec=[],Nc=1,Qc=2,ns=[],si=[];Xs("UpsampleRgbLinePair",vl,3),Xs("UpsampleBgrLinePair",Jo,3),Xs("UpsampleRgbaLinePair",Co,4),Xs("UpsampleBgraLinePair",yl,4),Xs("UpsampleArgbLinePair",Xc,4),Xs("UpsampleRgba4444LinePair",Li,2),Xs("UpsampleRgb565LinePair",Bl,2);var Kc=V.UpsampleRgbLinePair,Mc=V.UpsampleBgrLinePair,dp=V.UpsampleRgbaLinePair,pn=V.UpsampleBgraLinePair,xn=V.UpsampleArgbLinePair,hp=V.UpsampleRgba4444LinePair,fy=V.UpsampleRgb565LinePair,Io=16,eo=1<q.ca.S||(alert("todo:WebPInitConvertARGBToYUV"),q.ca.f.kb.F!=null&&Bi()),q.Pb&&0(xe=j.Md)?0:100Ee;++Ee)12>(we=Z.pb[Ee]).lc&&(we.ia=xe*E[0>we.lc?0:we.lc]>>3),Ue|=we.ia;Ue&&(alert("todo:VP8InitRandom"),Z.ia=1)}Z.Ga=j.Id,100Z.Ga&&(Z.Ga=0)}(function(ke,je){if(ke==null)return 0;if(je==null)return Wn(ke,2,"NULL VP8Io parameter in VP8Decode().");if(!ke.cb&&!Un(ke,je))return 0;if(e(ke.cb),je.ac==null||je.ac(je)){je.ob&&(ke.L=0);var Je=N[ke.L];if(ke.L==2?(ke.yb=0,ke.zb=0):(ke.yb=je.v-Je>>4,ke.zb=je.j-Je>>4,0>ke.yb&&(ke.yb=0),0>ke.zb&&(ke.zb=0)),ke.Va=je.o+15+Je>>4,ke.Hb=je.va+15+Je>>4,ke.Hb>ke.za&&(ke.Hb=ke.za),ke.Va>ke.Ub&&(ke.Va=ke.Ub),0Je;++Je){var Ye;if(ke.Qa.Cb){var Ke=ke.Qa.Lb[Je];ke.Qa.Fb||(Ke+=xt.Tb)}else Ke=xt.Tb;for(Ye=0;1>=Ye;++Ye){var kt=ke.gd[Je][Ye],Rt=Ke;if(xt.Pc&&(Rt+=xt.vd[0],Ye&&(Rt+=xt.od[0])),0<(Rt=0>Rt?0:63>2:Wt>>1)>9-xt.wb&&(Wt=9-xt.wb),1>Wt&&(Wt=1),kt.dd=Wt,kt.tc=2*Rt+Wt,kt.ld=40<=Rt?2:15<=Rt?1:0}else kt.tc=0;kt.La=Ye}}}Je=0}else Wn(ke,6,"Frame setup failed"),Je=ke.a;if(Je=Je==0){if(Je){ke.$c=0,0ke.Vb){if(ke.Vb=0,ke.Ec=s(kt),ke.Fc=0,ke.Ec==null){Je=Wn(ke,1,"no memory during frame initialization.");break t}ke.Vb=kt}kt=ke.Ec,Rt=ke.Fc,ke.Ac=kt,ke.Bc=Rt,Rt+=xt,ke.Gd=a(Kt,vn),ke.Hd=0,ke.rb=a(tn+1,wt),ke.sb=1,ke.wa=Zn?a(Zn,Ge):null,ke.Y=0,ke.D.Nb=0,ke.D.wa=ke.wa,ke.D.Y=ke.Y,0=Je;++Je)Sl[255+Je]=0>Je?-Je:Je;for(Je=-1020;1020>=Je;++Je)vf[1020+Je]=-128>Je?-128:127=Je;++Je)u0[112+Je]=-16>Je?-16:15=Je;++Je)Cu[255+Je]=0>Je?0:255Er;++Er){var Bs,$i=rs[0+Er];for(Bs=0;4>Bs;++Bs){$i=Vl[_i[zi+Bs]][$i];for(var gs=yn[Xe(xr,$i[0])];0>3;for(gs=0;256>gs;gs+=16)Er[Vi+gs]=Pu}Tl=1,$d=zi[0]}var Us=15&xr.la,Do=15&Wr.la;for(gs=0;4>gs;++gs){var As=1&Do;for(Pu=Cs=0;4>Pu;++Pu)Us=Us>>1|(As=(to=wr(_i,$d,to=As+(1&Us),Di.Sc,Tl,Er,Vi))>Tl)<<7,Cs=Cs<<2|(3>=4,Do=Do>>1|As<<7,Bs=(Bs<<8|Cs)>>>0}for($d=Us,Tl=Do>>4,za=0;4>za;za+=2){for(Cs=0,Us=xr.la>>4+za,Do=Wr.la>>4+za,gs=0;2>gs;++gs){for(As=1&Do,Pu=0;2>Pu;++Pu)to=As+(1&Us),Us=Us>>1|(As=0<(to=wr(_i,zi[2],to,Di.Qc,0,Er,Vi)))<<3,Cs=Cs<<2|(3>=2,Do=Do>>1|As<<5}$i|=Cs<<4*za,$d|=Us<<4<=Qn.zb&&Qn.M<=Qn.Va,Qn.Aa==0)t:{if(Kn.M=Qn.M,Kn.uc=xr,wc(Qn,Kn),pi=1,Kn=(Cs=Qn.D).Nb,xr=($i=N[Qn.L])*Qn.R,_i=$i/2*Qn.B,gs=16*Kn*Qn.R,Pu=8*Kn*Qn.B,zi=Qn.sa,rs=Qn.ta-xr+gs,Di=Qn.qa,Er=Qn.ra-_i+Pu,Vi=Qn.Ha,Wr=Qn.Ia-_i+Pu,Do=(Us=Cs.M)==0,Bs=Us>=Qn.Va-1,Qn.Aa==2&&wc(Qn,Cs),Cs.uc)for(As=(to=Qn).D.M,e(to.D.uc),Cs=to.yb;Cskn.o&&(Us=kn.o),kn.F=null,kn.J=null,Qn.Fa!=null&&0>1),kn.W+=Qn.B*($i>>1),kn.F!=null&&(kn.J+=kn.width*$i)),Cs>1,kn.W+=kn.v>>1,kn.F!=null&&(kn.J+=kn.v),kn.ka=Cs-kn.j,kn.U=kn.va-kn.v,kn.T=Us-Cs,pi=kn.put(kn))}Kn+1!=Qn.Ic||Bs||(r(Qn.sa,Qn.ta-xr,zi,rs+16*Qn.R,xr),r(Qn.qa,Qn.ra-_i,Di,Er+8*Qn.B,_i),r(Qn.Ha,Qn.Ia-_i,Vi,Wr+8*Qn.B,_i))}if(!pi)return Wn(Rr,6,"Output aborted.")}return 1}(ke,je)),je.bc!=null&&je.bc(je),Je&=1}return Je?(ke.cb=0,Je):0})(v,q)||(T=v.a)}}else T=v.a}T==0&&ne.Oa!=null&&ne.Oa.fd&&(T=Po(ne.ba))}ne=T}te=ne!=0?null:11>te?le.f.RGBA.eb:le.f.kb.y}else te=null;return te};var D=[3,4,3,4,4,2,2,4,4,4,2,1,1]};function c(V,$){for(var G="",H=0;H<4;H++)G+=String.fromCharCode(V[$++]);return G}function u(V,$){return V[$+0]|V[$+1]<<8}function d(V,$){return(V[$+0]|V[$+1]<<8|V[$+2]<<16)>>>0}function h(V,$){return(V[$+0]|V[$+1]<<8|V[$+2]<<16|V[$+3]<<24)>>>0}new l;var p=[0],g=[0],x=[],_=new l,y=n,M=function(V,$){var G={},H=0,K=!1,W=0,J=0;if(G.frames=[],!function(ee,me){for(var Ae=0;Ae<4;Ae++)if(ee[me+Ae]!="RIFF".charCodeAt(Ae))return!0;return!1}(V,$)){for(h(V,$+=4),$+=8;$>1&1}ie!="ANMF"&&($+=Q)}return G}}(y,0);M.response=y,M.rgbaoutput=!0,M.dataurl=!1;var C=M.header?M.header:null,k=M.frames?M.frames:null;if(C){C.loop_counter=C.loop_count,p=[C.canvas_height],g=[C.canvas_width];for(var B=0;B'+t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")+"",this.internal.__metadata__.metadataObjectNumber=this.internal.newObject(),this.internal.write("<< /Type /Metadata /Subtype /XML /Length "+n.length+" >>"),this.internal.write("stream"),this.internal.write(n),this.internal.write("endstream"),this.internal.write("endobj")}function UGe(){this.internal.__metadata__.metadataObjectNumber&&this.internal.write("/Metadata "+this.internal.__metadata__.metadataObjectNumber+" 0 R")}(function(n){var e,t,r,i,s,a,o,l,c,u=function(ee){return ee=ee||{},this.isStrokeTransparent=ee.isStrokeTransparent||!1,this.strokeOpacity=ee.strokeOpacity||1,this.strokeStyle=ee.strokeStyle||"#000000",this.fillStyle=ee.fillStyle||"#000000",this.isFillTransparent=ee.isFillTransparent||!1,this.fillOpacity=ee.fillOpacity||1,this.font=ee.font||"10px sans-serif",this.textBaseline=ee.textBaseline||"alphabetic",this.textAlign=ee.textAlign||"left",this.lineWidth=ee.lineWidth||1,this.lineJoin=ee.lineJoin||"miter",this.lineCap=ee.lineCap||"butt",this.path=ee.path||[],this.transform=ee.transform!==void 0?ee.transform.clone():new l,this.globalCompositeOperation=ee.globalCompositeOperation||"normal",this.globalAlpha=ee.globalAlpha||1,this.clip_path=ee.clip_path||[],this.currentPoint=ee.currentPoint||new a,this.miterLimit=ee.miterLimit||10,this.lastPoint=ee.lastPoint||new a,this.lineDashOffset=ee.lineDashOffset||0,this.lineDash=ee.lineDash||[],this.margin=ee.margin||[0,0,0,0],this.prevPageLastElemOffset=ee.prevPageLastElemOffset||0,this.ignoreClearRect=typeof ee.ignoreClearRect!="boolean"||ee.ignoreClearRect,this};n.events.push(["initialized",function(){this.context2d=new d(this),e=this.internal.f2,t=this.internal.getCoordinateString,r=this.internal.getVerticalCoordinateString,i=this.internal.getHorizontalCoordinate,s=this.internal.getVerticalCoordinate,a=this.internal.Point,o=this.internal.Rectangle,l=this.internal.Matrix,c=new u}]);var d=function(ee){Object.defineProperty(this,"canvas",{get:function(){return{parentNode:!1,style:!1}}});var me=ee;Object.defineProperty(this,"pdf",{get:function(){return me}});var Ae=!1;Object.defineProperty(this,"pageWrapXEnabled",{get:function(){return Ae},set:function(Ce){Ae=!!Ce}});var be=!1;Object.defineProperty(this,"pageWrapYEnabled",{get:function(){return be},set:function(Ce){be=!!Ce}});var pe=0;Object.defineProperty(this,"posX",{get:function(){return pe},set:function(Ce){isNaN(Ce)||(pe=Ce)}});var ge=0;Object.defineProperty(this,"posY",{get:function(){return ge},set:function(Ce){isNaN(Ce)||(ge=Ce)}}),Object.defineProperty(this,"margin",{get:function(){return c.margin},set:function(Ce){var lt;typeof Ce=="number"?lt=[Ce,Ce,Ce,Ce]:((lt=new Array(4))[0]=Ce[0],lt[1]=Ce.length>=2?Ce[1]:lt[0],lt[2]=Ce.length>=3?Ce[2]:lt[0],lt[3]=Ce.length>=4?Ce[3]:lt[1]),c.margin=lt}});var Te=!1;Object.defineProperty(this,"autoPaging",{get:function(){return Te},set:function(Ce){Te=Ce}});var ze=0;Object.defineProperty(this,"lastBreak",{get:function(){return ze},set:function(Ce){ze=Ce}});var Xe=[];Object.defineProperty(this,"pageBreaks",{get:function(){return Xe},set:function(Ce){Xe=Ce}}),Object.defineProperty(this,"ctx",{get:function(){return c},set:function(Ce){Ce instanceof u&&(c=Ce)}}),Object.defineProperty(this,"path",{get:function(){return c.path},set:function(Ce){c.path=Ce}});var Qe=[];Object.defineProperty(this,"ctxStack",{get:function(){return Qe},set:function(Ce){Qe=Ce}}),Object.defineProperty(this,"fillStyle",{get:function(){return this.ctx.fillStyle},set:function(Ce){var lt;lt=h(Ce),this.ctx.fillStyle=lt.style,this.ctx.isFillTransparent=lt.a===0,this.ctx.fillOpacity=lt.a,this.pdf.setFillColor(lt.r,lt.g,lt.b,{a:lt.a}),this.pdf.setTextColor(lt.r,lt.g,lt.b,{a:lt.a})}}),Object.defineProperty(this,"strokeStyle",{get:function(){return this.ctx.strokeStyle},set:function(Ce){var lt=h(Ce);this.ctx.strokeStyle=lt.style,this.ctx.isStrokeTransparent=lt.a===0,this.ctx.strokeOpacity=lt.a,lt.a===0?this.pdf.setDrawColor(255,255,255):(lt.a,this.pdf.setDrawColor(lt.r,lt.g,lt.b))}}),Object.defineProperty(this,"lineCap",{get:function(){return this.ctx.lineCap},set:function(Ce){["butt","round","square"].indexOf(Ce)!==-1&&(this.ctx.lineCap=Ce,this.pdf.setLineCap(Ce))}}),Object.defineProperty(this,"lineWidth",{get:function(){return this.ctx.lineWidth},set:function(Ce){isNaN(Ce)||(this.ctx.lineWidth=Ce,this.pdf.setLineWidth(Ce))}}),Object.defineProperty(this,"lineJoin",{get:function(){return this.ctx.lineJoin},set:function(Ce){["bevel","round","miter"].indexOf(Ce)!==-1&&(this.ctx.lineJoin=Ce,this.pdf.setLineJoin(Ce))}}),Object.defineProperty(this,"miterLimit",{get:function(){return this.ctx.miterLimit},set:function(Ce){isNaN(Ce)||(this.ctx.miterLimit=Ce,this.pdf.setMiterLimit(Ce))}}),Object.defineProperty(this,"textBaseline",{get:function(){return this.ctx.textBaseline},set:function(Ce){this.ctx.textBaseline=Ce}}),Object.defineProperty(this,"textAlign",{get:function(){return this.ctx.textAlign},set:function(Ce){["right","end","center","left","start"].indexOf(Ce)!==-1&&(this.ctx.textAlign=Ce)}});var ot=null,bt=null,ht=null;Object.defineProperty(this,"fontFaces",{get:function(){return ht},set:function(Ce){ot=null,bt=null,ht=Ce}}),Object.defineProperty(this,"font",{get:function(){return this.ctx.font},set:function(Ce){var lt;if(this.ctx.font=Ce,(lt=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z0-9]+?)\s*$/i.exec(Ce))!==null){var ft=lt[1];lt[2];var et=lt[3],At=lt[4];lt[5];var Lt=lt[6],st=/^([.\d]+)((?:%|in|[cem]m|ex|p[ctx]))$/i.exec(At)[2];At=Math.floor(st==="px"?parseFloat(At)*this.pdf.internal.scaleFactor:st==="em"?parseFloat(At)*this.pdf.getFontSize():parseFloat(At)*this.pdf.internal.scaleFactor),this.pdf.setFontSize(At);var Ht=function(vt){var Ut,dt,mt=[],Ft=vt.trim();if(Ft==="")return Sj;if(Ft in Mse)return[Mse[Ft]];for(;Ft!=="";){switch(dt=null,Ut=(Ft=Pse(Ft)).charAt(0)){case'"':case"'":dt=kGe(Ft.substring(1),Ut);break;default:dt=IGe(Ft)}if(dt===null||(mt.push(dt[0]),(Ft=Pse(dt[1]))!==""&&Ft.charAt(0)!==","))return Sj;Ft=Ft.replace(/^,/,"")}return mt}(Lt);if(this.fontFaces){var Se=function(vt,Ut){var dt=vt.getFontList(),mt=JSON.stringify(dt);if(ot===null||bt!==mt){var Ft=function(tt){var Pe=[];return Object.keys(tt).forEach(function(nt){tt[nt].forEach(function(qe){var yt=null;switch(qe){case"bold":yt={family:nt,weight:"bold"};break;case"italic":yt={family:nt,style:"italic"};break;case"bolditalic":yt={family:nt,weight:"bold",style:"italic"};break;case"":case"normal":yt={family:nt}}yt!==null&&(yt.ref={name:nt,style:qe},Pe.push(yt))})}),Pe}(dt);ot=function(tt){for(var Pe={},nt=0;nt=700||ft==="bold")&&(De="bold"),ft==="italic"&&(De+="italic"),De.length===0&&(De="normal");for(var ue="",Ve={arial:"Helvetica",Arial:"Helvetica",verdana:"Helvetica",Verdana:"Helvetica",helvetica:"Helvetica",Helvetica:"Helvetica","sans-serif":"Helvetica",fixed:"Courier",monospace:"Courier",terminal:"Courier",cursive:"Times",fantasy:"Times",serif:"Times"},We=0;We=2*Math.PI&&(be=0,pe=2*Math.PI),this.path.push({type:"arc",x:ee,y:me,radius:Ae,startAngle:be,endAngle:pe,counterclockwise:ge})},d.prototype.arcTo=function(ee,me,Ae,be,pe){throw new Error("arcTo not implemented.")},d.prototype.rect=function(ee,me,Ae,be){if(isNaN(ee)||isNaN(me)||isNaN(Ae)||isNaN(be))throw Ra.error("jsPDF.context2d.rect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.rect");this.moveTo(ee,me),this.lineTo(ee+Ae,me),this.lineTo(ee+Ae,me+be),this.lineTo(ee,me+be),this.lineTo(ee,me),this.lineTo(ee+Ae,me),this.lineTo(ee,me)},d.prototype.fillRect=function(ee,me,Ae,be){if(isNaN(ee)||isNaN(me)||isNaN(Ae)||isNaN(be))throw Ra.error("jsPDF.context2d.fillRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.fillRect");if(!p.call(this)){var pe={};this.lineCap!=="butt"&&(pe.lineCap=this.lineCap,this.lineCap="butt"),this.lineJoin!=="miter"&&(pe.lineJoin=this.lineJoin,this.lineJoin="miter"),this.beginPath(),this.rect(ee,me,Ae,be),this.fill(),pe.hasOwnProperty("lineCap")&&(this.lineCap=pe.lineCap),pe.hasOwnProperty("lineJoin")&&(this.lineJoin=pe.lineJoin)}},d.prototype.strokeRect=function(ee,me,Ae,be){if(isNaN(ee)||isNaN(me)||isNaN(Ae)||isNaN(be))throw Ra.error("jsPDF.context2d.strokeRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.strokeRect");g.call(this)||(this.beginPath(),this.rect(ee,me,Ae,be),this.stroke())},d.prototype.clearRect=function(ee,me,Ae,be){if(isNaN(ee)||isNaN(me)||isNaN(Ae)||isNaN(be))throw Ra.error("jsPDF.context2d.clearRect: Invalid arguments",arguments),new Error("Invalid arguments passed to jsPDF.context2d.clearRect");this.ignoreClearRect||(this.fillStyle="#ffffff",this.fillRect(ee,me,Ae,be))},d.prototype.save=function(ee){ee=typeof ee!="boolean"||ee;for(var me=this.pdf.internal.getCurrentPageInfo().pageNumber,Ae=0;Ae0||this.margin[1]>0||this.margin[2]>0||this.margin[3]>0};d.prototype.drawImage=function(ee,me,Ae,be,pe,ge,Te,ze,Xe){var Qe=this.pdf.getImageProperties(ee),ot=1,bt=1,ht=1,Ce=1;be!==void 0&&ze!==void 0&&(ht=ze/be,Ce=Xe/pe,ot=Qe.width/be*ze/be,bt=Qe.height/pe*Xe/pe),ge===void 0&&(ge=me,Te=Ae,me=0,Ae=0),be!==void 0&&ze===void 0&&(ze=be,Xe=pe),be===void 0&&ze===void 0&&(ze=Qe.width,Xe=Qe.height);var lt=this.ctx.transform.decompose(),ft=Q(lt.rotate.shx),et=new l,At=(et=(et=(et=et.multiply(lt.translate)).multiply(lt.skew)).multiply(lt.scale)).applyToRectangle(new o(ge-me*ht,Te-Ae*Ce,be*ot,pe*bt));if(this.autoPaging){for(var Lt,st=_.call(this,At),Ht=[],Se=0;Se_t||DeAt||st0)){for(;Xe>=0;Xe--)if(pe[Xe-1].close!==!0&&pe[Xe-1].begin!==!0){pe[Xe-1].deltas.push(Ae),pe[Xe-1].abs.push(ze);break}}break;case"bct":Ae=[ze.x1-ge[Te-1].x,ze.y1-ge[Te-1].y,ze.x2-ge[Te-1].x,ze.y2-ge[Te-1].y,ze.x-ge[Te-1].x,ze.y-ge[Te-1].y],pe[pe.length-1].deltas.push(Ae);break;case"qct":var Qe=ge[Te-1].x+2/3*(ze.x1-ge[Te-1].x),ot=ge[Te-1].y+2/3*(ze.y1-ge[Te-1].y),bt=ze.x+2/3*(ze.x1-ze.x),ht=ze.y+2/3*(ze.y1-ze.y),Ce=ze.x,lt=ze.y;Ae=[Qe-ge[Te-1].x,ot-ge[Te-1].y,bt-ge[Te-1].x,ht-ge[Te-1].y,Ce-ge[Te-1].x,lt-ge[Te-1].y],pe[pe.length-1].deltas.push(Ae);break;case"arc":pe.push({deltas:[],abs:[],arc:!0}),Array.isArray(pe[pe.length-1].abs)&&pe[pe.length-1].abs.push(ze)}}be=me?null:ee==="stroke"?"stroke":"fill";for(var ft=!1,et=0;et=.01&&(be=this.pdf.internal.getFontSize(),this.pdf.setFontSize(be*ee.scale),pe=this.lineWidth,this.lineWidth=pe*ee.scale);var ct=this.autoPaging!=="text";if(ct||We.y+We.h<=Se){if(ct||We.y>=st&&We.x<=It){var vt=ct?ee.text:this.pdf.splitTextToSize(ee.text,ee.maxWidth||It-We.x)[0],Ut=M([JSON.parse(JSON.stringify(bt))],this.posX+this.margin[3],-ue+st+this.ctx.prevPageLastElemOffset)[0],dt=ct&&(Lt>et||Lt=.01&&(this.pdf.setFontSize(be),this.lineWidth=pe)}}else ee.scale>=.01&&(be=this.pdf.internal.getFontSize(),this.pdf.setFontSize(be*ee.scale),pe=this.lineWidth,this.lineWidth=pe*ee.scale),this.pdf.text(ee.text,Xe.x+this.posX,Xe.y+this.posY,{angle:ee.angle,align:me,renderingMode:ee.renderingMode,maxWidth:ee.maxWidth}),ee.scale>=.01&&(this.pdf.setFontSize(be),this.lineWidth=pe)},K=function(ee,me,Ae,be){Ae=Ae||0,be=be||0,this.pdf.internal.out(t(ee+Ae)+" "+r(me+be)+" l")},W=function(ee,me,Ae){return this.pdf.lines(ee,me,Ae,null,null)},J=function(ee,me,Ae,be,pe,ge,Te,ze){this.pdf.internal.out([e(i(Ae+ee)),e(s(be+me)),e(i(pe+ee)),e(s(ge+me)),e(i(Te+ee)),e(s(ze+me)),"c"].join(" "))},ie=function(ee,me,Ae,be){for(var pe=2*Math.PI,ge=Math.PI/2;me>Ae;)me-=pe;var Te=Math.abs(Ae-me);Te1e-5;){var ot=Qe+Xe*Math.min(Te,ge);ze.push(ae.call(this,ee,Qe,ot)),Te-=Math.abs(ot-Qe),Qe=ot}return ze},ae=function(ee,me,Ae){var be=(Ae-me)/2,pe=ee*Math.cos(be),ge=ee*Math.sin(be),Te=pe,ze=-ge,Xe=Te*Te+ze*ze,Qe=Xe+Te*pe+ze*ge,ot=4/3*(Math.sqrt(2*Xe*Qe)-Qe)/(Te*ge-ze*pe),bt=Te-ot*ze,ht=ze+ot*Te,Ce=bt,lt=-ht,ft=be+me,et=Math.cos(ft),At=Math.sin(ft);return{x1:ee*Math.cos(me),y1:ee*Math.sin(me),x2:bt*et-ht*At,y2:bt*At+ht*et,x3:Ce*et-lt*At,y3:Ce*At+lt*et,x4:ee*Math.cos(Ae),y4:ee*Math.sin(Ae)}},Q=function(ee){return 180*ee/Math.PI},re=function(ee,me,Ae,be,pe,ge){var Te=ee+.5*(Ae-ee),ze=me+.5*(be-me),Xe=pe+.5*(Ae-pe),Qe=ge+.5*(be-ge),ot=Math.min(ee,pe,Te,Xe),bt=Math.max(ee,pe,Te,Xe),ht=Math.min(me,ge,ze,Qe),Ce=Math.max(me,ge,ze,Qe);return new o(ot,ht,bt-ot,Ce-ht)},oe=function(ee,me,Ae,be,pe,ge,Te,ze){var Xe,Qe,ot,bt,ht,Ce,lt,ft,et,At,Lt,st,Ht,Se,_t=Ae-ee,It=be-me,De=pe-Ae,ue=ge-be,Ve=Te-pe,We=ze-ge;for(Qe=0;Qe<41;Qe++)et=(lt=(ot=ee+(Xe=Qe/40)*_t)+Xe*((ht=Ae+Xe*De)-ot))+Xe*(ht+Xe*(pe+Xe*Ve-ht)-lt),At=(ft=(bt=me+Xe*It)+Xe*((Ce=be+Xe*ue)-bt))+Xe*(Ce+Xe*(ge+Xe*We-Ce)-ft),Qe==0?(Lt=et,st=At,Ht=et,Se=At):(Lt=Math.min(Lt,et),st=Math.min(st,At),Ht=Math.max(Ht,et),Se=Math.max(Se,At));return new o(Math.round(Lt),Math.round(st),Math.round(Ht-Lt),Math.round(Se-st))},fe=function(){if(this.prevLineDash||this.ctx.lineDash.length||this.ctx.lineDashOffset){var ee,me,Ae=(ee=this.ctx.lineDash,me=this.ctx.lineDashOffset,JSON.stringify({lineDash:ee,lineDashOffset:me}));this.prevLineDash!==Ae&&(this.pdf.setLineDash(this.ctx.lineDash,this.ctx.lineDashOffset),this.prevLineDash=Ae)}}})(Cr.API),function(n){var e=function(a){var o,l,c,u,d,h,p,g,x,_;for(l=[],c=0,u=(a+=o="\0\0\0\0".slice(a.length%4||4)).length;u>c;c+=4)(d=(a.charCodeAt(c)<<24)+(a.charCodeAt(c+1)<<16)+(a.charCodeAt(c+2)<<8)+a.charCodeAt(c+3))!==0?(h=(d=((d=((d=((d=(d-(_=d%85))/85)-(x=d%85))/85)-(g=d%85))/85)-(p=d%85))/85)%85,l.push(h+33,p+33,g+33,x+33,_+33)):l.push(122);return function(y,M){for(var C=M;C>0;C--)y.pop()}(l,o.length),String.fromCharCode.apply(String,l)+"~>"},t=function(a){var o,l,c,u,d,h=String,p="length",g=255,x="charCodeAt",_="slice",y="replace";for(a[_](-2),a=a[_](0,-2)[y](/\s/g,"")[y]("z","!!!!!"),c=[],u=0,d=(a+=o="uuuuu"[_](a[p]%5||5))[p];d>u;u+=5)l=52200625*(a[x](u)-33)+614125*(a[x](u+1)-33)+7225*(a[x](u+2)-33)+85*(a[x](u+3)-33)+(a[x](u+4)-33),c.push(g&l>>24,g&l>>16,g&l>>8,g&l);return function(M,C){for(var k=C;k>0;k--)M.pop()}(c,o[p]),h.fromCharCode.apply(h,c)},r=function(a){return a.split("").map(function(o){return("0"+o.charCodeAt().toString(16)).slice(-2)}).join("")+">"},i=function(a){var o=new RegExp(/^([0-9A-Fa-f]{2})+$/);if((a=a.replace(/\s/g,"")).indexOf(">")!==-1&&(a=a.substr(0,a.indexOf(">"))),a.length%2&&(a+="0"),o.test(a)===!1)return"";for(var l="",c=0;cimport("./html2canvas.esm-CBrSDip1.js"),[],import.meta.url)).catch(function(o){return Promise.reject(new Error("Could not load html2canvas: "+o))}).then(function(o){return o.default?o.default:o})}function t(){return(hi.DOMPurify?Promise.resolve(hi.DOMPurify):sj(()=>import("./purify.es-BaNf_EpD.js"),[],import.meta.url)).catch(function(o){return Promise.reject(new Error("Could not load dompurify: "+o))}).then(function(o){return o.default?o.default:o})}var r=function(o){var l=pa(o);return l==="undefined"?"undefined":l==="string"||o instanceof String?"string":l==="number"||o instanceof Number?"number":l==="function"||o instanceof Function?"function":o&&o.constructor===Array?"array":o&&o.nodeType===1?"element":l==="object"?"object":"unknown"},i=function(o,l){var c=document.createElement(o);for(var u in l.className&&(c.className=l.className),l.innerHTML&&l.dompurify&&(c.innerHTML=l.dompurify.sanitize(l.innerHTML)),l.style)c.style[u]=l.style[u];return c},s=function o(l,c){for(var u=l.nodeType===3?document.createTextNode(l.nodeValue):l.cloneNode(!1),d=l.firstChild;d;d=d.nextSibling)c!==!0&&d.nodeType===1&&d.nodeName==="SCRIPT"||u.appendChild(o(d,c));return l.nodeType===1&&(l.nodeName==="CANVAS"?(u.width=l.width,u.height=l.height,u.getContext("2d").drawImage(l,0,0)):l.nodeName!=="TEXTAREA"&&l.nodeName!=="SELECT"||(u.value=l.value),u.addEventListener("load",function(){u.scrollTop=l.scrollTop,u.scrollLeft=l.scrollLeft},!0)),u},a=function o(l){var c=Object.assign(o.convert(Promise.resolve()),JSON.parse(JSON.stringify(o.template))),u=o.convert(Promise.resolve(),c);return(u=u.setProgress(1,o,1,[o])).set(l)};(a.prototype=Object.create(Promise.prototype)).constructor=a,a.convert=function(o,l){return o.__proto__=l||a.prototype,o},a.template={prop:{src:null,container:null,overlay:null,canvas:null,img:null,pdf:null,pageSize:null,callback:function(){}},progress:{val:0,state:null,n:0,stack:[]},opt:{filename:"file.pdf",margin:[0,0,0,0],enableLinks:!0,x:0,y:0,html2canvas:{},jsPDF:{},backgroundColor:"transparent"}},a.prototype.from=function(o,l){return this.then(function(){switch(l=l||function(c){switch(r(c)){case"string":return"string";case"element":return c.nodeName.toLowerCase()==="canvas"?"canvas":"element";default:return"unknown"}}(o),l){case"string":return this.then(t).then(function(c){return this.set({src:i("div",{innerHTML:o,dompurify:c})})});case"element":return this.set({src:o});case"canvas":return this.set({canvas:o});case"img":return this.set({img:o});default:return this.error("Unknown source type.")}})},a.prototype.to=function(o){switch(o){case"container":return this.toContainer();case"canvas":return this.toCanvas();case"img":return this.toImg();case"pdf":return this.toPdf();default:return this.error("Invalid target.")}},a.prototype.toContainer=function(){return this.thenList([function(){return this.prop.src||this.error("Cannot duplicate - no source HTML.")},function(){return this.prop.pageSize||this.setPageSize()}]).then(function(){var o={position:"relative",display:"inline-block",width:(typeof this.opt.width!="number"||isNaN(this.opt.width)||typeof this.opt.windowWidth!="number"||isNaN(this.opt.windowWidth)?Math.max(this.prop.src.clientWidth,this.prop.src.scrollWidth,this.prop.src.offsetWidth):this.opt.windowWidth)+"px",left:0,right:0,top:0,margin:"auto",backgroundColor:this.opt.backgroundColor},l=s(this.prop.src,this.opt.html2canvas.javascriptEnabled);l.tagName==="BODY"&&(o.height=Math.max(document.body.scrollHeight,document.body.offsetHeight,document.documentElement.clientHeight,document.documentElement.scrollHeight,document.documentElement.offsetHeight)+"px"),this.prop.overlay=i("div",{className:"html2pdf__overlay",style:{position:"fixed",overflow:"hidden",zIndex:1e3,left:"-100000px",right:0,bottom:0,top:0}}),this.prop.container=i("div",{className:"html2pdf__container",style:o}),this.prop.container.appendChild(l),this.prop.container.firstChild.appendChild(i("div",{style:{clear:"both",border:"0 none transparent",margin:0,padding:0,height:0}})),this.prop.container.style.float="none",this.prop.overlay.appendChild(this.prop.container),document.body.appendChild(this.prop.overlay),this.prop.container.firstChild.style.position="relative",this.prop.container.height=Math.max(this.prop.container.firstChild.clientHeight,this.prop.container.firstChild.scrollHeight,this.prop.container.firstChild.offsetHeight)+"px"})},a.prototype.toCanvas=function(){var o=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(o).then(e).then(function(l){var c=Object.assign({},this.opt.html2canvas);return delete c.onrendered,l(this.prop.container,c)}).then(function(l){(this.opt.html2canvas.onrendered||function(){})(l),this.prop.canvas=l,document.body.removeChild(this.prop.overlay)})},a.prototype.toContext2d=function(){var o=[function(){return document.body.contains(this.prop.container)||this.toContainer()}];return this.thenList(o).then(e).then(function(l){var c=this.opt.jsPDF,u=this.opt.fontFaces,d=typeof this.opt.width!="number"||isNaN(this.opt.width)||typeof this.opt.windowWidth!="number"||isNaN(this.opt.windowWidth)?1:this.opt.width/this.opt.windowWidth,h=Object.assign({async:!0,allowTaint:!0,scale:d,scrollX:this.opt.scrollX||0,scrollY:this.opt.scrollY||0,backgroundColor:"#ffffff",imageTimeout:15e3,logging:!0,proxy:null,removeContainer:!0,foreignObjectRendering:!1,useCORS:!1},this.opt.html2canvas);if(delete h.onrendered,c.context2d.autoPaging=this.opt.autoPaging===void 0||this.opt.autoPaging,c.context2d.posX=this.opt.x,c.context2d.posY=this.opt.y,c.context2d.margin=this.opt.margin,c.context2d.fontFaces=u,u)for(var p=0;px&&(g=_,_=x,x=g);else{if(o!=="l"&&o!=="landscape")throw"Invalid orientation: "+o;o="l",x>_&&(g=_,_=x,x=g)}return{width:_,height:x,unit:l,k:d,orientation:o}},n.html=function(o,l){(l=l||{}).callback=l.callback||function(){},l.html2canvas=l.html2canvas||{},l.html2canvas.canvas=l.html2canvas.canvas||this.canvas,l.jsPDF=l.jsPDF||this,l.fontFaces=l.fontFaces?l.fontFaces.map(wj):null;var c=new a(l);return l.worker?c:c.from(o).doCallback()}}(Cr.API),Cr.API.addJS=function(n){var e,t,r=function(i){for(var s="",a=0;a=0&&i[c]==="\\";c--)l++;s+=l%2==0?"\\"+o:o}else s+=o}return s}(n);return this.internal.events.subscribe("postPutResources",function(){e=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/Names [(EmbeddedJS) "+(e+1)+" 0 R]"),this.internal.out(">>"),this.internal.out("endobj"),t=this.internal.newObject(),this.internal.out("<<"),this.internal.out("/S /JavaScript"),this.internal.out("/JS ("+r+")"),this.internal.out(">>"),this.internal.out("endobj")}),this.internal.events.subscribe("putCatalog",function(){e!==void 0&&t!==void 0&&this.internal.out("/Names <>")}),this},function(n){var e;n.events.push(["postPutResources",function(){var t=this,r=/^(\d+) 0 obj$/;if(this.outline.root.children.length>0)for(var i=t.outline.render().split(/\r\n/),s=0;s> endobj")}var p=t.internal.newObject();for(t.internal.write("<< /Names [ "),s=0;s>","endobj"),e=t.internal.newObject(),t.internal.write("<< /Dests "+p+" 0 R"),t.internal.write(">>","endobj")}}]),n.events.push(["putCatalog",function(){var t=this;t.outline.root.children.length>0&&(t.internal.write("/Outlines",this.outline.makeRef(this.outline.root)),this.outline.createNamedDestinations&&t.internal.write("/Names "+e+" 0 R"))}]),n.events.push(["initialized",function(){var t=this;t.outline={createNamedDestinations:!1,root:{children:[]}},t.outline.add=function(r,i,s){var a={title:i,options:s,children:[]};return r==null&&(r=this.root),r.children.push(a),a},t.outline.render=function(){return this.ctx={},this.ctx.val="",this.ctx.pdf=t,this.genIds_r(this.root),this.renderRoot(this.root),this.renderItems(this.root),this.ctx.val},t.outline.genIds_r=function(r){r.id=t.internal.newObjectDeferred();for(var i=0;i0&&(this.line("/First "+this.makeRef(r.children[0])),this.line("/Last "+this.makeRef(r.children[r.children.length-1]))),this.line("/Count "+this.count_r({count:0},r)),this.objEnd()},t.outline.renderItems=function(r){for(var i=this.ctx.pdf.internal.getVerticalCoordinateString,s=0;s0&&this.line("/Prev "+this.makeRef(r.children[s-1])),s0&&(this.line("/First "+this.makeRef(a.children[0])),this.line("/Last "+this.makeRef(a.children[a.children.length-1])));var o=this.count=this.count_r({count:0},a);if(o>0&&this.line("/Count "+o),a.options&&a.options.pageNumber){var l=t.internal.getPageInfo(a.options.pageNumber);this.line("/Dest ["+l.objId+" 0 R /XYZ 0 "+i(0)+" 0]")}this.objEnd()}for(var c=0;c> \r endobj\r `},t.outline.count_r=function(r,i){for(var s=0;s1){W=!0,ie=void 0;var pe=V*$;ae=new Uint8Array(pe);for(var ge=new DataView(G.buffer),Te=0;Te536870912)throw new Error("Image dimensions exceed 512MB, which is too large.");this.data=new Uint8Array(e);try{this[n]()}catch(t){Ra.log("bit decode error:"+t)}},m0.prototype.bit1=function(){var n,e=Math.ceil(this.width/8),t=e%4;for(n=this.height-1;n>=0;n--){for(var r=this.bottom_up?n:this.height-1-n,i=0;i>7-o&1];this.data[a+4*o]=l.blue,this.data[a+4*o+1]=l.green,this.data[a+4*o+2]=l.red,this.data[a+4*o+3]=255}t!==0&&(this.pos+=4-t)}},m0.prototype.bit4=function(){for(var n=Math.ceil(this.width/2),e=n%4,t=this.height-1;t>=0;t--){for(var r=this.bottom_up?t:this.height-1-t,i=0;i>4,l=15&s,c=this.palette[o];if(this.data[a]=c.blue,this.data[a+1]=c.green,this.data[a+2]=c.red,this.data[a+3]=255,2*i+1>=this.width)break;c=this.palette[l],this.data[a+4]=c.blue,this.data[a+4+1]=c.green,this.data[a+4+2]=c.red,this.data[a+4+3]=255}e!==0&&(this.pos+=4-e)}},m0.prototype.bit8=function(){for(var n=this.width%4,e=this.height-1;e>=0;e--){for(var t=this.bottom_up?e:this.height-1-e,r=0;r=0;t--){for(var r=this.bottom_up?t:this.height-1-t,i=0;i>5&e)/e*255|0,l=(s>>10&e)/e*255|0,c=s>>15?255:0,u=r*this.width*4+4*i;this.data[u]=l,this.data[u+1]=o,this.data[u+2]=a,this.data[u+3]=c}this.pos+=n}},m0.prototype.bit16=function(){for(var n=this.width%3,e=parseInt("11111",2),t=parseInt("111111",2),r=this.height-1;r>=0;r--){for(var i=this.bottom_up?r:this.height-1-r,s=0;s>5&t)/t*255|0,c=(a>>11)/e*255|0,u=i*this.width*4+4*s;this.data[u]=c,this.data[u+1]=l,this.data[u+2]=o,this.data[u+3]=255}this.pos+=n}},m0.prototype.bit24=function(){for(var n=this.height-1;n>=0;n--){for(var e=this.bottom_up?n:this.height-1-n,t=0;t=0;n--)for(var e=this.bottom_up?n:this.height-1-n,t=0;tr&&(i.push(n.slice(l,s)),o=0,l=s),o+=e[s],s++;return l!==s&&i.push(n.slice(l,s)),i},kse=function(n,e,t){t||(t={});var r,i,s,a,o,l,c,u=[],d=[u],h=t.textIndent||0,p=0,g=0,x=n.split(" "),_=TT.apply(this,[" ",t])[0];if(l=t.lineIndent===-1?x[0].length+2:t.lineIndent||0){var y=Array(l).join(" "),M=[];x.map(function(k){(k=k.split(/\s*\n/)).length>1?M=M.concat(k.map(function(B,U){return(U&&B.length?` `:"")+B})):M.push(k[0])}),x=M,l=Rse.apply(this,[y,t])}for(s=0,a=x.length;se||C){if(g>e){for(o=Lse.apply(this,[r,i,e-(h+p),e]),u.push(o.shift()),u=[o.pop()];o.length;)d.push([o.shift()]);g=i.slice(r.length-(u[0]?u[0].length:0)).reduce(function(k,B){return k+B},0)}else u=[r];d.push(u),h=g+l,p=_}else u.push(r),h+=p+g,p=_}return c=l?function(k,B){return(B?y:"")+k.join(" ")}:function(k){return k.join(" ")},d.map(c)},Py.splitTextToSize=function(n,e,t){var r,i=(t=t||{}).fontSize||this.internal.getFontSize(),s=(function(u){if(u.widths&&u.kerning)return{widths:u.widths,kerning:u.kerning};var d=this.internal.getFont(u.fontName,u.fontStyle),h="Unicode";return d.metadata[h]?{widths:d.metadata[h].widths||{0:1},kerning:d.metadata[h].kerning||{}}:{font:d.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,t);r=Array.isArray(n)?n:String(n).split(/\r?\n/);var a=1*this.internal.scaleFactor*e/i;s.textIndent=t.textIndent?1*t.textIndent*this.internal.scaleFactor/i:0,s.lineIndent=t.lineIndent;var o,l,c=[];for(o=0,l=r.length;oimport("./index.es-Civ3iYto.js"),[],import.meta.url)).catch(function(h){return Promise.reject(new Error("Could not load canvg: "+h))}).then(function(h){return h.default?h.default:h}).then(function(h){return h.fromString(c,n,u)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(h){return h.render(u)}).then(function(){d.addImage(l.toDataURL("image/jpeg",1),e,t,r,i,a,o)})},Cr.API.putTotalPages=function(n){var e,t=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(n,"g"),t=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(n,this.internal.getFont()),"g"),t=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var r=1;r<=this.internal.getNumberOfPages();r++)for(var i=0;i1){for(u=0;u>`)}),this.internal.viewerpreferences.isSubscribed=!0),this.internal.viewerpreferences.configuration=t,this},Cr.API.addMetadata=function(n,e){return this.internal.__metadata__===void 0&&(this.internal.__metadata__={metadata:n,namespaceUri:e??"http://jspdf.default.namespaceuri/",rawXml:typeof e=="boolean"&&e},this.internal.events.subscribe("putCatalog",UGe),this.internal.events.subscribe("postPutResources",BGe)),this},function(n){var e=n.API,t=e.pdfEscape16=function(s,a){for(var o,l=a.metadata.Unicode.widths,c=["","0","00","000","0000"],u=[""],d=0,h=s.length;d> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def 1 begincodespacerange <0000> endcodespacerange`,l=[],d=0,h=(o=Object.keys(s).sort(function(p,g){return p-g})).length;d=100&&(u+=` `+l.length+` beginbfchar `+l.join(` `)+` endbfchar`,l=[]),s[a]!==void 0&&s[a]!==null&&typeof s[a].toString=="function"&&(c=("0000"+s[a].toString(16)).slice(-4),a=("0000"+(+a).toString(16)).slice(-4),l.push("<"+a+"><"+c+">"));return l.length&&(u+=` `+l.length+` beginbfchar `+l.join(` `)+` endbfchar `),u+`endcmap CMapName currentdict /CMap defineresource pop end end`};e.events.push(["putFont",function(s){(function(a){var o=a.font,l=a.out,c=a.newObject,u=a.putStream;if(o.metadata instanceof n.API.TTFFont&&o.encoding==="Identity-H"){for(var d=o.metadata.Unicode.widths,h=o.metadata.subset.encode(o.metadata.glyIdsUsed,1),p="",g=0;g>"),l("endobj");var M=c();l("<<"),l("/Type /Font"),l("/BaseFont /"+Nb(o.fontName)),l("/FontDescriptor "+y+" 0 R"),l("/W "+n.API.PDFObject.convert(d)),l("/CIDToGIDMap /Identity"),l("/DW 1000"),l("/Subtype /CIDFontType2"),l("/CIDSystemInfo"),l("<<"),l("/Supplement 0"),l("/Registry (Adobe)"),l("/Ordering ("+o.encoding+")"),l(">>"),l(">>"),l("endobj"),o.objectNumber=c(),l("<<"),l("/Type /Font"),l("/Subtype /Type0"),l("/ToUnicode "+_+" 0 R"),l("/BaseFont /"+Nb(o.fontName)),l("/Encoding /"+o.encoding),l("/DescendantFonts ["+M+" 0 R]"),l(">>"),l("endobj"),o.isAlreadyPutted=!0}})(s)}]),e.events.push(["putFont",function(s){(function(a){var o=a.font,l=a.out,c=a.newObject,u=a.putStream;if(o.metadata instanceof n.API.TTFFont&&o.encoding==="WinAnsiEncoding"){for(var d=o.metadata.rawData,h="",p=0;p>"),l("endobj"),o.objectNumber=c();for(var y=0;y>"),l("endobj"),o.isAlreadyPutted=!0}})(s)}]);var i=function(s){var a,o=s.text||"",l=s.x,c=s.y,u=s.options||{},d=s.mutex||{},h=d.pdfEscape,p=d.activeFontKey,g=d.fonts,x=p,_="",y=0,M="",C=g[x].encoding;if(g[x].encoding!=="Identity-H")return{text:o,x:l,y:c,options:u,mutex:d};for(M=o,x=p,Array.isArray(o)&&(M=o[0]),y=0;y","<","[","]","[","{","}","{","«","»","«","‹","›","‹","⁅","⁆","⁅","⁽","⁾","⁽","₍","₎","₍","≤","≥","≤","〈","〉","〈","﹙","﹚","﹙","﹛","﹜","﹛","﹝","﹞","﹝","﹤","﹥","﹤"],y=new RegExp(/^([1-4|9]|1[0-9]|2[0-9]|3[0168]|4[04589]|5[012]|7[78]|159|16[0-9]|17[0-2]|21[569]|22[03489]|250)$/),M=!1,C=0;this.__bidiEngine__={};var k=function(G){var H=G.charCodeAt(),K=H>>8,W=x[K];return W!==void 0?d[256*W+(255&H)]:K===252||K===253?"AL":y.test(K)?"L":K===8?"R":"N"},B=function(G){for(var H,K=0;K=H.length||(J=K[W-1])!=="EN"&&J!=="AN"||(ie=H[W+1])!=="EN"&&ie!=="AN"?re="N":M&&(ie="AN"),re=ie===J?ie:"N";break;case"ES":re=(J=W>0?K[W-1]:"B")==="EN"&&W+10&&K[W-1]==="EN"){re="EN";break}if(M){re="N";break}for(ae=W+1,Q=H.length;ae=1425&&oe<=2303||oe===64286;if(J=H[ae],fe&&(J==="R"||J==="AL")){re="R";break}}}re=W<1||(J=H[W-1])==="B"?"N":K[W-1];break;case"B":M=!1,i=!0,re=C;break;case"S":s=!0,re="N"}return re},z=function(G,H,K){var W=G.split("");return K&&O(W,K,{hiLevel:C}),W.reverse(),H&&H.reverse(),W.join("")},O=function(G,H,K){var W,J,ie,ae,Q,re=-1,oe=G.length,fe=0,ee=[],me=C?p:h,Ae=[];for(M=!1,i=!1,s=!1,J=0;J0)if(W===16){for(J=re;J-1){for(J=re;J=0&&be[ze]==="WS";ze--)pe[ze]=C}}(Ae,H,oe)},V=function(G,H,K,W,J){if(!(J.hiLevel=G){for(Q=fe+1;Q=G;)Q++;for(re=fe,ae=Q-1;re=0&&(ie[oe]=_[re+1])}(W,K,J),V(2,W,H,K,J),V(1,W,H,K,J),W.join("")};return this.__bidiEngine__.doBidiReorder=function(G,H,K){if(function(J,ie){if(ie)for(var ae=0;ae>16)&&(t=-(1+(65535^t))),this.italicAngle=+(t+"."+r)):this.italicAngle=0,this.ascender=Math.round(this.ascender*this.scaleFactor),this.decender=Math.round(this.decender*this.scaleFactor),this.lineGap=Math.round(this.lineGap*this.scaleFactor),this.capHeight=this.os2.exists&&this.os2.capHeight||this.ascender,this.xHeight=this.os2.exists&&this.os2.xHeight||0,this.familyClass=(this.os2.exists&&this.os2.familyClass||0)>>8,this.isSerif=(s=this.familyClass)===1||s===2||s===3||s===4||s===5||s===7,this.isScript=this.familyClass===10,this.flags=0,this.post.isFixedPitch&&(this.flags|=1),this.isSerif&&(this.flags|=2),this.isScript&&(this.flags|=8),this.italicAngle!==0&&(this.flags|=64),this.flags|=32,!this.cmap.unicode)throw new Error("No unicode cmap for font")},n.prototype.characterToGlyph=function(e){var t;return((t=this.cmap.unicode)!=null?t.codeMap[e]:void 0)||0},n.prototype.widthOfGlyph=function(e){var t;return t=1e3/this.head.unitsPerEm,this.hmtx.forGlyph(e).advance*t},n.prototype.widthOfString=function(e,t,r){var i,s,a,o;for(a=0,s=0,o=(e=""+e).length;0<=o?so;s=0<=o?++s:--s)i=e.charCodeAt(s),a+=this.widthOfGlyph(this.characterToGlyph(i))+r*(1e3/t)||0;return a*(t/1e3)},n.prototype.lineHeight=function(e,t){var r;return t==null&&(t=!1),r=t?this.lineGap:0,(this.ascender+r-this.decender)/1e3*e},n}();var ap,BA=function(){function n(e){this.data=e??[],this.pos=0,this.length=this.data.length}return n.prototype.readByte=function(){return this.data[this.pos++]},n.prototype.writeByte=function(e){return this.data[this.pos++]=e},n.prototype.readUInt32=function(){return 16777216*this.readByte()+(this.readByte()<<16)+(this.readByte()<<8)+this.readByte()},n.prototype.writeUInt32=function(e){return this.writeByte(e>>>24&255),this.writeByte(e>>16&255),this.writeByte(e>>8&255),this.writeByte(255&e)},n.prototype.readInt32=function(){var e;return(e=this.readUInt32())>=2147483648?e-4294967296:e},n.prototype.writeInt32=function(e){return e<0&&(e+=4294967296),this.writeUInt32(e)},n.prototype.readUInt16=function(){return this.readByte()<<8|this.readByte()},n.prototype.writeUInt16=function(e){return this.writeByte(e>>8&255),this.writeByte(255&e)},n.prototype.readInt16=function(){var e;return(e=this.readUInt16())>=32768?e-65536:e},n.prototype.writeInt16=function(e){return e<0&&(e+=65536),this.writeUInt16(e)},n.prototype.readString=function(e){var t,r;for(r=[],t=0;0<=e?te;t=0<=e?++t:--t)r[t]=String.fromCharCode(this.readByte());return r.join("")},n.prototype.writeString=function(e){var t,r,i;for(i=[],t=0,r=e.length;0<=r?tr;t=0<=r?++t:--t)i.push(this.writeByte(e.charCodeAt(t)));return i},n.prototype.readShort=function(){return this.readInt16()},n.prototype.writeShort=function(e){return this.writeInt16(e)},n.prototype.readLongLong=function(){var e,t,r,i,s,a,o,l;return e=this.readByte(),t=this.readByte(),r=this.readByte(),i=this.readByte(),s=this.readByte(),a=this.readByte(),o=this.readByte(),l=this.readByte(),128&e?-1*(72057594037927940*(255^e)+281474976710656*(255^t)+1099511627776*(255^r)+4294967296*(255^i)+16777216*(255^s)+65536*(255^a)+256*(255^o)+(255^l)+1):72057594037927940*e+281474976710656*t+1099511627776*r+4294967296*i+16777216*s+65536*a+256*o+l},n.prototype.writeLongLong=function(e){var t,r;return t=Math.floor(e/4294967296),r=4294967295&e,this.writeByte(t>>24&255),this.writeByte(t>>16&255),this.writeByte(t>>8&255),this.writeByte(255&t),this.writeByte(r>>24&255),this.writeByte(r>>16&255),this.writeByte(r>>8&255),this.writeByte(255&r)},n.prototype.readInt=function(){return this.readInt32()},n.prototype.writeInt=function(e){return this.writeInt32(e)},n.prototype.read=function(e){var t,r;for(t=[],r=0;0<=e?re;r=0<=e?++r:--r)t.push(this.readByte());return t},n.prototype.write=function(e){var t,r,i,s;for(s=[],r=0,i=e.length;rs;i=0<=s?++i:--i)r={tag:t.readString(4),checksum:t.readInt(),offset:t.readInt(),length:t.readInt()},this.tables[r.tag]=r}return e.prototype.encode=function(t){var r,i,s,a,o,l,c,u,d,h,p,g,x;for(x in p=Object.keys(t).length,l=Math.log(2),d=16*Math.floor(Math.log(p)/l),a=Math.floor(d/l),u=16*p-d,(i=new BA).writeInt(this.scalarType),i.writeShort(p),i.writeShort(d),i.writeShort(a),i.writeShort(u),s=16*p,c=i.pos+s,o=null,g=[],t)for(h=t[x],i.writeString(x),i.writeInt(n(h)),i.writeInt(c),i.writeInt(h.length),g=g.concat(h),x==="head"&&(o=c),c+=h.length;c%4;)g.push(0),c++;return i.write(g),r=2981146554-n(i.data),i.pos=o+8,i.writeUInt32(r),i.data},n=function(t){var r,i,s,a;for(t=r2e.call(t);t.length%4;)t.push(0);for(s=new BA(t),i=0,r=0,a=t.length;rh;l=0<=h?++k:--k)B.push(e.readUInt16());return B}(),e.pos+=2,x=function(){var k,B;for(B=[],l=k=0;0<=h?kh;l=0<=h?++k:--k)B.push(e.readUInt16());return B}(),c=function(){var k,B;for(B=[],l=k=0;0<=h?kh;l=0<=h?++k:--k)B.push(e.readUInt16());return B}(),u=function(){var k,B;for(B=[],l=k=0;0<=h?kh;l=0<=h?++k:--k)B.push(e.readUInt16());return B}(),i=(this.length-e.pos+this.offset)/2,o=function(){var k,B;for(B=[],l=k=0;0<=i?ki;l=0<=i?++k:--k)B.push(e.readUInt16());return B}(),l=y=0,C=s.length;y=_;r=g<=_?++M:--M)u[l]===0?a=r+c[l]:(a=o[u[l]/2+(r-g)-(h-l)]||0)!==0&&(a+=c[l]),this.codeMap[r]=65535&a}e.pos=d}return n.encode=function(e,t){var r,i,s,a,o,l,c,u,d,h,p,g,x,_,y,M,C,k,B,U,z,O,V,$,G,H,K,W,J,ie,ae,Q,re,oe,fe,ee,me,Ae,be,pe,ge,Te,ze,Xe,Qe,ot;switch(W=new BA,a=Object.keys(e).sort(function(bt,ht){return bt-ht}),t){case"macroman":for(x=0,_=function(){var bt=[];for(g=0;g<256;++g)bt.push(0);return bt}(),M={0:0},s={},J=0,re=a.length;J=32768)for(l.push(0),U.push(2*(p.length+V-g)),i=Q=G;G<=u?Q<=u:Q>=u;i=G<=u?++Q:--Q)p.push(r[i].new);else l.push(K-G),U.push(0)}for(W.writeUInt16(3),W.writeUInt16(1),W.writeUInt32(12),W.writeUInt16(4),W.writeUInt16(16+8*V+2*p.length),W.writeUInt16(0),W.writeUInt16($),W.writeUInt16(O),W.writeUInt16(h),W.writeUInt16(z),ge=0,ee=d.length;gei;r=0<=i?++r:--r)t=new Vse(e,this.offset),this.tables.push(t),t.isUnicode&&this.unicode==null&&(this.unicode=t);return!0},n.encode=function(e,t){var r,i;return t==null&&(t="macroman"),r=Vse.encode(e,t),(i=new BA).writeUInt16(0),i.writeUInt16(1),r.table=i.data.concat(r.subtable),r},n}(),GGe=function(){function n(){return n.__super__.constructor.apply(this,arguments)}return wm(n,ap),n.prototype.tag="hhea",n.prototype.parse=function(e){return e.pos=this.offset,this.version=e.readInt(),this.ascender=e.readShort(),this.decender=e.readShort(),this.lineGap=e.readShort(),this.advanceWidthMax=e.readShort(),this.minLeftSideBearing=e.readShort(),this.minRightSideBearing=e.readShort(),this.xMaxExtent=e.readShort(),this.caretSlopeRise=e.readShort(),this.caretSlopeRun=e.readShort(),this.caretOffset=e.readShort(),e.pos+=8,this.metricDataFormat=e.readShort(),this.numberOfMetrics=e.readUInt16()},n}(),HGe=function(){function n(){return n.__super__.constructor.apply(this,arguments)}return wm(n,ap),n.prototype.tag="OS/2",n.prototype.parse=function(e){if(e.pos=this.offset,this.version=e.readUInt16(),this.averageCharWidth=e.readShort(),this.weightClass=e.readUInt16(),this.widthClass=e.readUInt16(),this.type=e.readShort(),this.ySubscriptXSize=e.readShort(),this.ySubscriptYSize=e.readShort(),this.ySubscriptXOffset=e.readShort(),this.ySubscriptYOffset=e.readShort(),this.ySuperscriptXSize=e.readShort(),this.ySuperscriptYSize=e.readShort(),this.ySuperscriptXOffset=e.readShort(),this.ySuperscriptYOffset=e.readShort(),this.yStrikeoutSize=e.readShort(),this.yStrikeoutPosition=e.readShort(),this.familyClass=e.readShort(),this.panose=function(){var t,r;for(r=[],t=0;t<10;++t)r.push(e.readByte());return r}(),this.charRange=function(){var t,r;for(r=[],t=0;t<4;++t)r.push(e.readInt());return r}(),this.vendorID=e.readString(4),this.selection=e.readShort(),this.firstCharIndex=e.readShort(),this.lastCharIndex=e.readShort(),this.version>0&&(this.ascent=e.readShort(),this.descent=e.readShort(),this.lineGap=e.readShort(),this.winAscent=e.readShort(),this.winDescent=e.readShort(),this.codePageRange=function(){var t,r;for(r=[],t=0;t<2;t=++t)r.push(e.readInt());return r}(),this.version>1))return this.xHeight=e.readShort(),this.capHeight=e.readShort(),this.defaultChar=e.readShort(),this.breakChar=e.readShort(),this.maxContext=e.readShort()},n}(),$Ge=function(){function n(){return n.__super__.constructor.apply(this,arguments)}return wm(n,ap),n.prototype.tag="post",n.prototype.parse=function(e){var t,r,i;switch(e.pos=this.offset,this.format=e.readInt(),this.italicAngle=e.readInt(),this.underlinePosition=e.readShort(),this.underlineThickness=e.readShort(),this.isFixedPitch=e.readInt(),this.minMemType42=e.readInt(),this.maxMemType42=e.readInt(),this.minMemType1=e.readInt(),this.maxMemType1=e.readInt(),this.format){case 65536:case 196608:break;case 131072:var s;for(r=e.readUInt16(),this.glyphNameIndex=[],s=0;0<=r?sr;s=0<=r?++s:--s)this.glyphNameIndex.push(e.readUInt16());for(this.names=[],i=[];e.poso;s=0<=o?++a:--a)l.push(e.readUInt32());return l}).call(this)}},n}(),WGe=function(n,e){this.raw=n,this.length=n.length,this.platformID=e.platformID,this.encodingID=e.encodingID,this.languageID=e.languageID},XGe=function(){function n(){return n.__super__.constructor.apply(this,arguments)}return wm(n,ap),n.prototype.tag="name",n.prototype.parse=function(e){var t,r,i,s,a,o,l,c,u,d,h;for(e.pos=this.offset,e.readShort(),t=e.readShort(),o=e.readShort(),r=[],s=0;0<=t?st;s=0<=t?++s:--s)r.push({platformID:e.readShort(),encodingID:e.readShort(),languageID:e.readShort(),nameID:e.readShort(),length:e.readShort(),offset:this.offset+o+e.readShort()});for(l={},s=u=0,d=r.length;uo;t=0<=o?++t:--t)this.metrics.push({advance:e.readUInt16(),lsb:e.readInt16()});for(i=this.file.maxp.numGlyphs-this.file.hhea.numberOfMetrics,this.leftSideBearings=function(){var c,u;for(u=[],t=c=0;0<=i?ci;t=0<=i?++c:--c)u.push(e.readInt16());return u}(),this.widths=(function(){var c,u,d,h;for(h=[],c=0,u=(d=this.metrics).length;ci;t=0<=i?++a:--a)l.push(this.widths.push(r));return l},n.prototype.forGlyph=function(e){return e in this.metrics?this.metrics[e]:{advance:this.metrics[this.metrics.length-1].advance,lsb:this.leftSideBearings[e-this.metrics.length]}},n}(),r2e=[].slice,QGe=function(){function n(){return n.__super__.constructor.apply(this,arguments)}return wm(n,ap),n.prototype.tag="glyf",n.prototype.parse=function(){return this.cache={}},n.prototype.glyphFor=function(e){var t,r,i,s,a,o,l,c,u,d;return e in this.cache?this.cache[e]:(s=this.file.loca,t=this.file.contents,r=s.indexOf(e),(i=s.lengthOf(e))===0?this.cache[e]=null:(t.pos=this.offset+r,a=(o=new BA(t.read(i))).readShort(),c=o.readShort(),d=o.readShort(),l=o.readShort(),u=o.readShort(),this.cache[e]=a===-1?new JGe(o,c,d,l,u):new KGe(o,a,c,d,l,u),this.cache[e]))},n.prototype.encode=function(e,t,r){var i,s,a,o,l;for(a=[],s=[],o=0,l=t.length;o0&&(i+=l)}for(var c=new Array(4*r.length),u=0;u>8,c[4*u+1]=(16711680&r[u])>>16,c[4*u]=(4278190080&r[u])>>24;return c},n}(),tHe=function(){function n(e){this.font=e,this.subset={},this.unicodes={},this.next=33}return n.prototype.generateCmap=function(){var e,t,r,i,s;for(t in i=this.font.cmap.tables[0].codeMap,e={},s=this.subset)r=s[t],e[t]=i[r];return e},n.prototype.glyphsFor=function(e){var t,r,i,s,a,o,l;for(i={},a=0,o=e.length;a0)for(s in l=this.glyphsFor(t))r=l[s],i[s]=r;return i},n.prototype.encode=function(e,t){var r,i,s,a,o,l,c,u,d,h,p,g,x,_,y;for(i in r=n2e.encode(this.generateCmap(),"unicode"),a=this.glyphsFor(e),p={0:0},y=r.charMap)p[(l=y[i]).old]=l.new;for(g in h=r.maxGlyphID,a)g in p||(p[g]=h++);return u=function(M){var C,k;for(C in k={},M)k[M[C]]=C;return k}(p),d=Object.keys(u).sort(function(M,C){return M-C}),x=function(){var M,C,k;for(k=[],M=0,C=d.length;M>"),s.join(` `)}return""+t},e}();function i2e(n){return wn({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M250.882 22.802c-23.366 3.035-44.553 30.444-44.553 65.935 0 19.558 6.771 36.856 16.695 48.815l11.84 14.263-18.217 3.424c-12.9 2.425-22.358 9.24-30.443 20.336-8.085 11.097-14.266 26.558-18.598 44.375-7.843 32.28-9.568 71.693-9.842 106.436h42.868l11.771 157.836c29.894 6.748 61.811 6.51 90.602.025l10.414-157.86h40.816c-.027-35.169-.477-75.126-7.584-107.65-3.918-17.934-9.858-33.372-18.04-44.343-8.185-10.97-18.08-17.745-32.563-19.989l-18.592-2.88 11.736-14.704c9.495-11.897 15.932-28.997 15.932-48.082 0-37.838-23.655-65.844-49.399-65.844z"},child:[]}]})(n)}const nHe=de.memo(n=>{const{data:e,onAddRelative:t}=n,[r,i]=de.useState(!1),s=e.is_placeholder||!1;let a=e.photo_url||e.photo||null;a&&a.startsWith("/")&&(a=`https://famille.ravin-cloud.fr${a}`);const o=C=>{if(!C)return null;try{const k=new Date(C);if(isNaN(k.getTime()))return null;const B=new Date;let U=B.getFullYear()-k.getFullYear();const z=B.getMonth()-k.getMonth();return(z<0||z===0&&B.getDate(){i(!1),t&&t(e.slug,C)},_=(C,k)=>{const B=C?C.charAt(0).toUpperCase():"",U=k?k.charAt(0).toUpperCase():"";return`${B}${U}`||"?"},y=C=>{if(!C)return null;const k=String(C).trim();if(!k)return null;if(/^\d{4}-\d{2}-\d{2}$/.test(k)){const[B,U,z]=k.split("-");return`${z}/${U}/${B}`}if(/^\d{4}-\d{2}$/.test(k)){const[B,U]=k.split("-");return`${U}/${B}`}if(/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(k))return k;try{const B=new Date(k);if(!isNaN(B.getTime())){const U=String(B.getDate()).padStart(2,"0"),z=String(B.getMonth()+1).padStart(2,"0"),O=B.getFullYear();return`${U}/${z}/${O}`}}catch{}return k},M=!s&&(!e.date_naissance||!e.lieu_naissance||!e.profession||!a);return f.jsxs(Gn.div,{className:g,onMouseLeave:()=>i(!1),whileHover:s?{}:{scale:1.03},transition:{type:"spring",stiffness:300,damping:20},children:[f.jsxs("div",{className:"flex items-center gap-1.5 mb-2 w-full",children:[l&&f.jsxs("span",{className:"px-2.5 py-0.5 rounded-full bg-gradient-to-r from-amber-400 to-amber-500 text-amber-950 font-black text-[9px] uppercase tracking-wider shadow-sm border border-amber-300 flex items-center gap-1",children:[f.jsx("span",{children:"👑"})," INDIVIDU CENTRAL"]}),c&&!l&&f.jsxs("span",{className:"px-2.5 py-0.5 rounded-full bg-gradient-to-r from-emerald-600 to-teal-700 text-white font-black text-[9px] uppercase tracking-wider shadow-sm border border-emerald-400 flex items-center gap-1",children:[f.jsx("span",{children:"⚜️"})," SOSA 1 (Racine)"]}),M&&!l&&f.jsx("span",{className:"ml-auto px-2 py-0.5 rounded-full bg-orange-500 text-white font-black text-[9px] shadow-sm flex items-center gap-1 border border-orange-400",title:"Informations à compléter",children:"⚠️ Incomplet"})]}),f.jsx(Fp,{type:"target",position:Tr.Top,className:"!w-4 !h-4 !-top-2 !bg-gradient-to-br !from-[#d4c4a8] !to-[#8b7355] !border-2 !border-white !rounded-full shadow-md",id:"top"}),f.jsx(Fp,{type:"source",position:Tr.Bottom,className:"!w-4 !h-4 !-bottom-2 !bg-gradient-to-br !from-[#d4c4a8] !to-[#8b7355] !border-2 !border-white !rounded-full shadow-md",id:"bottom"}),f.jsx(Fp,{type:"source",position:Tr.Left,className:"!w-3.5 !h-3.5 !-left-1.5 !top-1/2 !-translate-y-1/2 !bg-rose-400 !border-2 !border-white !rounded-full shadow-md",id:"left-source"}),f.jsx(Fp,{type:"target",position:Tr.Left,className:"!w-3.5 !h-3.5 !-left-1.5 !top-1/2 !-translate-y-1/2 !bg-rose-400 !border-2 !border-white !rounded-full shadow-md",id:"left-target"}),f.jsx(Fp,{type:"source",position:Tr.Right,className:"!w-3.5 !h-3.5 !-right-1.5 !top-1/2 !-translate-y-1/2 !bg-rose-400 !border-2 !border-white !rounded-full shadow-md",id:"right-source"}),f.jsx(Fp,{type:"target",position:Tr.Right,className:"!w-3.5 !h-3.5 !-right-1.5 !top-1/2 !-translate-y-1/2 !bg-rose-400 !border-2 !border-white !rounded-full shadow-md",id:"right-target"}),f.jsxs("div",{className:"flex gap-4 items-start w-full",children:[f.jsxs("div",{className:`w-[74px] h-[92px] shrink-0 rounded-2xl flex items-center justify-center border-2 border-white shadow-[0_6px_16px_rgba(0,0,0,0.12)] overflow-hidden group/avatar cursor-pointer transition-transform duration-300 group-hover:scale-105 relative ${s?"bg-slate-100":u?"bg-gradient-to-br from-rose-100 via-rose-50 to-rose-200 text-rose-500":d?"bg-gradient-to-br from-sky-100 via-sky-50 to-sky-200 text-sky-500":"bg-gradient-to-br from-[#f4f1ea] to-[#e8e4db] text-[#8b7355]"} `,onClick:C=>{C.stopPropagation(),e.onAvatarClick&&!s&&e.onAvatarClick(e.slug)},title:"Cliquez pour changer la photo",children:[a?f.jsx("img",{src:a,alt:`${e.prenom} ${e.nom}`,className:"w-full h-full object-cover grayscale-[15%] sepia-[25%]"}):s?f.jsx(hm,{className:"w-6 h-6 text-slate-300"}):f.jsx("span",{className:"text-xl font-serif font-black tracking-widest text-slate-700/80",children:_(e.prenom,e.nom)}),!s&&f.jsx("div",{className:"absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover/avatar:opacity-100 transition-opacity duration-300",children:f.jsx(fm,{className:"text-white w-5 h-5"})})]}),f.jsxs("div",{className:"flex flex-col flex-grow min-w-0 justify-center",children:[f.jsxs("div",{className:"flex items-center justify-between gap-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[u?f.jsx("span",{className:"w-4 h-4 rounded-full bg-rose-100 border border-rose-300 text-rose-700 flex items-center justify-center text-[10px] font-black shrink-0 shadow-2xs",title:"Femme (♀)",children:"♀"}):f.jsx("span",{className:"w-4 h-4 rounded-full bg-sky-100 border border-sky-300 text-sky-700 flex items-center justify-center text-[10px] font-black shrink-0 shadow-2xs",title:"Homme (♂)",children:"♂"}),f.jsx("h3",{className:"font-serif font-bold text-[20px] leading-tight text-slate-900 truncate",title:`${e.prenom} ${e.nom}`,children:e.prenom})]}),(n.onEditPerson||e.onEditPerson)&&!s&&f.jsx("button",{onClick:C=>{C.stopPropagation(),(n.onEditPerson||e.onEditPerson)(e)},className:"p-1.5 rounded-lg bg-amber-50 hover:bg-amber-100 text-amber-800 border border-amber-300/80 shadow-xs hover:scale-110 transition-all shrink-0",title:"Modifier cette fiche",children:f.jsx(Pg,{size:12})})]}),f.jsxs("div",{className:"text-[11px] font-black text-amber-700/90 uppercase tracking-[0.18em] truncate mb-1 font-serif flex items-center gap-1 flex-wrap",children:[f.jsx("span",{children:e.nom}),(e.nom_jeune_fille||e.nom_naissance)&&(e.nom_jeune_fille||e.nom_naissance).toUpperCase()!==(e.nom||"").toUpperCase()&&f.jsxs("span",{className:"text-[10px] lowercase text-slate-500 font-normal italic tracking-normal",children:["(née ",(e.nom_jeune_fille||e.nom_naissance).toUpperCase(),")"]}),e.surnom&&f.jsxs("span",{className:"text-[10px] text-purple-600 font-bold tracking-normal",children:["« ",e.surnom," »"]})]}),!s&&f.jsxs("div",{className:"flex flex-col gap-1 text-[11px] font-semibold text-slate-700",children:[e.date_naissance?f.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-800 bg-emerald-50 px-2 py-0.5 rounded-md border border-emerald-200/60 w-fit shadow-xs",children:[f.jsx("span",{className:"font-black text-[10px] text-emerald-900 bg-emerald-200/90 px-1 py-0.2 rounded shrink-0",children:"N"}),f.jsx("span",{className:"font-bold tracking-tight",children:y(e.date_naissance)}),e.lieu_naissance&&f.jsxs("span",{className:"text-[10px] text-slate-500 font-normal truncate max-w-[100px]",children:["(",e.lieu_naissance,")"]}),o(e.date_naissance)!==null&&!e.date_deces&&f.jsxs("span",{className:"text-emerald-600 font-extrabold text-[10px] shrink-0",children:["(",o(e.date_naissance),"a)"]})]}):f.jsxs("div",{className:"flex items-center gap-1.5 text-orange-800 bg-orange-50 px-2 py-0.5 rounded-md border border-orange-200/80 w-fit",children:[f.jsx("span",{className:"font-black text-[10px] text-orange-900 bg-orange-200 px-1 rounded shrink-0",children:"N"}),f.jsx("span",{className:"font-bold text-[10px] italic text-orange-600",children:"Date de naissance manquante"})]}),e.date_mariage&&f.jsxs("div",{className:"flex items-center gap-1.5 text-rose-800 bg-rose-50 px-2 py-0.5 rounded-md border border-rose-200/60 w-fit shadow-xs",children:[f.jsx("span",{className:"font-black text-[10px] text-rose-900 bg-rose-200/90 px-1 py-0.2 rounded shrink-0",children:"M"}),f.jsx("span",{className:"font-bold tracking-tight",children:y(e.date_mariage)}),e.lieu_mariage&&f.jsxs("span",{className:"text-[10px] text-slate-500 font-normal truncate max-w-[90px]",children:["(",e.lieu_mariage,")"]})]}),e.date_divorce&&f.jsxs("div",{className:"flex items-center gap-1.5 text-purple-800 bg-purple-50 px-2 py-0.5 rounded-md border border-purple-200/60 w-fit shadow-xs",children:[f.jsx("span",{className:"font-black text-[10px] text-purple-900 bg-purple-200/90 px-1 py-0.2 rounded shrink-0",children:"Div"}),f.jsx("span",{className:"font-bold tracking-tight",children:y(e.date_divorce)}),e.lieu_divorce&&f.jsxs("span",{className:"text-[10px] text-slate-500 font-normal truncate max-w-[90px]",children:["(",e.lieu_divorce,")"]})]}),e.date_deces&&f.jsxs("div",{className:"flex items-center gap-1.5 text-slate-800 bg-slate-100 px-2 py-0.5 rounded-md border border-slate-300/80 w-fit shadow-xs",children:[f.jsx("span",{className:"font-black text-[10px] text-slate-900 bg-slate-300 px-1 py-0.2 rounded shrink-0",children:"† D"}),f.jsx("span",{className:"font-bold tracking-tight",children:y(e.date_deces)}),e.lieu_deces&&f.jsxs("span",{className:"text-[10px] text-slate-500 font-normal truncate max-w-[90px]",children:["(",e.lieu_deces,")"]})]}),e.profession?f.jsxs("div",{className:"flex items-center gap-1.5 text-slate-600 truncate mt-0.5",children:[f.jsx(Wp,{className:"text-slate-400 shrink-0",size:10}),f.jsx("span",{className:"truncate font-semibold text-slate-500 text-[10px]",children:e.profession})]}):f.jsx("div",{className:"flex items-center gap-1.5 text-orange-600 truncate mt-0.5",children:f.jsx("span",{className:"text-[10px] italic text-orange-500 font-bold",children:"💼 Profession non renseignée"})})]})]})]}),!s&&e.biographie&&f.jsxs("div",{className:"mt-2.5 pt-2 border-t border-purple-200/60 flex flex-col gap-1",children:[f.jsx("div",{className:"flex items-center gap-1",children:f.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-gradient-to-r from-purple-600 via-fuchsia-600 to-indigo-600 text-white font-black text-[9px] shadow-sm flex items-center gap-1 border border-purple-300/40",children:[f.jsx("span",{children:"✨"})," Résumé IA"]})}),f.jsxs("p",{className:"text-[11px] text-purple-950 font-medium italic line-clamp-2 leading-relaxed bg-purple-50/80 p-1.5 rounded-xl border border-purple-100/90 shadow-xs",children:['"',e.biographie.replace(/<[^>]*>?/gm,"").trim(),'"']})]}),!s&&f.jsxs("div",{className:"absolute -right-3 -bottom-3 opacity-0 group-hover:opacity-100 transition-opacity duration-300",onMouseEnter:()=>i(!0),children:[f.jsx(Gn.button,{whileHover:{scale:1.2,rotate:90},whileTap:{scale:.9},className:"p-2.5 bg-emerald-500 text-white rounded-full shadow-lg hover:bg-emerald-600 transition-colors",children:f.jsx(P0,{size:14})}),f.jsx(Da,{children:r&&f.jsxs(Gn.div,{initial:{opacity:0,scale:.8,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.8,y:10},className:"absolute bottom-full right-0 mb-2 w-48 bg-white/95 backdrop-blur-xl rounded-2xl shadow-2xl border border-slate-100 z-50 py-2 overflow-hidden transform origin-bottom-right",children:[f.jsxs("button",{onClick:()=>x("parent"),className:"w-full text-left px-5 py-3 text-sm text-slate-700 hover:bg-emerald-50 flex items-center font-medium transition-colors",children:[f.jsx(i2e,{className:"mr-3 text-emerald-500",size:18})," Ajouter un parent"]}),f.jsxs("button",{onClick:()=>x("child"),className:"w-full text-left px-5 py-3 text-sm text-slate-700 hover:bg-emerald-50 flex items-center font-medium transition-colors",children:[f.jsx(Jpe,{className:"mr-3 text-emerald-500",size:16})," Ajouter un enfant"]}),f.jsxs("button",{onClick:()=>x("spouse"),className:"w-full text-left px-5 py-3 text-sm text-slate-700 hover:bg-rose-50 flex items-center font-medium transition-colors",children:[f.jsx($pe,{className:"mr-3 text-rose-400",size:16})," Ajouter conjoint"]}),f.jsxs("button",{onClick:C=>{C.stopPropagation(),i(!1);const k=n.onConnectRelative||e.onConnectRelative;k&&k(e)},className:"w-full text-left px-5 py-3 text-sm text-sky-800 hover:bg-sky-50 flex items-center font-bold transition-colors border-t border-slate-100",children:[f.jsx(xM,{className:"mr-3 text-sky-600",size:15})," 🔗 Relier à un membre..."]}),e.conjoint&&f.jsxs("button",{onClick:C=>{C.stopPropagation(),i(!1);const k=prompt("Date de mariage avec conjoint actuel (YYYY-MM-DD) ?");k&&fetch(`https://famille.ravin-cloud.fr/api/people/${e.slug}/update`,{method:"POST",credentials:"include",body:JSON.stringify({date_mariage:k}),headers:{"Content-Type":"application/json"}}).then(()=>window.location.reload())},className:"w-full text-left px-5 py-3 text-sm text-slate-700 hover:bg-rose-50 flex items-center font-medium transition-colors border-t border-slate-100",children:[f.jsx(Y0,{className:"mr-3 text-rose-400",size:16})," Date de mariage"]})]})})]})]})}),rHe="https://famille.ravin-cloud.fr";function iHe({nodes:n=[],edges:e=[],onNodeClick:t,onAddRelative:r,onAvatarClick:i,onSwitchTo2D:s}){var U,z,O,V;const[a,o]=de.useState(null),[l,c]=de.useState([]),[u,d]=de.useState(""),[h,p]=de.useState("");de.useEffect(()=>{if(!a&&n.length>0){const $=n.filter(H=>{var K,W;return!((K=H.data)!=null&&K.is_placeholder)&&((W=H.data)==null?void 0:W.slug)}),G=$.find(H=>{var K,W;return((K=H.data)==null?void 0:K.photo_url)||((W=H.data)==null?void 0:W.photo)});G?o(G.data.slug):$.length>0&&o($[0].data.slug)}},[n,a]);const g=de.useMemo(()=>{const $=new Set(n.filter(G=>{var H,K;return!((H=G.data)!=null&&H.is_placeholder)&&((K=G.data)==null?void 0:K.nom)}).map(G=>G.data.nom.toUpperCase()));return Array.from($).sort()},[n]),x=de.useMemo(()=>{const $={};return n.forEach(G=>{var H;(H=G.data)!=null&&H.slug&&($[G.data.slug]=G.data)}),$},[n]),_=x[a]||null,y=de.useMemo(()=>{if(!u||u.length<2)return[];const $=u.toLowerCase();return n.filter(G=>{var H;return!((H=G.data)!=null&&H.is_placeholder)}).map(G=>G.data).filter(G=>`${G.prenom||""} ${G.nom||""} ${G.nom_jeune_fille||""} ${G.nom_naissance||""} ${G.surnom||""}`.toLowerCase().includes($)).slice(0,8)},[n,u]),M=de.useMemo(()=>{if(!a)return{parents:[],children:[],spouse:null,siblings:[]};const $=[],G=[];let H=null;e.forEach(W=>{W.target===a&&W.label!=="conjoint"&&!W.source.includes("placeholder")&&$.push(W.source),W.source===a&&W.label!=="conjoint"&&!W.target.includes("placeholder")&&G.push(W.target),W.label==="conjoint"&&(W.source===a&&!W.target.includes("placeholder")&&(H=W.target),W.target===a&&!W.source.includes("placeholder")&&(H=W.source))});const K=new Set;return $.length>0&&e.forEach(W=>{$.includes(W.source)&&W.label!=="conjoint"&&W.target!==a&&!W.target.includes("placeholder")&&K.add(W.target)}),{parents:$.map(W=>x[W]).filter(Boolean),children:G.map(W=>x[W]).filter(Boolean),spouse:H?x[H]:null,siblings:Array.from(K).map(W=>x[W]).filter(Boolean)}},[a,e,x]),C=$=>{!$||$===a||(a&&c(G=>[...G,a]),o($),d(""))},k=()=>{if(l.length===0)return;const $=l[l.length-1];c(G=>G.slice(0,-1)),o($)},B=$=>{if(!$)return null;let G=$.photo_url||$.photo||null;return G&&G.startsWith("/")&&(G=`${rHe}${G}`),G};return f.jsxs("div",{className:"w-full flex flex-col gap-4 p-3 sm:p-5 bg-gradient-to-b from-slate-900 via-slate-800 to-slate-950 text-white rounded-3xl min-h-[82vh] shadow-2xl border border-slate-700/60 overflow-hidden",children:[f.jsxs("div",{className:"flex flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xl",children:"📱"}),f.jsx("span",{className:"font-extrabold text-base text-emerald-400 tracking-tight",children:"Navigateur Arbre Mobile"})]}),f.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-slate-700/80 hover:bg-slate-600 text-xs font-bold text-slate-200 border border-slate-600 transition-all active:scale-95",children:[f.jsx(X4,{className:"text-emerald-400"}),f.jsx("span",{children:"Vue 2D Graphique"})]})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 relative z-30",children:[f.jsxs("div",{className:"relative",children:[f.jsxs("div",{className:"flex items-center bg-slate-800/90 border border-slate-700 rounded-2xl px-3 py-2 text-sm focus-within:border-emerald-500 transition-all",children:[f.jsx(X0,{className:"text-slate-400 mr-2 shrink-0"}),f.jsx("input",{type:"text",value:u,onChange:$=>d($.target.value),placeholder:"Rechercher un membre...",className:"bg-transparent border-none outline-none text-white placeholder-slate-400 text-xs sm:text-sm w-full font-semibold"}),u&&f.jsx("button",{onClick:()=>d(""),className:"text-slate-400 hover:text-white text-xs px-1",children:"✕"})]}),y.length>0&&f.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 bg-slate-800/95 backdrop-blur-xl border border-slate-700 rounded-2xl shadow-2xl overflow-hidden z-50 max-h-60 overflow-y-auto",children:y.map($=>{var G,H;return f.jsxs("div",{onClick:()=>C($.slug),className:"flex items-center gap-3 p-3 hover:bg-slate-700/70 cursor-pointer border-b border-slate-700/50 last:border-none",children:[f.jsx("div",{className:"w-8 h-8 rounded-full bg-emerald-600/30 text-emerald-300 font-bold flex items-center justify-center text-xs overflow-hidden shrink-0 border border-emerald-500/40",children:B($)?f.jsx("img",{src:B($),alt:"",className:"w-full h-full object-cover"}):f.jsxs("span",{children:[((G=$.prenom)==null?void 0:G[0])||"?",((H=$.nom)==null?void 0:H[0])||""]})}),f.jsxs("div",{className:"flex flex-col",children:[f.jsxs("span",{className:"font-bold text-xs text-white",children:[$.prenom," ",$.nom]}),f.jsx("span",{className:"text-[10px] text-slate-400",children:$.date_naissance||$.annee_naissance||"Année inconnue"})]})]},$.slug)})})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("select",{value:h,onChange:$=>{if(p($.target.value),$.target.value){const G=n.find(H=>{var K,W,J;return!((K=H.data)!=null&&K.is_placeholder)&&((J=(W=H.data)==null?void 0:W.nom)==null?void 0:J.toUpperCase())===$.target.value});G&&C(G.data.slug)}},className:"w-full bg-slate-800/90 border border-slate-700 rounded-2xl px-3 py-2 text-xs font-semibold text-slate-200 outline-none focus:border-emerald-500 cursor-pointer",children:[f.jsxs("option",{value:"",children:["🌍 Toutes les Familles (",g.length,")"]}),g.map($=>f.jsxs("option",{value:$,children:["Famille ",$]},$))]}),l.length>0&&f.jsxs("button",{onClick:k,className:"flex items-center gap-1 px-3 py-2 bg-emerald-600/30 border border-emerald-500/50 text-emerald-300 rounded-2xl text-xs font-bold hover:bg-emerald-600/50 shrink-0",title:"Retour au membre précédent",children:[f.jsx(aCe,{})," ",f.jsx("span",{children:l.length})]})]})]})]}),_?f.jsx(Da,{mode:"wait",children:f.jsxs(Gn.div,{initial:{opacity:0,y:15},animate:{opacity:1,y:0},exit:{opacity:0,y:-15},transition:{duration:.25},className:"flex flex-col gap-4 flex-1 overflow-y-auto pr-1",children:[f.jsxs("div",{className:"bg-slate-800/60 border border-slate-700/80 rounded-2xl p-3 flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold text-sky-400",children:[f.jsx(WCe,{})," ",f.jsx("span",{children:"PARENTS & ASCENDANTS"})]}),M.parents.length>0?f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:M.parents.map($=>{var G,H;return f.jsxs("div",{onClick:()=>C($.slug),className:"flex items-center gap-3 p-2.5 rounded-xl bg-slate-700/50 hover:bg-sky-950/40 border border-slate-600/50 hover:border-sky-500/60 cursor-pointer transition-all active:scale-98 group",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-sky-900/60 text-sky-200 font-bold flex items-center justify-center text-xs overflow-hidden shrink-0 border border-sky-400/40",children:B($)?f.jsx("img",{src:B($),alt:"",className:"w-full h-full object-cover"}):f.jsxs("span",{children:[(G=$.prenom)==null?void 0:G[0],(H=$.nom)==null?void 0:H[0]]})}),f.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[f.jsxs("span",{className:"text-xs font-bold text-white truncate group-hover:text-sky-300",children:[$.prenom," ",$.nom]}),f.jsxs("span",{className:"text-[10px] text-slate-400",children:[$.sexe==="F"?"👩 Mère":"👨 Père"," • ",$.date_naissance||$.annee_naissance||"Génération N-1"]})]}),f.jsx(_A,{className:"text-slate-500 group-hover:text-sky-400 text-xs shrink-0"})]},$.slug)})}):f.jsx("div",{className:"text-center py-2 text-slate-500 text-xs italic",children:"Aucun parent enregistré pour cette branche."})]}),f.jsxs("div",{className:"bg-gradient-to-br from-emerald-950/80 via-slate-800 to-slate-900 border-2 border-emerald-500/60 rounded-3xl p-4 flex flex-col gap-3 shadow-xl relative overflow-hidden",children:[f.jsx("div",{className:"absolute top-0 right-0 w-32 h-32 bg-emerald-500/10 rounded-full blur-2xl pointer-events-none"}),f.jsxs("div",{className:"flex items-start gap-4 z-10",children:[f.jsxs("div",{onClick:()=>i&&i(_.slug),className:"relative w-16 h-16 sm:w-20 sm:h-20 rounded-2xl bg-slate-800 border-2 border-emerald-400 overflow-hidden shrink-0 shadow-lg group cursor-pointer",title:"Cliquer pour modifier la photo",children:[B(_)?f.jsx("img",{src:B(_),alt:"",className:"w-full h-full object-cover"}):f.jsxs("div",{className:"w-full h-full flex items-center justify-center bg-emerald-900/60 text-emerald-200 font-extrabold text-xl",children:[(U=_.prenom)==null?void 0:U[0],(z=_.nom)==null?void 0:z[0]]}),f.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 flex items-center justify-center transition-opacity text-white",children:f.jsx(fm,{size:16})})]}),f.jsxs("div",{className:"flex flex-col flex-1 min-w-0 z-10",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsxs("span",{className:"text-base sm:text-lg font-black text-white leading-tight",children:[_.prenom," ",_.nom]}),_.sexe&&f.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-bold ${_.sexe==="F"?"bg-rose-500/20 text-rose-300 border border-rose-500/40":"bg-sky-500/20 text-sky-300 border border-sky-500/40"}`,children:_.sexe==="F"?"Femme":"Homme"})]}),(_.nom_jeune_fille||_.nom_naissance)&&(_.nom_jeune_fille||_.nom_naissance).toUpperCase()!==(_.nom||"").toUpperCase()&&f.jsxs("span",{className:"text-xs text-pink-300 italic",children:["née ",_.nom_jeune_fille||_.nom_naissance]}),_.surnom&&f.jsxs("span",{className:"text-xs text-purple-300 font-semibold",children:["« ",_.surnom," »"]}),f.jsxs("div",{className:"mt-1 flex flex-col gap-0.5 text-xs font-semibold",children:[_.date_naissance||_.annee_naissance?f.jsxs("div",{className:"text-emerald-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-emerald-900/60 text-emerald-300 px-1 rounded text-[10px] font-black",children:"N"}),f.jsx("span",{children:_.date_naissance||_.annee_naissance}),_.lieu_naissance&&f.jsxs("span",{className:"text-slate-400 text-[10px]",children:["(",_.lieu_naissance,")"]})]}):f.jsxs("div",{className:"text-orange-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-orange-900/60 text-orange-300 px-1 rounded text-[10px] font-black",children:"N"}),f.jsx("span",{className:"italic text-[10px]",children:"Date naissance inconnue"})]}),_.date_mariage&&f.jsxs("div",{className:"text-rose-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-rose-900/60 text-rose-300 px-1 rounded text-[10px] font-black",children:"💍 M"}),f.jsx("span",{children:_.date_mariage}),_.lieu_mariage&&f.jsxs("span",{className:"text-slate-400 text-[10px]",children:["(",_.lieu_mariage,")"]})]}),_.date_divorce&&f.jsxs("div",{className:"text-purple-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-purple-900/60 text-purple-300 px-1 rounded text-[10px] font-black",children:"Div"}),f.jsx("span",{children:_.date_divorce}),_.lieu_divorce&&f.jsxs("span",{className:"text-slate-400 text-[10px]",children:["(",_.lieu_divorce,")"]})]}),_.date_deces&&f.jsxs("div",{className:"text-slate-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-slate-700 text-slate-200 px-1 rounded text-[10px] font-black",children:"† D"}),f.jsx("span",{children:_.date_deces}),_.lieu_deces&&f.jsxs("span",{className:"text-slate-500 text-[10px]",children:["(",_.lieu_deces,")"]})]}),_.profession?f.jsxs("div",{className:"text-slate-300 text-xs truncate mt-0.5",children:["💼 ",_.profession]}):f.jsx("div",{className:"text-orange-400/90 text-[10px] italic",children:"⚠️ Profession non renseignée"})]})]})]}),_.biographie&&f.jsxs("div",{className:"p-2.5 rounded-2xl bg-purple-950/40 border border-purple-800/40 text-xs space-y-1 z-10",children:[f.jsx("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-gradient-to-r from-purple-600 via-fuchsia-600 to-indigo-600 text-white font-extrabold text-[9px] shadow-sm",children:"✨ Résumé IA"}),f.jsxs("p",{className:"text-purple-200 italic line-clamp-2",children:['"',_.biographie.replace(/<[^>]*>?/gm,"").trim(),'"']})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-2 pt-2 border-t border-slate-700/70 z-10",children:[f.jsxs("button",{onClick:()=>t&&t(_),className:"flex items-center justify-center gap-1.5 py-2 px-2 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs shadow-md transition-all active:scale-95",children:[f.jsx(zCe,{})," ",f.jsx("span",{children:"Discuter"})]}),f.jsxs("button",{onClick:()=>i&&i(_.slug),className:"flex items-center justify-center gap-1.5 py-2 px-2 rounded-xl bg-slate-700 hover:bg-slate-600 text-slate-200 font-bold text-xs border border-slate-600 transition-all active:scale-95",children:[f.jsx(fm,{})," ",f.jsx("span",{children:"Photo"})]}),f.jsxs("button",{onClick:()=>r&&r(_.slug,"child"),className:"flex items-center justify-center gap-1.5 py-2 px-2 rounded-xl bg-slate-700 hover:bg-slate-600 text-slate-200 font-bold text-xs border border-slate-600 transition-all active:scale-95",children:[f.jsx(P0,{})," ",f.jsx("span",{children:"Proche"})]})]})]}),M.spouse&&f.jsxs("div",{className:"bg-rose-950/30 border border-rose-800/40 rounded-2xl p-3 flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold text-rose-400",children:[f.jsx(Y0,{})," ",f.jsx("span",{children:"CONJOINT(E) & MARIAGE"})]}),f.jsxs("div",{onClick:()=>C(M.spouse.slug),className:"flex items-center gap-3 p-2.5 rounded-xl bg-slate-800/70 hover:bg-rose-950/50 border border-rose-800/30 hover:border-rose-500/60 cursor-pointer transition-all active:scale-98 group",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-rose-900/60 text-rose-200 font-bold flex items-center justify-center text-xs overflow-hidden shrink-0 border border-rose-400/40",children:B(M.spouse)?f.jsx("img",{src:B(M.spouse),alt:"",className:"w-full h-full object-cover"}):f.jsxs("span",{children:[(O=M.spouse.prenom)==null?void 0:O[0],(V=M.spouse.nom)==null?void 0:V[0]]})}),f.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[f.jsxs("span",{className:"text-xs font-bold text-white truncate group-hover:text-rose-300",children:[M.spouse.prenom," ",M.spouse.nom]}),f.jsxs("span",{className:"text-[10px] text-slate-400",children:["💍 Conjoint • ",M.spouse.date_naissance||M.spouse.annee_naissance||""]})]}),f.jsx(_A,{className:"text-slate-500 group-hover:text-rose-400 text-xs shrink-0"})]})]}),M.siblings.length>0&&f.jsxs("div",{className:"bg-slate-800/60 border border-slate-700/80 rounded-2xl p-3 flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold text-amber-400",children:[f.jsx($pe,{})," ",f.jsxs("span",{children:["FRÈRES & SŒURS (",M.siblings.length,")"]})]}),f.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1 custom-scrollbar",children:M.siblings.map($=>{var G;return f.jsxs("div",{onClick:()=>C($.slug),className:"flex items-center gap-2 px-3 py-1.5 rounded-xl bg-slate-700/60 hover:bg-amber-950/40 border border-slate-600/50 hover:border-amber-500/60 cursor-pointer shrink-0 transition-all active:scale-95 group",children:[f.jsx("div",{className:"w-6 h-6 rounded-full bg-amber-900/60 text-amber-200 font-bold flex items-center justify-center text-[10px] overflow-hidden shrink-0 border border-amber-400/40",children:B($)?f.jsx("img",{src:B($),alt:"",className:"w-full h-full object-cover"}):f.jsx("span",{children:(G=$.prenom)==null?void 0:G[0]})}),f.jsxs("span",{className:"text-xs font-semibold text-white group-hover:text-amber-300",children:[$.prenom," ",$.nom]})]},$.slug)})})]}),f.jsxs("div",{className:"bg-slate-800/60 border border-slate-700/80 rounded-2xl p-3 flex flex-col gap-2",children:[f.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold text-emerald-400",children:[f.jsx(XCe,{})," ",f.jsxs("span",{children:["ENFANTS & DESCENDANCE (",M.children.length,")"]})]}),M.children.length>0?f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:M.children.map($=>{var G,H;return f.jsxs("div",{onClick:()=>C($.slug),className:"flex items-center gap-3 p-2.5 rounded-xl bg-slate-700/50 hover:bg-emerald-950/40 border border-slate-600/50 hover:border-emerald-500/60 cursor-pointer transition-all active:scale-98 group",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-900/60 text-emerald-200 font-bold flex items-center justify-center text-xs overflow-hidden shrink-0 border border-emerald-400/40",children:B($)?f.jsx("img",{src:B($),alt:"",className:"w-full h-full object-cover"}):f.jsxs("span",{children:[(G=$.prenom)==null?void 0:G[0],(H=$.nom)==null?void 0:H[0]]})}),f.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[f.jsxs("span",{className:"text-xs font-bold text-white truncate group-hover:text-emerald-300",children:[$.prenom," ",$.nom]}),f.jsxs("span",{className:"text-[10px] text-slate-400",children:["Génération N+1 • ",$.date_naissance||$.annee_naissance||""]})]}),f.jsx(_A,{className:"text-slate-500 group-hover:text-emerald-400 text-xs shrink-0"})]},$.slug)})}):f.jsx("div",{className:"text-center py-2 text-slate-500 text-xs italic",children:"Aucun enfant enregistré pour cette personne."})]})]},_.slug)}):f.jsxs("div",{className:"flex flex-col items-center justify-center flex-1 text-slate-400 text-center p-6 gap-3",children:[f.jsx(hm,{size:40,className:"text-slate-600 animate-pulse"}),f.jsx("span",{className:"text-sm font-bold",children:"Sélectionnez une personne ci-dessus pour naviguer dans sa branche."})]})]})}const ET="https://famille.ravin-cloud.fr";function NT(n){if(!n)return null;const e=n.date_naissance||n.annee_naissance||"";if(!e)return null;const t=String(e).match(/(\d{4})/);return t?parseInt(t[1],10):null}function sHe({isOpen:n,onClose:e,sourcePerson:t,targetPerson:r,allPeople:i=[],initialRelation:s="parent_of",onSuccess:a}){const[o,l]=de.useState(r||null),[c,u]=de.useState(s),[d,h]=de.useState(""),[p,g]=de.useState(!1),[x,_]=de.useState(!1);de.useEffect(()=>{l(r||null),u(s||"parent_of"),g(!1)},[r,s,n]);const y=Rg(t),M=o?Rg(o):!1,C=NT(t),k=NT(o),B=de.useMemo(()=>{if(!i||i.length===0)return[];const O=d.toLowerCase().trim();return i.filter(V=>V.slug!==(t==null?void 0:t.slug)).filter(V=>O?`${V.prenom||""} ${V.nom||""} ${V.surnom||""}`.toLowerCase().includes(O):!0).slice(0,15)},[i,t,d]),U=de.useMemo(()=>{if(!t||!o)return null;const O=[];let V=!1,$=null;const G=(t.nom||"").trim().toUpperCase(),H=(o.nom||"").trim().toUpperCase();if(c==="parent_of"||c==="child_of"){const K=c==="parent_of"?t:o,W=c==="parent_of"?o:t,J=(K.nom||"").trim().toUpperCase(),ie=(W.nom||"").trim().toUpperCase();J&&ie&&J===ie?O.push({type:"success",title:"Cohérence patronymique parfaite",detail:`L'enfant porte bien le même nom de famille "${J}" que son parent.`}):J&&ie&&J!==ie&&($={parentNom:J,childNom:ie,childPrenom:W.prenom},O.push({type:"warning",title:"Noms de famille différents",detail:`Le parent s'appelle ${J} et l'enfant ${ie}. S'agit-il d'un nom marital ou d'une branche maternelle ?`}))}else c==="spouse"&&(G&&H&&G===H?O.push({type:"info",title:"Même nom de famille pour les conjoints",detail:`Les deux conjoints portent le nom "${G}". Préciser un nom de jeune fille si nécessaire.`}):O.push({type:"success",title:"Union familiale",detail:`Création du lien de mariage / union entre ${t.prenom} ${t.nom} et ${o.prenom} ${o.nom}.`}));if(C&&k){if(c==="parent_of"){const K=k-C;K<0?(V=!0,O.push({type:"error",title:"Incohérence chronologique critique",detail:`Le parent (${t.prenom}, né en ${C}) est né APRÈS l'enfant (${o.prenom}, né en ${k}) !`})):K<14?O.push({type:"warning",title:"Écart d'âge très faible",detail:`Seulement ${K} ans d'écart entre ${t.prenom} et ${o.prenom}.`}):O.push({type:"success",title:"Écart d'âge cohérent",detail:`${K} ans d'écart entre la naissance du parent (${C}) et de l'enfant (${k}).`})}else if(c==="child_of"){const K=C-k;K<0?(V=!0,O.push({type:"error",title:"Incohérence chronologique critique",detail:`Le parent (${o.prenom}, né en ${k}) est né APRÈS l'enfant (${t.prenom}, né en ${C}) !`})):K<14?O.push({type:"warning",title:"Écart d'âge très faible",detail:`Seulement ${K} ans d'écart entre ${o.prenom} et ${t.prenom}.`}):O.push({type:"success",title:"Écart d'âge cohérent",detail:`${K} ans d'écart générationnel (${k} ➔ ${C}).`})}else if(c==="spouse"){const K=Math.abs(C-k);O.push({type:"info",title:"Écart d'âge entre conjoints",detail:`${K} an(s) d'écart entre les époux (${C} et ${k}).`})}}return{insights:O,isChronologyError:V,nameNotice:$}},[t,o,c,C,k]);if(!n||!t)return null;const z=async()=>{if(!o){jt.error("Veuillez sélectionner la personne à relier.");return}if(U!=null&&U.isChronologyError&&!window.confirm("⚠️ Attention : Une incohérence de dates a été détectée. Voulez-vous quand même enregistrer ce lien ?"))return;_(!0);const O=jt.loading("Création du lien dans l'arbre...");try{if(c==="parent_of"){const V=Array.isArray(o.parents)?o.parents:o.parents?[o.parents]:[],G={parents:Array.from(new Set([...V,t.slug]))};if(p&&t.nom&&(G.nom_naissance=t.nom),!(await fetch(`${ET}/api/people/${o.slug}/update`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(G)})).ok)throw new Error("Échec mise à jour enfant")}else if(c==="child_of"){const V=Array.isArray(t.parents)?t.parents:t.parents?[t.parents]:[],G={parents:Array.from(new Set([...V,o.slug]))};if(p&&o.nom&&(G.nom_naissance=o.nom),!(await fetch(`${ET}/api/people/${t.slug}/update`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(G)})).ok)throw new Error("Échec mise à jour enfant")}else c==="spouse"&&await Promise.all([fetch(`${ET}/api/people/${t.slug}/update`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({conjoint:o.slug})}),fetch(`${ET}/api/people/${o.slug}/update`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({conjoint:t.slug})})]);jt.success("🎉 Lien généalogique créé avec succès !",{id:O}),a&&a(),e()}catch(V){console.error(V),jt.error("Erreur lors de la création du lien.",{id:O})}finally{_(!1)}};return f.jsx(Da,{children:f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/70 backdrop-blur-md overflow-y-auto",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},className:"bg-white/95 backdrop-blur-2xl border border-white/80 rounded-[2.5rem] shadow-[0_25px_70px_rgba(0,0,0,0.25)] max-w-2xl w-full p-6 sm:p-8 relative space-y-6 max-h-[92vh] overflow-y-auto no-scrollbar",children:[f.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-slate-100",children:[f.jsxs("div",{className:"flex items-center gap-2.5",children:[f.jsx("span",{className:"p-2.5 rounded-2xl bg-gradient-to-br from-indigo-500 to-sky-600 text-white shadow-md shadow-sky-500/20",children:f.jsx(xM,{size:18})}),f.jsxs("div",{children:[f.jsxs("h3",{className:"text-xl font-black text-slate-900 tracking-tight flex items-center gap-2",children:["Connecteur & Liens Familiaux",f.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-purple-100 text-purple-700 font-bold text-[10px] border border-purple-200 flex items-center gap-1",children:[f.jsx(ld,{size:10})," IA Native"]})]}),f.jsx("p",{className:"text-xs text-slate-500 font-medium",children:"Reliez facilement deux membres avec vérification automatique"})]})]}),f.jsx("button",{onClick:e,className:"p-2 text-slate-400 hover:text-slate-600 hover:bg-slate-100 rounded-full transition-colors",children:f.jsx($a,{size:18})})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-11 gap-3 items-center",children:[f.jsxs("div",{className:`sm:col-span-5 p-4 rounded-2xl border flex items-center gap-3.5 shadow-xs ${y?"border-rose-200 bg-gradient-to-br from-rose-50/80 via-white to-pink-50/40 text-rose-950":"border-sky-200 bg-gradient-to-br from-sky-50/80 via-white to-blue-50/40 text-sky-950"}`,children:[f.jsx(q0,{person:t,className:"w-14 h-14",rounded:"rounded-2xl",showGenderBadge:!0}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-1 text-[11px] font-black uppercase tracking-wider",children:[y?f.jsx("span",{className:"text-rose-600",children:"♀ Femme"}):f.jsx("span",{className:"text-sky-600",children:"♂ Homme"}),C&&f.jsxs("span",{className:"text-slate-400",children:["(",C,")"]})]}),f.jsxs("div",{className:"font-extrabold text-slate-900 truncate text-base",children:[t.prenom," ",f.jsx("span",{className:"uppercase font-black text-emerald-800",children:t.nom})]}),t.profession&&f.jsxs("div",{className:"text-[11px] text-slate-500 truncate",children:["💼 ",t.profession]})]})]}),f.jsx("div",{className:"sm:col-span-1 flex justify-center py-1",children:f.jsx("span",{className:"p-2.5 rounded-full bg-slate-100 text-slate-600 border border-slate-200 shadow-2xs",children:f.jsx(FCe,{size:14,className:"rotate-90 sm:rotate-0 text-emerald-600"})})}),f.jsx("div",{className:`sm:col-span-5 p-4 rounded-2xl border min-h-[90px] flex flex-col justify-center ${o?M?"border-rose-200 bg-gradient-to-br from-rose-50/80 via-white to-pink-50/40 text-rose-950":"border-sky-200 bg-gradient-to-br from-sky-50/80 via-white to-blue-50/40 text-sky-950":"border-dashed border-slate-300 bg-slate-50/70"}`,children:o?f.jsxs("div",{className:"flex items-center gap-3.5",children:[f.jsx(q0,{person:o,className:"w-14 h-14",rounded:"rounded-2xl",showGenderBadge:!0}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-1 text-[11px] font-black uppercase tracking-wider",children:[M?f.jsx("span",{className:"text-rose-600",children:"♀ Femme"}):f.jsx("span",{className:"text-sky-600",children:"♂ Homme"}),k&&f.jsxs("span",{className:"text-slate-400",children:["(",k,")"]})]}),f.jsxs("div",{className:"font-extrabold text-slate-900 truncate text-base",children:[o.prenom," ",f.jsx("span",{className:"uppercase font-black text-emerald-800",children:o.nom})]}),f.jsx("button",{onClick:()=>l(null),className:"text-[10px] text-indigo-600 hover:underline font-bold mt-0.5",children:"Changer de personne"})]})]}):f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"text-xs font-bold text-slate-700 flex items-center gap-1.5",children:[f.jsx(X0,{className:"text-slate-400"})," Choisir un membre de la famille :"]}),f.jsx("input",{type:"text",value:d,onChange:O=>h(O.target.value),placeholder:"Rechercher un prénom, nom...",className:"w-full px-3 py-1.5 text-xs rounded-xl border border-slate-200 bg-white focus:outline-none focus:ring-2 focus:ring-emerald-400"}),f.jsx("div",{className:"max-h-36 overflow-y-auto space-y-1 no-scrollbar pr-1",children:B.map(O=>f.jsxs("div",{onClick:()=>l(O),className:"p-1.5 rounded-xl hover:bg-emerald-100/60 cursor-pointer flex items-center gap-2 text-xs transition-colors",children:[f.jsx(q0,{person:O,className:"w-6 h-6 text-[8px]"}),f.jsxs("span",{className:"font-bold text-slate-800 truncate",children:[O.prenom," ",O.nom]}),NT(O)&&f.jsxs("span",{className:"text-[10px] text-slate-400",children:["(",NT(O),")"]})]},O.slug))})]})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("label",{className:"text-xs font-black uppercase tracking-wider text-slate-500",children:"Type de lien à établir :"}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[f.jsxs("button",{type:"button",onClick:()=>u("parent_of"),className:`p-3 rounded-2xl border text-left transition-all flex flex-col gap-1 ${c==="parent_of"?"border-emerald-500 bg-emerald-50/80 ring-2 ring-emerald-400/30 text-emerald-950 font-bold shadow-xs":"border-slate-200 hover:bg-slate-50 text-slate-700 font-medium"}`,children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-black text-emerald-800",children:[f.jsx(i2e,{size:16})," ",t.prenom," est le PARENT"]}),f.jsx("div",{className:"text-[11px] text-slate-500",children:o?`${o.prenom} devient son enfant`:"de l'enfant cible"})]}),f.jsxs("button",{type:"button",onClick:()=>u("child_of"),className:`p-3 rounded-2xl border text-left transition-all flex flex-col gap-1 ${c==="child_of"?"border-emerald-500 bg-emerald-50/80 ring-2 ring-emerald-400/30 text-emerald-950 font-bold shadow-xs":"border-slate-200 hover:bg-slate-50 text-slate-700 font-medium"}`,children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-black text-emerald-800",children:[f.jsx(Jpe,{size:14})," ",t.prenom," est l'ENFANT"]}),f.jsx("div",{className:"text-[11px] text-slate-500",children:o?`${o.prenom} devient son parent`:"du parent cible"})]}),f.jsxs("button",{type:"button",onClick:()=>u("spouse"),className:`p-3 rounded-2xl border text-left transition-all flex flex-col gap-1 ${c==="spouse"?"border-rose-500 bg-rose-50/80 ring-2 ring-rose-400/30 text-rose-950 font-bold shadow-xs":"border-slate-200 hover:bg-slate-50 text-slate-700 font-medium"}`,children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-black text-rose-800",children:[f.jsx(Y0,{size:14})," CONJOINTS (Union)"]}),f.jsx("div",{className:"text-[11px] text-slate-500",children:"Mariage ou partenariat"})]})]})]}),U&&f.jsxs(Gn.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:"p-4 rounded-2xl bg-gradient-to-br from-purple-50/80 via-white to-indigo-50/50 border border-purple-200 shadow-xs space-y-3",children:[f.jsx("div",{className:"flex items-center justify-between",children:f.jsxs("div",{className:"flex items-center gap-2 text-xs font-black text-purple-900 uppercase tracking-wider",children:[f.jsx("span",{className:"p-1 rounded-lg bg-purple-200 text-purple-800",children:f.jsx(ld,{size:12})}),"Analyse & Contrôles IA de la Relation"]})}),f.jsx("div",{className:"space-y-2",children:U.insights.map((O,V)=>f.jsxs("div",{className:`p-2.5 rounded-xl text-xs flex items-start gap-2.5 ${O.type==="error"?"bg-rose-100/90 text-rose-950 border border-rose-300":O.type==="warning"?"bg-amber-100/90 text-amber-950 border border-amber-300":O.type==="info"?"bg-sky-100/90 text-sky-950 border border-sky-300":"bg-emerald-100/90 text-emerald-950 border border-emerald-300"}`,children:[f.jsxs("span",{className:"mt-0.5 shrink-0",children:[O.type==="error"&&f.jsx(vM,{className:"text-rose-600"}),O.type==="warning"&&f.jsx(vM,{className:"text-amber-600"}),O.type==="info"&&f.jsx(xM,{className:"text-sky-600"}),O.type==="success"&&f.jsx(td,{className:"text-emerald-600"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"font-bold",children:O.title}),f.jsx("div",{className:"text-[11px] opacity-90",children:O.detail})]})]},V))}),U.nameNotice&&f.jsx("div",{className:"pt-2 border-t border-purple-200/60",children:f.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer select-none",children:[f.jsx("input",{type:"checkbox",checked:p,onChange:O=>g(O.target.checked),className:"mt-0.5 rounded border-purple-300 text-purple-600 focus:ring-purple-400"}),f.jsxs("span",{className:"text-xs text-purple-950 font-medium",children:["Harmoniser le patronyme : Mettre le nom de naissance de"," ",f.jsx("b",{children:U.nameNotice.childPrenom})," à"," ",f.jsxs("b",{className:"text-emerald-800",children:["« ",U.nameNotice.parentNom," »"]})]})]})})]}),f.jsxs("div",{className:"flex items-center justify-end gap-3 pt-2",children:[f.jsx("button",{type:"button",onClick:e,disabled:x,className:"px-5 py-2.5 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold text-xs transition-colors",children:"Annuler"}),f.jsxs("button",{type:"button",onClick:z,disabled:x||!o,className:"px-6 py-2.5 rounded-full bg-gradient-to-r from-emerald-600 via-teal-600 to-emerald-700 hover:from-emerald-500 hover:to-teal-500 text-white font-black text-xs shadow-lg shadow-emerald-500/25 transition-all hover:scale-105 active:scale-95 disabled:opacity-50 disabled:pointer-events-none flex items-center gap-2",children:[f.jsx(td,{}),f.jsx("span",{children:x?"Enregistrement...":"Valider & Créer le Lien"})]})]})]})})})}const Uu="https://famille.ravin-cloud.fr";function s2e({isOpen:n,onClose:e,person:t,people:r=[],onUpdatePerson:i,onNavigateToPerson:s}){var Ae,be;if(!n||!t)return null;const[a,o]=de.useState("factuel"),[l,c]=de.useState(null),[u,d]=de.useState(1),[h,p]=de.useState(!1),[g,x]=de.useState(!1),[_,y]=de.useState(!1),[M,C]=de.useState(!1),[k,B]=de.useState(!1),[U,z]=de.useState({type:"Acte de Naissance",titre:"Acte de Naissance",date:t.date_naissance||"",lieu:t.lieu_naissance||"",url:"",source:"Archives Départementales / État Civil",transcription:"",notes:""}),[O,V]=de.useState({titre:"",auteur:"",date:new Date().toLocaleDateString("fr-FR"),type:"Témoignage",contenu:""}),[$,G]=de.useState({titre:"",date:"",lieu:"",categorie:"Fait d'Histoire",description:"",impact:"",photo:""}),H=Array.isArray(t.actes_etat_civil)?t.actes_etat_civil:[],K=Array.isArray(t.textes_libres)?t.textes_libres:[],W=Array.isArray(t.evenements_remarquables)?t.evenements_remarquables:[],J=Array.isArray(t.evenements_marquants)?t.evenements_marquants:[],ie=t.photo_url||t.photo?(t.photo_url||t.photo).startsWith("/")?`${Uu}${t.photo_url||t.photo}`:t.photo_url||t.photo:null,ae=async pe=>{var ze;const ge=(ze=pe.target.files)==null?void 0:ze[0];if(!ge)return;C(!0);const Te=new FormData;Te.append("file",ge),Te.append("slug",t.slug);try{const Xe=await fetch(`${Uu}/api/people/${t.slug}/actes/upload`,{method:"POST",credentials:"include",body:Te}),Qe=await Xe.json();Xe.ok&&Qe.url?(z(ot=>({...ot,url:Qe.url})),jt.success("Document scanné téléversé avec succès !",{icon:"📜"})):jt.error(Qe.error||"Erreur lors du téléversement")}catch{jt.error("Erreur réseau lors du téléversement")}finally{C(!1)}},Q=async pe=>{if(pe.preventDefault(),!U.titre){jt.error("Veuillez saisir un titre");return}B(!0);try{const ge=await fetch(`${Uu}/api/people/${t.slug}/actes/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(U)}),Te=await ge.json();ge.ok&&Te.actes?(jt.success("Acte d'état civil enregistré !",{icon:"✅"}),i&&i({...t,actes_etat_civil:Te.actes}),p(!1),z({type:"Acte de Naissance",titre:"Acte de Naissance",date:t.date_naissance||"",lieu:t.lieu_naissance||"",url:"",source:"Archives Départementales / État Civil",transcription:"",notes:""})):jt.error(Te.error||"Erreur d'enregistrement")}catch{jt.error("Erreur de communication avec le serveur")}finally{B(!1)}},re=async pe=>{if(confirm("Voulez-vous vraiment supprimer cet acte d'état civil ?"))try{const ge=await fetch(`${Uu}/api/people/${t.slug}/actes/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({id:pe})}),Te=await ge.json();ge.ok&&Te.actes?(jt.success("Acte supprimé"),i&&i({...t,actes_etat_civil:Te.actes}),(l==null?void 0:l.id)===pe&&c(null)):jt.error(Te.error||"Erreur de suppression")}catch{jt.error("Erreur réseau")}},oe=async pe=>{if(pe.preventDefault(),!O.titre||!O.contenu){jt.error("Veuillez renseigner le titre et le contenu");return}B(!0);try{const ge=await fetch(`${Uu}/api/people/${t.slug}/textes-libres/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(O)}),Te=await ge.json();ge.ok&&Te.textes_libres?(jt.success("Récit / Témoignage enregistré !",{icon:"✍️"}),i&&i({...t,textes_libres:Te.textes_libres}),x(!1),V({titre:"",auteur:"",date:new Date().toLocaleDateString("fr-FR"),type:"Témoignage",contenu:""})):jt.error(Te.error||"Erreur d'enregistrement")}catch{jt.error("Erreur de communication avec le serveur")}finally{B(!1)}},fe=async pe=>{if(confirm("Supprimer ce texte / témoignage ?"))try{const ge=await fetch(`${Uu}/api/people/${t.slug}/textes-libres/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({id:pe})}),Te=await ge.json();ge.ok&&Te.textes_libres&&(jt.success("Texte supprimé"),i&&i({...t,textes_libres:Te.textes_libres}))}catch{jt.error("Erreur réseau")}},ee=async pe=>{if(pe.preventDefault(),!$.titre||!$.description){jt.error("Titre et description obligatoires");return}B(!0);try{const ge=await fetch(`${Uu}/api/people/${t.slug}/evenements-remarquables/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify($)}),Te=await ge.json();ge.ok&&Te.evenements_remarquables?(jt.success("Événement remarquable enregistré !",{icon:"🌟"}),i&&i({...t,evenements_remarquables:Te.evenements_remarquables}),y(!1),G({titre:"",date:"",lieu:"",categorie:"Fait d'Histoire",description:"",impact:"",photo:""})):jt.error(Te.error||"Erreur d'enregistrement")}catch{jt.error("Erreur de communication avec le serveur")}finally{B(!1)}},me=async pe=>{if(confirm("Supprimer cet événement remarquable ?"))try{const ge=await fetch(`${Uu}/api/people/${t.slug}/evenements-remarquables/delete`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({id:pe})}),Te=await ge.json();ge.ok&&Te.evenements_remarquables&&(jt.success("Événement remarquable supprimé"),i&&i({...t,evenements_remarquables:Te.evenements_remarquables}))}catch{jt.error("Erreur réseau")}};return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-2 sm:p-4 bg-slate-950/80 backdrop-blur-md overflow-y-auto",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},className:"w-full max-w-6xl max-h-[92vh] bg-slate-900 border border-amber-500/30 rounded-3xl shadow-2xl flex flex-col overflow-hidden text-slate-100 relative",children:[f.jsxs("div",{className:"px-5 py-4 bg-gradient-to-r from-slate-950 via-slate-900 to-amber-950/40 border-b border-amber-500/20 flex flex-wrap items-center justify-between gap-3 shrink-0",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[ie?f.jsx("img",{src:ie,alt:"",className:"w-11 h-11 rounded-2xl object-cover border-2 border-amber-400 shadow-md"}):f.jsx("div",{className:"w-11 h-11 rounded-2xl bg-amber-600/30 border border-amber-400/40 flex items-center justify-center text-amber-300 font-bold text-lg",children:((Ae=t.prenom)==null?void 0:Ae[0])||"📁"}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("h2",{className:"text-lg sm:text-xl font-serif font-black tracking-wide text-white",children:[t.prenom," ",f.jsx("span",{className:"uppercase text-amber-400",children:t.nom})]}),f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-amber-500/20 border border-amber-400/40 text-amber-300 text-[10px] font-bold uppercase tracking-widest",children:"📂 Dossier Vivant d'Archives"})]}),f.jsxs("p",{className:"text-xs text-slate-400 flex items-center gap-2",children:[f.jsx("span",{children:t.profession||"Profession non renseignée"}),f.jsx("span",{children:"•"}),f.jsx("span",{children:t.date_naissance||"Date de naissance inconnue"}),t.lieu_naissance&&f.jsxs("span",{children:["à ",t.lieu_naissance]})]})]})]}),f.jsx("button",{onClick:e,className:"p-2.5 rounded-2xl bg-slate-800 hover:bg-rose-600/80 hover:text-white text-slate-400 border border-slate-700 transition",title:"Fermer le dossier",children:f.jsx($a,{})})]}),f.jsxs("div",{className:"px-4 py-2.5 bg-slate-950/90 border-b border-slate-800 flex items-center gap-2 overflow-x-auto no-scrollbar shrink-0",children:[f.jsxs("button",{onClick:()=>o("factuel"),className:`px-4 py-2 rounded-xl text-xs sm:text-sm font-bold flex items-center gap-2 transition shrink-0 ${a==="factuel"?"bg-gradient-to-r from-emerald-600 to-teal-600 text-white shadow-md border border-emerald-400/50":"bg-slate-800/80 hover:bg-slate-700 text-slate-300"}`,children:[f.jsx("span",{children:"🏛️"}),f.jsx("span",{children:"Données Factuelles"})]}),f.jsxs("button",{onClick:()=>o("actes"),className:`px-4 py-2 rounded-xl text-xs sm:text-sm font-bold flex items-center gap-2 transition shrink-0 relative ${a==="actes"?"bg-gradient-to-r from-amber-600 to-yellow-600 text-white shadow-md border border-amber-400/50":"bg-slate-800/80 hover:bg-slate-700 text-slate-300"}`,children:[f.jsx("span",{children:"📜"}),f.jsx("span",{children:"Scans d'Actes d'État Civil"}),H.length>0&&f.jsx("span",{className:"px-1.5 py-0.2 bg-amber-300 text-slate-950 rounded-full text-[10px] font-black",children:H.length})]}),f.jsxs("button",{onClick:()=>o("photos"),className:`px-4 py-2 rounded-xl text-xs sm:text-sm font-bold flex items-center gap-2 transition shrink-0 ${a==="photos"?"bg-gradient-to-r from-indigo-600 to-purple-600 text-white shadow-md border border-indigo-400/50":"bg-slate-800/80 hover:bg-slate-700 text-slate-300"}`,children:[f.jsx("span",{children:"📸"}),f.jsx("span",{children:"Photos & Événements"}),J.filter(pe=>typeof pe=="object"&&(pe.photo||pe.photo_url)).length>0&&f.jsx("span",{className:"px-1.5 py-0.2 bg-purple-300 text-slate-950 rounded-full text-[10px] font-black",children:J.filter(pe=>typeof pe=="object"&&(pe.photo||pe.photo_url)).length})]}),f.jsxs("button",{onClick:()=>o("textes"),className:`px-4 py-2 rounded-xl text-xs sm:text-sm font-bold flex items-center gap-2 transition shrink-0 ${a==="textes"?"bg-gradient-to-r from-sky-600 to-blue-600 text-white shadow-md border border-sky-400/50":"bg-slate-800/80 hover:bg-slate-700 text-slate-300"}`,children:[f.jsx("span",{children:"✍️"}),f.jsx("span",{children:"Textes Libres & Témoignages"}),K.length>0&&f.jsx("span",{className:"px-1.5 py-0.2 bg-sky-300 text-slate-950 rounded-full text-[10px] font-black",children:K.length})]}),f.jsxs("button",{onClick:()=>o("remarquables"),className:`px-4 py-2 rounded-xl text-xs sm:text-sm font-bold flex items-center gap-2 transition shrink-0 ${a==="remarquables"?"bg-gradient-to-r from-rose-600 to-orange-600 text-white shadow-md border border-rose-400/50":"bg-slate-800/80 hover:bg-slate-700 text-slate-300"}`,children:[f.jsx("span",{children:"🌟"}),f.jsx("span",{children:"Événements Remarquables"}),W.length>0&&f.jsx("span",{className:"px-1.5 py-0.2 bg-rose-300 text-slate-950 rounded-full text-[10px] font-black",children:W.length})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-5 space-y-6",children:[a==="factuel"&&f.jsxs(Gn.div,{initial:{opacity:0},animate:{opacity:1},className:"space-y-5",children:[f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[f.jsxs("div",{className:"p-4 bg-slate-800/70 border border-slate-700 rounded-2xl space-y-3",children:[f.jsxs("h3",{className:"text-xs font-black text-emerald-400 uppercase tracking-wider flex items-center gap-2",children:[f.jsx(HCe,{})," État Civil & Identité"]}),f.jsxs("div",{className:"space-y-2 text-xs",children:[f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Prénom & Nom :"}),f.jsxs("span",{className:"font-bold text-white",children:[t.prenom," ",t.nom]})]}),t.nom_jeune_fille&&f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Nom de jeune fille :"}),f.jsx("span",{className:"font-bold text-amber-300",children:t.nom_jeune_fille})]}),t.surnom&&f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Surnom :"}),f.jsxs("span",{className:"font-bold text-purple-300",children:["« ",t.surnom," »"]})]}),f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Sexe :"}),f.jsx("span",{className:"font-bold text-white",children:t.sexe==="F"?"Femme ♀":"Homme ♂"})]}),f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Profession :"}),f.jsx("span",{className:"font-bold text-emerald-300",children:t.profession||"Non renseignée"})]})]})]}),f.jsxs("div",{className:"p-4 bg-slate-800/70 border border-slate-700 rounded-2xl space-y-3",children:[f.jsxs("h3",{className:"text-xs font-black text-amber-400 uppercase tracking-wider flex items-center gap-2",children:[f.jsx(B_,{})," Dates & Lieux Notables"]}),f.jsxs("div",{className:"space-y-2 text-xs",children:[f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Naissance :"}),f.jsxs("span",{className:"font-bold text-emerald-300",children:[t.date_naissance||"Inconnue"," ",t.lieu_naissance?`(${t.lieu_naissance})`:""]})]}),f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Mariage :"}),f.jsxs("span",{className:"font-bold text-rose-300",children:[t.date_mariage||"Non renseigné"," ",t.lieu_mariage?`(${t.lieu_mariage})`:""]})]}),f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Décès :"}),f.jsxs("span",{className:"font-bold text-slate-300",children:[t.date_deces||"Vivant(e) ou Inconnu"," ",t.lieu_deces?`(${t.lieu_deces})`:""]})]}),f.jsxs("div",{className:"flex justify-between border-b border-slate-700/50 pb-1",children:[f.jsx("span",{className:"text-slate-400",children:"Union :"}),f.jsx("span",{className:"font-bold text-sky-300",children:t.statut_union||"En couple"})]})]})]}),f.jsxs("div",{className:"p-4 bg-slate-800/70 border border-slate-700 rounded-2xl space-y-3",children:[f.jsxs("h3",{className:"text-xs font-black text-sky-400 uppercase tracking-wider flex items-center gap-2",children:[f.jsx(jA,{})," Filiation Directe"]}),f.jsxs("div",{className:"space-y-2 text-xs",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-slate-400 block mb-1",children:"Parents :"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:t.parents&&t.parents.length>0?t.parents.map(pe=>{const ge=r.find(Te=>Te.slug===pe);return f.jsx("button",{onClick:()=>ge&&s&&s(ge),className:"px-2.5 py-1 bg-emerald-950/60 hover:bg-emerald-800/60 border border-emerald-500/40 rounded-lg text-emerald-300 font-bold",children:ge?`${ge.prenom} ${ge.nom}`:pe.replace(/-/g," ")},pe)}):f.jsx("span",{className:"text-slate-500 italic",children:"Non renseignés"})})]}),f.jsxs("div",{children:[f.jsx("span",{className:"text-slate-400 block mb-1",children:"Conjoint(e) :"}),t.conjoint?(()=>{const pe=r.find(ge=>ge.slug===t.conjoint);return f.jsx("button",{onClick:()=>pe&&s&&s(pe),className:"px-2.5 py-1 bg-rose-950/60 hover:bg-rose-800/60 border border-rose-500/40 rounded-lg text-rose-300 font-bold",children:pe?`${pe.prenom} ${pe.nom}`:t.conjoint.replace(/-/g," ")})})():f.jsx("span",{className:"text-slate-500 italic",children:"Aucun conjoint répertorié"})]})]})]})]}),t.biographie&&f.jsxs("div",{className:"p-5 bg-slate-800/50 border border-slate-700/80 rounded-3xl space-y-2",children:[f.jsxs("h3",{className:"text-xs font-black text-amber-400 uppercase tracking-wider flex items-center gap-2",children:[f.jsx(xH,{})," Récit de Vie & Histoire"]}),f.jsx("p",{className:"text-xs sm:text-sm text-slate-300 leading-relaxed whitespace-pre-wrap font-sans",children:t.biographie})]})]}),a==="actes"&&f.jsxs(Gn.div,{initial:{opacity:0},animate:{opacity:1},className:"space-y-5",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[f.jsx("span",{children:"📜"})," Scans & Pièces Justificatives Officielles"]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Archives d'état civil, actes de naissance, baptêmes, mariages, décès, livrets de famille."})]}),f.jsxs("button",{onClick:()=>p(!0),className:"px-3.5 py-2 bg-gradient-to-r from-amber-500 to-yellow-600 hover:from-amber-400 hover:to-yellow-500 text-slate-950 font-black rounded-xl text-xs flex items-center gap-1.5 transition shadow-md hover:scale-105 active:scale-95",children:[f.jsx(P0,{})," Ajouter un Acte Scanné"]})]}),H.length>0?f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:H.map((pe,ge)=>{var Xe;const Te=pe.url?pe.url.startsWith("http")?pe.url:pe.url.startsWith("/")?`${Uu}${pe.url}`:`${Uu}/${pe.url}`:null,ze=(Xe=pe.url)==null?void 0:Xe.toLowerCase().endsWith(".pdf");return f.jsxs("div",{className:"p-4 bg-slate-800/80 hover:bg-slate-800 border border-amber-500/30 rounded-2xl shadow-md space-y-3 transition flex flex-col justify-between group",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-amber-500/20 text-amber-300 font-black text-[10px] uppercase tracking-wider border border-amber-400/30",children:pe.type||"Acte officiel"}),f.jsx("button",{onClick:()=>re(pe.id),className:"p-1.5 text-slate-500 hover:text-rose-400 opacity-0 group-hover:opacity-100 transition rounded-lg hover:bg-slate-700",title:"Supprimer cet acte",children:f.jsx(z0,{size:12})})]}),f.jsx("h4",{className:"font-bold text-white text-sm",children:pe.titre}),f.jsxs("div",{className:"text-xs text-slate-400 space-y-0.5",children:[pe.date&&f.jsxs("p",{className:"flex items-center gap-1",children:["📅 Date : ",f.jsx("strong",{className:"text-slate-200",children:pe.date})]}),pe.lieu&&f.jsxs("p",{className:"flex items-center gap-1",children:["📍 Lieu : ",f.jsx("strong",{className:"text-slate-200",children:pe.lieu})]}),pe.source&&f.jsxs("p",{className:"text-[11px] text-amber-200/70 italic",children:["🏛️ ",pe.source]})]}),Te&&f.jsxs("div",{className:"relative rounded-xl overflow-hidden border border-slate-700 bg-slate-950 aspect-video flex items-center justify-center group/preview",children:[ze?f.jsxs("div",{className:"text-center p-4",children:[f.jsx(Qpe,{className:"text-rose-400 text-3xl mx-auto mb-1"}),f.jsx("span",{className:"text-[11px] text-slate-300 font-mono",children:"Document PDF"})]}):f.jsx("img",{src:Te,alt:"",className:"w-full h-full object-cover group-hover/preview:scale-105 transition duration-300"}),f.jsxs("button",{onClick:()=>c(pe),className:"absolute inset-0 bg-slate-950/60 opacity-0 group-hover/preview:opacity-100 flex items-center justify-center gap-2 text-white font-bold text-xs transition backdrop-blur-2xs",children:[f.jsx(yK,{})," Ouvrir & Inspecter"]})]}),pe.transcription&&f.jsxs("div",{className:"p-2.5 bg-slate-900/90 rounded-xl border border-slate-700/60 text-xs text-slate-300 italic font-serif leading-relaxed line-clamp-3",children:["« ",pe.transcription," »"]})]}),f.jsxs("div",{className:"pt-2 flex items-center justify-between border-t border-slate-700/60 text-xs",children:[f.jsxs("button",{onClick:()=>c(pe),className:"text-amber-400 hover:text-amber-300 font-bold flex items-center gap-1.5",children:[f.jsx(Kpe,{})," Déchiffrer & Zoomer"]}),Te&&f.jsx("a",{href:Te,download:!0,target:"_blank",rel:"noopener noreferrer",className:"text-slate-400 hover:text-white p-1",title:"Télécharger l'acte",children:f.jsx(T3,{size:12})})]})]},pe.id||ge)})}):f.jsxs("div",{className:"p-10 text-center bg-slate-800/40 rounded-3xl border border-dashed border-slate-700 space-y-3",children:[f.jsx("div",{className:"text-4xl",children:"📜"}),f.jsx("h4",{className:"font-bold text-slate-300",children:"Aucun acte d'état civil numérisé"}),f.jsx("p",{className:"text-xs text-slate-400 max-w-md mx-auto",children:"Numérisez et associez les actes de naissance, mariage ou décès pour donner une valeur historique authentique à cette fiche."}),f.jsxs("button",{onClick:()=>p(!0),className:"px-4 py-2 bg-amber-500 hover:bg-amber-400 text-slate-950 font-black rounded-xl text-xs inline-flex items-center gap-1.5 transition shadow-md",children:[f.jsx(P0,{})," Ajouter le premier acte scanné"]})]})]}),a==="photos"&&f.jsxs(Gn.div,{initial:{opacity:0},animate:{opacity:1},className:"space-y-5",children:[f.jsxs("div",{children:[f.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[f.jsx("span",{children:"📸"})," Photothèque de Vie & Moments Marquants"]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Photos historiques, portraits et clichés associés aux événements de vie."})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:[ie&&f.jsxs("div",{className:"p-3 bg-slate-800/70 border border-slate-700 rounded-2xl space-y-2",children:[f.jsx("span",{className:"text-[10px] font-black uppercase text-amber-300",children:"Photo Principale"}),f.jsx("div",{className:"aspect-square rounded-xl overflow-hidden bg-slate-950",children:f.jsx("img",{src:ie,alt:"",className:"w-full h-full object-cover"})}),f.jsxs("p",{className:"text-xs font-bold text-white text-center",children:[t.prenom," ",t.nom]})]}),J.filter(pe=>typeof pe=="object"&&(pe.photo||pe.photo_url)).map((pe,ge)=>{const Te=pe.photo||pe.photo_url,ze=Te.startsWith("http")?Te:Te.startsWith("/")?`${Uu}${Te}`:`${Uu}/${Te}`;return f.jsxs("div",{className:"p-3 bg-slate-800/70 border border-slate-700 rounded-2xl space-y-2",children:[f.jsx("span",{className:"text-[10px] font-black uppercase text-purple-300",children:pe.date||"Moment marquant"}),f.jsx("div",{className:"aspect-square rounded-xl overflow-hidden bg-slate-950",children:f.jsx("img",{src:ze,alt:"",className:"w-full h-full object-cover hover:scale-105 transition"})}),f.jsx("p",{className:"text-xs font-bold text-white truncate",children:pe.titre||pe.title||pe.description})]},ge)})]})]}),a==="textes"&&f.jsxs(Gn.div,{initial:{opacity:0},animate:{opacity:1},className:"space-y-5",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[f.jsx("span",{children:"✍️"})," Textes Libres, Récits & Lettres de Famille"]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Témoignages intimes, correspondances, lettres de guerre, récits oraux transcrits."})]}),f.jsxs("button",{onClick:()=>x(!0),className:"px-3.5 py-2 bg-gradient-to-r from-sky-500 to-blue-600 hover:from-sky-400 hover:to-blue-500 text-white font-black rounded-xl text-xs flex items-center gap-1.5 transition shadow-md hover:scale-105 active:scale-95",children:[f.jsx(P0,{})," Rédiger un Texte Libre"]})]}),K.length>0?f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:K.map((pe,ge)=>f.jsxs("div",{className:"p-5 bg-slate-800/80 border border-sky-500/30 rounded-3xl space-y-3 relative group shadow-md",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-slate-700/60 pb-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-sky-500/20 text-sky-300 font-black text-[10px] uppercase tracking-wider border border-sky-400/30",children:pe.type||"Témoignage"}),f.jsxs("span",{className:"text-xs text-slate-400",children:["par ",f.jsx("strong",{className:"text-slate-200",children:pe.auteur})]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-[11px] text-slate-500",children:pe.date}),f.jsx("button",{onClick:()=>fe(pe.id),className:"p-1.5 text-slate-500 hover:text-rose-400 opacity-0 group-hover:opacity-100 transition rounded-lg hover:bg-slate-700",title:"Supprimer ce texte",children:f.jsx(z0,{size:12})})]})]}),f.jsx("h4",{className:"font-serif font-black text-white text-sm",children:pe.titre}),f.jsxs("div",{className:"p-3.5 bg-slate-900/90 rounded-2xl border border-slate-700/50 text-xs sm:text-sm text-slate-200 leading-relaxed italic font-serif whitespace-pre-wrap",children:[f.jsx(hH,{className:"text-sky-500/40 mb-1"}),pe.contenu]})]},pe.id||ge))}):f.jsxs("div",{className:"p-10 text-center bg-slate-800/40 rounded-3xl border border-dashed border-slate-700 space-y-3",children:[f.jsx("div",{className:"text-4xl",children:"✍️"}),f.jsx("h4",{className:"font-bold text-slate-300",children:"Aucun texte libre ou témoignage enregistré"}),f.jsx("p",{className:"text-xs text-slate-400 max-w-md mx-auto",children:"Partagez un souvenir, une lettre d'époque ou une anecdote rédigée librement pour transmettre l'âme de cette personne."}),f.jsxs("button",{onClick:()=>x(!0),className:"px-4 py-2 bg-sky-500 hover:bg-sky-400 text-white font-black rounded-xl text-xs inline-flex items-center gap-1.5 transition shadow-md",children:[f.jsx(P0,{})," Rédiger le premier témoignage"]})]})]}),a==="remarquables"&&f.jsxs(Gn.div,{initial:{opacity:0},animate:{opacity:1},className:"space-y-5",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[f.jsx("span",{children:"🌟"})," Événements Remarquables (au sens propre)"]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Faits d'histoire, décorations, actes de bravoure, voyages historiques, créations et tournants de vie."})]}),f.jsxs("button",{onClick:()=>y(!0),className:"px-3.5 py-2 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-400 hover:to-orange-400 text-white font-black rounded-xl text-xs flex items-center gap-1.5 transition shadow-md hover:scale-105 active:scale-95",children:[f.jsx(P0,{})," Ajouter un Événement Remarquable"]})]}),W.length>0?f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:W.map((pe,ge)=>{const Te=pe.photo?pe.photo.startsWith("http")?pe.photo:pe.photo.startsWith("/")?`${Uu}${pe.photo}`:`${Uu}/${pe.photo}`:null;return f.jsxs("div",{className:"p-5 bg-gradient-to-br from-slate-800/90 to-slate-900 border border-rose-500/30 rounded-3xl space-y-3 relative group shadow-md",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-slate-700/60 pb-2",children:[f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-rose-500/20 text-rose-300 font-black text-[10px] uppercase tracking-wider border border-rose-400/30",children:pe.categorie||"Fait d'Histoire"}),f.jsxs("div",{className:"flex items-center gap-2",children:[pe.date&&f.jsxs("span",{className:"text-xs font-mono font-bold text-amber-300",children:["📅 ",pe.date]}),f.jsx("button",{onClick:()=>me(pe.id),className:"p-1.5 text-slate-500 hover:text-rose-400 opacity-0 group-hover:opacity-100 transition rounded-lg hover:bg-slate-700",title:"Supprimer cet événement",children:f.jsx(z0,{size:12})})]})]}),f.jsx("h4",{className:"font-serif font-black text-white text-base",children:pe.titre}),pe.lieu&&f.jsxs("p",{className:"text-xs text-slate-400",children:["📍 Lieu : ",f.jsx("strong",{className:"text-slate-200",children:pe.lieu})]}),Te&&f.jsx("div",{className:"rounded-2xl overflow-hidden border border-slate-700 aspect-video bg-slate-950",children:f.jsx("img",{src:Te,alt:"",className:"w-full h-full object-cover"})}),f.jsx("p",{className:"text-xs sm:text-sm text-slate-200 leading-relaxed font-sans",children:pe.description}),pe.impact&&f.jsxs("div",{className:"p-3 bg-rose-950/40 rounded-2xl border border-rose-500/30 text-xs text-rose-200",children:[f.jsx("span",{className:"font-bold block text-[10px] uppercase tracking-wider text-rose-300 mb-0.5",children:"🌟 Impact & Portée :"}),pe.impact]})]},pe.id||ge)})}):f.jsxs("div",{className:"p-10 text-center bg-slate-800/40 rounded-3xl border border-dashed border-slate-700 space-y-3",children:[f.jsx("div",{className:"text-4xl",children:"🌟"}),f.jsx("h4",{className:"font-bold text-slate-300",children:"Aucun événement remarquable répertorié"}),f.jsx("p",{className:"text-xs text-slate-400 max-w-md mx-auto",children:"Inscrivez les faits historiques majeurs, médailles, périples ou anecdotes mémorables de sa vie."}),f.jsxs("button",{onClick:()=>y(!0),className:"px-4 py-2 bg-rose-500 hover:bg-rose-400 text-white font-black rounded-xl text-xs inline-flex items-center gap-1.5 transition shadow-md",children:[f.jsx(P0,{})," Ajouter un premier événement marquant"]})]})]})]}),f.jsx(Da,{children:l&&f.jsx("div",{className:"fixed inset-0 z-60 flex items-center justify-center p-3 bg-slate-950/90 backdrop-blur-lg",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},className:"w-full max-w-5xl max-h-[92vh] bg-slate-900 border border-amber-400/40 rounded-3xl flex flex-col overflow-hidden shadow-2xl",children:[f.jsxs("div",{className:"px-5 py-3.5 bg-slate-950 border-b border-slate-800 flex items-center justify-between",children:[f.jsxs("div",{children:[f.jsxs("h3",{className:"font-bold text-white text-sm sm:text-base flex items-center gap-2",children:[f.jsx("span",{children:"📜"})," ",l.titre]}),f.jsxs("p",{className:"text-xs text-amber-300 font-mono",children:[l.type," • ",l.date," • ",l.lieu]})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>d(pe=>Math.max(.5,pe-.25)),className:"p-2 rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-300",title:"Zoom -",children:f.jsx(mCe,{})}),f.jsxs("span",{className:"text-xs font-mono text-slate-400",children:[Math.round(u*100),"%"]}),f.jsx("button",{onClick:()=>d(pe=>Math.min(3,pe+.25)),className:"p-2 rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-300",title:"Zoom +",children:f.jsx(yK,{})}),f.jsx("button",{onClick:()=>{c(null),d(1)},className:"p-2 rounded-xl bg-rose-600 hover:bg-rose-500 text-white ml-2",children:f.jsx($a,{})})]})]}),f.jsx("div",{className:"flex-1 overflow-auto p-4 flex items-center justify-center bg-slate-950/80",children:(be=l.url)!=null&&be.toLowerCase().endsWith(".pdf")?f.jsx("iframe",{src:l.url.startsWith("http")?l.url:`${Uu}${l.url}`,className:"w-full h-[60vh] rounded-xl border border-slate-800",title:"PDF Acte"}):l.url?f.jsx("div",{className:"overflow-auto max-h-[60vh] max-w-full",children:f.jsx("img",{src:l.url.startsWith("http")?l.url:`${Uu}${l.url}`,alt:"",style:{transform:`scale(${u})`,transformOrigin:"center center"},className:"rounded-xl transition-transform duration-200 max-w-full object-contain"})}):f.jsx("p",{className:"text-slate-400 italic",children:"Aucun fichier joint."})}),l.transcription&&f.jsxs("div",{className:"p-4 bg-slate-900 border-t border-slate-800 max-h-48 overflow-y-auto space-y-1",children:[f.jsxs("span",{className:"text-[11px] font-black uppercase text-amber-400 flex items-center gap-1",children:[f.jsx("span",{children:"✍️"})," Déchiffrage & Transcription Textuelle de l'Acte :"]}),f.jsxs("p",{className:"text-xs text-slate-200 font-serif leading-relaxed italic whitespace-pre-wrap bg-slate-950/60 p-3 rounded-xl border border-slate-800",children:["« ",l.transcription," »"]})]})]})})}),f.jsx(Da,{children:h&&f.jsx("div",{className:"fixed inset-0 z-60 flex items-center justify-center p-3 bg-slate-950/80 backdrop-blur-md",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"w-full max-w-lg bg-slate-900 border border-amber-400/40 rounded-3xl p-5 space-y-4 shadow-2xl",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-2",children:[f.jsxs("h3",{className:"font-bold text-white text-sm flex items-center gap-2",children:[f.jsx("span",{children:"📜"})," Numériser un Acte d'État Civil"]}),f.jsx("button",{onClick:()=>p(!1),className:"text-slate-400 hover:text-white",children:f.jsx($a,{})})]}),f.jsxs("form",{onSubmit:Q,className:"space-y-3 text-xs",children:[f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Type d'Acte"}),f.jsxs("select",{value:U.type,onChange:pe=>z({...U,type:pe.target.value,titre:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-amber-400",children:[f.jsx("option",{value:"Acte de Naissance",children:"Acte de Naissance"}),f.jsx("option",{value:"Acte de Baptême",children:"Acte de Baptême"}),f.jsx("option",{value:"Acte de Mariage",children:"Acte de Mariage"}),f.jsx("option",{value:"Acte de Décès",children:"Acte de Décès"}),f.jsx("option",{value:"Livret de Famille",children:"Livret de Famille"}),f.jsx("option",{value:"Fiche Militaire / Matricule",children:"Fiche Militaire / Matricule"}),f.jsx("option",{value:"Carte d'Identité / Passeport",children:"Carte d'Identité / Passeport"}),f.jsx("option",{value:"Autre Document Officiel",children:"Autre Document Officiel"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Titre de la Pièce"}),f.jsx("input",{type:"text",value:U.titre,onChange:pe=>z({...U,titre:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-amber-400",placeholder:"ex: Acte de naissance de Jean",required:!0})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Date"}),f.jsx("input",{type:"text",value:U.date,onChange:pe=>z({...U,date:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-amber-400",placeholder:"ex: 14/07/1889"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Lieu"}),f.jsx("input",{type:"text",value:U.lieu,onChange:pe=>z({...U,lieu:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-amber-400",placeholder:"ex: Pondichéry, Inde"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Fichier du Scan (Image ou PDF)"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("label",{className:"px-3 py-2 bg-amber-500/20 hover:bg-amber-500/30 border border-amber-400/40 text-amber-300 font-bold rounded-xl cursor-pointer flex items-center gap-1.5 shrink-0 transition",children:[f.jsx(gM,{})," ",M?"Téléversement...":"Choisir un fichier",f.jsx("input",{type:"file",accept:"image/*,application/pdf",onChange:ae,className:"hidden"})]}),f.jsx("input",{type:"text",value:U.url,onChange:pe=>z({...U,url:pe.target.value}),placeholder:"ou collez l'URL / chemin du fichier",className:"flex-1 bg-slate-800 border border-slate-700 rounded-xl p-2 text-white text-xs"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Transcription textuelle (Déchiffrage)"}),f.jsx("textarea",{value:U.transcription,onChange:pe=>z({...U,transcription:pe.target.value}),rows:3,className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white font-serif text-xs focus:outline-none focus:border-amber-400",placeholder:"Recopiez ici le texte manuscrit de l'acte pour le rendre lisible par tous..."})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-800",children:[f.jsx("button",{type:"button",onClick:()=>p(!1),className:"px-4 py-2 bg-slate-800 text-slate-300 rounded-xl font-bold hover:bg-slate-700",children:"Annuler"}),f.jsxs("button",{type:"submit",disabled:k,className:"px-5 py-2 bg-gradient-to-r from-amber-500 to-yellow-600 hover:from-amber-400 hover:to-yellow-500 text-slate-950 font-black rounded-xl shadow-md disabled:opacity-50 flex items-center gap-1.5",children:[k?f.jsx(vu,{className:"animate-spin"}):f.jsx(td,{})," Enregistrer l'acte"]})]})]})]})})}),f.jsx(Da,{children:g&&f.jsx("div",{className:"fixed inset-0 z-60 flex items-center justify-center p-3 bg-slate-950/80 backdrop-blur-md",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"w-full max-w-lg bg-slate-900 border border-sky-400/40 rounded-3xl p-5 space-y-4 shadow-2xl",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-2",children:[f.jsxs("h3",{className:"font-bold text-white text-sm flex items-center gap-2",children:[f.jsx("span",{children:"✍️"})," Rédiger un Récit ou Témoignage"]}),f.jsx("button",{onClick:()=>x(!1),className:"text-slate-400 hover:text-white",children:f.jsx($a,{})})]}),f.jsxs("form",{onSubmit:oe,className:"space-y-3 text-xs",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Titre"}),f.jsx("input",{type:"text",value:O.titre,onChange:pe=>V({...O,titre:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-sky-400",placeholder:"ex: Souvenirs de l'été 1968, Lettre du front...",required:!0})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Auteur / Témoin"}),f.jsx("input",{type:"text",value:O.auteur,onChange:pe=>V({...O,auteur:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-sky-400",placeholder:"Votre nom ou nom du parent"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Type de texte"}),f.jsxs("select",{value:O.type,onChange:pe=>V({...O,type:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-sky-400",children:[f.jsx("option",{value:"Témoignage",children:"Témoignage"}),f.jsx("option",{value:"Lettre ancienne",children:"Lettre ancienne"}),f.jsx("option",{value:"Anecdote intime",children:"Anecdote intime"}),f.jsx("option",{value:"Hommage",children:"Hommage"}),f.jsx("option",{value:"Écrit libre",children:"Écrit libre"})]})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Contenu libre"}),f.jsx("textarea",{value:O.contenu,onChange:pe=>V({...O,contenu:pe.target.value}),rows:5,className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-3 text-white font-serif text-xs leading-relaxed focus:outline-none focus:border-sky-400",placeholder:"Rédigez librement le récit, la lettre ou l'anecdote...",required:!0})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-800",children:[f.jsx("button",{type:"button",onClick:()=>x(!1),className:"px-4 py-2 bg-slate-800 text-slate-300 rounded-xl font-bold hover:bg-slate-700",children:"Annuler"}),f.jsxs("button",{type:"submit",disabled:k,className:"px-5 py-2 bg-gradient-to-r from-sky-500 to-blue-600 hover:from-sky-400 hover:to-blue-500 text-white font-black rounded-xl shadow-md disabled:opacity-50 flex items-center gap-1.5",children:[k?f.jsx(vu,{className:"animate-spin"}):f.jsx(td,{})," Enregistrer le récit"]})]})]})]})})}),f.jsx(Da,{children:_&&f.jsx("div",{className:"fixed inset-0 z-60 flex items-center justify-center p-3 bg-slate-950/80 backdrop-blur-md",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:"w-full max-w-lg bg-slate-900 border border-rose-400/40 rounded-3xl p-5 space-y-4 shadow-2xl",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-2",children:[f.jsxs("h3",{className:"font-bold text-white text-sm flex items-center gap-2",children:[f.jsx("span",{children:"🌟"})," Ajouter un Événement Remarquable"]}),f.jsx("button",{onClick:()=>y(!1),className:"text-slate-400 hover:text-white",children:f.jsx($a,{})})]}),f.jsxs("form",{onSubmit:ee,className:"space-y-3 text-xs",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Titre de l'événement"}),f.jsx("input",{type:"text",value:$.titre,onChange:pe=>G({...$,titre:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-rose-400",placeholder:"ex: Décoration de la Légion d'Honneur, Traversée de l'Atlantique...",required:!0})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Catégorie"}),f.jsxs("select",{value:$.categorie,onChange:pe=>G({...$,categorie:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-rose-400",children:[f.jsx("option",{value:"Fait d'Histoire",children:"Fait d'Histoire"}),f.jsx("option",{value:"Décoration / Médaille",children:"Décoration / Médaille"}),f.jsx("option",{value:"Voyage d'exception",children:"Voyage d'exception"}),f.jsx("option",{value:"Acte de Bravoure / Héroïsme",children:"Acte de Bravoure / Héroïsme"}),f.jsx("option",{value:"Création / Œuvre",children:"Création / Œuvre"}),f.jsx("option",{value:"Tournant de Vie",children:"Tournant de Vie"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Date"}),f.jsx("input",{type:"text",value:$.date,onChange:pe=>G({...$,date:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-rose-400",placeholder:"ex: 1944"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Description narrative"}),f.jsx("textarea",{value:$.description,onChange:pe=>G({...$,description:pe.target.value}),rows:3,className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-rose-400",placeholder:"Racontez les détails de cet événement marquant...",required:!0})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-slate-400 font-bold mb-1",children:"Impact & Portée Historique"}),f.jsx("input",{type:"text",value:$.impact,onChange:pe=>G({...$,impact:pe.target.value}),className:"w-full bg-slate-800 border border-slate-700 rounded-xl p-2 text-white focus:outline-none focus:border-rose-400",placeholder:"ex: A marqué toute la famille, changement de pays..."})]}),f.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-slate-800",children:[f.jsx("button",{type:"button",onClick:()=>y(!1),className:"px-4 py-2 bg-slate-800 text-slate-300 rounded-xl font-bold hover:bg-slate-700",children:"Annuler"}),f.jsxs("button",{type:"submit",disabled:k,className:"px-5 py-2 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-400 hover:to-orange-400 text-white font-black rounded-xl shadow-md disabled:opacity-50 flex items-center gap-1.5",children:[k?f.jsx(vu,{className:"animate-spin"}):f.jsx(td,{})," Enregistrer"]})]})]})]})})})]})})}const jm="https://famille.ravin-cloud.fr",qse=320,Gse=160,aHe=(n,e,t="TB")=>{const r=new Cie.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:t,nodesep:150,ranksep:300,edgesep:80}),n.forEach(a=>{r.setNode(a.id,{width:qse,height:Gse})});let i=0;const s={};return e.forEach(a=>{a.relationship!=="conjoint"&&(s[a.target]||(s[a.target]=[]),s[a.target].push(a.source))}),e.forEach(a=>{if(a.relationship==="conjoint"){const o=`dummy_child_for_spouses_${i++}`;r.setNode(o,{width:1,height:1,weight:1}),r.setEdge(a.source,o,{weight:1}),r.setEdge(a.target,o,{weight:1});const l=s[a.source]||[],c=s[a.target]||[];l.length>0&&c.length===0?(console.log("Adding invis edge:",l[0],a.target),r.setEdge(l[0],a.target,{weight:0})):c.length>0&&l.length===0&&(console.log("Adding invis edge:",c[0],a.source),r.setEdge(c[0],a.source,{weight:0}))}else r.setEdge(a.source,a.target,{weight:2})}),Cie.layout(r),n.forEach(a=>{const o=r.node(a.id);a.targetPosition=t==="TB"?"top":"left",a.sourcePosition=t==="TB"?"bottom":"right",a.position={x:o.x-qse/2,y:o.y-Gse/2}}),e.forEach(a=>{if(a.relationship==="conjoint"||a.label==="conjoint"){const o=n.find(c=>c.id===a.source),l=n.find(c=>c.id===a.target);if(o&&l){const c=Math.max(o.position.y,l.position.y);o.position.y=c,l.position.y=c,o.position.x{const[r,i]=de.useState([]),[s,a]=de.useState([]),[o,l]=de.useState([]),[c,u]=de.useState([]),[d,h]=de.useState(""),{fitView:p,getNodes:g,setCenter:x}=U7(),[_,y]=de.useState(!1),[M,C]=de.useState(null),[k,B]=de.useState(!1),[U,z]=de.useState("TB"),[O,V]=de.useState(""),[$,G]=de.useState(2),[H,K]=de.useState(null),[W,J]=de.useState(!1),[ie,ae]=de.useState(!1),[Q,re]=de.useState(null),[oe,fe]=de.useState(!1),[ee,me]=de.useState({query:"",branch:"all",era:"all",status:"all",gender:"all",completeness:"all",city:"",profession:"",sortBy:"name_asc"}),[Ae,be]=de.useState("heredis"),[pe,ge]=de.useState("xxl"),[Te,ze]=de.useState(null),[Xe,Qe]=de.useState(!1),[ot,bt]=de.useState(!1),[ht,Ce]=de.useState({parents:!0,spouses:!0,children:!0,siblings:!0,grandparents:!1}),lt=$e=>{Ce(ut=>({...ut,[$e]:!ut[$e]}))},ft=de.useMemo(()=>o.filter($e=>!$e.data.is_placeholder).sort(($e,ut)=>{const Gt=`${$e.data.prenom||""} ${$e.data.nom||""}`.trim(),it=`${ut.data.prenom||""} ${ut.data.nom||""}`.trim();return Gt.localeCompare(it)}),[o]),et=de.useMemo(()=>{const $e={};return o.forEach(ut=>{var it,Ot;if((it=ut.data)!=null&&it.is_placeholder)return;const Gt=(((Ot=ut.data)==null?void 0:Ot.nom)||"").trim().toUpperCase();Gt&&($e[Gt]=($e[Gt]||0)+1)}),Object.entries($e).sort((ut,Gt)=>Gt[1]-ut[1]).map(([ut,Gt])=>({name:ut,count:Gt}))},[o]),At=de.useMemo(()=>{let $e=ft;const ut=(ee.query||d||"").trim().toLowerCase();if(ut&&($e=$e.filter(Gt=>{const it=`${Gt.data.prenom||""} ${Gt.data.nom||""}`.toLowerCase(),Ot=(Gt.data.surnom||"").toLowerCase(),nn=`${Gt.data.lieu_naissance||""} ${Gt.data.lieu_mariage||""} ${Gt.data.lieu_deces||""}`.toLowerCase(),Nt=(Gt.data.profession||"").toLowerCase(),m=`${Gt.data.date_naissance||Gt.data.annee_naissance||""} ${Gt.data.date_deces||Gt.data.annee_deces||""}`.toLowerCase();return it.includes(ut)||Ot.includes(ut)||nn.includes(ut)||Nt.includes(ut)||m.includes(ut)})),ee.branch&&ee.branch!=="all"&&($e=$e.filter(Gt=>(Gt.data.nom||"").trim().toUpperCase()===ee.branch.toUpperCase())),ee.gender&&ee.gender!=="all"&&($e=$e.filter(Gt=>{const it=(Gt.data.sexe||"").trim().toLowerCase();return ee.gender==="male"?it==="m"||it==="homme"||it==="h":ee.gender==="female"?it==="f"||it==="femme":!0})),ee.status&&ee.status!=="all"&&($e=$e.filter(Gt=>{const it=!!(Gt.data.date_deces||Gt.data.annee_deces);return ee.status==="deceased"?it:!it})),ee.era&&ee.era!=="all"&&($e=$e.filter(Gt=>{const Ot=String(Gt.data.date_naissance||Gt.data.annee_naissance||"").match(/\d{4}/),nn=Ot?parseInt(Ot[0],10):null;return nn?ee.era==="contemporary"?nn>=2e3:ee.era==="xx"?nn>=1900&&nn<2e3:ee.era==="xix"?nn>=1800&&nn<1900:ee.era==="ancient"?nn<1800:!0:!1})),ee.city&&ee.city.trim()){const Gt=ee.city.trim().toLowerCase();$e=$e.filter(it=>`${it.data.lieu_naissance||""} ${it.data.lieu_mariage||""} ${it.data.lieu_deces||""}`.toLowerCase().includes(Gt))}if(ee.profession&&ee.profession.trim()){const Gt=ee.profession.trim().toLowerCase();$e=$e.filter(it=>(it.data.profession||"").toLowerCase().includes(Gt))}return ee.completeness&&ee.completeness!=="all"&&($e=$e.filter(Gt=>{const it=!!(Gt.data.photo_url||Gt.data.photo),Ot=!Gt.data.date_naissance||!Gt.data.lieu_naissance||!Gt.data.profession||!it;return ee.completeness==="incomplete"?Ot:ee.completeness==="complete"?!Ot:ee.completeness==="has_photo"?it:ee.completeness==="no_photo"?!it:!0})),[...$e].sort((Gt,it)=>{if(ee.sortBy==="name_desc"){const Nt=`${Gt.data.nom||""} ${Gt.data.prenom||""}`.trim();return`${it.data.nom||""} ${it.data.prenom||""}`.trim().localeCompare(Nt)}if(ee.sortBy==="birth_asc"||ee.sortBy==="birth_desc"){const Nt=parseInt((String(Gt.data.date_naissance||Gt.data.annee_naissance||"").match(/\d{4}/)||[0])[0],10)||(ee.sortBy==="birth_asc"?9999:0),m=parseInt((String(it.data.date_naissance||it.data.annee_naissance||"").match(/\d{4}/)||[0])[0],10)||(ee.sortBy==="birth_asc"?9999:0);return ee.sortBy==="birth_asc"?Nt-m:m-Nt}const Ot=`${Gt.data.prenom||""} ${Gt.data.nom||""}`.trim(),nn=`${it.data.prenom||""} ${it.data.nom||""}`.trim();return Ot.localeCompare(nn)})},[ft,d,ee]),Lt=de.useCallback($e=>{V($e);const ut=o.find(Gt=>Gt.id===$e);ut&&(K(ut.data),jt.success(`${ut.data.prenom||""} ${ut.data.nom||""} centré(e)`,{icon:"🎯"})),setTimeout(()=>{p({duration:700,padding:.25})},100)},[o,p]),st=de.useMemo(()=>{var $e;return(($e=o.find(ut=>ut.id===O))==null?void 0:$e.data)||null},[o,O]),Ht=de.useMemo(()=>{var ut;const $e=o.find(Gt=>{var it,Ot;return(Ot=(it=Gt.data)==null?void 0:it.prenom)==null?void 0:Ot.toLowerCase().includes("lauriane")});return $e?$e.id:((ut=o.find(Gt=>{var it;return!((it=Gt.data)!=null&&it.is_placeholder)}))==null?void 0:ut.id)||""},[o]),Se=de.useMemo(()=>{if(!O||o.length===0)return{parents:[],children:[],spouses:[],siblings:[],grandparents:[]};const $e=Ln=>c.filter(Rn=>Rn.target===Ln&&Rn.label!=="conjoint").map(Rn=>o.find(Mn=>Mn.id===Rn.source)).filter(Boolean),ut=Ln=>c.filter(Rn=>Rn.source===Ln&&Rn.label!=="conjoint").map(Rn=>o.find(Mn=>Mn.id===Rn.target)).filter(Boolean),Gt=Ln=>c.filter(Rn=>Rn.label==="conjoint"&&(Rn.source===Ln||Rn.target===Ln)).map(Rn=>o.find(Mn=>Mn.id===(Rn.source===Ln?Rn.target:Rn.source))).filter(Boolean),it=$e(O).filter(Ln=>!Ln.data.is_placeholder),Ot=ut(O).filter(Ln=>!Ln.data.is_placeholder),nn=Gt(O).filter(Ln=>!Ln.data.is_placeholder),Nt=new Set;it.forEach(Ln=>{ut(Ln.id).forEach(Rn=>{Rn.id!==O&&!Rn.data.is_placeholder&&Nt.add(Rn)})});const m=Array.from(Nt),Ie=new Set;it.forEach(Ln=>{$e(Ln.id).forEach(Rn=>{Rn.data.is_placeholder||Ie.add(Rn)})});const An=Array.from(Ie);return{parents:it,children:Ot,spouses:nn,siblings:m,grandparents:An}},[O,o,c]),[_t,It]=de.useState(null),[De,ue]=de.useState(null);de.useEffect(()=>{const $e=Gt=>{Gt.key==="Escape"&&ue(null)},ut=()=>ue(null);return window.addEventListener("click",ut),window.addEventListener("keydown",$e),()=>{window.removeEventListener("click",ut),window.removeEventListener("keydown",$e)}},[]);const Ve=de.useCallback($e=>i(ut=>Ige($e,ut)),[]),We=de.useCallback($e=>a(ut=>JIe($e,ut)),[]),ct=de.useCallback($e=>{var it,Ot,nn,Nt,m,Ie;const ut=o.find(An=>An.id===$e.source),Gt=o.find(An=>An.id===$e.target);if(ut!=null&&ut.data&&(Gt!=null&&Gt.data)&&ut.id!==Gt.id){const An=((it=$e.sourceHandle)==null?void 0:it.includes("left"))||((Ot=$e.sourceHandle)==null?void 0:Ot.includes("right"))||((nn=$e.targetHandle)==null?void 0:nn.includes("left"))||((Nt=$e.targetHandle)==null?void 0:Nt.includes("right")),Ln=((m=$e.sourceHandle)==null?void 0:m.includes("top"))||((Ie=$e.targetHandle)==null?void 0:Ie.includes("bottom")),Rn=An?"spouse":Ln?"child_of":"parent_of";It({sourcePerson:ut.data,targetPerson:Gt.data,initialRelation:Rn})}},[o]),vt=de.useCallback($e=>{It({sourcePerson:$e,targetPerson:null,initialRelation:"parent_of"})},[]),Ut=de.useCallback($e=>{window.confirm("Voulez-vous vraiment supprimer cette relation ?")&&a(ut=>ut.filter(Gt=>!$e.includes(Gt)))},[]),dt=de.useRef(null),[mt,Ft]=de.useState(null),tt=de.useCallback($e=>{Ft($e),dt.current&&dt.current.click()},[]),Pe=async $e=>{const ut=$e.target.files[0];if(!ut||!mt)return;const Gt=jt.loading("Envoi de la photo..."),it=new FormData;it.append("file",ut),it.append("slug",mt);try{const Ot=await fetch(`${jm}/api/upload_avatar`,{method:"POST",credentials:"include",body:it}),nn=await Ot.json();Ot.ok?(jt.success("Photo mise à jour !",{id:Gt}),Yt()):jt.error(`Erreur: ${nn.error}`,{id:Gt})}catch{jt.error("Échec de l'envoi",{id:Gt})}finally{$e.target.value=null,Ft(null)}},nt=de.useCallback(($e,ut)=>{C({sourceSlug:$e,relationType:ut}),y(!0)},[]),qe=de.useMemo(()=>({personNode:$e=>f.jsx(nHe,{...$e,onAddRelative:nt,onConnectRelative:vt,onEditPerson:e})}),[nt,vt,e]),yt=async($e,ut)=>{if(!M)return;const{sourceSlug:Gt,relationType:it}=M,Ot=jt.loading("Création du lien familial...");try{if(!(await fetch(`${jm}/api/add_relative`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({source_slug:Gt,relation_type:it,new_person_data:{prenom:$e,nom:ut}})})).ok)throw new Error("Failed to add relative");jt.success("Généalogie mise à jour !",{id:Ot}),y(!1),C(null),Yt()}catch(nn){jt.error(`Erreur: ${nn.message}`,{id:Ot})}},Qt=async $e=>{if(!$e)return;ae(!0);const ut=jt.loading("Suppression de la fiche...");try{const Gt=await fetch(`${jm}/api/people/${$e}`,{method:"DELETE",credentials:"include"}),it=await Gt.json();Gt.ok?(jt.success(it.message||"Fiche supprimée avec succès !",{id:ut}),K(null),J(!1),Yt()):jt.error(it.error||"Erreur lors de la suppression",{id:ut})}catch{ae(!1)}},[Be,pt]=de.useState(!1),rt=async $e=>{if(!$e)return;pt(!0);const ut=jt.loading("Validation de la fiche...");try{const Gt=await fetch(`${jm}/api/people/${$e}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({field:"all"})}),it=await Gt.json();Gt.ok?(jt.success(it.message||"Fiche validée avec succès !",{id:ut}),K(Ot=>Ot?{...Ot,validations:it.validations}:null),Yt()):jt.error(it.error||"Erreur de validation",{id:ut})}catch{jt.error("Erreur de connexion",{id:ut})}finally{pt(!1)}},zt=de.useCallback(async($e="png")=>{B(!0);const ut=jt.loading(`Génération ${$e==="svg"?"Vectorielle (SVG)":"Ultra HD"} en cours...`);try{await new Promise(An=>setTimeout(An,500));const Gt=document.querySelector(".react-flow__viewport"),it=GS(g()),Ot=150,nn=it.width+Ot*2,Nt=it.height+Ot*2,m={backgroundColor:"#0f172a",width:nn,height:Nt,pixelRatio:4,style:{width:`${nn}px`,height:`${Nt}px`,transform:`translate(${-it.x+Ot}px, ${-it.y+Ot}px) scale(1)`},filter:An=>{var Ln,Rn,Mn;return!((Ln=An==null?void 0:An.classList)!=null&&Ln.contains("react-flow__controls")||(Rn=An==null?void 0:An.classList)!=null&&Rn.contains("react-flow__panel")||(Mn=An==null?void 0:An.classList)!=null&&Mn.contains("react-flow__minimap"))}};let Ie;if($e==="svg"?Ie=await ume(Gt,m):Ie=await dme(Gt,m),$e==="png"||$e==="svg"){const An=document.createElement("a");An.download=`arbre-genealogique.${$e}`,An.href=Ie,An.click(),jt.success(`Fichier ${$e.toUpperCase()} sauvegardé !`,{id:ut})}else if($e==="pdf"){const An=new Cr({orientation:"landscape",unit:"mm",format:"a3"}),Ln=An.getImageProperties(Ie),Rn=An.internal.pageSize.getWidth(),Mn=Ln.height*Rn/Ln.width;An.addImage(Ie,"PNG",0,0,Rn,Mn,"","FAST"),An.save("arbre-genealogique-hd.pdf"),jt.success("PDF HD sauvegardé !",{id:ut})}}catch(Gt){console.error(Gt),jt.error("Erreur lors de l'exportation",{id:ut})}finally{B(!1)}},[p,g]),Yt=de.useCallback(()=>{(async()=>{try{const Gt=await(await fetch(`${jm}/api/tree`,{credentials:"include"})).json();Gt.nodes&&Gt.nodes.length>0&&(l(Gt.nodes),u(Gt.edges),V(it=>{var nn;if(it)return it;const Ot=Gt.nodes.find(Nt=>{var m,Ie;return(Ie=(m=Nt.data)==null?void 0:m.prenom)==null?void 0:Ie.toLowerCase().includes("lauriane")});return Ot?Ot.id:((nn=Gt.nodes.find(Nt=>{var m;return!((m=Nt.data)!=null&&m.is_placeholder)}))==null?void 0:nn.id)||""}))}catch(ut){console.error("Failed to fetch family tree data:",ut)}})()},[]);de.useEffect(()=>{Yt()},[Yt]),de.useEffect(()=>{if(o.length===0)return;let $e=o,ut=c;if(O&&O!=="all"){const Ie=new Set([O]),An=Mn=>c.filter(Cn=>Cn.target===Mn&&Cn.label!=="conjoint").map(Cn=>Cn.source),Ln=Mn=>c.filter(Cn=>Cn.source===Mn&&Cn.label!=="conjoint").map(Cn=>Cn.target),Rn=Mn=>c.filter(Cn=>Cn.label==="conjoint"&&(Cn.source===Mn||Cn.target===Mn)).map(Cn=>Cn.source===Mn?Cn.target:Cn.source);if(pe==="core"){Rn(O).forEach(Cn=>Ie.add(Cn));const Mn=An(O);Mn.forEach(Cn=>Ie.add(Cn)),Mn.forEach(Cn=>Ln(Cn).forEach(Hn=>Ie.add(Hn))),Ln(O).forEach(Cn=>{Ie.add(Cn),Rn(Cn).forEach(Hn=>Ie.add(Hn))})}else if(pe==="ancestors"){let Mn=[O];for(let Cn=0;Cn<$;Cn++){let Hn=[];Mn.forEach(lr=>{An(lr).forEach(jr=>{Ie.add(jr),Rn(jr).forEach(Qr=>Ie.add(Qr)),Hn.push(jr)})}),Mn=Hn}}else if(pe==="descendants"){Rn(O).forEach(Cn=>Ie.add(Cn));let Mn=[O];for(let Cn=0;Cn<$;Cn++){let Hn=[];Mn.forEach(lr=>{Ln(lr).forEach(jr=>{Ie.add(jr),Rn(jr).forEach(Qr=>Ie.add(Qr)),Hn.push(jr)})}),Mn=Hn}}else{Rn(O).forEach(Hn=>Ie.add(Hn));let Mn=An(O);Mn.forEach(Hn=>Ie.add(Hn)),Mn.forEach(Hn=>Ln(Hn).forEach(lr=>Ie.add(lr)));for(let Hn=1;Hn<$;Hn++){let lr=[];Mn.forEach(jr=>{An(jr).forEach(Qr=>{Ie.add(Qr),lr.push(Qr)})}),Mn=lr}let Cn=[O];for(let Hn=0;Hn<$;Hn++){let lr=[];Cn.forEach(jr=>{Ln(jr).forEach(Qr=>{Ie.add(Qr),lr.push(Qr),Rn(Qr).forEach(Os=>Ie.add(Os))})}),Cn=lr}}$e=o.filter(Mn=>{var Cn;return Ie.has(Mn.id)||((Cn=Mn.data)==null?void 0:Cn.is_placeholder)}),ut=c.filter(Mn=>Ie.has(Mn.source)&&Ie.has(Mn.target))}const Gt=$e.map(Ie=>({...Ie,data:{...Ie.data,onAvatarClick:tt,isCentered:Ie.id===O,isRoot:Ie.id===Ht}}));let it=[...ut];const Ot={};it.forEach(Ie=>{Ie.source&&Ie.target&&!Ie.label&&(Ot[Ie.target]||(Ot[Ie.target]=[]),Ot[Ie.target].push(Ie.source))}),Object.keys(Ot).forEach(Ie=>{const An=Ot[Ie];if(An.length===1){const Ln=An[0],Rn=`placeholder-parent-of-${Ie}`;Gt.find(Mn=>Mn.id===Rn)||Gt.push({id:Rn,type:"personNode",data:{prenom:"?",nom:"Inconnu",slug:Rn,is_placeholder:!0},position:{x:0,y:0}}),it.some(Mn=>Mn.source===Rn&&Mn.target===Ie)||it.push({id:`edge-${Rn}-${Ie}`,source:Rn,target:Ie}),it.some(Mn=>Mn.label==="conjoint"&&(Mn.source===Ln&&Mn.target===Rn||Mn.source===Rn&&Mn.target===Ln))||it.push({id:`spouse-edge-${Ln}-${Rn}`,source:Ln,target:Rn,label:"conjoint"})}}),it=it.map(Ie=>{var ra,cs,Jn,wa;const An=o.find(Ii=>Ii.id===Ie.target),Ln=o.find(Ii=>Ii.id===Ie.source);Ie.relationship=Ie.label||"parent-child";let Rn="",Mn="#64748b",Cn="12px",Hn={fill:"white",fillOpacity:.9,rx:6,ry:6},lr="#0284c7",jr=2.5,Qr="none",Os=!1,la={type:aA.ArrowClosed,color:lr};if(Ie.label==="conjoint"){const Ii=String(((ra=Ln==null?void 0:Ln.data)==null?void 0:ra.date_mariage)||((cs=An==null?void 0:An.data)==null?void 0:cs.date_mariage)||"").substring(0,4);Rn=Ii?`💍 ${Ii}`:"💍",lr="#ec4899",jr=3,Qr="8,5",Os=!0,Mn="#db2777",Cn="14px",Hn={fill:"#fdf2f8",fillOpacity:.95,stroke:"#fbcfe8",strokeWidth:1.5,rx:8,ry:8},la=void 0}else{const Ii=String(((Jn=An==null?void 0:An.data)==null?void 0:Jn.date_naissance)||((wa=An==null?void 0:An.data)==null?void 0:wa.annee_naissance)||"").substring(0,4),Ge=O&&(Ie.source===O||Se.spouses.some(_e=>_e.id===Ie.source)),wt=O&&Ie.target===O;Ge?(lr="#10b981",jr=3,Qr="none",Rn=Ii?`🍼 N: ${Ii}`:"🍼 Enfant",Mn="#047857",Cn="13px",Hn={fill:"#ecfdf5",fillOpacity:.95,stroke:"#a7f3d0",strokeWidth:1.5,rx:6,ry:6},la={type:aA.ArrowClosed,color:"#10b981"}):wt?(lr="#3b82f6",jr=3,Qr="none",Rn=Ii?`🧬 N: ${Ii}`:"🧬 Parent",Mn="#1d4ed8",Cn="13px",Hn={fill:"#eff6ff",fillOpacity:.95,stroke:"#bfdbfe",strokeWidth:1.5,rx:6,ry:6},la={type:aA.ArrowClosed,color:"#3b82f6"}):(lr="#0284c7",jr=2.5,Qr="none",Rn=Ii?`N: ${Ii}`:"",Mn="#0369a1",Cn="12px",Hn={fill:"#f0f9ff",fillOpacity:.9,stroke:"#bae6fd",strokeWidth:1,rx:5,ry:5},la={type:aA.ArrowClosed,color:"#0284c7"})}const Pi=Ie.label==="conjoint"||Ie.relationship==="conjoint";return{...Ie,type:Pi?"straight":"smoothstep",sourceHandle:Pi?Ie.sourceHandle:void 0,targetHandle:Pi?Ie.targetHandle:void 0,animated:Os,style:{stroke:lr,strokeWidth:jr,strokeDasharray:Qr},label:Rn,labelStyle:{fontSize:Cn,fill:Mn,fontWeight:"bold"},labelBgStyle:Rn?Hn:void 0,labelBgPadding:[6,3],labelBgBorderRadius:6,markerEnd:la}});const nn=Gt.filter(Ie=>!Ie.data.is_placeholder||it.some(An=>An.source===Ie.id||An.target===Ie.id)),{nodes:Nt,edges:m}=aHe(nn,it,U);i(Nt),a(m),setTimeout(()=>p({padding:.3,duration:800}),100)},[o,c,O,pe,$,U,p,tt]);const Bt=()=>{if(!H)return null;const $e=H.photo_url||H.photo;$e?$e.startsWith("/")&&`${jm}${$e}`:H.sexe==="F"||H.sexe;const ut=(H.nom_jeune_fille||H.nom_naissance||"").trim(),Gt=ut&&ut.toUpperCase()!==(H.nom||"").trim().toUpperCase();return f.jsx(Da,{children:f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/70 backdrop-blur-md",onClick:()=>{K(null),J(!1)},children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.92,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.92,y:15},transition:{type:"spring",stiffness:350,damping:25},onClick:it=>it.stopPropagation(),className:"w-full max-w-lg bg-gradient-to-b from-slate-900 via-slate-800 to-slate-900 border border-emerald-500/40 rounded-3xl p-6 shadow-2xl text-white relative overflow-hidden flex flex-col gap-4",children:[f.jsx("div",{className:"absolute top-0 right-0 w-44 h-44 bg-emerald-500/10 rounded-full blur-3xl pointer-events-none"}),f.jsx("div",{className:"absolute bottom-0 left-0 w-44 h-44 bg-amber-500/10 rounded-full blur-3xl pointer-events-none"}),f.jsx("button",{onClick:()=>{K(null),J(!1)},className:"absolute top-4 right-4 p-2 rounded-full bg-slate-800/80 hover:bg-slate-700 text-slate-400 hover:text-white transition z-10",title:"Fermer",children:f.jsx($a,{size:15})}),f.jsxs("div",{className:"flex items-start gap-4 z-10",children:[f.jsx(q0,{person:H,className:"w-20 h-24",rounded:"rounded-2xl shadow-lg border-2 border-emerald-400/60",dark:!0}),f.jsxs("div",{className:"flex-1 min-w-0 pr-6",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsxs("h3",{className:"text-xl font-extrabold text-white leading-tight",children:[H.prenom," ",f.jsx("span",{className:"uppercase text-emerald-400",children:H.nom})]}),H.sexe&&f.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-bold border ${H.sexe==="F"||H.sexe==="Femme"?"bg-pink-500/20 text-pink-300 border-pink-500/40":"bg-sky-500/20 text-sky-300 border-sky-500/40"}`,children:H.sexe==="F"||H.sexe==="Femme"?"👩 Femme":"👨 Homme"})]}),Gt&&f.jsxs("p",{className:"text-xs text-pink-300 font-semibold italic mt-0.5",children:["née ",ut]}),H.surnom&&f.jsxs("p",{className:"text-xs text-purple-300 font-bold mt-0.5",children:["« ",H.surnom," »"]}),H.profession&&f.jsxs("p",{className:"text-xs text-amber-200/90 font-medium mt-1 flex items-center gap-1.5",children:[f.jsx(Wp,{className:"text-amber-400 text-xs shrink-0"})," ",f.jsx("span",{className:"truncate",children:H.profession})]})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 bg-slate-800/80 backdrop-blur-sm p-3.5 rounded-2xl border border-slate-700/60 text-xs",children:[f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-[10px] text-emerald-400 font-black uppercase tracking-wider",children:"🍼 Naissance"}),f.jsx("span",{className:"font-bold text-white",children:H.date_naissance||H.annee_naissance||"Inconnue"}),H.lieu_naissance&&f.jsx("span",{className:"text-[11px] text-slate-400 truncate",children:H.lieu_naissance})]}),f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-[10px] text-pink-400 font-black uppercase tracking-wider",children:"💍 Union / Mariage"}),f.jsx("span",{className:"font-bold text-white",children:H.date_mariage||"Non renseigné"}),H.lieu_mariage&&f.jsx("span",{className:"text-[11px] text-slate-400 truncate",children:H.lieu_mariage})]}),H.date_divorce&&f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-[10px] text-purple-400 font-black uppercase tracking-wider",children:"💔 Divorce"}),f.jsx("span",{className:"font-bold text-white",children:H.date_divorce}),H.lieu_divorce&&f.jsx("span",{className:"text-[11px] text-slate-400 truncate",children:H.lieu_divorce})]}),H.date_deces&&f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsx("span",{className:"text-[10px] text-slate-400 font-black uppercase tracking-wider",children:"† Décès"}),f.jsx("span",{className:"font-bold text-slate-300",children:H.date_deces}),H.lieu_deces&&f.jsx("span",{className:"text-[11px] text-slate-400 truncate",children:H.lieu_deces})]})]}),H.biographie&&f.jsx("div",{className:"bg-slate-800/50 p-3 rounded-2xl border border-slate-700/50",children:f.jsxs("p",{className:"text-xs text-slate-300 italic line-clamp-3 leading-relaxed",children:['"',H.biographie.replace(/<[^>]*>?/gm,"").trim(),'"']})}),(()=>{var Nt;const it=H.validations||{},Ot=((Nt=it.profil_global)==null?void 0:Nt.status)==="verified"||Object.values(it).some(m=>m.status==="verified"),nn=it.profil_global||Object.values(it)[0];return f.jsxs("div",{className:`p-3 rounded-2xl border flex items-center justify-between gap-2 text-xs ${Ot?"bg-emerald-950/70 border-emerald-500/40 text-emerald-200":"bg-amber-950/60 border-amber-500/40 text-amber-200"}`,children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"text-sm shrink-0",children:Ot?"✅":"🤖"}),f.jsx("div",{className:"truncate",children:Ot?f.jsxs("p",{className:"font-bold text-[11px] truncate",children:["Validé par ",nn.confirmed_by," ",f.jsxs("span",{className:"text-slate-400 font-normal",children:["(",nn.confirmed_at,")"]})]}):f.jsxs("p",{className:"font-semibold text-[11px] truncate",children:["Déduit par l'IA ",f.jsx("span",{className:"text-amber-300/80 font-normal",children:"(À confirmer)"})]})})]}),f.jsxs("button",{type:"button",onClick:()=>rt(H.slug),disabled:Be,className:`px-3 py-1 rounded-xl text-[11px] font-extrabold flex items-center gap-1 transition shadow-md shrink-0 hover:scale-105 active:scale-95 disabled:opacity-50 ${Ot?"bg-emerald-600 hover:bg-emerald-500 text-white":"bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-400 hover:to-teal-500 text-white"}`,title:"Confirmer l'exactitude de cette fiche",children:[f.jsx(td,{size:10}),f.jsx("span",{children:Be?"...":Ot?"Re-valider":"✅ Confirmer"})]})]})})(),W?f.jsxs("div",{className:"bg-rose-950/80 border border-rose-500/60 rounded-2xl p-4 flex flex-col gap-3 animate-fadeIn",children:[f.jsxs("div",{className:"flex items-center gap-2 text-rose-300 font-bold text-sm",children:[f.jsx(vM,{className:"text-rose-400 shrink-0"}),f.jsx("span",{children:"Supprimer cette fiche ?"})]}),f.jsxs("p",{className:"text-xs text-rose-200",children:["Êtes-vous sûr de vouloir supprimer définitivement la fiche de ",f.jsxs("strong",{className:"text-white",children:[H.prenom," ",H.nom]})," ? Cette action est irréversible."]}),f.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[f.jsx("button",{onClick:()=>J(!1),className:"px-3.5 py-1.5 rounded-xl bg-slate-700 hover:bg-slate-600 text-white text-xs font-semibold transition",disabled:ie,children:"Annuler"}),f.jsxs("button",{onClick:()=>Qt(H.slug),className:"px-4 py-1.5 rounded-xl bg-rose-600 hover:bg-rose-500 text-white text-xs font-bold transition flex items-center gap-1.5 shadow-md disabled:opacity-50",disabled:ie,children:[f.jsx(z0,{size:12}),ie?"Suppression...":"Confirmer la suppression"]})]})]}):f.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 pt-1",children:[f.jsxs("button",{onClick:()=>{n&&n(H),K(null)},className:"p-3 rounded-2xl bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white font-bold text-xs flex flex-col items-center justify-center gap-1.5 shadow-lg shadow-emerald-950/50 transition hover:scale-102 active:scale-98",children:[f.jsx(PCe,{size:15,className:"text-emerald-200"}),f.jsx("span",{children:"Voir Détails"})]}),f.jsxs("button",{onClick:()=>{e&&e(H),K(null)},className:"p-3 rounded-2xl bg-amber-500/20 hover:bg-amber-500/30 border border-amber-400/40 text-amber-200 font-bold text-xs flex flex-col items-center justify-center gap-1.5 shadow-md transition hover:scale-102 active:scale-98",children:[f.jsx(Pg,{size:15,className:"text-amber-400"}),f.jsx("span",{children:"Modifier"})]}),f.jsxs("button",{onClick:()=>{V(H.slug||H.id),K(null),jt.success(`Arbre centré sur ${H.prenom}`,{icon:"🎯"})},className:"p-3 rounded-2xl bg-sky-600/20 hover:bg-sky-600/30 border border-sky-500/30 text-sky-200 font-bold text-xs flex flex-col items-center justify-center gap-1.5 shadow-md transition hover:scale-102 active:scale-98",children:[f.jsx(BCe,{size:15,className:"text-sky-400"}),f.jsx("span",{children:"Centrer Arbre"})]}),f.jsxs("button",{onClick:()=>J(!0),className:"p-3 rounded-2xl bg-rose-600/20 hover:bg-rose-600/30 border border-rose-500/30 text-rose-200 font-bold text-xs flex flex-col items-center justify-center gap-1.5 shadow-md transition hover:scale-102 active:scale-98",children:[f.jsx(z0,{size:15,className:"text-rose-400"}),f.jsx("span",{children:"Supprimer"})]})]})]})})})};return Ae==="mobile"?f.jsxs("div",{className:"relative w-full",children:[f.jsx("input",{type:"file",ref:dt,onChange:Pe,className:"hidden",accept:"image/jpeg,image/png,image/webp"}),_&&f.jsx(cz,{onSubmit:yt,onCancel:()=>y(!1)}),f.jsx(iHe,{nodes:r,edges:s,onNodeClick:$e=>{K($e),J(!1)},onAddRelative:nt,onAvatarClick:tt,onSwitchTo2D:()=>be("heredis")}),Bt()]}):f.jsxs("div",{className:"relative w-full h-[88vh] rounded-[2.5rem] overflow-hidden shadow-2xl border-4 border-slate-800 bg-slate-950 text-slate-100 flex flex-col font-sans",children:[f.jsx("input",{type:"file",ref:dt,onChange:Pe,className:"hidden",accept:"image/jpeg,image/png,image/webp"}),_&&f.jsx(cz,{onSubmit:yt,onCancel:()=>y(!1)}),f.jsxs("div",{className:"bg-slate-900/90 backdrop-blur-xl border-b border-slate-800 px-4 py-3 flex flex-wrap items-center justify-between gap-3 z-20",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("button",{onClick:()=>Qe(!Xe),className:`p-2.5 rounded-xl border transition-all ${Xe?"bg-emerald-600/20 text-emerald-400 border-emerald-500/40":"bg-slate-800 text-slate-400 border-slate-700 hover:text-white"}`,title:"Afficher/Masquer le panneau Recherche & Index",children:f.jsx(CCe,{size:16})}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xl",children:"🗂️"}),f.jsxs("h3",{className:"font-extrabold text-sm sm:text-base text-white tracking-wide",children:["Généalogie ",f.jsx("span",{className:"text-emerald-400 font-black",children:"PRO"})," Workspace"]})]})]}),f.jsx("div",{className:"flex items-center bg-slate-950/80 p-1 rounded-2xl border border-slate-800 shadow-inner overflow-x-auto max-w-full custom-scrollbar",children:[{id:"core",label:"Noyau",icon:f.jsx(jA,{}),title:"Noyau Familial Direct",desc:"Concentre la vue sur les parents immédiats, le conjoint et les enfants directs de la personne active."},{id:"xxl",label:"XXL",icon:f.jsx(X4,{}),title:"Arbre Étendu XXL",desc:"Affiche la généalogie élargie avec toutes les branches collatérales, cousins, oncles et tantes."},{id:"ancestors",label:"Ascendance",icon:f.jsx(YCe,{}),title:"Ascendance (Généalogie directe)",desc:"Remonte la lignée vers le haut : parents, grands-parents, arrière-grands-parents."},{id:"descendants",label:"Descendance",icon:f.jsx(ZCe,{}),title:"Descendance (Postérité)",desc:"Déroule la lignée vers le bas : enfants, petits-enfants et générations futures."}].map($e=>f.jsxs("div",{className:"relative inline-flex",onMouseEnter:()=>ze($e.id),onMouseLeave:()=>{Te===$e.id&&ze(null)},children:[f.jsxs("button",{onClick:()=>ge($e.id),className:`px-3 sm:px-4 py-1.5 sm:py-2 rounded-xl text-xs sm:text-sm font-bold flex items-center gap-1.5 transition-all shrink-0 ${pe===$e.id?"bg-emerald-600 text-white shadow-lg":"text-slate-400 hover:text-white hover:bg-slate-800/50"}`,children:[f.jsx("span",{children:$e.icon}),f.jsx("span",{children:$e.label})]}),f.jsx(Da,{children:Te===$e.id&&f.jsxs(Gn.div,{initial:{opacity:0,y:6,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:4,scale:.96},transition:{duration:.15},className:"absolute top-full mt-2 left-1/2 -translate-x-1/2 z-50 w-60 p-3 bg-slate-950/95 backdrop-blur-xl border border-slate-700 text-white rounded-2xl shadow-2xl text-left pointer-events-auto",children:[f.jsxs("div",{className:"flex items-center justify-between pb-1 mb-1 border-b border-slate-800",children:[f.jsxs("span",{className:"font-extrabold text-xs text-emerald-400 flex items-center gap-1",children:[$e.icon," ",$e.title]}),f.jsx("button",{type:"button",onClick:ut=>{ut.stopPropagation(),ze(null)},className:"text-slate-400 hover:text-white p-0.5 text-xs rounded hover:bg-slate-800 leading-none",title:"Fermer",children:"✕"})]}),f.jsx("p",{className:"text-[11px] text-slate-300 leading-relaxed font-normal",children:$e.desc}),f.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 -mb-1 w-2 h-2 bg-slate-950 border-l border-t border-slate-700 rotate-45"})]})})]},$e.id))}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("select",{value:$,onChange:$e=>G(Number($e.target.value)),className:"bg-slate-800 text-slate-200 border border-slate-700 rounded-xl px-3 py-2 text-xs font-semibold outline-none focus:border-emerald-500 cursor-pointer",children:[f.jsx("option",{value:1,children:"Prof. +1"}),f.jsx("option",{value:2,children:"Prof. +2 (Défaut)"}),f.jsx("option",{value:3,children:"Prof. +3"}),f.jsx("option",{value:4,children:"Prof. +4"}),f.jsx("option",{value:5,children:"Prof. +5"})]}),f.jsx("button",{onClick:()=>z($e=>$e==="TB"?"LR":"TB"),className:"p-2.5 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded-xl border border-slate-700 transition-colors",title:"Changer l'orientation de l'arbre (Vertical/Horizontal)",children:f.jsx(X4,{className:"text-emerald-400"})}),f.jsx("button",{onClick:()=>be("mobile"),className:"px-3 py-2 text-xs font-bold text-white bg-emerald-600 hover:bg-emerald-700 rounded-xl transition-colors shadow-md flex items-center gap-1.5",children:"📱 Mobile"}),f.jsx("button",{onClick:()=>bt(!ot),className:`p-2.5 rounded-xl border transition-all ${ot?"bg-emerald-600/20 text-emerald-400 border-emerald-500/40":"bg-slate-800 text-slate-400 border-slate-700 hover:text-white"}`,title:"Afficher/Masquer la Palette de Navigation & Relations",children:f.jsx(Wpe,{size:16})})]})]}),f.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[f.jsxs("button",{onClick:()=>Qe(!Xe),className:`absolute top-1/2 -translate-y-1/2 z-40 bg-slate-900/95 hover:bg-emerald-600 text-emerald-400 hover:text-white p-3 rounded-r-2xl border-y border-r border-slate-700/80 shadow-[0_10px_25px_rgba(0,0,0,0.5)] transition-all duration-300 flex items-center gap-1 group ${Xe?"left-72 sm:left-80":"left-0"}`,title:Xe?"Réduire l'Index des individus":"Déplier l'Index des individus",children:[Xe?f.jsx(n4,{size:16}):f.jsx(_A,{size:16}),f.jsx("span",{className:"max-w-0 overflow-hidden group-hover:max-w-xs transition-all whitespace-nowrap text-xs font-bold pl-0 group-hover:pl-1",children:Xe?"Masquer Index":"Ouvrir Index"})]}),Xe&&f.jsxs("div",{className:"absolute top-0 bottom-0 left-0 z-30 w-80 sm:w-96 bg-slate-900/98 backdrop-blur-2xl border-r border-slate-800 flex flex-col shadow-[10px_0_30px_rgba(0,0,0,0.5)] transition-all animate-in slide-in-from-left duration-300",children:[f.jsxs("div",{className:"p-3 border-b border-slate-800 space-y-2",children:[f.jsxs("div",{className:"relative",children:[f.jsx(X0,{className:"absolute left-3.5 top-3 text-slate-500 text-xs"}),f.jsx("input",{type:"text",placeholder:"Rechercher (prénom, nom, lieu, métier)...",value:d,onChange:$e=>h($e.target.value),className:"w-full bg-slate-950 border border-slate-800 rounded-xl pl-9 pr-8 py-2 text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:border-emerald-500"}),d&&f.jsx("button",{onClick:()=>h(""),className:"absolute right-3 top-2.5 text-slate-500 hover:text-white",children:f.jsx($a,{size:12})})]}),f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("button",{onClick:()=>fe(!oe),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-bold transition-colors ${oe?"bg-emerald-600 text-white":"bg-slate-800 text-slate-300 hover:text-white hover:bg-slate-700"}`,children:[f.jsx(gH,{size:10}),f.jsx("span",{children:oe?"Masquer Filtres":"Filtres Avancés"}),(ee.branch!=="all"||ee.era!=="all"||ee.status!=="all"||ee.gender!=="all"||ee.completeness!=="all"||ee.city||ee.profession)&&f.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400 animate-pulse"})]}),f.jsxs("span",{className:"text-[11px] font-bold text-emerald-400 bg-emerald-500/10 border border-emerald-500/30 px-2 py-0.5 rounded-full",children:[At.length," / ",ft.length]})]}),oe&&f.jsxs("div",{className:"mt-2 p-2.5 bg-slate-950/80 rounded-xl border border-slate-800 space-y-2 text-[11px] animate-in fade-in duration-200",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-[10px] font-bold uppercase text-slate-400 block mb-1",children:"🌿 Branche / Patronyme"}),f.jsxs("select",{value:ee.branch,onChange:$e=>me(ut=>({...ut,branch:$e.target.value})),className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2 py-1 text-slate-200 outline-none focus:border-emerald-500",children:[f.jsxs("option",{value:"all",children:["Toutes les branches (",et.length,")"]}),et.map($e=>f.jsxs("option",{value:$e.name,children:[$e.name," (",$e.count,")"]},$e.name))]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-[10px] font-bold uppercase text-slate-400 block mb-1",children:"⏳ Époque / Siècle"}),f.jsx("div",{className:"grid grid-cols-2 gap-1",children:[{id:"all",label:"Tous"},{id:"contemporary",label:"2000+ Contemporain"},{id:"xx",label:"XXe (1900-1999)"},{id:"xix",label:"XIXe (1800-1899)"},{id:"ancient",label:"Avant 1800"}].map($e=>f.jsx("button",{type:"button",onClick:()=>me(ut=>({...ut,era:$e.id})),className:`px-1.5 py-1 rounded text-[10px] font-bold text-left truncate transition ${ee.era===$e.id?"bg-emerald-600 text-white":"bg-slate-900 text-slate-400 hover:text-slate-200"}`,children:$e.label},$e.id))})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[f.jsxs("div",{children:[f.jsx("label",{className:"text-[10px] font-bold uppercase text-slate-400 block mb-1",children:"💚 Statut"}),f.jsxs("select",{value:ee.status,onChange:$e=>me(ut=>({...ut,status:$e.target.value})),className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2 py-1 text-slate-200 outline-none focus:border-emerald-500",children:[f.jsx("option",{value:"all",children:"Tous"}),f.jsx("option",{value:"alive",children:"🌱 Vivants"}),f.jsx("option",{value:"deceased",children:"🕊️ Défunts"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-[10px] font-bold uppercase text-slate-400 block mb-1",children:"🚻 Genre"}),f.jsxs("select",{value:ee.gender,onChange:$e=>me(ut=>({...ut,gender:$e.target.value})),className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2 py-1 text-slate-200 outline-none focus:border-emerald-500",children:[f.jsx("option",{value:"all",children:"Tous"}),f.jsx("option",{value:"male",children:"♂️ Hommes"}),f.jsx("option",{value:"female",children:"♀️ Femmes"})]})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"text-[10px] font-bold uppercase text-slate-400 block mb-1",children:"📸 Complétude & Photo"}),f.jsxs("select",{value:ee.completeness,onChange:$e=>me(ut=>({...ut,completeness:$e.target.value})),className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2 py-1 text-slate-200 outline-none focus:border-emerald-500",children:[f.jsx("option",{value:"all",children:"Tous les profils"}),f.jsx("option",{value:"has_photo",children:"📸 Avec photo de profil"}),f.jsx("option",{value:"no_photo",children:"👤 Sans photo (À compléter)"}),f.jsx("option",{value:"incomplete",children:"⚠️ Fiches incomplètes"}),f.jsx("option",{value:"complete",children:"✅ Fiches complètes"})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[f.jsx("input",{type:"text",placeholder:"Lieu / Ville...",value:ee.city,onChange:$e=>me(ut=>({...ut,city:$e.target.value})),className:"bg-slate-900 border border-slate-800 rounded-lg px-2 py-1 text-slate-200 outline-none focus:border-emerald-500"}),f.jsx("input",{type:"text",placeholder:"Métier / Profession...",value:ee.profession,onChange:$e=>me(ut=>({...ut,profession:$e.target.value})),className:"bg-slate-900 border border-slate-800 rounded-lg px-2 py-1 text-slate-200 outline-none focus:border-emerald-500"})]}),f.jsxs("div",{className:"flex items-center justify-between pt-1 border-t border-slate-800/80",children:[f.jsxs("select",{value:ee.sortBy,onChange:$e=>me(ut=>({...ut,sortBy:$e.target.value})),className:"bg-slate-900 border border-slate-800 rounded-lg px-2 py-1 text-slate-300 text-[10px] outline-none",children:[f.jsx("option",{value:"name_asc",children:"Tri : Nom (A-Z)"}),f.jsx("option",{value:"name_desc",children:"Tri : Nom (Z-A)"}),f.jsx("option",{value:"birth_asc",children:"Tri : Plus anciens"}),f.jsx("option",{value:"birth_desc",children:"Tri : Plus récents"})]}),f.jsxs("button",{type:"button",onClick:()=>{me({query:"",branch:"all",era:"all",status:"all",gender:"all",completeness:"all",city:"",profession:"",sortBy:"name_asc"}),h("")},className:"text-[10px] font-bold text-rose-400 hover:text-rose-300 flex items-center gap-1",children:[f.jsx(vCe,{size:9})," Reset"]})]})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto custom-scrollbar divide-y divide-slate-800/50",children:At.map($e=>{var Nt;const ut=$e.id===O,Gt=(((Nt=$e.data)==null?void 0:Nt.sexe)||"").trim().toLowerCase(),it=Gt==="m"||Gt==="homme"||Gt==="h"||Gt==="garcon",Ot=Gt==="f"||Gt==="femme"||Gt==="fille",nn=[$e.data.annee_naissance||$e.data.date_naissance,$e.data.annee_deces||$e.data.date_deces].filter(Boolean).join(" - ");return f.jsxs("button",{onClick:()=>Lt($e.id),className:`w-full text-left p-3 flex items-center gap-3 transition-all hover:bg-slate-800/60 ${ut?"bg-emerald-950/60 border-l-4 border-emerald-500 text-white":"text-slate-300"}`,children:[f.jsxs("div",{className:"relative shrink-0",children:[$e.data.photo_url||$e.data.photo?f.jsx("img",{src:($e.data.photo_url||$e.data.photo).startsWith("/")?`${jm}${$e.data.photo_url||$e.data.photo}`:$e.data.photo_url||$e.data.photo,alt:$e.data.prenom,className:"w-9 h-9 rounded-full object-cover border border-slate-700 shadow-md"}):f.jsx("div",{className:`w-9 h-9 rounded-full flex items-center justify-center text-xs font-bold shadow-md ${it?"bg-sky-500/20 text-sky-400 border border-sky-500/30":Ot?"bg-pink-500/20 text-pink-400 border border-pink-500/30":"bg-slate-800 text-slate-400 border border-slate-700"}`,children:it?f.jsx(NCe,{}):Ot?f.jsx(OCe,{}):f.jsx(hm,{})}),$e.id===Ht&&f.jsx("span",{className:"absolute -top-1 -right-1 bg-amber-500 text-slate-950 text-[9px] rounded-full p-0.5 shadow",children:"👑"})]}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:"font-bold text-xs truncate flex items-center gap-1.5",children:f.jsxs("span",{children:[$e.data.prenom," ",f.jsx("strong",{className:"uppercase",children:$e.data.nom})]})}),nn&&f.jsx("div",{className:"text-[10px] text-slate-400 font-mono mt-0.5",children:nn}),$e.data.profession&&f.jsxs("div",{className:"text-[9px] text-emerald-400/80 truncate mt-0.5",children:["💼 ",$e.data.profession]})]})]},$e.id)})})]}),f.jsx("div",{className:"flex-1 relative bg-[#111827] overflow-hidden",children:f.jsxs(Wge,{nodes:r,edges:s,onNodesChange:Ve,onEdgesChange:We,onConnect:ct,onEdgesDelete:Ut,onNodeClick:($e,ut)=>{ut.data.is_placeholder||(V(ut.id),K(ut.data),J(!1),ue(null))},onNodeDoubleClick:($e,ut)=>{ut.data.is_placeholder||n&&n(ut.data)},onNodeContextMenu:($e,ut)=>{if($e.preventDefault(),ut.data.is_placeholder)return;const Gt=Math.min($e.clientX,window.innerWidth-300),it=Math.min($e.clientY,window.innerHeight-560);ue({x:Gt,y:it,person:ut.data})},onPaneClick:()=>ue(null),onPaneContextMenu:$e=>{$e.preventDefault(),ue(null)},nodeTypes:qe,fitView:!0,minZoom:.05,maxZoom:2,className:"font-sans",children:[f.jsx(fOe,{variant:"dots",gap:30,size:1.5,color:"#334155",className:"opacity-60"}),f.jsx(oOe,{className:"bg-slate-900/90 backdrop-blur-xl rounded-2xl shadow-2xl border border-slate-800 overflow-hidden [&>button]:border-b [&>button]:border-slate-800 [&>button]:w-10 [&>button]:h-10 [&>button]:text-slate-300 hover:[&>button]:bg-slate-800",showInteractive:!1}),f.jsx(eOe,{className:"bg-slate-900/90 backdrop-blur-xl border border-slate-800 rounded-2xl overflow-hidden shadow-2xl hidden md:block",maskColor:"rgba(15, 23, 42, 0.7)",nodeColor:$e=>{var Gt;const ut=(((Gt=$e.data)==null?void 0:Gt.sexe)||"").trim().toLowerCase();return ut==="m"||ut==="homme"||ut==="h"?"#38bdf8":ut==="f"||ut==="femme"?"#ec4899":"#64748b"}}),f.jsxs(p_,{position:"top-center",className:"mt-4 pointer-events-none flex flex-col items-center gap-2",children:[f.jsxs("div",{className:"pointer-events-auto bg-slate-900/90 backdrop-blur-2xl px-4 py-2 rounded-full shadow-2xl border border-slate-800 flex items-center gap-3 text-xs",children:[f.jsx("span",{className:"text-slate-400 font-medium hidden sm:inline",children:"Actif:"}),f.jsx("span",{className:"font-extrabold text-emerald-400",children:st?`${st.prenom} ${st.nom}`:"Vue Globale"}),f.jsx("div",{className:"h-4 w-px bg-slate-700"}),f.jsxs("button",{onClick:()=>{V("all"),ge("core"),setTimeout(()=>p({duration:800,padding:.2}),100),jt.success("Vue globale affichée",{icon:"🌐"})},className:"flex items-center gap-1.5 px-3 py-1 font-bold text-white bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 rounded-full transition-all shadow-md hover:scale-105 active:scale-95",title:"Afficher tout l'arbre généalogique au complet",children:[f.jsx("span",{children:"🌐"})," Vue Globale"]}),f.jsxs("button",{onClick:()=>p({duration:800,padding:.2}),className:"flex items-center gap-1.5 px-3 py-1 font-bold text-slate-300 hover:text-white bg-slate-800 hover:bg-slate-700 rounded-full transition-colors",title:"Centrer et ajuster la vue sur l'arbre",children:[f.jsx(UCe,{className:"text-emerald-400"})," Ajuster"]}),f.jsx("button",{onClick:()=>{const $e=Xe||ot;Qe(!$e),bt(!$e)},className:`flex items-center gap-1.5 px-3 py-1 font-bold rounded-full transition-colors ${!Xe&&!ot?"bg-emerald-600 text-white shadow-lg":"bg-slate-800 text-slate-300 hover:text-white"}`,title:"Activer/Désactiver le mode Plein Écran sans volets",children:!Xe&&!ot?"👁️ Volets":"🖥️ Plein Écran"})]}),f.jsxs("div",{className:"pointer-events-auto hidden sm:flex items-center gap-3 px-3.5 py-1 bg-slate-900/80 backdrop-blur-md rounded-full border border-slate-800/80 text-[10px] font-bold shadow-lg",children:[f.jsxs("div",{className:"flex items-center gap-1.5 text-pink-400",children:[f.jsx("span",{className:"w-4 h-0 border-t-2 border-dashed border-pink-500 inline-block"}),f.jsx("span",{children:"💍 Mariage / Union"})]}),f.jsx("span",{className:"text-slate-600",children:"•"}),f.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[f.jsx("span",{className:"w-4 h-1 bg-blue-500 rounded-full inline-block"}),f.jsx("span",{children:"🧬 Parent (Ascendance)"})]}),f.jsx("span",{className:"text-slate-600",children:"•"}),f.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400",children:[f.jsx("span",{className:"w-4 h-1 bg-emerald-500 rounded-full inline-block"}),f.jsx("span",{children:"🍼 Enfant (Descendance)"})]})]})]}),f.jsx(p_,{position:"bottom-center",className:"mb-4 pointer-events-none",children:f.jsxs("div",{className:"pointer-events-auto bg-slate-900/95 backdrop-blur-2xl px-4 py-2 rounded-2xl shadow-2xl border border-slate-800 flex items-center gap-2 text-xs flex-wrap justify-center",children:[f.jsx("span",{className:"text-slate-400 font-extrabold uppercase text-[10px] tracking-widest hidden sm:inline mr-1",children:"🧭 Navigation:"}),f.jsxs("button",{onClick:()=>{Se.parents.length>0?(V(Se.parents[0].id),jt.success(`Centré sur ${Se.parents[0].label}`)):jt("Aucun parent répertorié")},disabled:Se.parents.length===0,className:"px-2.5 py-1.5 bg-slate-800 hover:bg-emerald-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-[11px] flex items-center gap-1 transition-all",title:"Sauter au Parent (Père/Mère)",children:[f.jsx(N2,{size:10})," Parent"]}),f.jsxs("button",{onClick:()=>{Se.spouses.length>0?(V(Se.spouses[0].id),jt.success(`Centré sur ${Se.spouses[0].label}`)):jt("Aucun conjoint répertorié")},disabled:Se.spouses.length===0,className:"px-2.5 py-1.5 bg-slate-800 hover:bg-rose-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-[11px] flex items-center gap-1 transition-all",title:"Sauter au Conjoint",children:[f.jsx(Y0,{size:10,className:"text-rose-400"})," Conjoint"]}),f.jsxs("button",{onClick:()=>{Se.siblings.length>0?(V(Se.siblings[0].id),jt.success(`Centré sur ${Se.siblings[0].label}`)):jt("Aucun frère/sœur répertorié")},disabled:Se.siblings.length===0,className:"px-2.5 py-1.5 bg-slate-800 hover:bg-amber-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-[11px] flex items-center gap-1 transition-all",title:"Sauter à la Fratrie",children:[f.jsx(jA,{size:10})," Fratrie"]}),f.jsxs("button",{onClick:()=>{Se.children.length>0?(V(Se.children[0].id),jt.success(`Centré sur ${Se.children[0].label}`)):jt("Aucun enfant répertorié")},disabled:Se.children.length===0,className:"px-2.5 py-1.5 bg-slate-800 hover:bg-blue-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-[11px] flex items-center gap-1 transition-all",title:"Sauter aux Enfants",children:[f.jsx(B1,{size:10})," Enfant"]}),f.jsx("div",{className:"h-4 w-px bg-slate-800 mx-1 hidden sm:block"}),f.jsxs("button",{onClick:()=>{V(Ht),jt.success("Retour à la personne Racine Sosa 1")},className:"px-2.5 py-1.5 bg-amber-500/20 text-amber-300 hover:bg-amber-500 hover:text-amber-950 rounded-xl font-bold text-[11px] flex items-center gap-1 transition-all border border-amber-500/40",title:"Changer pour la personne Racine Sosa 1",children:[f.jsx(tN,{size:10})," Racine Sosa 1"]}),f.jsx("button",{onClick:()=>{var $e;if(o.length>0){const ut=o[Math.floor(Math.random()*o.length)];ut&&!(($e=ut.data)!=null&&$e.is_placeholder)&&(V(ut.id),jt.success(`Au hasard: ${ut.data.prenom} ${ut.data.nom}`))}},className:"px-2.5 py-1.5 bg-slate-800 hover:bg-purple-600 text-slate-200 hover:text-white rounded-xl font-bold text-[11px] flex items-center gap-1 transition-all",title:"Changer pour une personne au hasard",children:"🎲 Au hasard"})]})}),f.jsx(p_,{position:"bottom-left",className:"mb-4 ml-4 hidden md:block pointer-events-none",children:f.jsxs("div",{className:"pointer-events-auto bg-slate-900/90 backdrop-blur-2xl p-3 rounded-2xl shadow-2xl border border-slate-800 w-52 flex flex-col gap-2",children:[f.jsx("div",{className:"text-[10px] font-black text-slate-400 uppercase tracking-wider px-1",children:"Exportation"}),f.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[f.jsxs("button",{onClick:()=>zt("pdf"),disabled:k,className:"flex items-center justify-center gap-2 p-2 bg-emerald-600 hover:bg-emerald-500 text-white font-bold text-xs rounded-xl transition-all disabled:opacity-50",children:[f.jsx(DCe,{size:14})," PDF"]}),f.jsxs("button",{onClick:()=>zt("png"),disabled:k,className:"flex items-center justify-center gap-2 p-2 bg-slate-800 hover:bg-slate-700 text-emerald-400 font-bold text-xs rounded-xl border border-slate-700 transition-all disabled:opacity-50",children:[f.jsx(fH,{size:14})," PNG"]})]}),f.jsxs("a",{href:`${jm}/api/export/gedcom`,download:"arbre.ged",className:"flex items-center justify-center gap-2 p-2 bg-indigo-900/60 hover:bg-indigo-800/80 text-indigo-300 font-bold text-xs rounded-xl border border-indigo-700/50 transition-all",children:[f.jsx(T3,{size:12})," Export GEDCOM"]})]})})]})}),f.jsxs("button",{onClick:()=>bt(!ot),className:`absolute top-1/2 -translate-y-1/2 z-40 bg-slate-900/95 hover:bg-emerald-600 text-emerald-400 hover:text-white p-3 rounded-l-2xl border-y border-l border-slate-700/80 shadow-[0_10px_25px_rgba(0,0,0,0.5)] transition-all duration-300 flex items-center gap-1 group ${ot?"right-80 sm:right-96":"right-0"}`,title:ot?"Réduire l'Inspecteur & Boussole":"Déplier l'Inspecteur & Boussole",children:[f.jsx("span",{className:"max-w-0 overflow-hidden group-hover:max-w-xs transition-all whitespace-nowrap text-xs font-bold pr-0 group-hover:pr-1",children:ot?"Masquer Boussole":"Ouvrir Boussole"}),ot?f.jsx(_A,{size:16}):f.jsx(n4,{size:16})]}),ot&&f.jsxs("div",{className:"absolute top-0 bottom-0 right-0 z-30 w-80 sm:w-96 bg-slate-900/98 backdrop-blur-2xl border-l border-slate-800 flex flex-col shadow-[-10px_0_30px_rgba(0,0,0,0.5)] transition-all overflow-y-auto custom-scrollbar p-4 space-y-4 animate-in slide-in-from-right duration-300",children:[f.jsxs("div",{className:"bg-slate-950/80 border border-slate-800 rounded-2xl p-3 shadow-inner",children:[f.jsxs("div",{className:"text-xs font-extrabold text-emerald-400 uppercase tracking-wider mb-2 flex items-center justify-between",children:[f.jsx("span",{children:"🧭 Boussole Généalogique"}),f.jsxs("button",{onClick:()=>V(Ht),className:"text-[10px] bg-amber-500/20 text-amber-300 px-2 py-0.5 rounded-md border border-amber-500/30 flex items-center gap-1 hover:bg-amber-500/30",title:"Revenir à la personne Racine Sosa 1",children:[f.jsx(tN,{size:10})," Racine Sosa 1"]})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-1.5 text-center mt-2",children:[f.jsx("div",{}),f.jsxs("button",{onClick:()=>{Se.parents.length>0?V(Se.parents[0].id):jt("Aucun parent enregistré")},disabled:Se.parents.length===0,className:"p-2 bg-slate-800 hover:bg-emerald-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-xs flex flex-col items-center gap-1 transition-all",title:"Sauter aux Parents",children:[f.jsx(N2,{}),f.jsx("span",{className:"text-[10px]",children:"Parents"})]}),f.jsx("div",{}),f.jsxs("button",{onClick:()=>{Se.siblings.length>0?V(Se.siblings[0].id):jt("Aucun frère/sœur enregistré")},disabled:Se.siblings.length===0,className:"p-2 bg-slate-800 hover:bg-emerald-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-xs flex flex-col items-center gap-1 transition-all",title:"Sauter aux Frères/Sœurs",children:[f.jsx(n4,{}),f.jsx("span",{className:"text-[10px]",children:"Sœurs/Frères"})]}),f.jsx("button",{onClick:()=>V(Ht),className:"p-2 bg-amber-600/30 text-amber-300 hover:bg-amber-600 hover:text-white rounded-xl font-bold text-xs flex flex-col items-center justify-center transition-all border border-amber-500/40",title:"Retour Racine Sosa 1",children:f.jsx(tN,{size:16})}),f.jsxs("button",{onClick:()=>{Se.spouses.length>0?V(Se.spouses[0].id):jt("Aucun conjoint enregistré")},disabled:Se.spouses.length===0,className:"p-2 bg-slate-800 hover:bg-emerald-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-xs flex flex-col items-center gap-1 transition-all",title:"Sauter aux Conjoints",children:[f.jsx(_A,{}),f.jsx("span",{className:"text-[10px]",children:"Conjoints"})]}),f.jsx("div",{}),f.jsxs("button",{onClick:()=>{Se.children.length>0?V(Se.children[0].id):jt("Aucun enfant enregistré")},disabled:Se.children.length===0,className:"p-2 bg-slate-800 hover:bg-emerald-600 disabled:opacity-30 disabled:hover:bg-slate-800 text-slate-200 hover:text-white rounded-xl font-bold text-xs flex flex-col items-center gap-1 transition-all",title:"Sauter aux Enfants",children:[f.jsx(B1,{}),f.jsx("span",{className:"text-[10px]",children:"Enfants"})]}),f.jsx("div",{})]})]}),st&&f.jsxs("div",{className:"bg-slate-950/80 border border-slate-800 rounded-2xl p-4 shadow-inner space-y-3",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx(q0,{person:st,className:"w-14 h-14",rounded:"rounded-2xl shadow-md border-2 border-emerald-500",dark:!0}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f.jsxs("h4",{className:"font-extrabold text-sm text-white truncate",children:[st.prenom," ",f.jsx("span",{className:"uppercase text-emerald-400",children:st.nom})]}),st.sexe&&f.jsx("span",{className:`text-[9px] px-1.5 py-0.2 rounded-full font-bold ${st.sexe==="F"?"bg-pink-500/20 text-pink-300 border border-pink-500/30":"bg-sky-500/20 text-sky-300 border border-sky-500/30"}`,children:st.sexe==="F"?"F":"H"})]}),f.jsxs("div",{className:"mt-1 flex flex-col gap-0.5 text-[11px] font-semibold",children:[st.date_naissance||st.annee_naissance?f.jsxs("div",{className:"text-emerald-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-emerald-900/60 text-emerald-300 px-1 rounded text-[9px] font-black",children:"N"}),f.jsx("span",{children:st.date_naissance||st.annee_naissance}),st.lieu_naissance&&f.jsxs("span",{className:"text-slate-400 text-[10px] truncate",children:["(",st.lieu_naissance,")"]})]}):f.jsxs("div",{className:"text-orange-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-orange-900/60 text-orange-300 px-1 rounded text-[9px] font-black",children:"N"}),f.jsx("span",{className:"italic text-[10px]",children:"Date naissance inconnue"})]}),st.date_mariage&&f.jsxs("div",{className:"text-pink-400 flex items-center gap-1",children:[f.jsx("span",{className:"bg-pink-900/60 text-pink-300 px-1 rounded text-[9px] font-black",children:"M"}),f.jsx("span",{children:st.date_mariage})]}),st.date_deces&&f.jsxs("div",{className:"text-slate-300 flex items-center gap-1",children:[f.jsx("span",{className:"bg-slate-800 text-slate-300 px-1 rounded text-[9px] font-black",children:"D"}),f.jsx("span",{children:st.date_deces}),st.lieu_deces&&f.jsxs("span",{className:"text-slate-400 text-[10px] truncate",children:["(",st.lieu_deces,")"]})]}),st.profession?f.jsxs("div",{className:"text-slate-400 text-[10px] truncate mt-0.5",children:["💼 ",st.profession]}):f.jsx("div",{className:"text-orange-400/90 text-[10px] italic",children:"⚠️ Profession à renseigner"})]})]})]}),st.biographie&&f.jsxs("div",{className:"p-2 rounded-xl bg-purple-950/40 border border-purple-800/40 text-[10px] space-y-1",children:[f.jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-gradient-to-r from-purple-600 to-indigo-600 text-white font-black text-[8px]",children:"✨ Résumé IA"}),f.jsxs("p",{className:"text-purple-200 italic line-clamp-2",children:['"',st.biographie.replace(/<[^>]*>?/gm,"").trim(),'"']})]}),f.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[f.jsxs("button",{onClick:()=>n&&n(st),className:"w-full py-1.5 px-2 bg-emerald-600 hover:bg-emerald-500 text-white rounded-xl font-bold text-[11px] flex items-center justify-center gap-1 transition-all shadow-md",children:[f.jsx(hm,{size:10})," Fiche Complète"]}),f.jsxs("button",{onClick:()=>nt(st.slug,"child"),className:"w-full py-1.5 px-2 bg-slate-800 hover:bg-slate-700 text-slate-200 rounded-xl font-bold text-[11px] flex items-center justify-center gap-1 border border-slate-700 transition-all",children:[f.jsx(P0,{size:10})," Ajouter Enfant"]}),e&&f.jsxs("button",{onClick:()=>e(st),className:"col-span-2 py-1.5 px-2 bg-slate-800 hover:bg-emerald-950/80 text-emerald-400 border border-emerald-800/60 rounded-xl font-bold text-[11px] flex items-center justify-center gap-1 transition-all hover:scale-105",children:[f.jsx(Pg,{size:10})," ✏️ Modifier / Supprimer Fiche"]})]})]}),f.jsxs("div",{className:"bg-slate-950/80 border border-slate-800 rounded-2xl p-3 shadow-inner flex-1 space-y-2",children:[f.jsxs("div",{className:"text-xs font-extrabold text-emerald-400 uppercase tracking-wider mb-2",children:["📑 Relations de ",(st==null?void 0:st.prenom)||"l'individu"]}),f.jsxs("div",{children:[f.jsxs("button",{onClick:()=>lt("parents"),className:"w-full flex items-center justify-between p-2 rounded-xl bg-slate-900 hover:bg-slate-850 text-xs font-bold text-slate-200 transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{children:"👨‍👩‍👦"}),f.jsx("span",{children:"Parents"}),f.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] bg-slate-800 text-emerald-400 border border-slate-700",children:Se.parents.length})]}),ht.parents?f.jsx(N2,{size:10}):f.jsx(B1,{size:10})]}),ht.parents&&f.jsx("div",{className:"mt-1 pl-2 space-y-1",children:Se.parents.length===0?f.jsx("p",{className:"text-[10px] text-slate-500 italic p-1",children:"Aucun parent répertorié"}):Se.parents.map($e=>f.jsxs("button",{onClick:()=>V($e.id),className:"w-full text-left px-2 py-1 rounded-lg hover:bg-slate-800 text-[11px] text-slate-300 hover:text-emerald-400 transition-colors flex items-center justify-between",children:[f.jsx("span",{className:"truncate",children:$e.label}),f.jsx("span",{className:"text-[9px] text-slate-500",children:"→"})]},$e.id))})]}),f.jsxs("div",{children:[f.jsxs("button",{onClick:()=>lt("spouses"),className:"w-full flex items-center justify-between p-2 rounded-xl bg-slate-900 hover:bg-slate-850 text-xs font-bold text-slate-200 transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{children:"💍"}),f.jsx("span",{children:"Conjoints"}),f.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] bg-slate-800 text-pink-400 border border-slate-700",children:Se.spouses.length})]}),ht.spouses?f.jsx(N2,{size:10}):f.jsx(B1,{size:10})]}),ht.spouses&&f.jsx("div",{className:"mt-1 pl-2 space-y-1",children:Se.spouses.length===0?f.jsx("p",{className:"text-[10px] text-slate-500 italic p-1",children:"Aucun conjoint répertorié"}):Se.spouses.map($e=>f.jsxs("button",{onClick:()=>V($e.id),className:"w-full text-left px-2 py-1 rounded-lg hover:bg-slate-800 text-[11px] text-slate-300 hover:text-pink-400 transition-colors flex items-center justify-between",children:[f.jsx("span",{className:"truncate",children:$e.label}),f.jsx("span",{className:"text-[9px] text-slate-500",children:"→"})]},$e.id))})]}),f.jsxs("div",{children:[f.jsxs("button",{onClick:()=>lt("children"),className:"w-full flex items-center justify-between p-2 rounded-xl bg-slate-900 hover:bg-slate-850 text-xs font-bold text-slate-200 transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{children:"👶"}),f.jsx("span",{children:"Enfants"}),f.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] bg-slate-800 text-blue-400 border border-slate-700",children:Se.children.length})]}),ht.children?f.jsx(N2,{size:10}):f.jsx(B1,{size:10})]}),ht.children&&f.jsx("div",{className:"mt-1 pl-2 space-y-1",children:Se.children.length===0?f.jsx("p",{className:"text-[10px] text-slate-500 italic p-1",children:"Aucun enfant répertorié"}):Se.children.map($e=>f.jsxs("button",{onClick:()=>V($e.id),className:"w-full text-left px-2 py-1 rounded-lg hover:bg-slate-800 text-[11px] text-slate-300 hover:text-blue-400 transition-colors flex items-center justify-between",children:[f.jsx("span",{className:"truncate",children:$e.label}),f.jsx("span",{className:"text-[9px] text-slate-500",children:"→"})]},$e.id))})]}),f.jsxs("div",{children:[f.jsxs("button",{onClick:()=>lt("siblings"),className:"w-full flex items-center justify-between p-2 rounded-xl bg-slate-900 hover:bg-slate-850 text-xs font-bold text-slate-200 transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{children:"👫"}),f.jsx("span",{children:"Fratrie (Frères & Sœurs)"}),f.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] bg-slate-800 text-amber-400 border border-slate-700",children:Se.siblings.length})]}),ht.siblings?f.jsx(N2,{size:10}):f.jsx(B1,{size:10})]}),ht.siblings&&f.jsx("div",{className:"mt-1 pl-2 space-y-1",children:Se.siblings.length===0?f.jsx("p",{className:"text-[10px] text-slate-500 italic p-1",children:"Aucun frère/sœur répertorié(e)"}):Se.siblings.map($e=>f.jsxs("button",{onClick:()=>V($e.id),className:"w-full text-left px-2 py-1 rounded-lg hover:bg-slate-800 text-[11px] text-slate-300 hover:text-amber-400 transition-colors flex items-center justify-between",children:[f.jsx("span",{className:"truncate",children:$e.label}),f.jsx("span",{className:"text-[9px] text-slate-500",children:"→"})]},$e.id))})]}),f.jsxs("div",{children:[f.jsxs("button",{onClick:()=>lt("grandparents"),className:"w-full flex items-center justify-between p-2 rounded-xl bg-slate-900 hover:bg-slate-850 text-xs font-bold text-slate-200 transition-colors",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{children:"👵"}),f.jsx("span",{children:"Grands-Parents"}),f.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] bg-slate-800 text-amber-400 border border-slate-700",children:Se.grandparents.length})]}),ht.grandparents?f.jsx(N2,{size:10}):f.jsx(B1,{size:10})]}),ht.grandparents&&f.jsx("div",{className:"mt-1 pl-2 space-y-1",children:Se.grandparents.length===0?f.jsx("p",{className:"text-[10px] text-slate-500 italic p-1",children:"Aucun grand-parent répertorié"}):Se.grandparents.map($e=>f.jsxs("button",{onClick:()=>V($e.id),className:"w-full text-left px-2 py-1 rounded-lg hover:bg-slate-800 text-[11px] text-slate-300 hover:text-amber-400 transition-colors flex items-center justify-between",children:[f.jsx("span",{className:"truncate",children:$e.label}),f.jsx("span",{className:"text-[9px] text-slate-500",children:"→"})]},$e.id))})]})]})]}),Bt(),f.jsx(sHe,{isOpen:!!_t,onClose:()=>It(null),sourcePerson:_t==null?void 0:_t.sourcePerson,targetPerson:_t==null?void 0:_t.targetPerson,allPeople:ft.map($e=>$e.data),initialRelation:(_t==null?void 0:_t.initialRelation)||"parent_of",onSuccess:()=>{It(null),Yt()}}),Q&&f.jsx(s2e,{isOpen:!!Q,onClose:()=>re(null),person:Q,people:ft.map($e=>$e.data),onUpdatePerson:$e=>{re($e),Yt()},onNavigateToPerson:$e=>{const ut=o.find(Gt=>Gt.id===$e);ut&&(re(ut.data),Lt($e))}}),De&&f.jsxs("div",{style:{top:`${De.y}px`,left:`${De.x}px`},className:"fixed z-50 w-72 bg-slate-900/98 backdrop-blur-2xl border border-slate-700/80 rounded-2xl shadow-[0_20px_50px_rgba(0,0,0,0.7)] py-2 text-slate-200 text-xs animate-in fade-in zoom-in-95 duration-150 select-none divide-y divide-slate-800/60",onClick:$e=>$e.stopPropagation(),children:[f.jsxs("div",{className:"px-3.5 py-2.5 flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-800 border border-slate-700 flex items-center justify-center font-bold text-amber-400 overflow-hidden shrink-0 shadow-md",children:De.person.photo_url||De.person.photo?f.jsx("img",{src:(De.person.photo_url||De.person.photo).startsWith("/")?`${jm}${De.person.photo_url||De.person.photo}`:De.person.photo_url||De.person.photo,alt:De.person.prenom,className:"w-full h-full object-cover"}):f.jsx("span",{children:De.person.prenom?De.person.prenom.charAt(0):"?"})}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("p",{className:"font-extrabold text-slate-100 truncate text-sm",children:[De.person.prenom," ",De.person.nom]}),f.jsxs("p",{className:"text-[11px] text-emerald-400 truncate",children:[De.person.date_naissance?`Né(e) en ${String(De.person.date_naissance).substring(0,4)}`:"Généalogie",De.person.profession?` • ${De.person.profession}`:""]})]})]}),f.jsx("div",{className:"py-1",children:f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),Lt($e)},className:"w-full px-3 py-1.5 text-left hover:bg-emerald-950/60 hover:text-emerald-300 flex items-center gap-2.5 text-emerald-400 font-bold transition",children:[f.jsx("span",{className:"text-sm",children:"👑"}),f.jsx("span",{children:"Centrer l'arbre sur ce membre"})]})}),f.jsxs("div",{className:"py-1",children:[f.jsxs("button",{onClick:()=>{const $e=De.person;ue(null),n&&n($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-white transition",children:[f.jsx("span",{className:"text-sky-400 text-sm",children:"👤"}),f.jsx("span",{children:"Voir la fiche profil (Double-clic)"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person;ue(null),re($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-amber-300 hover:text-amber-200 font-medium transition",children:[f.jsx("span",{className:"text-sm",children:"📖"}),f.jsx("span",{children:"Ouvrir le Dossier Vivant (Actes & Récits)"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person;ue(null),t?t($e):n&&n($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-teal-300 hover:text-teal-200 transition",children:[f.jsx("span",{className:"text-sm",children:"⏳"}),f.jsx("span",{children:"Frise Chronologique de vie"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person;ue(null),e&&e($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-white transition",children:[f.jsx("span",{className:"text-amber-400 text-sm",children:"✏️"}),f.jsx("span",{children:"Modifier les informations"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),tt($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-white transition",children:[f.jsx("span",{className:"text-pink-400 text-sm",children:"📸"}),f.jsx("span",{children:"Changer la photo de profil"})]})]}),f.jsxs("div",{className:"py-1",children:[f.jsx("div",{className:"px-3 py-1 text-[10px] font-black uppercase tracking-wider text-slate-500",children:"Focus Généalogique"}),f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),ge("ancestors"),Lt($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-blue-300 hover:text-blue-200 transition",children:[f.jsx("span",{className:"text-sm",children:"🧬"}),f.jsx("span",{children:"Arbre d'Ascendance (Parents & Ancêtres)"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),ge("descendants"),Lt($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-emerald-300 hover:text-emerald-200 transition",children:[f.jsx("span",{className:"text-sm",children:"🍼"}),f.jsx("span",{children:"Arbre de Descendance (Enfants & Descendants)"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),ge("core"),Lt($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-white transition",children:[f.jsx("span",{className:"text-sm",children:"👥"}),f.jsx("span",{children:"Famille Proche (Noyau)"})]})]}),f.jsxs("div",{className:"py-1",children:[f.jsx("div",{className:"px-3 py-1 text-[10px] font-black uppercase tracking-wider text-slate-500",children:"Ajouter une relation"}),f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),nt($e,"child")},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-emerald-400 transition",children:[f.jsx("span",{className:"text-sm",children:"👶"}),f.jsx("span",{children:"Ajouter un enfant"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),nt($e,"parent")},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-sky-400 transition",children:[f.jsx("span",{className:"text-sm",children:"🧬"}),f.jsx("span",{children:"Ajouter un parent"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person.slug;ue(null),nt($e,"conjoint")},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-pink-400 transition",children:[f.jsx("span",{className:"text-sm",children:"💍"}),f.jsx("span",{children:"Ajouter un conjoint / pacsé"})]}),f.jsxs("button",{onClick:()=>{const $e=De.person;ue(null),vt($e)},className:"w-full px-3 py-1.5 text-left hover:bg-slate-800/80 flex items-center gap-2.5 text-slate-200 hover:text-amber-400 transition",children:[f.jsx("span",{className:"text-sm",children:"🔗"}),f.jsx("span",{children:"Relier à un membre existant"})]})]}),f.jsx("div",{className:"py-1",children:f.jsxs("button",{onClick:()=>{const $e=De.person;ue(null),window.confirm(`Voulez-vous vraiment supprimer définitivement ${$e.prenom} ${$e.nom} de l'arbre généalogique ?`)&&Qt($e.slug)},className:"w-full px-3 py-1.5 text-left hover:bg-rose-950/60 flex items-center gap-2.5 text-rose-400 hover:text-rose-300 transition",children:[f.jsx("span",{className:"text-rose-400 text-sm",children:"🗑️"}),f.jsx("div",{className:"font-semibold",children:"Supprimer ce membre"})]})})]})]})]})};function lHe({onNodeClick:n,onEditPerson:e,onNavigateToTimeline:t}){return f.jsx(zH,{children:f.jsx(oHe,{onNodeClick:n,onEditPerson:e,onNavigateToTimeline:t})})}const Nj="https://famille.ravin-cloud.fr";function a2e({isOpen:n,onClose:e,photos:t=[],initialIndex:r=0,title:i="Galerie Photos",onSetProfilePhoto:s=null,currentAvatarUrl:a=null,people:o=[],onRefreshPeople:l=null}){const[c,u]=de.useState(r),[d,h]=de.useState(!1),[p,g]=de.useState("profile"),[x,_]=de.useState(""),[y,M]=de.useState(null);if(de.useEffect(()=>{n&&(u(r),h(!1),_(""))},[n,r]),de.useEffect(()=>{if(!n)return;const W=J=>{J.key==="Escape"&&(d?h(!1):e()),J.key==="ArrowRight"&&!d&&$(),J.key==="ArrowLeft"&&!d&&G()};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[n,c,t,d]),!n||!t||t.length===0)return null;const C=t[c]||t[0],k=typeof C=="string"?C:C.src,B=C.date||null,U=C.lieu||null,z=C.title||null,O=C.source||"Album Familial";C.associated_people;const V=a&&(a===k||k.endsWith(a)||a.endsWith(k)),$=()=>{u(W=>(W+1)%t.length)},G=()=>{u(W=>(W-1+t.length)%t.length)},H=async(W,J="profile")=>{if(!W||!W.slug)return;M(W.slug);const ie=jt.loading(J==="profile"?`Définition du profil pour ${W.prenom}...`:`Ajout à la galerie de ${W.prenom}...`);try{if(J==="profile"){const ae=await fetch(`${Nj}/api/people/${W.slug}/set-profile-photo`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({photo_url:k})}),Q=await ae.json();if(!ae.ok)throw new Error(Q.error||"Erreur de mise à jour");jt.success(`Photo définie comme profil de ${W.prenom} ${W.nom} !`,{id:ie,icon:"⭐"})}else{const ae=await fetch(`${Nj}/api/media/tag-person`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({slug:W.slug,photo_url:k,action:"add"})}),Q=await ae.json();if(!ae.ok)throw new Error(Q.error||"Erreur d'association");jt.success(`Photo ajoutée à la galerie de ${W.prenom} ${W.nom} !`,{id:ie,icon:"👥"})}h(!1),s&&V&&s(k),l&&l()}catch(ae){jt.error(ae.message||"Impossible de mettre à jour",{id:ie})}finally{M(null)}},K=(o||[]).filter(W=>{if(!x.trim())return!0;const J=x.toLowerCase();return`${W.prenom||""} ${W.nom||""}`.toLowerCase().includes(J)||W.surnom&&W.surnom.toLowerCase().includes(J)});return f.jsx(Da,{children:f.jsxs(Gn.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-50 flex items-center justify-center bg-black/95 backdrop-blur-2xl select-none",onClick:e,children:[f.jsxs("div",{className:"absolute top-0 inset-x-0 p-4 sm:p-6 flex items-center justify-between text-white z-20 bg-gradient-to-b from-black/80 to-transparent flex-wrap gap-2",onClick:W=>W.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-amber-400 font-bold text-sm sm:text-base",children:i}),f.jsxs("span",{className:"px-2.5 py-0.5 rounded-full bg-white/10 text-slate-300 text-xs font-mono font-bold",children:[c+1," / ",t.length]})]}),f.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[s&&f.jsxs("button",{onClick:()=>s(k),className:`px-3 py-1.5 rounded-xl text-xs font-black flex items-center gap-1.5 transition shadow-lg ${V?"bg-emerald-600/90 text-white border border-emerald-400":"bg-amber-500 hover:bg-amber-400 text-slate-950 hover:scale-105 active:scale-95"}`,title:"Définir comme photo de profil principale",children:[V?f.jsx(td,{size:12}):f.jsx(V0,{size:12}),f.jsx("span",{className:"hidden sm:inline",children:V?"Profil Actif":"Mon Profil"}),f.jsx("span",{className:"sm:hidden",children:V?"Profil":"Choisir"})]}),o&&o.length>0&&f.jsx("div",{className:"relative",children:f.jsxs("button",{onClick:()=>{g("profile"),h(!d)},className:"px-3 py-1.5 rounded-xl text-xs font-black bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-500 hover:to-purple-500 text-white flex items-center gap-1.5 transition shadow-lg hover:scale-105 active:scale-95 border border-indigo-400/40",title:"Définir cette photo comme photo de profil de n'importe quel membre de la famille",children:[f.jsx(M7,{size:12}),f.jsx("span",{children:"Attribuer à un membre..."})]})}),f.jsx("a",{href:k,download:!0,target:"_blank",rel:"noreferrer",className:"p-2.5 rounded-full bg-white/10 hover:bg-white/20 text-white transition hover:scale-110",title:"Télécharger l'image HD",children:f.jsx(T3,{size:14})}),f.jsx("button",{onClick:e,className:"p-2.5 rounded-full bg-rose-500/80 hover:bg-rose-600 text-white transition hover:scale-110 shadow-lg",title:"Fermer (Échap)",children:f.jsx($a,{size:16})})]})]}),f.jsx(Da,{children:d&&f.jsx("div",{className:"fixed inset-0 z-60 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",onClick:()=>h(!1),children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"w-full max-w-md bg-slate-900 border border-slate-700 rounded-3xl p-5 shadow-2xl space-y-4 text-white",onClick:W=>W.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-3",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xl",children:"⭐"}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-base font-black text-amber-400",children:p==="profile"?"Définir comme photo de profil":"Ajouter à la galerie"}),f.jsx("p",{className:"text-xs text-slate-400",children:"Sélectionnez le membre de la famille"})]})]}),f.jsx("button",{onClick:()=>h(!1),className:"p-1.5 rounded-full bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white",children:f.jsx($a,{size:14})})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{onClick:()=>g("profile"),className:`flex-1 py-1.5 px-3 rounded-xl text-xs font-bold transition flex items-center justify-center gap-1.5 ${p==="profile"?"bg-amber-500 text-slate-950 shadow-md":"bg-slate-800 text-slate-400 hover:text-white"}`,children:[f.jsx(V0,{size:11})," Photo de profil"]}),f.jsxs("button",{onClick:()=>g("gallery"),className:`flex-1 py-1.5 px-3 rounded-xl text-xs font-bold transition flex items-center justify-center gap-1.5 ${p==="gallery"?"bg-indigo-600 text-white shadow-md":"bg-slate-800 text-slate-400 hover:text-white"}`,children:[f.jsx(F_,{size:11})," Album / Galerie"]})]}),f.jsxs("div",{className:"relative",children:[f.jsx(X0,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"}),f.jsx("input",{type:"text",value:x,onChange:W=>_(W.target.value),placeholder:"Rechercher par prénom, nom...",className:"w-full bg-slate-800 border border-slate-700 rounded-xl pl-9 pr-4 py-2 text-xs text-white placeholder-slate-400 focus:outline-none focus:border-amber-400",autoFocus:!0})]}),f.jsx("div",{className:"max-h-60 overflow-y-auto space-y-1.5 pr-1 custom-scrollbar",children:K.map(W=>{var Q,re;const J=W.photo_url||W.photo||W.avatar,ie=J&&(J===k||k.endsWith(J)),ae=y===W.slug;return f.jsxs("button",{disabled:ae,onClick:()=>H(W,p),className:`w-full p-2.5 rounded-2xl border transition-all flex items-center justify-between gap-3 text-left ${ie?"bg-amber-500/15 border-amber-400/40 text-amber-200":"bg-slate-800/60 hover:bg-slate-800 border-slate-700/60 hover:border-slate-600 text-white"}`,children:[f.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[f.jsx("div",{className:"w-9 h-9 rounded-xl bg-slate-700 overflow-hidden flex items-center justify-center shrink-0 border border-slate-600",children:J?f.jsx("img",{src:J.startsWith("/")?`${Nj}${J}`:J,alt:W.prenom,className:"w-full h-full object-cover"}):f.jsx("span",{className:"text-xs font-bold font-serif text-amber-300",children:(((Q=W.prenom)==null?void 0:Q[0])||"")+(((re=W.nom)==null?void 0:re[0])||"")})}),f.jsxs("div",{className:"min-w-0",children:[f.jsxs("p",{className:"text-xs font-black truncate",children:[W.prenom," ",W.nom]}),W.date_naissance&&f.jsxs("p",{className:"text-[10px] text-slate-400",children:["Né(e) en ",String(W.date_naissance).slice(-4)]})]})]}),f.jsx("div",{className:"shrink-0",children:ae?f.jsx("span",{className:"text-xs text-amber-400 font-bold animate-pulse",children:"Application..."}):ie&&p==="profile"?f.jsx("span",{className:"text-[10px] font-bold text-emerald-400 bg-emerald-950/60 px-2 py-0.5 rounded-full border border-emerald-500/30 flex items-center gap-1",children:"✓ Profil Actuel"}):f.jsx("span",{className:"text-xs font-bold text-indigo-400 group-hover:text-indigo-300",children:"Choisir →"})})]},W.slug)})})]})})}),t.length>1&&f.jsx("button",{onClick:W=>{W.stopPropagation(),G()},className:"absolute left-3 sm:left-6 z-20 p-3 sm:p-4 rounded-full bg-black/60 hover:bg-black/90 text-white border border-white/20 hover:border-amber-400 transition hover:scale-110 shadow-2xl",title:"Photo précédente (←)",children:f.jsx(n4,{size:20})}),f.jsxs("div",{className:"relative max-w-5xl max-h-[75vh] sm:max-h-[80vh] flex flex-col items-center justify-center p-2 sm:p-4 z-10",onClick:W=>W.stopPropagation(),children:[f.jsx(Gn.img,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},transition:{duration:.2},src:k,alt:z||"Photo",className:"max-h-[65vh] sm:max-h-[72vh] max-w-full object-contain rounded-2xl shadow-2xl border border-white/10"},c),f.jsxs("div",{className:"mt-3 text-center text-slate-200 max-w-2xl px-4 space-y-1",children:[z&&f.jsx("p",{className:"text-sm font-semibold text-white",children:z}),f.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-slate-400",children:[B&&f.jsxs("span",{className:"flex items-center gap-1 text-amber-300",children:[f.jsx(B_,{size:10})," ",B]}),U&&f.jsxs("span",{className:"flex items-center gap-1 text-emerald-300",children:[f.jsx(bA,{size:10})," ",U]}),f.jsxs("span",{children:["🏛️ ",O]})]})]})]}),t.length>1&&f.jsx("button",{onClick:W=>{W.stopPropagation(),$()},className:"absolute right-3 sm:right-6 z-20 p-3 sm:p-4 rounded-full bg-black/60 hover:bg-black/90 text-white border border-white/20 hover:border-amber-400 transition hover:scale-110 shadow-2xl",title:"Photo suivante (→)",children:f.jsx(_A,{size:20})}),t.length>1&&f.jsx("div",{className:"absolute bottom-3 inset-x-0 z-20 flex justify-center px-4",onClick:W=>W.stopPropagation(),children:f.jsx("div",{className:"flex gap-2 p-2 bg-black/70 backdrop-blur-md rounded-2xl border border-white/10 overflow-x-auto max-w-[90vw] scrollbar-thin",children:t.map((W,J)=>{const ie=typeof W=="string"?W:W.src,ae=J===c;return f.jsx("button",{onClick:()=>u(J),className:`shrink-0 w-12 h-12 rounded-xl overflow-hidden border-2 transition-all duration-200 ${ae?"border-amber-400 scale-110 shadow-md ring-2 ring-amber-400/50":"border-transparent opacity-60 hover:opacity-100"}`,children:f.jsx("img",{src:ie,alt:"thumbnail",className:"w-full h-full object-cover"})},J)})})})]})})}const yp="https://famille.ravin-cloud.fr";function cHe({people:n=[],onRefreshPeople:e=null,onSelectPerson:t=null}){const[r,i]=de.useState("gallery"),[s,a]=de.useState(!1),[o,l]=de.useState(!1),[c,u]=de.useState([]),d=de.useRef(null),[h,p]=de.useState([]),[g,x]=de.useState(!1),[_,y]=de.useState("all"),[M,C]=de.useState("all"),[k,B]=de.useState(""),[U,z]=de.useState(null),[O,V]=de.useState(null),[$,G]=de.useState("profile"),[H,K]=de.useState(""),[W,J]=de.useState(!1),ie=async()=>{x(!0);try{const ge=await fetch(`${yp}/api/media/all-photos`,{credentials:"include"}),Te=await ge.json();ge.ok&&Te.photos&&p(Te.photos)}catch(ge){console.error("Error fetching all photos:",ge)}finally{x(!1)}};de.useEffect(()=>{ie()},[]);const ae=ge=>{ge.preventDefault(),ge.stopPropagation(),ge.type==="dragenter"||ge.type==="dragover"?a(!0):ge.type==="dragleave"&&a(!1)},Q=ge=>{ge.preventDefault(),ge.stopPropagation(),a(!1),ge.dataTransfer.files&&ge.dataTransfer.files[0]&&oe(ge.dataTransfer.files)},re=ge=>{ge.preventDefault(),ge.target.files&&ge.target.files[0]&&oe(ge.target.files)},oe=async ge=>{const Te=Array.from(ge);for(const ze of Te)await fe(ze)},fe=async ge=>{l(!0);const Te=jt.loading(`Analyse de ${ge.name} par l'IA...`),ze=new FormData;ze.append("file",ge);try{const Xe=await fetch(`${yp}/api/media/analyze`,{method:"POST",body:ze,credentials:"include"});if(!Xe.ok)throw new Error("Échec de l'analyse");const Qe=await Xe.json();u(ot=>[...ot,{...Qe,status:"pending",file:ge}]),jt.success("Analyse terminée !",{id:Te}),ie()}catch(Xe){console.error(Xe),jt.error("Erreur lors de l'analyse",{id:Te})}finally{l(!1)}},ee=async ge=>{const Te=c[ge];if(!Te.suggested_slugs||Te.suggested_slugs.length===0){jt.error("Veuillez sélectionner au moins une personne.");return}const ze=jt.loading("Sauvegarde dans l'arbre...");try{if(!(await fetch(`${yp}/api/media/attach`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({slugs:Te.suggested_slugs,date:Te.date,titre:Te.titre,description:Te.description,file_url:Te.file_url})})).ok)throw new Error("Échec de la sauvegarde");jt.success("Attaché avec succès !",{id:ze}),u(Qe=>{const ot=[...Qe];return ot[ge].status="attached",ot}),ie(),e&&e()}catch{jt.error("Erreur de sauvegarde",{id:ze})}},me=(ge,Te)=>{u(ze=>{const Xe=[...ze],Qe=Xe[ge];return Qe.suggested_slugs||(Qe.suggested_slugs=[]),Qe.suggested_slugs.includes(Te)?Qe.suggested_slugs=Qe.suggested_slugs.filter(ot=>ot!==Te):Qe.suggested_slugs.push(Te),Xe})},Ae=async(ge,Te)=>{if(!ge||!ge.slug||!O)return;J(!0);const ze=jt.loading(Te==="profile"?`Définition du profil pour ${ge.prenom}...`:`Ajout à la galerie de ${ge.prenom}...`);try{if(Te==="profile"){const Xe=await fetch(`${yp}/api/people/${ge.slug}/set-profile-photo`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({photo_url:O.src})}),Qe=await Xe.json();if(!Xe.ok)throw new Error(Qe.error||"Erreur de mise à jour");jt.success(`Photo définie comme profil de ${ge.prenom} ${ge.nom} !`,{id:ze,icon:"⭐"})}else{const Xe=await fetch(`${yp}/api/media/tag-person`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({slug:ge.slug,photo_url:O.src,action:"add"})}),Qe=await Xe.json();if(!Xe.ok)throw new Error(Qe.error||"Erreur d'association");jt.success(`Photo ajoutée à la galerie de ${ge.prenom} ${ge.nom} !`,{id:ze,icon:"👥"})}V(null),ie(),e&&e()}catch(Xe){jt.error(Xe.message||"Impossible d'affecter la photo",{id:ze})}finally{J(!1)}},be=h.filter(ge=>{if(k.trim()){const Te=k.toLowerCase(),ze=(ge.title||"").toLowerCase().includes(Te),Xe=(ge.filename||"").toLowerCase().includes(Te),Qe=(ge.associated_people||[]).some(ot=>ot.name.toLowerCase().includes(Te));if(!ze&&!Xe&&!Qe)return!1}return!(_!=="all"&&!(ge.associated_people||[]).some(ze=>ze.slug===_)||M==="assigned"&&!ge.is_assigned||M==="unassigned"&&ge.is_assigned)}),pe=ge=>{const Te=be.map(ze=>({src:ze.src.startsWith("http")?ze.src:`${yp}${ze.src}`,title:ze.title,date:ze.date,source:ze.source,associated_people:ze.associated_people}));z({photos:Te,initialIndex:ge,title:"Photothèque Familiale"})};return f.jsxs("div",{className:"w-full max-w-7xl mx-auto space-y-6 pb-32 px-3 sm:px-6",children:[f.jsxs("div",{className:"bg-gradient-to-r from-slate-900 via-indigo-950 to-slate-900 text-white rounded-3xl p-6 sm:p-8 shadow-2xl border border-slate-800 flex flex-col md:flex-row items-start md:items-center justify-between gap-6 relative overflow-hidden",children:[f.jsxs("div",{className:"space-y-2 z-10",children:[f.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-amber-500/20 border border-amber-400/30 text-amber-300 text-xs font-black",children:[f.jsx("span",{children:"✨"}),f.jsx("span",{children:"Médiathèque & Visages de la Famille"})]}),f.jsx("h2",{className:"text-2xl sm:text-4xl font-black tracking-tight text-white font-serif",children:"Photothèque & Médiathèque"}),f.jsxs("p",{className:"text-slate-300 text-xs sm:text-sm max-w-2xl leading-relaxed",children:["Explorez toutes les photos de la famille (",h.length," photos au total). Parcourez les visages à travers les époques et définissez en un clic la photo de profil de chaque personne."]})]}),f.jsxs("div",{className:"flex bg-slate-800/90 p-1.5 rounded-2xl border border-slate-700/80 shrink-0 z-10 shadow-lg",children:[f.jsxs("button",{onClick:()=>i("gallery"),className:`px-4 py-2 rounded-xl text-xs sm:text-sm font-black transition-all flex items-center gap-2 cursor-pointer ${r==="gallery"?"bg-gradient-to-r from-amber-500 to-amber-600 text-slate-950 shadow-md scale-105":"text-slate-300 hover:text-white"}`,children:[f.jsx("span",{children:"🖼️ Photothèque"}),f.jsx("span",{className:`text-[10px] px-1.5 py-0.2 rounded-full font-mono ${r==="gallery"?"bg-slate-950/20 text-slate-950 font-bold":"bg-slate-900 text-amber-400"}`,children:h.length})]}),f.jsx("button",{onClick:()=>i("upload"),className:`px-4 py-2 rounded-xl text-xs sm:text-sm font-black transition-all flex items-center gap-2 cursor-pointer ${r==="upload"?"bg-gradient-to-r from-indigo-600 to-purple-600 text-white shadow-md scale-105":"text-slate-300 hover:text-white"}`,children:f.jsx("span",{children:"📥 Scanner & IA"})})]})]}),r==="gallery"&&f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"bg-white/80 backdrop-blur-xl p-4 rounded-2xl border border-slate-200/80 shadow-sm flex flex-col md:flex-row items-stretch md:items-center justify-between gap-3.5",children:[f.jsxs("div",{className:"relative flex-1",children:[f.jsx(X0,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"}),f.jsx("input",{type:"text",value:k,onChange:ge=>B(ge.target.value),placeholder:"Rechercher par titre, nom de personne, mot-clé...",className:"w-full bg-slate-50 border border-slate-200 rounded-xl pl-9 pr-4 py-2 text-xs font-medium text-slate-800 placeholder-slate-400 focus:outline-none focus:border-amber-400 focus:bg-white transition"}),k&&f.jsx("button",{onClick:()=>B(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 text-xs",children:"✕"})]}),f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsxs("select",{value:_,onChange:ge=>y(ge.target.value),className:"bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-xs font-bold text-slate-700 focus:outline-none focus:border-amber-400 cursor-pointer",children:[f.jsxs("option",{value:"all",children:["👤 Tous les membres (",n.length,")"]}),n.map(ge=>f.jsxs("option",{value:ge.slug,children:[ge.prenom," ",ge.nom]},ge.slug))]}),f.jsxs("select",{value:M,onChange:ge=>C(ge.target.value),className:"bg-slate-50 border border-slate-200 rounded-xl px-3 py-2 text-xs font-bold text-slate-700 focus:outline-none focus:border-amber-400 cursor-pointer",children:[f.jsx("option",{value:"all",children:"📁 Toutes les photos"}),f.jsx("option",{value:"assigned",children:"✅ Déjà associées"}),f.jsx("option",{value:"unassigned",children:"⏳ Non associées"})]}),f.jsx("button",{onClick:ie,disabled:g,className:"p-2.5 bg-slate-100 hover:bg-slate-200 rounded-xl text-slate-600 transition hover:rotate-180 duration-300 cursor-pointer",title:"Actualiser les photos",children:f.jsx(AM,{className:g?"animate-spin":"",size:13})})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-500 font-medium px-1",children:[f.jsxs("span",{children:["Affichage de ",f.jsx("strong",{className:"text-slate-800 font-bold",children:be.length})," photo(s) sur ",h.length]}),_!=="all"&&f.jsx("button",{onClick:()=>y("all"),className:"text-amber-700 hover:underline font-bold cursor-pointer",children:"Réinitialiser le filtre personne"})]}),g?f.jsxs("div",{className:"py-20 flex flex-col items-center justify-center gap-3",children:[f.jsx("div",{className:"w-12 h-12 border-4 border-amber-200 border-t-amber-600 rounded-full animate-spin"}),f.jsx("p",{className:"text-xs font-bold text-slate-500",children:"Chargement de la photothèque..."})]}):be.length===0?f.jsxs("div",{className:"bg-white rounded-3xl p-12 text-center border border-slate-200 space-y-3",children:[f.jsx("div",{className:"w-16 h-16 rounded-full bg-slate-100 flex items-center justify-center text-3xl mx-auto",children:"📷"}),f.jsx("h3",{className:"text-lg font-bold text-slate-800",children:"Aucune photo ne correspond à ces critères"}),f.jsx("p",{className:"text-xs text-slate-500 max-w-sm mx-auto",children:"Essayez d'élargir vos filtres de recherche ou importez de nouvelles photos via le scanner IA."})]}):f.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3 sm:gap-4",children:be.map((ge,Te)=>{var ot;const ze=ge.src.startsWith("http")?ge.src:`${yp}${ge.src}`,Xe=ge.associated_people&&ge.associated_people.length>0,Qe=(ot=ge.associated_people)==null?void 0:ot.some(bt=>bt.is_profile);return f.jsxs(Gn.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.2,delay:Math.min(Te*.015,.3)},className:"group bg-white rounded-2xl overflow-hidden border border-slate-200/80 shadow-xs hover:shadow-xl transition-all duration-300 flex flex-col",children:[f.jsxs("div",{className:"relative aspect-square bg-slate-900 cursor-pointer overflow-hidden",onClick:()=>pe(Te),children:[f.jsx("img",{src:ze,alt:ge.title||"Photo de famille",className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",loading:"lazy"}),f.jsxs("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-black/30 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col justify-between p-2.5",children:[f.jsx("div",{className:"flex justify-end",children:f.jsx("span",{className:"p-1.5 rounded-lg bg-black/60 text-white text-xs hover:bg-black/80",children:f.jsx(Kpe,{})})}),f.jsx("div",{className:"text-center",children:f.jsx("span",{className:"text-[11px] font-bold text-white bg-black/60 px-2.5 py-1 rounded-xl backdrop-blur-xs",children:"🔍 Agrandir"})})]}),Qe&&f.jsxs("div",{className:"absolute top-2 left-2 px-2 py-0.5 rounded-full bg-amber-500 text-slate-950 font-black text-[10px] shadow-md border border-amber-300 flex items-center gap-1",children:[f.jsx(V0,{size:8})," Profil"]})]}),f.jsxs("div",{className:"p-2.5 flex-1 flex flex-col justify-between space-y-2",children:[f.jsxs("div",{className:"space-y-1",children:[f.jsx("p",{className:"text-[11px] font-black text-slate-800 line-clamp-1 leading-snug",children:ge.title||ge.filename}),f.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-slate-400",children:[f.jsx("span",{children:ge.source}),ge.date&&f.jsxs("span",{children:["• ",ge.date]})]})]}),Xe?f.jsx("div",{className:"flex flex-wrap gap-1",children:ge.associated_people.map(bt=>f.jsxs("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-md flex items-center gap-1 ${bt.is_profile?"bg-amber-100 text-amber-900 border border-amber-300":"bg-indigo-50 text-indigo-700 border border-indigo-200"}`,children:[bt.is_profile?"⭐":"👤"," ",bt.name]},bt.slug))}):f.jsx("span",{className:"text-[9px] text-slate-400 italic",children:"Non associée"}),f.jsxs("div",{className:"pt-1.5 border-t border-slate-100 flex items-center justify-between gap-1",children:[f.jsxs("button",{onClick:bt=>{bt.stopPropagation(),V(ge),G("profile")},className:"flex-1 py-1 px-1.5 rounded-lg bg-amber-50 hover:bg-amber-100 text-amber-800 text-[10px] font-black border border-amber-200/80 transition flex items-center justify-center gap-1 cursor-pointer",title:"Définir cette photo comme photo de profil d'un membre",children:[f.jsx(V0,{size:9})," Profil..."]}),f.jsx("button",{onClick:bt=>{bt.stopPropagation(),V(ge),G("gallery")},className:"py-1 px-2 rounded-lg bg-indigo-50 hover:bg-indigo-100 text-indigo-800 text-[10px] font-black border border-indigo-200/80 transition flex items-center justify-center gap-1 cursor-pointer",title:"Ajouter cette photo à l'album d'un membre",children:f.jsx(F_,{size:9})})]})]})]},`${ge.src}-${Te}`)})})]}),r==="upload"&&f.jsxs("div",{className:"space-y-8 max-w-4xl mx-auto",children:[f.jsxs("div",{className:"text-center space-y-2 mt-4",children:[f.jsx("h3",{className:"text-2xl font-black text-slate-800",children:"Scanner & Analyseur Intelligent IA"}),f.jsx("p",{className:"text-slate-500 text-xs sm:text-sm",children:"Déposez vos photos, cartes d'identité, actes d'état civil ou lettres. L'IA extrait automatiquement les dates, reconnaît les personnes et les relie à l'arbre généalogique."})]}),f.jsxs("div",{className:`relative w-full h-64 border-4 border-dashed rounded-3xl flex flex-col items-center justify-center transition-all cursor-pointer overflow-hidden ${s?"border-indigo-500 bg-indigo-50 scale-105":"border-slate-300 bg-white hover:border-indigo-400 hover:bg-indigo-50/50"}`,onDragEnter:ae,onDragLeave:ae,onDragOver:ae,onDrop:Q,onClick:()=>d.current.click(),children:[f.jsx("input",{ref:d,type:"file",multiple:!0,accept:"image/jpeg, image/png, image/webp, application/pdf",className:"hidden",onChange:re}),o?f.jsxs("div",{className:"flex flex-col items-center text-indigo-500",children:[f.jsx(ld,{className:"text-5xl mb-4 animate-bounce"}),f.jsx("p",{className:"font-bold text-lg animate-pulse",children:"L'Intelligence Artificielle analyse vos documents..."})]}):f.jsxs("div",{className:"flex flex-col items-center text-slate-400 pointer-events-none",children:[f.jsx(gM,{className:"text-5xl mb-4 text-indigo-500/70"}),f.jsx("p",{className:"font-bold text-base text-slate-700",children:"Glissez-déposez vos médias ici"}),f.jsx("p",{className:"text-xs text-slate-400",children:"ou cliquez pour parcourir vos fichiers (JPG, PNG, WEBP, PDF)"})]})]}),f.jsx("div",{className:"space-y-6",children:f.jsx(Da,{children:c.map((ge,Te)=>f.jsxs(Gn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,scale:.9},className:`flex flex-col md:flex-row bg-white rounded-3xl overflow-hidden shadow-lg border-2 transition-colors ${ge.status==="attached"?"border-emerald-500":"border-slate-200"}`,children:[f.jsx("div",{className:"w-full md:w-1/3 bg-slate-100 flex items-center justify-center p-4",children:ge.file_url?f.jsx("img",{src:`${yp}${ge.file_url}`,alt:"Preview",className:"max-h-64 object-contain rounded-xl shadow-md"}):f.jsx(fH,{className:"text-6xl text-slate-300"})}),f.jsxs("div",{className:"w-full md:w-2/3 p-6 flex flex-col",children:[f.jsxs("div",{className:"flex justify-between items-start mb-4",children:[f.jsxs("div",{children:[f.jsx("span",{className:"inline-block px-3 py-1 bg-indigo-100 text-indigo-800 font-bold rounded-full text-xs mb-2",children:ge.date||"Date inconnue"}),f.jsx("h3",{className:"text-2xl font-bold text-slate-800",children:ge.titre})]}),ge.status==="attached"&&f.jsx(td,{className:"text-3xl text-emerald-500"})]}),f.jsx("p",{className:"text-slate-600 mb-6 flex-grow",children:ge.description}),ge.status==="pending"&&f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("p",{className:"text-sm font-bold text-slate-700 mb-2 flex items-center gap-2",children:[f.jsx(ld,{className:"text-indigo-500"})," Personnes suggérées par l'IA :"]}),f.jsx("div",{className:"flex flex-wrap gap-2",children:n.map(ze=>{const Xe=(ge.suggested_slugs||[]).includes(ze.slug);return f.jsxs("button",{onClick:()=>me(Te,ze.slug),className:`px-3 py-1.5 rounded-xl text-sm font-medium transition-all cursor-pointer ${Xe?"bg-indigo-600 text-white shadow-md scale-105":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,children:[ze.prenom," ",ze.nom]},ze.slug)})})]}),f.jsx("button",{onClick:()=>ee(Te),className:"w-full py-3 bg-emerald-500 hover:bg-emerald-600 text-white font-bold rounded-xl shadow-lg hover:shadow-xl transition-all cursor-pointer",children:"Valider et Attacher à l'Arbre"})]}),ge.status==="attached"&&f.jsxs("p",{className:"text-sm font-bold text-emerald-600 bg-emerald-50 p-3 rounded-xl border border-emerald-100",children:["Média ajouté avec succès dans l'histoire de ",ge.suggested_slugs.join(", ")," !"]})]})]},Te))})})]}),f.jsx(Da,{children:O&&f.jsx("div",{className:"fixed inset-0 z-60 bg-black/60 backdrop-blur-xs flex items-center justify-center p-4",onClick:()=>V(null),children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},className:"w-full max-w-md bg-slate-900 border border-slate-700 rounded-3xl p-5 shadow-2xl space-y-4 text-white",onClick:ge=>ge.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-3",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-xl overflow-hidden bg-slate-800 border border-slate-700 shrink-0",children:f.jsx("img",{src:O.src.startsWith("http")?O.src:`${yp}${O.src}`,alt:"Aperçu",className:"w-full h-full object-cover"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-base font-black text-amber-400",children:$==="profile"?"Définir comme photo de profil":"Ajouter à la galerie"}),f.jsx("p",{className:"text-xs text-slate-400",children:"Choisissez le membre concerné"})]})]}),f.jsx("button",{onClick:()=>V(null),className:"p-1.5 rounded-full bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white",children:f.jsx($a,{size:14})})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{onClick:()=>G("profile"),className:`flex-1 py-1.5 px-3 rounded-xl text-xs font-bold transition flex items-center justify-center gap-1.5 cursor-pointer ${$==="profile"?"bg-amber-500 text-slate-950 shadow-md":"bg-slate-800 text-slate-400 hover:text-white"}`,children:[f.jsx(V0,{size:11})," Photo de profil"]}),f.jsxs("button",{onClick:()=>G("gallery"),className:`flex-1 py-1.5 px-3 rounded-xl text-xs font-bold transition flex items-center justify-center gap-1.5 cursor-pointer ${$==="gallery"?"bg-indigo-600 text-white shadow-md":"bg-slate-800 text-slate-400 hover:text-white"}`,children:[f.jsx(F_,{size:11})," Album / Galerie"]})]}),f.jsxs("div",{className:"relative",children:[f.jsx(X0,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"}),f.jsx("input",{type:"text",value:H,onChange:ge=>K(ge.target.value),placeholder:"Rechercher par prénom, nom...",className:"w-full bg-slate-800 border border-slate-700 rounded-xl pl-9 pr-4 py-2 text-xs text-white placeholder-slate-400 focus:outline-none focus:border-amber-400",autoFocus:!0})]}),f.jsx("div",{className:"max-h-60 overflow-y-auto space-y-1.5 pr-1 custom-scrollbar",children:n.filter(ge=>{if(!H.trim())return!0;const Te=H.toLowerCase();return`${ge.prenom||""} ${ge.nom||""}`.toLowerCase().includes(Te)}).map(ge=>{var Xe,Qe;const Te=ge.photo_url||ge.photo||ge.avatar,ze=Te&&(Te===O.src||O.src.endsWith(Te)||Te.endsWith(O.src));return f.jsxs("button",{disabled:W,onClick:()=>Ae(ge,$),className:`w-full p-2.5 rounded-2xl border transition-all flex items-center justify-between gap-3 text-left cursor-pointer ${ze?"bg-amber-500/15 border-amber-400/40 text-amber-200":"bg-slate-800/60 hover:bg-slate-800 border-slate-700/60 hover:border-slate-600 text-white"}`,children:[f.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[f.jsx("div",{className:"w-9 h-9 rounded-xl bg-slate-700 overflow-hidden flex items-center justify-center shrink-0 border border-slate-600",children:Te?f.jsx("img",{src:Te.startsWith("/")?`${yp}${Te}`:Te,alt:ge.prenom,className:"w-full h-full object-cover"}):f.jsx("span",{className:"text-xs font-bold font-serif text-amber-300",children:(((Xe=ge.prenom)==null?void 0:Xe[0])||"")+(((Qe=ge.nom)==null?void 0:Qe[0])||"")})}),f.jsxs("div",{className:"min-w-0",children:[f.jsxs("p",{className:"text-xs font-black truncate",children:[ge.prenom," ",ge.nom]}),ge.date_naissance&&f.jsxs("p",{className:"text-[10px] text-slate-400",children:["Né(e) en ",String(ge.date_naissance).slice(-4)]})]})]}),f.jsx("div",{className:"shrink-0",children:ze&&$==="profile"?f.jsx("span",{className:"text-[10px] font-bold text-emerald-400 bg-emerald-950/60 px-2 py-0.5 rounded-full border border-emerald-500/30 flex items-center gap-1",children:"✓ Profil Actuel"}):f.jsx("span",{className:"text-xs font-bold text-indigo-400 hover:text-indigo-300",children:"Choisir →"})})]},ge.slug)})})]})})}),f.jsx(a2e,{isOpen:!!U,onClose:()=>z(null),photos:(U==null?void 0:U.photos)||[],initialIndex:(U==null?void 0:U.initialIndex)||0,title:(U==null?void 0:U.title)||"Photothèque",people:n,onRefreshPeople:()=>{ie(),e&&e()}})]})}function o2e(n,e){const t=de.useRef(e);de.useEffect(function(){e!==t.current&&n.attributionControl!=null&&(t.current!=null&&n.attributionControl.removeAttribution(t.current),e!=null&&n.attributionControl.addAttribution(e)),t.current=e},[n,e])}const uHe=1;function dHe(n){return Object.freeze({__version:uHe,map:n})}function l2e(n,e){return Object.freeze({...n,...e})}const c2e=de.createContext(null),u2e=c2e.Provider;function f$(){const n=de.useContext(c2e);if(n==null)throw new Error("No context provided: useLeafletContext() can only be used in a descendant of ");return n}function d2e(n){function e(t,r){const{instance:i,context:s}=n(t).current;return de.useImperativeHandle(r,()=>i),t.children==null?null:ln.createElement(u2e,{value:s},t.children)}return de.forwardRef(e)}function hHe(n){function e(t,r){const[i,s]=de.useState(!1),{instance:a}=n(t,s).current;de.useImperativeHandle(r,()=>a),de.useEffect(function(){i&&a.update()},[a,i,t.children]);const o=a._contentNode;return o?l0e.createPortal(t.children,o):null}return de.forwardRef(e)}function fHe(n){function e(t,r){const{instance:i}=n(t).current;return de.useImperativeHandle(r,()=>i),null}return de.forwardRef(e)}function p$(n,e){const t=de.useRef();de.useEffect(function(){return e!=null&&n.instance.on(e),t.current=e,function(){t.current!=null&&n.instance.off(t.current),t.current=null}},[n,e])}function lP(n,e){const t=n.pane??e.pane;return t?{...n,pane:t}:n}function pHe(n,e){return function(r,i){const s=f$(),a=n(lP(r,s),s);return o2e(s.map,r.attribution),p$(a.current,r.eventHandlers),e(a.current,s,r,i),a}}var Uz={exports:{}};/* @preserve * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade */(function(n,e){(function(t,r){r(e)})(kb,function(t){var r="1.9.4";function i(b){var F,X,he,Me;for(X=1,he=arguments.length;X"u"||!L||!L.Mixin)){b=C(b)?b:[b];for(var F=0;F0?Math.floor(b):Math.ceil(b)};Q.prototype={clone:function(){return new Q(this.x,this.y)},add:function(b){return this.clone()._add(oe(b))},_add:function(b){return this.x+=b.x,this.y+=b.y,this},subtract:function(b){return this.clone()._subtract(oe(b))},_subtract:function(b){return this.x-=b.x,this.y-=b.y,this},divideBy:function(b){return this.clone()._divideBy(b)},_divideBy:function(b){return this.x/=b,this.y/=b,this},multiplyBy:function(b){return this.clone()._multiplyBy(b)},_multiplyBy:function(b){return this.x*=b,this.y*=b,this},scaleBy:function(b){return new Q(this.x*b.x,this.y*b.y)},unscaleBy:function(b){return new Q(this.x/b.x,this.y/b.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=re(this.x),this.y=re(this.y),this},distanceTo:function(b){b=oe(b);var F=b.x-this.x,X=b.y-this.y;return Math.sqrt(F*F+X*X)},equals:function(b){return b=oe(b),b.x===this.x&&b.y===this.y},contains:function(b){return b=oe(b),Math.abs(b.x)<=Math.abs(this.x)&&Math.abs(b.y)<=Math.abs(this.y)},toString:function(){return"Point("+h(this.x)+", "+h(this.y)+")"}};function oe(b,F,X){return b instanceof Q?b:C(b)?new Q(b[0],b[1]):b==null?b:typeof b=="object"&&"x"in b&&"y"in b?new Q(b.x,b.y):new Q(b,F,X)}function fe(b,F){if(b)for(var X=F?[b,F]:b,he=0,Me=X.length;he=this.min.x&&X.x<=this.max.x&&F.y>=this.min.y&&X.y<=this.max.y},intersects:function(b){b=ee(b);var F=this.min,X=this.max,he=b.min,Me=b.max,He=Me.x>=F.x&&he.x<=X.x,Mt=Me.y>=F.y&&he.y<=X.y;return He&&Mt},overlaps:function(b){b=ee(b);var F=this.min,X=this.max,he=b.min,Me=b.max,He=Me.x>F.x&&he.xF.y&&he.y=F.lat&&Me.lat<=X.lat&&he.lng>=F.lng&&Me.lng<=X.lng},intersects:function(b){b=Ae(b);var F=this._southWest,X=this._northEast,he=b.getSouthWest(),Me=b.getNorthEast(),He=Me.lat>=F.lat&&he.lat<=X.lat,Mt=Me.lng>=F.lng&&he.lng<=X.lng;return He&&Mt},overlaps:function(b){b=Ae(b);var F=this._southWest,X=this._northEast,he=b.getSouthWest(),Me=b.getNorthEast(),He=Me.lat>F.lat&&he.latF.lng&&he.lng1,Bt=function(){var b=!1;try{var F=Object.defineProperty({},"passive",{get:function(){b=!0}});window.addEventListener("testPassiveEventSupport",d,F),window.removeEventListener("testPassiveEventSupport",d,F)}catch{}return b}(),$e=function(){return!!document.createElement("canvas").getContext}(),ut=!!(document.createElementNS&&Ce("svg").createSVGRect),Gt=!!ut&&function(){var b=document.createElement("div");return b.innerHTML="",(b.firstChild&&b.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"}(),it=!ut&&function(){try{var b=document.createElement("div");b.innerHTML='';var F=b.firstChild;return F.style.behavior="url(#default#VML)",F&&typeof F.adj=="object"}catch{return!1}}(),Ot=navigator.platform.indexOf("Mac")===0,nn=navigator.platform.indexOf("Linux")===0;function Nt(b){return navigator.userAgent.toLowerCase().indexOf(b)>=0}var m={ie:et,ielt9:At,edge:Lt,webkit:st,android:Ht,android23:Se,androidStock:It,opera:De,chrome:ue,gecko:Ve,safari:We,phantom:ct,opera12:vt,win:Ut,ie3d:dt,webkit3d:mt,gecko3d:Ft,any3d:tt,mobile:Pe,mobileWebkit:nt,mobileWebkit3d:qe,msPointer:yt,pointer:Qt,touch:pt,touchNative:Be,mobileOpera:rt,mobileGecko:zt,retina:Yt,passiveEvents:Bt,canvas:$e,svg:ut,vml:it,inlineSvg:Gt,mac:Ot,linux:nn},Ie=m.msPointer?"MSPointerDown":"pointerdown",An=m.msPointer?"MSPointerMove":"pointermove",Ln=m.msPointer?"MSPointerUp":"pointerup",Rn=m.msPointer?"MSPointerCancel":"pointercancel",Mn={touchstart:Ie,touchmove:An,touchend:Ln,touchcancel:Rn},Cn={touchstart:Jn,touchmove:cs,touchend:cs,touchcancel:cs},Hn={},lr=!1;function jr(b,F,X){return F==="touchstart"&&ra(),Cn[F]?(X=Cn[F].bind(this,X),b.addEventListener(Mn[F],X,!1),X):(console.warn("wrong event specified:",F),d)}function Qr(b,F,X){if(!Mn[F]){console.warn("wrong event specified:",F);return}b.removeEventListener(Mn[F],X,!1)}function Os(b){Hn[b.pointerId]=b}function la(b){Hn[b.pointerId]&&(Hn[b.pointerId]=b)}function Pi(b){delete Hn[b.pointerId]}function ra(){lr||(document.addEventListener(Ie,Os,!0),document.addEventListener(An,la,!0),document.addEventListener(Ln,Pi,!0),document.addEventListener(Rn,Pi,!0),lr=!0)}function cs(b,F){if(F.pointerType!==(F.MSPOINTER_TYPE_MOUSE||"mouse")){F.touches=[];for(var X in Hn)F.touches.push(Hn[X]);F.changedTouches=[F],b(F)}}function Jn(b,F){F.MSPOINTER_TYPE_TOUCH&&F.pointerType===F.MSPOINTER_TYPE_TOUCH&&Fs(F),cs(b,F)}function wa(b){var F={},X,he;for(he in b)X=b[he],F[he]=X&&X.bind?X.bind(b):X;return b=F,F.type="dblclick",F.detail=2,F.isTrusted=!1,F._simulated=!0,F}var Ii=200;function Ge(b,F){b.addEventListener("dblclick",F);var X=0,he;function Me(He){if(He.detail!==1){he=He.detail;return}if(!(He.pointerType==="mouse"||He.sourceCapabilities&&!He.sourceCapabilities.firesTouchEvents)){var Mt=Hs(He);if(!(Mt.some(function(rn){return rn instanceof HTMLLabelElement&&rn.attributes.for})&&!Mt.some(function(rn){return rn instanceof HTMLInputElement||rn instanceof HTMLSelectElement}))){var Jt=Date.now();Jt-X<=Ii?(he++,he===2&&F(wa(He))):he=1,X=Jt}}}return b.addEventListener("click",Me),{dblclick:F,simDblclick:Me}}function wt(b,F){b.removeEventListener("dblclick",F.dblclick),b.removeEventListener("click",F.simDblclick)}var _e=Ri(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Dt=Ri(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),Xt=Dt==="webkitTransition"||Dt==="OTransition"?Dt+"End":"transitionend";function vn(b){return typeof b=="string"?document.getElementById(b):b}function Sn(b,F){var X=b.style[F]||b.currentStyle&&b.currentStyle[F];if((!X||X==="auto")&&document.defaultView){var he=document.defaultView.getComputedStyle(b,null);X=he?he[F]:null}return X==="auto"?null:X}function hn(b,F,X){var he=document.createElement(b);return he.className=F||"",X&&X.appendChild(he),he}function Tn(b){var F=b.parentNode;F&&F.removeChild(b)}function Re(b){for(;b.firstChild;)b.removeChild(b.firstChild)}function Wn(b){var F=b.parentNode;F&&F.lastChild!==b&&F.appendChild(b)}function Ar(b){var F=b.parentNode;F&&F.firstChild!==b&&F.insertBefore(b,F.firstChild)}function Un(b,F){if(b.classList!==void 0)return b.classList.contains(F);var X=Kr(b);return X.length>0&&new RegExp("(^|\\s)"+F+"(\\s|$)").test(X)}function zn(b,F){if(b.classList!==void 0)for(var X=g(F),he=0,Me=X.length;he0?2*window.devicePixelRatio:1;function Qo(b){return m.edge?b.wheelDeltaY/2:b.deltaY&&b.deltaMode===0?-b.deltaY/Zo:b.deltaY&&b.deltaMode===1?-b.deltaY*20:b.deltaY&&b.deltaMode===2?-b.deltaY*60:b.deltaX||b.deltaZ?0:b.wheelDelta?(b.wheelDeltaY||b.wheelDelta)/2:b.detail&&Math.abs(b.detail)<32765?-b.detail*20:b.detail?b.detail/-32765*60:0}function yc(b,F){var X=F.relatedTarget;if(!X)return!0;try{for(;X&&X!==b;)X=X.parentNode}catch{return!1}return X!==b}var bc={__proto__:null,on:Dn,off:es,stopPropagation:Ya,disableScrollPropagation:$c,disableClickPropagation:Za,preventDefault:Fs,stop:xl,getPropagationPath:Hs,getMousePosition:fo,getWheelDelta:Qo,isExternalTarget:yc,addListener:Dn,removeListener:es},Qa=ae.extend({run:function(b,F,X,he){this.stop(),this._el=b,this._inProgress=!0,this._duration=X||.25,this._easeOutPower=1/Math.max(he||.5,.2),this._startPos=fs(b),this._offset=F.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=G(this._animate,this),this._step()},_step:function(b){var F=+new Date-this._startTime,X=this._duration*1e3;Fthis.options.maxZoom)?this.setZoom(b):this},panInsideBounds:function(b,F){this._enforcingBounds=!0;var X=this.getCenter(),he=this._limitCenter(X,this._zoom,Ae(b));return X.equals(he)||this.panTo(he,F),this._enforcingBounds=!1,this},panInside:function(b,F){F=F||{};var X=oe(F.paddingTopLeft||F.padding||[0,0]),he=oe(F.paddingBottomRight||F.padding||[0,0]),Me=this.project(this.getCenter()),He=this.project(b),Mt=this.getPixelBounds(),Jt=ee([Mt.min.add(X),Mt.max.subtract(he)]),rn=Jt.getSize();if(!Jt.contains(He)){this._enforcingBounds=!0;var _n=He.subtract(Jt.getCenter()),Xn=Jt.extend(He).getSize().subtract(rn);Me.x+=_n.x<0?-Xn.x:Xn.x,Me.y+=_n.y<0?-Xn.y:Xn.y,this.panTo(this.unproject(Me),F),this._enforcingBounds=!1}return this},invalidateSize:function(b){if(!this._loaded)return this;b=i({animate:!1,pan:!0},b===!0?{animate:!0}:b);var F=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var X=this.getSize(),he=F.divideBy(2).round(),Me=X.divideBy(2).round(),He=he.subtract(Me);return!He.x&&!He.y?this:(b.animate&&b.pan?this.panBy(He):(b.pan&&this._rawPanBy(He),this.fire("move"),b.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(a(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:F,newSize:X}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(b){if(b=this._locateOptions=i({timeout:1e4,watch:!1},b),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var F=a(this._handleGeolocationResponse,this),X=a(this._handleGeolocationError,this);return b.watch?this._locationWatchId=navigator.geolocation.watchPosition(F,X,b):navigator.geolocation.getCurrentPosition(F,X,b),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(b){if(this._container._leaflet_id){var F=b.code,X=b.message||(F===1?"permission denied":F===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:F,message:"Geolocation error: "+X+"."})}},_handleGeolocationResponse:function(b){if(this._container._leaflet_id){var F=b.coords.latitude,X=b.coords.longitude,he=new be(F,X),Me=he.toBounds(b.coords.accuracy*2),He=this._locateOptions;if(He.setView){var Mt=this.getBoundsZoom(Me);this.setView(he,He.maxZoom?Math.min(Mt,He.maxZoom):Mt)}var Jt={latlng:he,bounds:Me,timestamp:b.timestamp};for(var rn in b.coords)typeof b.coords[rn]=="number"&&(Jt[rn]=b.coords[rn]);this.fire("locationfound",Jt)}},addHandler:function(b,F){if(!F)return this;var X=this[b]=new F(this);return this._handlers.push(X),this.options[b]&&X.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),Tn(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(H(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var b;for(b in this._layers)this._layers[b].remove();for(b in this._panes)Tn(this._panes[b]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(b,F){var X="leaflet-pane"+(b?" leaflet-"+b.replace("Pane","")+"-pane":""),he=hn("div",X,F||this._mapPane);return b&&(this._panes[b]=he),he},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var b=this.getPixelBounds(),F=this.unproject(b.getBottomLeft()),X=this.unproject(b.getTopRight());return new me(F,X)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(b,F,X){b=Ae(b),X=oe(X||[0,0]);var he=this.getZoom()||0,Me=this.getMinZoom(),He=this.getMaxZoom(),Mt=b.getNorthWest(),Jt=b.getSouthEast(),rn=this.getSize().subtract(X),_n=ee(this.project(Jt,he),this.project(Mt,he)).getSize(),Xn=m.any3d?this.options.zoomSnap:1,wr=rn.x/_n.x,zr=rn.y/_n.y,gi=F?Math.max(wr,zr):Math.min(wr,zr);return he=this.getScaleZoom(gi,he),Xn&&(he=Math.round(he/(Xn/100))*(Xn/100),he=F?Math.ceil(he/Xn)*Xn:Math.floor(he/Xn)*Xn),Math.max(Me,Math.min(He,he))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new Q(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(b,F){var X=this._getTopLeftPoint(b,F);return new fe(X,X.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(b){return this.options.crs.getProjectedBounds(b===void 0?this.getZoom():b)},getPane:function(b){return typeof b=="string"?this._panes[b]:b},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(b,F){var X=this.options.crs;return F=F===void 0?this._zoom:F,X.scale(b)/X.scale(F)},getScaleZoom:function(b,F){var X=this.options.crs;F=F===void 0?this._zoom:F;var he=X.zoom(b*X.scale(F));return isNaN(he)?1/0:he},project:function(b,F){return F=F===void 0?this._zoom:F,this.options.crs.latLngToPoint(pe(b),F)},unproject:function(b,F){return F=F===void 0?this._zoom:F,this.options.crs.pointToLatLng(oe(b),F)},layerPointToLatLng:function(b){var F=oe(b).add(this.getPixelOrigin());return this.unproject(F)},latLngToLayerPoint:function(b){var F=this.project(pe(b))._round();return F._subtract(this.getPixelOrigin())},wrapLatLng:function(b){return this.options.crs.wrapLatLng(pe(b))},wrapLatLngBounds:function(b){return this.options.crs.wrapLatLngBounds(Ae(b))},distance:function(b,F){return this.options.crs.distance(pe(b),pe(F))},containerPointToLayerPoint:function(b){return oe(b).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(b){return oe(b).add(this._getMapPanePos())},containerPointToLatLng:function(b){var F=this.containerPointToLayerPoint(oe(b));return this.layerPointToLatLng(F)},latLngToContainerPoint:function(b){return this.layerPointToContainerPoint(this.latLngToLayerPoint(pe(b)))},mouseEventToContainerPoint:function(b){return fo(b,this._container)},mouseEventToLayerPoint:function(b){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(b))},mouseEventToLatLng:function(b){return this.layerPointToLatLng(this.mouseEventToLayerPoint(b))},_initContainer:function(b){var F=this._container=vn(b);if(F){if(F._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");Dn(F,"scroll",this._onScroll,this),this._containerId=l(F)},_initLayout:function(){var b=this._container;this._fadeAnimated=this.options.fadeAnimation&&m.any3d,zn(b,"leaflet-container"+(m.touch?" leaflet-touch":"")+(m.retina?" leaflet-retina":"")+(m.ielt9?" leaflet-oldie":"")+(m.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var F=Sn(b,"position");F!=="absolute"&&F!=="relative"&&F!=="fixed"&&F!=="sticky"&&(b.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var b=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Ai(this._mapPane,new Q(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(zn(b.markerPane,"leaflet-zoom-hide"),zn(b.shadowPane,"leaflet-zoom-hide"))},_resetView:function(b,F,X){Ai(this._mapPane,new Q(0,0));var he=!this._loaded;this._loaded=!0,F=this._limitZoom(F),this.fire("viewprereset");var Me=this._zoom!==F;this._moveStart(Me,X)._move(b,F)._moveEnd(Me),this.fire("viewreset"),he&&this.fire("load")},_moveStart:function(b,F){return b&&this.fire("zoomstart"),F||this.fire("movestart"),this},_move:function(b,F,X,he){F===void 0&&(F=this._zoom);var Me=this._zoom!==F;return this._zoom=F,this._lastCenter=b,this._pixelOrigin=this._getNewPixelOrigin(b),he?X&&X.pinch&&this.fire("zoom",X):((Me||X&&X.pinch)&&this.fire("zoom",X),this.fire("move",X)),this},_moveEnd:function(b){return b&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return H(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(b){Ai(this._mapPane,this._getMapPanePos().subtract(b))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(b){this._targets={},this._targets[l(this._container)]=this;var F=b?es:Dn;F(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&F(window,"resize",this._onResize,this),m.any3d&&this.options.transform3DLimit&&(b?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){H(this._resizeRequest),this._resizeRequest=G(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var b=this._getMapPanePos();Math.max(Math.abs(b.x),Math.abs(b.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(b,F){for(var X=[],he,Me=F==="mouseout"||F==="mouseover",He=b.target||b.srcElement,Mt=!1;He;){if(he=this._targets[l(He)],he&&(F==="click"||F==="preclick")&&this._draggableMoved(he)){Mt=!0;break}if(he&&he.listens(F,!0)&&(Me&&!yc(He,b)||(X.push(he),Me))||He===this._container)break;He=He.parentNode}return!X.length&&!Mt&&!Me&&this.listens(F,!0)&&(X=[this]),X},_isClickDisabled:function(b){for(;b&&b!==this._container;){if(b._leaflet_disable_click)return!0;b=b.parentNode}},_handleDOMEvent:function(b){var F=b.target||b.srcElement;if(!(!this._loaded||F._leaflet_disable_events||b.type==="click"&&this._isClickDisabled(F))){var X=b.type;X==="mousedown"&&Fa(F),this._fireDOMEvent(b,X)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(b,F,X){if(b.type==="click"){var he=i({},b);he.type="preclick",this._fireDOMEvent(he,he.type,X)}var Me=this._findEventTargets(b,F);if(X){for(var He=[],Mt=0;Mt0?Math.round(b-F)/2:Math.max(0,Math.ceil(b))-Math.max(0,Math.floor(F))},_limitZoom:function(b){var F=this.getMinZoom(),X=this.getMaxZoom(),he=m.any3d?this.options.zoomSnap:1;return he&&(b=Math.round(b/he)*he),Math.max(F,Math.min(X,b))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){Nr(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(b,F){var X=this._getCenterOffset(b)._trunc();return(F&&F.animate)!==!0&&!this.getSize().contains(X)?!1:(this.panBy(X,F),!0)},_createAnimProxy:function(){var b=this._proxy=hn("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(b),this.on("zoomanim",function(F){var X=_e,he=this._proxy.style[X];sr(this._proxy,this.project(F.center,F.zoom),this.getZoomScale(F.zoom,1)),he===this._proxy.style[X]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){Tn(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var b=this.getCenter(),F=this.getZoom();sr(this._proxy,this.project(b,F),this.getZoomScale(F,1))},_catchTransitionEnd:function(b){this._animatingZoom&&b.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(b,F,X){if(this._animatingZoom)return!0;if(X=X||{},!this._zoomAnimated||X.animate===!1||this._nothingToAnimate()||Math.abs(F-this._zoom)>this.options.zoomAnimationThreshold)return!1;var he=this.getZoomScale(F),Me=this._getCenterOffset(b)._divideBy(1-1/he);return X.animate!==!0&&!this.getSize().contains(Me)?!1:(G(function(){this._moveStart(!0,X.noMoveStart||!1)._animateZoom(b,F,!0)},this),!0)},_animateZoom:function(b,F,X,he){this._mapPane&&(X&&(this._animatingZoom=!0,this._animateToCenter=b,this._animateToZoom=F,zn(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:b,zoom:F,noUpdate:he}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(a(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&Nr(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Wc(b,F){return new qr(b,F)}var $s=W.extend({options:{position:"topright"},initialize:function(b){x(this,b)},getPosition:function(){return this.options.position},setPosition:function(b){var F=this._map;return F&&F.removeControl(this),this.options.position=b,F&&F.addControl(this),this},getContainer:function(){return this._container},addTo:function(b){this.remove(),this._map=b;var F=this._container=this.onAdd(b),X=this.getPosition(),he=b._controlCorners[X];return zn(F,"leaflet-control"),X.indexOf("bottom")!==-1?he.insertBefore(F,he.firstChild):he.appendChild(F),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(Tn(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(b){this._map&&b&&b.screenX>0&&b.screenY>0&&this._map.getContainer().focus()}}),ca=function(b){return new $s(b)};qr.include({addControl:function(b){return b.addTo(this),this},removeControl:function(b){return b.remove(),this},_initControlPos:function(){var b=this._controlCorners={},F="leaflet-",X=this._controlContainer=hn("div",F+"control-container",this._container);function he(Me,He){var Mt=F+Me+" "+F+He;b[Me+He]=hn("div",Mt,X)}he("top","left"),he("top","right"),he("bottom","left"),he("bottom","right")},_clearControlPos:function(){for(var b in this._controlCorners)Tn(this._controlCorners[b]);Tn(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var ia=$s.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(b,F,X,he){return X1,this._baseLayersList.style.display=b?"":"none"),this._separator.style.display=F&&b?"":"none",this},_onLayerChange:function(b){this._handlingClick||this._update();var F=this._getLayer(l(b.target)),X=F.overlay?b.type==="add"?"overlayadd":"overlayremove":b.type==="add"?"baselayerchange":null;X&&this._map.fire(X,F)},_createRadioElement:function(b,F){var X='",he=document.createElement("div");return he.innerHTML=X,he.firstChild},_addItem:function(b){var F=document.createElement("label"),X=this._map.hasLayer(b.layer),he;b.overlay?(he=document.createElement("input"),he.type="checkbox",he.className="leaflet-control-layers-selector",he.defaultChecked=X):he=this._createRadioElement("leaflet-base-layers_"+l(this),X),this._layerControlInputs.push(he),he.layerId=l(b.layer),Dn(he,"click",this._onInputClick,this);var Me=document.createElement("span");Me.innerHTML=" "+b.name;var He=document.createElement("span");F.appendChild(He),He.appendChild(he),He.appendChild(Me);var Mt=b.overlay?this._overlaysList:this._baseLayersList;return Mt.appendChild(F),this._checkDisabledLayers(),F},_onInputClick:function(){if(!this._preventClick){var b=this._layerControlInputs,F,X,he=[],Me=[];this._handlingClick=!0;for(var He=b.length-1;He>=0;He--)F=b[He],X=this._getLayer(F.layerId).layer,F.checked?he.push(X):F.checked||Me.push(X);for(He=0;He=0;Me--)F=b[Me],X=this._getLayer(F.layerId).layer,F.disabled=X.options.minZoom!==void 0&&heX.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var b=this._section;this._preventClick=!0,Dn(b,"click",Fs),this.expand();var F=this;setTimeout(function(){es(b,"click",Fs),F._preventClick=!1})}}),dd=function(b,F,X){return new ia(b,F,X)},Ta=$s.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(b){var F="leaflet-control-zoom",X=hn("div",F+" leaflet-bar"),he=this.options;return this._zoomInButton=this._createButton(he.zoomInText,he.zoomInTitle,F+"-in",X,this._zoomIn),this._zoomOutButton=this._createButton(he.zoomOutText,he.zoomOutTitle,F+"-out",X,this._zoomOut),this._updateDisabled(),b.on("zoomend zoomlevelschange",this._updateDisabled,this),X},onRemove:function(b){b.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(b){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(b.shiftKey?3:1))},_createButton:function(b,F,X,he,Me){var He=hn("a",X,he);return He.innerHTML=b,He.href="#",He.title=F,He.setAttribute("role","button"),He.setAttribute("aria-label",F),Za(He),Dn(He,"click",xl),Dn(He,"click",Me,this),Dn(He,"click",this._refocusOnMap,this),He},_updateDisabled:function(){var b=this._map,F="leaflet-disabled";Nr(this._zoomInButton,F),Nr(this._zoomOutButton,F),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||b._zoom===b.getMinZoom())&&(zn(this._zoomOutButton,F),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||b._zoom===b.getMaxZoom())&&(zn(this._zoomInButton,F),this._zoomInButton.setAttribute("aria-disabled","true"))}});qr.mergeOptions({zoomControl:!0}),qr.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Ta,this.addControl(this.zoomControl))});var Ko=function(b){return new Ta(b)},Tu=$s.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(b){var F="leaflet-control-scale",X=hn("div",F),he=this.options;return this._addScales(he,F+"-line",X),b.on(he.updateWhenIdle?"moveend":"move",this._update,this),b.whenReady(this._update,this),X},onRemove:function(b){b.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(b,F,X){b.metric&&(this._mScale=hn("div",F,X)),b.imperial&&(this._iScale=hn("div",F,X))},_update:function(){var b=this._map,F=b.getSize().y/2,X=b.distance(b.containerPointToLatLng([0,F]),b.containerPointToLatLng([this.options.maxWidth,F]));this._updateScales(X)},_updateScales:function(b){this.options.metric&&b&&this._updateMetric(b),this.options.imperial&&b&&this._updateImperial(b)},_updateMetric:function(b){var F=this._getRoundNum(b),X=F<1e3?F+" m":F/1e3+" km";this._updateScale(this._mScale,X,F/b)},_updateImperial:function(b){var F=b*3.2808399,X,he,Me;F>5280?(X=F/5280,he=this._getRoundNum(X),this._updateScale(this._iScale,he+" mi",he/X)):(Me=this._getRoundNum(F),this._updateScale(this._iScale,Me+" ft",Me/F))},_updateScale:function(b,F,X){b.style.width=Math.round(this.options.maxWidth*X)+"px",b.innerHTML=F},_getRoundNum:function(b){var F=Math.pow(10,(Math.floor(b)+"").length-1),X=b/F;return X=X>=10?10:X>=5?5:X>=3?3:X>=2?2:1,F*X}}),qd=function(b){return new Tu(b)},Ea='',Ws=$s.extend({options:{position:"bottomright",prefix:''+(m.inlineSvg?Ea+" ":"")+"Leaflet"},initialize:function(b){x(this,b),this._attributions={}},onAdd:function(b){b.attributionControl=this,this._container=hn("div","leaflet-control-attribution"),Za(this._container);for(var F in b._layers)b._layers[F].getAttribution&&this.addAttribution(b._layers[F].getAttribution());return this._update(),b.on("layeradd",this._addAttribution,this),this._container},onRemove:function(b){b.off("layeradd",this._addAttribution,this)},_addAttribution:function(b){b.layer.getAttribution&&(this.addAttribution(b.layer.getAttribution()),b.layer.once("remove",function(){this.removeAttribution(b.layer.getAttribution())},this))},setPrefix:function(b){return this.options.prefix=b,this._update(),this},addAttribution:function(b){return b?(this._attributions[b]||(this._attributions[b]=0),this._attributions[b]++,this._update(),this):this},removeAttribution:function(b){return b?(this._attributions[b]&&(this._attributions[b]--,this._update()),this):this},_update:function(){if(this._map){var b=[];for(var F in this._attributions)this._attributions[F]&&b.push(F);var X=[];this.options.prefix&&X.push(this.options.prefix),b.length&&X.push(b.join(", ")),this._container.innerHTML=X.join(' ')}}});qr.mergeOptions({attributionControl:!0}),qr.addInitHook(function(){this.options.attributionControl&&new Ws().addTo(this)});var vs=function(b){return new Ws(b)};$s.Layers=ia,$s.Zoom=Ta,$s.Scale=Tu,$s.Attribution=Ws,ca.layers=dd,ca.zoom=Ko,ca.scale=qd,ca.attribution=vs;var ce=W.extend({initialize:function(b){this._map=b},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});ce.addTo=function(b,F){return b.addHandler(F,this),this};var Oe={Events:ie},at=m.touch?"touchstart mousedown":"mousedown",Et=ae.extend({options:{clickTolerance:3},initialize:function(b,F,X,he){x(this,he),this._element=b,this._dragStartTarget=F||b,this._preventOutline=X},enable:function(){this._enabled||(Dn(this._dragStartTarget,at,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Et._dragging===this&&this.finishDrag(!0),es(this._dragStartTarget,at,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(b){if(this._enabled&&(this._moved=!1,!Un(this._element,"leaflet-zoom-anim"))){if(b.touches&&b.touches.length!==1){Et._dragging===this&&this.finishDrag();return}if(!(Et._dragging||b.shiftKey||b.which!==1&&b.button!==1&&!b.touches)&&(Et._dragging=this,this._preventOutline&&Fa(this._element),ja(),Ki(),!this._moving)){this.fire("down");var F=b.touches?b.touches[0]:b,X=nr(this._element);this._startPoint=new Q(F.clientX,F.clientY),this._startPos=fs(this._element),this._parentScale=Hc(X);var he=b.type==="mousedown";Dn(document,he?"mousemove":"touchmove",this._onMove,this),Dn(document,he?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(b){if(this._enabled){if(b.touches&&b.touches.length>1){this._moved=!0;return}var F=b.touches&&b.touches.length===1?b.touches[0]:b,X=new Q(F.clientX,F.clientY)._subtract(this._startPoint);!X.x&&!X.y||Math.abs(X.x)+Math.abs(X.y)He&&(Mt=Jt,He=rn);He>X&&(F[Mt]=1,sa(b,F,X,he,Mt),sa(b,F,X,Mt,Me))}function us(b,F){for(var X=[b[0]],he=1,Me=0,He=b.length;heF&&(X.push(b[he]),Me=he);return MeF.max.x&&(X|=2),b.yF.max.y&&(X|=8),X}function Xs(b,F){var X=F.x-b.x,he=F.y-b.y;return X*X+he*he}function Hr(b,F,X,he){var Me=F.x,He=F.y,Mt=X.x-Me,Jt=X.y-He,rn=Mt*Mt+Jt*Jt,_n;return rn>0&&(_n=((b.x-Me)*Mt+(b.y-He)*Jt)/rn,_n>1?(Me=X.x,He=X.y):_n>0&&(Me+=Mt*_n,He+=Jt*_n)),Mt=b.x-Me,Jt=b.y-He,he?Mt*Mt+Jt*Jt:new Q(Me,He)}function Ka(b){return!C(b[0])||typeof b[0][0]!="object"&&typeof b[0][0]<"u"}function _c(b){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Ka(b)}function Ba(b,F){var X,he,Me,He,Mt,Jt,rn,_n;if(!b||b.length===0)throw new Error("latlngs not passed");Ka(b)||(console.warn("latlngs are not flat! Only the first ring will be used"),b=b[0]);var Xn=pe([0,0]),wr=Ae(b),zr=wr.getNorthWest().distanceTo(wr.getSouthWest())*wr.getNorthEast().distanceTo(wr.getNorthWest());zr<1700&&(Xn=gn(b));var gi=b.length,yn=[];for(X=0;Xhe){rn=(He-he)/Me,_n=[Jt.x-rn*(Jt.x-Mt.x),Jt.y-rn*(Jt.y-Mt.y)];break}var Vl=F.unproject(oe(_n));return pe([Vl.lat+Xn.lat,Vl.lng+Xn.lng])}var Ja={__proto__:null,simplify:ar,pointToSegmentDistance:Dr,closestPointOnSegment:Gr,clipSegment:Ns,_getEdgeIntersection:ps,_getBitCode:Bi,_sqClosestPointOnSegment:Hr,isFlat:Ka,_flat:_c,polylineCenter:Ba},vl={project:function(b){return new Q(b.lng,b.lat)},unproject:function(b){return new be(b.y,b.x)},bounds:new fe([-180,-90],[180,90])},Jo={R:6378137,R_MINOR:6356752314245179e-9,bounds:new fe([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(b){var F=Math.PI/180,X=this.R,he=b.lat*F,Me=this.R_MINOR/X,He=Math.sqrt(1-Me*Me),Mt=He*Math.sin(he),Jt=Math.tan(Math.PI/4-he/2)/Math.pow((1-Mt)/(1+Mt),He/2);return he=-X*Math.log(Math.max(Jt,1e-10)),new Q(b.lng*F*X,he)},unproject:function(b){for(var F=180/Math.PI,X=this.R,he=this.R_MINOR/X,Me=Math.sqrt(1-he*he),He=Math.exp(-b.y/X),Mt=Math.PI/2-2*Math.atan(He),Jt=0,rn=.1,_n;Jt<15&&Math.abs(rn)>1e-7;Jt++)_n=Me*Math.sin(Mt),_n=Math.pow((1-_n)/(1+_n),Me/2),rn=Math.PI/2-2*Math.atan(He*_n)-Mt,Mt+=rn;return new be(Mt*F,b.x*F/X)}},Bl={__proto__:null,LonLat:vl,Mercator:Jo,SphericalMercator:Xe},Li=i({},Te,{code:"EPSG:3395",projection:Jo,transformation:function(){var b=.5/(Math.PI*Jo.R);return ot(b,.5,-b,.5)}()}),Xc=i({},Te,{code:"EPSG:4326",projection:vl,transformation:ot(1/180,1,-1/180,.5)}),yl=i({},ge,{projection:vl,transformation:ot(1,0,-1,0),scale:function(b){return Math.pow(2,b)},zoom:function(b){return Math.log(b)/Math.LN2},distance:function(b,F){var X=F.lng-b.lng,he=F.lat-b.lat;return Math.sqrt(X*X+he*he)},infinite:!0});ge.Earth=Te,ge.EPSG3395=Li,ge.EPSG3857=bt,ge.EPSG900913=ht,ge.EPSG4326=Xc,ge.Simple=yl;var Co=ae.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(b){return b.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(b){return b&&b.removeLayer(this),this},getPane:function(b){return this._map.getPane(b?this.options[b]||b:this.options.pane)},addInteractiveTarget:function(b){return this._map._targets[l(b)]=this,this},removeInteractiveTarget:function(b){return delete this._map._targets[l(b)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(b){var F=b.target;if(F.hasLayer(this)){if(this._map=F,this._zoomAnimated=F._zoomAnimated,this.getEvents){var X=this.getEvents();F.on(X,this),this.once("remove",function(){F.off(X,this)},this)}this.onAdd(F),this.fire("add"),F.fire("layeradd",{layer:this})}}});qr.include({addLayer:function(b){if(!b._layerAdd)throw new Error("The provided object is not a Layer.");var F=l(b);return this._layers[F]?this:(this._layers[F]=b,b._mapToAdd=this,b.beforeAdd&&b.beforeAdd(this),this.whenReady(b._layerAdd,b),this)},removeLayer:function(b){var F=l(b);return this._layers[F]?(this._loaded&&b.onRemove(this),delete this._layers[F],this._loaded&&(this.fire("layerremove",{layer:b}),b.fire("remove")),b._map=b._mapToAdd=null,this):this},hasLayer:function(b){return l(b)in this._layers},eachLayer:function(b,F){for(var X in this._layers)b.call(F,this._layers[X]);return this},_addLayers:function(b){b=b?C(b)?b:[b]:[];for(var F=0,X=b.length;Fthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&F[0]instanceof be&&F[0].equals(F[X-1])&&F.pop(),F},_setLatLngs:function(b){mo.prototype._setLatLngs.call(this,b),Ka(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Ka(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var b=this._renderer._bounds,F=this.options.weight,X=new Q(F,F);if(b=new fe(b.min.subtract(X),b.max.add(X)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(b))){if(this.options.noClip){this._parts=this._rings;return}for(var he=0,Me=this._rings.length,He;heb.y!=Me.y>b.y&&b.x<(Me.x-he.x)*(b.y-he.y)/(Me.y-he.y)+he.x&&(F=!F);return F||mo.prototype._containsPoint.call(this,b,!0)}});function Ui(b,F){return new Ma(b,F)}var bl=$r.extend({initialize:function(b,F){x(this,F),this._layers={},b&&this.addData(b)},addData:function(b){var F=C(b)?b:b.features,X,he,Me;if(F){for(X=0,he=F.length;X0&&Me.push(Me[0].slice()),Me}function rl(b,F){return b.feature?i({},b.feature,{geometry:F}):Tc(F)}function Tc(b){return b.type==="Feature"||b.type==="FeatureCollection"?b:{type:"Feature",properties:{},geometry:b}}var Hi={toGeoJSON:function(b){return rl(this,{type:"Point",coordinates:pd(this.getLatLng(),b)})}};Yc.include(Hi),Sc.include(Hi),Ys.include(Hi),mo.include({toGeoJSON:function(b){var F=!Ka(this._latlngs),X=zl(this._latlngs,F?1:0,!1,b);return rl(this,{type:(F?"Multi":"")+"LineString",coordinates:X})}}),Ma.include({toGeoJSON:function(b){var F=!Ka(this._latlngs),X=F&&!Ka(this._latlngs[0]),he=zl(this._latlngs,X?2:F?1:0,!0,b);return F||(he=[he]),rl(this,{type:(X?"Multi":"")+"Polygon",coordinates:he})}}),ms.include({toMultiPoint:function(b){var F=[];return this.eachLayer(function(X){F.push(X.toGeoJSON(b).geometry.coordinates)}),rl(this,{type:"MultiPoint",coordinates:F})},toGeoJSON:function(b){var F=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(F==="MultiPoint")return this.toMultiPoint(b);var X=F==="GeometryCollection",he=[];return this.eachLayer(function(Me){if(Me.toGeoJSON){var He=Me.toGeoJSON(b);if(X)he.push(He.geometry);else{var Mt=Tc(He);Mt.type==="FeatureCollection"?he.push.apply(he,Mt.features):he.push(Mt)}}}),X?rl(this,{geometries:he,type:"GeometryCollection"}):{type:"FeatureCollection",features:he}}});function tc(b,F){return new bl(b,F)}var Eu=tc,Zc=Co.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(b,F,X){this._url=b,this._bounds=Ae(F),x(this,X)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(zn(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){Tn(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(b){return this.options.opacity=b,this._image&&this._updateOpacity(),this},setStyle:function(b){return b.opacity&&this.setOpacity(b.opacity),this},bringToFront:function(){return this._map&&Wn(this._image),this},bringToBack:function(){return this._map&&Ar(this._image),this},setUrl:function(b){return this._url=b,this._image&&(this._image.src=b),this},setBounds:function(b){return this._bounds=Ae(b),this._map&&this._reset(),this},getEvents:function(){var b={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(b.zoomanim=this._animateZoom),b},setZIndex:function(b){return this.options.zIndex=b,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var b=this._url.tagName==="IMG",F=this._image=b?this._url:hn("img");if(zn(F,"leaflet-image-layer"),this._zoomAnimated&&zn(F,"leaflet-zoom-animated"),this.options.className&&zn(F,this.options.className),F.onselectstart=d,F.onmousemove=d,F.onload=a(this.fire,this,"load"),F.onerror=a(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(F.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),b){this._url=F.src;return}F.src=this._url,F.alt=this.options.alt},_animateZoom:function(b){var F=this._map.getZoomScale(b.zoom),X=this._map._latLngBoundsToNewLayerBounds(this._bounds,b.zoom,b.center).min;sr(this._image,X,F)},_reset:function(){var b=this._image,F=new fe(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),X=F.getSize();Ai(b,F.min),b.style.width=X.x+"px",b.style.height=X.y+"px"},_updateOpacity:function(){Ir(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var b=this.options.errorOverlayUrl;b&&this._url!==b&&(this._url=b,this._image.src=b)},getCenter:function(){return this._bounds.getCenter()}}),ua=function(b,F,X){return new Zc(b,F,X)},da=Zc.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var b=this._url.tagName==="VIDEO",F=this._image=b?this._url:hn("video");if(zn(F,"leaflet-image-layer"),this._zoomAnimated&&zn(F,"leaflet-zoom-animated"),this.options.className&&zn(F,this.options.className),F.onselectstart=d,F.onmousemove=d,F.onloadeddata=a(this.fire,this,"load"),b){for(var X=F.getElementsByTagName("source"),he=[],Me=0;Me0?he:[F.src];return}C(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(F.style,"objectFit")&&(F.style.objectFit="fill"),F.autoplay=!!this.options.autoplay,F.loop=!!this.options.loop,F.muted=!!this.options.muted,F.playsInline=!!this.options.playsInline;for(var He=0;HeMe?(F.height=Me+"px",zn(b,He)):Nr(b,He),this._containerWidth=this._container.offsetWidth},_animateZoom:function(b){var F=this._map._latLngToNewLayerPoint(this._latlng,b.zoom,b.center),X=this._getAnchor();Ai(this._container,F.add(X))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var b=this._map,F=parseInt(Sn(this._container,"marginBottom"),10)||0,X=this._container.offsetHeight+F,he=this._containerWidth,Me=new Q(this._containerLeft,-X-this._containerBottom);Me._add(fs(this._container));var He=b.layerPointToContainerPoint(Me),Mt=oe(this.options.autoPanPadding),Jt=oe(this.options.autoPanPaddingTopLeft||Mt),rn=oe(this.options.autoPanPaddingBottomRight||Mt),_n=b.getSize(),Xn=0,wr=0;He.x+he+rn.x>_n.x&&(Xn=He.x+he-_n.x+rn.x),He.x-Xn-Jt.x<0&&(Xn=He.x-Jt.x),He.y+X+rn.y>_n.y&&(wr=He.y+X-_n.y+rn.y),He.y-wr-Jt.y<0&&(wr=He.y-Jt.y),(Xn||wr)&&(this.options.keepInView&&(this._autopanning=!0),b.fire("autopanstart").panBy([Xn,wr]))}},_getAnchor:function(){return oe(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Nu=function(b,F){return new wl(b,F)};qr.mergeOptions({closePopupOnClick:!0}),qr.include({openPopup:function(b,F,X){return this._initOverlay(wl,b,F,X).openOn(this),this},closePopup:function(b){return b=arguments.length?b:this._popup,b&&b.close(),this}}),Co.include({bindPopup:function(b,F){return this._popup=this._initOverlay(wl,this._popup,b,F),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(b){return this._popup&&(this instanceof $r||(this._popup._source=this),this._popup._prepareOpen(b||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(b){return this._popup&&this._popup.setContent(b),this},getPopup:function(){return this._popup},_openPopup:function(b){if(!(!this._popup||!this._map)){xl(b);var F=b.layer||b.target;if(this._popup._source===F&&!(F instanceof el)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(b.latlng);return}this._popup._source=F,this.openPopup(b.latlng)}},_movePopup:function(b){this._popup.setLatLng(b.latlng)},_onKeyPress:function(b){b.originalEvent.keyCode===13&&this._openPopup(b)}});var Ua=Jr.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(b){Jr.prototype.onAdd.call(this,b),this.setOpacity(this.options.opacity),b.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(b){Jr.prototype.onRemove.call(this,b),b.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var b=Jr.prototype.getEvents.call(this);return this.options.permanent||(b.preclick=this.close),b},_initLayout:function(){var b="leaflet-tooltip",F=b+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=hn("div",F),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+l(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(b){var F,X,he=this._map,Me=this._container,He=he.latLngToContainerPoint(he.getCenter()),Mt=he.layerPointToContainerPoint(b),Jt=this.options.direction,rn=Me.offsetWidth,_n=Me.offsetHeight,Xn=oe(this.options.offset),wr=this._getAnchor();Jt==="top"?(F=rn/2,X=_n):Jt==="bottom"?(F=rn/2,X=0):Jt==="center"?(F=rn/2,X=_n/2):Jt==="right"?(F=0,X=_n/2):Jt==="left"?(F=rn,X=_n/2):Mt.xthis.options.maxZoom||Xhe?this._retainParent(Me,He,Mt,he):!1)},_retainChildren:function(b,F,X,he){for(var Me=2*b;Me<2*b+2;Me++)for(var He=2*F;He<2*F+2;He++){var Mt=new Q(Me,He);Mt.z=X+1;var Jt=this._tileCoordsToKey(Mt),rn=this._tiles[Jt];if(rn&&rn.active){rn.retain=!0;continue}else rn&&rn.loaded&&(rn.retain=!0);X+1this.options.maxZoom||this.options.minZoom!==void 0&&Me1){this._setView(b,X);return}for(var wr=Me.min.y;wr<=Me.max.y;wr++)for(var zr=Me.min.x;zr<=Me.max.x;zr++){var gi=new Q(zr,wr);if(gi.z=this._tileZoom,!!this._isValidTile(gi)){var yn=this._tiles[this._tileCoordsToKey(gi)];yn?yn.current=!0:Mt.push(gi)}}if(Mt.sort(function(Vl,Th){return Vl.distanceTo(He)-Th.distanceTo(He)}),Mt.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var bs=document.createDocumentFragment();for(zr=0;zrX.max.x)||!F.wrapLat&&(b.yX.max.y))return!1}if(!this.options.bounds)return!0;var he=this._tileCoordsToBounds(b);return Ae(this.options.bounds).overlaps(he)},_keyToBounds:function(b){return this._tileCoordsToBounds(this._keyToTileCoords(b))},_tileCoordsToNwSe:function(b){var F=this._map,X=this.getTileSize(),he=b.scaleBy(X),Me=he.add(X),He=F.unproject(he,b.z),Mt=F.unproject(Me,b.z);return[He,Mt]},_tileCoordsToBounds:function(b){var F=this._tileCoordsToNwSe(b),X=new me(F[0],F[1]);return this.options.noWrap||(X=this._map.wrapLatLngBounds(X)),X},_tileCoordsToKey:function(b){return b.x+":"+b.y+":"+b.z},_keyToTileCoords:function(b){var F=b.split(":"),X=new Q(+F[0],+F[1]);return X.z=+F[2],X},_removeTile:function(b){var F=this._tiles[b];F&&(Tn(F.el),delete this._tiles[b],this.fire("tileunload",{tile:F.el,coords:this._keyToTileCoords(b)}))},_initTile:function(b){zn(b,"leaflet-tile");var F=this.getTileSize();b.style.width=F.x+"px",b.style.height=F.y+"px",b.onselectstart=d,b.onmousemove=d,m.ielt9&&this.options.opacity<1&&Ir(b,this.options.opacity)},_addTile:function(b,F){var X=this._getTilePos(b),he=this._tileCoordsToKey(b),Me=this.createTile(this._wrapCoords(b),a(this._tileReady,this,b));this._initTile(Me),this.createTile.length<2&&G(a(this._tileReady,this,b,null,Me)),Ai(Me,X),this._tiles[he]={el:Me,coords:b,current:!0},F.appendChild(Me),this.fire("tileloadstart",{tile:Me,coords:b})},_tileReady:function(b,F,X){F&&this.fire("tileerror",{error:F,tile:X,coords:b});var he=this._tileCoordsToKey(b);X=this._tiles[he],X&&(X.loaded=+new Date,this._map._fadeAnimated?(Ir(X.el,0),H(this._fadeFrame),this._fadeFrame=G(this._updateOpacity,this)):(X.active=!0,this._pruneTiles()),F||(zn(X.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:X.el,coords:b})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),m.ielt9||!this._map._fadeAnimated?G(this._pruneTiles,this):setTimeout(a(this._pruneTiles,this),250)))},_getTilePos:function(b){return b.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(b){var F=new Q(this._wrapX?u(b.x,this._wrapX):b.x,this._wrapY?u(b.y,this._wrapY):b.y);return F.z=b.z,F},_pxBoundsToTileRange:function(b){var F=this.getTileSize();return new fe(b.min.unscaleBy(F).floor(),b.max.unscaleBy(F).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var b in this._tiles)if(!this._tiles[b].loaded)return!1;return!0}});function lp(b){return new md(b)}var Ao=md.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(b,F){this._url=b,F=x(this,F),F.detectRetina&&m.retina&&F.maxZoom>0?(F.tileSize=Math.floor(F.tileSize/2),F.zoomReverse?(F.zoomOffset--,F.minZoom=Math.min(F.maxZoom,F.minZoom+1)):(F.zoomOffset++,F.maxZoom=Math.max(F.minZoom,F.maxZoom-1)),F.minZoom=Math.max(0,F.minZoom)):F.zoomReverse?F.minZoom=Math.min(F.maxZoom,F.minZoom):F.maxZoom=Math.max(F.minZoom,F.maxZoom),typeof F.subdomains=="string"&&(F.subdomains=F.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(b,F){return this._url===b&&F===void 0&&(F=!0),this._url=b,F||this.redraw(),this},createTile:function(b,F){var X=document.createElement("img");return Dn(X,"load",a(this._tileOnLoad,this,F,X)),Dn(X,"error",a(this._tileOnError,this,F,X)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(X.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(X.referrerPolicy=this.options.referrerPolicy),X.alt="",X.src=this.getTileUrl(b),X},getTileUrl:function(b){var F={r:m.retina?"@2x":"",s:this._getSubdomain(b),x:b.x,y:b.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var X=this._globalTileRange.max.y-b.y;this.options.tms&&(F.y=X),F["-y"]=X}return M(this._url,i(F,this.options))},_tileOnLoad:function(b,F){m.ielt9?setTimeout(a(b,this,null,F),0):b(null,F)},_tileOnError:function(b,F,X){var he=this.options.errorTileUrl;he&&F.getAttribute("src")!==he&&(F.src=he),b(X,F)},_onTileRemove:function(b){b.tile.onload=null},_getZoomForUrl:function(){var b=this._tileZoom,F=this.options.maxZoom,X=this.options.zoomReverse,he=this.options.zoomOffset;return X&&(b=F-b),b+he},_getSubdomain:function(b){var F=Math.abs(b.x+b.y)%this.options.subdomains.length;return this.options.subdomains[F]},_abortLoading:function(){var b,F;for(b in this._tiles)if(this._tiles[b].coords.z!==this._tileZoom&&(F=this._tiles[b].el,F.onload=d,F.onerror=d,!F.complete)){F.src=B;var X=this._tiles[b].coords;Tn(F),delete this._tiles[b],this.fire("tileabort",{tile:F,coords:X})}},_removeTile:function(b){var F=this._tiles[b];if(F)return F.el.setAttribute("src",B),md.prototype._removeTile.call(this,b)},_tileReady:function(b,F,X){if(!(!this._map||X&&X.getAttribute("src")===B))return md.prototype._tileReady.call(this,b,F,X)}});function il(b,F){return new Ao(b,F)}var Mu=Ao.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(b,F){this._url=b;var X=i({},this.defaultWmsParams);for(var he in F)he in this.options||(X[he]=F[he]);F=x(this,F);var Me=F.detectRetina&&m.retina?2:1,He=this.getTileSize();X.width=He.x*Me,X.height=He.y*Me,this.wmsParams=X},onAdd:function(b){this._crs=this.options.crs||b.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var F=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[F]=this._crs.code,Ao.prototype.onAdd.call(this,b)},getTileUrl:function(b){var F=this._tileCoordsToNwSe(b),X=this._crs,he=ee(X.project(F[0]),X.project(F[1])),Me=he.min,He=he.max,Mt=(this._wmsVersion>=1.3&&this._crs===Xc?[Me.y,Me.x,He.y,He.x]:[Me.x,Me.y,He.x,He.y]).join(","),Jt=Ao.prototype.getTileUrl.call(this,b);return Jt+_(this.wmsParams,Jt,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+Mt},setParams:function(b,F){return i(this.wmsParams,b),F||this.redraw(),this}});function gd(b,F){return new Mu(b,F)}Ao.WMS=Mu,il.wms=gd;var Sl=Co.extend({options:{padding:.1},initialize:function(b){x(this,b),l(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),zn(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var b={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(b.zoomanim=this._onAnimZoom),b},_onAnimZoom:function(b){this._updateTransform(b.center,b.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(b,F){var X=this._map.getZoomScale(F,this._zoom),he=this._map.getSize().multiplyBy(.5+this.options.padding),Me=this._map.project(this._center,F),He=he.multiplyBy(-X).add(Me).subtract(this._map._getNewPixelOrigin(b,F));m.any3d?sr(this._container,He,X):Ai(this._container,He)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var b in this._layers)this._layers[b]._reset()},_onZoomEnd:function(){for(var b in this._layers)this._layers[b]._project()},_updatePaths:function(){for(var b in this._layers)this._layers[b]._update()},_update:function(){var b=this.options.padding,F=this._map.getSize(),X=this._map.containerPointToLayerPoint(F.multiplyBy(-b)).round();this._bounds=new fe(X,X.add(F.multiplyBy(1+b*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),vf=Sl.extend({options:{tolerance:0},getEvents:function(){var b=Sl.prototype.getEvents.call(this);return b.viewprereset=this._onViewPreReset,b},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Sl.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var b=this._container=document.createElement("canvas");Dn(b,"mousemove",this._onMouseMove,this),Dn(b,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Dn(b,"mouseout",this._handleMouseOut,this),b._leaflet_disable_events=!0,this._ctx=b.getContext("2d")},_destroyContainer:function(){H(this._redrawRequest),delete this._ctx,Tn(this._container),es(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var b;this._redrawBounds=null;for(var F in this._layers)b=this._layers[F],b._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Sl.prototype._update.call(this);var b=this._bounds,F=this._container,X=b.getSize(),he=m.retina?2:1;Ai(F,b.min),F.width=he*X.x,F.height=he*X.y,F.style.width=X.x+"px",F.style.height=X.y+"px",m.retina&&this._ctx.scale(2,2),this._ctx.translate(-b.min.x,-b.min.y),this.fire("update")}},_reset:function(){Sl.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(b){this._updateDashArray(b),this._layers[l(b)]=b;var F=b._order={layer:b,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=F),this._drawLast=F,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(b){this._requestRedraw(b)},_removePath:function(b){var F=b._order,X=F.next,he=F.prev;X?X.prev=he:this._drawLast=he,he?he.next=X:this._drawFirst=X,delete b._order,delete this._layers[l(b)],this._requestRedraw(b)},_updatePath:function(b){this._extendRedrawBounds(b),b._project(),b._update(),this._requestRedraw(b)},_updateStyle:function(b){this._updateDashArray(b),this._requestRedraw(b)},_updateDashArray:function(b){if(typeof b.options.dashArray=="string"){var F=b.options.dashArray.split(/[, ]+/),X=[],he,Me;for(Me=0;Me')}}catch{}return function(b){return document.createElement("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),cp={_initContainer:function(){this._container=hn("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Sl.prototype._update.call(this),this.fire("update"))},_initPath:function(b){var F=b._container=Cu("shape");zn(F,"leaflet-vml-shape "+(this.options.className||"")),F.coordsize="1 1",b._path=Cu("path"),F.appendChild(b._path),this._updateStyle(b),this._layers[l(b)]=b},_addPath:function(b){var F=b._container;this._container.appendChild(F),b.options.interactive&&b.addInteractiveTarget(F)},_removePath:function(b){var F=b._container;Tn(F),b.removeInteractiveTarget(F),delete this._layers[l(b)]},_updateStyle:function(b){var F=b._stroke,X=b._fill,he=b.options,Me=b._container;Me.stroked=!!he.stroke,Me.filled=!!he.fill,he.stroke?(F||(F=b._stroke=Cu("stroke")),Me.appendChild(F),F.weight=he.weight+"px",F.color=he.color,F.opacity=he.opacity,he.dashArray?F.dashStyle=C(he.dashArray)?he.dashArray.join(" "):he.dashArray.replace(/( *, *)/g," "):F.dashStyle="",F.endcap=he.lineCap.replace("butt","flat"),F.joinstyle=he.lineJoin):F&&(Me.removeChild(F),b._stroke=null),he.fill?(X||(X=b._fill=Cu("fill")),Me.appendChild(X),X.color=he.fillColor||he.color,X.opacity=he.fillOpacity):X&&(Me.removeChild(X),b._fill=null)},_updateCircle:function(b){var F=b._point.round(),X=Math.round(b._radius),he=Math.round(b._radiusY||X);this._setPath(b,b._empty()?"M0 0":"AL "+F.x+","+F.y+" "+X+","+he+" 0,"+65535*360)},_setPath:function(b,F){b._path.v=F},_bringToFront:function(b){Wn(b._container)},_bringToBack:function(b){Ar(b._container)}},wh=m.vml?Cu:Ce,Ad=Sl.extend({_initContainer:function(){this._container=wh("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=wh("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){Tn(this._container),es(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){Sl.prototype._update.call(this);var b=this._bounds,F=b.getSize(),X=this._container;(!this._svgSize||!this._svgSize.equals(F))&&(this._svgSize=F,X.setAttribute("width",F.x),X.setAttribute("height",F.y)),Ai(X,b.min),X.setAttribute("viewBox",[b.min.x,b.min.y,F.x,F.y].join(" ")),this.fire("update")}},_initPath:function(b){var F=b._path=wh("path");b.options.className&&zn(F,b.options.className),b.options.interactive&&zn(F,"leaflet-interactive"),this._updateStyle(b),this._layers[l(b)]=b},_addPath:function(b){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(b._path),b.addInteractiveTarget(b._path)},_removePath:function(b){Tn(b._path),b.removeInteractiveTarget(b._path),delete this._layers[l(b)]},_updatePath:function(b){b._project(),b._update()},_updateStyle:function(b){var F=b._path,X=b.options;F&&(X.stroke?(F.setAttribute("stroke",X.color),F.setAttribute("stroke-opacity",X.opacity),F.setAttribute("stroke-width",X.weight),F.setAttribute("stroke-linecap",X.lineCap),F.setAttribute("stroke-linejoin",X.lineJoin),X.dashArray?F.setAttribute("stroke-dasharray",X.dashArray):F.removeAttribute("stroke-dasharray"),X.dashOffset?F.setAttribute("stroke-dashoffset",X.dashOffset):F.removeAttribute("stroke-dashoffset")):F.setAttribute("stroke","none"),X.fill?(F.setAttribute("fill",X.fillColor||X.color),F.setAttribute("fill-opacity",X.fillOpacity),F.setAttribute("fill-rule",X.fillRule||"evenodd")):F.setAttribute("fill","none"))},_updatePoly:function(b,F){this._setPath(b,lt(b._parts,F))},_updateCircle:function(b){var F=b._point,X=Math.max(Math.round(b._radius),1),he=Math.max(Math.round(b._radiusY),1)||X,Me="a"+X+","+he+" 0 1,0 ",He=b._empty()?"M0 0":"M"+(F.x-X)+","+F.y+Me+X*2+",0 "+Me+-X*2+",0 ";this._setPath(b,He)},_setPath:function(b,F){b._path.setAttribute("d",F)},_bringToFront:function(b){Wn(b._path)},_bringToBack:function(b){Ar(b._path)}});m.vml&&Ad.include(cp);function sl(b){return m.svg||m.vml?new Ad(b):null}qr.include({getRenderer:function(b){var F=b.options.renderer||this._getPaneRenderer(b.options.pane)||this.options.renderer||this._renderer;return F||(F=this._renderer=this._createRenderer()),this.hasLayer(F)||this.addLayer(F),F},_getPaneRenderer:function(b){if(b==="overlayPane"||b===void 0)return!1;var F=this._paneRenderers[b];return F===void 0&&(F=this._createRenderer({pane:b}),this._paneRenderers[b]=F),F},_createRenderer:function(b){return this.options.preferCanvas&&u0(b)||sl(b)}});var Lo=Ma.extend({initialize:function(b,F){Ma.prototype.initialize.call(this,this._boundsToLatLngs(b),F)},setBounds:function(b){return this.setLatLngs(this._boundsToLatLngs(b))},_boundsToLatLngs:function(b){return b=Ae(b),[b.getSouthWest(),b.getNorthWest(),b.getNorthEast(),b.getSouthEast()]}});function d0(b,F){return new Lo(b,F)}Ad.create=wh,Ad.pointsToPath=lt,bl.geometryToLayer=ys,bl.coordsToLatLng=_l,bl.coordsToLatLngs=Ro,bl.latLngToCoords=pd,bl.latLngsToCoords=zl,bl.getFeature=rl,bl.asFeature=Tc,qr.mergeOptions({boxZoom:!0});var Gd=ce.extend({initialize:function(b){this._map=b,this._container=b._container,this._pane=b._panes.overlayPane,this._resetStateTimeout=0,b.on("unload",this._destroy,this)},addHooks:function(){Dn(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){es(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){Tn(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(b){if(!b.shiftKey||b.which!==1&&b.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),Ki(),ja(),this._startPoint=this._map.mouseEventToContainerPoint(b),Dn(document,{contextmenu:xl,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(b){this._moved||(this._moved=!0,this._box=hn("div","leaflet-zoom-box",this._container),zn(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(b);var F=new fe(this._point,this._startPoint),X=F.getSize();Ai(this._box,F.min),this._box.style.width=X.x+"px",this._box.style.height=X.y+"px"},_finish:function(){this._moved&&(Tn(this._box),Nr(this._container,"leaflet-crosshair")),js(),fi(),es(document,{contextmenu:xl,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(b){if(!(b.which!==1&&b.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(a(this._resetState,this),0);var F=new me(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(F).fire("boxzoomend",{boxZoomBounds:F})}},_onKeyDown:function(b){b.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});qr.addInitHook("addHandler","boxZoom",Gd),qr.mergeOptions({doubleClickZoom:!0});var yf=ce.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(b){var F=this._map,X=F.getZoom(),he=F.options.zoomDelta,Me=b.originalEvent.shiftKey?X-he:X+he;F.options.doubleClickZoom==="center"?F.setZoom(Me):F.setZoomAround(b.containerPoint,Me)}});qr.addInitHook("addHandler","doubleClickZoom",yf),qr.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Sh=ce.extend({addHooks:function(){if(!this._draggable){var b=this._map;this._draggable=new Et(b._mapPane,b._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),b.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),b.on("zoomend",this._onZoomEnd,this),b.whenReady(this._onZoomEnd,this))}zn(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){Nr(this._map._container,"leaflet-grab"),Nr(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var b=this._map;if(b._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var F=Ae(this._map.options.maxBounds);this._offsetLimit=ee(this._map.latLngToContainerPoint(F.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(F.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;b.fire("movestart").fire("dragstart"),b.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(b){if(this._map.options.inertia){var F=this._lastTime=+new Date,X=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(X),this._times.push(F),this._prunePositions(F)}this._map.fire("move",b).fire("drag",b)},_prunePositions:function(b){for(;this._positions.length>1&&b-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var b=this._map.getSize().divideBy(2),F=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=F.subtract(b).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(b,F){return b-(b-F)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var b=this._draggable._newPos.subtract(this._draggable._startPos),F=this._offsetLimit;b.xF.max.x&&(b.x=this._viscousLimit(b.x,F.max.x)),b.y>F.max.y&&(b.y=this._viscousLimit(b.y,F.max.y)),this._draggable._newPos=this._draggable._startPos.add(b)}},_onPreDragWrap:function(){var b=this._worldWidth,F=Math.round(b/2),X=this._initialWorldOffset,he=this._draggable._newPos.x,Me=(he-F+X)%b+F-X,He=(he+F+X)%b-F-X,Mt=Math.abs(Me+X)0?He:-He))-F;this._delta=0,this._startTime=null,Mt&&(b.options.scrollWheelZoom==="center"?b.setZoom(F+Mt):b.setZoomAround(this._lastMousePos,F+Mt))}});qr.addInitHook("addHandler","scrollWheelZoom",bf);var up=600;qr.mergeOptions({tapHold:m.touchNative&&m.safari&&m.mobile,tapTolerance:15});var h0=ce.extend({addHooks:function(){Dn(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){es(this._map._container,"touchstart",this._onDown,this)},_onDown:function(b){if(clearTimeout(this._holdTimeout),b.touches.length===1){var F=b.touches[0];this._startPos=this._newPos=new Q(F.clientX,F.clientY),this._holdTimeout=setTimeout(a(function(){this._cancel(),this._isTapValid()&&(Dn(document,"touchend",Fs),Dn(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",F))},this),up),Dn(document,"touchend touchcancel contextmenu",this._cancel,this),Dn(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function b(){es(document,"touchend",Fs),es(document,"touchend touchcancel",b)},_cancel:function(){clearTimeout(this._holdTimeout),es(document,"touchend touchcancel contextmenu",this._cancel,this),es(document,"touchmove",this._onMove,this)},_onMove:function(b){var F=b.touches[0];this._newPos=new Q(F.clientX,F.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(b,F){var X=new MouseEvent(b,{bubbles:!0,cancelable:!0,view:window,screenX:F.screenX,screenY:F.screenY,clientX:F.clientX,clientY:F.clientY});X._simulated=!0,F.target.dispatchEvent(X)}});qr.addInitHook("addHandler","tapHold",h0),qr.mergeOptions({touchZoom:m.touch,bounceAtZoomLimits:!0});var vd=ce.extend({addHooks:function(){zn(this._map._container,"leaflet-touch-zoom"),Dn(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){Nr(this._map._container,"leaflet-touch-zoom"),es(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(b){var F=this._map;if(!(!b.touches||b.touches.length!==2||F._animatingZoom||this._zooming)){var X=F.mouseEventToContainerPoint(b.touches[0]),he=F.mouseEventToContainerPoint(b.touches[1]);this._centerPoint=F.getSize()._divideBy(2),this._startLatLng=F.containerPointToLatLng(this._centerPoint),F.options.touchZoom!=="center"&&(this._pinchStartLatLng=F.containerPointToLatLng(X.add(he)._divideBy(2))),this._startDist=X.distanceTo(he),this._startZoom=F.getZoom(),this._moved=!1,this._zooming=!0,F._stop(),Dn(document,"touchmove",this._onTouchMove,this),Dn(document,"touchend touchcancel",this._onTouchEnd,this),Fs(b)}},_onTouchMove:function(b){if(!(!b.touches||b.touches.length!==2||!this._zooming)){var F=this._map,X=F.mouseEventToContainerPoint(b.touches[0]),he=F.mouseEventToContainerPoint(b.touches[1]),Me=X.distanceTo(he)/this._startDist;if(this._zoom=F.getScaleZoom(Me,this._startZoom),!F.options.bounceAtZoomLimits&&(this._zoomF.getMaxZoom()&&Me>1)&&(this._zoom=F._limitZoom(this._zoom)),F.options.touchZoom==="center"){if(this._center=this._startLatLng,Me===1)return}else{var He=X._add(he)._divideBy(2)._subtract(this._centerPoint);if(Me===1&&He.x===0&&He.y===0)return;this._center=F.unproject(F.project(this._pinchStartLatLng,this._zoom).subtract(He),this._zoom)}this._moved||(F._moveStart(!0,!1),this._moved=!0),H(this._animRequest);var Mt=a(F._move,F,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=G(Mt,this,!0),Fs(b)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,H(this._animRequest),es(document,"touchmove",this._onTouchMove,this),es(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});qr.addInitHook("addHandler","touchZoom",vd),qr.BoxZoom=Gd,qr.DoubleClickZoom=yf,qr.Drag=Sh,qr.Keyboard=xd,qr.ScrollWheelZoom=bf,qr.TapHold=h0,qr.TouchZoom=vd,t.Bounds=fe,t.Browser=m,t.CRS=ge,t.Canvas=vf,t.Circle=Sc,t.CircleMarker=Ys,t.Class=W,t.Control=$s,t.DivIcon=go,t.DivOverlay=Jr,t.DomEvent=bc,t.DomUtil=Xo,t.Draggable=Et,t.Evented=ae,t.FeatureGroup=$r,t.GeoJSON=bl,t.GridLayer=md,t.Handler=ce,t.Icon=Na,t.ImageOverlay=Zc,t.LatLng=be,t.LatLngBounds=me,t.Layer=Co,t.LayerGroup=ms,t.LineUtil=Ja,t.Map=qr,t.Marker=Yc,t.Mixin=Oe,t.Path=el,t.Point=Q,t.PolyUtil=dr,t.Polygon=Ma,t.Polyline=mo,t.Popup=wl,t.PosAnimation=Qa,t.Projection=Bl,t.Rectangle=Lo,t.Renderer=Sl,t.SVG=Ad,t.SVGOverlay=Br,t.TileLayer=Ao,t.Tooltip=Ua,t.Transformation=Qe,t.Util=K,t.VideoOverlay=da,t.bind=a,t.bounds=ee,t.canvas=u0,t.circle=ec,t.circleMarker=tl,t.control=ca,t.divIcon=_h,t.extend=i,t.featureGroup=wc,t.geoJSON=tc,t.geoJson=Eu,t.gridLayer=lp,t.icon=po,t.imageOverlay=ua,t.latLng=pe,t.latLngBounds=Ae,t.layerGroup=Ms,t.map=Wc,t.marker=hd,t.point=oe,t.polygon=Ui,t.polyline=fd,t.popup=Nu,t.rectangle=d0,t.setOptions=x,t.stamp=l,t.svg=sl,t.svgOverlay=xi,t.tileLayer=il,t.tooltip=xf,t.transformation=ot,t.version=r,t.videoOverlay=ts;var ko=window.L;t.noConflict=function(){return window.L=ko,this},window.L=t})})(Uz,Uz.exports);var L3=Uz.exports;const VM=Vv(L3);function cP(n,e,t){return Object.freeze({instance:n,context:e,container:t})}function uP(n,e){return e==null?function(r,i){const s=de.useRef();return s.current||(s.current=n(r,i)),s}:function(r,i){const s=de.useRef();s.current||(s.current=n(r,i));const a=de.useRef(r),{instance:o}=s.current;return de.useEffect(function(){a.current!==r&&(e(o,r,a.current),a.current=r)},[o,r,i]),s}}function h2e(n,e){de.useEffect(function(){return(e.layerContainer??e.map).addLayer(n.instance),function(){var s;(s=e.layerContainer)==null||s.removeLayer(n.instance),e.map.removeLayer(n.instance)}},[e,n])}function f2e(n){return function(t){const r=f$(),i=n(lP(t,r),r);return o2e(r.map,t.attribution),p$(i.current,t.eventHandlers),h2e(i.current,r),i}}function mHe(n,e){const t=de.useRef();de.useEffect(function(){if(e.pathOptions!==t.current){const i=e.pathOptions??{};n.instance.setStyle(i),t.current=i}},[n,e])}function gHe(n){return function(t){const r=f$(),i=n(lP(t,r),r);return p$(i.current,t.eventHandlers),h2e(i.current,r),mHe(i.current,t),i}}function AHe(n,e){const t=uP(n,e),r=f2e(t);return d2e(r)}function xHe(n,e){const t=uP(n),r=pHe(t,e);return hHe(r)}function vHe(n,e){const t=uP(n,e),r=gHe(t);return d2e(r)}function yHe(n,e){const t=uP(n,e),r=f2e(t);return fHe(r)}function bHe(n,e,t){const{opacity:r,zIndex:i}=e;r!=null&&r!==t.opacity&&n.setOpacity(r),i!=null&&i!==t.zIndex&&n.setZIndex(i)}function zz(){return zz=Object.assign||function(n){for(var e=1;e(p==null?void 0:p.map)??null,[p]);const x=de.useCallback(y=>{if(y!==null&&p===null){const M=new L3.Map(y,u);t!=null&&c!=null?M.setView(t,c):n!=null&&M.fitBounds(n,e),l!=null&&M.whenReady(l),g(dHe(M))}},[]);de.useEffect(()=>()=>{p==null||p.map.remove()},[p]);const _=p?ln.createElement(u2e,{value:p},r):a??null;return ln.createElement("div",zz({},h,{ref:x}),_)}const wHe=de.forwardRef(_He),SHe=AHe(function({position:e,...t},r){const i=new L3.Marker(e,t);return cP(i,l2e(r,{overlayContainer:i}))},function(e,t,r){t.position!==r.position&&e.setLatLng(t.position),t.icon!=null&&t.icon!==r.icon&&e.setIcon(t.icon),t.zIndexOffset!=null&&t.zIndexOffset!==r.zIndexOffset&&e.setZIndexOffset(t.zIndexOffset),t.opacity!=null&&t.opacity!==r.opacity&&e.setOpacity(t.opacity),e.dragging!=null&&t.draggable!==r.draggable&&(t.draggable===!0?e.dragging.enable():e.dragging.disable())}),THe=vHe(function({positions:e,...t},r){const i=new L3.Polyline(e,t);return cP(i,l2e(r,{overlayContainer:i}))},function(e,t,r){t.positions!==r.positions&&e.setLatLngs(t.positions)}),Hse=xHe(function(e,t){const r=new L3.Popup(e,t.overlayContainer);return cP(r,t)},function(e,t,{position:r},i){de.useEffect(function(){const{instance:a}=e;function o(c){c.popup===a&&(a.update(),i(!0))}function l(c){c.popup===a&&i(!1)}return t.map.on({popupopen:o,popupclose:l}),t.overlayContainer==null?(r!=null&&a.setLatLng(r),a.openOn(t.map)):t.overlayContainer.bindPopup(a),function(){var u;t.map.off({popupopen:o,popupclose:l}),(u=t.overlayContainer)==null||u.unbindPopup(),t.map.removeLayer(a)}},[e,t,i,r])}),EHe=yHe(function({url:e,...t},r){const i=new L3.TileLayer(e,lP(t,r));return cP(i,r)},function(e,t,r){bHe(e,t,r);const{url:i}=t;i!=null&&i!==r.url&&e.setUrl(i)});function NHe(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,i,s,a,o=[],l=!0,c=!1;try{if(s=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=s.call(t)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}function MHe(n,e,t){return e=OHe(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function $se(n,e){return RHe(n)||NHe(n,e)||p2e(n,e)||IHe()}function CHe(n){return PHe(n)||LHe(n)||p2e(n)||kHe()}function PHe(n){if(Array.isArray(n))return Vz(n)}function RHe(n){if(Array.isArray(n))return n}function LHe(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function p2e(n,e){if(n){if(typeof n=="string")return Vz(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);if(t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set")return Array.from(n);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Vz(n,e)}}function Vz(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);ts,methodNames:r=[],initPropNames:i=[]}={}){return de.forwardRef((s,a)=>{const o=de.useRef(),l=de.useMemo(()=>{const d=Object.fromEntries(i.filter(h=>s.hasOwnProperty(h)).map(h=>[h,s[h]]));return n(d)},[]);Wse(()=>{l(t(o.current))},de.useLayoutEffect),Wse(()=>l._destructor instanceof Function?l._destructor:void 0);const c=de.useCallback((d,...h)=>l[d]instanceof Function?l[d](...h):void 0,[l]),u=de.useRef({});return Object.keys(jHe(s,[...r,...i])).filter(d=>u.current[d]!==s[d]).forEach(d=>c(d,s[d])),u.current=s,de.useImperativeHandle(a,()=>Object.fromEntries(r.map(d=>[d,(...h)=>c(d,...h)])),[c]),ln.createElement(e,{ref:o})})}function Wse(n,e=de.useEffect){const t=de.useRef(),r=de.useRef(!1),i=de.useRef(!1),[s,a]=de.useState(0);r.current&&(i.current=!0),e(()=>(r.current||(t.current=n(),r.current=!0),a(o=>o+1),()=>{i.current&&(t.current&&t.current(),t.current=void 0,r.current=!1,i.current=!1)}),[])}/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT */const Sm="185",sc={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},$h={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},m$=0,qM=1,g$=2,BHe=3,A$=0,EA=1,y_=2,Vf=3,id=0,Ds=1,ao=2,Yl=0,ac=1,Kh=2,cg=3,ug=4,NA=5,dP=6,Fc=100,hP=101,fP=102,x$=103,v$=104,Bp=200,pP=201,mP=202,gP=203,rv=204,iv=205,AP=206,xP=207,vP=208,yP=209,bP=210,m2e=211,g2e=212,A2e=213,x2e=214,G_=0,H_=1,$_=2,jg=3,W_=4,X_=5,Y_=6,Z_=7,k3=0,y$=1,b$=2,cc=0,_P=1,wP=2,SP=3,QS=4,_$=5,TP=6,EP=7,qz="attached",v2e="detached",KS=300,ph=301,e0=302,MA=303,CA=304,pm=306,Fg=1e3,uc=1001,Bg=1002,Ss=1003,JS=1004,UHe=1004,qf=1005,zHe=1005,Ci=1006,PA=1007,VHe=1007,Bc=1008,y2e=1008,ma=1009,gg=1010,Ag=1011,Jh=1012,ml=1013,xs=1014,ea=1015,ba=1016,I3=1017,D3=1018,Od=1020,O3=35902,j3=35899,e6=1021,t2=1022,Oa=1023,hc=1026,mu=1027,e1=1028,Tm=1029,dc=1030,t1=1031,NP=1032,Jv=1033,xg=33776,vg=33777,yg=33778,bg=33779,Q_=35840,K_=35841,J_=35842,e3=35843,sv=36196,av=37492,ov=37496,lv=37488,cv=37489,Ug=37490,uv=37491,dv=37808,hv=37809,fv=37810,pv=37811,mv=37812,gv=37813,Av=37814,xv=37815,vv=37816,yv=37817,bv=37818,_v=37819,wv=37820,Sv=37821,Tv=36492,Ev=36494,Nv=36495,Mv=36283,Cv=36284,zg=36285,Pv=36286,b2e=2200,_2e=2201,w2e=2202,iS=2300,GM=2301,pN=2302,Gz=2303,wx=2400,Sx=2401,sS=2402,MP=2500,w$=2501,S2e=0,T2e=1,Hz=2,E2e=3200,N2e=3201,qHe=3202,GHe=3203,Xf=0,S$=1,Rd="",ic="srgb",Rv="srgb-linear",Lv="linear",rr="srgb",mN="",T$="rg",M2e="ga",C2e=0,q1=7680,P2e=7681,R2e=7682,L2e=7683,k2e=34055,I2e=34056,D2e=5386,O2e=512,j2e=513,F2e=514,B2e=515,U2e=516,z2e=517,V2e=518,HM=519,CP=512,t6=513,PP=514,n1=515,t3=516,RP=517,mm=518,LP=519,UA=35044,F3=35048,HHe=35040,$He=35045,WHe=35049,XHe=35041,YHe=35046,ZHe=35050,QHe=35042,KHe="100",$z="300 es",gu=2e3,mh=2001,I0={COMPUTE:"compute",RENDER:"render"},JHe={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},e$e={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},n2={TEXTURE_COMPARE:"depthTextureCompare"};function t$e(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}const n$e={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Jb(n,e){return new n$e[n](e)}function n3(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function aS(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function E$(){const n=aS("canvas");return n.style.display="block",n}const Xse={};let zA=null;function r$e(n){zA=n}function i$e(){return zA}function r3(...n){const e="THREE."+n.shift();zA?zA("log",e,...n):console.log(e,...n)}function q2e(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function sn(...n){n=q2e(n);const e="THREE."+n.shift();if(zA)zA("warn",e,...n);else{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function on(...n){n=q2e(n);const e="THREE."+n.shift();if(zA)zA("error",e,...n);else{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function ji(...n){const e=n.join(" ");e in Xse||(Xse[e]=!0,sn(...n))}function G2e(){return typeof self<"u"&&typeof self.scheduler<"u"&&typeof self.scheduler.yield<"u"?self.scheduler.yield():new Promise(n=>{requestAnimationFrame(n)})}function s$e(n,e,t){return new Promise(function(r,i){function s(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:i();break;case n.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:r()}}setTimeout(s,t)})}const N$={[G_]:H_,[$_]:Y_,[W_]:Z_,[jg]:X_,[H_]:G_,[Y_]:$_,[Z_]:W_,[X_]:jg};let zd=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const r=t[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;s>8&255]+zu[n>>16&255]+zu[n>>24&255]+"-"+zu[e&255]+zu[e>>8&255]+"-"+zu[e>>16&15|64]+zu[e>>24&255]+"-"+zu[t&63|128]+zu[t>>8&255]+"-"+zu[t>>16&255]+zu[t>>24&255]+zu[r&255]+zu[r>>8&255]+zu[r>>16&255]+zu[r>>24&255]).toLowerCase()}function ai(n,e,t){return Math.max(e,Math.min(t,n))}function M$(n,e){return(n%e+e)%e}function a$e(n,e,t,r,i){return r+(n-e)*(i-r)/(t-e)}function o$e(n,e,t){return n!==e?(t-n)/(e-n):0}function a4(n,e,t){return(1-t)*n+t*e}function l$e(n,e,t,r){return a4(n,e,1-Math.exp(-t*r))}function c$e(n,e=1){return e-Math.abs(M$(n,e*2)-e)}function u$e(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function d$e(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function h$e(n,e){return n+Math.floor(Math.random()*(e-n+1))}function f$e(n,e){return n+Math.random()*(e-n)}function p$e(n){return n*(.5-Math.random())}function m$e(n){n!==void 0&&(Yse=n);let e=Yse+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function g$e(n){return n*jx}function A$e(n){return n*kv}function x$e(n){return(n&n-1)===0&&n!==0}function v$e(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function y$e(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function b$e(n,e,t,r,i){const s=Math.cos,a=Math.sin,o=s(t/2),l=a(t/2),c=s((e+r)/2),u=a((e+r)/2),d=s((e-r)/2),h=a((e-r)/2),p=s((r-e)/2),g=a((r-e)/2);switch(i){case"XYX":n.set(o*u,l*d,l*h,o*c);break;case"YZY":n.set(l*h,o*u,l*d,o*c);break;case"ZXZ":n.set(l*d,l*h,o*u,o*c);break;case"XZX":n.set(o*u,l*g,l*p,o*c);break;case"YXY":n.set(l*p,o*u,l*g,o*c);break;case"ZYZ":n.set(l*g,l*p,o*u,o*c);break;default:sn("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Ld(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Mi(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const Q0={DEG2RAD:jx,RAD2DEG:kv,generateUUID:rf,clamp:ai,euclideanModulo:M$,mapLinear:a$e,inverseLerp:o$e,lerp:a4,damp:l$e,pingpong:c$e,smoothstep:u$e,smootherstep:d$e,randInt:h$e,randFloat:f$e,randFloatSpread:p$e,seededRandom:m$e,degToRad:g$e,radToDeg:A$e,isPowerOfTwo:x$e,ceilPowerOfTwo:v$e,floorPowerOfTwo:y$e,setQuaternionFromProperEuler:b$e,normalize:Mi,denormalize:Ld},jY=class jY{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 new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: 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){const t=this.x,r=this.y,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6],this.y=i[1]*t+i[4]*r+i[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=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(ai(r,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){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(ai(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,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){const r=Math.cos(t),i=Math.sin(t),s=this.x-e.x,a=this.y-e.y;return this.x=s*r-a*i+e.x,this.y=s*i+a*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};jY.prototype.isVector2=!0;let en=jY;class zo{constructor(e=0,t=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=r,this._w=i}static slerpFlat(e,t,r,i,s,a,o){let l=r[i+0],c=r[i+1],u=r[i+2],d=r[i+3],h=s[a+0],p=s[a+1],g=s[a+2],x=s[a+3];if(d!==x||l!==h||c!==p||u!==g){let _=l*h+c*p+u*g+d*x;_<0&&(h=-h,p=-p,g=-g,x=-x,_=-_);let y=1-o;if(_<.9995){const M=Math.acos(_),C=Math.sin(M);y=Math.sin(y*M)/C,o=Math.sin(o*M)/C,l=l*y+h*o,c=c*y+p*o,u=u*y+g*o,d=d*y+x*o}else{l=l*y+h*o,c=c*y+p*o,u=u*y+g*o,d=d*y+x*o;const M=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=M,c*=M,u*=M,d*=M}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,r,i,s,a){const o=r[i],l=r[i+1],c=r[i+2],u=r[i+3],d=s[a],h=s[a+1],p=s[a+2],g=s[a+3];return e[t]=o*g+u*d+l*p-c*h,e[t+1]=l*g+u*h+c*d-o*p,e[t+2]=c*g+u*p+o*h-l*d,e[t+3]=u*g-o*d-l*h-c*p,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,r,i){return this._x=e,this._y=t,this._z=r,this._w=i,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){const r=e._x,i=e._y,s=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(r/2),u=o(i/2),d=o(s/2),h=l(r/2),p=l(i/2),g=l(s/2);switch(a){case"XYZ":this._x=h*u*d+c*p*g,this._y=c*p*d-h*u*g,this._z=c*u*g+h*p*d,this._w=c*u*d-h*p*g;break;case"YXZ":this._x=h*u*d+c*p*g,this._y=c*p*d-h*u*g,this._z=c*u*g-h*p*d,this._w=c*u*d+h*p*g;break;case"ZXY":this._x=h*u*d-c*p*g,this._y=c*p*d+h*u*g,this._z=c*u*g+h*p*d,this._w=c*u*d-h*p*g;break;case"ZYX":this._x=h*u*d-c*p*g,this._y=c*p*d+h*u*g,this._z=c*u*g-h*p*d,this._w=c*u*d+h*p*g;break;case"YZX":this._x=h*u*d+c*p*g,this._y=c*p*d+h*u*g,this._z=c*u*g-h*p*d,this._w=c*u*d-h*p*g;break;case"XZY":this._x=h*u*d-c*p*g,this._y=c*p*d-h*u*g,this._z=c*u*g+h*p*d,this._w=c*u*d+h*p*g;break;default:sn("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,i=Math.sin(r);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],i=t[4],s=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=r+o+d;if(h>0){const p=.5/Math.sqrt(h+1);this._w=.25/p,this._x=(u-l)*p,this._y=(s-c)*p,this._z=(a-i)*p}else if(r>o&&r>d){const p=2*Math.sqrt(1+r-o-d);this._w=(u-l)/p,this._x=.25*p,this._y=(i+a)/p,this._z=(s+c)/p}else if(o>d){const p=2*Math.sqrt(1+o-r-d);this._w=(s-c)/p,this._x=(i+a)/p,this._y=.25*p,this._z=(l+u)/p}else{const p=2*Math.sqrt(1+d-r-o);this._w=(a-i)/p,this._x=(s+c)/p,this._y=(l+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(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=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ai(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,t/r);return this.slerp(e,i),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=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,i=e._y,s=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=r*u+a*o+i*c-s*l,this._y=i*u+a*l+s*o-r*c,this._z=s*u+a*c+r*l-i*o,this._w=a*u-r*o-i*l-s*c,this._onChangeCallback(),this}slerp(e,t){let r=e._x,i=e._y,s=e._z,a=e._w,o=this.dot(e);o<0&&(r=-r,i=-i,s=-s,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+r*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+r*t,this._y=this._y*l+i*t,this._z=this._z*l+s*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),r=Math.random(),i=Math.sqrt(1-r),s=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),s*Math.sin(t),s*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}}const FY=class FY{constructor(e=0,t=0,r=0){this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,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 new Error("THREE.Vector3: 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 new Error("THREE.Vector3: 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(Zse.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Zse.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[3]*r+s[6]*i,this.y=s[1]*t+s[4]*r+s[7]*i,this.z=s[2]*t+s[5]*r+s[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,i=this.z,s=e.elements,a=1/(s[3]*t+s[7]*r+s[11]*i+s[15]);return this.x=(s[0]*t+s[4]*r+s[8]*i+s[12])*a,this.y=(s[1]*t+s[5]*r+s[9]*i+s[13])*a,this.z=(s[2]*t+s[6]*r+s[10]*i+s[14])*a,this}applyQuaternion(e){const t=this.x,r=this.y,i=this.z,s=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*i-o*r),u=2*(o*t-s*i),d=2*(s*r-a*t);return this.x=t+l*c+a*d-o*u,this.y=r+l*u+o*c-s*d,this.z=i+l*d+s*u-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){const t=this.x,r=this.y,i=this.z,s=e.elements;return this.x=s[0]*t+s[4]*r+s[8]*i,this.y=s[1]*t+s[5]*r+s[9]*i,this.z=s[2]*t+s[6]*r+s[10]*i,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=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this.z=ai(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this.z=ai(this.z,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(ai(r,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,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,i=e.y,s=e.z,a=t.x,o=t.y,l=t.z;return this.x=i*l-s*o,this.y=s*a-r*l,this.z=r*o-i*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return Mj.copy(this).projectOnVector(e),this.sub(Mj)}reflect(e){return this.sub(Mj.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(ai(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return t*t+r*r+i*i}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,r){const i=Math.sin(t)*e;return this.x=i*Math.sin(r),this.y=Math.cos(t)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=i,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(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,r=Math.sqrt(1-t*t);return this.x=r*Math.cos(e),this.y=t,this.z=r*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};FY.prototype.isVector3=!0;let Fe=FY;const Mj=new Fe,Zse=new zo,BY=class BY{constructor(e,t,r,i,s,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,r,i,s,a,o,l,c)}set(e,t,r,i,s,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=i,u[2]=o,u[3]=t,u[4]=s,u[5]=l,u[6]=r,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const 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){const r=e.elements,i=t.elements,s=this.elements,a=r[0],o=r[3],l=r[6],c=r[1],u=r[4],d=r[7],h=r[2],p=r[5],g=r[8],x=i[0],_=i[3],y=i[6],M=i[1],C=i[4],k=i[7],B=i[2],U=i[5],z=i[8];return s[0]=a*x+o*M+l*B,s[3]=a*_+o*C+l*U,s[6]=a*y+o*k+l*z,s[1]=c*x+u*M+d*B,s[4]=c*_+u*C+d*U,s[7]=c*y+u*k+d*z,s[2]=h*x+p*M+g*B,s[5]=h*_+p*C+g*U,s[8]=h*y+p*k+g*z,this}multiplyScalar(e){const 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(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-r*s*u+r*o*l+i*s*c-i*a*l}invert(){const e=this.elements,t=e[0],r=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*s,p=c*s-a*l,g=t*d+r*h+i*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=d*x,e[1]=(i*c-u*r)*x,e[2]=(o*r-i*a)*x,e[3]=h*x,e[4]=(u*t-i*l)*x,e[5]=(i*s-o*t)*x,e[6]=p*x,e[7]=(r*l-c*t)*x,e[8]=(a*t-r*s)*x,this}transpose(){let e;const 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){const 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,r,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(r*l,r*c,-r*(l*a+c*o)+a+e,-i*c,i*l,-i*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return ji("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Cj.makeScale(e,t)),this}rotate(e){return ji("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Cj.makeRotation(-e)),this}translate(e,t){return ji("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Cj.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){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,r=e.elements;for(let i=0;i<9;i++)if(t[i]!==r[i])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}};BY.prototype.isMatrix3=!0;let ni=BY;const Cj=new ni,Qse=new ni().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Kse=new ni().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function _$e(){const n={enabled:!0,workingColorSpace:Rv,spaces:{},convert:function(i,s,a){return this.enabled===!1||s===a||!s||!a||(this.spaces[s].transfer===rr&&(i.r=_g(i.r),i.g=_g(i.g),i.b=_g(i.b)),this.spaces[s].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[s].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===rr&&(i.r=b_(i.r),i.g=b_(i.g),i.b=b_(i.b))),i},workingToColorSpace:function(i,s){return this.convert(i,this.workingColorSpace,s)},colorSpaceToWorking:function(i,s){return this.convert(i,s,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Rd?Lv:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,s=this.workingColorSpace){return i.fromArray(this.spaces[s].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,s,a){return i.copy(this.spaces[s].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,s){return ji("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return ji("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(i,s)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],r=[.3127,.329];return n.define({[Rv]:{primaries:e,whitePoint:r,transfer:Lv,toXYZ:Qse,fromXYZ:Kse,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:ic},outputColorSpaceConfig:{drawingBufferColorSpace:ic}},[ic]:{primaries:e,whitePoint:r,transfer:rr,toXYZ:Qse,fromXYZ:Kse,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:ic}}}),n}const Sr=_$e();function _g(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function b_(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let Ry;class H2e{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let r;if(e instanceof HTMLCanvasElement)r=e;else{Ry===void 0&&(Ry=aS("canvas")),Ry.width=e.width,Ry.height=e.height;const i=Ry.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=Ry}return r.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=aS("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),s=i.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Rj).x}get height(){return this.source.getSize(Rj).y}get depth(){return this.source.getSize(Rj).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(const t in e){const r=e[t];if(r===void 0){sn(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){sn(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&r&&i.isVector2&&r.isVector2||i&&r&&i.isVector3&&r.isVector3||i&&r&&i.isMatrix3&&r.isMatrix3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const r={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&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==KS)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Fg:e.x=e.x-Math.floor(e.x);break;case uc:e.x=e.x<0?0:1;break;case Bg:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Fg:e.y=e.y-Math.floor(e.y);break;case uc:e.y=e.y<0?0:1;break;case Bg:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-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++}}Aa.DEFAULT_IMAGE=null;Aa.DEFAULT_MAPPING=KS;Aa.DEFAULT_ANISOTROPY=1;const UY=class UY{constructor(e=0,t=0,r=0,i=1){this.x=e,this.y=t,this.z=r,this.w=i}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,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,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 new Error("THREE.Vector4: 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 new Error("THREE.Vector4: 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?e.w:1,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){const t=this.x,r=this.y,i=this.z,s=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*i+a[12]*s,this.y=a[1]*t+a[5]*r+a[9]*i+a[13]*s,this.z=a[2]*t+a[6]*r+a[10]*i+a[14]*s,this.w=a[3]*t+a[7]*r+a[11]*i+a[15]*s,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);const 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,r,i,s;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],p=l[5],g=l[9],x=l[2],_=l[6],y=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-x)<.01&&Math.abs(g-_)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+x)<.1&&Math.abs(g+_)<.1&&Math.abs(c+p+y-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const C=(c+1)/2,k=(p+1)/2,B=(y+1)/2,U=(u+h)/4,z=(d+x)/4,O=(g+_)/4;return C>k&&C>B?C<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(C),i=U/r,s=z/r):k>B?k<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(k),r=U/i,s=O/i):B<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(B),r=z/s,i=O/s),this.set(r,i,s,t),this}let M=Math.sqrt((_-g)*(_-g)+(d-x)*(d-x)+(h-u)*(h-u));return Math.abs(M)<.001&&(M=1),this.x=(_-g)/M,this.y=(d-x)/M,this.z=(h-u)/M,this.w=Math.acos((c+p+y-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}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.w=Math.min(this.w,e.w),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.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=ai(this.x,e.x,t.x),this.y=ai(this.y,e.y,t.y),this.z=ai(this.z,e.z,t.z),this.w=ai(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=ai(this.x,e,t),this.y=ai(this.y,e,t),this.z=ai(this.z,e,t),this.w=ai(this.w,e,t),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(ai(r,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};UY.prototype.isVector4=!0;let gr=UY;class mf extends zd{constructor(e=1,t=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ci,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},r),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=r.depth,this.scissor=new gr(0,0,e,t),this.scissorTest=!1,this.viewport=new gr(0,0,e,t),this.textures=[];const i={width:e,height:t,depth:r.depth},s=new Aa(i),a=r.count;for(let o=0;o1);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,r=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let r=0;r0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(r.geometries=o),l.length>0&&(r.materials=l),c.length>0&&(r.textures=c),u.length>0&&(r.images=u),d.length>0&&(r.shapes=d),h.length>0&&(r.skeletons=h),p.length>0&&(r.animations=p),g.length>0&&(r.nodes=g)}return r.object=i,r;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}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?e.pivot.clone():null,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 r=0;rp+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,r),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(i=t.getPose(e.targetRaySpace,r),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(k$e)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const r=new nd;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}const $2e={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},b1={h:0,s:0,l:0},PT={h:0,s:0,l:0};function kj(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Fn{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,r)}set(e,t,r){if(t===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,t,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ic){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Sr.colorSpaceToWorking(this,t),this}setRGB(e,t,r,i=Sr.workingColorSpace){return this.r=e,this.g=t,this.b=r,Sr.colorSpaceToWorking(this,i),this}setHSL(e,t,r,i=Sr.workingColorSpace){if(e=M$(e,1),t=ai(t,0,1),r=ai(r,0,1),t===0)this.r=this.g=this.b=r;else{const s=r<=.5?r*(1+t):r+t-r*t,a=2*r-s;this.r=kj(a,s,e+1/3),this.g=kj(a,s,e),this.b=kj(a,s,e-1/3)}return Sr.colorSpaceToWorking(this,i),this}setStyle(e,t=ic){function r(s){s!==void 0&&parseFloat(s)<1&&sn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return r(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:sn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(s,16),t);sn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ic){const r=$2e[e.toLowerCase()];return r!==void 0?this.setHex(r,t):sn("Color: Unknown color "+e),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=_g(e.r),this.g=_g(e.g),this.b=_g(e.b),this}copyLinearToSRGB(e){return this.r=b_(e.r),this.g=b_(e.g),this.b=b_(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ic){return Sr.workingToColorSpace(Vu.copy(this),e),Math.round(ai(Vu.r*255,0,255))*65536+Math.round(ai(Vu.g*255,0,255))*256+Math.round(ai(Vu.b*255,0,255))}getHexString(e=ic){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Sr.workingColorSpace){Sr.workingToColorSpace(Vu.copy(this),t);const r=Vu.r,i=Vu.g,s=Vu.b,a=Math.max(r,i,s),o=Math.min(r,i,s);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case r:l=(i-s)/d+(i0&&(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}}const A0=new Fe,Bm=new Fe,Ij=new Fe,Um=new Fe,Dy=new Fe,Oy=new Fe,aae=new Fe,Dj=new Fe,Oj=new Fe,jj=new Fe,Fj=new gr,Bj=new gr,Uj=new gr;class nh{constructor(e=new Fe,t=new Fe,r=new Fe){this.a=e,this.b=t,this.c=r}static getNormal(e,t,r,i){i.subVectors(r,t),A0.subVectors(e,t),i.cross(A0);const s=i.lengthSq();return s>0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(e,t,r,i,s){A0.subVectors(i,t),Bm.subVectors(r,t),Ij.subVectors(e,t);const a=A0.dot(A0),o=A0.dot(Bm),l=A0.dot(Ij),c=Bm.dot(Bm),u=Bm.dot(Ij),d=a*c-o*o;if(d===0)return s.set(0,0,0),null;const h=1/d,p=(c*l-o*u)*h,g=(a*u-o*l)*h;return s.set(1-p-g,g,p)}static containsPoint(e,t,r,i){return this.getBarycoord(e,t,r,i,Um)===null?!1:Um.x>=0&&Um.y>=0&&Um.x+Um.y<=1}static getInterpolation(e,t,r,i,s,a,o,l){return this.getBarycoord(e,t,r,i,Um)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Um.x),l.addScaledVector(a,Um.y),l.addScaledVector(o,Um.z),l)}static getInterpolatedAttribute(e,t,r,i,s,a){return Fj.setScalar(0),Bj.setScalar(0),Uj.setScalar(0),Fj.fromBufferAttribute(e,t),Bj.fromBufferAttribute(e,r),Uj.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(Fj,s.x),a.addScaledVector(Bj,s.y),a.addScaledVector(Uj,s.z),a}static isFrontFacing(e,t,r,i){return A0.subVectors(r,t),Bm.subVectors(e,t),A0.cross(Bm).dot(i)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,i){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,r,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,i),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 A0.subVectors(this.c,this.b),Bm.subVectors(this.a,this.b),A0.cross(Bm).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nh.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nh.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,r,i,s){return nh.getInterpolation(e,this.a,this.b,this.c,t,r,i,s)}containsPoint(e){return nh.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nh.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,i=this.b,s=this.c;let a,o;Dy.subVectors(i,r),Oy.subVectors(s,r),Dj.subVectors(e,r);const l=Dy.dot(Dj),c=Oy.dot(Dj);if(l<=0&&c<=0)return t.copy(r);Oj.subVectors(e,i);const u=Dy.dot(Oj),d=Oy.dot(Oj);if(u>=0&&d<=u)return t.copy(i);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(r).addScaledVector(Dy,a);jj.subVectors(e,s);const p=Dy.dot(jj),g=Oy.dot(jj);if(g>=0&&p<=g)return t.copy(s);const x=p*c-l*g;if(x<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(r).addScaledVector(Oy,o);const _=u*g-p*d;if(_<=0&&d-u>=0&&p-g>=0)return aae.subVectors(s,i),o=(d-u)/(d-u+(p-g)),t.copy(i).addScaledVector(aae,o);const y=1/(_+x+h);return a=x*y,o=h*y,t.copy(r).addScaledVector(Dy,a).addScaledVector(Oy,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class So{constructor(e=new Fe(1/0,1/0,1/0),t=new Fe(-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,r=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,x0),x0.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(_w),LT.subVectors(this.max,_w),jy.subVectors(e.a,_w),Fy.subVectors(e.b,_w),By.subVectors(e.c,_w),_1.subVectors(Fy,jy),w1.subVectors(By,Fy),C2.subVectors(jy,By);let t=[0,-_1.z,_1.y,0,-w1.z,w1.y,0,-C2.z,C2.y,_1.z,0,-_1.x,w1.z,0,-w1.x,C2.z,0,-C2.x,-_1.y,_1.x,0,-w1.y,w1.x,0,-C2.y,C2.x,0];return!zj(t,jy,Fy,By,LT)||(t=[1,0,0,0,1,0,0,0,1],!zj(t,jy,Fy,By,LT))?!1:(kT.crossVectors(_1,w1),t=[kT.x,kT.y,kT.z],zj(t,jy,Fy,By,LT))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,x0).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(x0).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:(zm[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),zm[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),zm[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),zm[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),zm[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),zm[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),zm[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),zm[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(zm),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}}const zm=[new Fe,new Fe,new Fe,new Fe,new Fe,new Fe,new Fe,new Fe],x0=new Fe,RT=new So,jy=new Fe,Fy=new Fe,By=new Fe,_1=new Fe,w1=new Fe,C2=new Fe,_w=new Fe,LT=new Fe,kT=new Fe,P2=new Fe;function zj(n,e,t,r,i){for(let s=0,a=n.length-3;s<=a;s+=3){P2.fromArray(n,s);const o=i.x*Math.abs(P2.x)+i.y*Math.abs(P2.y)+i.z*Math.abs(P2.z),l=e.dot(P2),c=t.dot(P2),u=r.dot(P2);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const eg=I$e();function I$e(){const n=new ArrayBuffer(4),e=new Float32Array(n),t=new Uint32Array(n),r=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(r[l]=0,r[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(r[l]=1024>>-c-14,r[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(r[l]=c+15<<10,r[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(r[l]=31744,r[l|256]=64512,i[l]=24,i[l|256]=24):(r[l]=31744,r[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,u=0;for(;!(c&8388608);)c<<=1,u-=8388608;c&=-8388609,u+=947912704,s[l]=c|u}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:e,uint32View:t,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function Kd(n){Math.abs(n)>65504&&sn("DataUtils.toHalfFloat(): Value out of range."),n=ai(n,-65504,65504),eg.floatView[0]=n;const e=eg.uint32View[0],t=e>>23&511;return eg.baseTable[t]+((e&8388607)>>eg.shiftTable[t])}function R5(n){const e=n>>10;return eg.uint32View[0]=eg.mantissaTable[eg.offsetTable[e]+(n&1023)]+eg.exponentTable[e],eg.floatView[0]}class D$e{static toHalfFloat(e){return Kd(e)}static fromHalfFloat(e){return R5(e)}}const Hl=new Fe,IT=new en;let O$e=0;class Gi extends zd{constructor(e,t,r=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:O$e++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r,this.usage=UA,this.updateRanges=[],this.gpuType=ea,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,r){e*=this.itemSize,r*=t.itemSize;for(let i=0,s=this.itemSize;ithis.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=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;ww.subVectors(e,this.center);const t=ww.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),i=(r-this.radius)*.5;this.center.addScaledVector(ww,i/r),this.radius+=i}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):(Vj.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ww.copy(e.center).add(Vj)),this.expandByPoint(ww.copy(e.center).sub(Vj))),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}}let q$e=0;const Ef=new ir,qj=new os,Uy=new Fe,Rh=new So,Sw=new So,kc=new Fe;class Pr extends zd{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:q$e++}),this.uuid=rf(),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={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(t$e(e)?jP:OP)(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,r=0){this.groups.push({start:e,count:t,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const s=new ni().getNormalMatrix(e);r.applyNormalMatrix(s),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return Ef.makeRotationFromQuaternion(e),this.applyMatrix4(Ef),this}rotateX(e){return Ef.makeRotationX(e),this.applyMatrix4(Ef),this}rotateY(e){return Ef.makeRotationY(e),this.applyMatrix4(Ef),this}rotateZ(e){return Ef.makeRotationZ(e),this.applyMatrix4(Ef),this}translate(e,t,r){return Ef.makeTranslation(e,t,r),this.applyMatrix4(Ef),this}scale(e,t,r){return Ef.makeScale(e,t,r),this.applyMatrix4(Ef),this}lookAt(e){return qj.lookAt(e),qj.updateMatrix(),this.applyMatrix4(qj.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Uy).negate(),this.translate(Uy.x,Uy.y,Uy.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const r=[];for(let i=0,s=e.length;it.count&&sn("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 So);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){on("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Fe(-1/0,-1/0,-1/0),new Fe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let r=0,i=t.length;r0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const l in r){const c=r[l];e.data.attributes[l]=c.toJSON(e.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(i[l]=u,s=!0)}s&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const 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;const t={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone());const i=e.attributes;for(const c in i){const u=i[c];this.setAttribute(c,u.clone(t))}const s=e.morphAttributes;for(const c in s){const u=[],d=s[c];for(let h=0,p=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const r=e[t];if(r===void 0){sn(`Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];if(i===void 0){sn(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(r):i&&i.isVector2&&r&&r.isVector2||i&&i.isEuler&&r&&r.isEuler||i&&i.isVector3&&r&&r.isVector3?i.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(r.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(r.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(r.dispersion=this.dispersion),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(r.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(r.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(r.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapRotation!==void 0&&(r.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==ac&&(r.blending=this.blending),this.side!==id&&(r.side=this.side),this.vertexColors===!0&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=!0),this.blendSrc!==rv&&(r.blendSrc=this.blendSrc),this.blendDst!==iv&&(r.blendDst=this.blendDst),this.blendEquation!==Fc&&(r.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(r.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(r.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(r.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(r.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(r.blendAlpha=this.blendAlpha),this.depthFunc!==jg&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==HM&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==q1&&(r.stencilFail=this.stencilFail),this.stencilZFail!==q1&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==q1&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.allowOverride===!1&&(r.allowOverride=!1),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(e.images);s.length>0&&(r.textures=s),a.length>0&&(r.images=a)}return r}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Fn().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let r=e.normalScale;Array.isArray(r)===!1&&(r=[r,r]),this.normalScale=new en().fromArray(r)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new en().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}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;const t=e.clippingPlanes;let r=null;if(t!==null){const i=t.length;r=new Array(i);for(let s=0;s!==i;++s)r[s]=t[s].clone()}return this.clippingPlanes=r,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++}}class FP extends fc{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Fn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let zy;const Tw=new Fe,Vy=new Fe,qy=new Fe,Gy=new en,Ew=new en,W2e=new ir,DT=new Fe,Nw=new Fe,OT=new Fe,oae=new en,Gj=new en,lae=new en;class X2e extends os{constructor(e=new FP){if(super(),this.isSprite=!0,this.type="Sprite",zy===void 0){zy=new Pr;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),r=new U3(t,5);zy.setIndex([0,1,2,0,2,3]),zy.setAttribute("position",new kl(r,3,0,!1)),zy.setAttribute("uv",new kl(r,2,3,!1))}this.geometry=zy,this.material=e,this.center=new en(.5,.5),this.count=1}raycast(e,t){e.camera===null&&on('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Vy.setFromMatrixScale(this.matrixWorld),W2e.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),qy.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Vy.multiplyScalar(-qy.z);const r=this.material.rotation;let i,s;r!==0&&(s=Math.cos(r),i=Math.sin(r));const a=this.center;jT(DT.set(-.5,-.5,0),qy,a,Vy,i,s),jT(Nw.set(.5,-.5,0),qy,a,Vy,i,s),jT(OT.set(.5,.5,0),qy,a,Vy,i,s),oae.set(0,0),Gj.set(1,0),lae.set(1,1);let o=e.ray.intersectTriangle(DT,Nw,OT,!1,Tw);if(o===null&&(jT(Nw.set(-.5,.5,0),qy,a,Vy,i,s),Gj.set(0,1),o=e.ray.intersectTriangle(DT,OT,Nw,!1,Tw),o===null))return;const l=e.ray.origin.distanceTo(Tw);le.far||t.push({distance:l,point:Tw.clone(),uv:nh.getInterpolation(Tw,DT,Nw,OT,oae,Gj,lae,new en),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function jT(n,e,t,r,i,s){Gy.subVectors(n,t).addScalar(.5).multiply(r),i!==void 0?(Ew.x=s*Gy.x-i*Gy.y,Ew.y=i*Gy.x+s*Gy.y):Ew.copy(Gy),n.copy(e),n.x+=Ew.x,n.y+=Ew.y,n.applyMatrix4(W2e)}const FT=new Fe,cae=new Fe;class Y2e extends os{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let r=0,i=t.length;r0){let r,i;for(r=1,i=t.length;r0){FT.setFromMatrixPosition(this.matrixWorld);const i=e.ray.origin.distanceTo(FT);this.getObjectForDistance(i).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){FT.setFromMatrixPosition(e.matrixWorld),cae.setFromMatrixPosition(this.matrixWorld);const r=FT.distanceTo(cae)/e.zoom;t[0].object.visible=!0;let i,s;for(i=1,s=t.length;i=a)t[i-1].object.visible=!1,t[i].object.visible=!0;else break}for(this._currentLevel=i-1;i0)if(d=a*l-o,h=a*o-l,g=s*u,d>=0)if(h>=-g)if(h<=g){const x=1/u;d*=x,h*=x,p=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=s,d=Math.max(0,-(a*h+o)),p=-d*d+h*(h+2*l)+c;else h=-s,d=Math.max(0,-(a*h+o)),p=-d*d+h*(h+2*l)+c;else h<=-g?(d=Math.max(0,-(-a*s+o)),h=d>0?-s:Math.min(Math.max(-s,-l),s),p=-d*d+h*(h+2*l)+c):h<=g?(d=0,h=Math.min(Math.max(-s,-l),s),p=h*(h+2*l)+c):(d=Math.max(0,-(a*s+o)),h=d>0?s:Math.min(Math.max(-s,-l),s),p=-d*d+h*(h+2*l)+c);else h=a>0?-s:s,d=Math.max(0,-(a*h+o)),p=-d*d+h*(h+2*l)+c;return r&&r.copy(this.origin).addScaledVector(this.direction,d),i&&i.copy(Hj).addScaledVector(BT,h),p}intersectSphere(e,t){Vm.subVectors(e.center,this.origin);const r=Vm.dot(this.direction),i=Vm.dot(Vm)-r*r,s=e.radius*e.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=r-a,l=r+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,i,s,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(r=(e.min.x-h.x)*c,i=(e.max.x-h.x)*c):(r=(e.max.x-h.x)*c,i=(e.min.x-h.x)*c),u>=0?(s=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(s=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),r>a||s>i||((s>r||isNaN(r))&&(r=s),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),r>l||o>i)||((o>r||r!==r)&&(r=o),(l=0?r:i,t)}intersectsBox(e){return this.intersectBox(e,Vm)!==null}intersectTriangle(e,t,r,i,s){$j.subVectors(t,e),UT.subVectors(r,e),Wj.crossVectors($j,UT);let a=this.direction.dot(Wj),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;S1.subVectors(this.origin,e);const l=o*this.direction.dot(UT.crossVectors(S1,UT));if(l<0)return null;const c=o*this.direction.dot($j.cross(S1));if(c<0||l+c>a)return null;const u=-o*S1.dot(Wj);return u<0?null:this.at(u/a,s)}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)}}class oc extends fc{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Fn(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 gh,this.combine=k3,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}}const uae=new ir,R2=new r2,zT=new Vo,dae=new Fe,VT=new Fe,qT=new Fe,GT=new Fe,Xj=new Fe,HT=new Fe,hae=new Fe,$T=new Fe;class ui extends os{constructor(e=new Pr,t=new oc){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(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s(e.far-e.near)**2))&&(uae.copy(s).invert(),R2.copy(e.ray).applyMatrix4(uae),!(r.boundingBox!==null&&R2.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,t,R2)))}_computeIntersections(e,t,r){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,d=s.attributes.normal,h=s.groups,p=s.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=h.length;gt.far?null:{distance:c,point:$T.clone(),object:n}}function WT(n,e,t,r,i,s,a,o,l,c){n.getVertexPosition(o,VT),n.getVertexPosition(l,qT),n.getVertexPosition(c,GT);const u=H$e(n,e,t,r,VT,qT,GT,hae);if(u){const d=new Fe;nh.getBarycoord(hae,VT,qT,GT,d),i&&(u.uv=nh.getInterpolatedAttribute(i,o,l,c,d,new en)),s&&(u.uv1=nh.getInterpolatedAttribute(s,o,l,c,d,new en)),a&&(u.normal=nh.getInterpolatedAttribute(a,o,l,c,d,new Fe),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new Fe,materialIndex:0};nh.getNormal(VT,qT,GT,h.normal),u.face=h,u.barycoord=d}return u}const Mw=new gr,fae=new gr,pae=new gr,$$e=new gr,mae=new ir,XT=new Fe,Yj=new Vo,gae=new ir,Zj=new r2;class Z2e extends ui{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=qz,this.bindMatrix=new ir,this.bindMatrixInverse=new ir,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new So),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let r=0;r1)?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<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){const r=t||Z$e.getNormalMatrix(e),i=this.coplanarPoint(Qj).applyMatrix4(e),s=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(s),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)}}const L2=new Vo,Q$e=new en(.5,.5),ZT=new Fe;class Vg{constructor(e=new Bf,t=new Bf,r=new Bf,i=new Bf,s=new Bf,a=new Bf){this.planes=[e,t,r,i,s,a]}set(e,t,r,i,s,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(r),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e,t=gu,r=!1){const i=this.planes,s=e.elements,a=s[0],o=s[1],l=s[2],c=s[3],u=s[4],d=s[5],h=s[6],p=s[7],g=s[8],x=s[9],_=s[10],y=s[11],M=s[12],C=s[13],k=s[14],B=s[15];if(i[0].setComponents(c-a,p-u,y-g,B-M).normalize(),i[1].setComponents(c+a,p+u,y+g,B+M).normalize(),i[2].setComponents(c+o,p+d,y+x,B+C).normalize(),i[3].setComponents(c-o,p-d,y-x,B-C).normalize(),r)i[4].setComponents(l,h,_,k).normalize(),i[5].setComponents(c-l,p-h,y-_,B-k).normalize();else if(i[4].setComponents(c-l,p-h,y-_,B-k).normalize(),t===gu)i[5].setComponents(c+l,p+h,y+_,B+k).normalize();else if(t===mh)i[5].setComponents(l,h,_,k).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),L2.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),L2.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(L2)}intersectsSprite(e){L2.center.set(0,0,0);const t=Q$e.distanceTo(e.center);return L2.radius=.7071067811865476+t,L2.applyMatrix4(e.matrixWorld),this.intersectsSphere(L2)}intersectsSphere(e){const t=this.planes,r=e.center,i=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(r)0?e.max.x:e.min.x,ZT.y=i.normal.y>0?e.max.y:e.min.y,ZT.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ZT)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const yae=new ir;class r6{constructor(){this.coordinateSystem=gu,this._frustums=[],this._count=0}setFromArrayCamera(e){const t=e.cameras,r=this._frustums;for(let i=0;i=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});const o=s[this.index];a.push(o),this.index++,o.start=e,o.count=t,o.z=r,o.index=i}reset(){this.list.length=0,this.index=0}}const Zd=new ir,tWe=new Fn(1,1,1),nWe=new Vg,rWe=new r6,QT=new So,k2=new Vo,Rw=new Fe,bae=new Fe,iWe=new Fe,Jj=new eWe,qu=new ui,KT=[];function sWe(n,e,t=0){const r=e.itemSize;if(n.isInterleavedBufferAttribute||n.array.constructor!==e.array.constructor){const i=n.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new Gi(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const r in t.attributes){if(!e.hasAttribute(r))throw new Error(`THREE.BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),s=t.getAttribute(r);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new So);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let r=0,i=t.length;r=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const r={visible:!0,active:!0,geometryIndex:e};let i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Kj),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=r):(i=this._instanceInfo.length,this._instanceInfo.push(r));const s=this._matricesTexture;Zd.identity().toArray(s.image.data,i*16),s.needsUpdate=!0;const a=this._colorsTexture;return a&&(tWe.toArray(a.image.data,i*4),a.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(e,t=-1,r=-1){this._initializeGeometry(e),this._validateGeometry(e);const i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=r===-1?a.count:r),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let l;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Kj),l=this._availableGeometryIds.shift(),s[l]=i):(l=this._geometryCount,this._geometryCount++,s.push(i)),this.setGeometryAt(l,e),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,l}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const r=this.geometry,i=r.getIndex()!==null,s=r.getIndex(),a=t.getIndex(),o=this._geometryInfo[e];if(i&&a.count>o.reservedIndexCount||t.attributes.position.count>o.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.reservedVertexCount;o.vertexCount=t.getAttribute("position").count;for(const u in r.attributes){const d=t.getAttribute(u),h=r.getAttribute(u);sWe(d,h,l);const p=d.itemSize;for(let g=d.count,x=c;g=t.length||t[e].active===!1)return this;const r=this._instanceInfo;for(let i=0,s=r.length;io).sort((a,o)=>r[a].vertexStart-r[o].vertexStart),s=this.geometry;for(let a=0,o=r.length;a=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingBox===null){const s=new So,a=r.index,o=r.attributes.position;for(let l=i.start,c=i.start+i.count;l=this._geometryCount)return null;const r=this.geometry,i=this._geometryInfo[e];if(i.boundingSphere===null){const s=new Vo;this.getBoundingBoxAt(e,QT),QT.getCenter(s.center);const a=r.index,o=r.attributes.position;let l=0;for(let c=i.start,u=i.start+i.count;co.active);if(Math.max(...r.map(o=>o.vertexStart+o.reservedVertexCount))>e)throw new Error(`THREE.BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...r.map(l=>l.indexStart+l.reservedIndexCount))>t)throw new Error(`THREE.BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Pr,this._initializeGeometry(s));const a=this.geometry;s.index&&I2(s.index.array,a.index.array);for(const o in s.attributes)I2(s.attributes[o].array,a.attributes[o].array)}raycast(e,t){const r=this._instanceInfo,i=this._geometryInfo,s=this.matrixWorld,a=this.geometry;qu.material=this.material,qu.geometry.index=a.index,qu.geometry.attributes=a.attributes,qu.geometry.boundingBox===null&&(qu.geometry.boundingBox=new So),qu.geometry.boundingSphere===null&&(qu.geometry.boundingSphere=new Vo);for(let o=0,l=r.length;o({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,r,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex();let o=a===null?1:a.array.BYTES_PER_ELEMENT,l=1;s.wireframe&&(l=2,o=i.attributes.position.count>65535?4:2);const c=this._instanceInfo,u=this._multiDrawStarts,d=this._multiDrawCounts,h=this._geometryInfo,p=this.perObjectFrustumCulled,g=this._indirectTexture,x=g.image.data,_=r.isArrayCamera?rWe:nWe;p&&(r.isArrayCamera?_.setFromArrayCamera(r):(Zd.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),_.setFromProjectionMatrix(Zd,r.coordinateSystem,r.reversedDepth)));let y=0;if(this.sortObjects){Zd.copy(this.matrixWorld).invert(),Rw.setFromMatrixPosition(r.matrixWorld).applyMatrix4(Zd),bae.set(0,0,-1).transformDirection(r.matrixWorld).transformDirection(Zd);for(let k=0,B=c.length;k0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;sr)return;eF.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(eF);if(!(ce.far))return{distance:c,point:wae.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Sae=new Fe,Tae=new Fe;class o0 extends K0{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,r=[];for(let i=0,s=t.count;i0){const i=t[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class exe extends Aa{constructor(e,t,r,i,s=Ci,a=Ci,o,l,c){super(e,t,r,i,s,a,o,l,c),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const u=this;function d(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(d))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class aWe extends exe{constructor(e,t,r,i,s,a,o,l){super({},e,t,r,i,s,a,o,l),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class UP extends Aa{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Ss,this.minFilter=Ss,this.generateMipmaps=!1,this.needsUpdate=!0}}class zP extends Aa{constructor(e,t,r,i,s,a,o,l,c,u,d,h){super(null,a,o,l,c,u,i,s,d,h),this.isCompressedTexture=!0,this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class oWe extends zP{constructor(e,t,r,i,s,a){super(e,t,r,s,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=uc,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class lWe extends zP{constructor(e,t,r){super(void 0,e[0].width,e[0].height,t,r,ph),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class r1 extends Aa{constructor(e=[],t=ph,r,i,s,a,o,l,c,u){super(e,t,r,i,s,a,o,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class cWe extends Aa{constructor(e,t,r,i,s,a,o,l,c){super(e,t,r,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class uWe extends Aa{constructor(e,t,r,i,s,a,o,l,c){super(e,t,r,i,s,a,o,l,c),this.isHTMLTexture=!0,this.generateMipmaps=!1,this.needsUpdate=!0;const u=e?e.parentNode:null;u!==null&&"requestPaint"in u&&(u.onpaint=()=>{this.needsUpdate=!0},u.requestPaint())}dispose(){const e=this.image?this.image.parentNode:null;e!==null&&"onpaint"in e&&(e.onpaint=null),super.dispose()}}class zc extends Aa{constructor(e,t,r=xs,i,s,a,o=Ss,l=Ss,c,u=hc,d=1){if(u!==hc&&u!==mu)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const h={width:e,height:t,depth:d};super(h,i,s,a,o,l,u,r,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new lA(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class L$ extends zc{constructor(e,t=xs,r=ph,i,s,a=Ss,o=Ss,l,c=hc){const u={width:e,height:e,depth:1},d=[u,u,u,u,u,u];super(e,e,t,r,i,s,a,o,l,c),this.image=d,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class k$ extends Aa{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Em extends Pr{constructor(e=1,t=1,r=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],u=[],d=[];let h=0,p=0;g("z","y","x",-1,-1,r,t,e,a,s,0),g("z","y","x",1,-1,r,t,-e,a,s,1),g("x","z","y",1,1,e,r,t,i,a,2),g("x","z","y",1,-1,e,r,-t,i,a,3),g("x","y","z",1,-1,e,t,r,i,s,4),g("x","y","z",-1,-1,e,t,-r,i,s,5),this.setIndex(l),this.setAttribute("position",new tr(c,3)),this.setAttribute("normal",new tr(u,3)),this.setAttribute("uv",new tr(d,2));function g(x,_,y,M,C,k,B,U,z,O,V){const $=k/z,G=B/O,H=k/2,K=B/2,W=U/2,J=z+1,ie=O+1;let ae=0,Q=0;const re=new Fe;for(let oe=0;oe0?1:-1,u.push(re.x,re.y,re.z),d.push(ee/z),d.push(1-oe/O),ae+=1}}for(let oe=0;oe0){const V=(M-1)*x;for(let $=0;$0&&C(!0),t>0&&C(!1)),this.setIndex(u),this.setAttribute("position",new tr(d,3)),this.setAttribute("normal",new tr(h,3)),this.setAttribute("uv",new tr(p,2));function M(){const k=new Fe,B=new Fe;let U=0;const z=(t-e)/r;for(let O=0;O<=s;O++){const V=[],$=O/s,G=$*(t-e)+e;for(let H=0;H<=i;H++){const K=H/i,W=K*l+o,J=Math.sin(W),ie=Math.cos(W);B.x=G*J,B.y=-$*r+_,B.z=G*ie,d.push(B.x,B.y,B.z),k.set(J,z,ie).normalize(),h.push(k.x,k.y,k.z),p.push(K,1-$),V.push(g++)}x.push(V)}for(let O=0;O0||V!==0)&&(u.push($,G,K),U+=3),(t>0||V!==s-1)&&(u.push(G,H,K),U+=3)}c.addGroup(y,U,0),y+=U}function C(k){const B=g,U=new en,z=new Fe;let O=0;const V=k===!0?e:t,$=k===!0?1:-1;for(let H=1;H<=i;H++)d.push(0,_*$,0),h.push(0,$,0),p.push(.5,.5),g++;const G=g;for(let H=0;H<=i;H++){const W=H/i*l+o,J=Math.cos(W),ie=Math.sin(W);z.x=V*ie,z.y=_*$,z.z=V*J,d.push(z.x,z.y,z.z),h.push(0,$,0),U.x=J*.5+.5,U.y=ie*.5*$+.5,p.push(U.x,U.y),g++}for(let H=0;H.9&&z<.1&&(C<.2&&(a[M+0]+=1),k<.2&&(a[M+2]+=1),B<.2&&(a[M+4]+=1))}}function h(M){s.push(M.x,M.y,M.z)}function p(M,C){const k=M*3;C.x=e[k+0],C.y=e[k+1],C.z=e[k+2]}function g(){const M=new Fe,C=new Fe,k=new Fe,B=new Fe,U=new en,z=new en,O=new en;for(let V=0,$=0;V0)l=i-1;else{l=i;break}if(i=l,r[i]===a)return i/(s-1);const u=r[i],h=r[i+1]-u,p=(a-u)/h;return(i+p)/(s-1)}getTangent(e,t){let i=e-1e-4,s=e+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=t||(a.isVector2?new en:new Fe);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t=!1){const r=new Fe,i=[],s=[],a=[],o=new Fe,l=new ir;for(let p=0;p<=e;p++){const g=p/e;i[p]=this.getTangentAt(g,new Fe)}s[0]=new Fe,a[0]=new Fe;let c=Number.MAX_VALUE;const u=Math.abs(i[0].x),d=Math.abs(i[0].y),h=Math.abs(i[0].z);u<=c&&(c=u,r.set(1,0,0)),d<=c&&(c=d,r.set(0,1,0)),h<=c&&r.set(0,0,1),o.crossVectors(i[0],r).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let p=1;p<=e;p++){if(s[p]=s[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(i[p-1],i[p]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(ai(i[p-1].dot(i[p]),-1,1));s[p].applyMatrix4(l.makeRotationAxis(o,g))}a[p].crossVectors(i[p],s[p])}if(t===!0){let p=Math.acos(ai(s[0].dot(s[e]),-1,1));p/=e,i[0].dot(o.crossVectors(s[0],s[e]))>0&&(p=-p);for(let g=1;g<=e;g++)s[g].applyMatrix4(l.makeRotationAxis(i[g],p*g)),a[g].crossVectors(i[g],s[g])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class GP extends l0{constructor(e=0,t=0,r=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new en){const r=t,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,u;this.closed||o>0?c=i[(o-1)%s]:(Cae.subVectors(i[0],i[1]).add(i[0]),c=Cae);const d=i[o%s],h=i[(o+1)%s];if(this.closed||o+2i.length-2?i.length-1:a+1],d=i[a>i.length-3?i.length-1:a+2];return r.set(Pae(o,l.x,c.x,u.x,d.x),Pae(o,l.y,c.y,u.y,d.y)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t=r){const a=i[s]-r,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}s++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let r=0,i=this.curves.length;r1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,r=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class a6 extends oS{constructor(e){super(e),this.uuid=rf(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let r=0,i=this.holes.length;r80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=p),g>d&&(d=g)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return lS(s,a,t,o,l,c,0),a}function axe(n,e,t,r,i){let s;if(i===IWe(n,e,t,r)>0)for(let a=e;a=e;a-=r)s=Rae(a/r|0,n[a],n[a+1],s);return s&&i3(s,s.next)&&(uS(s),s=s.next),s}function Iv(n,e){if(!n)return n;e||(e=n);let t=n,r;do if(r=!1,!t.steiner&&(i3(t,t.next)||Bo(t.prev,t,t.next)===0)){if(uS(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function lS(n,e,t,r,i,s,a){if(!n)return;!a&&s&&MWe(n,r,i,s);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(s?yWe(n,r,i,s):vWe(n)){e.push(l.i,n.i,c.i),uS(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=bWe(Iv(n),e),lS(n,e,t,r,i,s,2)):a===2&&_We(n,e,t,r,i,s):lS(Iv(n),e,t,r,i,s,1);break}}}function vWe(n){const e=n.prev,t=n,r=n.next;if(Bo(e,t,r)>=0)return!1;const i=e.x,s=t.x,a=r.x,o=e.y,l=t.y,c=r.y,u=Math.min(i,s,a),d=Math.min(o,l,c),h=Math.max(i,s,a),p=Math.max(o,l,c);let g=r.next;for(;g!==e;){if(g.x>=u&&g.x<=h&&g.y>=d&&g.y<=p&&L5(i,o,s,l,a,c,g.x,g.y)&&Bo(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function yWe(n,e,t,r){const i=n.prev,s=n,a=n.next;if(Bo(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,u=i.y,d=s.y,h=a.y,p=Math.min(o,l,c),g=Math.min(u,d,h),x=Math.max(o,l,c),_=Math.max(u,d,h),y=Xz(p,g,e,t,r),M=Xz(x,_,e,t,r);let C=n.prevZ,k=n.nextZ;for(;C&&C.z>=y&&k&&k.z<=M;){if(C.x>=p&&C.x<=x&&C.y>=g&&C.y<=_&&C!==i&&C!==a&&L5(o,u,l,d,c,h,C.x,C.y)&&Bo(C.prev,C,C.next)>=0||(C=C.prevZ,k.x>=p&&k.x<=x&&k.y>=g&&k.y<=_&&k!==i&&k!==a&&L5(o,u,l,d,c,h,k.x,k.y)&&Bo(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;C&&C.z>=y;){if(C.x>=p&&C.x<=x&&C.y>=g&&C.y<=_&&C!==i&&C!==a&&L5(o,u,l,d,c,h,C.x,C.y)&&Bo(C.prev,C,C.next)>=0)return!1;C=C.prevZ}for(;k&&k.z<=M;){if(k.x>=p&&k.x<=x&&k.y>=g&&k.y<=_&&k!==i&&k!==a&&L5(o,u,l,d,c,h,k.x,k.y)&&Bo(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function bWe(n,e){let t=n;do{const r=t.prev,i=t.next.next;!i3(r,i)&&lxe(r,t,t.next,i)&&cS(r,i)&&cS(i,r)&&(e.push(r.i,t.i,i.i),uS(t),uS(t.next),t=n=i),t=t.next}while(t!==n);return Iv(t)}function _We(n,e,t,r,i,s){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&RWe(a,o)){let l=cxe(a,o);a=Iv(a,a.next),l=Iv(l,l.next),lS(a,e,t,r,i,s,0),lS(l,e,t,r,i,s,0);return}o=o.next}a=a.next}while(a!==n)}function wWe(n,e,t,r){const i=[];for(let s=0,a=e.length;s=t.next.y&&t.next.y!==t.y){const d=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=r&&d>s&&(s=d,a=t.x=t.x&&t.x>=l&&r!==t.x&&oxe(ia.x||t.x===a.x&&NWe(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function NWe(n,e){return Bo(n.prev,n,e.prev)<0&&Bo(e.next,n,n.next)<0}function MWe(n,e,t,r){let i=n;do i.z===0&&(i.z=Xz(i.x,i.y,e,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==n);i.prevZ.nextZ=null,i.prevZ=null,CWe(i)}function CWe(n){let e,t=1;do{let r=n,i;n=null;let s=null;for(e=0;r;){e++;let a=r,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||r.z<=a.z)?(i=r,r=r.nextZ,o--):(i=a,a=a.nextZ,l--),s?s.nextZ=i:n=i,i.prevZ=s,s=i;r=a}s.nextZ=null,t*=2}while(e>1);return n}function Xz(n,e,t,r,i){return n=(n-t)*i|0,e=(e-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function PWe(n){let e=n,t=n;do(e.x=(n-a)*(s-o)&&(n-a)*(r-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(r-o)}function L5(n,e,t,r,i,s,a,o){return!(n===a&&e===o)&&oxe(n,e,t,r,i,s,a,o)}function RWe(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!LWe(n,e)&&(cS(n,e)&&cS(e,n)&&kWe(n,e)&&(Bo(n.prev,n,e.prev)||Bo(n,e.prev,e))||i3(n,e)&&Bo(n.prev,n,n.next)>0&&Bo(e.prev,e,e.next)>0)}function Bo(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function i3(n,e){return n.x===e.x&&n.y===e.y}function lxe(n,e,t,r){const i=o8(Bo(n,e,t)),s=o8(Bo(n,e,r)),a=o8(Bo(t,r,n)),o=o8(Bo(t,r,e));return!!(i!==s&&a!==o||i===0&&a8(n,t,e)||s===0&&a8(n,r,e)||a===0&&a8(t,n,r)||o===0&&a8(t,e,r))}function a8(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function o8(n){return n>0?1:n<0?-1:0}function LWe(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&lxe(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function cS(n,e){return Bo(n.prev,n,n.next)<0?Bo(n,e,n.next)>=0&&Bo(n,n.prev,e)>=0:Bo(n,e,n.prev)<0||Bo(n,n.next,e)<0}function kWe(n,e){let t=n,r=!1;const i=(n.x+e.x)/2,s=(n.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&i<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==n);return r}function cxe(n,e){const t=Yz(n.i,n.x,n.y),r=Yz(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function Rae(n,e,t,r){const i=Yz(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function uS(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function Yz(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function IWe(n,e,t,r){let i=0;for(let s=e,a=t-r;s2&&n[e-1].equals(n[0])&&n.pop()}function kae(n,e){for(let t=0;tNumber.EPSILON){const De=Math.sqrt(_t),ue=Math.sqrt(Ht*Ht+Se*Se),Ve=Ce.x-st/De,We=Ce.y+Lt/De,ct=lt.x-Se/ue,vt=lt.y+Ht/ue,Ut=((ct-Ve)*Se-(vt-We)*Ht)/(Lt*Se-st*Ht);ft=Ve+Lt*Ut-ht.x,et=We+st*Ut-ht.y;const dt=ft*ft+et*et;if(dt<=2)return new en(ft,et);At=Math.sqrt(dt/2)}else{let De=!1;Lt>Number.EPSILON?Ht>Number.EPSILON&&(De=!0):Lt<-Number.EPSILON?Ht<-Number.EPSILON&&(De=!0):Math.sign(st)===Math.sign(Se)&&(De=!0),De?(ft=-st,et=Lt,At=Math.sqrt(_t)):(ft=Lt,et=st,At=Math.sqrt(_t/2))}return new en(ft/At,et/At)}const re=[];for(let ht=0,Ce=J.length,lt=Ce-1,ft=ht+1;ht=0;ht--){const Ce=ht/_,lt=p*Math.cos(Ce*Math.PI/2),ft=g*Math.sin(Ce*Math.PI/2)+x;for(let et=0,At=J.length;et=0;){const ft=lt;let et=lt-1;et<0&&(et=ht.length-1);for(let At=0,Lt=u+_*2;At0)&&p.push(C,k,U),(y!==r-1||l0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const r={};for(const i in this.extensions)this.extensions[i]===!0&&(r[i]=!0);return Object.keys(r).length>0&&(t.extensions=r),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const r in e.uniforms){const i=e.uniforms[r];switch(this.uniforms[r]={},i.type){case"t":this.uniforms[r].value=t[i.value]||null;break;case"c":this.uniforms[r].value=new Fn().setHex(i.value);break;case"v2":this.uniforms[r].value=new en().fromArray(i.value);break;case"v3":this.uniforms[r].value=new Fe().fromArray(i.value);break;case"v4":this.uniforms[r].value=new gr().fromArray(i.value);break;case"m3":this.uniforms[r].value=new ni().fromArray(i.value);break;case"m4":this.uniforms[r].value=new ir().fromArray(i.value);break;default:this.uniforms[r].value=i.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const r in e.extensions)this.extensions[r]=e.extensions[r];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class V$ extends Dl{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class JP extends fc{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Fn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xf,this.normalScale=new en(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new gh,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class q$ extends JP{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new en(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ai(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Fn(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Fn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Fn(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class eR extends fc{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Fn(16777215),this.specular=new Fn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xf,this.normalScale=new en(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new gh,this.combine=k3,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,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.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class G$ extends fc{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Fn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xf,this.normalScale=new en(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class H$ extends fc{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xf,this.normalScale=new en(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class op extends fc{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Fn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Fn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xf,this.normalScale=new en(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new gh,this.combine=k3,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,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.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,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.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class tR extends fc{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=E2e,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}}class nR extends fc{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}}class $$ extends fc{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Fn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Xf,this.normalScale=new en(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class W$ extends Ac{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Tx(n,e){return!n||n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function dxe(n){function e(i,s){return n[i]-n[s]}const t=n.length,r=new Array(t);for(let i=0;i!==t;++i)r[i]=i;return r.sort(e),r}function Zz(n,e,t){const r=n.length,i=new n.constructor(r);for(let s=0,a=0;a!==r;++s){const o=t[s]*e;for(let l=0;l!==e;++l)i[a++]=n[o+l]}return i}function hxe(n,e,t,r){let i=1,s=n[0];for(;s!==void 0&&s[r]===void 0;)s=n[i++];if(s===void 0)return;let a=s[r];if(a!==void 0)if(Array.isArray(a))do a=s[r],a!==void 0&&(e.push(s.time),t.push(...a)),s=n[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[r],a!==void 0&&(e.push(s.time),a.toArray(t,t.length)),s=n[i++];while(s!==void 0);else do a=s[r],a!==void 0&&(e.push(s.time),t.push(a)),s=n[i++];while(s!==void 0)}function VWe(n,e,t,r,i=30){const s=n.clone();s.name=e;const a=[];for(let l=0;l=r)){d.push(c.times[p]);for(let x=0;xs.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l=o.times[g]){const y=g*d+u,M=y+d-u;x=o.values.slice(y,M)}else{const y=o.createInterpolant(),M=u,C=d-u;y.evaluate(s),x=y.resultBuffer.slice(M,C)}l==="quaternion"&&new zo().fromArray(x).normalize().conjugate().toArray(x);const _=c.times.length;for(let y=0;y<_;++y){const M=y*p+h;if(l==="quaternion")zo.multiplyQuaternionsFlat(c.values,M,x,0,c.values,M);else{const C=p-h*2;for(let k=0;k=s)){const o=t[1];e=s)break t}a=r,r=0;break n}break e}for(;r>>1;et;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=r.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(on("KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,i=this.values,s=r.length;s===0&&(on("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let o=0;o!==s;o++){const l=r[o];if(typeof l=="number"&&isNaN(l)){on("KeyframeTrack: Time is not a valid number.",this,o,l),e=!1;break}if(a!==null&&a>l){on("KeyframeTrack: Out of order keys.",this,o,l,a),e=!1;break}a=l}if(i!==void 0&&n3(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){on("KeyframeTrack: Value is not a valid number.",this,o,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),r=this.getValueSize(),i=this.getInterpolation()===pN,s=e.length-1;let a=1;for(let o=1;o0){e[a]=e[s];for(let o=s*r,l=a*r,c=0;c!==r;++c)t[l+c]=t[o+c];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*r)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),r=this.constructor,i=new r(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}}c0.prototype.ValueTypeName="";c0.prototype.TimeBufferType=Float32Array;c0.prototype.ValueBufferType=Float32Array;c0.prototype.DefaultInterpolation=GM;class ty extends c0{constructor(e,t,r){super(e,t,r)}}ty.prototype.ValueTypeName="bool";ty.prototype.ValueBufferType=Array;ty.prototype.DefaultInterpolation=iS;ty.prototype.InterpolantFactoryMethodLinear=void 0;ty.prototype.InterpolantFactoryMethodSmooth=void 0;class Y$ extends c0{constructor(e,t,r,i){super(e,t,r,i)}}Y$.prototype.ValueTypeName="color";class rR extends c0{constructor(e,t,r,i){super(e,t,r,i)}}rR.prototype.ValueTypeName="number";class gxe extends V3{constructor(e,t,r,i){super(e,t,r,i)}interpolate_(e,t,r,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(r-t)/(i-t);let c=e*o;for(let u=c+o;c!==u;c+=4)zo.slerpFlat(s,0,a,c-o,a,c,l);return s}}class iR extends c0{constructor(e,t,r,i){super(e,t,r,i)}InterpolantFactoryMethodLinear(e){return new gxe(this.times,this.values,this.getValueSize(),e)}}iR.prototype.ValueTypeName="quaternion";iR.prototype.InterpolantFactoryMethodSmooth=void 0;class ny extends c0{constructor(e,t,r){super(e,t,r)}}ny.prototype.ValueTypeName="string";ny.prototype.ValueBufferType=Array;ny.prototype.DefaultInterpolation=iS;ny.prototype.InterpolantFactoryMethodLinear=void 0;ny.prototype.InterpolantFactoryMethodSmooth=void 0;class Z$ extends c0{constructor(e,t,r,i){super(e,t,r,i)}}Z$.prototype.ValueTypeName="vector";class dS{constructor(e="",t=-1,r=[],i=MP){this.name=e,this.tracks=r,this.duration=t,this.blendMode=i,this.uuid=rf(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,i=1/(e.fps||1);for(let a=0,o=r.length;a!==o;++a)t.push($We(r[a]).scale(i));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){const t=[],r=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,a=r.length;s!==a;++s)t.push(c0.toJSON(r[s]));return i}static CreateFromMorphTargetSequence(e,t,r,i){const s=t.length,a=[];for(let o=0;o1){const d=u[1];let h=i[d];h||(i[d]=h=[]),h.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],t,r));return a}resetDuration(){const e=this.tracks;let t=0;for(let r=0,i=e.length;r!==i;++r){const s=this.tracks[r];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(s),this.manager.itemEnd(e)},0);return}if(qm[e]!==void 0){qm[e].push({onLoad:t,onProgress:r,onError:i});return}qm[e]=[],qm[e].push({onLoad:t,onProgress:r,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&sn("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const u=qm[e],d=c.body.getReader(),h=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),p=h?parseInt(h):0,g=p!==0;let x=0;const _=new ReadableStream({start(y){M();function M(){d.read().then(({done:C,value:k})=>{if(C)y.close();else{x+=k.byteLength;const B=new ProgressEvent("progress",{lengthComputable:g,loaded:x,total:p});for(let U=0,z=u.length;U{y.error(C)})}}});return new Response(_)}else throw new WWe(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,o));case"json":return c.json();default:if(o==="")return c.text();{const d=/charset="?([^;"\s]*)"?/i.exec(o),h=d&&d[1]?d[1].toLowerCase():void 0,p=new TextDecoder(h);return c.arrayBuffer().then(g=>p.decode(g))}}}).then(c=>{Qp.add(`file:${e}`,c);const u=qm[e];delete qm[e];for(let d=0,h=u.length;d{const u=qm[e];if(u===void 0)throw this.manager.itemError(e),c;delete qm[e];for(let d=0,h=u.length;d{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class XWe extends yh{constructor(e){super(e)}load(e,t,r,i){const s=this,a=new Gg(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(o){try{t(s.parse(JSON.parse(o)))}catch(l){i?i(l):on(l),s.manager.itemError(e)}},r,i)}parse(e){const t=[];for(let r=0;r0){const l=new Q$(t);s=new hS(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,u=e.length;c0){i=new hS(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=e.length;a{let y=null,M=null;return _.boundingBox!==void 0&&(y=new So().fromJSON(_.boundingBox)),_.boundingSphere!==void 0&&(M=new Vo().fromJSON(_.boundingSphere)),{..._,boundingBox:y,boundingSphere:M}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=c(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new Vo().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new So().fromJSON(e.boundingBox));break;case"LOD":a=new Y2e;break;case"Line":a=new K0(o(e.geometry),l(e.material));break;case"LineLoop":a=new J2e(o(e.geometry),l(e.material));break;case"LineSegments":a=new o0(o(e.geometry),l(e.material));break;case"PointCloud":case"Points":a=new R$(o(e.geometry),l(e.material));break;case"Sprite":a=new X2e(l(e.material));break;case"Group":a=new nd;break;case"Bone":a=new P$;break;default:a=new os}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.pivot!==void 0&&(a.pivot=new Fe().fromArray(e.pivot)),e.morphTargetDictionary!==void 0&&(a.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.morphTargetInfluences!==void 0&&(a.morphTargetInfluences=e.morphTargetInfluences.slice()),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.static!==void 0&&(a.static=e.static),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const h=e.children;for(let p=0;p"u"&&sn("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&sn("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,a=Qp.get(`image-bitmap:${e}`);if(a!==void 0){if(s.manager.itemStart(e),a.then){a.then(c=>{oF.has(a)===!0?(i&&i(oF.get(a)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(c),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(a),s.manager.itemEnd(e)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const l=fetch(e,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){Qp.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e)}).catch(function(c){i&&i(c),oF.set(l,c),Qp.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});Qp.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let u8;class iW{static getContext(){return u8===void 0&&(u8=new(window.AudioContext||window.webkitAudioContext)),u8}static setContext(e){u8=e}}class iXe extends yh{constructor(e){super(e)}load(e,t,r,i){const s=this,a=new Gg(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{const c=l.slice(0),u=iW.getContext(),d=e+"#decode";s.manager.itemStart(d),u.decodeAudioData(c,function(h){t(h),s.manager.itemEnd(d)}).catch(function(h){o(h),s.manager.itemEnd(d)})}catch(c){o(c)}},r,i);function o(l){i?i(l):on(l),s.manager.itemError(e)}}}const Hae=new ir,$ae=new ir,D2=new ir;class sXe{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ga,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ga,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,D2.copy(e.projectionMatrix);const i=t.eyeSep/2,s=i*t.near/t.focus,a=t.near*Math.tan(jx*t.fov*.5)/t.zoom;let o,l;$ae.elements[12]=-i,Hae.elements[12]=i,o=-a*t.aspect+s,l=a*t.aspect+s,D2.elements[0]=2*t.near/(l-o),D2.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(D2),o=-a*t.aspect-s,l=a*t.aspect-s,D2.elements[0]=2*t.near/(l-o),D2.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(D2)}this.cameraL.matrix.copy(e.matrixWorld).multiply($ae),this.cameraL.matrixWorldNeedsUpdate=!0,this.cameraR.matrix.copy(e.matrixWorld).multiply(Hae),this.cameraR.matrixWorldNeedsUpdate=!0}}const Wy=-90,Xy=1;class sW extends os{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ga(Wy,Xy,e,t);i.layers=this.layers,this.add(i);const s=new Ga(Wy,Xy,e,t);s.layers=this.layers,this.add(s);const a=new Ga(Wy,Xy,e,t);a.layers=this.layers,this.add(a);const o=new Ga(Wy,Xy,e,t);o.layers=this.layers,this.add(o);const l=new Ga(Wy,Xy,e,t);l.layers=this.layers,this.add(l);const c=new Ga(Wy,Xy,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[r,i,s,a,o,l]=t;for(const c of t)this.remove(c);if(e===gu)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===mh)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:r,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const x=r.texture.generateMipmaps;r.texture.generateMipmaps=!1;let _=!1;e.isWebGLRenderer===!0?_=e.state.buffers.depth.getReversed():_=e.reversedDepthBuffer,e.setRenderTarget(r,0,i),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(r,1,i),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(r,2,i),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(r,3,i),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(r,4,i),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),r.texture.generateMipmaps=x,e.setRenderTarget(r,5,i),_&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,p),e.xr.enabled=g,r.texture.needsPMREMUpdate=!0}}class aW extends Ga{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class lR{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=aXe.bind(this),e.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function aXe(){this._document.hidden===!1&&this.reset()}const O2=new Fe,lF=new zo,oXe=new Fe,j2=new Fe,F2=new Fe;class lXe extends os{constructor(){super(),this.type="AudioListener",this.context=iW.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._timer=new lR}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this._timer.update();const t=this.context.listener;if(this.timeDelta=this._timer.getDelta(),this.matrixWorld.decompose(O2,lF,oXe),j2.set(0,0,-1).applyQuaternion(lF),F2.set(0,1,0).applyQuaternion(lF),t.positionX){const r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(O2.x,r),t.positionY.linearRampToValueAtTime(O2.y,r),t.positionZ.linearRampToValueAtTime(O2.z,r),t.forwardX.linearRampToValueAtTime(j2.x,r),t.forwardY.linearRampToValueAtTime(j2.y,r),t.forwardZ.linearRampToValueAtTime(j2.z,r),t.upX.linearRampToValueAtTime(F2.x,r),t.upY.linearRampToValueAtTime(F2.y,r),t.upZ.linearRampToValueAtTime(F2.z,r)}else t.setPosition(O2.x,O2.y,O2.z),t.setOrientation(j2.x,j2.y,j2.z,F2.x,F2.y,F2.z)}}class vxe extends os{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){sn("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){sn("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){sn("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){sn("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(r,i,this._addIndex*t,1,t);for(let l=t,c=t+t;l!==c;++l)if(r[l]!==r[l+t]){o.setValue(r,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,r=this.valueSize,i=r*this._origIndex;e.getValue(t,i);for(let s=r,a=i;s!==a;++s)t[s]=t[i+s%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let r=e;r=.5)for(let a=0;a!==s;++a)e[t+a]=e[r+a]}_slerp(e,t,r,i){zo.slerpFlat(e,t,e,t,e,r,i)}_slerpAdditive(e,t,r,i,s){const a=this._workIndex*s;zo.multiplyQuaternionsFlat(e,a,e,t,e,r),zo.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,r,i,s){const a=1-i;for(let o=0;o!==s;++o){const l=t+o;e[l]=e[l]*a+e[r+o]*i}}_lerpAdditive(e,t,r,i,s){for(let a=0;a!==s;++a){const o=t+a;e[o]=e[o]+e[r+a]*i}}}const oW="\\[\\]\\.:\\/",hXe=new RegExp("["+oW+"]","g"),lW="[^"+oW+"]",fXe="[^"+oW.replace("\\.","")+"]",pXe=/((?:WC+[\/:])*)/.source.replace("WC",lW),mXe=/(WCOD+)?/.source.replace("WCOD",fXe),gXe=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",lW),AXe=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",lW),xXe=new RegExp("^"+pXe+mXe+gXe+AXe+"$"),vXe=["material","materials","bones","map"];class yXe{constructor(e,t,r){const i=r||Ls.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,i=this._bindings[r];i!==void 0&&i.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=r.length;i!==s;++i)r[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}class Ls{constructor(e,t,r){this.path=t,this.parsedPath=r||Ls.parseTrackName(t),this.node=Ls.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new Ls.Composite(e,t,r):new Ls(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(hXe,"")}static parseTrackName(e){const t=xXe.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=r.nodeName&&r.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=r.nodeName.substring(i+1);vXe.indexOf(s)!==-1&&(r.nodeName=r.nodeName.substring(0,i),r.objectName=s)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){const r=function(s){for(let a=0;a=s){const d=s++,h=e[d];t[h.uuid]=u,e[u]=h,t[c]=d,e[d]=l;for(let p=0,g=i;p!==g;++p){const x=r[p],_=x[d],y=x[u];x[u]=_,x[d]=y}}}this.nCachedObjects_=s}uncache(){const e=this._objects,t=this._indicesByUUID,r=this._bindings,i=r.length;let s=this.nCachedObjects_,a=e.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],u=c.uuid,d=t[u];if(d!==void 0)if(delete t[u],d0&&(t[p.uuid]=d),e[d]=p,e.pop();for(let g=0,x=i;g!==x;++g){const _=r[g];_[d]=_[h],_.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){const r=this._bindingsIndicesByPath;let i=r[e];const s=this._bindings;if(i!==void 0)return s[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,u=this.nCachedObjects_,d=new Array(c);i=s.length,r[e]=i,a.push(e),o.push(t),s.push(d);for(let h=u,p=l.length;h!==p;++h){const g=l[h];d[h]=new Ls(g,e,t)}return d}unsubscribe_(e){const t=this._bindingsIndicesByPath,r=t[e];if(r!==void 0){const i=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=e[o];t[c]=r,a[r]=l,a.pop(),s[r]=s[o],s.pop(),i[r]=i[o],i.pop()}}}class bxe{constructor(e,t,r=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=r,this.blendMode=i;const s=t.tracks,a=s.length,o=new Array(a),l={endingStart:wx,endingEnd:wx};for(let c=0;c!==a;++c){const u=s[c].createInterpolant(null);o[c]=u,u.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=_2e,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,r=!1){if(e.fadeOut(t),this.fadeIn(t),r===!0){const i=this._clip.duration,s=e._clip.duration,a=s/i,o=i/s;e._restoreTimeScale=e.timeScale,this._restoreTimeScale=this.timeScale,e.warp(1,a,t),this.warp(o,1,t)}return this}crossFadeTo(e,t,r=!1){return e.crossFadeFrom(this,t,r)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,r){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+r,c[0]=e/a,c[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,r,i){if(!this.enabled){this._updateWeight(e);return}const s=this._startTime;if(s!==null){const l=(e-s)*r;l<0||r===0?t=0:(this._startTime=null,t=r*l)}t*=this._updateTimeScale(e);const a=this._updateTime(t),o=this._updateWeight(e);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case w$:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(a),c[u].accumulateAdditive(o);break;case MP:default:for(let u=0,d=l.length;u!==d;++u)l[u].evaluate(a),c[u].accumulate(i,o)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;if(r!==null){const i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;if(r!==null){const i=r.evaluate(e)[0];t*=i,e>r.parameterPositions[1]&&(t===0?this.paused=!0:(this._restoreTimeScale!==null&&(t=this._restoreTimeScale),this.timeScale=t),this.stopWarping())}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,r=this.loop;let i=this.time+e,s=this._loopCount;const a=r===w2e;if(e===0)return s===-1?i:a&&(s&1)===1?t-i:i;if(r===b2e){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=t||i<0){const o=Math.floor(i/t);i-=t*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(l===1){const c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=s,this.time=i;if(a&&(s&1)===1)return t-i}return i}_setEndings(e,t,r){const i=this._interpolantSettings;r?(i.endingStart=Sx,i.endingEnd=Sx):(e?i.endingStart=this.zeroSlopeAtStart?Sx:wx:i.endingStart=sS,t?i.endingEnd=this.zeroSlopeAtEnd?Sx:wx:i.endingEnd=sS)}_scheduleFading(e,t,r){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=t,o[1]=s+e,l[1]=r,this}}const _Xe=new Float32Array(1);class wXe extends zd{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(e,t){const r=e._localRoot||this._root,i=e._clip.tracks,s=i.length,a=e._propertyBindings,o=e._interpolants,l=r.uuid,c=this._bindingsByRootAndName;let u=c[l];u===void 0&&(u={},c[l]=u);for(let d=0;d!==s;++d){const h=i[d],p=h.name;let g=u[p];if(g!==void 0)++g.referenceCount,a[d]=g;else{if(g=a[d],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,l,p));continue}const x=t&&t._propertyBindings[d].binding.parsedPath;g=new yxe(Ls.create(r,p,x),h.ValueTypeName,h.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,l,p),a[d]=g}o[d].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const r=(e._localRoot||this._root).uuid,i=e._clip.uuid,s=this._actionsByClip[i];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,i,r)}const t=e._propertyBindings;for(let r=0,i=t.length;r!==i;++r){const s=t[r];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let r=0,i=t.length;r!==i;++r){const s=t[r];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--r)e[r].stop();return this}update(e){e*=this.timeScale;const t=this._actions,r=this._nActiveActions,i=this.time+=e,s=Math.sign(e),a=this._accuIndex^=1;for(let c=0;c!==r;++c)t[c]._update(i,e,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(e){this.time=0;for(let t=0;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}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}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))}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}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Zae).distanceTo(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}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)}}const Qae=new Fe,d8=new Fe,Yy=new Fe,Zy=new Fe,cF=new Fe,PXe=new Fe,RXe=new Fe;class uW{constructor(e=new Fe,t=new Fe){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Qae.subVectors(e,this.start),d8.subVectors(this.end,this.start);const r=d8.dot(d8);if(r===0)return 0;let s=d8.dot(Qae)/r;return t&&(s=ai(s,0,1)),s}closestPointToPoint(e,t,r){const i=this.closestPointToPointParameter(e,t);return this.delta(r).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=PXe,r=RXe){const i=10000000000000001e-32;let s,a;const o=this.start,l=e.start,c=this.end,u=e.end;Yy.subVectors(c,o),Zy.subVectors(u,l),cF.subVectors(o,l);const d=Yy.dot(Yy),h=Zy.dot(Zy),p=Zy.dot(cF);if(d<=i&&h<=i)return t.copy(o),r.copy(l),t.sub(r),t.dot(t);if(d<=i)s=0,a=p/h,a=ai(a,0,1);else{const g=Yy.dot(cF);if(h<=i)a=0,s=ai(-g/d,0,1);else{const x=Yy.dot(Zy),_=d*h-x*x;_!==0?s=ai((x*p-g*h)/_,0,1):s=0,a=(x*s+p)/h,a<0?(a=0,s=ai(-g/d,0,1)):a>1&&(a=1,s=ai((x-g)/d,0,1))}}return t.copy(o).addScaledVector(Yy,s),r.copy(l).addScaledVector(Zy,a),t.distanceToSquared(r)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Kae=new Fe;class LXe extends os{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const r=new Pr,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a1)for(let d=0;d.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{roe.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(roe,t)}}setLength(e,t=e*.2,r=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class HXe extends o0{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Pr;i.setAttribute("position",new tr(t,3)),i.setAttribute("color",new tr(r,3));const s=new Ac({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(e,t,r){const i=new Fn,s=this.geometry.attributes.color.array;return i.set(e),i.toArray(s,0),i.toArray(s,3),i.set(t),i.toArray(s,6),i.toArray(s,9),i.set(r),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Exe{constructor(){this.type="ShapePath",this.color=new Fn,this.subPaths=[],this.currentPath=null,this.userData={}}moveTo(e,t){return this.currentPath=new oS,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,i){return this.currentPath.quadraticCurveTo(e,t,r,i),this}bezierCurveTo(e,t,r,i,s,a){return this.currentPath.bezierCurveTo(e,t,r,i,s,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(){function e(l,c){let u=!1;const d=c.length;for(let h=0,p=d-1;hl.y!=x.y>l.y&&l.x<(x.x-g.x)*(l.y-g.y)/(x.y-g.y)+g.x&&(u=!u)}return u}function t(l,c){const u=c.getCenter(new en);if(e(u,l))return u;const d=u.y,h=[],p=l.length;for(let g=0;gd!=_.y>d){const y=x.x+(d-x.y)*(_.x-x.x)/(_.y-x.y);h.push(y)}}return h.length>1&&(h.sort((g,x)=>g-x),u.x=(h[0]+h[1])/2),u}let r=this.userData.style&&this.userData.style.fillRule||"nonzero";r!=="nonzero"&&r!=="evenodd"&&(sn('Fill-rule "'+r+'" is not supported, falling back to "nonzero".'),r="nonzero");const i=r==="nonzero"?l=>l!==0:l=>(l&1)!==0,s=[];for(const l of this.subPaths){const c=l.getPoints();if(c.length<3)continue;const u=D0.area(c);if(u===0)continue;const d=new Sxe;for(let h=0;hc.absArea-l.absArea);for(let l=0;l=0;d--){const h=s[d];if(h.boundingBox.containsBox(c.boundingBox)&&e(c.interiorPoint,h.points)){c.container=h.exclude?h.container:h,u=h.winding,c.winding+=u;break}}i(c.winding)===i(u)&&(c.exclude=!0)}for(const l of s)l.exclude||(l.role=l.container===null||l.container.role==="hole"?"outer":"hole");const a=[],o=new Map;for(const l of s){if(l.exclude||l.role!=="outer")continue;const c=new a6;c.curves=l.subPath.curves,a.push(c),o.set(l,c)}for(const l of s){if(l.exclude||l.role!=="hole")continue;const c=o.get(l.container);if(!c)continue;const u=new oS;u.curves=l.subPath.curves,c.holes.push(u)}return a}}class cR extends zd{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){sn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function $Xe(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2):(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0),n}function WXe(n,e){const t=n.image&&n.image.width?n.image.width/n.image.height:1;return t>e?(n.repeat.x=e/t,n.repeat.y=1,n.offset.x=(1-n.repeat.x)/2,n.offset.y=0):(n.repeat.x=1,n.repeat.y=t/e,n.offset.x=0,n.offset.y=(1-n.repeat.y)/2),n}function XXe(n){return n.repeat.x=1,n.repeat.y=1,n.offset.x=0,n.offset.y=0,n}function YM(n,e,t,r){const i=YXe(r);switch(t){case e6:return n*e;case e1:return n*e/i.components*i.byteLength;case Tm:return n*e/i.components*i.byteLength;case dc:return n*e*2/i.components*i.byteLength;case t1:return n*e*2/i.components*i.byteLength;case t2:return n*e*3/i.components*i.byteLength;case Oa:return n*e*4/i.components*i.byteLength;case Jv:return n*e*4/i.components*i.byteLength;case xg:case vg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case yg:case bg:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case K_:case e3:return Math.max(n,16)*Math.max(e,8)/4;case Q_:case J_:return Math.max(n,8)*Math.max(e,8)/2;case sv:case av:case lv:case cv:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ov:case Ug:case uv:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case dv:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case hv:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case fv:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case pv:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case mv:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case gv:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Av:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case xv:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case vv:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case yv:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case bv:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case _v:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case wv:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case Sv:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case Tv:case Ev:case Nv:return Math.ceil(n/4)*Math.ceil(e/4)*16;case Mv:case Cv:return Math.ceil(n/4)*Math.ceil(e/4)*8;case zg:case Pv:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function YXe(n){switch(n){case ma:case gg:return{byteLength:1,components:1};case Jh:case Ag:case ba:return{byteLength:2,components:1};case I3:case D3:return{byteLength:2,components:4};case xs:case ml:case ea:return{byteLength:4,components:1};case O3:case j3:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}class ZXe{static contain(e,t){return $Xe(e,t)}static cover(e,t){return WXe(e,t)}static fill(e){return XXe(e)}static getByteLength(e,t,r,i){return YM(e,t,r,i)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Sm}}));typeof window<"u"&&(window.__THREE__?sn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Sm);/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT */function Nxe(){let n=null,e=!1,t=null,r=null;function i(s,a){t(s,a),r=n.requestAnimationFrame(i)}return{start:function(){e!==!0&&t!==null&&n!==null&&(r=n.requestAnimationFrame(i),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){n=s}}}function QXe(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let p;if(c instanceof Float32Array)p=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)p=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?p=n.HALF_FLOAT:p=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)p=n.SHORT;else if(c instanceof Uint32Array)p=n.UNSIGNED_INT;else if(c instanceof Int32Array)p=n.INT;else if(c instanceof Int8Array)p=n.BYTE;else if(c instanceof Uint8Array)p=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)p=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:p,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function r(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((p,g)=>p.start-g.start);let h=0;for(let p=1;p 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`,pYe=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,mYe=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,gYe=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,AYe=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #endif`,xYe=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; #endif`,vYe=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; #endif`,yYe=`#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`,bYe=`#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 ); } #define inverseTransformDirection transformDirectionByInverseViewMatrix vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); } vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).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`,_Ye=`#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`,wYe=`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; #endif`,SYe=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,TYe=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,EYe=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,NYe=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,MYe="gl_FragColor = linearToOutputTexel( gl_FragColor );",CYe=`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 ); }`,PYe=`#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 = transformNormalByInverseViewMatrix( 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`,RYe=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,LYe=`#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`,kYe=`#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`,IYe=`#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 = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,DYe=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,OYe=`#ifdef USE_FOG varying float vFogDepth; #endif`,jYe=`#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`,FYe=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,BYe=`#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 }`,UYe=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,zYe=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,VYe=`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`,qYe=`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 = transformNormalByInverseViewMatrix( 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 `,GYe=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = transformNormalByInverseViewMatrix( 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 = transformDirectionByInverseViewMatrix( 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`,HYe=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,$Ye=`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`,WYe=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,XYe=`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`,YYe=`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`,ZYe=`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 ); }`,QYe=` 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 = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,KYe=`#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`,JYe=`#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`,eZe=`#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`,tZe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,nZe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,rZe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,iZe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,sZe=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,aZe=`#ifdef USE_MAP uniform sampler2D map; #endif`,oZe=`#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`,lZe=`#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`,cZe=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,uZe=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,dZe=`#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`,hZe=`#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`,fZe=`#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`,pZe=`#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`,mZe=`#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`,gZe=`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 #ifdef DOUBLE_SIDED 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 #ifdef DOUBLE_SIDED tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,AZe=`#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`,xZe=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,vZe=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,yZe=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #ifdef FLIP_SIDED vBitangent = - vBitangent; #endif #endif #endif`,bZe=`#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`,_Ze=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,wZe=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,SZe=`#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`,TZe=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,EZe=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,NZe=`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 }`,MZe=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,CZe=`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;`,PZe=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,RZe=`#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`,LZe=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,kZe=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,IZe=`#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`,DZe=`#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`,OZe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( 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`,jZe=`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; }`,FZe=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,BZe=`#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`,UZe=`#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`,zZe=`#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`,VZe=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,qZe=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,GZe=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,HZe=`#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; }`,$Ze=`#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 = transformNormalByInverseViewMatrix( 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`,WZe=`#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`,XZe=`#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`,YZe=`#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`,ZZe=`#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`,QZe=`#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`;const KZe=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,JZe=`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 }`,eQe=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,tQe=`#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 }`,nQe=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,rQe=`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 }`,iQe=`#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; }`,sQe=`#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 }`,aQe=`#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; }`,oQe=`#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 ); }`,lQe=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,cQe=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,uQe=`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 }`,dQe=`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 }`,hQe=`#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 }`,fQe=`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 }`,pQe=`#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 }`,mQe=`#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 }`,gQe=`#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; }`,AQe=`#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 }`,xQe=`#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 }`,vQe=`#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 }`,yQe=`#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 }`,bQe=`#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 }`,_Qe=`#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 }`,wQe=`#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 }`,SQe=`#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 }`,TQe=`#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 }`,EQe=`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 }`,NQe=`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 }`,MQe=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,CQe=`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 }`,PQe=`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 }`,RQe=`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 }`,di={alphahash_fragment:KXe,alphahash_pars_fragment:JXe,alphamap_fragment:eYe,alphamap_pars_fragment:tYe,alphatest_fragment:nYe,alphatest_pars_fragment:rYe,aomap_fragment:iYe,aomap_pars_fragment:sYe,batching_pars_vertex:aYe,batching_vertex:oYe,begin_vertex:lYe,beginnormal_vertex:cYe,bsdfs:uYe,iridescence_fragment:dYe,bumpmap_pars_fragment:hYe,clipping_planes_fragment:fYe,clipping_planes_pars_fragment:pYe,clipping_planes_pars_vertex:mYe,clipping_planes_vertex:gYe,color_fragment:AYe,color_pars_fragment:xYe,color_pars_vertex:vYe,color_vertex:yYe,common:bYe,cube_uv_reflection_fragment:_Ye,defaultnormal_vertex:wYe,displacementmap_pars_vertex:SYe,displacementmap_vertex:TYe,emissivemap_fragment:EYe,emissivemap_pars_fragment:NYe,colorspace_fragment:MYe,colorspace_pars_fragment:CYe,envmap_fragment:PYe,envmap_common_pars_fragment:RYe,envmap_pars_fragment:LYe,envmap_pars_vertex:kYe,envmap_physical_pars_fragment:GYe,envmap_vertex:IYe,fog_vertex:DYe,fog_pars_vertex:OYe,fog_fragment:jYe,fog_pars_fragment:FYe,gradientmap_pars_fragment:BYe,lightmap_pars_fragment:UYe,lights_lambert_fragment:zYe,lights_lambert_pars_fragment:VYe,lights_pars_begin:qYe,lights_toon_fragment:HYe,lights_toon_pars_fragment:$Ye,lights_phong_fragment:WYe,lights_phong_pars_fragment:XYe,lights_physical_fragment:YYe,lights_physical_pars_fragment:ZYe,lights_fragment_begin:QYe,lights_fragment_maps:KYe,lights_fragment_end:JYe,lightprobes_pars_fragment:eZe,logdepthbuf_fragment:tZe,logdepthbuf_pars_fragment:nZe,logdepthbuf_pars_vertex:rZe,logdepthbuf_vertex:iZe,map_fragment:sZe,map_pars_fragment:aZe,map_particle_fragment:oZe,map_particle_pars_fragment:lZe,metalnessmap_fragment:cZe,metalnessmap_pars_fragment:uZe,morphinstance_vertex:dZe,morphcolor_vertex:hZe,morphnormal_vertex:fZe,morphtarget_pars_vertex:pZe,morphtarget_vertex:mZe,normal_fragment_begin:gZe,normal_fragment_maps:AZe,normal_pars_fragment:xZe,normal_pars_vertex:vZe,normal_vertex:yZe,normalmap_pars_fragment:bZe,clearcoat_normal_fragment_begin:_Ze,clearcoat_normal_fragment_maps:wZe,clearcoat_pars_fragment:SZe,iridescence_pars_fragment:TZe,opaque_fragment:EZe,packing:NZe,premultiplied_alpha_fragment:MZe,project_vertex:CZe,dithering_fragment:PZe,dithering_pars_fragment:RZe,roughnessmap_fragment:LZe,roughnessmap_pars_fragment:kZe,shadowmap_pars_fragment:IZe,shadowmap_pars_vertex:DZe,shadowmap_vertex:OZe,shadowmask_pars_fragment:jZe,skinbase_vertex:FZe,skinning_pars_vertex:BZe,skinning_vertex:UZe,skinnormal_vertex:zZe,specularmap_fragment:VZe,specularmap_pars_fragment:qZe,tonemapping_fragment:GZe,tonemapping_pars_fragment:HZe,transmission_fragment:$Ze,transmission_pars_fragment:WZe,uv_pars_fragment:XZe,uv_pars_vertex:YZe,uv_vertex:ZZe,worldpos_vertex:QZe,background_vert:KZe,background_frag:JZe,backgroundCube_vert:eQe,backgroundCube_frag:tQe,cube_vert:nQe,cube_frag:rQe,depth_vert:iQe,depth_frag:sQe,distance_vert:aQe,distance_frag:oQe,equirect_vert:lQe,equirect_frag:cQe,linedashed_vert:uQe,linedashed_frag:dQe,meshbasic_vert:hQe,meshbasic_frag:fQe,meshlambert_vert:pQe,meshlambert_frag:mQe,meshmatcap_vert:gQe,meshmatcap_frag:AQe,meshnormal_vert:xQe,meshnormal_frag:vQe,meshphong_vert:yQe,meshphong_frag:bQe,meshphysical_vert:_Qe,meshphysical_frag:wQe,meshtoon_vert:SQe,meshtoon_frag:TQe,points_vert:EQe,points_frag:NQe,shadow_vert:MQe,shadow_frag:CQe,sprite_vert:PQe,sprite_frag:RQe},Yn={common:{diffuse:{value:new Fn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ni},alphaMap:{value:null},alphaMapTransform:{value:new ni},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ni}},envmap:{envMap:{value:null},envMapRotation:{value:new ni},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ni}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ni}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ni},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ni},normalScale:{value:new en(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ni},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ni}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ni}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ni}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Fn(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 Fe},probesMax:{value:new Fe},probesResolution:{value:new Fe}},points:{diffuse:{value:new Fn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ni},alphaTest:{value:0},uvTransform:{value:new ni}},sprite:{diffuse:{value:new Fn(16777215)},opacity:{value:1},center:{value:new en(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ni},alphaMap:{value:null},alphaMapTransform:{value:new ni},alphaTest:{value:0}}},Ed={basic:{uniforms:wd([Yn.common,Yn.specularmap,Yn.envmap,Yn.aomap,Yn.lightmap,Yn.fog]),vertexShader:di.meshbasic_vert,fragmentShader:di.meshbasic_frag},lambert:{uniforms:wd([Yn.common,Yn.specularmap,Yn.envmap,Yn.aomap,Yn.lightmap,Yn.emissivemap,Yn.bumpmap,Yn.normalmap,Yn.displacementmap,Yn.fog,Yn.lights,{emissive:{value:new Fn(0)},envMapIntensity:{value:1}}]),vertexShader:di.meshlambert_vert,fragmentShader:di.meshlambert_frag},phong:{uniforms:wd([Yn.common,Yn.specularmap,Yn.envmap,Yn.aomap,Yn.lightmap,Yn.emissivemap,Yn.bumpmap,Yn.normalmap,Yn.displacementmap,Yn.fog,Yn.lights,{emissive:{value:new Fn(0)},specular:{value:new Fn(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:di.meshphong_vert,fragmentShader:di.meshphong_frag},standard:{uniforms:wd([Yn.common,Yn.envmap,Yn.aomap,Yn.lightmap,Yn.emissivemap,Yn.bumpmap,Yn.normalmap,Yn.displacementmap,Yn.roughnessmap,Yn.metalnessmap,Yn.fog,Yn.lights,{emissive:{value:new Fn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:di.meshphysical_vert,fragmentShader:di.meshphysical_frag},toon:{uniforms:wd([Yn.common,Yn.aomap,Yn.lightmap,Yn.emissivemap,Yn.bumpmap,Yn.normalmap,Yn.displacementmap,Yn.gradientmap,Yn.fog,Yn.lights,{emissive:{value:new Fn(0)}}]),vertexShader:di.meshtoon_vert,fragmentShader:di.meshtoon_frag},matcap:{uniforms:wd([Yn.common,Yn.bumpmap,Yn.normalmap,Yn.displacementmap,Yn.fog,{matcap:{value:null}}]),vertexShader:di.meshmatcap_vert,fragmentShader:di.meshmatcap_frag},points:{uniforms:wd([Yn.points,Yn.fog]),vertexShader:di.points_vert,fragmentShader:di.points_frag},dashed:{uniforms:wd([Yn.common,Yn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:di.linedashed_vert,fragmentShader:di.linedashed_frag},depth:{uniforms:wd([Yn.common,Yn.displacementmap]),vertexShader:di.depth_vert,fragmentShader:di.depth_frag},normal:{uniforms:wd([Yn.common,Yn.bumpmap,Yn.normalmap,Yn.displacementmap,{opacity:{value:1}}]),vertexShader:di.meshnormal_vert,fragmentShader:di.meshnormal_frag},sprite:{uniforms:wd([Yn.sprite,Yn.fog]),vertexShader:di.sprite_vert,fragmentShader:di.sprite_frag},background:{uniforms:{uvTransform:{value:new ni},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:di.background_vert,fragmentShader:di.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ni}},vertexShader:di.backgroundCube_vert,fragmentShader:di.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:di.cube_vert,fragmentShader:di.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:di.equirect_vert,fragmentShader:di.equirect_frag},distance:{uniforms:wd([Yn.common,Yn.displacementmap,{referencePosition:{value:new Fe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:di.distance_vert,fragmentShader:di.distance_frag},shadow:{uniforms:wd([Yn.lights,Yn.fog,{color:{value:new Fn(0)},opacity:{value:1}}]),vertexShader:di.shadow_vert,fragmentShader:di.shadow_frag}};Ed.physical={uniforms:wd([Ed.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ni},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ni},clearcoatNormalScale:{value:new en(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ni},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ni},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ni},sheen:{value:0},sheenColor:{value:new Fn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ni},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ni},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ni},transmissionSamplerSize:{value:new en},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ni},attenuationDistance:{value:0},attenuationColor:{value:new Fn(0)},specularColor:{value:new Fn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ni},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ni},anisotropyVector:{value:new en},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ni}}]),vertexShader:di.meshphysical_vert,fragmentShader:di.meshphysical_frag};const A8={r:0,b:0,g:0},LQe=new ir,Mxe=new ni;Mxe.set(-1,0,0,0,1,0,0,0,1);function kQe(n,e,t,r,i,s){const a=new Fn(0);let o=i===!0?0:1,l,c,u=null,d=0,h=null;function p(M){let C=M.isScene===!0?M.background:null;if(C&&C.isTexture){const k=M.backgroundBlurriness>0;C=e.get(C,k)}return C}function g(M){let C=!1;const k=p(M);k===null?_(a,o):k&&k.isColor&&(_(k,1),C=!0);const B=n.xr.getEnvironmentBlendMode();B==="additive"?t.buffers.color.setClear(0,0,0,1,s):B==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(n.autoClear||C)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function x(M,C){const k=p(C);k&&(k.isCubeTexture||k.mapping===pm)?(c===void 0&&(c=new ui(new Em(1,1,1),new Dl({name:"BackgroundCubeMaterial",uniforms:s3(Ed.backgroundCube.uniforms),vertexShader:Ed.backgroundCube.vertexShader,fragmentShader:Ed.backgroundCube.fragmentShader,side:Ds,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(B,U,z){this.matrixWorld.copyPosition(z.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=k,c.material.uniforms.backgroundBlurriness.value=C.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(LQe.makeRotationFromEuler(C.backgroundRotation)).transpose(),k.isCubeTexture&&k.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mxe),c.material.toneMapped=Sr.getTransfer(k.colorSpace)!==rr,(u!==k||d!==k.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=k,d=k.version,h=n.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)):k&&k.isTexture&&(l===void 0&&(l=new ui(new Nm(2,2),new Dl({name:"BackgroundMaterial",uniforms:s3(Ed.background.uniforms),vertexShader:Ed.background.vertexShader,fragmentShader:Ed.background.fragmentShader,side:id,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=k,l.material.uniforms.backgroundIntensity.value=C.backgroundIntensity,l.material.toneMapped=Sr.getTransfer(k.colorSpace)!==rr,k.matrixAutoUpdate===!0&&k.updateMatrix(),l.material.uniforms.uvTransform.value.copy(k.matrix),(u!==k||d!==k.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=k,d=k.version,h=n.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null))}function _(M,C){M.getRGB(A8,uxe(n)),t.buffers.color.setClear(A8.r,A8.g,A8.b,C,s)}function y(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(M,C=1){a.set(M),o=C,_(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(M){o=M,_(a,o)},render:g,addToRenderList:x,dispose:y}}function IQe(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),r={},i=h(null);let s=i,a=!1;function o(G,H,K,W,J){let ie=!1;const ae=d(G,W,K,H);s!==ae&&(s=ae,c(s.object)),ie=p(G,W,K,J),ie&&g(G,W,K,J),J!==null&&e.update(J,n.ELEMENT_ARRAY_BUFFER),(ie||a)&&(a=!1,k(G,H,K,W),J!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(J).buffer))}function l(){return n.createVertexArray()}function c(G){return n.bindVertexArray(G)}function u(G){return n.deleteVertexArray(G)}function d(G,H,K,W){const J=W.wireframe===!0;let ie=r[H.id];ie===void 0&&(ie={},r[H.id]=ie);const ae=G.isInstancedMesh===!0?G.id:0;let Q=ie[ae];Q===void 0&&(Q={},ie[ae]=Q);let re=Q[K.id];re===void 0&&(re={},Q[K.id]=re);let oe=re[J];return oe===void 0&&(oe=h(l()),re[J]=oe),oe}function h(G){const H=[],K=[],W=[];for(let J=0;J=0){const fe=J[re];let ee=ie[re];if(ee===void 0&&(re==="instanceMatrix"&&G.instanceMatrix&&(ee=G.instanceMatrix),re==="instanceColor"&&G.instanceColor&&(ee=G.instanceColor)),fe===void 0||fe.attribute!==ee||ee&&fe.data!==ee.data)return!0;ae++}return s.attributesNum!==ae||s.index!==W}function g(G,H,K,W){const J={},ie=H.attributes;let ae=0;const Q=K.getAttributes();for(const re in Q)if(Q[re].location>=0){let fe=ie[re];fe===void 0&&(re==="instanceMatrix"&&G.instanceMatrix&&(fe=G.instanceMatrix),re==="instanceColor"&&G.instanceColor&&(fe=G.instanceColor));const ee={};ee.attribute=fe,fe&&fe.data&&(ee.data=fe.data),J[re]=ee,ae++}s.attributes=J,s.attributesNum=ae,s.index=W}function x(){const G=s.newAttributes;for(let H=0,K=G.length;H=0){let oe=J[Q];if(oe===void 0&&(Q==="instanceMatrix"&&G.instanceMatrix&&(oe=G.instanceMatrix),Q==="instanceColor"&&G.instanceColor&&(oe=G.instanceColor)),oe!==void 0){const fe=oe.normalized,ee=oe.itemSize,me=e.get(oe);if(me===void 0)continue;const Ae=me.buffer,be=me.type,pe=me.bytesPerElement,ge=be===n.INT||be===n.UNSIGNED_INT||oe.gpuType===ml;if(oe.isInterleavedBufferAttribute){const Te=oe.data,ze=Te.stride,Xe=oe.offset;if(Te.isInstancedInterleavedBuffer){for(let Qe=0;Qe0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";z="mediump"}return z==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(sn("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&sn("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const p=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=n.getParameter(n.MAX_TEXTURE_SIZE),_=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),y=n.getParameter(n.MAX_VERTEX_ATTRIBS),M=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),C=n.getParameter(n.MAX_VARYING_VECTORS),k=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),B=n.getParameter(n.MAX_SAMPLES),U=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:p,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:_,maxAttributes:y,maxVertexUniforms:M,maxVaryings:C,maxFragmentUniforms:k,maxSamples:B,samples:U}}function jQe(n){const e=this;let t=null,r=0,i=!1,s=!1;const a=new Bf,o=new ni,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const p=d.length!==0||h||r!==0||i;return i=h,r=d.length,p},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,p){const g=d.clippingPlanes,x=d.clipIntersection,_=d.clipShadows,y=n.get(d);if(!i||g===null||g.length===0||s&&!_)s?u(null):c();else{const M=s?0:r,C=M*4;let k=y.clippingState||null;l.value=k,k=u(g,h,C,p);for(let B=0;B!==C;++B)k[B]=t[B];y.clippingState=k,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(d,h,p,g){const x=d!==null?d.length:0;let _=null;if(x!==0){if(_=l.value,g!==!0||_===null){const y=p+x*4,M=h.matrixWorldInverse;o.getNormalMatrix(M),(_===null||_.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=loe(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ooe(),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=Math.pow(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?B:0,B,B),d.setRenderTarget(i),y&&d.render(x,l),d.render(e,l)}d.toneMapping=p,d.autoClear=h,e.background=M}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===ph||e.mapping===e0;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=loe()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ooe());const s=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=s;const o=s.uniforms;o.envMap.value=e;const l=this._cubeSize;Qy(t,0,0,3*l,2*l),r.setRenderTarget(t),r.render(a,kw)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;sg-cA?r-g+cA:0),y=4*(this._cubeSize-x);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=g-t,Qy(s,_,y,3*x,2*x),i.setRenderTarget(s),i.render(o,kw),l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=g-r,Qy(e,_,y,3*x,2*x),i.setRenderTarget(e),i.render(o,kw)}_blur(e,t,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&on("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[i];d.material=c;const h=c.uniforms,p=this._sizeLods[r]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*dx-1),x=s/g,_=isFinite(s)?1+Math.floor(u*x):dx;_>dx&&sn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${dx}`);const y=[];let M=0;for(let z=0;zC-cA?i-C+cA:0),U=4*(this._cubeSize-k);Qy(t,B,U,3*k,2*k),l.setRenderTarget(t),l.render(d,kw)}};function UQe(n){const e=[],t=[],r=[];let i=n;const s=n-cA+1+ioe.length;for(let a=0;an-cA?l=ioe[a-n+cA-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,g=6,x=3,_=2,y=1,M=new Float32Array(x*g*p),C=new Float32Array(_*g*p),k=new Float32Array(y*g*p);for(let U=0;U2?0:-1,V=[z,O,0,z+2/3,O,0,z+2/3,O+1,0,z,O,0,z+2/3,O+1,0,z,O+1,0];M.set(V,x*g*U),C.set(h,_*g*U);const $=[U,U,U,U,U,U];k.set($,y*g*U)}const B=new Pr;B.setAttribute("position",new Gi(M,x)),B.setAttribute("uv",new Gi(C,_)),B.setAttribute("faceIndex",new Gi(k,y)),r.push(new ui(B,null)),i>cA&&i--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function aoe(n,e,t){const r=new dh(n,e,t);return r.texture.mapping=pm,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Qy(n,e,t,r,i){n.viewport.set(e,t,r,i),n.scissor.set(e,t,r,i)}function zQe(n,e,t){return new Dl({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:FQe,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:uR(),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:Yl,depthTest:!1,depthWrite:!1})}function VQe(n,e,t){const r=new Float32Array(dx),i=new Fe(0,1,0);return new Dl({name:"SphericalGaussianBlur",defines:{n:dx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:uR(),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:Yl,depthTest:!1,depthWrite:!1})}function ooe(){return new Dl({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uR(),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:Yl,depthTest:!1,depthWrite:!1})}function loe(){return new Dl({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uR(),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:Yl,depthTest:!1,depthWrite:!1})}function uR(){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 ); } `}class dW extends dh{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new r1(i),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;const r={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 ); } `},i=new Em(5,5,5),s=new Dl({name:"CubemapFromEquirect",uniforms:s3(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Ds,blending:Yl});s.uniforms.tEquirect.value=t;const a=new ui(i,s),o=t.minFilter;return t.minFilter===Bc&&(t.minFilter=Ci),new sW(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,r,i);e.setRenderTarget(s)}}function qQe(n){let e=new WeakMap,t=new WeakMap,r=null;function i(h,p=!1){return h==null?null:p?a(h):s(h)}function s(h){if(h&&h.isTexture){const p=h.mapping;if(p===MA||p===CA)if(e.has(h)){const g=e.get(h).texture;return o(g,h.mapping)}else{const g=h.image;if(g&&g.height>0){const x=new dW(g.height);return x.fromEquirectangularTexture(n,h),e.set(h,x),h.addEventListener("dispose",c),o(x.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const p=h.mapping,g=p===MA||p===CA,x=p===ph||p===e0;if(g||x){let _=t.get(h);const y=_!==void 0?_.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==y)return r===null&&(r=new Jz(n)),_=g?r.fromEquirectangular(h,_):r.fromCubemap(h,_),_.texture.pmremVersion=h.pmremVersion,t.set(h,_),_.texture;if(_!==void 0)return _.texture;{const M=h.image;return g&&M&&M.height>0||x&&M&&l(M)?(r===null&&(r=new Jz(n)),_=g?r.fromEquirectangular(h):r.fromCubemap(h),_.texture.pmremVersion=h.pmremVersion,t.set(h,_),h.addEventListener("dispose",u),_.texture):null}}}return h}function o(h,p){return p===MA?h.mapping=ph:p===CA&&(h.mapping=e0),h}function l(h){let p=0;const g=6;for(let x=0;x=65535?jP:OP)(h,1);_.version=x;const y=s.get(d);y&&e.remove(y),s.set(d,_)}function u(d){const h=s.get(d);if(h){const p=d.index;p!==null&&h.versione.maxTextureSize&&(B=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const U=new Float32Array(k*B*4*d),z=new n6(U,k,B,d);z.type=ea,z.needsUpdate=!0;const O=C*4;for(let $=0;$ #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}),u=new ui(l,c),d=new Yf(-1,1,1,-1,0,1);let h=null,p=null,g=!1,x,_=null,y=[],M=!1;this.setSize=function(C,k){a.setSize(C,k),o.setSize(C,k);for(let B=0;B0&&y[0].isRenderPass===!0;const k=a.width,B=a.height;for(let U=0;U0)return n;const i=e*t;let s=coe[i];if(s===void 0&&(s=new Float32Array(i),coe[i]=s),e!==0){r.toArray(s,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(s,o)}return s}function pc(n,e){if(n.length!==e.length)return!1;for(let t=0,r=n.length;t0&&(this.seq=i.concat(s))}setValue(e,t,r,i){const s=this.map[t];s!==void 0&&s.setValue(e,r,i)}setOptional(e,t,r){const i=t[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,t,r,i){for(let s=0,a=t.length;s!==a;++s){const o=t[s],l=r[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,i)}}static seqWithValue(e,t){const r=[];for(let i=0,s=e.length;i!==s;++i){const a=e[i];a.id in t&&r.push(a)}return r}}function moe(n,e,t){const r=n.createShader(e);return n.shaderSource(r,t),n.compileShader(r),r}const VKe=37297;let qKe=0;function GKe(n,e){const t=n.split(` `),r=[],i=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let a=i;a":" "} ${o}: ${t[a]}`)}return r.join(` `)}const goe=new ni;function HKe(n){Sr._getMatrix(goe,Sr.workingColorSpace,n);const e=`mat3( ${goe.elements.map(t=>t.toFixed(4))} )`;switch(Sr.getTransfer(n)){case Lv:return[e,"LinearTransferOETF"];case rr:return[e,"sRGBTransferOETF"];default:return sn("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function Aoe(n,e,t){const r=n.getShaderParameter(e,n.COMPILE_STATUS),s=(n.getShaderInfoLog(e)||"").trim();if(r&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` `+s+` `+GKe(n.getShaderSource(e),o)}else return s}function $Ke(n,e){const t=HKe(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` `)}const WKe={[_P]:"Linear",[wP]:"Reinhard",[SP]:"Cineon",[QS]:"ACESFilmic",[TP]:"AgX",[EP]:"Neutral",[_$]:"Custom"};function XKe(n,e){const t=WKe[e];return t===void 0?(sn("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const x8=new Fe;function YKe(){Sr.getLuminanceCoefficients(x8);const n=x8.x.toFixed(4),e=x8.y.toFixed(4),t=x8.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` `)}function ZKe(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(k5).join(` `)}function QKe(n){const e=[];for(const t in n){const r=n[t];r!==!1&&e.push("#define "+t+" "+r)}return e.join(` `)}function KKe(n,e){const t={},r=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function tV(n){return n.replace(JKe,tJe)}const eJe=new Map;function tJe(n,e){let t=di[e];if(t===void 0){const r=eJe.get(e);if(r!==void 0)t=di[r],sn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return tV(t)}const nJe=/#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 yoe(n){return n.replace(nJe,rJe)}function rJe(n,e,t,r){let i="";for(let s=parseInt(e);s0&&(_+=` `),y=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(k5).join(` `),y.length>0&&(y+=` `)):(_=[boe(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.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(k5).join(` `),y=[boe(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==cc?"#define TONE_MAPPING":"",t.toneMapping!==cc?di.tonemapping_pars_fragment:"",t.toneMapping!==cc?XKe("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",di.colorspace_pars_fragment,$Ke("linearToOutputTexel",t.outputColorSpace),YKe(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(k5).join(` `)),a=tV(a),a=xoe(a,t),a=voe(a,t),o=tV(o),o=xoe(o,t),o=voe(o,t),a=yoe(a),o=yoe(o),t.isRawShaderMaterial!==!0&&(M=`#version 300 es `,_=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+_,y=["#define varying in",t.glslVersion===$z?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===$z?"":"#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(` `)+` `+y);const C=M+_+a,k=M+y+o,B=moe(i,i.VERTEX_SHADER,C),U=moe(i,i.FRAGMENT_SHADER,k);i.attachShader(x,B),i.attachShader(x,U),t.index0AttributeName!==void 0?i.bindAttribLocation(x,0,t.index0AttributeName):t.hasPositionAttribute===!0&&i.bindAttribLocation(x,0,"position"),i.linkProgram(x);function z(G){if(n.debug.checkShaderErrors){const H=i.getProgramInfoLog(x)||"",K=i.getShaderInfoLog(B)||"",W=i.getShaderInfoLog(U)||"",J=H.trim(),ie=K.trim(),ae=W.trim();let Q=!0,re=!0;if(i.getProgramParameter(x,i.LINK_STATUS)===!1)if(Q=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(i,x,B,U);else{const oe=Aoe(i,B,"vertex"),fe=Aoe(i,U,"fragment");on("WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(x,i.VALIDATE_STATUS)+` Material Name: `+G.name+` Material Type: `+G.type+` Program Info Log: `+J+` `+oe+` `+fe)}else J!==""?sn("WebGLProgram: Program Info Log:",J):(ie===""||ae==="")&&(re=!1);re&&(G.diagnostics={runnable:Q,programLog:J,vertexShader:{log:ie,prefix:_},fragmentShader:{log:ae,prefix:y}})}i.deleteShader(B),i.deleteShader(U),O=new gN(i,x),V=KKe(i,x)}let O;this.getUniforms=function(){return O===void 0&&z(this),O};let V;this.getAttributes=function(){return V===void 0&&z(this),V};let $=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return $===!1&&($=i.getProgramParameter(x,VKe)),$},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=qKe++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=B,this.fragmentShader=U,this}let pJe=0;class mJe{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,r){const i=this._getShaderCacheForMaterial(e);return i.has(t)===!1&&(i.add(t),t.usedTimes++),i.has(r)===!1&&(i.add(r),r.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new gJe(e),t.set(e,r)),r}}class gJe{constructor(e){this.id=pJe++,this.code=e,this.usedTimes=0}}function AJe(n){return n===dc||n===Ug||n===zg}function xJe(n,e,t,r,i,s){const a=new Fx,o=new mJe,l=new Set,c=[],u=new Map,d=r.logarithmicDepthBuffer;let h=r.precision;const 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 g(O){return l.add(O),O===0?"uv":`uv${O}`}function x(O,V,$,G,H,K){const W=G.fog,J=H.geometry,ie=O.isMeshStandardMaterial||O.isMeshLambertMaterial||O.isMeshPhongMaterial?G.environment:null,ae=O.isMeshStandardMaterial||O.isMeshLambertMaterial&&!O.envMap||O.isMeshPhongMaterial&&!O.envMap,Q=e.get(O.envMap||ie,ae),re=Q&&Q.mapping===pm?Q.image.height:null,oe=p[O.type];O.precision!==null&&(h=r.getMaxPrecision(O.precision),h!==O.precision&&sn("WebGLProgram.getParameters:",O.precision,"not supported, using",h,"instead."));const fe=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,ee=fe!==void 0?fe.length:0;let me=0;J.morphAttributes.position!==void 0&&(me=1),J.morphAttributes.normal!==void 0&&(me=2),J.morphAttributes.color!==void 0&&(me=3);let Ae,be,pe,ge;if(oe){const ut=Ed[oe];Ae=ut.vertexShader,be=ut.fragmentShader}else{Ae=O.vertexShader,be=O.fragmentShader;const ut=o.getVertexShaderStage(O),Gt=o.getFragmentShaderStage(O);o.update(O,ut,Gt),pe=ut.id,ge=Gt.id}const Te=n.getRenderTarget(),ze=n.state.buffers.depth.getReversed(),Xe=H.isInstancedMesh===!0,Qe=H.isBatchedMesh===!0,ot=!!O.map,bt=!!O.matcap,ht=!!Q,Ce=!!O.aoMap,lt=!!O.lightMap,ft=!!O.bumpMap&&O.wireframe===!1,et=!!O.normalMap,At=!!O.displacementMap,Lt=!!O.emissiveMap,st=!!O.metalnessMap,Ht=!!O.roughnessMap,Se=O.anisotropy>0,_t=O.clearcoat>0,It=O.dispersion>0,De=O.iridescence>0,ue=O.sheen>0,Ve=O.transmission>0,We=Se&&!!O.anisotropyMap,ct=_t&&!!O.clearcoatMap,vt=_t&&!!O.clearcoatNormalMap,Ut=_t&&!!O.clearcoatRoughnessMap,dt=De&&!!O.iridescenceMap,mt=De&&!!O.iridescenceThicknessMap,Ft=ue&&!!O.sheenColorMap,tt=ue&&!!O.sheenRoughnessMap,Pe=!!O.specularMap,nt=!!O.specularColorMap,qe=!!O.specularIntensityMap,yt=Ve&&!!O.transmissionMap,Qt=Ve&&!!O.thicknessMap,Be=!!O.gradientMap,pt=!!O.alphaMap,rt=O.alphaTest>0,zt=!!O.alphaHash,Yt=!!O.extensions;let Bt=cc;O.toneMapped&&(Te===null||Te.isXRRenderTarget===!0)&&(Bt=n.toneMapping);const $e={shaderID:oe,shaderType:O.type,shaderName:O.name,vertexShader:Ae,fragmentShader:be,defines:O.defines,customVertexShaderID:pe,customFragmentShaderID:ge,isRawShaderMaterial:O.isRawShaderMaterial===!0,glslVersion:O.glslVersion,precision:h,batching:Qe,batchingColor:Qe&&H._colorsTexture!==null,instancing:Xe,instancingColor:Xe&&H.instanceColor!==null,instancingMorph:Xe&&H.morphTexture!==null,outputColorSpace:Te===null?n.outputColorSpace:Te.isXRRenderTarget===!0?Te.texture.colorSpace:Sr.workingColorSpace,alphaToCoverage:!!O.alphaToCoverage,map:ot,matcap:bt,envMap:ht,envMapMode:ht&&Q.mapping,envMapCubeUVHeight:re,aoMap:Ce,lightMap:lt,bumpMap:ft,normalMap:et,displacementMap:At,emissiveMap:Lt,normalMapObjectSpace:et&&O.normalMapType===S$,normalMapTangentSpace:et&&O.normalMapType===Xf,packedNormalMap:et&&O.normalMapType===Xf&&AJe(O.normalMap.format),metalnessMap:st,roughnessMap:Ht,anisotropy:Se,anisotropyMap:We,clearcoat:_t,clearcoatMap:ct,clearcoatNormalMap:vt,clearcoatRoughnessMap:Ut,dispersion:It,iridescence:De,iridescenceMap:dt,iridescenceThicknessMap:mt,sheen:ue,sheenColorMap:Ft,sheenRoughnessMap:tt,specularMap:Pe,specularColorMap:nt,specularIntensityMap:qe,transmission:Ve,transmissionMap:yt,thicknessMap:Qt,gradientMap:Be,opaque:O.transparent===!1&&O.blending===ac&&O.alphaToCoverage===!1,alphaMap:pt,alphaTest:rt,alphaHash:zt,combine:O.combine,mapUv:ot&&g(O.map.channel),aoMapUv:Ce&&g(O.aoMap.channel),lightMapUv:lt&&g(O.lightMap.channel),bumpMapUv:ft&&g(O.bumpMap.channel),normalMapUv:et&&g(O.normalMap.channel),displacementMapUv:At&&g(O.displacementMap.channel),emissiveMapUv:Lt&&g(O.emissiveMap.channel),metalnessMapUv:st&&g(O.metalnessMap.channel),roughnessMapUv:Ht&&g(O.roughnessMap.channel),anisotropyMapUv:We&&g(O.anisotropyMap.channel),clearcoatMapUv:ct&&g(O.clearcoatMap.channel),clearcoatNormalMapUv:vt&&g(O.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ut&&g(O.clearcoatRoughnessMap.channel),iridescenceMapUv:dt&&g(O.iridescenceMap.channel),iridescenceThicknessMapUv:mt&&g(O.iridescenceThicknessMap.channel),sheenColorMapUv:Ft&&g(O.sheenColorMap.channel),sheenRoughnessMapUv:tt&&g(O.sheenRoughnessMap.channel),specularMapUv:Pe&&g(O.specularMap.channel),specularColorMapUv:nt&&g(O.specularColorMap.channel),specularIntensityMapUv:qe&&g(O.specularIntensityMap.channel),transmissionMapUv:yt&&g(O.transmissionMap.channel),thicknessMapUv:Qt&&g(O.thicknessMap.channel),alphaMapUv:pt&&g(O.alphaMap.channel),vertexTangents:!!J.attributes.tangent&&(et||Se),vertexNormals:!!J.attributes.normal,vertexColors:O.vertexColors,vertexAlphas:O.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,pointsUvs:H.isPoints===!0&&!!J.attributes.uv&&(ot||pt),fog:!!W,useFog:O.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:O.wireframe===!1&&(O.flatShading===!0||J.attributes.normal===void 0&&et===!1&&(O.isMeshLambertMaterial||O.isMeshPhongMaterial||O.isMeshStandardMaterial||O.isMeshPhysicalMaterial)),sizeAttenuation:O.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:ze,skinning:H.isSkinnedMesh===!0,hasPositionAttribute:J.attributes.position!==void 0,morphTargets:J.morphAttributes.position!==void 0,morphNormals:J.morphAttributes.normal!==void 0,morphColors:J.morphAttributes.color!==void 0,morphTargetsCount:ee,morphTextureStride:me,numDirLights:V.directional.length,numPointLights:V.point.length,numSpotLights:V.spot.length,numSpotLightMaps:V.spotLightMap.length,numRectAreaLights:V.rectArea.length,numHemiLights:V.hemi.length,numDirLightShadows:V.directionalShadowMap.length,numPointLightShadows:V.pointShadowMap.length,numSpotLightShadows:V.spotShadowMap.length,numSpotLightShadowsWithMaps:V.numSpotLightShadowsWithMaps,numLightProbes:V.numLightProbes,numLightProbeGrids:K.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:O.dithering,shadowMapEnabled:n.shadowMap.enabled&&$.length>0,shadowMapType:n.shadowMap.type,toneMapping:Bt,decodeVideoTexture:ot&&O.map.isVideoTexture===!0&&Sr.getTransfer(O.map.colorSpace)===rr,decodeVideoTextureEmissive:Lt&&O.emissiveMap.isVideoTexture===!0&&Sr.getTransfer(O.emissiveMap.colorSpace)===rr,premultipliedAlpha:O.premultipliedAlpha,doubleSided:O.side===ao,flipSided:O.side===Ds,useDepthPacking:O.depthPacking>=0,depthPacking:O.depthPacking||0,index0AttributeName:O.index0AttributeName,extensionClipCullDistance:Yt&&O.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Yt&&O.extensions.multiDraw===!0||Qe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:O.customProgramCacheKey()};return $e.vertexUv1s=l.has(1),$e.vertexUv2s=l.has(2),$e.vertexUv3s=l.has(3),l.clear(),$e}function _(O){const V=[];if(O.shaderID?V.push(O.shaderID):(V.push(O.customVertexShaderID),V.push(O.customFragmentShaderID)),O.defines!==void 0)for(const $ in O.defines)V.push($),V.push(O.defines[$]);return O.isRawShaderMaterial===!1&&(y(V,O),M(V,O),V.push(n.outputColorSpace)),V.push(O.customProgramCacheKey),V.join()}function y(O,V){O.push(V.precision),O.push(V.outputColorSpace),O.push(V.envMapMode),O.push(V.envMapCubeUVHeight),O.push(V.mapUv),O.push(V.alphaMapUv),O.push(V.lightMapUv),O.push(V.aoMapUv),O.push(V.bumpMapUv),O.push(V.normalMapUv),O.push(V.displacementMapUv),O.push(V.emissiveMapUv),O.push(V.metalnessMapUv),O.push(V.roughnessMapUv),O.push(V.anisotropyMapUv),O.push(V.clearcoatMapUv),O.push(V.clearcoatNormalMapUv),O.push(V.clearcoatRoughnessMapUv),O.push(V.iridescenceMapUv),O.push(V.iridescenceThicknessMapUv),O.push(V.sheenColorMapUv),O.push(V.sheenRoughnessMapUv),O.push(V.specularMapUv),O.push(V.specularColorMapUv),O.push(V.specularIntensityMapUv),O.push(V.transmissionMapUv),O.push(V.thicknessMapUv),O.push(V.combine),O.push(V.fogExp2),O.push(V.sizeAttenuation),O.push(V.morphTargetsCount),O.push(V.morphAttributeCount),O.push(V.numDirLights),O.push(V.numPointLights),O.push(V.numSpotLights),O.push(V.numSpotLightMaps),O.push(V.numHemiLights),O.push(V.numRectAreaLights),O.push(V.numDirLightShadows),O.push(V.numPointLightShadows),O.push(V.numSpotLightShadows),O.push(V.numSpotLightShadowsWithMaps),O.push(V.numLightProbes),O.push(V.shadowMapType),O.push(V.toneMapping),O.push(V.numClippingPlanes),O.push(V.numClipIntersection),O.push(V.depthPacking)}function M(O,V){a.disableAll(),V.instancing&&a.enable(0),V.instancingColor&&a.enable(1),V.instancingMorph&&a.enable(2),V.matcap&&a.enable(3),V.envMap&&a.enable(4),V.normalMapObjectSpace&&a.enable(5),V.normalMapTangentSpace&&a.enable(6),V.clearcoat&&a.enable(7),V.iridescence&&a.enable(8),V.alphaTest&&a.enable(9),V.vertexColors&&a.enable(10),V.vertexAlphas&&a.enable(11),V.vertexUv1s&&a.enable(12),V.vertexUv2s&&a.enable(13),V.vertexUv3s&&a.enable(14),V.vertexTangents&&a.enable(15),V.anisotropy&&a.enable(16),V.alphaHash&&a.enable(17),V.batching&&a.enable(18),V.dispersion&&a.enable(19),V.batchingColor&&a.enable(20),V.gradientMap&&a.enable(21),V.packedNormalMap&&a.enable(22),V.vertexNormals&&a.enable(23),O.push(a.mask),a.disableAll(),V.fog&&a.enable(0),V.useFog&&a.enable(1),V.flatShading&&a.enable(2),V.logarithmicDepthBuffer&&a.enable(3),V.reversedDepthBuffer&&a.enable(4),V.skinning&&a.enable(5),V.morphTargets&&a.enable(6),V.morphNormals&&a.enable(7),V.morphColors&&a.enable(8),V.premultipliedAlpha&&a.enable(9),V.shadowMapEnabled&&a.enable(10),V.doubleSided&&a.enable(11),V.flipSided&&a.enable(12),V.useDepthPacking&&a.enable(13),V.dithering&&a.enable(14),V.transmission&&a.enable(15),V.sheen&&a.enable(16),V.opaque&&a.enable(17),V.pointsUvs&&a.enable(18),V.decodeVideoTexture&&a.enable(19),V.decodeVideoTextureEmissive&&a.enable(20),V.alphaToCoverage&&a.enable(21),V.numLightProbeGrids>0&&a.enable(22),V.hasPositionAttribute&&a.enable(23),O.push(a.mask)}function C(O){const V=p[O.type];let $;if(V){const G=Ed[V];$=qg.clone(G.uniforms)}else $=O.uniforms;return $}function k(O,V){let $=u.get(V);return $!==void 0?++$.usedTimes:($=new fJe(n,V,O,i),c.push($),u.set(V,$)),$}function B(O){if(--O.usedTimes===0){const V=c.indexOf(O);c[V]=c[c.length-1],c.pop(),u.delete(O.cacheKey),O.destroy()}}function U(O){o.remove(O)}function z(){o.dispose()}return{getParameters:x,getProgramCacheKey:_,getUniforms:C,acquireProgram:k,releaseProgram:B,releaseShaderCache:U,programs:c,dispose:z}}function vJe(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function r(a){n.delete(a)}function i(a,o,l){n.get(a)[o]=l}function s(){n=new WeakMap}return{has:e,get:t,remove:r,update:i,dispose:s}}function yJe(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function _oe(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function woe(){const n=[];let e=0;const t=[],r=[],i=[];function s(){e=0,t.length=0,r.length=0,i.length=0}function a(h){let p=0;return h.isInstancedMesh&&(p+=2),h.isSkinnedMesh&&(p+=1),p}function o(h,p,g,x,_,y){let M=n[e];return M===void 0?(M={id:h.id,object:h,geometry:p,material:g,materialVariant:a(h),groupOrder:x,renderOrder:h.renderOrder,z:_,group:y},n[e]=M):(M.id=h.id,M.object=h,M.geometry=p,M.material=g,M.materialVariant=a(h),M.groupOrder=x,M.renderOrder=h.renderOrder,M.z=_,M.group=y),e++,M}function l(h,p,g,x,_,y){const M=o(h,p,g,x,_,y);g.transmission>0?r.push(M):g.transparent===!0?i.push(M):t.push(M)}function c(h,p,g,x,_,y){const M=o(h,p,g,x,_,y);g.transmission>0?r.unshift(M):g.transparent===!0?i.unshift(M):t.unshift(M)}function u(h,p,g){t.length>1&&t.sort(h||yJe),r.length>1&&r.sort(p||_oe),i.length>1&&i.sort(p||_oe),g&&(t.reverse(),r.reverse(),i.reverse())}function d(){for(let h=e,p=n.length;h=s.length?(a=new woe,s.push(a)):a=s[i],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function _Je(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new Fe,color:new Fn};break;case"SpotLight":t={position:new Fe,direction:new Fe,color:new Fn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new Fe,color:new Fn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new Fe,skyColor:new Fn,groundColor:new Fn};break;case"RectAreaLight":t={color:new Fn,position:new Fe,halfWidth:new Fe,halfHeight:new Fe};break}return n[e.id]=t,t}}}function wJe(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new en};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new en};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new en,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let SJe=0;function TJe(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function EJe(n){const e=new _Je,t=wJe(),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 c=0;c<9;c++)r.probe.push(new Fe);const i=new Fe,s=new ir,a=new ir;function o(c){let u=0,d=0,h=0;for(let V=0;V<9;V++)r.probe[V].set(0,0,0);let p=0,g=0,x=0,_=0,y=0,M=0,C=0,k=0,B=0,U=0,z=0;c.sort(TJe);for(let V=0,$=c.length;V<$;V++){const G=c[V],H=G.color,K=G.intensity,W=G.distance;let J=null;if(G.shadow&&G.shadow.map&&(G.shadow.map.texture.format===dc?J=G.shadow.map.texture:J=G.shadow.map.depthTexture||G.shadow.map.texture),G.isAmbientLight)u+=H.r*K,d+=H.g*K,h+=H.b*K;else if(G.isLightProbe){for(let ie=0;ie<9;ie++)r.probe[ie].addScaledVector(G.sh.coefficients[ie],K);z++}else if(G.isDirectionalLight){const ie=e.get(G);if(ie.color.copy(G.color).multiplyScalar(G.intensity),G.castShadow){const ae=G.shadow,Q=t.get(G);Q.shadowIntensity=ae.intensity,Q.shadowBias=ae.bias,Q.shadowNormalBias=ae.normalBias,Q.shadowRadius=ae.radius,Q.shadowMapSize=ae.mapSize,r.directionalShadow[p]=Q,r.directionalShadowMap[p]=J,r.directionalShadowMatrix[p]=G.shadow.matrix,M++}r.directional[p]=ie,p++}else if(G.isSpotLight){const ie=e.get(G);ie.position.setFromMatrixPosition(G.matrixWorld),ie.color.copy(H).multiplyScalar(K),ie.distance=W,ie.coneCos=Math.cos(G.angle),ie.penumbraCos=Math.cos(G.angle*(1-G.penumbra)),ie.decay=G.decay,r.spot[x]=ie;const ae=G.shadow;if(G.map&&(r.spotLightMap[B]=G.map,B++,ae.updateMatrices(G),G.castShadow&&U++),r.spotLightMatrix[x]=ae.matrix,G.castShadow){const Q=t.get(G);Q.shadowIntensity=ae.intensity,Q.shadowBias=ae.bias,Q.shadowNormalBias=ae.normalBias,Q.shadowRadius=ae.radius,Q.shadowMapSize=ae.mapSize,r.spotShadow[x]=Q,r.spotShadowMap[x]=J,k++}x++}else if(G.isRectAreaLight){const ie=e.get(G);ie.color.copy(H).multiplyScalar(K),ie.halfWidth.set(G.width*.5,0,0),ie.halfHeight.set(0,G.height*.5,0),r.rectArea[_]=ie,_++}else if(G.isPointLight){const ie=e.get(G);if(ie.color.copy(G.color).multiplyScalar(G.intensity),ie.distance=G.distance,ie.decay=G.decay,G.castShadow){const ae=G.shadow,Q=t.get(G);Q.shadowIntensity=ae.intensity,Q.shadowBias=ae.bias,Q.shadowNormalBias=ae.normalBias,Q.shadowRadius=ae.radius,Q.shadowMapSize=ae.mapSize,Q.shadowCameraNear=ae.camera.near,Q.shadowCameraFar=ae.camera.far,r.pointShadow[g]=Q,r.pointShadowMap[g]=J,r.pointShadowMatrix[g]=G.shadow.matrix,C++}r.point[g]=ie,g++}else if(G.isHemisphereLight){const ie=e.get(G);ie.skyColor.copy(G.color).multiplyScalar(K),ie.groundColor.copy(G.groundColor).multiplyScalar(K),r.hemi[y]=ie,y++}}_>0&&(n.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Yn.LTC_FLOAT_1,r.rectAreaLTC2=Yn.LTC_FLOAT_2):(r.rectAreaLTC1=Yn.LTC_HALF_1,r.rectAreaLTC2=Yn.LTC_HALF_2)),r.ambient[0]=u,r.ambient[1]=d,r.ambient[2]=h;const O=r.hash;(O.directionalLength!==p||O.pointLength!==g||O.spotLength!==x||O.rectAreaLength!==_||O.hemiLength!==y||O.numDirectionalShadows!==M||O.numPointShadows!==C||O.numSpotShadows!==k||O.numSpotMaps!==B||O.numLightProbes!==z)&&(r.directional.length=p,r.spot.length=x,r.rectArea.length=_,r.point.length=g,r.hemi.length=y,r.directionalShadow.length=M,r.directionalShadowMap.length=M,r.pointShadow.length=C,r.pointShadowMap.length=C,r.spotShadow.length=k,r.spotShadowMap.length=k,r.directionalShadowMatrix.length=M,r.pointShadowMatrix.length=C,r.spotLightMatrix.length=k+B-U,r.spotLightMap.length=B,r.numSpotLightShadowsWithMaps=U,r.numLightProbes=z,O.directionalLength=p,O.pointLength=g,O.spotLength=x,O.rectAreaLength=_,O.hemiLength=y,O.numDirectionalShadows=M,O.numPointShadows=C,O.numSpotShadows=k,O.numSpotMaps=B,O.numLightProbes=z,r.version=SJe++)}function l(c,u){let d=0,h=0,p=0,g=0,x=0;const _=u.matrixWorldInverse;for(let y=0,M=c.length;y=a.length?(o=new Soe(n),a.push(o)):o=a[s],o}function r(){e=new WeakMap}return{get:t,dispose:r}}const MJe=`void main() { gl_Position = vec4( position, 1.0 ); }`,CJe=`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 ); }`,PJe=[new Fe(1,0,0),new Fe(-1,0,0),new Fe(0,1,0),new Fe(0,-1,0),new Fe(0,0,1),new Fe(0,0,-1)],RJe=[new Fe(0,-1,0),new Fe(0,-1,0),new Fe(0,0,1),new Fe(0,0,-1),new Fe(0,-1,0),new Fe(0,-1,0)],Toe=new ir,Iw=new Fe,AF=new Fe;function LJe(n,e,t){let r=new Vg;const i=new en,s=new en,a=new gr,o=new tR,l=new nR,c={},u=t.maxTextureSize,d={[id]:Ds,[Ds]:id,[ao]:ao},h=new Dl({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new en},radius:{value:4}},vertexShader:MJe,fragmentShader:CJe}),p=h.clone();p.defines.HORIZONTAL_PASS=1;const g=new Pr;g.setAttribute("position",new Gi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new ui(g,h),_=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=EA;let y=this.type;this.render=function(U,z,O){if(_.enabled===!1||_.autoUpdate===!1&&_.needsUpdate===!1||U.length===0)return;this.type===y_&&(sn("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=EA);const V=n.getRenderTarget(),$=n.getActiveCubeFace(),G=n.getActiveMipmapLevel(),H=n.state;H.setBlending(Yl),H.buffers.depth.getReversed()===!0?H.buffers.color.setClear(0,0,0,0):H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);const K=y!==this.type;K&&z.traverse(function(W){W.material&&(Array.isArray(W.material)?W.material.forEach(J=>J.needsUpdate=!0):W.material.needsUpdate=!0)});for(let W=0,J=U.length;Wu||i.y>u)&&(i.x>u&&(s.x=Math.floor(u/Q.x),i.x=s.x*Q.x,ae.mapSize.x=s.x),i.y>u&&(s.y=Math.floor(u/Q.y),i.y=s.y*Q.y,ae.mapSize.y=s.y));const re=n.state.buffers.depth.getReversed();if(ae.camera._reversedDepth=re,ae.map===null||K===!0){if(ae.map!==null&&(ae.map.depthTexture!==null&&(ae.map.depthTexture.dispose(),ae.map.depthTexture=null),ae.map.dispose()),this.type===Vf){if(ie.isPointLight){sn("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}ae.map=new dh(i.x,i.y,{format:dc,type:ba,minFilter:Ci,magFilter:Ci,generateMipmaps:!1}),ae.map.texture.name=ie.name+".shadowMap",ae.map.depthTexture=new zc(i.x,i.y,ea),ae.map.depthTexture.name=ie.name+".shadowMapDepth",ae.map.depthTexture.format=hc,ae.map.depthTexture.compareFunction=null,ae.map.depthTexture.minFilter=Ss,ae.map.depthTexture.magFilter=Ss}else ie.isPointLight?(ae.map=new dW(i.x),ae.map.depthTexture=new L$(i.x,xs)):(ae.map=new dh(i.x,i.y),ae.map.depthTexture=new zc(i.x,i.y,xs)),ae.map.depthTexture.name=ie.name+".shadowMap",ae.map.depthTexture.format=hc,this.type===EA?(ae.map.depthTexture.compareFunction=re?mm:n1,ae.map.depthTexture.minFilter=Ci,ae.map.depthTexture.magFilter=Ci):(ae.map.depthTexture.compareFunction=null,ae.map.depthTexture.minFilter=Ss,ae.map.depthTexture.magFilter=Ss);ae.camera.updateProjectionMatrix()}const oe=ae.map.isWebGLCubeRenderTarget?6:1;for(let fe=0;fe0||z.map&&z.alphaTest>0||z.alphaToCoverage===!0){const H=$.uuid,K=z.uuid;let W=c[H];W===void 0&&(W={},c[H]=W);let J=W[K];J===void 0&&(J=$.clone(),W[K]=J,z.addEventListener("dispose",B)),$=J}if($.visible=z.visible,$.wireframe=z.wireframe,V===Vf?$.side=z.shadowSide!==null?z.shadowSide:z.side:$.side=z.shadowSide!==null?z.shadowSide:d[z.side],$.alphaMap=z.alphaMap,$.alphaTest=z.alphaToCoverage===!0?.5:z.alphaTest,$.map=z.map,$.clipShadows=z.clipShadows,$.clippingPlanes=z.clippingPlanes,$.clipIntersection=z.clipIntersection,$.displacementMap=z.displacementMap,$.displacementScale=z.displacementScale,$.displacementBias=z.displacementBias,$.wireframeLinewidth=z.wireframeLinewidth,$.linewidth=z.linewidth,O.isPointLight===!0&&$.isMeshDistanceMaterial===!0){const H=n.properties.get($);H.light=O}return $}function k(U,z,O,V,$){if(U.visible===!1)return;if(U.layers.test(z.layers)&&(U.isMesh||U.isLine||U.isPoints)&&(U.castShadow||U.receiveShadow&&$===Vf)&&(!U.frustumCulled||r.intersectsObject(U))){U.modelViewMatrix.multiplyMatrices(O.matrixWorldInverse,U.matrixWorld);const K=e.update(U),W=U.material;if(Array.isArray(W)){const J=K.groups;for(let ie=0,ae=J.length;ie=1):re.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(re)[1]),ae=Q>=2);let oe=null,fe={};const ee=n.getParameter(n.SCISSOR_BOX),me=n.getParameter(n.VIEWPORT),Ae=new gr().fromArray(ee),be=new gr().fromArray(me);function pe(Be,pt,rt,zt){const Yt=new Uint8Array(4),Bt=n.createTexture();n.bindTexture(Be,Bt),n.texParameteri(Be,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(Be,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let $e=0;$e"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new en,u=new WeakMap,d=new Set;let h;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(De,ue){return g?new OffscreenCanvas(De,ue):aS("canvas")}function _(De,ue,Ve){let We=1;const ct=It(De);if((ct.width>Ve||ct.height>Ve)&&(We=Ve/Math.max(ct.width,ct.height)),We<1)if(typeof HTMLImageElement<"u"&&De instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&De instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&De instanceof ImageBitmap||typeof VideoFrame<"u"&&De instanceof VideoFrame){const vt=Math.floor(We*ct.width),Ut=Math.floor(We*ct.height);h===void 0&&(h=x(vt,Ut));const dt=ue?x(vt,Ut):h;return dt.width=vt,dt.height=Ut,dt.getContext("2d").drawImage(De,0,0,vt,Ut),sn("WebGLRenderer: Texture has been resized from ("+ct.width+"x"+ct.height+") to ("+vt+"x"+Ut+")."),dt}else return"data"in De&&sn("WebGLRenderer: Image in DataTexture is too big ("+ct.width+"x"+ct.height+")."),De;return De}function y(De){return De.generateMipmaps}function M(De){n.generateMipmap(De)}function C(De){return De.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:De.isWebGL3DRenderTarget?n.TEXTURE_3D:De.isWebGLArrayRenderTarget||De.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function k(De,ue,Ve,We,ct,vt=!1){if(De!==null){if(n[De]!==void 0)return n[De];sn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+De+"'")}let Ut;We&&(Ut=e.get("EXT_texture_norm16"),Ut||sn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let dt=ue;if(ue===n.RED&&(Ve===n.FLOAT&&(dt=n.R32F),Ve===n.HALF_FLOAT&&(dt=n.R16F),Ve===n.UNSIGNED_BYTE&&(dt=n.R8),Ve===n.UNSIGNED_SHORT&&Ut&&(dt=Ut.R16_EXT),Ve===n.SHORT&&Ut&&(dt=Ut.R16_SNORM_EXT)),ue===n.RED_INTEGER&&(Ve===n.UNSIGNED_BYTE&&(dt=n.R8UI),Ve===n.UNSIGNED_SHORT&&(dt=n.R16UI),Ve===n.UNSIGNED_INT&&(dt=n.R32UI),Ve===n.BYTE&&(dt=n.R8I),Ve===n.SHORT&&(dt=n.R16I),Ve===n.INT&&(dt=n.R32I)),ue===n.RG&&(Ve===n.FLOAT&&(dt=n.RG32F),Ve===n.HALF_FLOAT&&(dt=n.RG16F),Ve===n.UNSIGNED_BYTE&&(dt=n.RG8),Ve===n.UNSIGNED_SHORT&&Ut&&(dt=Ut.RG16_EXT),Ve===n.SHORT&&Ut&&(dt=Ut.RG16_SNORM_EXT)),ue===n.RG_INTEGER&&(Ve===n.UNSIGNED_BYTE&&(dt=n.RG8UI),Ve===n.UNSIGNED_SHORT&&(dt=n.RG16UI),Ve===n.UNSIGNED_INT&&(dt=n.RG32UI),Ve===n.BYTE&&(dt=n.RG8I),Ve===n.SHORT&&(dt=n.RG16I),Ve===n.INT&&(dt=n.RG32I)),ue===n.RGB_INTEGER&&(Ve===n.UNSIGNED_BYTE&&(dt=n.RGB8UI),Ve===n.UNSIGNED_SHORT&&(dt=n.RGB16UI),Ve===n.UNSIGNED_INT&&(dt=n.RGB32UI),Ve===n.BYTE&&(dt=n.RGB8I),Ve===n.SHORT&&(dt=n.RGB16I),Ve===n.INT&&(dt=n.RGB32I)),ue===n.RGBA_INTEGER&&(Ve===n.UNSIGNED_BYTE&&(dt=n.RGBA8UI),Ve===n.UNSIGNED_SHORT&&(dt=n.RGBA16UI),Ve===n.UNSIGNED_INT&&(dt=n.RGBA32UI),Ve===n.BYTE&&(dt=n.RGBA8I),Ve===n.SHORT&&(dt=n.RGBA16I),Ve===n.INT&&(dt=n.RGBA32I)),ue===n.RGB&&(Ve===n.UNSIGNED_SHORT&&Ut&&(dt=Ut.RGB16_EXT),Ve===n.SHORT&&Ut&&(dt=Ut.RGB16_SNORM_EXT),Ve===n.UNSIGNED_INT_5_9_9_9_REV&&(dt=n.RGB9_E5),Ve===n.UNSIGNED_INT_10F_11F_11F_REV&&(dt=n.R11F_G11F_B10F)),ue===n.RGBA){const mt=vt?Lv:Sr.getTransfer(ct);Ve===n.FLOAT&&(dt=n.RGBA32F),Ve===n.HALF_FLOAT&&(dt=n.RGBA16F),Ve===n.UNSIGNED_BYTE&&(dt=mt===rr?n.SRGB8_ALPHA8:n.RGBA8),Ve===n.UNSIGNED_SHORT&&Ut&&(dt=Ut.RGBA16_EXT),Ve===n.SHORT&&Ut&&(dt=Ut.RGBA16_SNORM_EXT),Ve===n.UNSIGNED_SHORT_4_4_4_4&&(dt=n.RGBA4),Ve===n.UNSIGNED_SHORT_5_5_5_1&&(dt=n.RGB5_A1)}return(dt===n.R16F||dt===n.R32F||dt===n.RG16F||dt===n.RG32F||dt===n.RGBA16F||dt===n.RGBA32F)&&e.get("EXT_color_buffer_float"),dt}function B(De,ue){let Ve;return De?ue===null||ue===xs||ue===Od?Ve=n.DEPTH24_STENCIL8:ue===ea?Ve=n.DEPTH32F_STENCIL8:ue===Jh&&(Ve=n.DEPTH24_STENCIL8,sn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):ue===null||ue===xs||ue===Od?Ve=n.DEPTH_COMPONENT24:ue===ea?Ve=n.DEPTH_COMPONENT32F:ue===Jh&&(Ve=n.DEPTH_COMPONENT16),Ve}function U(De,ue){return y(De)===!0||De.isFramebufferTexture&&De.minFilter!==Ss&&De.minFilter!==Ci?Math.log2(Math.max(ue.width,ue.height))+1:De.mipmaps!==void 0&&De.mipmaps.length>0?De.mipmaps.length:De.isCompressedTexture&&Array.isArray(De.image)?ue.mipmaps.length:1}function z(De){const ue=De.target;ue.removeEventListener("dispose",z),V(ue),ue.isVideoTexture&&u.delete(ue),ue.isHTMLTexture&&d.delete(ue)}function O(De){const ue=De.target;ue.removeEventListener("dispose",O),G(ue)}function V(De){const ue=r.get(De);if(ue.__webglInit===void 0)return;const Ve=De.source,We=p.get(Ve);if(We){const ct=We[ue.__cacheKey];ct.usedTimes--,ct.usedTimes===0&&$(De),Object.keys(We).length===0&&p.delete(Ve)}r.remove(De)}function $(De){const ue=r.get(De);n.deleteTexture(ue.__webglTexture);const Ve=De.source,We=p.get(Ve);delete We[ue.__cacheKey],a.memory.textures--}function G(De){const ue=r.get(De);if(De.depthTexture&&(De.depthTexture.dispose(),r.remove(De.depthTexture)),De.isWebGLCubeRenderTarget)for(let We=0;We<6;We++){if(Array.isArray(ue.__webglFramebuffer[We]))for(let ct=0;ct=i.maxTextures&&sn("WebGLTextures: Trying to use "+De+" texture units while this GPU supports only "+i.maxTextures),H+=1,De}function ae(De){const ue=[];return ue.push(De.wrapS),ue.push(De.wrapT),ue.push(De.wrapR||0),ue.push(De.magFilter),ue.push(De.minFilter),ue.push(De.anisotropy),ue.push(De.internalFormat),ue.push(De.format),ue.push(De.type),ue.push(De.generateMipmaps),ue.push(De.premultiplyAlpha),ue.push(De.flipY),ue.push(De.unpackAlignment),ue.push(De.colorSpace),ue.join()}function Q(De,ue){const Ve=r.get(De);if(De.isVideoTexture&&Se(De),De.isRenderTargetTexture===!1&&De.isExternalTexture!==!0&&De.version>0&&Ve.__version!==De.version){const We=De.image;if(We===null)sn("WebGLRenderer: Texture marked for update but no image data found.");else if(We.complete===!1)sn("WebGLRenderer: Texture marked for update but image is incomplete");else{ze(Ve,De,ue);return}}else De.isExternalTexture&&(Ve.__webglTexture=De.sourceTexture?De.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,Ve.__webglTexture,n.TEXTURE0+ue)}function re(De,ue){const Ve=r.get(De);if(De.isRenderTargetTexture===!1&&De.version>0&&Ve.__version!==De.version){ze(Ve,De,ue);return}else De.isExternalTexture&&(Ve.__webglTexture=De.sourceTexture?De.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,Ve.__webglTexture,n.TEXTURE0+ue)}function oe(De,ue){const Ve=r.get(De);if(De.isRenderTargetTexture===!1&&De.version>0&&Ve.__version!==De.version){ze(Ve,De,ue);return}t.bindTexture(n.TEXTURE_3D,Ve.__webglTexture,n.TEXTURE0+ue)}function fe(De,ue){const Ve=r.get(De);if(De.isCubeDepthTexture!==!0&&De.version>0&&Ve.__version!==De.version){Xe(Ve,De,ue);return}t.bindTexture(n.TEXTURE_CUBE_MAP,Ve.__webglTexture,n.TEXTURE0+ue)}const ee={[Fg]:n.REPEAT,[uc]:n.CLAMP_TO_EDGE,[Bg]:n.MIRRORED_REPEAT},me={[Ss]:n.NEAREST,[JS]:n.NEAREST_MIPMAP_NEAREST,[qf]:n.NEAREST_MIPMAP_LINEAR,[Ci]:n.LINEAR,[PA]:n.LINEAR_MIPMAP_NEAREST,[Bc]:n.LINEAR_MIPMAP_LINEAR},Ae={[CP]:n.NEVER,[LP]:n.ALWAYS,[t6]:n.LESS,[n1]:n.LEQUAL,[PP]:n.EQUAL,[mm]:n.GEQUAL,[t3]:n.GREATER,[RP]:n.NOTEQUAL};function be(De,ue){if(ue.type===ea&&e.has("OES_texture_float_linear")===!1&&(ue.magFilter===Ci||ue.magFilter===PA||ue.magFilter===qf||ue.magFilter===Bc||ue.minFilter===Ci||ue.minFilter===PA||ue.minFilter===qf||ue.minFilter===Bc)&&sn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(De,n.TEXTURE_WRAP_S,ee[ue.wrapS]),n.texParameteri(De,n.TEXTURE_WRAP_T,ee[ue.wrapT]),(De===n.TEXTURE_3D||De===n.TEXTURE_2D_ARRAY)&&n.texParameteri(De,n.TEXTURE_WRAP_R,ee[ue.wrapR]),n.texParameteri(De,n.TEXTURE_MAG_FILTER,me[ue.magFilter]),n.texParameteri(De,n.TEXTURE_MIN_FILTER,me[ue.minFilter]),ue.compareFunction&&(n.texParameteri(De,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(De,n.TEXTURE_COMPARE_FUNC,Ae[ue.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(ue.magFilter===Ss||ue.minFilter!==qf&&ue.minFilter!==Bc||ue.type===ea&&e.has("OES_texture_float_linear")===!1)return;if(ue.anisotropy>1||r.get(ue).__currentAnisotropy){const Ve=e.get("EXT_texture_filter_anisotropic");n.texParameterf(De,Ve.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(ue.anisotropy,i.getMaxAnisotropy())),r.get(ue).__currentAnisotropy=ue.anisotropy}}}function pe(De,ue){let Ve=!1;De.__webglInit===void 0&&(De.__webglInit=!0,ue.addEventListener("dispose",z));const We=ue.source;let ct=p.get(We);ct===void 0&&(ct={},p.set(We,ct));const vt=ae(ue);if(vt!==De.__cacheKey){ct[vt]===void 0&&(ct[vt]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,Ve=!0),ct[vt].usedTimes++;const Ut=ct[De.__cacheKey];Ut!==void 0&&(ct[De.__cacheKey].usedTimes--,Ut.usedTimes===0&&$(ue)),De.__cacheKey=vt,De.__webglTexture=ct[vt].texture}return Ve}function ge(De,ue,Ve){return Math.floor(Math.floor(De/Ve)/ue)}function Te(De,ue,Ve,We){const vt=De.updateRanges;if(vt.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,ue.width,ue.height,Ve,We,ue.data);else{vt.sort((tt,Pe)=>tt.start-Pe.start);let Ut=0;for(let tt=1;tt0){yt&&Qt&&t.texStorage2D(n.TEXTURE_2D,pt,Pe,qe[0].width,qe[0].height);for(let rt=0,zt=qe.length;rt0){const Yt=YM(nt.width,nt.height,ue.format,ue.type);for(const Bt of ue.layerUpdates){const $e=nt.data.subarray(Bt*Yt/nt.data.BYTES_PER_ELEMENT,(Bt+1)*Yt/nt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,rt,0,0,Bt,nt.width,nt.height,1,Ft,$e)}ue.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,rt,0,0,0,nt.width,nt.height,mt.depth,Ft,nt.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,rt,Pe,nt.width,nt.height,mt.depth,0,nt.data,0,0);else sn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else yt?Be&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,rt,0,0,0,nt.width,nt.height,mt.depth,Ft,tt,nt.data):t.texImage3D(n.TEXTURE_2D_ARRAY,rt,Pe,nt.width,nt.height,mt.depth,0,Ft,tt,nt.data)}else{yt&&Qt&&t.texStorage2D(n.TEXTURE_2D,pt,Pe,qe[0].width,qe[0].height);for(let rt=0,zt=qe.length;rt0){const rt=YM(mt.width,mt.height,ue.format,ue.type);for(const zt of ue.layerUpdates){const Yt=mt.data.subarray(zt*rt/mt.data.BYTES_PER_ELEMENT,(zt+1)*rt/mt.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,zt,mt.width,mt.height,1,Ft,tt,Yt)}ue.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,mt.width,mt.height,mt.depth,Ft,tt,mt.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,Pe,mt.width,mt.height,mt.depth,0,Ft,tt,mt.data);else if(ue.isData3DTexture)yt?(Qt&&t.texStorage3D(n.TEXTURE_3D,pt,Pe,mt.width,mt.height,mt.depth),Be&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,mt.width,mt.height,mt.depth,Ft,tt,mt.data)):t.texImage3D(n.TEXTURE_3D,0,Pe,mt.width,mt.height,mt.depth,0,Ft,tt,mt.data);else if(ue.isFramebufferTexture){if(Qt)if(yt)t.texStorage2D(n.TEXTURE_2D,pt,Pe,mt.width,mt.height);else{let rt=mt.width,zt=mt.height;for(let Yt=0;Yt>=1,zt>>=1}}else if(ue.isHTMLTexture){if("texElementImage2D"in n){const rt=n.canvas;if(rt.hasAttribute("layoutsubtree")||rt.setAttribute("layoutsubtree","true"),mt.parentNode!==rt){rt.appendChild(mt),d.add(ue),rt.onpaint=zt=>{const Yt=zt.changedElements;for(const Bt of d)Yt.includes(Bt.image)&&(Bt.needsUpdate=!0)},rt.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,mt);else{const Yt=n.RGBA,Bt=n.RGBA,$e=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Yt,Bt,$e,mt)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(qe.length>0){if(yt&&Qt){const rt=It(qe[0]);t.texStorage2D(n.TEXTURE_2D,pt,Pe,rt.width,rt.height)}for(let rt=0,zt=qe.length;rt0&&zt++;const Bt=It(Pe[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,zt,Qt,Bt.width,Bt.height)}for(let Bt=0;Bt<6;Bt++)if(tt){Be?rt&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Bt,0,0,0,Pe[Bt].width,Pe[Bt].height,qe,yt,Pe[Bt].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Bt,0,Qt,Pe[Bt].width,Pe[Bt].height,0,qe,yt,Pe[Bt].data);for(let $e=0;$e>vt),nt=Math.max(1,ue.height>>vt);ct===n.TEXTURE_3D||ct===n.TEXTURE_2D_ARRAY?t.texImage3D(ct,vt,mt,Pe,nt,ue.depth,0,Ut,dt,null):t.texImage2D(ct,vt,mt,Pe,nt,0,Ut,dt,null)}t.bindFramebuffer(n.FRAMEBUFFER,De),Ht(ue)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,We,ct,tt.__webglTexture,0,st(ue)):(ct===n.TEXTURE_2D||ct>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&ct<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,We,ct,tt.__webglTexture,vt),t.bindFramebuffer(n.FRAMEBUFFER,null)}function ot(De,ue,Ve){if(n.bindRenderbuffer(n.RENDERBUFFER,De),ue.depthBuffer){const We=ue.depthTexture,ct=We&&We.isDepthTexture?We.type:null,vt=B(ue.stencilBuffer,ct),Ut=ue.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;Ht(ue)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,st(ue),vt,ue.width,ue.height):Ve?n.renderbufferStorageMultisample(n.RENDERBUFFER,st(ue),vt,ue.width,ue.height):n.renderbufferStorage(n.RENDERBUFFER,vt,ue.width,ue.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,Ut,n.RENDERBUFFER,De)}else{const We=ue.textures;for(let ct=0;ct{delete ue.__boundDepthTexture,delete ue.__depthDisposeCallback,We.removeEventListener("dispose",ct)};We.addEventListener("dispose",ct),ue.__depthDisposeCallback=ct}ue.__boundDepthTexture=We}if(De.depthTexture&&!ue.__autoAllocateDepthBuffer)if(Ve)for(let We=0;We<6;We++)bt(ue.__webglFramebuffer[We],De,We);else{const We=De.texture.mipmaps;We&&We.length>0?bt(ue.__webglFramebuffer[0],De,0):bt(ue.__webglFramebuffer,De,0)}else if(Ve){ue.__webglDepthbuffer=[];for(let We=0;We<6;We++)if(t.bindFramebuffer(n.FRAMEBUFFER,ue.__webglFramebuffer[We]),ue.__webglDepthbuffer[We]===void 0)ue.__webglDepthbuffer[We]=n.createRenderbuffer(),ot(ue.__webglDepthbuffer[We],De,!1);else{const ct=De.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,vt=ue.__webglDepthbuffer[We];n.bindRenderbuffer(n.RENDERBUFFER,vt),n.framebufferRenderbuffer(n.FRAMEBUFFER,ct,n.RENDERBUFFER,vt)}}else{const We=De.texture.mipmaps;if(We&&We.length>0?t.bindFramebuffer(n.FRAMEBUFFER,ue.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,ue.__webglFramebuffer),ue.__webglDepthbuffer===void 0)ue.__webglDepthbuffer=n.createRenderbuffer(),ot(ue.__webglDepthbuffer,De,!1);else{const ct=De.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,vt=ue.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,vt),n.framebufferRenderbuffer(n.FRAMEBUFFER,ct,n.RENDERBUFFER,vt)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Ce(De,ue,Ve){const We=r.get(De);ue!==void 0&&Qe(We.__webglFramebuffer,De,De.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),Ve!==void 0&&ht(De)}function lt(De){const ue=De.texture,Ve=r.get(De),We=r.get(ue);De.addEventListener("dispose",O);const ct=De.textures,vt=De.isWebGLCubeRenderTarget===!0,Ut=ct.length>1;if(Ut||(We.__webglTexture===void 0&&(We.__webglTexture=n.createTexture()),We.__version=ue.version,a.memory.textures++),vt){Ve.__webglFramebuffer=[];for(let dt=0;dt<6;dt++)if(ue.mipmaps&&ue.mipmaps.length>0){Ve.__webglFramebuffer[dt]=[];for(let mt=0;mt0){Ve.__webglFramebuffer=[];for(let dt=0;dt0&&Ht(De)===!1){Ve.__webglMultisampledFramebuffer=n.createFramebuffer(),Ve.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,Ve.__webglMultisampledFramebuffer);for(let dt=0;dt0)for(let mt=0;mt0)for(let mt=0;mt0){if(Ht(De)===!1){const ue=De.textures,Ve=De.width,We=De.height;let ct=n.COLOR_BUFFER_BIT;const vt=De.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ut=r.get(De),dt=ue.length>1;if(dt)for(let Ft=0;Ft0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ut.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,Ut.__webglFramebuffer);for(let Ft=0;Ft0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&ue.__useRenderToTexture!==!1}function Se(De){const ue=a.render.frame;u.get(De)!==ue&&(u.set(De,ue),De.update())}function _t(De,ue){const Ve=De.colorSpace,We=De.format,ct=De.type;return De.isCompressedTexture===!0||De.isVideoTexture===!0||Ve!==Rv&&Ve!==Rd&&(Sr.getTransfer(Ve)===rr?(We!==Oa||ct!==ma)&&sn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):on("WebGLTextures: Unsupported texture color space:",Ve)),ue}function It(De){return typeof HTMLImageElement<"u"&&De instanceof HTMLImageElement?(c.width=De.naturalWidth||De.width,c.height=De.naturalHeight||De.height):typeof VideoFrame<"u"&&De instanceof VideoFrame?(c.width=De.displayWidth,c.height=De.displayHeight):(c.width=De.width,c.height=De.height),c}this.allocateTextureUnit=ie,this.resetTextureUnits=K,this.getTextureUnits=W,this.setTextureUnits=J,this.setTexture2D=Q,this.setTexture2DArray=re,this.setTexture3D=oe,this.setTextureCube=fe,this.rebindTextures=Ce,this.setupRenderTarget=lt,this.updateRenderTargetMipmap=ft,this.updateMultisampleRenderTarget=Lt,this.setupDepthRenderbuffer=ht,this.setupFrameBufferTexture=Qe,this.useMultisampledRTT=Ht,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function kxe(n,e){function t(r,i=Rd){let s;const a=Sr.getTransfer(i);if(r===ma)return n.UNSIGNED_BYTE;if(r===I3)return n.UNSIGNED_SHORT_4_4_4_4;if(r===D3)return n.UNSIGNED_SHORT_5_5_5_1;if(r===O3)return n.UNSIGNED_INT_5_9_9_9_REV;if(r===j3)return n.UNSIGNED_INT_10F_11F_11F_REV;if(r===gg)return n.BYTE;if(r===Ag)return n.SHORT;if(r===Jh)return n.UNSIGNED_SHORT;if(r===ml)return n.INT;if(r===xs)return n.UNSIGNED_INT;if(r===ea)return n.FLOAT;if(r===ba)return n.HALF_FLOAT;if(r===e6)return n.ALPHA;if(r===t2)return n.RGB;if(r===Oa)return n.RGBA;if(r===hc)return n.DEPTH_COMPONENT;if(r===mu)return n.DEPTH_STENCIL;if(r===e1)return n.RED;if(r===Tm)return n.RED_INTEGER;if(r===dc)return n.RG;if(r===t1)return n.RG_INTEGER;if(r===Jv)return n.RGBA_INTEGER;if(r===xg||r===vg||r===yg||r===bg)if(a===rr)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===xg)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===vg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===yg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===bg)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===xg)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===vg)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===yg)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===bg)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Q_||r===K_||r===J_||r===e3)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===Q_)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===K_)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===J_)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===e3)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===sv||r===av||r===ov||r===lv||r===cv||r===Ug||r===uv)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===sv||r===av)return a===rr?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===ov)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(r===lv)return s.COMPRESSED_R11_EAC;if(r===cv)return s.COMPRESSED_SIGNED_R11_EAC;if(r===Ug)return s.COMPRESSED_RG11_EAC;if(r===uv)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(r===dv||r===hv||r===fv||r===pv||r===mv||r===gv||r===Av||r===xv||r===vv||r===yv||r===bv||r===_v||r===wv||r===Sv)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===dv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===hv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===fv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===pv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===mv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===gv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===Av)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===xv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===vv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===yv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===bv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===_v)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===wv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===Sv)return a===rr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===Tv||r===Ev||r===Nv)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===Tv)return a===rr?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===Ev)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===Nv)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===Mv||r===Cv||r===zg||r===Pv)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===Mv)return s.COMPRESSED_RED_RGTC1_EXT;if(r===Cv)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===zg)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===Pv)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Od?n.UNSIGNED_INT_24_8:n[r]!==void 0?n[r]:null}return{convert:t}}const DJe=` void main() { gl_Position = vec4( position, 1.0 ); }`,OJe=` 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; } }`;class jJe{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const r=new k$(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,r=new Dl({vertexShader:DJe,fragmentShader:OJe,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ui(new Nm(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class FJe extends zd{constructor(e,t){super();const r=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,p=null,g=null;const x=typeof XRWebGLBinding<"u",_=new jJe,y={},M=t.getContextAttributes();let C=null,k=null;const B=[],U=[],z=new en;let O=null;const V=new Ga;V.viewport=new gr;const $=new Ga;$.viewport=new gr;const G=[V,$],H=new aW;let K=null,W=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(pe){let ge=B[pe];return ge===void 0&&(ge=new o4,B[pe]=ge),ge.getTargetRaySpace()},this.getControllerGrip=function(pe){let ge=B[pe];return ge===void 0&&(ge=new o4,B[pe]=ge),ge.getGripSpace()},this.getHand=function(pe){let ge=B[pe];return ge===void 0&&(ge=new o4,B[pe]=ge),ge.getHandSpace()};function J(pe){const ge=U.indexOf(pe.inputSource);if(ge===-1)return;const Te=B[ge];Te!==void 0&&(Te.update(pe.inputSource,pe.frame,c||a),Te.dispatchEvent({type:pe.type,data:pe.inputSource}))}function ie(){i.removeEventListener("select",J),i.removeEventListener("selectstart",J),i.removeEventListener("selectend",J),i.removeEventListener("squeeze",J),i.removeEventListener("squeezestart",J),i.removeEventListener("squeezeend",J),i.removeEventListener("end",ie),i.removeEventListener("inputsourceschange",ae);for(let pe=0;pe=0&&(U[ze]=null,B[ze].disconnect(Te))}for(let ge=0;ge=U.length){U.push(Te),ze=Qe;break}else if(U[Qe]===null){U[Qe]=Te,ze=Qe;break}if(ze===-1)break}const Xe=B[ze];Xe&&Xe.connect(Te)}}const Q=new Fe,re=new Fe;function oe(pe,ge,Te){Q.setFromMatrixPosition(ge.matrixWorld),re.setFromMatrixPosition(Te.matrixWorld);const ze=Q.distanceTo(re),Xe=ge.projectionMatrix.elements,Qe=Te.projectionMatrix.elements,ot=Xe[14]/(Xe[10]-1),bt=Xe[14]/(Xe[10]+1),ht=(Xe[9]+1)/Xe[5],Ce=(Xe[9]-1)/Xe[5],lt=(Xe[8]-1)/Xe[0],ft=(Qe[8]+1)/Qe[0],et=ot*lt,At=ot*ft,Lt=ze/(-lt+ft),st=Lt*-lt;if(ge.matrixWorld.decompose(pe.position,pe.quaternion,pe.scale),pe.translateX(st),pe.translateZ(Lt),pe.matrixWorld.compose(pe.position,pe.quaternion,pe.scale),pe.matrixWorldInverse.copy(pe.matrixWorld).invert(),Xe[10]===-1)pe.projectionMatrix.copy(ge.projectionMatrix),pe.projectionMatrixInverse.copy(ge.projectionMatrixInverse);else{const Ht=ot+Lt,Se=bt+Lt,_t=et-st,It=At+(ze-st),De=ht*bt/Se*Ht,ue=Ce*bt/Se*Ht;pe.projectionMatrix.makePerspective(_t,It,De,ue,Ht,Se),pe.projectionMatrixInverse.copy(pe.projectionMatrix).invert()}}function fe(pe,ge){ge===null?pe.matrixWorld.copy(pe.matrix):pe.matrixWorld.multiplyMatrices(ge.matrixWorld,pe.matrix),pe.matrixWorldInverse.copy(pe.matrixWorld).invert()}this.updateCamera=function(pe){if(i===null)return;let ge=pe.near,Te=pe.far;_.texture!==null&&(_.depthNear>0&&(ge=_.depthNear),_.depthFar>0&&(Te=_.depthFar)),H.near=$.near=V.near=ge,H.far=$.far=V.far=Te,(K!==H.near||W!==H.far)&&(i.updateRenderState({depthNear:H.near,depthFar:H.far}),K=H.near,W=H.far),H.layers.mask=pe.layers.mask|6,V.layers.mask=H.layers.mask&-5,$.layers.mask=H.layers.mask&-3;const ze=pe.parent,Xe=H.cameras;fe(H,ze);for(let Qe=0;Qe0&&(_.alphaTest.value=y.alphaTest);const M=e.get(y),C=M.envMap,k=M.envMapRotation;C&&(_.envMap.value=C,_.envMapRotation.value.setFromMatrix4(BJe.makeRotationFromEuler(k)).transpose(),C.isCubeTexture&&C.isRenderTargetTexture===!1&&_.envMapRotation.value.premultiply(Ixe),_.reflectivity.value=y.reflectivity,_.ior.value=y.ior,_.refractionRatio.value=y.refractionRatio),y.lightMap&&(_.lightMap.value=y.lightMap,_.lightMapIntensity.value=y.lightMapIntensity,t(y.lightMap,_.lightMapTransform)),y.aoMap&&(_.aoMap.value=y.aoMap,_.aoMapIntensity.value=y.aoMapIntensity,t(y.aoMap,_.aoMapTransform))}function a(_,y){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,y.map&&(_.map.value=y.map,t(y.map,_.mapTransform))}function o(_,y){_.dashSize.value=y.dashSize,_.totalSize.value=y.dashSize+y.gapSize,_.scale.value=y.scale}function l(_,y,M,C){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,_.size.value=y.size*M,_.scale.value=C*.5,y.map&&(_.map.value=y.map,t(y.map,_.uvTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,t(y.alphaMap,_.alphaMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest)}function c(_,y){_.diffuse.value.copy(y.color),_.opacity.value=y.opacity,_.rotation.value=y.rotation,y.map&&(_.map.value=y.map,t(y.map,_.mapTransform)),y.alphaMap&&(_.alphaMap.value=y.alphaMap,t(y.alphaMap,_.alphaMapTransform)),y.alphaTest>0&&(_.alphaTest.value=y.alphaTest)}function u(_,y){_.specular.value.copy(y.specular),_.shininess.value=Math.max(y.shininess,1e-4)}function d(_,y){y.gradientMap&&(_.gradientMap.value=y.gradientMap)}function h(_,y){_.metalness.value=y.metalness,y.metalnessMap&&(_.metalnessMap.value=y.metalnessMap,t(y.metalnessMap,_.metalnessMapTransform)),_.roughness.value=y.roughness,y.roughnessMap&&(_.roughnessMap.value=y.roughnessMap,t(y.roughnessMap,_.roughnessMapTransform)),y.envMap&&(_.envMapIntensity.value=y.envMapIntensity)}function p(_,y,M){_.ior.value=y.ior,y.sheen>0&&(_.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),_.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(_.sheenColorMap.value=y.sheenColorMap,t(y.sheenColorMap,_.sheenColorMapTransform)),y.sheenRoughnessMap&&(_.sheenRoughnessMap.value=y.sheenRoughnessMap,t(y.sheenRoughnessMap,_.sheenRoughnessMapTransform))),y.clearcoat>0&&(_.clearcoat.value=y.clearcoat,_.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(_.clearcoatMap.value=y.clearcoatMap,t(y.clearcoatMap,_.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(_.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,t(y.clearcoatRoughnessMap,_.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(_.clearcoatNormalMap.value=y.clearcoatNormalMap,t(y.clearcoatNormalMap,_.clearcoatNormalMapTransform),_.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===Ds&&_.clearcoatNormalScale.value.negate())),y.dispersion>0&&(_.dispersion.value=y.dispersion),y.iridescence>0&&(_.iridescence.value=y.iridescence,_.iridescenceIOR.value=y.iridescenceIOR,_.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],_.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(_.iridescenceMap.value=y.iridescenceMap,t(y.iridescenceMap,_.iridescenceMapTransform)),y.iridescenceThicknessMap&&(_.iridescenceThicknessMap.value=y.iridescenceThicknessMap,t(y.iridescenceThicknessMap,_.iridescenceThicknessMapTransform))),y.transmission>0&&(_.transmission.value=y.transmission,_.transmissionSamplerMap.value=M.texture,_.transmissionSamplerSize.value.set(M.width,M.height),y.transmissionMap&&(_.transmissionMap.value=y.transmissionMap,t(y.transmissionMap,_.transmissionMapTransform)),_.thickness.value=y.thickness,y.thicknessMap&&(_.thicknessMap.value=y.thicknessMap,t(y.thicknessMap,_.thicknessMapTransform)),_.attenuationDistance.value=y.attenuationDistance,_.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(_.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(_.anisotropyMap.value=y.anisotropyMap,t(y.anisotropyMap,_.anisotropyMapTransform))),_.specularIntensity.value=y.specularIntensity,_.specularColor.value.copy(y.specularColor),y.specularColorMap&&(_.specularColorMap.value=y.specularColorMap,t(y.specularColorMap,_.specularColorMapTransform)),y.specularIntensityMap&&(_.specularIntensityMap.value=y.specularIntensityMap,t(y.specularIntensityMap,_.specularIntensityMapTransform))}function g(_,y){y.matcap&&(_.matcap.value=y.matcap)}function x(_,y){const M=e.get(y).light;_.referencePosition.value.setFromMatrixPosition(M.matrixWorld),_.nearDistance.value=M.shadow.camera.near,_.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function zJe(n,e,t,r){let i={},s={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(k,B){const U=B.program;r.uniformBlockBinding(k,U)}function c(k,B){let U=i[k.id];U===void 0&&(_(k),U=u(k),i[k.id]=U,k.addEventListener("dispose",M));const z=B.program;r.updateUBOMapping(k,z);const O=e.render.frame;s[k.id]!==O&&(h(k),s[k.id]=O)}function u(k){const B=d();k.__bindingPointIndex=B;const U=n.createBuffer(),z=k.__size,O=k.usage;return n.bindBuffer(n.UNIFORM_BUFFER,U),n.bufferData(n.UNIFORM_BUFFER,z,O),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,B,U),U}function d(){for(let k=0;k0&&(U+=z-O),k.__size=U,k.__cache={},this}function y(k){const B={boundary:0,storage:0};return typeof k=="number"||typeof k=="boolean"?(B.boundary=4,B.storage=4):k.isVector2?(B.boundary=8,B.storage=8):k.isVector3||k.isColor?(B.boundary=16,B.storage=12):k.isVector4?(B.boundary=16,B.storage=16):k.isMatrix3?(B.boundary=48,B.storage=48):k.isMatrix4?(B.boundary=64,B.storage=64):k.isTexture?sn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(k)?(B.boundary=16,B.storage=k.byteLength):sn("WebGLRenderer: Unsupported uniform value type.",k),B}function M(k){const B=k.target;B.removeEventListener("dispose",M);const U=a.indexOf(B.__bindingPointIndex);a.splice(U,1),n.deleteBuffer(i[B.id]),delete i[B.id],delete s[B.id]}function C(){for(const k in i)n.deleteBuffer(i[k]);a=[],i={},s={}}return{bind:l,update:c,dispose:C}}const VJe=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]);let _p=null;function qJe(){return _p===null&&(_p=new hh(VJe,16,16,dc,ba),_p.name="DFG_LUT",_p.minFilter=Ci,_p.magFilter=Ci,_p.wrapS=uc,_p.wrapT=uc,_p.generateMipmaps=!1,_p.needsUpdate=!0),_p}class hW{constructor(e={}){const{canvas:t=E$(),context:r=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:p=ma}=e;this.isWebGLRenderer=!0;let g;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=r.getContextAttributes().alpha}else g=a;const x=p,_=new Set([Jv,t1,Tm]),y=new Set([ma,xs,Jh,Od,I3,D3]),M=new Uint32Array(4),C=new Int32Array(4),k=new Fe;let B=null,U=null;const z=[],O=[];let V=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=cc,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const $=this;let G=!1,H=null,K=null,W=null,J=null;this._outputColorSpace=ic;let ie=0,ae=0,Q=null,re=-1,oe=null;const fe=new gr,ee=new gr;let me=null;const Ae=new Fn(0);let be=0,pe=t.width,ge=t.height,Te=1,ze=null,Xe=null;const Qe=new gr(0,0,pe,ge),ot=new gr(0,0,pe,ge);let bt=!1;const ht=new Vg;let Ce=!1,lt=!1;const ft=new ir,et=new Fe,At=new gr,Lt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let st=!1;function Ht(){return Q===null?Te:1}let Se=r;function _t(Ge,wt){return t.getContext(Ge,wt)}try{const Ge={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Sm}`),t.addEventListener("webglcontextlost",Gt,!1),t.addEventListener("webglcontextrestored",it,!1),t.addEventListener("webglcontextcreationerror",Ot,!1),Se===null){const wt="webgl2";if(Se=_t(wt,Ge),Se===null)throw _t(wt)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(Ge){throw on("WebGLRenderer: "+Ge.message),Ge}let It,De,ue,Ve,We,ct,vt,Ut,dt,mt,Ft,tt,Pe,nt,qe,yt,Qt,Be,pt,rt,zt,Yt,Bt;function $e(){It=new GQe(Se),It.init(),zt=new kxe(Se,It),De=new OQe(Se,It,e,zt),ue=new kJe(Se,It),De.reversedDepthBuffer&&h&&ue.buffers.depth.setReversed(!0),K=Se.createFramebuffer(),W=Se.createFramebuffer(),J=Se.createFramebuffer(),Ve=new WQe(Se),We=new vJe,ct=new IJe(Se,It,ue,We,De,zt,Ve),vt=new qQe($),Ut=new QXe(Se),Yt=new IQe(Se,Ut),dt=new HQe(Se,Ut,Ve,Yt),mt=new YQe(Se,dt,Ut,Yt,Ve),Be=new XQe(Se,De,ct),qe=new jQe(We),Ft=new xJe($,vt,It,De,Yt,qe),tt=new UJe($,We),Pe=new bJe,nt=new NJe(It),Qt=new kQe($,vt,ue,mt,g,l),yt=new LJe($,mt,De),Bt=new zJe(Se,Ve,De,ue),pt=new DQe(Se,It,Ve),rt=new $Qe(Se,It,Ve),Ve.programs=Ft.programs,$.capabilities=De,$.extensions=It,$.properties=We,$.renderLists=Pe,$.shadowMap=yt,$.state=ue,$.info=Ve}$e(),x!==ma&&(V=new QQe(x,t.width,t.height,o,i,s));const ut=new FJe($,Se);this.xr=ut,this.getContext=function(){return Se},this.getContextAttributes=function(){return Se.getContextAttributes()},this.forceContextLoss=function(){const Ge=It.get("WEBGL_lose_context");Ge&&Ge.loseContext()},this.forceContextRestore=function(){const Ge=It.get("WEBGL_lose_context");Ge&&Ge.restoreContext()},this.getPixelRatio=function(){return Te},this.setPixelRatio=function(Ge){Ge!==void 0&&(Te=Ge,this.setSize(pe,ge,!1))},this.getSize=function(Ge){return Ge.set(pe,ge)},this.setSize=function(Ge,wt,_e=!0){if(ut.isPresenting){sn("WebGLRenderer: Can't change size while VR device is presenting.");return}pe=Ge,ge=wt,t.width=Math.floor(Ge*Te),t.height=Math.floor(wt*Te),_e===!0&&(t.style.width=Ge+"px",t.style.height=wt+"px"),V!==null&&V.setSize(t.width,t.height),this.setViewport(0,0,Ge,wt)},this.getDrawingBufferSize=function(Ge){return Ge.set(pe*Te,ge*Te).floor()},this.setDrawingBufferSize=function(Ge,wt,_e){pe=Ge,ge=wt,Te=_e,t.width=Math.floor(Ge*_e),t.height=Math.floor(wt*_e),this.setViewport(0,0,Ge,wt)},this.setEffects=function(Ge){if(x===ma){on("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(Ge){for(let wt=0;wt{function vn(){if(Dt.forEach(function(Sn){We.get(Sn).currentProgram.isReady()&&Dt.delete(Sn)}),Dt.size===0){Xt(Ge);return}setTimeout(vn,10)}It.get("KHR_parallel_shader_compile")!==null?vn():setTimeout(vn,10)})};let An=null;function Ln(Ge){An&&An(Ge)}function Rn(){Cn.stop()}function Mn(){Cn.start()}const Cn=new Nxe;Cn.setAnimationLoop(Ln),typeof self<"u"&&Cn.setContext(self),this.setAnimationLoop=function(Ge){An=Ge,ut.setAnimationLoop(Ge),Ge===null?Cn.stop():Cn.start()},ut.addEventListener("sessionstart",Rn),ut.addEventListener("sessionend",Mn),this.render=function(Ge,wt){if(wt!==void 0&&wt.isCamera!==!0){on("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(G===!0)return;H!==null&&H.renderStart(Ge,wt);const _e=ut.enabled===!0&&ut.isPresenting===!0,Dt=V!==null&&(Q===null||_e)&&V.begin($,Q);if(Ge.matrixWorldAutoUpdate===!0&&Ge.updateMatrixWorld(),wt.parent===null&&wt.matrixWorldAutoUpdate===!0&&wt.updateMatrixWorld(),ut.enabled===!0&&ut.isPresenting===!0&&(V===null||V.isCompositing()===!1)&&(ut.cameraAutoUpdate===!0&&ut.updateCamera(wt),wt=ut.getCamera()),Ge.isScene===!0&&Ge.onBeforeRender($,Ge,wt,Q),U=nt.get(Ge,O.length),U.init(wt),U.state.textureUnits=ct.getTextureUnits(),O.push(U),ft.multiplyMatrices(wt.projectionMatrix,wt.matrixWorldInverse),ht.setFromProjectionMatrix(ft,gu,wt.reversedDepth),lt=this.localClippingEnabled,Ce=qe.init(this.clippingPlanes,lt),B=Pe.get(Ge,z.length),B.init(),z.push(B),ut.enabled===!0&&ut.isPresenting===!0){const Sn=$.xr.getDepthSensingMesh();Sn!==null&&Hn(Sn,wt,-1/0,$.sortObjects)}Hn(Ge,wt,0,$.sortObjects),B.finish(),$.sortObjects===!0&&B.sort(ze,Xe,wt.reversedDepth),st=ut.enabled===!1||ut.isPresenting===!1||ut.hasDepthSensing()===!1,st&&Qt.addToRenderList(B,Ge),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ce===!0&&qe.beginShadows();const Xt=U.state.shadowsArray;if(yt.render(Xt,Ge,wt),Ce===!0&&qe.endShadows(),(Dt&&V.hasRenderPass())===!1){const Sn=B.opaque,hn=B.transmissive;if(U.setupLights(),wt.isArrayCamera){const Tn=wt.cameras;if(hn.length>0)for(let Re=0,Wn=Tn.length;Re0&&jr(Sn,hn,Ge,wt),st&&Qt.render(Ge),lr(B,Ge,wt)}Q!==null&&ae===0&&(ct.updateMultisampleRenderTarget(Q),ct.updateRenderTargetMipmap(Q)),Dt&&V.end($),Ge.isScene===!0&&Ge.onAfterRender($,Ge,wt),Yt.resetDefaultState(),re=-1,oe=null,O.pop(),O.length>0?(U=O[O.length-1],ct.setTextureUnits(U.state.textureUnits),Ce===!0&&qe.setGlobalState($.clippingPlanes,U.state.camera)):U=null,z.pop(),z.length>0?B=z[z.length-1]:B=null,H!==null&&H.renderEnd()};function Hn(Ge,wt,_e,Dt){if(Ge.visible===!1)return;if(Ge.layers.test(wt.layers)){if(Ge.isGroup)_e=Ge.renderOrder;else if(Ge.isLOD)Ge.autoUpdate===!0&&Ge.update(wt);else if(Ge.isLightProbeGrid)U.pushLightProbeGrid(Ge);else if(Ge.isLight)U.pushLight(Ge),Ge.castShadow&&U.pushShadow(Ge);else if(Ge.isSprite){if(!Ge.frustumCulled||ht.intersectsSprite(Ge)){Dt&&At.setFromMatrixPosition(Ge.matrixWorld).applyMatrix4(ft);const Sn=mt.update(Ge),hn=Ge.material;hn.visible&&B.push(Ge,Sn,hn,_e,At.z,null)}}else if((Ge.isMesh||Ge.isLine||Ge.isPoints)&&(!Ge.frustumCulled||ht.intersectsObject(Ge))){const Sn=mt.update(Ge),hn=Ge.material;if(Dt&&(Ge.boundingSphere!==void 0?(Ge.boundingSphere===null&&Ge.computeBoundingSphere(),At.copy(Ge.boundingSphere.center)):(Sn.boundingSphere===null&&Sn.computeBoundingSphere(),At.copy(Sn.boundingSphere.center)),At.applyMatrix4(Ge.matrixWorld).applyMatrix4(ft)),Array.isArray(hn)){const Tn=Sn.groups;for(let Re=0,Wn=Tn.length;Re0&&Qr(Xt,wt,_e),vn.length>0&&Qr(vn,wt,_e),Sn.length>0&&Qr(Sn,wt,_e),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function jr(Ge,wt,_e,Dt){if((_e.isScene===!0?_e.overrideMaterial:null)!==null)return;if(U.state.transmissionRenderTarget[Dt.id]===void 0){const Un=It.has("EXT_color_buffer_half_float")||It.has("EXT_color_buffer_float");U.state.transmissionRenderTarget[Dt.id]=new dh(1,1,{generateMipmaps:!0,type:Un?ba:ma,minFilter:Bc,samples:Math.max(4,De.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Sr.workingColorSpace})}const vn=U.state.transmissionRenderTarget[Dt.id],Sn=Dt.viewport||fe;vn.setSize(Sn.z*$.transmissionResolutionScale,Sn.w*$.transmissionResolutionScale);const hn=$.getRenderTarget(),Tn=$.getActiveCubeFace(),Re=$.getActiveMipmapLevel();$.setRenderTarget(vn),$.getClearColor(Ae),be=$.getClearAlpha(),be<1&&$.setClearColor(16777215,.5),$.clear(),st&&Qt.render(_e);const Wn=$.toneMapping;$.toneMapping=cc;const Ar=Dt.viewport;if(Dt.viewport!==void 0&&(Dt.viewport=void 0),U.setupLightsView(Dt),Ce===!0&&qe.setGlobalState($.clippingPlanes,Dt),Qr(Ge,_e,Dt),ct.updateMultisampleRenderTarget(vn),ct.updateRenderTargetMipmap(vn),It.has("WEBGL_multisampled_render_to_texture")===!1){let Un=!1;for(let zn=0,Nr=wt.length;zn0,Dt.currentProgram=Ar,Dt.uniformsList=null,Ar}function Pi(Ge){if(Ge.uniformsList===null){const wt=Ge.currentProgram.getUniforms();Ge.uniformsList=gN.seqWithValue(wt.seq,Ge.uniforms)}return Ge.uniformsList}function ra(Ge,wt){const _e=We.get(Ge);_e.outputColorSpace=wt.outputColorSpace,_e.batching=wt.batching,_e.batchingColor=wt.batchingColor,_e.instancing=wt.instancing,_e.instancingColor=wt.instancingColor,_e.instancingMorph=wt.instancingMorph,_e.skinning=wt.skinning,_e.morphTargets=wt.morphTargets,_e.morphNormals=wt.morphNormals,_e.morphColors=wt.morphColors,_e.morphTargetsCount=wt.morphTargetsCount,_e.numClippingPlanes=wt.numClippingPlanes,_e.numIntersection=wt.numClipIntersection,_e.vertexAlphas=wt.vertexAlphas,_e.vertexTangents=wt.vertexTangents,_e.toneMapping=wt.toneMapping}function cs(Ge,wt){if(Ge.length===0)return null;if(Ge.length===1)return Ge[0].texture!==null?Ge[0]:null;k.setFromMatrixPosition(wt.matrixWorld);for(let _e=0,Dt=Ge.length;_e0),Un=!!_e.morphAttributes.position,zn=!!_e.morphAttributes.normal,Nr=!!_e.morphAttributes.color;let ii=cc;Dt.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(ii=$.toneMapping);const Kr=_e.morphAttributes.position||_e.morphAttributes.normal||_e.morphAttributes.color,Ir=Kr!==void 0?Kr.length:0,In=We.get(Dt),Ri=U.state.lights;if(Ce===!0&&(lt===!0||Ge!==oe)){const fi=Ge===oe&&Dt.id===re;qe.setState(Dt,Ge,fi)}let sr=!1;Dt.version===In.__version?(In.needsLights&&In.lightsStateVersion!==Ri.state.version||In.outputColorSpace!==hn||Xt.isBatchedMesh&&In.batching===!1||!Xt.isBatchedMesh&&In.batching===!0||Xt.isBatchedMesh&&In.batchingColor===!0&&Xt.colorTexture===null||Xt.isBatchedMesh&&In.batchingColor===!1&&Xt.colorTexture!==null||Xt.isInstancedMesh&&In.instancing===!1||!Xt.isInstancedMesh&&In.instancing===!0||Xt.isSkinnedMesh&&In.skinning===!1||!Xt.isSkinnedMesh&&In.skinning===!0||Xt.isInstancedMesh&&In.instancingColor===!0&&Xt.instanceColor===null||Xt.isInstancedMesh&&In.instancingColor===!1&&Xt.instanceColor!==null||Xt.isInstancedMesh&&In.instancingMorph===!0&&Xt.morphTexture===null||Xt.isInstancedMesh&&In.instancingMorph===!1&&Xt.morphTexture!==null||In.envMap!==Re||Dt.fog===!0&&In.fog!==vn||In.numClippingPlanes!==void 0&&(In.numClippingPlanes!==qe.numPlanes||In.numIntersection!==qe.numIntersection)||In.vertexAlphas!==Wn||In.vertexTangents!==Ar||In.morphTargets!==Un||In.morphNormals!==zn||In.morphColors!==Nr||In.toneMapping!==ii||In.morphTargetsCount!==Ir||!!In.lightProbeGrid!=U.state.lightProbeGridArray.length>0)&&(sr=!0):(sr=!0,In.__version=Dt.version);let Ai=In.currentProgram;sr===!0&&(Ai=la(Dt,wt,Xt),H&&Dt.isNodeMaterial&&H.onUpdateProgram(Dt,Ai,In));let fs=!1,Ki=!1,js=!1;const oi=Ai.getUniforms(),Ei=In.uniforms;if(ue.useProgram(Ai.program)&&(fs=!0,Ki=!0,js=!0),Dt.id!==re&&(re=Dt.id,Ki=!0),In.needsLights){const fi=cs(U.state.lightProbeGridArray,Xt);In.lightProbeGrid!==fi&&(In.lightProbeGrid=fi,Ki=!0)}if(fs||oe!==Ge){ue.buffers.depth.getReversed()&&Ge.reversedDepth!==!0&&(Ge._reversedDepth=!0,Ge.updateProjectionMatrix()),oi.setValue(Se,"projectionMatrix",Ge.projectionMatrix),oi.setValue(Se,"viewMatrix",Ge.matrixWorldInverse);const Ji=oi.map.cameraPosition;Ji!==void 0&&Ji.setValue(Se,et.setFromMatrixPosition(Ge.matrixWorld)),De.logarithmicDepthBuffer&&oi.setValue(Se,"logDepthBufFC",2/(Math.log(Ge.far+1)/Math.LN2)),(Dt.isMeshPhongMaterial||Dt.isMeshToonMaterial||Dt.isMeshLambertMaterial||Dt.isMeshBasicMaterial||Dt.isMeshStandardMaterial||Dt.isShaderMaterial)&&oi.setValue(Se,"isOrthographic",Ge.isOrthographicCamera===!0),oe!==Ge&&(oe=Ge,Ki=!0,js=!0)}if(In.needsLights&&(Ri.state.directionalShadowMap.length>0&&oi.setValue(Se,"directionalShadowMap",Ri.state.directionalShadowMap,ct),Ri.state.spotShadowMap.length>0&&oi.setValue(Se,"spotShadowMap",Ri.state.spotShadowMap,ct),Ri.state.pointShadowMap.length>0&&oi.setValue(Se,"pointShadowMap",Ri.state.pointShadowMap,ct)),Xt.isSkinnedMesh){oi.setOptional(Se,Xt,"bindMatrix"),oi.setOptional(Se,Xt,"bindMatrixInverse");const fi=Xt.skeleton;fi&&(fi.boneTexture===null&&fi.computeBoneTexture(),oi.setValue(Se,"boneTexture",fi.boneTexture,ct))}Xt.isBatchedMesh&&(oi.setOptional(Se,Xt,"batchingTexture"),oi.setValue(Se,"batchingTexture",Xt._matricesTexture,ct),oi.setOptional(Se,Xt,"batchingIdTexture"),oi.setValue(Se,"batchingIdTexture",Xt._indirectTexture,ct),oi.setOptional(Se,Xt,"batchingColorTexture"),Xt._colorsTexture!==null&&oi.setValue(Se,"batchingColorTexture",Xt._colorsTexture,ct));const ja=_e.morphAttributes;if((ja.position!==void 0||ja.normal!==void 0||ja.color!==void 0)&&Be.update(Xt,_e,Ai),(Ki||In.receiveShadow!==Xt.receiveShadow)&&(In.receiveShadow=Xt.receiveShadow,oi.setValue(Se,"receiveShadow",Xt.receiveShadow)),(Dt.isMeshStandardMaterial||Dt.isMeshLambertMaterial||Dt.isMeshPhongMaterial)&&Dt.envMap===null&&wt.environment!==null&&(Ei.envMapIntensity.value=wt.environmentIntensity),Ei.dfgLUT!==void 0&&(Ei.dfgLUT.value=qJe()),Ki){if(oi.setValue(Se,"toneMappingExposure",$.toneMappingExposure),In.needsLights&&wa(Ei,js),vn&&Dt.fog===!0&&tt.refreshFogUniforms(Ei,vn),tt.refreshMaterialUniforms(Ei,Dt,Te,ge,U.state.transmissionRenderTarget[Ge.id]),In.needsLights&&In.lightProbeGrid){const fi=In.lightProbeGrid;Ei.probesSH.value=fi.texture,Ei.probesMin.value.copy(fi.boundingBox.min),Ei.probesMax.value.copy(fi.boundingBox.max),Ei.probesResolution.value.copy(fi.resolution)}gN.upload(Se,Pi(In),Ei,ct)}if(Dt.isShaderMaterial&&Dt.uniformsNeedUpdate===!0&&(gN.upload(Se,Pi(In),Ei,ct),Dt.uniformsNeedUpdate=!1),Dt.isSpriteMaterial&&oi.setValue(Se,"center",Xt.center),oi.setValue(Se,"modelViewMatrix",Xt.modelViewMatrix),oi.setValue(Se,"normalMatrix",Xt.normalMatrix),oi.setValue(Se,"modelMatrix",Xt.matrixWorld),Dt.uniformsGroups!==void 0){const fi=Dt.uniformsGroups;for(let Ji=0,Sa=fi.length;Ji0&&ct.useMultisampledRTT(Ge)===!1?Dt=We.get(Ge).__webglMultisampledFramebuffer:Array.isArray(Re)?Dt=Re[_e]:Dt=Re,fe.copy(Ge.viewport),ee.copy(Ge.scissor),me=Ge.scissorTest}else fe.copy(Qe).multiplyScalar(Te).floor(),ee.copy(ot).multiplyScalar(Te).floor(),me=bt;if(_e!==0&&(Dt=K),ue.bindFramebuffer(Se.FRAMEBUFFER,Dt)&&ue.drawBuffers(Ge,Dt),ue.viewport(fe),ue.scissor(ee),ue.setScissorTest(me),Xt){const hn=We.get(Ge.texture);Se.framebufferTexture2D(Se.FRAMEBUFFER,Se.COLOR_ATTACHMENT0,Se.TEXTURE_CUBE_MAP_POSITIVE_X+wt,hn.__webglTexture,_e)}else if(vn){const hn=wt;for(let Tn=0;Tn1&&Se.readBuffer(Se.COLOR_ATTACHMENT0+hn),!De.textureFormatReadable(Wn)){on("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!De.textureTypeReadable(Ar)){on("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}wt>=0&&wt<=Ge.width-Dt&&_e>=0&&_e<=Ge.height-Xt&&Se.readPixels(wt,_e,Dt,Xt,zt.convert(Wn),zt.convert(Ar),vn)}finally{const Re=Q!==null?We.get(Q).__webglFramebuffer:null;ue.bindFramebuffer(Se.FRAMEBUFFER,Re)}}},this.readRenderTargetPixelsAsync=async function(Ge,wt,_e,Dt,Xt,vn,Sn,hn=0){if(!(Ge&&Ge.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tn=We.get(Ge).__webglFramebuffer;if(Ge.isWebGLCubeRenderTarget&&Sn!==void 0&&(Tn=Tn[Sn]),Tn)if(wt>=0&&wt<=Ge.width-Dt&&_e>=0&&_e<=Ge.height-Xt){ue.bindFramebuffer(Se.FRAMEBUFFER,Tn);const Re=Ge.textures[hn],Wn=Re.format,Ar=Re.type;if(Ge.textures.length>1&&Se.readBuffer(Se.COLOR_ATTACHMENT0+hn),!De.textureFormatReadable(Wn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!De.textureTypeReadable(Ar))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Un=Se.createBuffer();Se.bindBuffer(Se.PIXEL_PACK_BUFFER,Un),Se.bufferData(Se.PIXEL_PACK_BUFFER,vn.byteLength,Se.STREAM_READ),Se.readPixels(wt,_e,Dt,Xt,zt.convert(Wn),zt.convert(Ar),0);const zn=Q!==null?We.get(Q).__webglFramebuffer:null;ue.bindFramebuffer(Se.FRAMEBUFFER,zn);const Nr=Se.fenceSync(Se.SYNC_GPU_COMMANDS_COMPLETE,0);return Se.flush(),await s$e(Se,Nr,4),Se.bindBuffer(Se.PIXEL_PACK_BUFFER,Un),Se.getBufferSubData(Se.PIXEL_PACK_BUFFER,0,vn),Se.deleteBuffer(Un),Se.deleteSync(Nr),vn}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(Ge,wt=null,_e=0){const Dt=Math.pow(2,-_e),Xt=Math.floor(Ge.image.width*Dt),vn=Math.floor(Ge.image.height*Dt),Sn=wt!==null?wt.x:0,hn=wt!==null?wt.y:0;ct.setTexture2D(Ge,0),Se.copyTexSubImage2D(Se.TEXTURE_2D,_e,0,0,Sn,hn,Xt,vn),ue.unbindTexture()},this.copyTextureToTexture=function(Ge,wt,_e=null,Dt=null,Xt=0,vn=0){let Sn,hn,Tn,Re,Wn,Ar,Un,zn,Nr;const ii=Ge.isCompressedTexture?Ge.mipmaps[vn]:Ge.image;if(_e!==null)Sn=_e.max.x-_e.min.x,hn=_e.max.y-_e.min.y,Tn=_e.isBox3?_e.max.z-_e.min.z:1,Re=_e.min.x,Wn=_e.min.y,Ar=_e.isBox3?_e.min.z:0;else{const Ei=Math.pow(2,-Xt);Sn=Math.floor(ii.width*Ei),hn=Math.floor(ii.height*Ei),Ge.isDataArrayTexture?Tn=ii.depth:Ge.isData3DTexture?Tn=Math.floor(ii.depth*Ei):Tn=1,Re=0,Wn=0,Ar=0}Dt!==null?(Un=Dt.x,zn=Dt.y,Nr=Dt.z):(Un=0,zn=0,Nr=0);const Kr=zt.convert(wt.format),Ir=zt.convert(wt.type);let In;wt.isData3DTexture?(ct.setTexture3D(wt,0),In=Se.TEXTURE_3D):wt.isDataArrayTexture||wt.isCompressedArrayTexture?(ct.setTexture2DArray(wt,0),In=Se.TEXTURE_2D_ARRAY):(ct.setTexture2D(wt,0),In=Se.TEXTURE_2D),ue.activeTexture(Se.TEXTURE0),ue.pixelStorei(Se.UNPACK_FLIP_Y_WEBGL,wt.flipY),ue.pixelStorei(Se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,wt.premultiplyAlpha),ue.pixelStorei(Se.UNPACK_ALIGNMENT,wt.unpackAlignment);const Ri=ue.getParameter(Se.UNPACK_ROW_LENGTH),sr=ue.getParameter(Se.UNPACK_IMAGE_HEIGHT),Ai=ue.getParameter(Se.UNPACK_SKIP_PIXELS),fs=ue.getParameter(Se.UNPACK_SKIP_ROWS),Ki=ue.getParameter(Se.UNPACK_SKIP_IMAGES);ue.pixelStorei(Se.UNPACK_ROW_LENGTH,ii.width),ue.pixelStorei(Se.UNPACK_IMAGE_HEIGHT,ii.height),ue.pixelStorei(Se.UNPACK_SKIP_PIXELS,Re),ue.pixelStorei(Se.UNPACK_SKIP_ROWS,Wn),ue.pixelStorei(Se.UNPACK_SKIP_IMAGES,Ar);const js=Ge.isDataArrayTexture||Ge.isData3DTexture,oi=wt.isDataArrayTexture||wt.isData3DTexture;if(Ge.isDepthTexture){const Ei=We.get(Ge),ja=We.get(wt),fi=We.get(Ei.__renderTarget),Ji=We.get(ja.__renderTarget);ue.bindFramebuffer(Se.READ_FRAMEBUFFER,fi.__webglFramebuffer),ue.bindFramebuffer(Se.DRAW_FRAMEBUFFER,Ji.__webglFramebuffer);for(let Sa=0;Sa=-1&&Ky.z<=1&&g.layers.test(_.layers)===!0,M=g.element;M.style.display=y===!0?"":"none",y===!0&&(g.onBeforeRender(t,x,_),M.style.transform="translate("+-100*g.center.x+"%,"+-100*g.center.y+"%)translate("+(Ky.x*s+s)+"px,"+(-Ky.y*a+a)+"px)",M.parentNode!==l&&l.appendChild(M),g.onAfterRender(t,x,_));const C={distanceToCameraSquared:d(_,g)};o.objects.set(g,C)}for(let y=0,M=g.children.length;y=e||z<0||d&&O>=s}function y(){var U=xF();if(_(U))return M(U);o=setTimeout(y,x(U))}function M(U){return o=void 0,h&&r?p(U):(r=i=void 0,a)}function C(){o!==void 0&&clearTimeout(o),c=0,r=l=i=o=void 0}function k(){return o===void 0?a:M(xF())}function B(){var U=xF(),z=_(U);if(r=arguments,i=this,l=U,z){if(o===void 0)return g(l);if(d)return clearTimeout(o),o=setTimeout(y,e),p(l)}return o===void 0&&(o=setTimeout(y,e)),a}return B.cancel=C,B.flush=k,B}function koe(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t1e4?1e4:n,{In:function(e){return Math.pow(e,n)},Out:function(e){return 1-Math.pow(1-e,n)},InOut:function(e){return e<.5?Math.pow(e*2,n)/2:(1-Math.pow(2-e*2,n))/2+.5}}}}),I5=function(){return performance.now()},hR=function(){function n(){for(var e=[],t=0;t0;){this._tweensAddedDuringUpdate={};for(var i=0;i1?s(n[t],n[t-1],t-r):s(n[i],n[i+1>t?t:i+1],r-i)},Utils:{Linear:function(n,e,t){return(e-n)*t+n}}},jxe=function(){function n(){}return n.nextId=function(){return n._nextId++},n._nextId=0,n}(),iV=new hR,cd=function(){function n(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Zl.Linear.None,this._interpolationFunction=rV.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=jxe.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t=="object"?(this._group=t,t.add(this)):t===!0&&(this._group=iV,iV.add(this))}return n.prototype.getId=function(){return this._id},n.prototype.isPlaying=function(){return this._isPlaying},n.prototype.isPaused=function(){return this._isPaused},n.prototype.getDuration=function(){return this._duration},n.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},n.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},n.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},n.prototype.start=function(e,t){if(e===void 0&&(e=I5()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var r in this._valuesStartRepeat)this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},n.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},n.prototype._setupProperties=function(e,t,r,i,s){for(var a in r){var o=e[a],l=Array.isArray(o),c=l?"array":typeof o,u=!l&&Array.isArray(r[a]);if(!(c==="undefined"||c==="function")){if(u){var d=r[a];if(d.length===0)continue;for(var h=[o],p=0,g=d.length;p"u"||s)&&(t[a]=o),l||(t[a]*=1),u?i[a]=r[a].slice().reverse():i[a]=t[a]||0}}},n.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},n.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},n.prototype.pause=function(e){return e===void 0&&(e=I5()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},n.prototype.resume=function(e){return e===void 0&&(e=I5()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},n.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;el)return 1;var x=Math.trunc(a/o),_=a-x*o,y=Math.min(_/r._duration,1);return y===0&&a===r._duration?1:y},u=c(),d=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var h=Math.min(Math.trunc((a-this._duration)/o)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=h);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=o*h,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var p=0,g=this._chainedTweens.length;p=(g=(l+d)/2))?l=g:d=g,(B=t>=(x=(c+h)/2))?c=x:h=x,(U=r>=(_=(u+p)/2))?u=_:p=_,s=a,!(a=a[z=U<<2|B<<1|k]))return s[z]=o,n;if(y=+n._x.call(null,a.data),M=+n._y.call(null,a.data),C=+n._z.call(null,a.data),e===y&&t===M&&r===C)return o.next=a,s?s[z]=o:n._root=o,n;do s=s?s[z]=new Array(8):n._root=new Array(8),(k=e>=(g=(l+d)/2))?l=g:d=g,(B=t>=(x=(c+h)/2))?c=x:h=x,(U=r>=(_=(u+p)/2))?u=_:p=_;while((z=U<<2|B<<1|k)===(O=(C>=_)<<2|(M>=x)<<1|y>=g));return s[O]=a,s[z]=o,n}function Pet(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let s=1/0,a=1/0,o=1/0,l=-1/0,c=-1/0,u=-1/0;for(let d=0,h,p,g,x;dl&&(l=p),gc&&(c=g),xu&&(u=x));if(s>l||a>c||o>u)return this;this.cover(s,a,o).cover(l,c,u);for(let d=0;dn||n>=a||i>e||e>=o||s>t||t>=l;)switch(h=(tg||(c=C.y0)>x||(u=C.z0)>_||(d=C.x1)=z)<<2|(e>=U)<<1|n>=B)&&(C=y[y.length-1],y[y.length-1]=y[y.length-1-k],y[y.length-1-k]=C)}else{var O=n-+this._x.call(null,M.data),V=e-+this._y.call(null,M.data),$=t-+this._z.call(null,M.data),G=O*O+V*V+$*$;if(GMath.sqrt((n-r)**2+(e-i)**2+(t-s)**2);function Oet(n,e,t,r){const i=[],s=n-r,a=e-r,o=t-r,l=n+r,c=e+r,u=t+r;return this.visit((d,h,p,g,x,_,y)=>{if(!d.length)do{const M=d.data;Det(n,e,t,this._x(M),this._y(M),this._z(M))<=r&&i.push(M)}while(d=d.next);return h>l||p>c||g>u||x=(x=(a+c)/2))?a=x:c=x,(C=p>=(_=(o+u)/2))?o=_:u=_,(k=g>=(y=(l+d)/2))?l=y:d=y,e=t,!(t=t[B=k<<2|C<<1|M]))return this;if(!t.length)break;(e[B+1&7]||e[B+2&7]||e[B+3&7]||e[B+4&7]||e[B+5&7]||e[B+6&7]||e[B+7&7])&&(r=e,U=B)}for(;t.data!==n;)if(i=t,!(t=t.next))return this;return(s=t.next)&&delete t.next,i?(s?i.next=s:delete i.next,this):e?(s?e[B]=s:delete e[B],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(r?r[U]=t:this._root=t),this):(this._root=s,this)}function Fet(n){for(var e=0,t=n.length;ee?1:n>=e?0:NaN}function Yet(n,e){return n==null||e==null?NaN:en?1:e>=n?0:NaN}function Uxe(n){let e,t,r;n.length!==2?(e=AN,t=(o,l)=>AN(n(o),l),r=(o,l)=>n(o)-l):(e=n===AN||n===Yet?n:Zet,t=n,r=n);function i(o,l,c=0,u=o.length){if(c>>1;t(o[d],l)<0?c=d+1:u=d}while(c>>1;t(o[d],l)<=0?c=d+1:u=d}while(cc&&r(o[d-1],l)>-r(o[d],l)?d-1:d}return{left:i,center:a,right:s}}function Zet(){return 0}function Qet(n){return n===null?NaN:+n}const Ket=Uxe(AN),zxe=Ket.right;Uxe(Qet).center;function QM(n,e){let t,r;if(e===void 0)for(const i of n)i!=null&&(t===void 0?i>=i&&(t=r=i):(t>i&&(t=i),r=s&&(t=r=s):(t>s&&(t=s),r0){for(a=e[--t];t>0&&(r=a,i=e[--t],a=r+i,s=i-(a-r),!s););t>0&&(s<0&&e[t-1]<0||s>0&&e[t-1]>0)&&(i=s*2,r=a+i,i==r-a&&(a=r))}return a}}const Jet=Math.sqrt(50),ett=Math.sqrt(10),ttt=Math.sqrt(2);function KM(n,e,t){const r=(e-n)/Math.max(0,t),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=Jet?10:s>=ett?5:s>=ttt?2:1;let o,l,c;return i<0?(c=Math.pow(10,-i)/a,o=Math.round(n*c),l=Math.round(e*c),o/ce&&--l,c=-c):(c=Math.pow(10,i)*a,o=Math.round(n/c),l=Math.round(e/c),o*ce&&--l),l0))return[];if(n===e)return[n];const r=e=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let c=0;c=r)&&(t=r);return t}function stt(n,e){let t=0,r=0;if(e===void 0)for(let i of n)i!=null&&(i=+i)>=i&&(++t,r+=i);else{let i=-1;for(let s of n)(s=e(s,++i,n))!=null&&(s=+s)>=s&&(++t,r+=s)}if(t)return r/t}function*att(n){for(const e of n)yield*e}function mS(n){return Array.from(att(n))}function e_(n,e,t){n=+n,e=+e,t=(i=arguments.length)<2?(e=n,n=0,1):i<3?1:+t;for(var r=-1,i=Math.max(0,Math.ceil((e-n)/t))|0,s=new Array(i);++re&&(t=n,n=e,e=t),function(r){return Math.max(n,Math.min(e,r))}}function dtt(n,e,t){var r=n[0],i=n[1],s=e[0],a=e[1];return i2?htt:dtt,l=c=null,d}function d(h){return h==null||isNaN(h=+h)?s:(l||(l=o(n.map(r),e,t)))(r(a(h)))}return d.invert=function(h){return a(i((c||(c=o(e,n.map(r),Ff)))(h)))},d.domain=function(h){return arguments.length?(n=Array.from(h,ctt),u()):n.slice()},d.range=function(h){return arguments.length?(e=Array.from(h),u()):e.slice()},d.rangeRound=function(h){return e=Array.from(h),t=L9e,u()},d.clamp=function(h){return arguments.length?(a=h?!0:t_,u()):a!==t_},d.interpolate=function(h){return arguments.length?(t=h,u()):t},d.unknown=function(h){return arguments.length?(s=h,d):s},function(h,p){return r=h,i=p,u()}}function mtt(){return ptt()(t_,t_)}function gtt(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function JM(n,e){if(!isFinite(n)||n===0)return null;var t=(n=e?n.toExponential(e-1):n.toExponential()).indexOf("e"),r=n.slice(0,t);return[r.length>1?r[0]+r.slice(2):r,+n.slice(t+1)]}function a3(n){return n=JM(Math.abs(n)),n?n[1]:NaN}function Att(n,e){return function(t,r){for(var i=t.length,s=[],a=0,o=n[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(t.substring(i-=o,i+o)),!((l+=o+1)>r));)o=n[a=(a+1)%n.length];return s.reverse().join(e)}}function xtt(n){return function(e){return e.replace(/[0-9]/g,function(t){return n[+t]})}}var vtt=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function eC(n){if(!(e=vtt.exec(n)))throw new Error("invalid format: "+n);var e;return new pW({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}eC.prototype=pW.prototype;function pW(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}pW.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function ytt(n){e:for(var e=n.length,t=1,r=-1,i;t0&&(r=0);break}return r>0?n.slice(0,r)+n.slice(i+1):n}var tC;function btt(n,e){var t=JM(n,e);if(!t)return tC=void 0,n.toPrecision(e);var r=t[0],i=t[1],s=i-(tC=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+JM(n,Math.max(0,e+s-1))[0]}function Ooe(n,e){var t=JM(n,e);if(!t)return n+"";var r=t[0],i=t[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const joe={"%":(n,e)=>(n*100).toFixed(e),b:n=>Math.round(n).toString(2),c:n=>n+"",d:gtt,e:(n,e)=>n.toExponential(e),f:(n,e)=>n.toFixed(e),g:(n,e)=>n.toPrecision(e),o:n=>Math.round(n).toString(8),p:(n,e)=>Ooe(n*100,e),r:Ooe,s:btt,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function Foe(n){return n}var Boe=Array.prototype.map,Uoe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function _tt(n){var e=n.grouping===void 0||n.thousands===void 0?Foe:Att(Boe.call(n.grouping,Number),n.thousands+""),t=n.currency===void 0?"":n.currency[0]+"",r=n.currency===void 0?"":n.currency[1]+"",i=n.decimal===void 0?".":n.decimal+"",s=n.numerals===void 0?Foe:xtt(Boe.call(n.numerals,String)),a=n.percent===void 0?"%":n.percent+"",o=n.minus===void 0?"−":n.minus+"",l=n.nan===void 0?"NaN":n.nan+"";function c(d,h){d=eC(d);var p=d.fill,g=d.align,x=d.sign,_=d.symbol,y=d.zero,M=d.width,C=d.comma,k=d.precision,B=d.trim,U=d.type;U==="n"?(C=!0,U="g"):joe[U]||(k===void 0&&(k=12),B=!0,U="g"),(y||p==="0"&&g==="=")&&(y=!0,p="0",g="=");var z=(h&&h.prefix!==void 0?h.prefix:"")+(_==="$"?t:_==="#"&&/[boxX]/.test(U)?"0"+U.toLowerCase():""),O=(_==="$"?r:/[%p]/.test(U)?a:"")+(h&&h.suffix!==void 0?h.suffix:""),V=joe[U],$=/[defgprs%]/.test(U);k=k===void 0?6:/[gprs]/.test(U)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function G(H){var K=z,W=O,J,ie,ae;if(U==="c")W=V(H)+W,H="";else{H=+H;var Q=H<0||1/H<0;if(H=isNaN(H)?l:V(Math.abs(H),k),B&&(H=ytt(H)),Q&&+H==0&&x!=="+"&&(Q=!1),K=(Q?x==="("?x:o:x==="-"||x==="("?"":x)+K,W=(U==="s"&&!isNaN(H)&&tC!==void 0?Uoe[8+tC/3]:"")+W+(Q&&x==="("?")":""),$){for(J=-1,ie=H.length;++Jae||ae>57){W=(ae===46?i+H.slice(J+1):H.slice(J))+W,H=H.slice(0,J);break}}}C&&!y&&(H=e(H,1/0));var re=K.length+H.length+W.length,oe=re>1)+K+H+W+oe.slice(re);break;default:H=oe+K+H+W;break}return s(H)}return G.toString=function(){return d+""},G}function u(d,h){var p=Math.max(-8,Math.min(8,Math.floor(a3(h)/3)))*3,g=Math.pow(10,-p),x=c((d=eC(d),d.type="f",d),{suffix:Uoe[8+p/3]});return function(_){return x(g*_)}}return{format:c,formatPrefix:u}}var v8,qxe,Gxe;wtt({thousands:",",grouping:[3],currency:["$",""]});function wtt(n){return v8=_tt(n),qxe=v8.format,Gxe=v8.formatPrefix,v8}function Stt(n){return Math.max(0,-a3(Math.abs(n)))}function Ttt(n,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(a3(e)/3)))*3-a3(Math.abs(n)))}function Ett(n,e){return n=Math.abs(n),e=Math.abs(e)-n,Math.max(0,a3(e)-a3(n))+1}function Ntt(n,e,t,r){var i=rtt(n,e,t),s;switch(r=eC(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(n),Math.abs(e));return r.precision==null&&!isNaN(s=Ttt(i,a))&&(r.precision=s),Gxe(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=Ett(i,Math.max(Math.abs(n),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=Stt(i))&&(r.precision=s-(r.type==="%")*2);break}}return qxe(r)}function Hxe(n){var e=n.domain;return n.ticks=function(t){var r=e();return ntt(r[0],r[r.length-1],t??10)},n.tickFormat=function(t,r){var i=e();return Ntt(i[0],i[i.length-1],t??10,r)},n.nice=function(t){t==null&&(t=10);var r=e(),i=0,s=r.length-1,a=r[i],o=r[s],l,c,u=10;for(o0;){if(c=sV(a,o,t),c===l)return r[i]=a,r[s]=o,e(r);if(c>0)a=Math.floor(a/c)*c,o=Math.ceil(o/c)*c;else if(c<0)a=Math.ceil(a*c)/c,o=Math.floor(o*c)/c;else break;l=c}return n},n}function Hg(){var n=mtt();return n.copy=function(){return ftt(n,Hg())},Vxe.apply(n,arguments),Hxe(n)}function $xe(){var n=0,e=1,t=1,r=[.5],i=[0,1],s;function a(l){return l!=null&&l<=l?i[zxe(r,l,0,t)]:s}function o(){var l=-1;for(r=new Array(t);++l=t?[r[t-1],e]:[r[c-1],r[c]]},a.unknown=function(l){return arguments.length&&(s=l),a},a.thresholds=function(){return r.slice()},a.copy=function(){return $xe().domain([n,e]).range(i).unknown(s)},Vxe.apply(Hxe(a),arguments)}var Zi=1e-6,nC=1e-12,ks=Math.PI,sh=ks/2,rC=ks/4,cf=ks*2,fl=180/ks,mi=ks/180,_a=Math.abs,mW=Math.atan,t0=Math.atan2,bi=Math.cos,y8=Math.ceil,Mtt=Math.exp,oV=Math.hypot,Ctt=Math.log,ci=Math.sin,Ptt=Math.sign||function(n){return n>0?1:n<0?-1:0},$g=Math.sqrt,Rtt=Math.tan;function Ltt(n){return n>1?0:n<-1?ks:Math.acos(n)}function Wg(n){return n>1?sh:n<-1?-sh:Math.asin(n)}function zoe(n){return(n=ci(n/2))*n}function Ju(){}function iC(n,e){n&&qoe.hasOwnProperty(n.type)&&qoe[n.type](n,e)}var Voe={Feature:function(n,e){iC(n.geometry,e)},FeatureCollection:function(n,e){for(var t=n.features,r=-1,i=t.length;++r=0?1:-1,i=r*t,s=bi(e),a=ci(e),o=dV*a,l=uV*s+o*bi(i),c=o*r*ci(i);sC.add(t0(c,l)),cV=n,uV=s,dV=a}function aC(n){return[t0(n[1],n[0]),Wg(n[2])]}function Dv(n){var e=n[0],t=n[1],r=bi(t);return[r*bi(e),r*ci(e),ci(t)]}function b8(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function o3(n,e){return[n[1]*e[2]-n[2]*e[1],n[2]*e[0]-n[0]*e[2],n[0]*e[1]-n[1]*e[0]]}function vF(n,e){n[0]+=e[0],n[1]+=e[1],n[2]+=e[2]}function _8(n,e){return[n[0]*e,n[1]*e,n[2]*e]}function oC(n){var e=$g(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=e,n[1]/=e,n[2]/=e}var Oo,th,cl,Wh,ox,Zxe,Qxe,__,u4,G1,Yg,Km={point:hV,lineStart:$oe,lineEnd:Woe,polygonStart:function(){Km.point=Jxe,Km.lineStart=Ott,Km.lineEnd=jtt,u4=new wg,Xg.polygonStart()},polygonEnd:function(){Xg.polygonEnd(),Km.point=hV,Km.lineStart=$oe,Km.lineEnd=Woe,sC<0?(Oo=-(cl=180),th=-(Wh=90)):u4>Zi?Wh=90:u4<-Zi&&(th=-90),Yg[0]=Oo,Yg[1]=cl},sphere:function(){Oo=-(cl=180),th=-(Wh=90)}};function hV(n,e){G1.push(Yg=[Oo=n,cl=n]),eWh&&(Wh=e)}function Kxe(n,e){var t=Dv([n*mi,e*mi]);if(__){var r=o3(__,t),i=[r[1],-r[0],0],s=o3(i,r);oC(s),s=aC(s);var a=n-ox,o=a>0?1:-1,l=s[0]*fl*o,c,u=_a(a)>180;u^(o*oxWh&&(Wh=c)):(l=(l+360)%360-180,u^(o*oxWh&&(Wh=e))),u?nVh(Oo,cl)&&(cl=n):Vh(n,cl)>Vh(Oo,cl)&&(Oo=n):cl>=Oo?(ncl&&(cl=n)):n>ox?Vh(Oo,n)>Vh(Oo,cl)&&(cl=n):Vh(n,cl)>Vh(Oo,cl)&&(Oo=n)}else G1.push(Yg=[Oo=n,cl=n]);eWh&&(Wh=e),__=t,ox=n}function $oe(){Km.point=Kxe}function Woe(){Yg[0]=Oo,Yg[1]=cl,Km.point=hV,__=null}function Jxe(n,e){if(__){var t=n-ox;u4.add(_a(t)>180?t+(t>0?360:-360):t)}else Zxe=n,Qxe=e;Xg.point(n,e),Kxe(n,e)}function Ott(){Xg.lineStart()}function jtt(){Jxe(Zxe,Qxe),Xg.lineEnd(),_a(u4)>Zi&&(Oo=-(cl=180)),Yg[0]=Oo,Yg[1]=cl,__=null}function Vh(n,e){return(e-=n)<0?e+360:e}function Ftt(n,e){return n[0]-e[0]}function Xoe(n,e){return n[0]<=n[1]?n[0]<=e&&e<=n[1]:eVh(r[0],r[1])&&(r[1]=i[1]),Vh(i[0],r[1])>Vh(r[0],r[1])&&(r[0]=i[0])):s.push(r=i);for(a=-1/0,t=s.length-1,e=0,r=s[t];e<=t;r=i,++e)i=s[e],(o=Vh(r[1],i[0]))>a&&(a=o,Oo=i[0],cl=r[1])}return G1=Yg=null,Oo===1/0||th===1/0?[[NaN,NaN],[NaN,NaN]]:[[Oo,th],[cl,Wh]]}var D5,lC,cC,uC,dC,hC,fC,pC,fV,pV,mV,tve,nve,Nd,Md,Cd,O0={sphere:Ju,point:gW,lineStart:Yoe,lineEnd:Zoe,polygonStart:function(){O0.lineStart=ztt,O0.lineEnd=Vtt},polygonEnd:function(){O0.lineStart=Yoe,O0.lineEnd=Zoe}};function gW(n,e){n*=mi,e*=mi;var t=bi(e);h6(t*bi(n),t*ci(n),ci(e))}function h6(n,e,t){++D5,cC+=(n-cC)/D5,uC+=(e-uC)/D5,dC+=(t-dC)/D5}function Yoe(){O0.point=Btt}function Btt(n,e){n*=mi,e*=mi;var t=bi(e);Nd=t*bi(n),Md=t*ci(n),Cd=ci(e),O0.point=Utt,h6(Nd,Md,Cd)}function Utt(n,e){n*=mi,e*=mi;var t=bi(e),r=t*bi(n),i=t*ci(n),s=ci(e),a=t0($g((a=Md*s-Cd*i)*a+(a=Cd*r-Nd*s)*a+(a=Nd*i-Md*r)*a),Nd*r+Md*i+Cd*s);lC+=a,hC+=a*(Nd+(Nd=r)),fC+=a*(Md+(Md=i)),pC+=a*(Cd+(Cd=s)),h6(Nd,Md,Cd)}function Zoe(){O0.point=gW}function ztt(){O0.point=qtt}function Vtt(){rve(tve,nve),O0.point=gW}function qtt(n,e){tve=n,nve=e,n*=mi,e*=mi,O0.point=rve;var t=bi(e);Nd=t*bi(n),Md=t*ci(n),Cd=ci(e),h6(Nd,Md,Cd)}function rve(n,e){n*=mi,e*=mi;var t=bi(e),r=t*bi(n),i=t*ci(n),s=ci(e),a=Md*s-Cd*i,o=Cd*r-Nd*s,l=Nd*i-Md*r,c=oV(a,o,l),u=Wg(c),d=c&&-u/c;fV.add(d*a),pV.add(d*o),mV.add(d*l),lC+=u,hC+=u*(Nd+(Nd=r)),fC+=u*(Md+(Md=i)),pC+=u*(Cd+(Cd=s)),h6(Nd,Md,Cd)}function Qoe(n){D5=lC=cC=uC=dC=hC=fC=pC=0,fV=new wg,pV=new wg,mV=new wg,fR(n,O0);var e=+fV,t=+pV,r=+mV,i=oV(e,t,r);return iks&&(n-=Math.round(n/cf)*cf),[n,e]}AV.invert=AV;function ive(n,e,t){return(n%=cf)?e||t?gV(Joe(n),ele(e,t)):Joe(n):e||t?ele(e,t):AV}function Koe(n){return function(e,t){return e+=n,_a(e)>ks&&(e-=Math.round(e/cf)*cf),[e,t]}}function Joe(n){var e=Koe(n);return e.invert=Koe(-n),e}function ele(n,e){var t=bi(n),r=ci(n),i=bi(e),s=ci(e);function a(o,l){var c=bi(l),u=bi(o)*c,d=ci(o)*c,h=ci(l),p=h*t+u*r;return[t0(d*i-p*s,u*t-h*r),Wg(p*i+d*s)]}return a.invert=function(o,l){var c=bi(l),u=bi(o)*c,d=ci(o)*c,h=ci(l),p=h*i-d*s;return[t0(d*i+h*s,u*t+p*r),Wg(p*t-u*r)]},a}function Gtt(n){n=ive(n[0]*mi,n[1]*mi,n.length>2?n[2]*mi:0);function e(t){return t=n(t[0]*mi,t[1]*mi),t[0]*=fl,t[1]*=fl,t}return e.invert=function(t){return t=n.invert(t[0]*mi,t[1]*mi),t[0]*=fl,t[1]*=fl,t},e}function Htt(n,e,t,r,i,s){if(t){var a=bi(e),o=ci(e),l=r*t;i==null?(i=e+r*cf,s=e-l/2):(i=tle(a,i),s=tle(a,s),(r>0?is)&&(i+=r*cf));for(var c,u=i;r>0?u>s:u1&&n.push(n.pop().concat(n.shift()))},result:function(){var t=n;return n=[],e=null,t}}}function xN(n,e){return _a(n[0]-e[0])=0;--o)i.point((d=u[o])[0],d[1]);else r(h.x,h.p.x,-1,i);h=h.p}h=h.o,u=h.z,p=!p}while(!h.v);i.lineEnd()}}}function nle(n){if(e=n.length){for(var e,t=0,r=n[0],i;++t=0?1:-1,$=V*O,G=$>ks,H=_*U;if(l.add(t0(H*V*ci($),y*z+H*bi($))),a+=G?O+V*cf:O,G^g>=t^k>=t){var K=o3(Dv(p),Dv(C));oC(K);var W=o3(s,K);oC(W);var J=(G^O>=0?-1:1)*Wg(W[2]);(r>J||r===J&&(K[0]||K[1]))&&(o+=G^O>=0?1:-1)}}return(a<-Zi||a0){for(l||(i.polygonStart(),l=!0),i.lineStart(),U=0;U1&&k&2&&B.push(B.pop().concat(B.shift())),u.push(B.filter($tt))}}return h}}function $tt(n){return n.length>1}function Wtt(n,e){return((n=n.x)[0]<0?n[1]-sh-Zi:sh-n[1])-((e=e.x)[0]<0?e[1]-sh-Zi:sh-e[1])}const rle=lve(function(){return!0},Xtt,Ztt,[-ks,-sh]);function Xtt(n){var e=NaN,t=NaN,r=NaN,i;return{lineStart:function(){n.lineStart(),i=1},point:function(s,a){var o=s>0?ks:-ks,l=_a(s-e);_a(l-ks)0?sh:-sh),n.point(r,t),n.lineEnd(),n.lineStart(),n.point(o,t),n.point(s,t),i=0):r!==o&&l>=ks&&(_a(e-r)Zi?mW((ci(e)*(s=bi(r))*ci(t)-ci(r)*(i=bi(e))*ci(n))/(i*s*a)):(e+r)/2}function Ztt(n,e,t,r){var i;if(n==null)i=t*sh,r.point(-ks,i),r.point(0,i),r.point(ks,i),r.point(ks,0),r.point(ks,-i),r.point(0,-i),r.point(-ks,-i),r.point(-ks,0),r.point(-ks,i);else if(_a(n[0]-e[0])>Zi){var s=n[0]0,i=_a(e)>Zi;function s(u,d,h,p){Htt(p,n,t,h,u,d)}function a(u,d){return bi(u)*bi(d)>e}function o(u){var d,h,p,g,x;return{lineStart:function(){g=p=!1,x=1},point:function(_,y){var M=[_,y],C,k=a(_,y),B=r?k?0:c(_,y):k?c(_+(_<0?ks:-ks),y):0;if(!d&&(g=p=k)&&u.lineStart(),k!==p&&(C=l(d,M),(!C||xN(d,C)||xN(M,C))&&(M[2]=1)),k!==p)x=0,k?(u.lineStart(),C=l(M,d),u.point(C[0],C[1])):(C=l(d,M),u.point(C[0],C[1],2),u.lineEnd()),d=C;else if(i&&d&&r^k){var U;!(B&h)&&(U=l(M,d,!0))&&(x=0,r?(u.lineStart(),u.point(U[0][0],U[0][1]),u.point(U[1][0],U[1][1]),u.lineEnd()):(u.point(U[1][0],U[1][1]),u.lineEnd(),u.lineStart(),u.point(U[0][0],U[0][1],3)))}k&&(!d||!xN(d,M))&&u.point(M[0],M[1]),d=M,p=k,h=B},lineEnd:function(){p&&u.lineEnd(),d=null},clean:function(){return x|(g&&p)<<1}}}function l(u,d,h){var p=Dv(u),g=Dv(d),x=[1,0,0],_=o3(p,g),y=b8(_,_),M=_[0],C=y-M*M;if(!C)return!h&&u;var k=e*y/C,B=-e*M/C,U=o3(x,_),z=_8(x,k),O=_8(_,B);vF(z,O);var V=U,$=b8(z,V),G=b8(V,V),H=$*$-G*(b8(z,z)-1);if(!(H<0)){var K=$g(H),W=_8(V,(-$-K)/G);if(vF(W,z),W=aC(W),!h)return W;var J=u[0],ie=d[0],ae=u[1],Q=d[1],re;ie0^W[1]<(_a(W[0]-J)ks^(J<=W[0]&&W[0]<=ie)){var me=_8(V,(-$+K)/G);return vF(me,z),[W,aC(me)]}}}function c(u,d){var h=r?n:ks-n,p=0;return u<-h?p|=1:u>h&&(p|=2),d<-h?p|=4:d>h&&(p|=8),p}return lve(a,o,s,r?[0,-n]:[-ks,n-ks])}function Ktt(n,e,t,r,i,s){var a=n[0],o=n[1],l=e[0],c=e[1],u=0,d=1,h=l-a,p=c-o,g;if(g=t-a,!(!h&&g>0)){if(g/=h,h<0){if(g0){if(g>d)return;g>u&&(u=g)}if(g=i-a,!(!h&&g<0)){if(g/=h,h<0){if(g>d)return;g>u&&(u=g)}else if(h>0){if(g0)){if(g/=p,p<0){if(g0){if(g>d)return;g>u&&(u=g)}if(g=s-o,!(!p&&g<0)){if(g/=p,p<0){if(g>d)return;g>u&&(u=g)}else if(p>0){if(g0&&(n[0]=a+u*h,n[1]=o+u*p),d<1&&(e[0]=a+d*h,e[1]=o+d*p),!0}}}}}var O5=1e9,S8=-O5;function Jtt(n,e,t,r){function i(c,u){return n<=c&&c<=t&&e<=u&&u<=r}function s(c,u,d,h){var p=0,g=0;if(c==null||(p=a(c,d))!==(g=a(u,d))||l(c,u)<0^d>0)do h.point(p===0||p===3?n:t,p>1?r:e);while((p=(p+d+4)%4)!==g);else h.point(u[0],u[1])}function a(c,u){return _a(c[0]-n)0?0:3:_a(c[0]-t)0?2:1:_a(c[1]-e)0?1:0:u>0?3:2}function o(c,u){return l(c.x,u.x)}function l(c,u){var d=a(c,1),h=a(u,1);return d!==h?d-h:d===0?u[1]-c[1]:d===1?c[0]-u[0]:d===2?c[1]-u[1]:u[0]-c[0]}return function(c){var u=c,d=sve(),h,p,g,x,_,y,M,C,k,B,U,z={point:O,lineStart:H,lineEnd:K,polygonStart:$,polygonEnd:G};function O(J,ie){i(J,ie)&&u.point(J,ie)}function V(){for(var J=0,ie=0,ae=p.length;ier&&(Ae-ee)*(r-me)>(be-me)*(n-ee)&&++J:be<=r&&(Ae-ee)*(r-me)<(be-me)*(n-ee)&&--J;return J}function $(){u=d,h=[],p=[],U=!0}function G(){var J=V(),ie=U&&J,ae=(h=mS(h)).length;(ie||ae)&&(c.polygonStart(),ie&&(c.lineStart(),s(null,null,1,c),c.lineEnd()),ae&&ave(h,o,J,s,c),c.polygonEnd()),u=c,h=p=g=null}function H(){z.point=W,p&&p.push(g=[]),B=!0,k=!1,M=C=NaN}function K(){h&&(W(x,_),y&&k&&d.rejoin(),h.push(d.result())),z.point=O,k&&u.lineEnd()}function W(J,ie){var ae=i(J,ie);if(p&&g.push([J,ie]),B)x=J,_=ie,y=ae,B=!1,ae&&(u.lineStart(),u.point(J,ie));else if(ae&&k)u.point(J,ie);else{var Q=[M=Math.max(S8,Math.min(O5,M)),C=Math.max(S8,Math.min(O5,C))],re=[J=Math.max(S8,Math.min(O5,J)),ie=Math.max(S8,Math.min(O5,ie))];Ktt(Q,re,n,e,t,r)?(k||(u.lineStart(),u.point(Q[0],Q[1])),u.point(re[0],re[1]),ae||u.lineEnd(),U=!1):ae&&(u.lineStart(),u.point(J,ie),U=!1)}M=J,C=ie,k=ae}return z}}var xV,vV,vN,yN,l3={sphere:Ju,point:Ju,lineStart:ent,lineEnd:Ju,polygonStart:Ju,polygonEnd:Ju};function ent(){l3.point=nnt,l3.lineEnd=tnt}function tnt(){l3.point=l3.lineEnd=Ju}function nnt(n,e){n*=mi,e*=mi,vV=n,vN=ci(e),yN=bi(e),l3.point=rnt}function rnt(n,e){n*=mi,e*=mi;var t=ci(e),r=bi(e),i=_a(n-vV),s=bi(i),a=ci(i),o=r*a,l=yN*t-vN*r*s,c=vN*t+yN*r*s;xV.add(t0($g(o*o+l*l),c)),vV=n,vN=t,yN=r}function int(n){return xV=new wg,fR(n,l3),+xV}var yV=[null,null],snt={type:"LineString",coordinates:yV};function qA(n,e){return yV[0]=n,yV[1]=e,int(snt)}var ile={Feature:function(n,e){return mC(n.geometry,e)},FeatureCollection:function(n,e){for(var t=n.features,r=-1,i=t.length;++r0&&(i=qA(n[s],n[s-1]),i>0&&t<=i&&r<=i&&(t+r-i)*(1-Math.pow((t-r)/i,2))Zi}).map(h)).concat(e_(y8(s/c)*c,i,c).filter(function(C){return _a(C%d)>Zi}).map(p))}return y.lines=function(){return M().map(function(C){return{type:"LineString",coordinates:C}})},y.outline=function(){return{type:"Polygon",coordinates:[g(r).concat(x(a).slice(1),g(t).reverse().slice(1),x(o).reverse().slice(1))]}},y.extent=function(C){return arguments.length?y.extentMajor(C).extentMinor(C):y.extentMinor()},y.extentMajor=function(C){return arguments.length?(r=+C[0][0],t=+C[1][0],o=+C[0][1],a=+C[1][1],r>t&&(C=r,r=t,t=C),o>a&&(C=o,o=a,a=C),y.precision(_)):[[r,o],[t,a]]},y.extentMinor=function(C){return arguments.length?(e=+C[0][0],n=+C[1][0],s=+C[0][1],i=+C[1][1],e>n&&(C=e,e=n,n=C),s>i&&(C=s,s=i,i=C),y.precision(_)):[[e,s],[n,i]]},y.step=function(C){return arguments.length?y.stepMajor(C).stepMinor(C):y.stepMinor()},y.stepMajor=function(C){return arguments.length?(u=+C[0],d=+C[1],y):[u,d]},y.stepMinor=function(C){return arguments.length?(l=+C[0],c=+C[1],y):[l,c]},y.precision=function(C){return arguments.length?(_=+C,h=cle(s,i,90),p=ule(e,n,_),g=cle(o,a,90),x=ule(r,t,_),y):_},y.extentMajor([[-180,-90+Zi],[180,90-Zi]]).extentMinor([[-180,-80-Zi],[180,80+Zi]])}function cnt(){return lnt()()}function AW(n,e){var t=n[0]*mi,r=n[1]*mi,i=e[0]*mi,s=e[1]*mi,a=bi(r),o=ci(r),l=bi(s),c=ci(s),u=a*bi(t),d=a*ci(t),h=l*bi(i),p=l*ci(i),g=2*Wg($g(zoe(s-r)+a*l*zoe(i-t))),x=ci(g),_=g?function(y){var M=ci(y*=g)/x,C=ci(g-y)/x,k=C*u+M*h,B=C*d+M*p,U=C*o+M*c;return[t0(B,k)*fl,t0(U,$g(k*k+B*B))*fl]}:function(){return[t*fl,r*fl]};return _.distance=g,_}const dle=n=>n;var c3=1/0,gC=c3,gS=-c3,AC=gS,hle={point:unt,lineStart:Ju,lineEnd:Ju,polygonStart:Ju,polygonEnd:Ju,result:function(){var n=[[c3,gC],[gS,AC]];return gS=AC=-(gC=c3=1/0),n}};function unt(n,e){ngS&&(gS=n),eAC&&(AC=e)}function xW(n){return function(e){var t=new bV;for(var r in n)t[r]=n[r];return t.stream=e,t}}function bV(){}bV.prototype={constructor:bV,point:function(n,e){this.stream.point(n,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function vW(n,e,t){var r=n.clipExtent&&n.clipExtent();return n.scale(150).translate([0,0]),r!=null&&n.clipExtent(null),fR(t,n.stream(hle)),e(hle.result()),r!=null&&n.clipExtent(r),n}function uve(n,e,t){return vW(n,function(r){var i=e[1][0]-e[0][0],s=e[1][1]-e[0][1],a=Math.min(i/(r[1][0]-r[0][0]),s/(r[1][1]-r[0][1])),o=+e[0][0]+(i-a*(r[1][0]+r[0][0]))/2,l=+e[0][1]+(s-a*(r[1][1]+r[0][1]))/2;n.scale(150*a).translate([o,l])},t)}function dnt(n,e,t){return uve(n,[[0,0],e],t)}function hnt(n,e,t){return vW(n,function(r){var i=+e,s=i/(r[1][0]-r[0][0]),a=(i-s*(r[1][0]+r[0][0]))/2,o=-s*r[0][1];n.scale(150*s).translate([a,o])},t)}function fnt(n,e,t){return vW(n,function(r){var i=+e,s=i/(r[1][1]-r[0][1]),a=-s*r[0][0],o=(i-s*(r[1][1]+r[0][1]))/2;n.scale(150*s).translate([a,o])},t)}var fle=16,pnt=bi(30*mi);function ple(n,e){return+e?gnt(n,e):mnt(n)}function mnt(n){return xW({point:function(e,t){e=n(e,t),this.stream.point(e[0],e[1])}})}function gnt(n,e){function t(r,i,s,a,o,l,c,u,d,h,p,g,x,_){var y=c-r,M=u-i,C=y*y+M*M;if(C>4*e&&x--){var k=a+h,B=o+p,U=l+g,z=$g(k*k+B*B+U*U),O=Wg(U/=z),V=_a(_a(U)-1)e||_a((y*K+M*W)/C-.5)>.3||a*h+o*p+l*g2?J[2]%360*mi:0,K()):[o*fl,l*fl,c*fl]},G.angle=function(J){return arguments.length?(d=J%360*mi,K()):d*fl},G.reflectX=function(J){return arguments.length?(h=J?-1:1,K()):h<0},G.reflectY=function(J){return arguments.length?(p=J?-1:1,K()):p<0},G.precision=function(J){return arguments.length?(U=ple(z,B=J*J),W()):$g(B)},G.fitExtent=function(J,ie){return uve(G,J,ie)},G.fitSize=function(J,ie){return dnt(G,J,ie)},G.fitWidth=function(J,ie){return hnt(G,J,ie)},G.fitHeight=function(J,ie){return fnt(G,J,ie)};function K(){var J=mle(t,0,0,h,p,d).apply(null,e(s,a)),ie=mle(t,r-J[0],i-J[1],h,p,d);return u=ive(o,l,c),z=gV(e,ie),O=gV(u,z),U=ple(z,B),W()}function W(){return V=$=null,G}return function(){return e=n.apply(this,arguments),G.invert=e.invert&&H,K()}}function _nt(n){return function(e,t){var r=$g(e*e+t*t),i=n(r),s=ci(i),a=bi(i);return[t0(e*s,r*a),Wg(r&&t*s/r)]}}function yW(n,e){return[n,Ctt(Rtt((sh+e)/2))]}yW.invert=function(n,e){return[n,2*mW(Mtt(e))-sh]};function dve(n,e){var t=bi(e),r=1+bi(n)*t;return[t*ci(n)/r,ci(e)/r]}dve.invert=_nt(function(n){return 2*mW(n)});function wnt(){return ynt(dve).scale(250).clipAngle(142)}function _V(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,i=Hg().domain([1,0]).range([t,r]).clamp(!0),s=Hg().domain([bF(t),bF(r)]).range([1,0]).clamp(!0),a=function(d){return s(bF(i(d)))},o=e.array,l=0,c=o.length;l2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0,o=[],l=Math.pow(2,e),c=360/l,u=180/l,d=s===void 0?l-1:s,h=a===void 0?l-1:a,p=r,g=Math.min(l-1,d);p<=g;p++)for(var x=i,_=Math.min(l-1,h);x<=_;x++){var y=x,M=u;if(t){y=x===0?x:gle(x/l)*l;var C=x+1===l?x+1:gle((x+1)/l)*l;M=(C-y)*180/l}var k=-180+(p+.5)*c,B=90-(y*180/l+M/2),U=M;o.push({x:p,y:x,lng:k,lat:B,latLen:U})}return o},znt=6,Vnt=7,qnt=3,Gnt=90,Up=new WeakMap,K1=new WeakMap,_F=new WeakMap,T8=new WeakMap,Lf=new WeakMap,vC=new WeakMap,w_=new WeakMap,V2=new WeakMap,E8=new WeakSet,Hnt=function(n){function e(t){var r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=i.tileUrl,a=i.minLevel,o=a===void 0?0:a,l=i.maxLevel,c=l===void 0?17:l,u=i.mercatorProjection,d=u===void 0?!0:u;return Mnt(this,e),r=Nnt(this,e),Cnt(r,E8),N1(r,Up,void 0),N1(r,K1,void 0),N1(r,_F,void 0),N1(r,T8,void 0),N1(r,Lf,{}),N1(r,vC,void 0),N1(r,w_,void 0),N1(r,V2,void 0),Jy(r,"minLevel",void 0),Jy(r,"maxLevel",void 0),Jy(r,"thresholds",pve(new Array(30)).map(function(h,p){return 8/Math.pow(2,p)})),Jy(r,"curvatureResolution",5),Jy(r,"tileMargin",0),Jy(r,"clearTiles",function(){Object.values(Xi(Lf,r)).forEach(function(h){h.forEach(function(p){p.obj&&(r.remove(p.obj),SV(p.obj),delete p.obj)})}),M1(Lf,r,{})}),M1(Up,r,t),r.tileUrl=s,M1(K1,r,d),r.minLevel=o,r.maxLevel=c,r.level=0,r.add(M1(V2,r,new ui(new gf(Xi(Up,r)*.99,180,90),new oc({color:0})))),Xi(V2,r).visible=!1,Xi(V2,r).material.polygonOffset=!0,Xi(V2,r).material.polygonOffsetUnits=3,Xi(V2,r).material.polygonOffsetFactor=1,r}return Lnt(e,n),Rnt(e,[{key:"tileUrl",get:function(){return Xi(_F,this)},set:function(r){M1(_F,this,r),this.updatePov(Xi(w_,this))}},{key:"level",get:function(){return Xi(T8,this)},set:function(r){var i,s=this;Xi(Lf,this)[r]||d4(E8,this,$nt).call(this,r);var a=Xi(T8,this);if(M1(T8,this,r),!(r===a||a===void 0)){if(Xi(V2,this).visible=r>0,Xi(Lf,this)[r].forEach(function(l){return l.obj&&(l.obj.material.depthWrite=!0)}),ar)for(var o=r+1;o<=a;o++)Xi(Lf,this)[o]&&Xi(Lf,this)[o].forEach(function(l){l.obj&&(s.remove(l.obj),SV(l.obj),delete l.obj)});d4(E8,this,xle).call(this)}}},{key:"updatePov",value:function(r){var i=this;if(!(!r||!(r instanceof iy))){M1(w_,this,r);var s;if(M1(vC,this,function(u){if(!u.hullPnts){var d=360/Math.pow(2,i.level),h=u.lng,p=u.lat,g=u.latLen,x=h-d/2,_=h+d/2,y=p-g/2,M=p+g/2;u.hullPnts=[[p,h],[y,x],[M,x],[y,_],[M,_]].map(function(C){var k=bN(C,2),B=k[0],U=k[1];return xve(B,U,Xi(Up,i))}).map(function(C){var k=C.x,B=C.y,U=C.z;return new Fe(k,B,U)})}return s||(s=new Vg,r.updateMatrix(),r.updateMatrixWorld(),s.setFromProjectionMatrix(new ir().multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse))),u.hullPnts.some(function(C){return s.containsPoint(C.clone().applyMatrix4(i.matrixWorld))})}),this.tileUrl){var a=r.position.clone(),o=a.distanceTo(this.getWorldPosition(new Fe)),l=(o-Xi(Up,this))/Xi(Up,this),c=this.thresholds.findIndex(function(u){return u&&u<=l});this.level=Math.min(this.maxLevel,Math.max(this.minLevel,c<0?this.thresholds.length:c)),d4(E8,this,xle).call(this)}}}}])}(nd);function $nt(n){var e=this;if(n>Vnt){Xi(Lf,this)[n]=[];return}var t=Xi(Lf,this)[n]=TV(n,Xi(K1,this));t.forEach(function(r){return r.centroid=xve(r.lat,r.lng,Xi(Up,e))}),t.octree=Bxe().x(function(r){return r.centroid.x}).y(function(r){return r.centroid.y}).z(function(r){return r.centroid.z}).addAll(t)}function xle(){var n=this;if(!(!this.tileUrl||this.level===void 0||!Xi(Lf,this).hasOwnProperty(this.level))&&!(!Xi(vC,this)&&this.level>znt)){var e=Xi(Lf,this)[this.level];if(Xi(w_,this)){var t=this.worldToLocal(Xi(w_,this).position.clone());if(e.octree){var r,i=this.worldToLocal(Xi(w_,this).position.clone()),s=(i.length()-Xi(Up,this))*qnt;e=(r=e.octree).findAllWithinRadius.apply(r,pve(i).concat([s]))}else{var a=Bnt(t),o=(a.r/Xi(Up,this)-1)*Gnt,l=o/Math.cos(z2(a.lat)),c=[a.lng-l,a.lng+l],u=[a.lat+o,a.lat-o],d=Ale(this.level,Xi(K1,this),c[0],u[0]),h=bN(d,2),p=h[0],g=h[1],x=Ale(this.level,Xi(K1,this),c[1],u[1]),_=bN(x,2),y=_[0],M=_[1];!e.record&&(e.record={});var C=e.record;if(!C.hasOwnProperty("".concat(Math.round((p+y)/2),"_").concat(Math.round((g+M)/2))))e=TV(this.level,Xi(K1,this),p,g,y,M).map(function(O){var V="".concat(O.x,"_").concat(O.y);return C.hasOwnProperty(V)?C[V]:(C[V]=O,e.push(O),O)});else{for(var k=[],B=p;B<=y;B++)for(var U=g;U<=M;U++){var z="".concat(B,"_").concat(U);C.hasOwnProperty(z)||(C[z]=TV(this.level,Xi(K1,this),B,U,B,U)[0],e.push(C[z])),k.push(C[z])}e=k}}}e.filter(function(O){return!O.obj}).filter(Xi(vC,this)||function(){return!0}).forEach(function(O){var V=O.x,$=O.y,G=O.lng,H=O.lat,K=O.latLen,W=360/Math.pow(2,n.level);if(!O.obj){var J=W*(1-n.tileMargin),ie=K*(1-n.tileMargin),ae=z2(G),Q=z2(-H),re=new ui(new gf(Xi(Up,n),Math.ceil(J/n.curvatureResolution),Math.ceil(ie/n.curvatureResolution),z2(90-J/2)+ae,z2(J),z2(90-ie/2)+Q,z2(ie)),new op);if(Xi(K1,n)){var oe=[H+K/2,H-K/2].map(function(Ae){return .5-Ae/180}),fe=bN(oe,2),ee=fe[0],me=fe[1];Unt(re.geometry.attributes.uv,ee,me)}O.obj=re}O.loading||(O.loading=!0,new ry().load(n.tileUrl(V,$,n.level),function(Ae){var be=O.obj;be&&(Ae.colorSpace=ic,be.material.map=Ae,be.material.color=null,be.material.needsUpdate=!0,n.add(be)),O.loading=!1}))})}}const AS=new Set;let EV=!1;function Wnt(n,e,t=2){const r=e&&e.length,i=r?e[0]*t:n.length;AS.size&&AS.clear();let s=yve(n,0,i,t,!0);const a=[];if(!s||s.next===s.prev)return a;let o=0,l=0,c=0;if(r&&(s=Knt(n,e,s,t)),n.length>80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=p),g>d&&(d=g)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return NV(s,a,o,l,c),a}function yve(n,e,t,r,i){let s=null;if(i===drt(n,e,t,r)>0)for(let a=e;a=e;a-=r)s=ble(a/r|0,n[a],n[a+1],s);return s&&xS(s,s.next)&&(yS(s),s=s.next),s}function Ov(n,e=n){const t=e===n;let r=n,i;do i=!1,r!==r.next&&(AS.size===0||!AS.has(r))&&(xS(r,r.next)||Xl(r.prev,r,r.next)===0)?((t||r===e)&&(e=r.prev),EV=!0,yS(r),r=r.prev,i=!0):(t||r!==e)&&(r=r.next,i=!t);while(i||r!==e);return e}function NV(n,e,t,r,i){i&&srt(n,t,r,i);let s=n,a=!1;for(;n.prev!==n.next;){const o=n.prev,l=n.next;if(Xl(o,n,l)<0&&(i?Ynt(n,t,r,i):Xnt(n))){e.push(o.i,n.i,l.i),yS(n),n=l,s=l;continue}if(n=l,n===s){if(EV=!1,n=Ov(n),EV){s=n;continue}if(!a){n=Znt(n,e),s=n,a=!0;continue}Qnt(n,e,t,r,i);break}}}function Xnt(n){const e=n.prev,t=n,r=n.next,i=e.x,s=t.x,a=r.x,o=e.y,l=t.y,c=r.y,u=Math.min(i,s,a),d=Math.min(o,l,c),h=Math.max(i,s,a),p=Math.max(o,l,c);let g=r.next;for(;g!==e;){if(g.x>=u&&g.x<=h&&g.y>=d&&g.y<=p&&!(i===g.x&&o===g.y)&&bC(i,o,s,l,a,c,g.x,g.y)&&Xl(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function Ynt(n,e,t,r){const i=n.prev,s=n,a=n.next,o=i.x,l=s.x,c=a.x,u=i.y,d=s.y,h=a.y,p=Math.min(o,l,c),g=Math.min(u,d,h),x=Math.max(o,l,c),_=Math.max(u,d,h),y=RV(p,g,e,t,r),M=RV(x,_,e,t,r);let C=n.prevZ;for(;C&&C.z>=y;){if(C.x>=p&&C.x<=x&&C.y>=g&&C.y<=_&&C!==a&&!(o===C.x&&u===C.y)&&bC(o,u,l,d,c,h,C.x,C.y)&&Xl(C.prev,C,C.next)>=0)return!1;C=C.prevZ}let k=n.nextZ;for(;k&&k.z<=M;){if(k.x>=p&&k.x<=x&&k.y>=g&&k.y<=_&&k!==a&&!(o===k.x&&u===k.y)&&bC(o,u,l,d,c,h,k.x,k.y)&&Xl(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function Znt(n,e){let t=n,r=!1;do{const i=t.prev,s=t.next.next;wve(i,t,t.next,s,!1)&&vS(i,s)&&vS(s,i)&&(e.push(i.i,t.i,s.i),yS(t),yS(t.next),t=n=s,r=!0),t=t.next}while(t!==n);return r?Ov(t):t}function Qnt(n,e,t,r,i){let s=n;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&lrt(s,a)){let o=Sve(s,a);s=Ov(s,s.next),o=Ov(o,o.next),NV(s,e,t,r,i),NV(o,e,t,r,i);return}a=a.next}s=s.next}while(s!==n)}let MV=!1;function Knt(n,e,t,r){const i=[];for(let s=0,a=e.length;sa&&(a=t.x),t.yo&&(o=t.y),u.xa&&(a=u.x),u.yo&&(o=u.y),t=u}while(++lpl[t+2]&&(pl[t+2]=e.x),e.y>pl[t+3]&&(pl[t+3]=e.y)}function vle(n){let e=PV[n];for(;e.prev.next!==e;)e=e.next;return PV[n]=e,e}function yle(n){let e=CV[n];for(;e.prev.next!==e;)e=e.next;return CV[n]=e,e}function rrt(n,e){let t=e;const r=n.x,i=n.y;let s=-1/0,a;if(xS(n,t))return t;for(let h=0,p=0;hpl[p+3]||pl[p]>r||pl[p+2]<=s)continue;const g=vle(h);t=yle(h);do{if(t.prev.next===t){if(xS(n,t.next))return t.next;if(i<=t.y&&i>=t.next.y&&t.next.y!==t.y){const x=t.x+(i-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(x<=r&&x>s&&(s=x,a=t.xr||pl[p+3]u)continue;const g=vle(h);t=yle(h);do{if(t.prev.next===t&&r>=t.x&&t.x>=o&&r!==t.x&&bC(ir)&&(xa.x||t.x===a.x&&irt(a,t)))&&(a=t,d=x)}t=t.next}while(t!==g)}return a}function irt(n,e){return Xl(n.prev,n,e.prev)<0&&Xl(e.next,n,n.next)<0}const Pf=[];let Ow=[],q2=new Uint32Array(0),jw=new Uint32Array(0);const Fw=new Uint32Array(256);function srt(n,e,t,r){let i=n,s=0;do i.z=RV(i.x,i.y,e,t,r),Pf[s++]=i,i=i.next;while(i!==n);art(s);let a=null;for(let o=0;o=0&&Pf[i].z>r;)Pf[i+1]=Pf[i],i--;Pf[i+1]=t}return}q2.length>>s&255]++;let a=0;for(let o=0;o<256;o++){const l=Fw[o];Fw[o]=a,a+=l}for(let o=0;o>>s&255]++;r[c]=e[o],i[c]=l}}function RV(n,e,t,r,i){return n=(n-t)*i|0,e=(e-r)*i|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function ort(n){let e=n,t=n;do(e.x=(n-a)*(s-o)&&(n-a)*(r-o)>=(t-a)*(e-o)&&(t-a)*(s-o)>=(i-a)*(r-o)}function lrt(n,e){const t=xS(n,e)&&Xl(n.prev,n,n.next)>0&&Xl(e.prev,e,e.next)>0;return n.next.i!==e.i&&(t||vS(n,e)&&vS(e,n)&&(Xl(n.prev,n,e.prev)!==0||Xl(n,e.prev,e)!==0))&&!crt(n,e)&&(t||urt(n,e))}function Xl(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function xS(n,e){return n.x===e.x&&n.y===e.y}function wve(n,e,t,r,i=!0){const s=Xl(n,e,t),a=Xl(n,e,r),o=Xl(t,r,n),l=Xl(t,r,e);return(s>0&&a<0||s<0&&a>0)&&(o>0&&l<0||o<0&&l>0)?!0:i?!!(s===0&&M8(n,t,e)||a===0&&M8(n,r,e)||o===0&&M8(t,n,r)||l===0&&M8(t,e,r)):!1}function M8(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function crt(n,e){const t=Math.min(n.x,e.x),r=Math.max(n.x,e.x),i=Math.min(n.y,e.y),s=Math.max(n.y,e.y);let a=n;do{const o=a.next;if(a.x>r&&o.x>r||a.xs&&o.y>s||a.y=0&&Xl(n,n.prev,e)>=0:Xl(n,e,n.prev)<0||Xl(n,n.next,e)<0}function urt(n,e){let t=n,r=!1;const i=(n.x+e.x)/2,s=(n.y+e.y)/2;do{const a=t.next;t.y>s!=a.y>s&&i<(a.x-t.x)*(s-t.y)/(a.y-t.y)+t.x&&(r=!r),t=a}while(t!==n);return r}function Sve(n,e){const t=LV(n.i,n.x,n.y),r=LV(e.i,e.x,e.y),i=n.next,s=e.prev;return n.next=e,e.prev=n,t.next=i,i.prev=t,r.next=t,t.prev=r,s.next=r,r.prev=s,r}function ble(n,e,t,r){const i=LV(n,e,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function yS(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ),MV&&nrt(n.prev,n.next)}function LV(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function drt(n,e,t,r){let i=0;for(let s=e,a=t-r;sn.length)&&(e=n.length);for(var t=0,r=Array(e);t=n.length?{done:!0}:{done:!1,value:n[r++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,o=!1;return{s:function(){t=t.call(n)},n:function(){var l=t.next();return a=l.done,l},e:function(l){o=!0,s=l},f:function(){try{a||t.return==null||t.return()}finally{if(o)throw s}}}}function wC(n){return wC=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},wC(n)}function vrt(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),e&&IV(n,e)}function Tve(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Tve=function(){return!!n})()}function yrt(n){if(typeof Symbol<"u"&&n[Symbol.iterator]!=null||n["@@iterator"]!=null)return Array.from(n)}function brt(n,e){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var r,i,s,a,o=[],l=!0,c=!1;try{if(s=(t=t.call(n)).next,e===0){if(Object(t)!==t)return;l=!1}else for(;!(l=(r=s.call(t)).done)&&(o.push(r.value),o.length!==e);l=!0);}catch(u){c=!0,i=u}finally{try{if(!l&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}function _rt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wrt(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Srt(n,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return prt(n)}function IV(n,e){return IV=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},IV(n,e)}function Bw(n,e){return hrt(n)||brt(n,e)||bW(n,e)||_rt()}function Trt(n){return frt(n)||yrt(n)||bW(n)||wrt()}function bW(n,e){if(n){if(typeof n=="string")return kV(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?kV(n,e):void 0}}var _le=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,r=[],i=null;return e.forEach(function(s){if(i){var a=qA(s,i)*180/Math.PI;if(a>t)for(var o=AW(i,s),l=i.length>2||s.length>2?Ff(i[2]||0,s[2]||0):null,c=l?function(h){return[].concat(Trt(o(h)),[l(h)])}:o,u=1/Math.ceil(a/t),d=u;d<1;)r.push(c(d)),d+=u}r.push(i=s)}),r},DV=typeof window<"u"&&window.THREE?window.THREE:{BufferGeometry:Pr,Float32BufferAttribute:tr},Ert=new DV.BufferGeometry().setAttribute?"setAttribute":"addAttribute",Eve=function(n){function e(t){var r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5;grt(this,e),r=mrt(this,e),r.type="GeoJsonGeometry",r.parameters={geoJson:t,radius:i,resolution:s};var a=({Point:u,MultiPoint:d,LineString:h,MultiLineString:p,Polygon:g,MultiPolygon:x}[t.type]||function(){return[]})(t.coordinates,i),o=[],l=[],c=0;a.forEach(function(_){var y=o.length;Uw({indices:o,vertices:l},_),r.addGroup(y,o.length-y,c++)}),o.length&&r.setIndex(o),l.length&&r[Ert]("position",new DV.Float32BufferAttribute(l,3));function u(_,y){var M=wF(_[1],_[0],y+(_[2]||0)),C=[];return[{vertices:M,indices:C}]}function d(_,y){var M={vertices:[],indices:[]};return _.map(function(C){return u(C,y)}).forEach(function(C){var k=Bw(C,1),B=k[0];Uw(M,B)}),[M]}function h(_,y){for(var M=_le(_,s).map(function(O){var V=Bw(O,3),$=V[0],G=V[1],H=V[2],K=H===void 0?0:H;return wF(G,$,y+K)}),C=_C([M]),k=C.vertices,B=Math.round(k.length/3),U=[],z=1;z2&&arguments[2]!==void 0?arguments[2]:0,r=(90-n)*Math.PI/180,i=(90-e)*Math.PI/180;return[t*Math.sin(r)*Math.cos(i),t*Math.cos(r),t*Math.sin(r)*Math.sin(i)]}function Nrt(n,e,t=!0){if(!e||!e.isReady)throw new Error("THREE.BufferGeometryUtils: Initialized MikkTSpace library required.");if(!n.hasAttribute("position")||!n.hasAttribute("normal")||!n.hasAttribute("uv"))throw new Error('THREE.BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function r(a){if(a.normalized||a.isInterleavedBufferAttribute){const o=new Float32Array(a.count*a.itemSize);for(let l=0,c=0;l2&&(o[c++]=a.getZ(l));return o}return a.array instanceof Float32Array?a.array:new Float32Array(a.array)}const i=n.index?n.toNonIndexed():n,s=e.generateTangents(r(i.attributes.position),r(i.attributes.normal),r(i.attributes.uv));if(t)for(let a=3;a=2&&a.setY(o,n.getY(o)),r>=3&&a.setZ(o,n.getZ(o)),r>=4&&a.setW(o,n.getW(o));return a}function Rrt(n){const e=n.attributes,t=n.morphTargets,r=new Map;for(const i in e){const s=e[i];s.isInterleavedBufferAttribute&&(r.has(s)||r.set(s,SC(s)),e[i]=r.get(s))}for(const i in t){const s=t[i];s.isInterleavedBufferAttribute&&(r.has(s)||r.set(s,SC(s)),t[i]=r.get(s))}}function Lrt(n){let e=0;for(const r in n.attributes){const i=n.getAttribute(r);e+=i.count*i.itemSize*i.array.BYTES_PER_ELEMENT}const t=n.getIndex();return e+=t?t.count*t.itemSize*t.array.BYTES_PER_ELEMENT:0,e}function krt(n,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},r=n.getIndex(),i=n.getAttribute("position"),s=r?r.count:i.count;let a=0;const o=Object.keys(n.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let M=0,C=o.length;M{const V=new z.array.constructor(z.count*z.itemSize);c[k][O]=new z.constructor(V,z.itemSize,z.normalized)}))}const p=e*.5,g=Math.log10(1/e),x=Math.pow(10,g),_=p*x;for(let M=0;Ma.materialIndex!==o.materialIndex?a.materialIndex-o.materialIndex:a.start-o.start),n.getIndex()===null){const a=n.getAttribute("position"),o=[];for(let l=0;la&&(H+=re,K+=oe,W+=fe)}const J=1/(Math.sqrt(H*H+K*K+W*W)||1);C[3*$+0]=H*J,C[3*$+1]=K*J,C[3*$+2]=W*J}}return t.setAttribute("normal",new Gi(C,3,!1)),t}const _W=Object.freeze(Object.defineProperty({__proto__:null,computeMikkTSpaceTangents:Nrt,computeMorphedAttributes:Drt,deepCloneAttribute:Crt,deinterleaveAttribute:SC,deinterleaveGeometry:Rrt,estimateBytesUsed:Lrt,interleaveAttributes:Prt,mergeAttributes:OV,mergeGeometries:Mrt,mergeGroups:Ort,mergeVertices:krt,toCreasedNormals:jrt,toTrianglesDrawMode:Irt},Symbol.toStringTag,{value:"Module"}));var En=function(n){return typeof n=="function"?n:typeof n=="string"?function(e){return e[n]}:function(e){return n}};function TC(n){"@babel/helpers - typeof";return TC=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},TC(n)}var Frt=/^\s+/,Brt=/\s+$/;function kr(n,e){if(n=n||"",e=e||{},n instanceof kr)return n;if(!(this instanceof kr))return new kr(n,e);var t=Urt(n);this._originalInput=n,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}kr.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,r,i,s,a,o;return t=e.r/255,r=e.g/255,i=e.b/255,t<=.03928?s=t/12.92:s=Math.pow((t+.055)/1.055,2.4),r<=.03928?a=r/12.92:a=Math.pow((r+.055)/1.055,2.4),i<=.03928?o=i/12.92:o=Math.pow((i+.055)/1.055,2.4),.2126*s+.7152*a+.0722*o},setAlpha:function(e){return this._a=Nve(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=Tle(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=Tle(this._r,this._g,this._b),t=Math.round(e.h*360),r=Math.round(e.s*100),i=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+r+"%, "+i+"%)":"hsva("+t+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var e=Sle(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Sle(this._r,this._g,this._b),t=Math.round(e.h*360),r=Math.round(e.s*100),i=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+r+"%, "+i+"%)":"hsla("+t+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(e){return Ele(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return Grt(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(yo(this._r,255)*100)+"%",g:Math.round(yo(this._g,255)*100)+"%",b:Math.round(yo(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(yo(this._r,255)*100)+"%, "+Math.round(yo(this._g,255)*100)+"%, "+Math.round(yo(this._b,255)*100)+"%)":"rgba("+Math.round(yo(this._r,255)*100)+"%, "+Math.round(yo(this._g,255)*100)+"%, "+Math.round(yo(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:nit[Ele(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+Nle(this._r,this._g,this._b,this._a),r=t,i=this._gradientType?"GradientType = 1, ":"";if(e){var s=kr(e);r="#"+Nle(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+t+",endColorstr="+r+")"},toString:function(e){var t=!!e;e=e||this._format;var r=!1,i=this._a<1&&this._a>=0,s=!t&&i&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return kr(this.toString())},_applyModification:function(e,t){var r=e.apply(null,[this].concat([].slice.call(t)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Xrt,arguments)},brighten:function(){return this._applyModification(Yrt,arguments)},darken:function(){return this._applyModification(Zrt,arguments)},desaturate:function(){return this._applyModification(Hrt,arguments)},saturate:function(){return this._applyModification($rt,arguments)},greyscale:function(){return this._applyModification(Wrt,arguments)},spin:function(){return this._applyModification(Qrt,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(eit,arguments)},complement:function(){return this._applyCombination(Krt,arguments)},monochromatic:function(){return this._applyCombination(tit,arguments)},splitcomplement:function(){return this._applyCombination(Jrt,arguments)},triad:function(){return this._applyCombination(Mle,[3])},tetrad:function(){return this._applyCombination(Mle,[4])}};kr.fromRatio=function(n,e){if(TC(n)=="object"){var t={};for(var r in n)n.hasOwnProperty(r)&&(r==="a"?t[r]=n[r]:t[r]=j5(n[r]));n=t}return kr(n,e)};function Urt(n){var e={r:0,g:0,b:0},t=1,r=null,i=null,s=null,a=!1,o=!1;return typeof n=="string"&&(n=ait(n)),TC(n)=="object"&&(Gm(n.r)&&Gm(n.g)&&Gm(n.b)?(e=zrt(n.r,n.g,n.b),a=!0,o=String(n.r).substr(-1)==="%"?"prgb":"rgb"):Gm(n.h)&&Gm(n.s)&&Gm(n.v)?(r=j5(n.s),i=j5(n.v),e=qrt(n.h,r,i),a=!0,o="hsv"):Gm(n.h)&&Gm(n.s)&&Gm(n.l)&&(r=j5(n.s),s=j5(n.l),e=Vrt(n.h,r,s),a=!0,o="hsl"),n.hasOwnProperty("a")&&(t=n.a)),t=Nve(t),{ok:a,format:n.format||o,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function zrt(n,e,t){return{r:yo(n,255)*255,g:yo(e,255)*255,b:yo(t,255)*255}}function Sle(n,e,t){n=yo(n,255),e=yo(e,255),t=yo(t,255);var r=Math.max(n,e,t),i=Math.min(n,e,t),s,a,o=(r+i)/2;if(r==i)s=a=0;else{var l=r-i;switch(a=o>.5?l/(2-r-i):l/(r+i),r){case n:s=(e-t)/l+(e1&&(d-=1),d<1/6?c+(u-c)*6*d:d<1/2?u:d<2/3?c+(u-c)*(2/3-d)*6:c}if(e===0)r=i=s=t;else{var o=t<.5?t*(1+e):t+e-t*e,l=2*t-o;r=a(l,o,n+1/3),i=a(l,o,n),s=a(l,o,n-1/3)}return{r:r*255,g:i*255,b:s*255}}function Tle(n,e,t){n=yo(n,255),e=yo(e,255),t=yo(t,255);var r=Math.max(n,e,t),i=Math.min(n,e,t),s,a,o=r,l=r-i;if(a=r===0?0:l/r,r==i)s=0;else{switch(r){case n:s=(e-t)/l+(e>1)+720)%360;--e;)r.h=(r.h+i)%360,s.push(kr(r));return s}function tit(n,e){e=e||6;for(var t=kr(n).toHsv(),r=t.h,i=t.s,s=t.v,a=[],o=1/e;e--;)a.push(kr({h:r,s:i,v:s})),s=(s+o)%1;return a}kr.mix=function(n,e,t){t=t===0?0:t||50;var r=kr(n).toRgb(),i=kr(e).toRgb(),s=t/100,a={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(i.a-r.a)*s+r.a};return kr(a)};kr.readability=function(n,e){var t=kr(n),r=kr(e);return(Math.max(t.getLuminance(),r.getLuminance())+.05)/(Math.min(t.getLuminance(),r.getLuminance())+.05)};kr.isReadable=function(n,e,t){var r=kr.readability(n,e),i,s;switch(s=!1,i=oit(t),i.level+i.size){case"AAsmall":case"AAAlarge":s=r>=4.5;break;case"AAlarge":s=r>=3;break;case"AAAsmall":s=r>=7;break}return s};kr.mostReadable=function(n,e,t){var r=null,i=0,s,a,o,l;t=t||{},a=t.includeFallbackColors,o=t.level,l=t.size;for(var c=0;ci&&(i=s,r=kr(e[c]));return kr.isReadable(n,r,{level:o,size:l})||!a?r:(t.includeFallbackColors=!1,kr.mostReadable(n,["#fff","#000"],t))};var jV=kr.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},nit=kr.hexNames=rit(jV);function rit(n){var e={};for(var t in n)n.hasOwnProperty(t)&&(e[n[t]]=t);return e}function Nve(n){return n=parseFloat(n),(isNaN(n)||n<0||n>1)&&(n=1),n}function yo(n,e){iit(n)&&(n="100%");var t=sit(n);return n=Math.min(e,Math.max(0,parseFloat(n))),t&&(n=parseInt(n*e,10)/100),Math.abs(n-e)<1e-6?1:n%e/parseFloat(e)}function pR(n){return Math.min(1,Math.max(0,n))}function Fh(n){return parseInt(n,16)}function iit(n){return typeof n=="string"&&n.indexOf(".")!=-1&&parseFloat(n)===1}function sit(n){return typeof n=="string"&&n.indexOf("%")!=-1}function j0(n){return n.length==1?"0"+n:""+n}function j5(n){return n<=1&&(n=n*100+"%"),n}function Mve(n){return Math.round(parseFloat(n)*255).toString(16)}function Cle(n){return Fh(n)/255}var T0=function(){var n="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+n+")",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",i="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Gm(n){return!!T0.CSS_UNIT.exec(n)}function ait(n){n=n.replace(Frt,"").replace(Brt,"").toLowerCase();var e=!1;if(jV[n])n=jV[n],e=!0;else if(n=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=T0.rgb.exec(n))?{r:t[1],g:t[2],b:t[3]}:(t=T0.rgba.exec(n))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=T0.hsl.exec(n))?{h:t[1],s:t[2],l:t[3]}:(t=T0.hsla.exec(n))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=T0.hsv.exec(n))?{h:t[1],s:t[2],v:t[3]}:(t=T0.hsva.exec(n))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=T0.hex8.exec(n))?{r:Fh(t[1]),g:Fh(t[2]),b:Fh(t[3]),a:Cle(t[4]),format:e?"name":"hex8"}:(t=T0.hex6.exec(n))?{r:Fh(t[1]),g:Fh(t[2]),b:Fh(t[3]),format:e?"name":"hex"}:(t=T0.hex4.exec(n))?{r:Fh(t[1]+""+t[1]),g:Fh(t[2]+""+t[2]),b:Fh(t[3]+""+t[3]),a:Cle(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=T0.hex3.exec(n))?{r:Fh(t[1]+""+t[1]),g:Fh(t[2]+""+t[2]),b:Fh(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function oit(n){var e,t;return n=n||{level:"AA",size:"small"},e=(n.level||"AA").toUpperCase(),t=(n.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function FV(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t=this._minInterval)if(isNaN(this._maxInterval))this.update(this._frameDeltaTime*this._timeScale,!0),this._lastTimeUpdated=this._now;else for(this._interval=Math.min(this._frameDeltaTime,this._maxInterval);this._now>=this._lastTimeUpdated+this._interval;)this.update(this._interval*this._timeScale,this._now<=this._lastTimeUpdated+2*this._maxInterval),this._lastTimeUpdated+=this._interval;this._isRunning&&this.animateOnce()},o.prototype.update=function(l,c){c===void 0&&(c=!0),this._currentTick++,this._currentTime+=l,this._tickDeltaTime=l,this._onTick.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick),c&&this._onTickOncePerFrame.dispatch(this.currentTimeSeconds,this.tickDeltaTimeSeconds,this.currentTick)},o.prototype.getTimer=function(){return Date.now()},o}();Object.defineProperty(r,"__esModule",{value:!0}),r.default=a},function(t,r,i){(function(s,a){t.exports=a()})(this,function(){return function(s){function a(l){if(o[l])return o[l].exports;var c=o[l]={exports:{},id:l,loaded:!1};return s[l].call(c.exports,c,c.exports,a),c.loaded=!0,c.exports}var o={};return a.m=s,a.c=o,a.p="",a(0)}([function(s,a){var o=function(){function l(){this.functions=[]}return l.prototype.add=function(c){return this.functions.indexOf(c)===-1&&(this.functions.push(c),!0)},l.prototype.remove=function(c){var u=this.functions.indexOf(c);return u>-1&&(this.functions.splice(u,1),!0)},l.prototype.removeAll=function(){return this.functions.length>0&&(this.functions.length=0,!0)},l.prototype.dispatch=function(){for(var c=[],u=0;uc==u>-c?(s=c,c=e[++d]):(s=u,u=r[++h]);let p=0;if(dc==u>-c?(a=c+s,o=s-(a-c),c=e[++d]):(a=u+s,o=s-(a-u),u=r[++h]),s=a,o!==0&&(i[p++]=o);dc==u>-c?(a=s+c,l=a-s,o=s-(a-l)+(c-l),c=e[++d]):(a=s+u,l=a-s,o=s-(a-l)+(u-l),u=r[++h]),s=a,o!==0&&(i[p++]=o);for(;d=W||-K>=W||(d=n-V,o=n-(V+d)+(d-i),d=t-$,c=t-($+d)+(d-i),d=e-G,l=e-(G+d)+(d-s),d=r-H,u=r-(H+d)+(d-s),o===0&&l===0&&c===0&&u===0)||(W=Mit*a+Sit*Math.abs(K),K+=V*u+H*o-(G*c+$*l),K>=W||-K>=W))return K;k=o*H,h=Hu*o,p=h-(h-o),g=o-p,h=Hu*H,x=h-(h-H),_=H-x,B=g*_-(k-p*x-g*x-p*_),U=l*$,h=Hu*l,p=h-(h-l),g=l-p,h=Hu*$,x=h-(h-$),_=$-x,z=g*_-(U-p*x-g*x-p*_),y=B-z,d=B-y,bd[0]=B-(y+d)+(d-z),M=k+y,d=M-k,C=k-(M-d)+(y-d),y=C-U,d=C-y,bd[1]=C-(y+d)+(d-U),O=M+y,d=O-M,bd[2]=M-(O-d)+(y-d),bd[3]=O;const J=NF(4,rb,4,bd,Ple);k=V*u,h=Hu*V,p=h-(h-V),g=V-p,h=Hu*u,x=h-(h-u),_=u-x,B=g*_-(k-p*x-g*x-p*_),U=G*c,h=Hu*G,p=h-(h-G),g=G-p,h=Hu*c,x=h-(h-c),_=c-x,z=g*_-(U-p*x-g*x-p*_),y=B-z,d=B-y,bd[0]=B-(y+d)+(d-z),M=k+y,d=M-k,C=k-(M-d)+(y-d),y=C-U,d=C-y,bd[1]=C-(y+d)+(d-U),O=M+y,d=O-M,bd[2]=M-(O-d)+(y-d),bd[3]=O;const ie=NF(J,Ple,4,bd,Rle);k=o*u,h=Hu*o,p=h-(h-o),g=o-p,h=Hu*u,x=h-(h-u),_=u-x,B=g*_-(k-p*x-g*x-p*_),U=l*c,h=Hu*l,p=h-(h-l),g=l-p,h=Hu*c,x=h-(h-c),_=c-x,z=g*_-(U-p*x-g*x-p*_),y=B-z,d=B-y,bd[0]=B-(y+d)+(d-z),M=k+y,d=M-k,C=k-(M-d)+(y-d),y=C-U,d=C-y,bd[1]=C-(y+d)+(d-U),O=M+y,d=O-M,bd[2]=M-(O-d)+(y-d),bd[3]=O;const ae=NF(ie,Rle,4,bd,Lle);return Lle[ae-1]}function F5(n,e,t,r,i,s){const a=(e-s)*(t-i),o=(n-i)*(r-s),l=a-o,c=Math.abs(a+o);return Math.abs(l)>=Eit*c?l:-Cit(n,e,t,r,i,s,c)}const kle=Math.pow(2,-52),P8=new Uint32Array(512);class bS{static from(e,t=Iit,r=Dit){const i=e.length,s=new Float64Array(i*2);for(let a=0;a>1;if(t>0&&typeof e[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=e;const r=Math.max(2*t-5,0);this._triangles=new Uint32Array(r*3),this._halfedges=new Int32Array(r*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:e,_hullPrev:t,_hullNext:r,_hullTri:i,_hullHash:s}=this,a=e.length>>1;let o=1/0,l=1/0,c=-1/0,u=-1/0;for(let V=0;Vc&&(c=$),G>u&&(u=G),this._ids[V]=V}const d=(o+c)/2,h=(l+u)/2;let p=0,g=0,x=0;for(let V=0,$=1/0;V0&&(g=V,$=G)}let M=e[2*g],C=e[2*g+1],k=1/0;for(let V=0;VH&&(V[$++]=K,H=W)}this.hull=V.subarray(0,$),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(F5(_,y,M,C,B,U)<0){const V=g,$=M,G=C;g=x,M=B,C=U,x=V,B=$,U=G}const z=kit(_,y,M,C,B,U);this._cx=z.x,this._cy=z.y;for(let V=0;V0&&Math.abs(K-$)<=kle&&Math.abs(W-G)<=kle||($=K,G=W,H===p||H===g||H===x))continue;let J=0;for(let oe=0,fe=this._hashKey(K,W);oe=0;)if(ie=ae,ie===J){ie=-1;break}if(ie===-1)continue;let Q=this._addTriangle(ie,H,r[ie],-1,-1,i[ie]);i[H]=this._legalize(Q+2),i[ie]=Q,O++;let re=r[ie];for(;ae=r[re],F5(K,W,e[2*re],e[2*re+1],e[2*ae],e[2*ae+1])<0;)Q=this._addTriangle(re,H,ae,i[H],-1,i[re]),i[H]=this._legalize(Q+2),r[re]=re,O--,re=ae;if(ie===J)for(;ae=t[ie],F5(K,W,e[2*ae],e[2*ae+1],e[2*ie],e[2*ie+1])<0;)Q=this._addTriangle(ae,H,ie,-1,i[ie],i[ae]),this._legalize(Q+2),i[ae]=Q,r[ie]=ie,O--,ie=ae;this._hullStart=t[H]=ie,r[ie]=t[re]=H,r[H]=re,s[this._hashKey(K,W)]=H,s[this._hashKey(e[2*ie],e[2*ie+1])]=ie}this.hull=new Uint32Array(O);for(let V=0,$=this._hullStart;V0?3-t:1+t)/4}function MF(n,e,t,r){const i=n-t,s=e-r;return i*i+s*s}function Rit(n,e,t,r,i,s,a,o){const l=n-a,c=e-o,u=t-a,d=r-o,h=i-a,p=s-o,g=l*l+c*c,x=u*u+d*d,_=h*h+p*p;return l*(d*_-x*p)-c*(u*_-x*h)+g*(u*p-d*h)<0}function Lit(n,e,t,r,i,s){const a=t-n,o=r-e,l=i-n,c=s-e,u=a*a+o*o,d=l*l+c*c,h=.5/(a*c-o*l),p=(c*u-o*d)*h,g=(a*d-l*u)*h;return p*p+g*g}function kit(n,e,t,r,i,s){const a=t-n,o=r-e,l=i-n,c=s-e,u=a*a+o*o,d=l*l+c*c,h=.5/(a*c-o*l),p=n+(c*u-o*d)*h,g=e+(a*d-l*u)*h;return{x:p,y:g}}function n_(n,e,t,r){if(r-t<=20)for(let i=t+1;i<=r;i++){const s=n[i],a=e[s];let o=i-1;for(;o>=t&&e[n[o]]>a;)n[o+1]=n[o--];n[o+1]=s}else{const i=t+r>>1;let s=t+1,a=r;Vw(n,i,s),e[n[t]]>e[n[r]]&&Vw(n,t,r),e[n[s]]>e[n[r]]&&Vw(n,s,r),e[n[t]]>e[n[s]]&&Vw(n,t,s);const o=n[s],l=e[o];for(;;){do s++;while(e[n[s]]l);if(a=a-t?(n_(n,e,s,r),n_(n,e,t,a-1)):(n_(n,e,t,a-1),n_(n,e,s,r))}}function Vw(n,e,t){const r=n[e];n[e]=n[t],n[t]=r}function Iit(n){return n[0]}function Dit(n){return n[1]}function Oit(n,e){var t,r,i=0,s,a,o,l,c,u,d,h=n[0],p=n[1],g=e.length;for(t=0;t=0||a<=0&&l>=0)return 0}else if(c>=0&&o<=0||c<=0&&o>=0){if(s=F5(a,l,o,c,0,0),s===0)return 0;(s>0&&c>0&&o<=0||s<0&&c<=0&&o>0)&&i++}u=d,o=c,a=l}}return i%2!==0}function jit(n){if(!n)throw new Error("coord is required");if(!Array.isArray(n)){if(n.type==="Feature"&&n.geometry!==null&&n.geometry.type==="Point")return[...n.geometry.coordinates];if(n.type==="Point")return[...n.coordinates]}if(Array.isArray(n)&&n.length>=2&&!Array.isArray(n[0])&&!Array.isArray(n[1]))return[...n];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Fit(n){return n.type==="Feature"?n.geometry:n}function Bit(n,e,t={}){if(!n)throw new Error("point is required");if(!e)throw new Error("polygon is required");const r=jit(n),i=Fit(e),s=i.type,a=e.bbox;let o=i.coordinates;if(a&&Uit(r,a)===!1)return!1;s==="Polygon"&&(o=[o]);let l=!1;for(var c=0;c=n[0]&&e[3]>=n[1]}var zit=Bit;const Ile=1e-6;class Ex{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(e,t){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(e,t){this._+=`L${this._x1=+e},${this._y1=+t}`}arc(e,t,r){e=+e,t=+t,r=+r;const i=e+r,s=t;if(r<0)throw new Error("negative radius");this._x1===null?this._+=`M${i},${s}`:(Math.abs(this._x1-i)>Ile||Math.abs(this._y1-s)>Ile)&&(this._+="L"+i+","+s),r&&(this._+=`A${r},${r},0,1,1,${e-r},${t}A${r},${r},0,1,1,${this._x1=i},${this._y1=s}`)}rect(e,t,r,i){this._+=`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${+r}v${+i}h${-r}Z`}value(){return this._||null}}class BV{constructor(){this._=[]}moveTo(e,t){this._.push([e,t])}closePath(){this._.push(this._[0].slice())}lineTo(e,t){this._.push([e,t])}value(){return this._.length?this._:null}}class Vit{constructor(e,[t,r,i,s]=[0,0,960,500]){if(!((i=+i)>=(t=+t))||!((s=+s)>=(r=+r)))throw new Error("invalid bounds");this.delaunay=e,this._circumcenters=new Float64Array(e.points.length*2),this.vectors=new Float64Array(e.points.length*2),this.xmax=i,this.xmin=t,this.ymax=s,this.ymin=r,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:e,hull:t,triangles:r},vectors:i}=this;let s,a;const o=this.circumcenters=this._circumcenters.subarray(0,r.length/3*2);for(let x=0,_=0,y=r.length,M,C;x1;)s-=2;for(let a=2;a0){if(t>=this.ymax)return null;(a=(this.ymax-t)/i)0){if(e>=this.xmax)return null;(a=(this.xmax-e)/r)this.xmax?2:0)|(tthis.ymax?8:0)}_simplify(e){if(e&&e.length>4){for(let t=0;t1e-10)return!1}return!0}function Wit(n,e,t){return[n+Math.sin(n+e)*t,e+Math.cos(n-e)*t]}class wW{static from(e,t=Git,r=Hit,i){return new wW("length"in e?Xit(e,t,r,i):Float64Array.from(Yit(e,t,r,i)))}constructor(e){this._delaunator=new bS(e),this.inedges=new Int32Array(e.length/2),this._hullIndex=new Int32Array(e.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const e=this._delaunator,t=this.points;if(e.hull&&e.hull.length>2&&$it(e)){this.collinear=Int32Array.from({length:t.length/2},(h,p)=>p).sort((h,p)=>t[2*h]-t[2*p]||t[2*h+1]-t[2*p+1]);const l=this.collinear[0],c=this.collinear[this.collinear.length-1],u=[t[2*l],t[2*l+1],t[2*c],t[2*c+1]],d=1e-8*Math.hypot(u[3]-u[1],u[2]-u[0]);for(let h=0,p=t.length/2;h0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=i[0],a[i[0]]=1,i.length===2&&(a[i[1]]=0,this.triangles[1]=i[1],this.triangles[2]=i[1]))}voronoi(e){return new Vit(this,e)}*neighbors(e){const{inedges:t,hull:r,_hullIndex:i,halfedges:s,triangles:a,collinear:o}=this;if(o){const d=o.indexOf(e);d>0&&(yield o[d-1]),d=0&&s!==r&&s!==i;)r=s;return s}_step(e,t,r){const{inedges:i,hull:s,_hullIndex:a,halfedges:o,triangles:l,points:c}=this;if(i[e]===-1||!c.length)return(e+1)%(c.length>>1);let u=e,d=ib(t-c[e*2],2)+ib(r-c[e*2+1],2);const h=i[e];let p=h;do{let g=l[p];const x=ib(t-c[g*2],2)+ib(r-c[g*2+1],2);if(x0?1:n<0?-1:0},Lve=Math.sqrt;function est(n){return n>1?Dle:n<-1?-Dle:Math.asin(n)}function kve(n,e){return n[0]*e[0]+n[1]*e[1]+n[2]*e[2]}function qh(n,e){return[n[1]*e[2]-n[2]*e[1],n[2]*e[0]-n[0]*e[2],n[0]*e[1]-n[1]*e[0]]}function EC(n,e){return[n[0]+e[0],n[1]+e[1],n[2]+e[2]]}function NC(n){var e=Lve(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);return[n[0]/e,n[1]/e,n[2]/e]}function TW(n){return[Zit(n[1],n[0])*Ole,est(Qit(-1,Kit(1,n[2])))*Ole]}function sm(n){const e=n[0]*jle,t=n[1]*jle,r=Fle(t);return[r*Fle(e),r*Ble(e),Ble(t)]}function EW(n){return n=n.map(e=>sm(e)),kve(n[0],qh(n[2],n[1]))}function tst(n){const e=rst(n),t=sst(e),r=ist(t,n),i=ost(t,n.length),s=nst(i,n),a=ast(t,n),{polygons:o,centers:l}=lst(a,t,n),c=cst(o),u=dst(t,n),d=ust(r,t);return{delaunay:e,edges:r,triangles:t,centers:l,neighbors:i,polygons:o,mesh:c,hull:u,urquhart:d,find:s}}function nst(n,e){function t(r,i){let s=r[0]-i[0],a=r[1]-i[1],o=r[2]-i[2];return s*s+a*a+o*o}return function(i,s,a){a===void 0&&(a=0);let o,l,c=a;const u=sm([i,s]);do o=a,a=null,l=t(u,sm(e[o])),n[o].forEach(d=>{let h=t(u,sm(e[d]));if(h1e32?i.push(d):p>s&&(s=p)}const a=1e6*Lve(s);i.forEach(d=>n[d]=[a,0]),n.push([0,a]),n.push([-a,0]),n.push([0,-a]);const o=wW.from(n);o.projection=r;const{triangles:l,halfedges:c,inedges:u}=o;for(let d=0,h=c.length;dn.length-3-1&&(l[d]=e);return o}function ist(n,e){const t=new Set;return e.length===2?[[0,1]]:(n.forEach(r=>{if(r[0]!==r[1]&&!(EW(r.map(i=>e[i]))<0))for(let i=0,s;i<3;i++)s=(i+1)%3,t.add(QM([r[i],r[s]]).join("-"))}),Array.from(t,r=>r.split("-").map(Number)))}function sst(n){const{triangles:e}=n;if(!e)return[];const t=[];for(let r=0,i=e.length/3;r{const r=t.map(s=>e[s]).map(sm),i=EC(EC(qh(r[1],r[0]),qh(r[2],r[1])),qh(r[0],r[2]));return TW(NC(i))})}function ost(n,e){const t=[];return n.forEach(r=>{for(let i=0;i<3;i++){const s=r[i],a=r[(i+1)%3];t[s]=t[s]||[],t[s].push(a)}}),n.length===0&&(e===2?(t[0]=[1],t[1]=[0]):e===1&&(t[0]=[])),t}function lst(n,e,t){const r=[],i=n.slice();if(e.length===0){if(t.length<2)return{polygons:r,centers:i};if(t.length===2){const o=sm(t[0]),l=sm(t[1]),c=NC(EC(o,l)),u=NC(qh(o,l)),d=qh(c,u),h=[c,qh(c,d),qh(qh(c,d),d),qh(qh(qh(c,d),d),d)].map(TW).map(a);return r.push(h),r.push(h.slice().reverse()),{polygons:r,centers:i}}}e.forEach((o,l)=>{for(let c=0;c<3;c++){const u=o[c],d=o[(c+1)%3],h=o[(c+2)%3];r[u]=r[u]||[],r[u].push([d,h,l,[u,d,h]])}});const s=r.map(o=>{const l=[o[0][2]];let c=o[0][1];for(let u=1;u2)return l;if(l.length==2){const u=Ule(t[o[0][3][0]],t[o[0][3][1]],i[l[0]]),d=Ule(t[o[0][3][2]],t[o[0][3][0]],i[l[0]]),h=a(u),p=a(d);return[l[0],p,l[1],h]}});function a(o){let l=-1;return i.slice(e.length,1/0).forEach((c,u)=>{c[0]===o[0]&&c[1]===o[1]&&(l=u+e.length)}),l<0&&(l=i.length,i.push(o)),l}return{polygons:s,centers:i}}function Ule(n,e,t){n=sm(n),e=sm(e),t=sm(t);const r=Jit(kve(qh(e,n),t));return TW(NC(EC(n,e)).map(i=>r*i))}function cst(n){const e=[];return n.forEach(t=>{if(!t)return;let r=t[t.length-1];for(let i of t)i>r&&e.push([r,i]),r=i}),e}function ust(n,e){return function(t){const r=new Map,i=new Map;return n.forEach((s,a)=>{const o=s.join("-");r.set(o,t[a]),i.set(o,!0)}),e.forEach(s=>{let a=0,o=-1;for(let l=0;l<3;l++){let c=QM([s[l],s[(l+1)%3]]).join("-");r.get(c)>a&&(a=r.get(c),o=c)}i.set(o,!1)}),n.map(s=>i.get(s.join("-")))}}function dst(n,e){const t=new Set,r=[];n.map(o=>{if(!(EW(o.map(l=>e[l>e.length?0:l]))>1e-12))for(let l=0;l<3;l++){let c=[o[l],o[(l+1)%3]],u=`${c[0]}-${c[1]}`;t.has(u)?t.delete(u):t.add(`${c[1]}-${c[0]}`)}});const i=new Map;let s;if(t.forEach(o=>{o=o.split("-").map(Number),i.set(o[0],o[1]),s=o[0]}),s===void 0)return r;let a=s;do{r.push(a);let o=i.get(a);i.set(a,-1),a=o}while(a>-1&&a!==s);return r}function hst(n){const e=function(t){if(e.delaunay=null,e._data=t,typeof e._data=="object"&&e._data.type==="FeatureCollection"&&(e._data=e._data.features),typeof e._data=="object"){const r=e._data.map(i=>[e._vx(i),e._vy(i),i]).filter(i=>isFinite(i[0]+i[1]));e.points=r.map(i=>[i[0],i[1]]),e.valid=r.map(i=>i[2]),e.delaunay=tst(e.points)}return e};return e._vx=function(t){if(typeof t=="object"&&"type"in t)return Qoe(t)[0];if(0 in t)return t[0]},e._vy=function(t){if(typeof t=="object"&&"type"in t)return Qoe(t)[1];if(1 in t)return t[1]},e.x=function(t){return t?(e._vx=t,e):e._vx},e.y=function(t){return t?(e._vy=t,e):e._vy},e.polygons=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const r={type:"FeatureCollection",features:[]};return e.valid.length===0||(e.delaunay.polygons.forEach((i,s)=>r.features.push({type:"Feature",geometry:i?{type:"Polygon",coordinates:[[...i,i[0]].map(a=>e.delaunay.centers[a])]}:null,properties:{site:e.valid[s],sitecoordinates:e.points[s],neighbours:e.delaunay.neighbors[s]}})),e.valid.length===1&&r.features.push({type:"Feature",geometry:{type:"Sphere"},properties:{site:e.valid[0],sitecoordinates:e.points[0],neighbours:[]}})),r},e.triangles=function(t){return t!==void 0&&e(t),e.delaunay?{type:"FeatureCollection",features:e.delaunay.triangles.map((r,i)=>(r=r.map(s=>e.points[s]),r.center=e.delaunay.centers[i],r)).filter(r=>EW(r)>0).map(r=>({type:"Feature",properties:{circumcenter:r.center},geometry:{type:"Polygon",coordinates:[[...r,r[0]]]}}))}:!1},e.links=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const r=e.delaunay.edges.map(s=>qA(e.points[s[0]],e.points[s[1]])),i=e.delaunay.urquhart(r);return{type:"FeatureCollection",features:e.delaunay.edges.map((s,a)=>({type:"Feature",properties:{source:e.valid[s[0]],target:e.valid[s[1]],length:r[a],urquhart:!!i[a]},geometry:{type:"LineString",coordinates:[e.points[s[0]],e.points[s[1]]]}}))}},e.mesh=function(t){return t!==void 0&&e(t),e.delaunay?{type:"MultiLineString",coordinates:e.delaunay.edges.map(r=>[e.points[r[0]],e.points[r[1]]])}:!1},e.cellMesh=function(t){if(t!==void 0&&e(t),!e.delaunay)return!1;const{centers:r,polygons:i}=e.delaunay,s=[];for(const a of i)if(a)for(let o=a.length,l=a[o-1],c=a[0],u=0;ul&&s.push([r[l],r[c]]);return{type:"MultiLineString",coordinates:s}},e._found=void 0,e.find=function(t,r,i){if(e._found=e.delaunay.find(t,r,e._found),!i||qA([t,r],e.points[e._found])i[s]),i[r[0]]]]}},n?e(n):e}function UV(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t1&&arguments[1]!==void 0?arguments[1]:{},t=e.resolution,r=t===void 0?1/0:t,i=Est(n,r),s=mS(i),a=Nst(n,r),o=[].concat(CF(s),CF(a)),l={type:"Polygon",coordinates:n},c=eve(l),u=zp(c,2),d=zp(u[0],2),h=d[0],p=d[1],g=zp(u[1],2),x=g[0],_=g[1],y=h>x||_>=89||p<=-89,M=[];if(y){var C=hst(o).triangles(),k=new Map(o.map(function(ae,Q){var re=zp(ae,2),oe=re[0],fe=re[1];return["".concat(oe,"-").concat(fe),Q]}));C.features.forEach(function(ae){var Q,re=ae.geometry.coordinates[0].slice(0,3).reverse(),oe=[];if(re.forEach(function(ee){var me=zp(ee,2),Ae=me[0],be=me[1],pe="".concat(Ae,"-").concat(be);k.has(pe)&&oe.push(k.get(pe))}),oe.length===3){if(oe.some(function(ee){return eee)for(var o=AW(i,s),l=1/Math.ceil(a/e),c=l;c<1;)r.push(o(c)),c+=l}r.push(i=s)}),r})}function Nst(n,e){var t={type:"Polygon",coordinates:n},r=eve(t),i=zp(r,2),s=zp(i[0],2),a=s[0],o=s[1],l=zp(i[1],2),c=l[0],u=l[1];if(Math.min(Math.abs(c-a),Math.abs(u-o))c||u>=89||o<=-89;return Mst(e,{minLng:a,maxLng:c,minLat:o,maxLat:u}).filter(function(h){return VV(h,t,d)})}function Mst(n){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.minLng,r=e.maxLng,i=e.minLat,s=e.maxLat,a=Math.round(Math.pow(360/n,2)/Math.PI),o=(1+Math.sqrt(5))/2,l=function(y){return y/o*360%360-180},c=function(y){return Math.acos(2*y/a-1)/Math.PI*180-90},u=function(y){return a*(Math.cos((y+90)*Math.PI/180)+1)/2},d=[s!==void 0?Math.ceil(u(s)):0,i!==void 0?Math.floor(u(i)):a-1],h=t===void 0&&r===void 0?function(){return!0}:t===void 0?function(_){return _<=r}:r===void 0?function(_){return _>=t}:r>=t?function(_){return _>=t&&_<=r}:function(_){return _>=t||_<=r},p=[],g=d[0];g<=d[1];g++){var x=l(g);h(x)&&p.push([x,c(g)])}return p}function VV(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return t?ont(e,n):zit(n,e)}var _N=window.THREE?window.THREE:{BufferGeometry:Pr,Float32BufferAttribute:tr},zle=new _N.BufferGeometry().setAttribute?"setAttribute":"addAttribute",NW=function(n){function e(t,r,i,s,a,o,l){var c;Ast(this,e),c=gst(this,e),c.type="ConicPolygonGeometry",c.parameters={polygonGeoJson:t,bottomHeight:r,topHeight:i,closedBottom:s,closedTop:a,includeSides:o,curvatureResolution:l},r=r||0,i=i||1,s=s!==void 0?s:!0,a=a!==void 0?a:!0,o=o!==void 0?o:!0,l=l||5;var u=Tst(t,{resolution:l}),d=u.contour,h=u.triangles,p=mS(h.uvs),g=[],x=[],_=[],y=0,M=function(z){var O=Math.round(g.length/3),V=_.length;g=g.concat(z.vertices),x=x.concat(z.uvs),_=_.concat(O?z.indices.map(function($){return $+O}):z.indices),c.addGroup(V,_.length-V,y++)};o&&M(k()),s&&M(B(r,!1)),a&&M(B(i,!0)),c.setIndex(_),c[zle]("position",new _N.Float32BufferAttribute(g,3)),c[zle]("uv",new _N.Float32BufferAttribute(x,2)),c.computeVertexNormals();function C(U,z){var O=typeof z=="function"?z:function(){return z},V=U.map(function($){return $.map(function(G){var H=zp(G,2),K=H[0],W=H[1];return Cst(W,K,O(K,W))})});return _C(V)}function k(){for(var U=C(d,r),z=U.vertices,O=U.holes,V=C(d,i),$=V.vertices,G=mS([$,z]),H=Math.round($.length/3),K=new Set(O),W=0,J=[],ie=0;ie=0;oe--)for(var fe=0;fe1&&arguments[1]!==void 0?arguments[1]:!0;return{indices:z?h.indices:h.indices.slice().reverse(),vertices:C([h.points],U).vertices,uvs:p}}return c}return vst(e,n),xst(e)}(_N.BufferGeometry);function Cst(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=(90-n)*Math.PI/180,i=(90-e)*Math.PI/180;return[t*Math.sin(r)*Math.cos(i),t*Math.cos(r),t*Math.sin(r)*Math.sin(i)]}function qV(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=(e instanceof Array?e.length?e:[void 0]:[e]).map(function(o){return{keyAccessor:o,isProp:!(o instanceof Function)}}),s=n.reduce(function(o,l){var c=o,u=l;return i.forEach(function(d,h){var p=d.keyAccessor,g=d.isProp,x;if(g){var _=u,y=_[p],M=Ost(_,[p].map(zst));x=y,u=M}else x=p(u,h);h+11&&arguments[1]!==void 0?arguments[1]:1;c===i.length?Object.keys(l).forEach(function(u){return l[u]=t(l[u])}):Object.values(l).forEach(function(u){return o(u,c+1)})}(s);var a=s;return r&&(a=[],function o(l){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];c.length===i.length?a.push({keys:c,vals:l}):Object.entries(l).forEach(function(u){var d=Fst(u,2),h=d[0],p=d[1];return o(p,[].concat(Bst(c),[h]))})}(s),e instanceof Array&&e.length===0&&a.length===1&&(a[0].keys=[])),a},hs=function(n){n=n||{};var e=typeof n<"u"?n:{},t={},r;for(r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);var i="";function s(it){return e.locateFile?e.locateFile(it,i):i+it}var a;typeof document<"u"&&document.currentScript&&(i=document.currentScript.src),i.indexOf("blob:")!==0?i=i.substr(0,i.lastIndexOf("/")+1):i="",a=function(Ot,nn,Nt){var m=new XMLHttpRequest;m.open("GET",Ot,!0),m.responseType="arraybuffer",m.onload=function(){if(m.status==200||m.status==0&&m.response){nn(m.response);return}var An=tt(Ot);if(An){nn(An.buffer);return}Nt()},m.onerror=Nt,m.send(null)};var o=e.print||console.log.bind(console),l=e.printErr||console.warn.bind(console);for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);t=null,e.arguments&&e.arguments;var c=0,u=function(it){c=it},d=function(){return c},h=8;function p(it,Ot,nn,Nt){switch(nn=nn||"i8",nn.charAt(nn.length-1)==="*"&&(nn="i32"),nn){case"i1":H[it>>0]=Ot;break;case"i8":H[it>>0]=Ot;break;case"i16":W[it>>1]=Ot;break;case"i32":J[it>>2]=Ot;break;case"i64":It=[Ot>>>0,(_t=Ot,+bt(_t)>=1?_t>0?(lt(+Ce(_t/4294967296),4294967295)|0)>>>0:~~+ht((_t-+(~~_t>>>0))/4294967296)>>>0:0)],J[it>>2]=It[0],J[it+4>>2]=It[1];break;case"float":ie[it>>2]=Ot;break;case"double":ae[it>>3]=Ot;break;default:Gt("invalid type for setValue: "+nn)}}function g(it,Ot,nn){switch(Ot=Ot||"i8",Ot.charAt(Ot.length-1)==="*"&&(Ot="i32"),Ot){case"i1":return H[it>>0];case"i8":return H[it>>0];case"i16":return W[it>>1];case"i32":return J[it>>2];case"i64":return J[it>>2];case"float":return ie[it>>2];case"double":return ae[it>>3];default:Gt("invalid type for getValue: "+Ot)}return null}var x=!1;function _(it,Ot){it||Gt("Assertion failed: "+Ot)}function y(it){var Ot=e["_"+it];return _(Ot,"Cannot call unknown function "+it+", make sure it is exported"),Ot}function M(it,Ot,nn,Nt,m){var Ie={string:function(jr){var Qr=0;if(jr!=null&&jr!==0){var Os=(jr.length<<2)+1;Qr=Qt(Os),O(jr,Qr,Os)}return Qr},array:function(jr){var Qr=Qt(jr.length);return V(jr,Qr),Qr}};function An(jr){return Ot==="string"?U(jr):Ot==="boolean"?!!jr:jr}var Ln=y(it),Rn=[],Mn=0;if(Nt)for(var Cn=0;Cn=Nt);)++m;if(m-Ot>16&&it.subarray&&k)return k.decode(it.subarray(Ot,m));for(var Ie="";Ot>10,56320|Mn&1023)}}return Ie}function U(it,Ot){return it?B(K,it,Ot):""}function z(it,Ot,nn,Nt){if(!(Nt>0))return 0;for(var m=nn,Ie=nn+Nt-1,An=0;An=55296&&Ln<=57343){var Rn=it.charCodeAt(++An);Ln=65536+((Ln&1023)<<10)|Rn&1023}if(Ln<=127){if(nn>=Ie)break;Ot[nn++]=Ln}else if(Ln<=2047){if(nn+1>=Ie)break;Ot[nn++]=192|Ln>>6,Ot[nn++]=128|Ln&63}else if(Ln<=65535){if(nn+2>=Ie)break;Ot[nn++]=224|Ln>>12,Ot[nn++]=128|Ln>>6&63,Ot[nn++]=128|Ln&63}else{if(nn+3>=Ie)break;Ot[nn++]=240|Ln>>18,Ot[nn++]=128|Ln>>12&63,Ot[nn++]=128|Ln>>6&63,Ot[nn++]=128|Ln&63}}return Ot[nn]=0,nn-m}function O(it,Ot,nn){return z(it,K,Ot,nn)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function V(it,Ot){H.set(it,Ot)}function $(it,Ot){return it%Ot>0&&(it+=Ot-it%Ot),it}var G,H,K,W,J,ie,ae;function Q(it){G=it,e.HEAP8=H=new Int8Array(it),e.HEAP16=W=new Int16Array(it),e.HEAP32=J=new Int32Array(it),e.HEAPU8=K=new Uint8Array(it),e.HEAPU16=new Uint16Array(it),e.HEAPU32=new Uint32Array(it),e.HEAPF32=ie=new Float32Array(it),e.HEAPF64=ae=new Float64Array(it)}var re=5271296,oe=28384,fe=e.TOTAL_MEMORY||33554432;e.buffer?G=e.buffer:G=new ArrayBuffer(fe),fe=G.byteLength,Q(G),J[oe>>2]=re;function ee(it){for(;it.length>0;){var Ot=it.shift();if(typeof Ot=="function"){Ot();continue}var nn=Ot.func;typeof nn=="number"?Ot.arg===void 0?e.dynCall_v(nn):e.dynCall_vi(nn,Ot.arg):nn(Ot.arg===void 0?null:Ot.arg)}}var me=[],Ae=[],be=[],pe=[];function ge(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Qe(e.preRun.shift());ee(me)}function Te(){ee(Ae)}function ze(){ee(be)}function Xe(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)ot(e.postRun.shift());ee(pe)}function Qe(it){me.unshift(it)}function ot(it){pe.unshift(it)}var bt=Math.abs,ht=Math.ceil,Ce=Math.floor,lt=Math.min,ft=0,et=null;function At(it){ft++,e.monitorRunDependencies&&e.monitorRunDependencies(ft)}function Lt(it){if(ft--,e.monitorRunDependencies&&e.monitorRunDependencies(ft),ft==0&&et){var Ot=et;et=null,Ot()}}e.preloadedImages={},e.preloadedAudios={};var st=null,Ht="data:application/octet-stream;base64,";function Se(it){return String.prototype.startsWith?it.startsWith(Ht):it.indexOf(Ht)===0}var _t,It;st="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAABgtRFT7IQlAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCUAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgtRFT7Ifm/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+b8AAAAAAAAAABgtRFT7IQnAGC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPshCcAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8AAAAAAAAAAAAAAAAAAAAAGC1EVPsh+T8AAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAMpi5RexJsw/BlIKPVwR5T95Wyu0/QjnP5PjoT7YYcu/mBhKZ6zrwj8wRYS7NebuP3qW6geh+Ls/SLrixebL3r+pcyymN9XrPwmkNHp7xec/GWNMZVAA17+82s+x2BLiPwn2ytbJ9ek/LgEH1sMS1j8yp/2LhTfeP+SnWwtQBbu/d38gkp5X7z8ytsuHaADGPzUYObdf1+m/7IauECWhwz+cjSACjzniP76Z+wUhN9K/1+GEKzup67+/GYr/04baPw6idWOvsuc/ZedTWsRa5b/EJQOuRzi0v/OncYhHPes/h49PixY53j+i8wWfC03Nvw2idWOvsue/ZedTWsRa5T/EJQOuRzi0P/KncYhHPeu/iY9PixY53r+i8wWfC03NP9anWwtQBbs/d38gkp5X778ytsuHaADGvzUYObdf1+k/74auECWhw7+cjSACjzniv8CZ+wUhN9I/1uGEKzup6z+/GYr/04bavwmkNHp7xee/F2NMZVAA1z+82s+x2BLivwr2ytbJ9em/KwEH1sMS1r8yp/2LhTfev81i5RexJsy/BlIKPVwR5b95Wyu0/Qjnv5DjoT7YYcs/nBhKZ6zrwr8wRYS7Nebuv3OW6geh+Lu/SLrixebL3j+pcyymN9Xrv8rHIFfWehZAMBwUdlo0DECTUc17EOb2PxpVB1SWChdAzjbhb9pTDUDQhmdvECX5P9FlMKCC9+g/IIAzjELgE0DajDngMv8GQFhWDmDPjNs/y1guLh96EkAxPi8k7DIEQJCc4URlhRhA3eLKKLwkEECqpNAyTBD/P6xpjXcDiwVAFtl//cQm4z+Ibt3XKiYTQM7mCLUb3QdAoM1t8yVv7D8aLZv2Nk8UQEAJPV5nQwxAtSsfTCoE9z9TPjXLXIIWQBVanC5W9AtAYM3d7Adm9j++5mQz1FoWQBUThyaVBghAwH5muQsV7T89Q1qv82MUQJoWGOfNuBdAzrkClkmwDkDQjKq77t37Py+g0dtitsE/ZwAMTwVPEUBojepluNwBQGYbtuW+t9w/HNWIJs6MEkDTNuQUSlgEQKxktPP5TcQ/ixbLB8JjEUCwuWjXMQYCQAS/R09FkRdAowpiZjhhDkB7LmlczD/7P01iQmhhsAVAnrtTwDy84z/Z6jfQ2TgTQChOCXMnWwpAhrW3daoz8z/HYJvVPI4VQLT3ik5FcA5Angi7LOZd+z+NNVzDy5gXQBXdvVTFUA1AYNMgOeYe+T8+qHXGCwkXQKQTOKwa5AJA8gFVoEMW0T+FwzJyttIRQAEAAAD/////BwAAAP////8xAAAA/////1cBAAD/////YQkAAP////+nQQAA/////5HLAQD/////95AMAP/////B9lcAAAAAAAAAAAAAAAAAAgAAAP////8OAAAA/////2IAAAD/////rgIAAP/////CEgAA/////06DAAD/////IpcDAP/////uIRkA/////4LtrwAAAAAAAAAAAAAAAAAAAAAAAgAAAP//////////AQAAAAMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////////////////////wEAAAAAAAAAAgAAAP///////////////wMAAAD//////////////////////////////////////////////////////////wIAAAD//////////wEAAAAAAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA/////////////////////wEAAAD///////////////8CAAAA////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAA////////////////AgAAAAEAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AQAAAAIAAAD///////////////8AAAAA/////////////////////wMAAAD///////////////////////////////8CAAAA////////////////AQAAAP////////////////////8AAAAA/////////////////////wMAAAD/////////////////////////////////////////////////////AwAAAP////////////////////8AAAAAAQAAAP//////////AgAAAP//////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAP///////////////wIAAAAAAAAAAQAAAP//////////////////////////////////////////////////////////////////////////AwAAAAEAAAD//////////wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAgAAAAAAAAACAAAAAQAAAAEAAAACAAAAAgAAAAAAAAAFAAAABQAAAAAAAAACAAAAAgAAAAMAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAAAgAAAAIAAAACAAAAAAAAAAUAAAAGAAAAAAAAAAIAAAACAAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAIAAAAAAAAAAgAAAAEAAAADAAAAAgAAAAIAAAAAAAAABQAAAAcAAAAAAAAAAgAAAAIAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAAAAAACAAAAAQAAAAQAAAACAAAAAgAAAAAAAAAFAAAACAAAAAAAAAACAAAAAgAAAAMAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAAAAAAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAUAAAAJAAAAAAAAAAIAAAACAAAAAwAAAAUAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAIAAAACAAAAAAAAAAMAAAAOAAAAAgAAAAAAAAACAAAAAwAAAAAAAAAAAAAAAgAAAAIAAAADAAAABgAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAgAAAAIAAAAAAAAAAwAAAAoAAAACAAAAAAAAAAIAAAADAAAAAQAAAAAAAAACAAAAAgAAAAMAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAgAAAAAAAAADAAAACwAAAAIAAAAAAAAAAgAAAAMAAAACAAAAAAAAAAIAAAACAAAAAwAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAACAAAAAAAAAAMAAAAMAAAAAgAAAAAAAAACAAAAAwAAAAMAAAAAAAAAAgAAAAIAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAgAAAAIAAAAAAAAAAwAAAA0AAAACAAAAAAAAAAIAAAADAAAABAAAAAAAAAACAAAAAgAAAAMAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAgAAAAAAAAADAAAABgAAAAIAAAAAAAAAAgAAAAMAAAAPAAAAAAAAAAIAAAACAAAAAwAAAAsAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAIAAAACAAAAAAAAAAMAAAAHAAAAAgAAAAAAAAACAAAAAwAAABAAAAAAAAAAAgAAAAIAAAADAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAIAAAAAAAAAAwAAAAgAAAACAAAAAAAAAAIAAAADAAAAEQAAAAAAAAACAAAAAgAAAAMAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAACAAAAAgAAAAAAAAADAAAACQAAAAIAAAAAAAAAAgAAAAMAAAASAAAAAAAAAAIAAAACAAAAAwAAAA4AAAAAAAAAAAAAAAAAAAAAAAAACQAAAAIAAAACAAAAAAAAAAMAAAAFAAAAAgAAAAAAAAACAAAAAwAAABMAAAAAAAAAAgAAAAIAAAADAAAADwAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAgAAAAAAAAACAAAAAQAAABMAAAACAAAAAgAAAAAAAAAFAAAACgAAAAAAAAACAAAAAgAAAAMAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABEAAAACAAAAAAAAAAIAAAABAAAADwAAAAIAAAACAAAAAAAAAAUAAAALAAAAAAAAAAIAAAACAAAAAwAAABEAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAIAAAAAAAAAAgAAAAEAAAAQAAAAAgAAAAIAAAAAAAAABQAAAAwAAAAAAAAAAgAAAAIAAAADAAAAEgAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAACAAAAAQAAABEAAAACAAAAAgAAAAAAAAAFAAAADQAAAAAAAAACAAAAAgAAAAMAAAATAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAACAAAAAAAAAAIAAAABAAAAEgAAAAIAAAACAAAAAAAAAAUAAAAOAAAAAAAAAAIAAAACAAAAAwAAAAIAAAABAAAAAAAAAAEAAAACAAAAAAAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAEAAAAAAAAAAgAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAgAAAAAAAAABAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAAAAAAAAAAABQAAAAQAAAAAAAAAAQAAAAUAAAAEAAAAAAAAAAUAAAAFAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAABAAAAAAEAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAEAAAAAAAAAAAAAOgehWlKfUEEz1zLi+JsiQa2og3wcMfVAWCbHorc0yEDi+Yn/Y6mbQJ11/mfsnG9At6bnG4UQQkBvMCQWKqUUQJVmwwswmOc/3hVgVBL3uj//qqOEOdGOPw/WDN4gnGE/H3ANkCUgND+AA8btKgAHPwTXBqJVSdo+XfRQAqsKrj4fc+zLYbSPQklEmCZHv2FCUP+uDso1NEKYtPhwphUHQptxnyFXYdpB7CddZAMmrkGAt1AxSTqBQUibBVdTsFNBSuX3MV+AJkFocv82SLf5QAqmgj7AY81A23VDSEnLoEDGEJVSeDFzQDYrqvBk70VA8U157pcRGUBWfEF+ZKbsP6phvycGBZRAJbod0OgwfkCp+L8jatBmQCjl3pGrPlFAfMWm114SOkButwtqS7UjQHQwbcjXyw1A8jnLuuyA9j9KwjL0VwHhPyotk0lcs8k/Q5PvEs9rsz+SfsOQEVqdPzUAKDojLoY/WJz/kcjCcD8YFu070FRZPyoLC2BdJEM/YOXQAuiMM0HIBz1bw3sdQdV46aaHRwZByatzjDPX8EDb3Jie8HXZQCJxj6ULP8NAUaG6uRAZrUCWdmou5/mVQLb9huRPm4BAhvoCHygZaUCuX/I3SPdSQC9/bC/1qTxAfKxsYQ6pJUCuslH+N14QQMS/cv7SvPg/Ol8maYKx4j8AAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAD/////AAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////wAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAP////8AAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////BQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAUAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAEAAQAAAQEAAAAAAAEAAAABAAAAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAKriWFiWZfg/Y2nmTbY/8z8MHSPSqmnjv6hnn18HR3c/quJYWJZl+D/jq5TzDdzyPwwdI9KqaeO/u0kC1eFSBECq4lhYlmX4P69pJmt7c/E/NnkJi6jSBsDESFlzKkr6P33ArMz7sfY/o2q2uqM08D+oZ59fB0d3PzEqCi3qrvK/kmm4ANp49D+4wS2wzhzvP9WJvyAnx+E/upcY75RVx7+95t+9y0T1P9L18g1caO0/k6CkRyVzAEBf99+e/GjxP6QMsuuLQ/U/PlP4Qr8q7j8Mb/GO2GMCwLl2K/DQIghAePiwytEp9D9UHrsuI/nqPzjMedJ+yuy/k6xgf58n/L+XoQtn22DzP2lzCnsYk+s/JhUSDI4P8z+8lFcBhgTcPxOqKRxEX/M/89MEdoPQ6j8OKQaXDob7vzWwNvblgAPAzGkxMcl88j9Nm4okPkbpP0vI89vxSgRAdac2Z6W2/T+6UFOMC3zyP/+2XEF3hug/QqhELwGKCMAwdlQerEoEQFcr/B+VnvE/hB1hfFzT5j8wdsE/Da64P0hIvnF/sOC/KH/hrXUg8T9bI5OQHaLlP+mYzla7td6/CtKG6iOm8b8FW3TV8oXwP8ORhtNuJ+c/q8JrTMz/AcC8PaUl+PUFwAXv9rkMT/A/m+sAswr15D+7hk/O3yvkP6c/yVsOHKI/qqAX9idJ8D/8hNz1KNPiP7xSXh3Ggvg/epbkiKr57T/23/LB1GLvP4GTTeNZi+M/W4TqlTheBcDupZgIdYUIQGwlcW3YZO8/tQvDXQ3H4j8Bt+sf9DkAQMdFie+nNvg/Z5Uh1wDX7j9h5X2d4KjhPxMJ1ZVT4Pa/evqB8xB//7+W183U9QLsPwzNxsC7AOA/af/LqCnK/r/lPceQ0FQDwHoY0nYIW+w/bHNSHrTg4D/DFcMAdabuv2sz5Ojhnve/FvLf01HN6z/tEDL2Hz/gP0bBv0KUhPA/pd7sEnMc4D8EGon4Lo7sP5NVbYtSON8/DAMC50odBkB+Z2J8MGYCQIhlM1gubOo/FssiPwWy4D8OIlGqRnkCQAd1vopp6f4/QS1keLLK6T9rfoBuT7LZP3KQbH5ugwjAjqVPXTmbBUBL/JxcqR3qP3oSeovuktg/Y6pRhJmqy7+0kwuU0Yjmv2wvsfFmQ+g/R98lJFqQ2T/IGb5gjLkCwK3mNff3kQbAqDznPFM86T+iiP0FfsvYP7fzKG6Mls0/h7+at2btzL8tsUTgk+LmP/YEIrTDINU/WmwKoVjA5L9aC02r6FHxvzzFCT/Qg+Y/nx0V97en0j8+1toJOm77P1kZ7h8KjfQ/GBbbqxgk5j9RGXM79G/SP+beHsWmweQ/9REi4eX0xD/V9s+kmMHkP+pb9yNs09A/c5ERjVDTAECqEr3OBCH7P14ILfMECOU/piRx4P8P0j+JYU//bfL0Pw62fw28B+w/l5YW2Ga45D9+CyKRbenOP5cH6fHy1/S/o/egk03++r91nTYRL/bjP3fHN6OJVdA/7xXQh1XLBcAB3g6tBdUIQKW2KnGYjeQ/SqIpagclyz8F9P3YgNL6v9H6NBsZ8QDAW2k5L5Qs4z/0axa1l6zLP1GE65Mu4wNAwfX+BYmWAEBBgJP90M3hP6/03qhPLdA/zqo5bJz2778/ESlPCTn1v7JkhGyvzuE/DM7sj5twwz/6xbXLavYGQH29RFRGkgNA7bOXVSJ54T9fEhTHO/TDP+8t+HMOiwDAxa0SbGTtA8Atii7y0mLgP4cecHFB3sM/uPUpyv+K7j8nktD1/WvhP2cWmi772d8/Fj7uU9kEvD8oKOESLzKmvwSdCqrHdNu/XCluGsvI3T929OW5md+uP9dP6rXcZNq/gXM+ggzL6b+eKjsPgJncP6i1e9aVu7E/2CnPNJyD1D/DnyGgSe+xvy8k7g9bp9s/nYmLvHn1sz9cFOwApH8IwGa6Mjy9cgZAJr95SiSW2z8rCkhOFvqdP3SIKmO/UwPAEy0zkN7bBsCds8Hg/13YP1zv413hVGi/FVtqixSn6L9XAPQGul3yv7SGu2BoCNk/n94bv7Maj79p13T6X9z3P45MPCW3WvI/rU/8/LRj1T9cgR6SXd+ZPymL2DstbPI/8s/pAkIz6z/fmoB+8efYPz2XyfWgYaa/6wys72AW/j8LZImhgrf3P729Zla/n9U/ySB8B3PBqL8O2nhevvbxv17+5A+n6fe/YrGIqEGB1T+wCEGbkhaxv989QHVE5wFAzd12PTu3/T9AHUPZY2DUP3SQDST0zq2/JCxAlIoj5T+Mhe1IJkrQP/cRpl8QhtU/amc4seFts79khiUSVaz3vxYfWtjPwf2/CHscxQqD0j/ctUBQ9my3v0POnFiyXv2/pjjn2Ju/AcDk45DwBhPRP/GjwlCrv7m/aT2ciwolBsAQOzHr/wUJQCzpq5UYvtI/gDCf3SlCwb+4i7S+mukEQBDA1f8mowFA2utnRN3KyT9T+9EYAVG6v9/IVZ0enrE/7NbRtdGfzr/8y8GpRz7LP3U0vTSk18e/JzHEcwiBB0AGm8Q7AJkEQNLciyt4Esk/gLou5zoQxr+RrOfM91oBwEzd36KybgTAgLou5zoQxj/S3IsreBLJv1gCch0OHO8/FD+RxSLN4j91NL00pNfHP/zLwalHPsu/nL7/By4Pyr8tSP5h7CPiv1P70RgBUbo/2utnRN3Kyb/KfllfCpUIwLkP5zj+NwdAgDCf3SlCwT8s6auVGL7Sv2aFPlaC4eC/XrS5UVH77b/xo8JQq7+5P+TjkPAGE9G/Q30/RYbn1z8FF/ISafuLv9y1QFD2bLc/CHscxQqD0r/fi+tPROX0P6vRc+19ie0/amc4seFtsz/3EaZfEIbVv77TYpahl/o/DDsu0CaC9D90kA0k9M6tP0AdQ9ljYNS/CCI0rxjZA8BgfCaLthgHwLAIQZuSFrE/YrGIqEGB1b8kvQ982+rsv4J8EWu7jPS/ySB8B3PBqD+9vWZWv5/VvwrAByWcJgBAxFujmE9a+j89l8n1oGGmP9+agH7x59i/N03cuJUt9L8X9v4GdIz6v1yBHpJd35m/rU/8/LRj1b8mz69sydf/vyu5idMqVQLAn94bv7Majz8AhrtgaAjZv+aCE66WZ/q/lA1Mgz/p/79c7+Nd4VRoP52zweD/Xdi/TJZpMTb4AkDLWZShPOb/PysKSE4W+p2/Jr95SiSW27/PkmbE7zjnP6UAiCDmMNI/nYmLvHn1s78vJO4PW6fbv5MWA2vqSrQ/V5WLwPB51b+otXvWlbuxv54qOw+Amdy/1keqzYeRBsApIEMHgZIIQHb05bmZ366/XCluGsvI3b8W44a9X9UFQEeQtDM4rwJAFj7uU9kEvL9nFpou+9nfv3Co+JcyyQhAcdkCX2KzBUCHHnBxQd7Dvy2KLvLSYuC/o6+5YTt/AcCHCNDW+8YEwF8SFMc79MO/7bOXVSJ54b9E/pfA2S3xPzD9xaBb0uQ/DM7sj5tww7+yZIRsr87hv7c4c0SEXNG/Tr79/9M+5r+v9N6oTy3Qv5uAk/3QzeG/XcI1OVQkAUAQSV9Z7Qr9P/RrFrWXrMu/W2k5L5Qs479Zo2IBM/vkv6FuipzkFvG/SqIpagcly7+ltipxmI3kv0pmis91cfc/gWQecsRh8D93xzejiVXQv3WdNhEv9uO/D7mgYy612j+PyVPNaT2jv34LIpFt6c6/l5YW2Ga45L+LUp+2A2z9P39i5xSpRfc/piRx4P8P0r9eCC3zBAjlv5n4OKmIUf2/jj/kUAwgAsDqW/cjbNPQv9X2z6SYweS/aTdljlWd8L94R8vZ8SL3v1EZczv0b9K/GBbbqxgk5r9XdfyikfEDwPILMvas0gfAnx0V97en0r88xQk/0IPmvxGErZ681fa/9kCaiOy2/b/2BCK0wyDVvy2xROCT4ua/+5EBLOXxA0B7p53+BnkAQKKI/QV+y9i/qDznPFM86b/snWGNkkgHwC+ByugkUwdAR98lJFqQ2b9sL7HxZkPovyJNGM67oek/HzNy6BqA1D96EnqL7pLYv0v8nFypHeq/axL/u1FnB0AkSEHvxn8DQGt+gG5Pstm/QS1keLLK6b/Sk/O6mtGzPxU8pLcPNty/FssiPwWy4L+IZTNYLmzqvw4szKfSouq/G+XJHY1a87+TVW2LUjjfvwQaifgujuy/3VARaoMl2L9NFodfK+/qv+0QMvYfP+C/FvLf01HN67+ETOQysd8AwH71iI/eGgXAbHNSHrTg4L96GNJ2CFvsv6BnExReeAFA5CakvxSl+j8MzcbAuwDgv5bXzdT1Auy/uVq8/8x58z+uvPMNqzTnP2HlfZ3gqOG/Z5Uh1wDX7r8PUbMSo2P7P9VfBrXlxPI/tQvDXQ3H4r9sJXFt2GTvvyDssGgO0PG/WxT/uE4N+r+Bk03jWYvjv/bf8sHUYu+/rUXN8hUe3j9m5HB1yZCzv/yE3PUo0+K/qqAX9idJ8L9mByqLMMH5v4kHC7KQowHAm+sAswr15L8F7/a5DE/wv2JLsGADFwTAKQjVGovZCMDDkYbTbifnvwVbdNXyhfC/malhH7yI7D+oevd0GWDZP1sjk5AdouW/KH/hrXUg8b8KWmrpQ0sFQAzEAF/pTgBAhB1hfFzT5r9XK/wflZ7xv18hRuqKXAjA/5rUd9v1BED/tlxBd4bov7pQU4wLfPK/4pnwn0T/sj/c277XPF3jv02biiQ+Rum/zGkxMcl88r8Yk0HhJVzjv62yUUFRjfS/89MEdoPQ6r8TqikcRF/zvxQxghHovfY/cfM1eFWE5j9pcwp7GJPrv5ehC2fbYPO/KUV2nGg0/795OhmUaqEFwFQeuy4j+eq/ePiwytEp9L8DuqWfW+8BQLytJylXHPY/PlP4Qr8q7r+kDLLri0P1vxT4ShWL+Oo/DMsWg0zlv7/S9fINXGjtv73m373LRPW/+xg/Gaxd8b94MdQEfW0AwLjBLbDOHO+/kmm4ANp49L+cShSMMbAEwKyjUgWirAdAo2q2uqM08L99wKzM+7H2v3RdlNBXFgnA8S9+ewyV/z+vaSZre3Pxv6riWFiWZfi/2J7VSZZ60j+LES81zPn3v+OrlPMN3PK/quJYWJZl+L/OZbufkEcEQLCNB/1lPOO/Y2nmTbY/87+q4lhYlmX4v7CNB/1lPOO/zmW7n5BHBEBwKD1Aa57LP/XsSsw7RbU/PMDPJGsfoD/TqningGKIPzFtCLYmb3I/qYfrJr7eWz9pQmleXRFFP0rWlJkA2i8/pCvcttgTGD9Dt8IWbjMCPyCG4GRlhOs+1JI2GhDN1D7ns8cGvXK/Pi8m8UTJxac+hNTfA2z4kT7GI8kjLyt7Pv//////HwAI//////8zEAj/////fzIgCP////9vMjAI/////2MyQAj///8/YjJQCP///zdiMmAI////M2IycAj//78zYjKACP//qzNiMpAI/3+rM2IyoAj/D6szYjKwCP8DqzNiMsAIvwOrM2Iy0AifA6szYjLgCJkDqzNiMvAI//////8/Dwj//////ysfCP////9/KS8I/////z8pPwj/////OSlPCP///z84KV8I////Dzgpbwj///8OOCl/CP//Hw44KY8I//8PDjgpnwj/fw0OOCmvCP8PDQ44Kb8I/w0NDjgpzwj/DA0OOCnfCMcMDQ44Ke8IxAwNDjgp/wgHAAAABwAAAAEAAAACAAAABAAAAAMAAAAAAAAAAAAAAAcAAAADAAAAAQAAAAIAAAAFAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAgAAAAEAAAADAAAADgAAAAYAAAALAAAAAgAAAAcAAAABAAAAGAAAAAUAAAAKAAAAAQAAAAYAAAAAAAAAJgAAAAcAAAAMAAAAAwAAAAgAAAACAAAAMQAAAAkAAAAOAAAAAAAAAAUAAAAEAAAAOgAAAAgAAAANAAAABAAAAAkAAAADAAAAPwAAAAsAAAAGAAAADwAAAAoAAAAQAAAASAAAAAwAAAAHAAAAEAAAAAsAAAARAAAAUwAAAAoAAAAFAAAAEwAAAA4AAAAPAAAAYQAAAA0AAAAIAAAAEQAAAAwAAAASAAAAawAAAA4AAAAJAAAAEgAAAA0AAAATAAAAdQAAAA8AAAATAAAAEQAAABIAAAAQAAAABgAAAAIAAAADAAAABQAAAAQAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAMAAAABAAAABQAAAAQAAAAAAAAAAAAAAAcAAAAFAAAAAwAAAAQAAAABAAAAAAAAAAIAAAAAAAAAAgAAAAMAAAABAAAABQAAAAQAAAAGAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifm/GC1EVPshCUAYLURU+yEJwGFsZ29zLmMAaDNOZWlnaGJvclJvdGF0aW9ucwBjZWxsc1RvTXVsdGlQb2x5LmMAY2VsbFRvRWRnZUFyY3MAAAEDAgQABAMFAQJjYW5jZWxBcmNQYWlycwBjcmVhdGVTb3J0YWJsZUxvb3AAZGlyZWN0ZWRFZGdlLmMAZGlyZWN0ZWRFZGdlVG9Cb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbdG1wRmlqay5mYWNlXVtmaWprLmZhY2VdID09IEtJAGZhY2VpamsuYwBfZmFjZUlqa1BlbnRUb0NlbGxCb3VuZGFyeQBhZGphY2VudEZhY2VEaXJbY2VudGVySUpLLmZhY2VdW2ZhY2UyXSA9PSBLSQBfZmFjZUlqa1RvQ2VsbEJvdW5kYXJ5AGgzSW5kZXguYwBjb21wYWN0Q2VsbHMAdmVjM1RvQ2VsbABjZWxsVG9DaGlsZFBvcwB2YWxpZGF0ZUNoaWxkUG9zAHJldkRpciAhPSBJTlZBTElEX0RJR0lUAGxvY2FsaWouYwBjZWxsVG9Mb2NhbElqawBiYXNlQ2VsbCAhPSBvcmlnaW5CYXNlQ2VsbAAhKG9yaWdpbk9uUGVudCAmJiBpbmRleE9uUGVudCkAYmFzZUNlbGwgPT0gb3JpZ2luQmFzZUNlbGwALi4vaW5jbHVkZS9jb29yZGlqay5oAF91cEFwN0NoZWNrZWQAX3VwQXA3ckNoZWNrZWQAYmFzZUNlbGwgIT0gSU5WQUxJRF9CQVNFX0NFTEwAbG9jYWxJamtUb0NlbGwAIV9pc0Jhc2VDZWxsUGVudGFnb24oYmFzZUNlbGwpAGJhc2VDZWxsUm90YXRpb25zID49IDAAZ3JpZFBhdGhDZWxsc0ludGVycG9sYXRlAHBvbHlmaWxsLmMAaXRlclN0ZXBQb2x5Z29uQ29tcGFjdAAwAHZlcnRleC5jAHZlcnRleFJvdGF0aW9ucwBjZWxsVG9WZXJ0ZXg=";var De=28400;function ue(it,Ot,nn,Nt){Gt("Assertion failed: "+U(it)+", at: "+[Ot?U(Ot):"unknown filename",nn,Nt?U(Nt):"unknown function"])}function Ve(){return H.length}function We(it,Ot,nn){K.set(K.subarray(Ot,Ot+nn),it)}function ct(it){return e.___errno_location&&(J[e.___errno_location()>>2]=it),it}function vt(it){Gt("OOM")}function Ut(it){try{var Ot=new ArrayBuffer(it);return Ot.byteLength!=it?void 0:(new Int8Array(Ot).set(H),yt(Ot),Q(Ot),1)}catch{}}function dt(it){var Ot=Ve(),nn=16777216,Nt=2147483648-nn;if(it>Nt)return!1;for(var m=16777216,Ie=Math.max(Ot,m);Ie>4,m=(Ln&15)<<4|Rn>>2,Ie=(Rn&3)<<6|Mn,nn=nn+String.fromCharCode(Nt),Rn!==64&&(nn=nn+String.fromCharCode(m)),Mn!==64&&(nn=nn+String.fromCharCode(Ie));while(Cn13780509?(w=rl(15,w)|0,w|0):(S=((A|0)<0)<<31>>31,E=si(A|0,S|0,3,0)|0,N=_e()|0,S=Pn(A|0,S|0,1,0)|0,S=si(E|0,N|0,S|0,_e()|0)|0,S=Pn(S|0,_e()|0,1,0)|0,A=_e()|0,m[w>>2]=S,m[w+4>>2]=A,w=0,w|0)}function Kr(A,w,S,N){return A=A|0,w=w|0,S=S|0,N=N|0,Ir(A,w,S,N,0)|0}function Ir(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0;if(T=Re,Re=Re+16|0,D=T,!(In(A,w,S,N,E)|0))return N=0,Re=T,N|0;do if((S|0)>=0){if((S|0)>13780509){if(P=rl(15,D)|0,P|0)break;v=D,D=m[v>>2]|0,v=m[v+4>>2]|0}else P=((S|0)<0)<<31>>31,j=si(S|0,P|0,3,0)|0,v=_e()|0,P=Pn(S|0,P|0,1,0)|0,P=si(j|0,v|0,P|0,_e()|0)|0,P=Pn(P|0,_e()|0,1,0)|0,v=_e()|0,m[D>>2]=P,m[D+4>>2]=v,D=P;if(Eh(N|0,0,D<<3|0)|0,E|0){Eh(E|0,0,D<<2|0)|0,P=Ri(A,w,S,N,E,D,v,0)|0;break}P=bs(D,4)|0,P?(j=Ri(A,w,S,N,P,D,v,0)|0,yn(P),P=j):P=13}else P=2;while(!1);return j=P,Re=T,j|0}function In(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0;if(xe=Re,Re=Re+16|0,ne=xe,le=xe+8|0,te=ne,m[te>>2]=A,m[te+4>>2]=w,(S|0)<0)return le=2,Re=xe,le|0;if(P=N,m[P>>2]=A,m[P+4>>2]=w,P=(E|0)!=0,P&&(m[E>>2]=0),Hr(A,w)|0)return le=9,Re=xe,le|0;m[le>>2]=0;e:do if((S|0)>=1)if(P)for(q=1,j=0,Z=0,te=1,P=A;;){if(!(j|Z)){if(P=sr(P,w,4,le,ne)|0,P|0)break e;if(w=ne,P=m[w>>2]|0,w=m[w+4>>2]|0,Hr(P,w)|0){P=9;break e}}if(P=sr(P,w,m[26864+(Z<<2)>>2]|0,le,ne)|0,P|0)break e;if(w=ne,P=m[w>>2]|0,w=m[w+4>>2]|0,A=N+(q<<3)|0,m[A>>2]=P,m[A+4>>2]=w,m[E+(q<<2)>>2]=te,A=j+1|0,D=(A|0)==(te|0),v=Z+1|0,T=(v|0)==6,Hr(P,w)|0){P=9;break e}if(te=te+(T&D&1)|0,(te|0)>(S|0)){P=0;break}else q=q+1|0,j=D?0:A,Z=D?T?0:v:Z}else for(q=1,j=0,Z=0,te=1,P=A;;){if(!(j|Z)){if(P=sr(P,w,4,le,ne)|0,P|0)break e;if(w=ne,P=m[w>>2]|0,w=m[w+4>>2]|0,Hr(P,w)|0){P=9;break e}}if(P=sr(P,w,m[26864+(Z<<2)>>2]|0,le,ne)|0,P|0)break e;if(w=ne,P=m[w>>2]|0,w=m[w+4>>2]|0,A=N+(q<<3)|0,m[A>>2]=P,m[A+4>>2]=w,A=j+1|0,D=(A|0)==(te|0),v=Z+1|0,T=(v|0)==6,Hr(P,w)|0){P=9;break e}if(te=te+(T&D&1)|0,(te|0)>(S|0)){P=0;break}else q=q+1|0,j=D?0:A,Z=D?T?0:v:Z}else P=0;while(!1);return le=P,Re=xe,le|0}function Ri(A,w,S,N,E,P,D,v){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0,D=D|0,v=v|0;var T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0;if(xe=Re,Re=Re+16|0,ne=xe+8|0,le=xe,T=Mc(A|0,w|0,P|0,D|0)|0,q=_e()|0,Z=N+(T<<3)|0,Ee=Z,Ue=m[Ee>>2]|0,Ee=m[Ee+4>>2]|0,j=(Ue|0)==(A|0)&(Ee|0)==(w|0),!((Ue|0)==0&(Ee|0)==0|j))do T=Pn(T|0,q|0,1,0)|0,T=Kc(T|0,_e()|0,P|0,D|0)|0,q=_e()|0,Z=N+(T<<3)|0,Ue=Z,Ee=m[Ue>>2]|0,Ue=m[Ue+4>>2]|0,j=(Ee|0)==(A|0)&(Ue|0)==(w|0);while(!((Ee|0)==0&(Ue|0)==0|j));if(T=E+(T<<2)|0,j&&(m[T>>2]|0)<=(v|0)||(Ue=Z,m[Ue>>2]=A,m[Ue+4>>2]=w,m[T>>2]=v,(v|0)>=(S|0)))return Ue=0,Re=xe,Ue|0;switch(j=v+1|0,m[ne>>2]=0,T=sr(A,w,2,ne,le)|0,T|0){case 9:{te=9;break}case 0:{T=le,T=Ri(m[T>>2]|0,m[T+4>>2]|0,S,N,E,P,D,j)|0,T||(te=9);break}}e:do if((te|0)==9){switch(m[ne>>2]=0,T=sr(A,w,3,ne,le)|0,T|0){case 9:break;case 0:{if(T=le,T=Ri(m[T>>2]|0,m[T+4>>2]|0,S,N,E,P,D,j)|0,T|0)break e;break}default:break e}switch(m[ne>>2]=0,T=sr(A,w,1,ne,le)|0,T|0){case 9:break;case 0:{if(T=le,T=Ri(m[T>>2]|0,m[T+4>>2]|0,S,N,E,P,D,j)|0,T|0)break e;break}default:break e}switch(m[ne>>2]=0,T=sr(A,w,5,ne,le)|0,T|0){case 9:break;case 0:{if(T=le,T=Ri(m[T>>2]|0,m[T+4>>2]|0,S,N,E,P,D,j)|0,T|0)break e;break}default:break e}switch(m[ne>>2]=0,T=sr(A,w,4,ne,le)|0,T|0){case 9:break;case 0:{if(T=le,T=Ri(m[T>>2]|0,m[T+4>>2]|0,S,N,E,P,D,j)|0,T|0)break e;break}default:break e}switch(m[ne>>2]=0,T=sr(A,w,6,ne,le)|0,T|0){case 9:break;case 0:{if(T=le,T=Ri(m[T>>2]|0,m[T+4>>2]|0,S,N,E,P,D,j)|0,T|0)break e;break}default:break e}return Ue=0,Re=xe,Ue|0}while(!1);return Ue=T,Re=xe,Ue|0}function sr(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0;if(S>>>0>6)return E=1,E|0;D=(m[N>>2]|0)%6|0,m[N>>2]=D;e:do if((D|0)>0)for(P=0;;){switch(S|0){case 1:{S=5;break}case 5:{S=4;break}case 4:{S=6;break}case 6:{S=2;break}case 2:{S=3;break}case 3:{S=1;break}}if(P=P+1|0,(P|0)==(D|0))break e}while(!1);if(Z=pn(A|0,w|0,45)|0,_e()|0,q=Z&127,q>>>0>121)return E=5,E|0;T=Li(A,w)|0,P=pn(A|0,w|0,52)|0,_e()|0,P=P&15;e:do if(!P)j=15;else{for(;;){if(D=(15-P|0)*3|0,v=pn(A|0,w|0,D|0)|0,_e()|0,v=v&7,(v|0)==7){w=5;break}if(le=($r(P)|0)==0,P=P+-1|0,te=xn(7,0,D|0)|0,w=w&~(_e()|0),ne=xn(m[(le?432:16)+(v*28|0)+(S<<2)>>2]|0,0,D|0)|0,D=_e()|0,S=m[(le?640:224)+(v*28|0)+(S<<2)>>2]|0,A=ne|A&~te,w=D|w,!S){S=0;break e}if(!P){j=15;break e}}return w|0}while(!1);(j|0)==15&&(le=m[848+(q*28|0)+(S<<2)>>2]|0,ne=xn(le|0,0,45)|0,A=ne|A,w=_e()|0|w&-1040385,S=m[4272+(q*28|0)+(S<<2)>>2]|0,(le&127|0)==127&&(le=xn(m[848+(q*28|0)+20>>2]|0,0,45)|0,w=_e()|0|w&-1040385,S=m[4272+(q*28|0)+20>>2]|0,A=yl(le|A,w)|0,w=_e()|0,m[N>>2]=(m[N>>2]|0)+1)),v=pn(A|0,w|0,45)|0,_e()|0,v=v&127;e:do if(nr(v)|0){t:do if((Li(A,w)|0)==1){if((q|0)!=(v|0))if(Es(v,m[7696+(q*28|0)>>2]|0)|0){A=ms(A,w)|0,D=1,w=_e()|0;break}else Dt(27634,26928,533,26936);switch(T|0){case 3:{A=yl(A,w)|0,w=_e()|0,m[N>>2]=(m[N>>2]|0)+1,D=0;break t}case 5:{A=ms(A,w)|0,w=_e()|0,m[N>>2]=(m[N>>2]|0)+5,D=0;break t}case 0:return le=9,le|0;default:return le=1,le|0}}else D=0;while(!1);if((S|0)>0){P=0;do A=Xc(A,w)|0,w=_e()|0,P=P+1|0;while((P|0)!=(S|0))}if((q|0)!=(v|0)){if(!(Hc(v)|0)){if((D|0)!=0|(Li(A,w)|0)!=5)break;m[N>>2]=(m[N>>2]|0)+1;break}switch(Z&127){case 8:case 118:break e}(Li(A,w)|0)!=3&&(m[N>>2]=(m[N>>2]|0)+1)}}else if((S|0)>0){P=0;do A=yl(A,w)|0,w=_e()|0,P=P+1|0;while((P|0)!=(S|0))}while(!1);return m[N>>2]=((m[N>>2]|0)+S|0)%6|0,le=E,m[le>>2]=A,m[le+4>>2]=w,le=0,le|0}function Ai(A,w,S,N){return A=A|0,w=w|0,S=S|0,N=N|0,fs(A,w,S,N)|0?(Eh(N|0,0,S*48|0)|0,N=Ki(A,w,S,N)|0,N|0):(N=0,N|0)}function fs(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0;if(le=Re,Re=Re+16|0,te=le,ne=le+8|0,Z=te,m[Z>>2]=A,m[Z+4>>2]=w,(S|0)<0)return ne=2,Re=le,ne|0;if(!S)return ne=N,m[ne>>2]=A,m[ne+4>>2]=w,ne=0,Re=le,ne|0;m[ne>>2]=0;e:do if(Hr(A,w)|0)A=9;else{E=0,Z=A;do{if(A=sr(Z,w,4,ne,te)|0,A|0)break e;if(w=te,Z=m[w>>2]|0,w=m[w+4>>2]|0,E=E+1|0,Hr(Z,w)|0){A=9;break e}}while((E|0)<(S|0));q=N,m[q>>2]=Z,m[q+4>>2]=w,q=S+-1|0,j=0,A=1;do{if(E=26864+(j<<2)|0,(j|0)==5)for(D=m[E>>2]|0,P=0,E=A;;){if(A=te,A=sr(m[A>>2]|0,m[A+4>>2]|0,D,ne,te)|0,A|0)break e;if((P|0)!=(q|0))if(T=te,v=m[T>>2]|0,T=m[T+4>>2]|0,A=N+(E<<3)|0,m[A>>2]=v,m[A+4>>2]=T,!(Hr(v,T)|0))A=E+1|0;else{A=9;break e}else A=E;if(P=P+1|0,(P|0)>=(S|0))break;E=A}else for(D=te,T=m[E>>2]|0,v=0,E=A,P=m[D>>2]|0,D=m[D+4>>2]|0;;){if(A=sr(P,D,T,ne,te)|0,A|0)break e;if(D=te,P=m[D>>2]|0,D=m[D+4>>2]|0,A=N+(E<<3)|0,m[A>>2]=P,m[A+4>>2]=D,A=E+1|0,Hr(P,D)|0){A=9;break e}if(v=v+1|0,(v|0)>=(S|0))break;E=A}j=j+1|0}while(j>>>0<6);A=te,A=(Z|0)==(m[A>>2]|0)&&(w|0)==(m[A+4>>2]|0)?0:9}while(!1);return ne=A,Re=le,ne|0}function Ki(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0;if(Z=Re,Re=Re+16|0,D=Z,!S)return m[N>>2]=A,m[N+4>>2]=w,N=0,Re=Z,N|0;do if((S|0)>=0){if((S|0)>13780509){if(E=rl(15,D)|0,E|0)break;P=D,E=m[P>>2]|0,P=m[P+4>>2]|0}else E=((S|0)<0)<<31>>31,q=si(S|0,E|0,3,0)|0,P=_e()|0,E=Pn(S|0,E|0,1,0)|0,E=si(q|0,P|0,E|0,_e()|0)|0,E=Pn(E|0,_e()|0,1,0)|0,P=_e()|0,q=D,m[q>>2]=E,m[q+4>>2]=P;if(j=bs(E,8)|0,!j)E=13;else{if(q=bs(E,4)|0,!q){yn(j),E=13;break}if(E=Ri(A,w,S,j,q,E,P,0)|0,E|0){yn(j),yn(q);break}if(w=m[D>>2]|0,D=m[D+4>>2]|0,(D|0)>0|(D|0)==0&w>>>0>0){E=0,v=0,T=0;do A=j+(v<<3)|0,P=m[A>>2]|0,A=m[A+4>>2]|0,!((P|0)==0&(A|0)==0)&&(m[q+(v<<2)>>2]|0)==(S|0)&&(te=N+(E<<3)|0,m[te>>2]=P,m[te+4>>2]=A,E=E+1|0),v=Pn(v|0,T|0,1,0)|0,T=_e()|0;while((T|0)<(D|0)|(T|0)==(D|0)&v>>>0>>0)}yn(j),yn(q),E=0}}else E=2;while(!1);return te=E,Re=Z,te|0}function js(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0;for(v=Re,Re=Re+16|0,P=v,D=v+8|0,E=(Hr(A,w)|0)==0,E=E?1:2;;){if(m[D>>2]=0,j=(sr(A,w,E,D,P)|0)==0,T=P,j&((m[T>>2]|0)==(S|0)?(m[T+4>>2]|0)==(N|0):0)){A=4;break}if(E=E+1|0,E>>>0>=7){E=7,A=4;break}}return(A|0)==4?(Re=v,E|0):0}function oi(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0;if(v=Re,Re=Re+48|0,E=v+16|0,P=v+8|0,D=v,S=gd(S)|0,S|0)return D=S,Re=v,D|0;if(j=A,T=m[j+4>>2]|0,S=P,m[S>>2]=m[j>>2],m[S+4>>2]=T,Mu(P,E),S=yc(E,w,D)|0,!S){if(w=m[P>>2]|0,P=m[A+8>>2]|0,(P|0)>0){E=m[A+12>>2]|0,S=0;do w=(m[E+(S<<3)>>2]|0)+w|0,S=S+1|0;while((S|0)<(P|0))}S=D,E=m[S>>2]|0,S=m[S+4>>2]|0,P=((w|0)<0)<<31>>31,(S|0)<(P|0)|(S|0)==(P|0)&E>>>0>>0?(S=D,m[S>>2]=w,m[S+4>>2]=P,S=P):w=E,T=Pn(w|0,S|0,12,0)|0,j=_e()|0,S=D,m[S>>2]=T,m[S+4>>2]=j,S=N,m[S>>2]=T,m[S+4>>2]=j,S=0}return j=S,Re=v,j|0}function Ei(A,w,S,N,E,P,D){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0,D=D|0;var v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0,kt=0,Rt=0,Wt=0,Kt=0,tn=0,Zn=0,On=0,Rr=0,fr=0,Kn=0,Qn=0;if(On=Re,Re=Re+64|0,Wt=On+48|0,Kt=On+32|0,tn=On+24|0,Je=On+8|0,xt=On,T=m[A>>2]|0,(T|0)<=0)return Zn=0,Re=On,Zn|0;for(Ye=A+4|0,Ke=Wt+8|0,kt=Kt+8|0,Rt=Je+8|0,v=0,ke=0;;){j=m[Ye>>2]|0,we=j+(ke<<4)|0,m[Wt>>2]=m[we>>2],m[Wt+4>>2]=m[we+4>>2],m[Wt+8>>2]=m[we+8>>2],m[Wt+12>>2]=m[we+12>>2],(ke|0)==(T+-1|0)?(m[Kt>>2]=m[j>>2],m[Kt+4>>2]=m[j+4>>2],m[Kt+8>>2]=m[j+8>>2],m[Kt+12>>2]=m[j+12>>2]):(we=j+(ke+1<<4)|0,m[Kt>>2]=m[we>>2],m[Kt+4>>2]=m[we+4>>2],m[Kt+8>>2]=m[we+8>>2],m[Kt+12>>2]=m[we+12>>2]),T=bc(Wt,Kt,N,tn)|0;e:do if(T)j=0,v=T;else if(T=tn,j=m[T>>2]|0,T=m[T+4>>2]|0,(T|0)>0|(T|0)==0&j>>>0>0){Ue=0,we=0;t:for(;;){if(fr=1/(+(j>>>0)+4294967296*+(T|0)),Qn=+Ie[Wt>>3],T=ds(j|0,T|0,Ue|0,we|0)|0,Kn=+(T>>>0)+4294967296*+(_e()|0),Rr=+(Ue>>>0)+4294967296*+(we|0),Ie[Je>>3]=fr*(Qn*Kn)+fr*(+Ie[Kt>>3]*Rr),Ie[Rt>>3]=fr*(+Ie[Ke>>3]*Kn)+fr*(+Ie[kt>>3]*Rr),T=wc(Je,N,xt)|0,T|0){v=T;break}Ee=xt,xe=m[Ee>>2]|0,Ee=m[Ee+4>>2]|0,te=Mc(xe|0,Ee|0,w|0,S|0)|0,q=_e()|0,T=D+(te<<3)|0,Z=T,j=m[Z>>2]|0,Z=m[Z+4>>2]|0;n:do if((j|0)==0&(Z|0)==0)je=T,Zn=16;else for(ne=0,le=0;;){if((ne|0)>(S|0)|(ne|0)==(S|0)&le>>>0>w>>>0){v=1;break t}if((j|0)==(xe|0)&(Z|0)==(Ee|0))break n;if(T=Pn(te|0,q|0,1,0)|0,te=Kc(T|0,_e()|0,w|0,S|0)|0,q=_e()|0,le=Pn(le|0,ne|0,1,0)|0,ne=_e()|0,T=D+(te<<3)|0,Z=T,j=m[Z>>2]|0,Z=m[Z+4>>2]|0,(j|0)==0&(Z|0)==0){je=T,Zn=16;break}}while(!1);if((Zn|0)==16&&(Zn=0,!((xe|0)==0&(Ee|0)==0))&&(le=je,m[le>>2]=xe,m[le+4>>2]=Ee,le=P+(m[E>>2]<<3)|0,m[le>>2]=xe,m[le+4>>2]=Ee,le=E,le=Pn(m[le>>2]|0,m[le+4>>2]|0,1,0)|0,xe=_e()|0,Ee=E,m[Ee>>2]=le,m[Ee+4>>2]=xe),Ue=Pn(Ue|0,we|0,1,0)|0,we=_e()|0,T=tn,j=m[T>>2]|0,T=m[T+4>>2]|0,!((T|0)>(we|0)|(T|0)==(we|0)&j>>>0>Ue>>>0)){j=1;break e}}j=0}else j=1;while(!1);if(ke=ke+1|0,!j){Zn=21;break}if(T=m[A>>2]|0,(ke|0)>=(T|0)){v=0,Zn=21;break}}return(Zn|0)==21?(Re=On,v|0):0}function ja(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0,kt=0,Rt=0,Wt=0,Kt=0,tn=0,Zn=0,On=0,Rr=0,fr=0,Kn=0;if(Kn=Re,Re=Re+112|0,Zn=Kn+80|0,T=Kn+72|0,On=Kn,Rr=Kn+56|0,E=gd(S)|0,E|0)return fr=E,Re=Kn,fr|0;if(j=A+8|0,fr=gi((m[j>>2]<<5)+32|0)|0,!fr)return fr=13,Re=Kn,fr|0;if(Sl(A,fr),E=gd(S)|0,!E){if(Kt=A,tn=m[Kt+4>>2]|0,E=T,m[E>>2]=m[Kt>>2],m[E+4>>2]=tn,Mu(T,Zn),E=yc(Zn,w,On)|0,E)Kt=0,tn=0;else{if(E=m[T>>2]|0,P=m[j>>2]|0,(P|0)>0){D=m[A+12>>2]|0,S=0;do E=(m[D+(S<<3)>>2]|0)+E|0,S=S+1|0;while((S|0)!=(P|0));S=E}else S=E;E=On,P=m[E>>2]|0,E=m[E+4>>2]|0,D=((S|0)<0)<<31>>31,(E|0)<(D|0)|(E|0)==(D|0)&P>>>0>>0?(E=On,m[E>>2]=S,m[E+4>>2]=D,E=D):S=P,Kt=Pn(S|0,E|0,12,0)|0,tn=_e()|0,E=On,m[E>>2]=Kt,m[E+4>>2]=tn,E=0}if(!E){if(S=bs(Kt,8)|0,!S)return yn(fr),fr=13,Re=Kn,fr|0;if(v=bs(Kt,8)|0,!v)return yn(fr),yn(S),fr=13,Re=Kn,fr|0;Rt=Zn,m[Rt>>2]=0,m[Rt+4>>2]=0,Rt=A,Wt=m[Rt+4>>2]|0,E=T,m[E>>2]=m[Rt>>2],m[E+4>>2]=Wt,E=Ei(T,Kt,tn,w,Zn,S,v)|0;e:do if(E)yn(S),yn(v),yn(fr);else{t:do if((m[j>>2]|0)>0){for(D=A+12|0,P=0;E=Ei((m[D>>2]|0)+(P<<3)|0,Kt,tn,w,Zn,S,v)|0,P=P+1|0,!(E|0);)if((P|0)>=(m[j>>2]|0))break t;yn(S),yn(v),yn(fr);break e}while(!1);(tn|0)>0|(tn|0)==0&Kt>>>0>0&&Eh(v|0,0,Kt<<3|0)|0,Wt=Zn,Rt=m[Wt+4>>2]|0;t:do if((Rt|0)>0|(Rt|0)==0&(m[Wt>>2]|0)>>>0>0){Ye=S,Ke=v,kt=S,Rt=v,Wt=S,E=S,je=S,Je=v,xt=v,S=v;n:for(;;){for(Ee=0,Ue=0,we=0,ke=0,P=0,D=0;;){v=On,T=v+56|0;do m[v>>2]=0,v=v+4|0;while((v|0)<(T|0));if(w=Ye+(Ee<<3)|0,j=m[w>>2]|0,w=m[w+4>>2]|0,In(j,w,1,On,0)|0){v=On,T=v+56|0;do m[v>>2]=0,v=v+4|0;while((v|0)<(T|0));v=bs(7,4)|0,v|0&&(Ri(j,w,1,On,v,7,0,0)|0,yn(v))}for(xe=0;;){le=On+(xe<<3)|0,ne=m[le>>2]|0,le=m[le+4>>2]|0;r:do if((ne|0)==0&(le|0)==0)v=P,T=D;else{if(q=Mc(ne|0,le|0,Kt|0,tn|0)|0,j=_e()|0,v=N+(q<<3)|0,w=v,T=m[w>>2]|0,w=m[w+4>>2]|0,!((T|0)==0&(w|0)==0)){Z=0,te=0;do{if((Z|0)>(tn|0)|(Z|0)==(tn|0)&te>>>0>Kt>>>0)break n;if((T|0)==(ne|0)&(w|0)==(le|0)){v=P,T=D;break r}v=Pn(q|0,j|0,1,0)|0,q=Kc(v|0,_e()|0,Kt|0,tn|0)|0,j=_e()|0,te=Pn(te|0,Z|0,1,0)|0,Z=_e()|0,v=N+(q<<3)|0,w=v,T=m[w>>2]|0,w=m[w+4>>2]|0}while(!((T|0)==0&(w|0)==0))}if((ne|0)==0&(le|0)==0){v=P,T=D;break}Po(ne,le,Rr)|0,vf(A,fr,Rr)|0&&(te=Pn(P|0,D|0,1,0)|0,D=_e()|0,Z=v,m[Z>>2]=ne,m[Z+4>>2]=le,P=Ke+(P<<3)|0,m[P>>2]=ne,m[P+4>>2]=le,P=te),v=P,T=D}while(!1);if(xe=xe+1|0,xe>>>0>=7)break;P=v,D=T}if(Ee=Pn(Ee|0,Ue|0,1,0)|0,Ue=_e()|0,we=Pn(we|0,ke|0,1,0)|0,ke=_e()|0,D=Zn,P=m[D>>2]|0,D=m[D+4>>2]|0,(ke|0)<(D|0)|(ke|0)==(D|0)&we>>>0

>>0)P=v,D=T;else break}if((D|0)>0|(D|0)==0&P>>>0>0){P=0,D=0;do ke=Ye+(P<<3)|0,m[ke>>2]=0,m[ke+4>>2]=0,P=Pn(P|0,D|0,1,0)|0,D=_e()|0,ke=Zn,we=m[ke+4>>2]|0;while((D|0)<(we|0)|((D|0)==(we|0)?P>>>0<(m[ke>>2]|0)>>>0:0))}if(ke=Zn,m[ke>>2]=v,m[ke+4>>2]=T,(T|0)>0|(T|0)==0&v>>>0>0)xe=S,Ee=xt,Ue=Wt,we=Je,ke=Ke,S=je,xt=E,Je=kt,je=xe,E=Ee,Wt=Rt,Rt=Ue,kt=we,Ke=Ye,Ye=ke;else break t}yn(kt),yn(Rt),yn(fr),E=1;break e}else E=v;while(!1);yn(fr),yn(S),yn(E),E=0}while(!1);return fr=E,Re=Kn,fr|0}}return yn(fr),fr=E,Re=Kn,fr|0}function fi(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0;if(v=Re,Re=Re+16|0,D=v,A=qr(A,w,((w|0)<0)<<31>>31,D)|0,A|0)return D=A,Re=v,D|0;if(P=Zc(D,S)|0,S=D+4|0,(m[D>>2]|0)>0){w=0;do{if(E=m[S>>2]|0,N=E+(w<<4)+4|0,yn(m[N>>2]|0),m[N>>2]=0,m[E+(w<<4)>>2]=0,N=E+(w<<4)+8|0,E=E+(w<<4)+12|0,(m[N>>2]|0)>0){A=0;do T=m[E>>2]|0,j=T+(A<<3)+4|0,yn(m[j>>2]|0),m[j>>2]=0,m[T+(A<<3)>>2]=0,A=A+1|0;while((A|0)<(m[N>>2]|0))}yn(m[E>>2]|0),m[E>>2]=0,m[N>>2]=0,w=w+1|0}while((w|0)<(m[D>>2]|0))}return yn(m[S>>2]|0),m[S>>2]=0,m[D>>2]=0,j=P,Re=v,j|0}function Ji(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0;if(D=m[A>>2]|0,(D|0)<=0)return E=0,N=0,D=E<0,N=12.566370614359172-N,N=E+N,E=D?N:E,Ie[w>>3]=E,0;if(P=m[A+4>>2]|0,A=(D|0)!=1&1,v=+Ie[P>>3]*.5+.7853981633974483,E=+Ie[P+(A<<4)>>3]*.5+.7853981633974483,S=+lr(+v)*+lr(+E),N=+Ie[P+(A<<4)+8>>3]-+Ie[P+8>>3],S=+Pi(+(+lr(+N)*S),+(+Hn(+v)*+Hn(+E)+ +Hn(+N)*S))*-2,N=S+0,S=N-S,(D|0)==1)return v=N,E=S,D=v<0,E=12.566370614359172-E,E=v+E,v=D?E:v,Ie[w>>3]=v,0;for(A=1,E=N;q=A,A=A+1|0,Z=(A|0)%(D|0)|0,j=+Ie[P+(q<<4)>>3]*.5+.7853981633974483,T=+Ie[P+(Z<<4)>>3]*.5+.7853981633974483,N=+lr(+j)*+lr(+T),v=+Ie[P+(Z<<4)+8>>3]-+Ie[P+(q<<4)+8>>3],S=+Pi(+(+lr(+v)*N),+(+Hn(+j)*+Hn(+T)+ +Hn(+v)*N))*-2-S,N=E+S,S=N-E-S,!((A|0)>=(D|0));)E=N;return Z=N<0,j=12.566370614359172-S,j=N+j,j=Z?j:N,Ie[w>>3]=j,0}function Sa(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;return D=Re,Re=Re+192|0,N=D+176|0,E=D,P=D+168|0,A=Ul(A,w,E)|0,A|0?(P=A,Re=D,P|0):(m[P>>2]=m[E>>2],m[P+4>>2]=E+8,m[N>>2]=m[P>>2],m[N+4>>2]=m[P+4>>2],Ji(N,S)|0,P=0,Re=D,P|0)}function Fa(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;return D=Re,Re=Re+192|0,N=D+176|0,E=D,P=D+168|0,A=Ul(A,w,E)|0,A?(P=A,Re=D,P|0):(m[P>>2]=m[E>>2],m[P+4>>2]=E+8,m[N>>2]=m[P>>2],m[N+4>>2]=m[P+4>>2],Ji(N,S)|0,Ie[S>>3]=+Ie[S>>3]*4058973249931477e-8,P=0,Re=D,P|0)}function Wo(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;return D=Re,Re=Re+192|0,N=D+176|0,E=D,P=D+168|0,A=Ul(A,w,E)|0,A?(P=A,Re=D,P|0):(m[P>>2]=m[E>>2],m[P+4>>2]=E+8,m[N>>2]=m[P>>2],m[N+4>>2]=m[P+4>>2],Ji(N,S)|0,Ie[S>>3]=+Ie[S>>3]*4058973249931477e-8*1e6,P=0,Re=D,P|0)}function nr(A){return A=A|0,A>>>0>121?(A=0,A|0):(A=m[7696+(A*28|0)+16>>2]|0,A|0)}function Hc(A){return A=A|0,(A|0)==4|(A|0)==117|0}function Xo(A){return A=A|0,m[11120+((m[A>>2]|0)*216|0)+((m[A+4>>2]|0)*72|0)+((m[A+8>>2]|0)*24|0)+(m[A+12>>2]<<3)>>2]|0}function Dn(A){return A=A|0,m[11120+((m[A>>2]|0)*216|0)+((m[A+4>>2]|0)*72|0)+((m[A+8>>2]|0)*24|0)+(m[A+12>>2]<<3)+4>>2]|0}function Yo(A,w){A=A|0,w=w|0,A=7696+(A*28|0)|0,m[w>>2]=m[A>>2],m[w+4>>2]=m[A+4>>2],m[w+8>>2]=m[A+8>>2],m[w+12>>2]=m[A+12>>2]}function es(A,w){A=A|0,w=w|0;var S=0,N=0;if(w>>>0>20)return w=-1,w|0;do if((m[11120+(w*216|0)>>2]|0)!=(A|0))if((m[11120+(w*216|0)+8>>2]|0)!=(A|0))if((m[11120+(w*216|0)+16>>2]|0)!=(A|0))if((m[11120+(w*216|0)+24>>2]|0)!=(A|0))if((m[11120+(w*216|0)+32>>2]|0)!=(A|0))if((m[11120+(w*216|0)+40>>2]|0)!=(A|0))if((m[11120+(w*216|0)+48>>2]|0)!=(A|0))if((m[11120+(w*216|0)+56>>2]|0)!=(A|0))if((m[11120+(w*216|0)+64>>2]|0)!=(A|0))if((m[11120+(w*216|0)+72>>2]|0)!=(A|0))if((m[11120+(w*216|0)+80>>2]|0)!=(A|0))if((m[11120+(w*216|0)+88>>2]|0)!=(A|0))if((m[11120+(w*216|0)+96>>2]|0)!=(A|0))if((m[11120+(w*216|0)+104>>2]|0)!=(A|0))if((m[11120+(w*216|0)+112>>2]|0)!=(A|0))if((m[11120+(w*216|0)+120>>2]|0)!=(A|0))if((m[11120+(w*216|0)+128>>2]|0)!=(A|0))if((m[11120+(w*216|0)+136>>2]|0)==(A|0))A=2,S=1,N=2;else{if((m[11120+(w*216|0)+144>>2]|0)==(A|0)){A=0,S=2,N=0;break}if((m[11120+(w*216|0)+152>>2]|0)==(A|0)){A=0,S=2,N=1;break}if((m[11120+(w*216|0)+160>>2]|0)==(A|0)){A=0,S=2,N=2;break}if((m[11120+(w*216|0)+168>>2]|0)==(A|0)){A=1,S=2,N=0;break}if((m[11120+(w*216|0)+176>>2]|0)==(A|0)){A=1,S=2,N=1;break}if((m[11120+(w*216|0)+184>>2]|0)==(A|0)){A=1,S=2,N=2;break}if((m[11120+(w*216|0)+192>>2]|0)==(A|0)){A=2,S=2,N=0;break}if((m[11120+(w*216|0)+200>>2]|0)==(A|0)){A=2,S=2,N=1;break}if((m[11120+(w*216|0)+208>>2]|0)==(A|0)){A=2,S=2,N=2;break}else A=-1;return A|0}else A=2,S=1,N=1;else A=2,S=1,N=0;else A=1,S=1,N=2;else A=1,S=1,N=1;else A=1,S=1,N=0;else A=0,S=1,N=2;else A=0,S=1,N=1;else A=0,S=1,N=0;else A=2,S=0,N=2;else A=2,S=0,N=1;else A=2,S=0,N=0;else A=1,S=0,N=2;else A=1,S=0,N=1;else A=1,S=0,N=0;else A=0,S=0,N=2;else A=0,S=0,N=1;else A=0,S=0,N=0;while(!1);return w=m[11120+(w*216|0)+(S*72|0)+(A*24|0)+(N<<3)+4>>2]|0,w|0}function Es(A,w){return A=A|0,w=w|0,(m[7696+(A*28|0)+20>>2]|0)==(w|0)?(w=1,w|0):(w=(m[7696+(A*28|0)+24>>2]|0)==(w|0),w|0)}function Jl(A,w){return A=A|0,w=w|0,m[848+(A*28|0)+(w<<2)>>2]|0}function Su(A,w){return A=A|0,w=w|0,(m[848+(A*28|0)>>2]|0)==(w|0)?(w=0,w|0):(m[848+(A*28|0)+4>>2]|0)==(w|0)?(w=1,w|0):(m[848+(A*28|0)+8>>2]|0)==(w|0)?(w=2,w|0):(m[848+(A*28|0)+12>>2]|0)==(w|0)?(w=3,w|0):(m[848+(A*28|0)+16>>2]|0)==(w|0)?(w=4,w|0):(m[848+(A*28|0)+20>>2]|0)==(w|0)?(w=5,w|0):((m[848+(A*28|0)+24>>2]|0)==(w|0)?6:7)|0}function Gs(){return 122}function Ya(A){A=A|0;var w=0,S=0,N=0;w=0;do xn(w|0,0,45)|0,N=_e()|0|134225919,S=A+(w<<3)|0,m[S>>2]=-1,m[S+4>>2]=N,w=w+1|0;while((w|0)!=122);return 0}function $c(A){A=A|0;var w=0,S=0,N=0;return N=+Ie[A+16>>3],S=+Ie[A+24>>3],w=N-S,+(N>3]<+Ie[A+24>>3]|0}function Fs(A){return A=A|0,+(+Ie[A>>3]-+Ie[A+8>>3])}function xl(A,w){A=A|0,w=w|0;var S=0,N=0,E=0;return S=+Ie[w>>3],!(S>=+Ie[A+8>>3])||!(S<=+Ie[A>>3])?(w=0,w|0):(N=+Ie[A+16>>3],S=+Ie[A+24>>3],E=+Ie[w+8>>3],w=E>=S,A=E<=N&1,N>3]<+Ie[w+8>>3]||+Ie[A+8>>3]>+Ie[w>>3]?(N=0,N|0):(P=+Ie[A+16>>3],S=A+24|0,q=+Ie[S>>3],D=P>3],E=w+24|0,T=+Ie[E>>3],v=j>3],w)||(q=+Ui(+Ie[S>>3],A),q>+Ui(+Ie[N>>3],w))?(v=0,v|0):(v=1,v|0))}function fo(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0;P=+Ie[A+16>>3],T=+Ie[A+24>>3],A=P>3],D=+Ie[w+24>>3],E=v>2]=A?E|w?1:2:0,m[N>>2]=E?A?1:w?2:1:0}function Zo(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;return+Ie[A>>3]<+Ie[w>>3]||+Ie[A+8>>3]>+Ie[w+8>>3]?(N=0,N|0):(N=A+16|0,T=+Ie[N>>3],P=+Ie[A+24>>3],D=T>3],E=w+24|0,j=+Ie[E>>3],v=q>3],w)?(q=+Ui(+Ie[N>>3],A),v=q>=+Ui(+Ie[S>>3],w),v|0):(v=0,v|0))}function Qo(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0;E=Re,Re=Re+176|0,N=E,m[N>>2]=4,v=+Ie[w>>3],Ie[N+8>>3]=v,P=+Ie[w+16>>3],Ie[N+16>>3]=P,Ie[N+24>>3]=v,v=+Ie[w+24>>3],Ie[N+32>>3]=v,D=+Ie[w+8>>3],Ie[N+40>>3]=D,Ie[N+48>>3]=v,Ie[N+56>>3]=D,Ie[N+64>>3]=P,w=N+72|0,S=w+96|0;do m[w>>2]=0,w=w+4|0;while((w|0)<(S|0));ql(A|0,N|0,168)|0,Re=E}function yc(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0;le=Re,Re=Re+288|0,q=le+264|0,Z=le+96|0,j=le,v=j,T=v+96|0;do m[v>>2]=0,v=v+4|0;while((v|0)<(T|0));return w=Ys(w,j)|0,w|0?(ne=w,Re=le,ne|0):(T=j,j=m[T>>2]|0,T=m[T+4>>2]|0,Po(j,T,q)|0,Ul(j,T,Z)|0,D=+ys(q,Z+8|0),Ie[q>>3]=+Ie[A>>3],T=q+8|0,Ie[T>>3]=+Ie[A+16>>3],Ie[Z>>3]=+Ie[A+8>>3],j=Z+8|0,Ie[j>>3]=+Ie[A+24>>3],E=+ys(q,Z),Ee=+Ie[T>>3]-+Ie[j>>3],P=+Mn(+Ee),xe=+Ie[q>>3]-+Ie[Z>>3],N=+Mn(+xe),!(Ee==0|xe==0)&&(Ee=+fy(+P,+N),Ee=+ra(+(E*E/+Io(+(Ee/+Io(+P,+N)),3)/(D*(D*2.59807621135)*.8))),Ie[An>>3]=Ee,te=~~Ee>>>0,ne=+Mn(Ee)>=1?Ee>0?~~+Jn(+Rn(Ee/4294967296),4294967295)>>>0:~~+ra((Ee-+(~~Ee>>>0))/4294967296)>>>0:0,(m[An+4>>2]&2146435072|0)!=2146435072)?(Z=(te|0)==0&(ne|0)==0,w=S,m[w>>2]=Z?1:te,m[w+4>>2]=Z?0:ne,w=0):w=1,ne=w,Re=le,ne|0)}function bc(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0;j=Re,Re=Re+288|0,D=j+264|0,v=j+96|0,T=j,E=T,P=E+96|0;do m[E>>2]=0,E=E+4|0;while((E|0)<(P|0));return S=Ys(S,T)|0,S|0?(N=S,Re=j,N|0):(S=T,E=m[S>>2]|0,S=m[S+4>>2]|0,Po(E,S,D)|0,Ul(E,S,v)|0,q=+ys(D,v+8|0),q=+ra(+(+ys(A,w)/(q*2))),Ie[An>>3]=q,S=~~q>>>0,E=+Mn(q)>=1?q>0?~~+Jn(+Rn(q/4294967296),4294967295)>>>0:~~+ra((q-+(~~q>>>0))/4294967296)>>>0:0,(m[An+4>>2]&2146435072|0)==2146435072?(N=1,Re=j,N|0):(T=(S|0)==0&(E|0)==0,m[N>>2]=T?1:S,m[N+4>>2]=T?0:E,N=0,Re=j,N|0))}function Qa(A,w){A=A|0,w=+w;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;P=A+16|0,D=+Ie[P>>3],S=A+24|0,E=+Ie[S>>3],N=D-E,N=D>3],v=A+8|0,T=+Ie[v>>3],q=j-T,N=(N*w-N)*.5,w=(q*w-q)*.5,j=j+w,Ie[A>>3]=j>1.5707963267948966?1.5707963267948966:j,w=T-w,Ie[v>>3]=w<-1.5707963267948966?-1.5707963267948966:w,w=D+N,w=w>3.141592653589793?w+-6.283185307179586:w,Ie[P>>3]=w<-3.141592653589793?w+6.283185307179586:w,w=E-N,w=w>3.141592653589793?w+-6.283185307179586:w,Ie[S>>3]=w<-3.141592653589793?w+6.283185307179586:w}function qr(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0,kt=0,Rt=0,Wt=0,Kt=0,tn=0;if(tn=Re,Re=Re+224|0,kt=tn,Je=tn+48|0,T=(S|0)>0|(S|0)==0&w>>>0>0,T&(S>>>0>0|(S|0)==0&w>>>0>17895697))return Kt=14,Re=tn,Kt|0;if((S|0)<0)return Kt=2,Re=tn,Kt|0;if((w|0)==0&(S|0)==0)return m[N>>2]=0,m[N+4>>2]=0,Kt=0,Re=tn,Kt|0;for(E=A,E=Gr(m[E>>2]|0,m[E+4>>2]|0)|0,D=0,v=0;;){if(P=A+(D<<3)|0,Kt=P,!(Fi(m[Kt>>2]|0,m[Kt+4>>2]|0)|0)){E=5,Rt=159;break}if(Kt=P,Kt=(Gr(m[Kt>>2]|0,m[Kt+4>>2]|0)|0)==(E|0),D=Pn(D|0,v|0,1,0)|0,v=_e()|0,!Kt){E=12,Rt=159;break}if(!((v|0)<(S|0)|(v|0)==(S|0)&D>>>0>>0)){Rt=8;break}}if((Rt|0)==8){do if((S|0)>0|(S|0)==0&w>>>0>1){if(E=w<<3,D=gi(E)|0,!D)return Kt=13,Re=tn,Kt|0;for(ql(D|0,A|0,E|0)|0,Me(D,w,8,1),E=1,P=0;Wt=D+(E<<3)|0,Kt=D+(E+-1<<3)|0,Kt=(m[Wt>>2]|0)==(m[Kt>>2]|0)?(m[Wt+4>>2]|0)==(m[Kt+4>>2]|0):0,E=Pn(E|0,P|0,1,0)|0,P=_e()|0,!Kt;)if(!((P|0)<(S|0)|(P|0)==(S|0)&E>>>0>>0)){Rt=14;break}if((Rt|0)==14){yn(D);break}return yn(D),Kt=10,Re=tn,Kt|0}while(!1);if(E=si(w|0,S|0,6,0)|0,P=_e()|0,T){D=0,v=0;do Kt=A+(v<<3)|0,Kt=((Hr(m[Kt>>2]|0,m[Kt+4>>2]|0)|0)!=0)<<31>>31,E=Pn(E|0,P|0,Kt|0,((Kt|0)<0)<<31>>31|0)|0,P=_e()|0,v=Pn(v|0,D|0,1,0)|0,D=_e()|0;while((D|0)<(S|0)|(D|0)==(S|0)&v>>>0>>0);je=E,ke=P}else je=E,ke=P;if(Ue=si(je|0,ke|0,10,0)|0,we=_e()|0,Wt=gi(je<<5)|0,!Wt)return Kt=13,Re=tn,Kt|0;if(Kt=bs(Ue,4)|0,!Kt)return yn(Wt),Kt=13,Re=tn,Kt|0;e:do if(T){for(Ke=A,Ws(m[Ke>>2]|0,m[Ke+4>>2]|0,kt)|0,ne=Wt,le=0,xe=0,E=0,Ee=0;;){T=kt,T=(m[T>>2]|0)==0&(m[T+4>>2]|0)==0,P=T?26990:26995,D=T?5:6,v=0,T=kt+((T&1)<<3)|0,j=Pn(D|0,v|0,-1,-1)|0,q=_e()|0,Z=0,te=0;do Ye=T+(Z<<3)|0,xt=m[Ye+4>>2]|0,Ke=ne+(Z<<5)|0,m[Ke>>2]=m[Ye>>2],m[Ke+4>>2]=xt,Nt[ne+(Z<<5)+9>>0]=0,Nt[ne+(Z<<5)+8>>0]=0,m[ne+(Z<<5)+20>>2]=ne,Ke=ne+(Z<<5)+24|0,m[Ke>>2]=1,m[Ke+4>>2]=0,Ke=Nt[P+Z>>0]|0,xt=Pn(j|0,q|0,Z|0,te|0)|0,xt=Mc(xt|0,_e()|0,D|0,v|0)|0,_e()|0,xt=Nt[P+xt>>0]|0,Z=Pn(Z|0,te|0,1,0)|0,te=_e()|0,Ye=Nt[P+((Z|0)==(D|0)&(te|0)==(v|0)?0:Z)>>0]|0,Ke=Ke&255,m[ne+(Ke<<5)+16>>2]=ne+((xt&255)<<5),m[ne+(Ke<<5)+12>>2]=ne+((Ye&255)<<5);while(te>>>0>>0|(te|0)==(v|0)&Z>>>0>>0);if(le=Pn(le|0,xe|0,1,0)|0,xe=_e()|0,E=Pn(D|0,v|0,E|0,Ee|0)|0,Ee=_e()|0,!((xe|0)<(S|0)|(xe|0)==(S|0)&le>>>0>>0))break e;Ke=A+(le<<3)|0,Ws(m[Ke>>2]|0,m[Ke+4>>2]|0,kt)|0||(ne=Wt+(E<<5)|0)}Dt(27634,26956,108,26975)}while(!1);if((ke|0)>0|(ke|0)==0&je>>>0>0){v=0,T=0;do{if(P=Wt+(v<<5)|0,D=m[P>>2]|0,P=m[P+4>>2]|0,E=pn(D|0,P|0,30)|0,P=si(E^D|0,(_e()|0)^P|0,484763065,-1084733587)|0,D=_e()|0,E=pn(P|0,D|0,27)|0,D=si(E^P|0,(_e()|0)^D|0,321982955,-1798288965)|0,P=_e()|0,E=pn(D|0,P|0,31)|0,P=Mc(E^D|0,(_e()|0)^P|0,Ue|0,we|0)|0,D=_e()|0,E=Kt+(P<<2)|0,m[E>>2]|0)do E=Pn(P|0,D|0,1,0)|0,P=Kc(E|0,_e()|0,Ue|0,we|0)|0,D=_e()|0,E=Kt+(P<<2)|0;while(m[E>>2]|0);m[E>>2]=Wt+(v<<5),v=Pn(v|0,T|0,1,0)|0,T=_e()|0}while((T|0)<(ke|0)|(T|0)==(ke|0)&v>>>0>>0);Z=0,te=0;do{if(v=Wt+(Z<<5)|0,T=Wt+(Z<<5)+9|0,!(Nt[T>>0]|0)){if(Ke=v,ce(m[Ke>>2]|0,m[Ke+4>>2]|0,kt)|0){Rt=39;break}q=kt,j=m[q>>2]|0,q=m[q+4>>2]|0,P=pn(j|0,q|0,30)|0,P=si(P^j|0,(_e()|0)^q|0,484763065,-1084733587)|0,D=_e()|0,E=pn(P|0,D|0,27)|0,D=si(E^P|0,(_e()|0)^D|0,321982955,-1798288965)|0,P=_e()|0,E=pn(D|0,P|0,31)|0,P=Mc(E^D|0,(_e()|0)^P|0,Ue|0,we|0)|0,D=_e()|0,E=m[Kt+(P<<2)>>2]|0;e:do if(E|0){for(;Ke=E,!((m[Ke>>2]|0)==(j|0)&&(m[Ke+4>>2]|0)==(q|0));)if(E=Pn(P|0,D|0,1,0)|0,P=Kc(E|0,_e()|0,Ue|0,we|0)|0,D=_e()|0,E=m[Kt+(P<<2)>>2]|0,!E)break e;Nt[T>>0]=1,Nt[E+9>>0]=1,P=E+16|0,Ke=Wt+(Z<<5)+12|0,m[(m[Ke>>2]|0)+16>>2]=m[P>>2],S=E+12|0,Ye=m[Wt+(Z<<5)+16>>2]|0,m[Ye+12>>2]=m[S>>2],m[(m[S>>2]|0)+16>>2]=Ye,m[(m[P>>2]|0)+12>>2]=m[Ke>>2],P=$s(v)|0,Ke=$s(E)|0,E=P+24|0,S=m[E+4>>2]|0,Ye=Ke+24|0,xt=m[Ye+4>>2]|0,Ye=(S|0)<(xt|0)|((S|0)==(xt|0)?(m[E>>2]|0)>>>0<(m[Ye>>2]|0)>>>0:0),E=Ye?P:Ke,P=Ye?Ke:P,(P|0)!=(E|0)&&(xt=E+24|0,Ke=P+24|0,Ye=Ke,xt=Pn(m[Ye>>2]|0,m[Ye+4>>2]|0,m[xt>>2]|0,m[xt+4>>2]|0)|0,Ye=_e()|0,m[Ke>>2]=xt,m[Ke+4>>2]=Ye,m[E+20>>2]=P)}while(!1)}Z=Pn(Z|0,te|0,1,0)|0,te=_e()|0}while((te|0)<(ke|0)|(te|0)==(ke|0)&Z>>>0>>0);(Rt|0)==39&&Dt(27634,26956,258,27001),E=0,P=0;do Nt[Wt+(E<<5)+8>>0]=0,E=Pn(E|0,P|0,1,0)|0,P=_e()|0;while((P|0)<(ke|0)|(P|0)==(ke|0)&E>>>0>>0);for(j=0,D=0,T=0,q=0;;){if(E=Wt+(j<<5)|0,!(Nt[Wt+(j<<5)+8>>0]|0)&&!(Nt[Wt+(j<<5)+9>>0]|0)){v=E,P=m[v>>2]|0,v=m[v+4>>2]|0;do Nt[E+8>>0]=1,E=m[E+12>>2]|0,Ke=E;while(!((m[Ke>>2]|0)==(P|0)&&(m[Ke+4>>2]|0)==(v|0)));D=Pn(D|0,T|0,1,0)|0,v=_e()|0}else v=T;if(j=Pn(j|0,q|0,1,0)|0,q=_e()|0,(q|0)<(ke|0)|(q|0)==(ke|0)&j>>>0>>0)T=v;else break}E=0,P=0;do Nt[Wt+(E<<5)+8>>0]=0,E=Pn(E|0,P|0,1,0)|0,P=_e()|0;while((P|0)<(ke|0)|(P|0)==(ke|0)&E>>>0>>0);Ye=D,xt=v,E=1}else Ye=0,xt=0,E=0;Ke=gi(Ye*24|0)|0;e:do if(Ke|0){t:do if(E){A=0,Ue=0,S=0,w=0;n:for(;;){if(E=Wt+(A<<5)|0,!(Nt[Wt+(A<<5)+8>>0]|0)&&!(Nt[Wt+(A<<5)+9>>0]|0)){Ee=E,xe=m[Ee>>2]|0,Ee=m[Ee+4>>2]|0,P=0,D=0;do P=Pn(P|0,D|0,2,0)|0,D=_e()|0,E=m[E+12>>2]|0,we=E;while(!((m[we>>2]|0)==(xe|0)&&(m[we+4>>2]|0)==(Ee|0)));if(le=gi(P<<4)|0,!le)break;P=xe,D=Ee,ne=0,te=0,v=0,T=0;do{if(vs(P,D,Je)|0){Rt=69;break n}if(we=m[Je>>2]|0,q=we+-1|0,Z=((q|0)<0)<<31>>31,(we|0)>1){D=v,j=0,P=T,v=0;do we=le+(D<<4)|0,T=Je+8+(j<<4)|0,m[we>>2]=m[T>>2],m[we+4>>2]=m[T+4>>2],m[we+8>>2]=m[T+8>>2],m[we+12>>2]=m[T+12>>2],D=Pn(D|0,P|0,1,0)|0,P=_e()|0,j=Pn(j|0,v|0,1,0)|0,v=_e()|0;while((v|0)<(Z|0)|(v|0)==(Z|0)&j>>>0>>0);v=D,T=P}ne=Pn(ne|0,te|0,q|0,Z|0)|0,te=_e()|0,Nt[E+8>>0]=1,E=m[E+12>>2]|0,D=E,P=m[D>>2]|0,D=m[D+4>>2]|0}while(!((P|0)==(xe|0)&(D|0)==(Ee|0)));if(P=Vl(le,ne<<4)|0,!P){Rt=75;break}Ee=$s(E)|0,we=m[Ee+4>>2]|0,E=Ke+(S*24|0)|0,m[E>>2]=m[Ee>>2],m[E+4>>2]=we,E=Ke+(S*24|0)+16|0,m[E>>2]=ne,m[Ke+(S*24|0)+20>>2]=P,m[kt>>2]=m[E>>2],m[kt+4>>2]=m[E+4>>2],Ji(kt,Ke+(S*24|0)+8|0)|0,P=Pn(S|0,Ue|0,1,0)|0,E=_e()|0}else P=S,E=Ue;if(A=Pn(A|0,w|0,1,0)|0,w=_e()|0,(w|0)<(ke|0)|(w|0)==(ke|0)&A>>>0>>0)Ue=E,S=P;else break t}if((Rt|0)==69?Dt(27634,26956,351,27016):(Rt|0)==75&&yn(le),(Ue|0)>0|(Ue|0)==0&S>>>0>0)for(v=0,T=0,E=S,D=Ue;P=m[Ke+(v*24|0)+20>>2]|0,P?(yn(P),P=Ue,E=S):P=D,v=Pn(v|0,T|0,1,0)|0,T=_e()|0,(T|0)<(P|0)|(T|0)==(P|0)&v>>>0>>0;)D=P;yn(Ke);break e}while(!1);Me(Ke,Ye,24,2);t:do if((Ye|0)==0&(xt|0)==0){if(we=gi(192)|0,we|0){if(m[we+16>>2]=0,m[we+20>>2]=0,te=we+8|0,m[te>>2]=3,E=gi(48)|0,ne=we+12|0,m[ne>>2]=E,E|0){m[E>>2]=m[3860],m[E+4>>2]=m[3861],m[E+8>>2]=m[3862],m[E+12>>2]=m[3863],Z=E+16|0,m[Z>>2]=m[3864],m[Z+4>>2]=m[3865],m[Z+8>>2]=m[3866],m[Z+12>>2]=m[3867],Z=E+32|0,m[Z>>2]=m[3868],m[Z+4>>2]=m[3869],m[Z+8>>2]=m[3870],m[Z+12>>2]=m[3871],m[kt>>2]=m[te>>2],m[kt+4>>2]=m[te+4>>2],Ji(kt,we)|0,m[we+40>>2]=0,m[we+44>>2]=0,Z=we+32|0,m[Z>>2]=3,E=gi(48)|0,le=we+36|0,m[le>>2]=E;do if(!E)v=0,T=1;else{if(m[E>>2]=m[3872],m[E+4>>2]=m[3873],m[E+8>>2]=m[3874],m[E+12>>2]=m[3875],q=E+16|0,m[q>>2]=m[3876],m[q+4>>2]=m[3877],m[q+8>>2]=m[3878],m[q+12>>2]=m[3879],q=E+32|0,m[q>>2]=m[3880],m[q+4>>2]=m[3881],m[q+8>>2]=m[3882],m[q+12>>2]=m[3883],m[kt>>2]=m[Z>>2],m[kt+4>>2]=m[Z+4>>2],Ji(kt,we+24|0)|0,m[we+64>>2]=0,m[we+68>>2]=0,q=we+56|0,m[q>>2]=3,E=gi(48)|0,xe=we+60|0,m[xe>>2]=E,!E){v=0,T=2;break}if(m[E>>2]=m[3884],m[E+4>>2]=m[3885],m[E+8>>2]=m[3886],m[E+12>>2]=m[3887],j=E+16|0,m[j>>2]=m[3888],m[j+4>>2]=m[3889],m[j+8>>2]=m[3890],m[j+12>>2]=m[3891],j=E+32|0,m[j>>2]=m[3892],m[j+4>>2]=m[3893],m[j+8>>2]=m[3894],m[j+12>>2]=m[3895],m[kt>>2]=m[q>>2],m[kt+4>>2]=m[q+4>>2],Ji(kt,we+48|0)|0,m[we+88>>2]=0,m[we+92>>2]=0,j=we+80|0,m[j>>2]=3,E=gi(48)|0,Ee=we+84|0,m[Ee>>2]=E,!E){v=0,T=3;break}if(m[E>>2]=m[3896],m[E+4>>2]=m[3897],m[E+8>>2]=m[3898],m[E+12>>2]=m[3899],T=E+16|0,m[T>>2]=m[3900],m[T+4>>2]=m[3901],m[T+8>>2]=m[3902],m[T+12>>2]=m[3903],T=E+32|0,m[T>>2]=m[3904],m[T+4>>2]=m[3905],m[T+8>>2]=m[3906],m[T+12>>2]=m[3907],m[kt>>2]=m[j>>2],m[kt+4>>2]=m[j+4>>2],Ji(kt,we+72|0)|0,m[we+112>>2]=0,m[we+116>>2]=0,T=we+104|0,m[T>>2]=3,E=gi(48)|0,A=we+108|0,m[A>>2]=E,!E){v=0,T=4;break}if(m[E>>2]=m[3908],m[E+4>>2]=m[3909],m[E+8>>2]=m[3910],m[E+12>>2]=m[3911],v=E+16|0,m[v>>2]=m[3912],m[v+4>>2]=m[3913],m[v+8>>2]=m[3914],m[v+12>>2]=m[3915],v=E+32|0,m[v>>2]=m[3916],m[v+4>>2]=m[3917],m[v+8>>2]=m[3918],m[v+12>>2]=m[3919],m[kt>>2]=m[T>>2],m[kt+4>>2]=m[T+4>>2],Ji(kt,we+96|0)|0,m[we+136>>2]=0,m[we+140>>2]=0,v=we+128|0,m[v>>2]=3,E=gi(48)|0,w=we+132|0,m[w>>2]=E,!E){v=0,T=5;break}if(m[E>>2]=m[3920],m[E+4>>2]=m[3921],m[E+8>>2]=m[3922],m[E+12>>2]=m[3923],D=E+16|0,m[D>>2]=m[3924],m[D+4>>2]=m[3925],m[D+8>>2]=m[3926],m[D+12>>2]=m[3927],D=E+32|0,m[D>>2]=m[3928],m[D+4>>2]=m[3929],m[D+8>>2]=m[3930],m[D+12>>2]=m[3931],m[kt>>2]=m[v>>2],m[kt+4>>2]=m[v+4>>2],Ji(kt,we+120|0)|0,m[we+160>>2]=0,m[we+164>>2]=0,D=we+152|0,m[D>>2]=3,E=gi(48)|0,S=we+156|0,m[S>>2]=E,!E){v=0,T=6;break}if(m[E>>2]=m[3932],m[E+4>>2]=m[3933],m[E+8>>2]=m[3934],m[E+12>>2]=m[3935],P=E+16|0,m[P>>2]=m[3936],m[P+4>>2]=m[3937],m[P+8>>2]=m[3938],m[P+12>>2]=m[3939],P=E+32|0,m[P>>2]=m[3940],m[P+4>>2]=m[3941],m[P+8>>2]=m[3942],m[P+12>>2]=m[3943],m[kt>>2]=m[D>>2],m[kt+4>>2]=m[D+4>>2],Ji(kt,we+144|0)|0,m[we+184>>2]=0,m[we+188>>2]=0,P=we+176|0,m[P>>2]=3,E=gi(48)|0,Ue=we+180|0,m[Ue>>2]=E,!E){v=0,T=7;break}if(m[E>>2]=m[3944],m[E+4>>2]=m[3945],m[E+8>>2]=m[3946],m[E+12>>2]=m[3947],Je=E+16|0,m[Je>>2]=m[3948],m[Je+4>>2]=m[3949],m[Je+8>>2]=m[3950],m[Je+12>>2]=m[3951],E=E+32|0,m[E>>2]=m[3952],m[E+4>>2]=m[3953],m[E+8>>2]=m[3954],m[E+12>>2]=m[3955],m[kt>>2]=m[P>>2],m[kt+4>>2]=m[P+4>>2],Ji(kt,we+168|0)|0,Me(we,8,24,3),E=gi(128)|0,m[N+4>>2]=E,E|0){m[N>>2]=8,m[E>>2]=m[te>>2],m[E+4>>2]=m[te+4>>2],m[E+8>>2]=m[te+8>>2],m[E+12>>2]=m[te+12>>2],Rt=E+16|0,m[Rt>>2]=m[Z>>2],m[Rt+4>>2]=m[Z+4>>2],m[Rt+8>>2]=m[Z+8>>2],m[Rt+12>>2]=m[Z+12>>2],Rt=E+32|0,m[Rt>>2]=m[q>>2],m[Rt+4>>2]=m[q+4>>2],m[Rt+8>>2]=m[q+8>>2],m[Rt+12>>2]=m[q+12>>2],Rt=E+48|0,m[Rt>>2]=m[j>>2],m[Rt+4>>2]=m[j+4>>2],m[Rt+8>>2]=m[j+8>>2],m[Rt+12>>2]=m[j+12>>2],Rt=E+64|0,m[Rt>>2]=m[T>>2],m[Rt+4>>2]=m[T+4>>2],m[Rt+8>>2]=m[T+8>>2],m[Rt+12>>2]=m[T+12>>2],Rt=E+80|0,m[Rt>>2]=m[v>>2],m[Rt+4>>2]=m[v+4>>2],m[Rt+8>>2]=m[v+8>>2],m[Rt+12>>2]=m[v+12>>2],Rt=E+96|0,m[Rt>>2]=m[D>>2],m[Rt+4>>2]=m[D+4>>2],m[Rt+8>>2]=m[D+8>>2],m[Rt+12>>2]=m[D+12>>2],Rt=E+112|0,m[Rt>>2]=m[P>>2],m[Rt+4>>2]=m[P+4>>2],m[Rt+8>>2]=m[P+8>>2],m[Rt+12>>2]=m[P+12>>2],yn(we),Rt=158;break t}E=m[ne>>2]|0,E|0&&yn(E),E=m[le>>2]|0,E|0&&yn(E),E=m[xe>>2]|0,E|0&&yn(E),E=m[Ee>>2]|0,E|0&&yn(E),E=m[A>>2]|0,E|0&&yn(E),E=m[w>>2]|0,E|0&&yn(E),E=m[S>>2]|0,E|0&&yn(E),E=m[Ue>>2]|0,E|0&&yn(E),yn(we);break t}while(!1);E=0,D=0;do P=m[we+(E*24|0)+12>>2]|0,P|0&&yn(P),E=Pn(E|0,D|0,1,0)|0,D=_e()|0;while(D>>>0>>0|(D|0)==(v|0)&E>>>0>>0)}yn(we),Rt=152}}else{if((xt|0)>0|(xt|0)==0&Ye>>>0>0){D=0,v=0,T=0,P=0,E=0,j=0;do Je=Ke+(D*24|0)|0,kt=v,v=m[Je>>2]|0,Rt=T,T=m[Je+4>>2]|0,P=Pn(P|0,E|0,((v|0)!=(kt|0)|(T|0)!=(Rt|0))&1|0,0)|0,E=_e()|0,D=Pn(D|0,j|0,1,0)|0,j=_e()|0;while((j|0)<(xt|0)|(j|0)==(xt|0)&D>>>0>>0);Ee=P,xe=E}else Ee=0,xe=0;if(A=gi(Ee*24|0)|0,A){n:do if((xt|0)>=0){for(te=0,ne=0,P=0,D=0,le=0,v=0;;){if(!((te|0)==(Ye|0)&(ne|0)==(xt|0))&&(kt=Ke+(P*24|0)|0,Rt=Ke+(te*24|0)|0,(m[kt>>2]|0)==(m[Rt>>2]|0)?(m[kt+4>>2]|0)==(m[Rt+4>>2]|0):0))E=le;else{if(q=Ke+(P*24|0)|0,Rt=ds(te|0,ne|0,P|0,D|0)|0,kt=_e()|0,Z=Pn(Rt|0,kt|0,-1,-1)|0,D=_e()|0,(kt|0)>0|(kt|0)==0&Rt>>>0>1){if(E=gi(Z<<3)|0,!E)break;T=0,j=0;do Rt=T,T=Pn(T|0,j|0,1,0)|0,j=_e()|0,Je=q+(T*24|0)+16|0,kt=m[Je+4>>2]|0,Rt=E+(Rt<<3)|0,m[Rt>>2]=m[Je>>2],m[Rt+4>>2]=kt;while((j|0)<(D|0)|(j|0)==(D|0)&T>>>0>>0)}else E=0;kt=Ke+(P*24|0)+16|0,Rt=m[kt+4>>2]|0,D=A+(v*24|0)+8|0,m[D>>2]=m[kt>>2],m[D+4>>2]=Rt,m[A+(v*24|0)+16>>2]=Z,m[A+(v*24|0)+20>>2]=E,Ie[A+(v*24|0)>>3]=+Ie[Ke+(P*24|0)+8>>3],v=Pn(v|0,le|0,1,0)|0,P=te,D=ne,E=_e()|0}if(Rt=te,te=Pn(te|0,ne|0,1,0)|0,kt=ne,ne=_e()|0,(kt|0)<(xt|0)|(kt|0)==(xt|0)&Rt>>>0>>0)le=E;else break n}if((le|0)>0|(le|0)==0&v>>>0>0){E=0,D=0;do P=m[A+(E*24|0)+20>>2]|0,P|0&&yn(P),E=Pn(E|0,D|0,1,0)|0,D=_e()|0;while((D|0)<(le|0)|(D|0)==(le|0)&E>>>0>>0)}yn(A),Rt=152;break t}while(!1);if(Me(A,Ee,24,3),E=gi(Ee<<4)|0,D=N+4|0,m[D>>2]=E,E){m[N>>2]=Ee;do if((xe|0)>0|(xe|0)==0&Ee>>>0>0){if(N=A+8|0,m[E>>2]=m[N>>2],m[E+4>>2]=m[N+4>>2],m[E+8>>2]=m[N+8>>2],m[E+12>>2]=m[N+12>>2],(Ee|0)==1&(xe|0)==0||(N=E+16|0,Rt=A+32|0,m[N>>2]=m[Rt>>2],m[N+4>>2]=m[Rt+4>>2],m[N+8>>2]=m[Rt+8>>2],m[N+12>>2]=m[Rt+12>>2],!((xe|0)>0|(xe|0)==0&Ee>>>0>2)))break;E=2,P=0;do N=(m[D>>2]|0)+(E<<4)|0,Rt=A+(E*24|0)+8|0,m[N>>2]=m[Rt>>2],m[N+4>>2]=m[Rt+4>>2],m[N+8>>2]=m[Rt+8>>2],m[N+12>>2]=m[Rt+12>>2],E=Pn(E|0,P|0,1,0)|0,P=_e()|0;while((P|0)<(xe|0)|(P|0)==(xe|0)&E>>>0>>0)}while(!1);yn(A),Rt=158;break}else{if((xe|0)>0|(xe|0)==0&Ee>>>0>0){E=0,D=0;do P=m[A+(E*24|0)+20>>2]|0,P|0&&yn(P),E=Pn(E|0,D|0,1,0)|0,D=_e()|0;while((D|0)<(xe|0)|(D|0)==(xe|0)&E>>>0>>0)}yn(A),Rt=152;break}}else Rt=152}while(!1);if((Rt|0)==158)return yn(Wt),yn(Kt),yn(Ke),Kt=0,Re=tn,Kt|0;if((Rt|0)==152&&(xt|0)>0|(xt|0)==0&Ye>>>0>0)for(v=0,T=0,E=Ye,D=xt;P=m[Ke+(v*24|0)+20>>2]|0,P?(yn(P),P=xt,E=Ye):P=D,v=Pn(v|0,T|0,1,0)|0,T=_e()|0,(T|0)<(P|0)|(T|0)==(P|0)&v>>>0>>0;)D=P;return yn(Ke),yn(Wt),yn(Kt),Kt=13,Re=tn,Kt|0}while(!1);return yn(Wt),yn(Kt),Kt=13,Re=tn,Kt|0}else if((Rt|0)==159)return Re=tn,E|0;return 0}function Wc(A,w){A=A|0,w=w|0;var S=0,N=0;return N=A,A=m[N>>2]|0,N=m[N+4>>2]|0,S=w,w=m[S>>2]|0,S=m[S+4>>2]|0,(N>>>0>>0|(N|0)==(S|0)&A>>>0>>0?-1:(N>>>0>S>>>0|(N|0)==(S|0)&A>>>0>w>>>0)&1)|0}function $s(A){A=A|0;var w=0,S=0;return w=A+20|0,S=m[w>>2]|0,(S|0)==(A|0)?A|0:(S=$s(S)|0,m[w>>2]=S,S|0)}function ca(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0;return v=A,D=m[v>>2]|0,v=m[v+4>>2]|0,P=w,E=m[P>>2]|0,P=m[P+4>>2]|0,v>>>0

>>0|(v|0)==(P|0)&D>>>0>>0?(w=-1,w|0):v>>>0>P>>>0|(v|0)==(P|0)&D>>>0>E>>>0?(w=1,w|0):(N=+Ie[A+8>>3],S=+Ie[w+8>>3],NS&1,w|0))}function ia(A,w){A=A|0,w=w|0;var S=0,N=0;return N=+Ie[A>>3],S=+Ie[w>>3],(N>S?-1:N>2]=0,E=0,Re=Z,E|0;if(D=pn(A|0,w|0,52)|0,_e()|0,D=D&15,j=pn(S|0,N|0,52)|0,_e()|0,(D|0)!=(j&15|0))return E=12,Re=Z,E|0;if(P=D+-1|0,D>>>0>1){Bi(A,w,P,q)|0,Bi(S,N,P,v)|0,j=q,T=m[j>>2]|0,j=m[j+4>>2]|0;e:do if((T|0)==(m[v>>2]|0)&&(j|0)==(m[v+4>>2]|0)){D=(D^15)*3|0,P=pn(A|0,w|0,D|0)|0,_e()|0,P=P&7,D=pn(S|0,N|0,D|0)|0,_e()|0,D=D&7;do if((P|0)==0|(D|0)==0)m[E>>2]=1,P=0;else if((P|0)==7)P=5;else{if((P|0)==1|(D|0)==1&&Hr(T,j)|0){P=5;break}if((m[15824+(P<<2)>>2]|0)!=(D|0)&&(m[15856+(P<<2)>>2]|0)!=(D|0))break e;m[E>>2]=1,P=0}while(!1);return E=P,Re=Z,E|0}while(!1)}P=q,D=P+56|0;do m[P>>2]=0,P=P+4|0;while((P|0)<(D|0));return Kr(A,w,1,q)|0,w=q,!((m[w>>2]|0)==(S|0)&&(m[w+4>>2]|0)==(N|0))&&(w=q+8|0,!((m[w>>2]|0)==(S|0)&&(m[w+4>>2]|0)==(N|0)))&&(w=q+16|0,!((m[w>>2]|0)==(S|0)&&(m[w+4>>2]|0)==(N|0)))&&(w=q+24|0,!((m[w>>2]|0)==(S|0)&&(m[w+4>>2]|0)==(N|0)))&&(w=q+32|0,!((m[w>>2]|0)==(S|0)&&(m[w+4>>2]|0)==(N|0)))&&(w=q+40|0,!((m[w>>2]|0)==(S|0)&&(m[w+4>>2]|0)==(N|0)))?(P=q+48|0,P=((m[P>>2]|0)==(S|0)?(m[P+4>>2]|0)==(N|0):0)&1):P=1,m[E>>2]=P,E=0,Re=Z,E|0}function Ta(A,w,S,N,E){return A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,S=js(A,w,S,N)|0,(S|0)==7?(E=11,E|0):(N=xn(S|0,0,56)|0,w=w&-2130706433|(_e()|0)|268435456,m[E>>2]=A|N,m[E+4>>2]=w,E=0,E|0)}function Ko(A,w,S){return A=A|0,w=w|0,S=S|0,!0&(w&2013265920|0)==268435456?(m[S>>2]=A,m[S+4>>2]=w&-2130706433|134217728,S=0,S|0):(S=6,S|0)}function Tu(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0;return E=Re,Re=Re+16|0,N=E,m[N>>2]=0,!0&(w&2013265920|0)==268435456?(P=pn(A|0,w|0,56)|0,_e()|0,N=sr(A,w&-2130706433|134217728,P&7,N,S)|0,Re=E,N|0):(N=6,Re=E,N|0)}function qd(A,w){A=A|0,w=w|0;var S=0;switch(S=pn(A|0,w|0,56)|0,_e()|0,S&7){case 0:case 7:return S=0,S|0}return S=w&-2130706433|134217728,!(!0&(w&2013265920|0)==268435456)||!0&(w&117440512|0)==16777216&(Hr(A,S)|0)!=0?(S=0,S|0):(S=Fi(A,S)|0,S|0)}function Ea(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;return E=Re,Re=Re+16|0,N=E,!0&(w&2013265920|0)==268435456?(P=w&-2130706433|134217728,D=S,m[D>>2]=A,m[D+4>>2]=P,m[N>>2]=0,w=pn(A|0,w|0,56)|0,_e()|0,N=sr(A,P,w&7,N,S+8|0)|0,Re=E,N|0):(N=6,Re=E,N|0)}function Ws(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0;return E=(Hr(A,w)|0)==0,w=w&-2130706433,N=S,m[N>>2]=E?A:0,m[N+4>>2]=E?w|285212672:0,N=S+8|0,m[N>>2]=A,m[N+4>>2]=w|301989888,N=S+16|0,m[N>>2]=A,m[N+4>>2]=w|318767104,N=S+24|0,m[N>>2]=A,m[N+4>>2]=w|335544320,N=S+32|0,m[N>>2]=A,m[N+4>>2]=w|352321536,S=S+40|0,m[S>>2]=A,m[S+4>>2]=w|369098752,0}function vs(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;return D=Re,Re=Re+16|0,E=D,P=w&-2130706433|134217728,!0&(w&2013265920|0)==268435456?(N=pn(A|0,w|0,56)|0,_e()|0,N=h0(A,P,N&7)|0,(N|0)==-1?(m[S>>2]=0,P=6,Re=D,P|0):(po(A,P,E)|0&&Dt(27634,27035,282,27050),w=pn(A|0,w|0,52)|0,_e()|0,w=w&15,Hr(A,P)|0?qt(E,w,N,2,S):ar(E,w,N,2,S),P=0,Re=D,P|0)):(P=6,Re=D,P|0)}function ce(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;return D=Re,Re=Re+16|0,N=D+8|0,E=D,P=w&-2130706433|134217728,!0&(w&2013265920|0)==268435456?(m[N>>2]=0,w=pn(A|0,w|0,56)|0,_e()|0,w=sr(A,P,w&7,N,E)|0,w|0?(S=w,Re=D,S|0):(N=m[E>>2]|0,E=m[E+4>>2]|0,w=js(N,E,A,P)|0,(w|0)==7?(S=11,Re=D,S|0):(A=xn(w|0,0,56)|0,P=E&-2130706433|(_e()|0)|268435456,m[S>>2]=N|A,m[S+4>>2]=P,S=0,Re=D,S|0))):(S=6,Re=D,S|0)}function Oe(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0;m[S>>2]=0,j=+Ie[A>>3],q=+Ie[A+8>>3],T=+Ie[A+16>>3],E=0,P=5,N=5,A=0;do xe=+Ie[15888+(E*24|0)>>3]-j,le=+Ie[15888+(E*24|0)+8>>3]-q,D=+Ie[15888+(E*24|0)+16>>3]-T,D=xe*xe+le*le+D*D,D>2]=E,P=D,A=E,N=D),E=E+1|0;while((E|0)!=20);if(P=+Qr(+(1-P*.5)),P<1e-16)T=0,D=0;else{if(je=+Ie[16368+(A*24|0)>>3],we=+Ie[15888+(A*24|0)>>3],ke=+Ie[15888+(A*24|0)+8>>3],Ue=+Ie[15888+(A*24|0)+16>>3],Je=-(Ue+(we*0+ke*0)),D=we*Je+0,xe=ke*Je+0,Je=Ue*Je+1,Ee=+Cn(+(Je*Je+(D*D+xe*xe))),Ee=Ee>0?1/Ee:0,D=D*Ee,xe=xe*Ee,Ee=Je*Ee,Je=-(j*we+q*ke+T*Ue),le=j+we*Je,N=q+ke*Je,j=T+Ue*Je,q=+Cn(+(j*j+(le*le+N*N))),q=q>0?1/q:0,le=le*q,N=N*q,q=j*q,N=+Ma(je-+Ma(+Pi(+(q*(ke*D-we*xe)+(le*(Ue*xe-ke*Ee)+N*(we*Ee-Ue*D))),+(Ee*q+(D*le+xe*N))))),$r(w)|0?D=+Ma(N+-.3334731722518321):D=N,N=+jr(+P)*2.618033988749896,(w|0)>0){A=0;do N=N*2.6457513110645907,A=A+1|0;while((A|0)!=(w|0))}T=+Hn(+D)*N,D=+lr(+D)*N}w=S+4|0,ne=S+12|0,m[ne>>2]=0,P=+Mn(+D)*1.1547005383792515,N=+Mn(+T)+P*.5,A=~~N,E=~~P,N=N-+(A|0),P=P-+(E|0);do if(N<.5)if(N<.3333333333333333)if(m[w>>2]=A,P<(N+1)*.5){m[S+8>>2]=E;break}else{E=E+1|0,m[S+8>>2]=E;break}else if(Je=1-N,E=(!(P>2]=E,Je<=P&P>2]=A;break}else{m[w>>2]=A;break}else{if(!(N<.6666666666666666))if(A=A+1|0,m[w>>2]=A,P>2]=E;break}else{E=E+1|0,m[S+8>>2]=E;break}if(P<1-N){if(m[S+8>>2]=E,N*2+-1>2]=A;break}}else E=E+1|0,m[S+8>>2]=E;A=A+1|0,m[w>>2]=A}while(!1);do if(T<0)if(E&1){te=(E+1|0)/2|0,te=ds(A|0,((A|0)<0)<<31>>31|0,te|0,((te|0)<0)<<31>>31|0)|0,A=~~(+(A|0)-((+(te>>>0)+4294967296*+(_e()|0))*2+1)),m[w>>2]=A,te=w;break}else{te=(E|0)/2|0,te=ds(A|0,((A|0)<0)<<31>>31|0,te|0,((te|0)<0)<<31>>31|0)|0,A=~~(+(A|0)-(+(te>>>0)+4294967296*+(_e()|0))*2),m[w>>2]=A,te=w;break}else te=w;while(!1);Z=S+8|0,w=0-E|0,D<0?(S=A-((E<<1|1|0)/2|0)|0,m[te>>2]=S,m[Z>>2]=w,E=w):S=A,A=E-S|0,w=0-S|0,(S|0)<0?(m[Z>>2]=A,m[ne>>2]=w,m[te>>2]=0,v=0):(A=E,v=S,w=0),S=v-A|0,E=w-A|0,(A|0)<0?(m[te>>2]=S,m[ne>>2]=E,m[Z>>2]=0,v=S,A=0):E=w,S=v-E|0,w=A-E|0,(E|0)<0?(m[te>>2]=S,m[Z>>2]=w,m[ne>>2]=0,E=0):(w=A,S=v),A=(w|0)<(S|0)?w:S,A=(E|0)<(A|0)?E:A,!((A|0)<=0)&&(m[te>>2]=S-A,m[Z>>2]=w-A,m[ne>>2]=E-A)}function at(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;N=Re,Re=Re+16|0,E=N,D=m[A+12>>2]|0,P=+((m[A+8>>2]|0)-D|0),Ie[E>>3]=+((m[A+4>>2]|0)-D|0)-P*.5,Ie[E+8>>3]=P*.8660254037844386,Et(E,m[A>>2]|0,w,0,S),Re=N}function Et(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0;if(P=+xd(A),P<1e-16){w=15888+(w*24|0)|0,m[E>>2]=m[w>>2],m[E+4>>2]=m[w+4>>2],m[E+8>>2]=m[w+8>>2],m[E+12>>2]=m[w+12>>2],m[E+16>>2]=m[w+16>>2],m[E+20>>2]=m[w+20>>2];return}if(D=+Pi(+ +Ie[A+8>>3],+ +Ie[A>>3]),(S|0)>0){A=0;do P=P*.37796447300922725,A=A+1|0;while((A|0)!=(S|0))}v=P*.3333333333333333,N?(S=($r(S)|0)==0,P=+la(+((S?v:v*.37796447300922725)*.381966011250105))):(P=+la(+(P*.381966011250105)),$r(S)|0&&(D=+Ma(D+.3334731722518321))),Z=+Ma(+Ie[16368+(w*24|0)>>3]-D),v=+Ie[15888+(w*24|0)>>3],q=+Ie[15888+(w*24|0)+8>>3],xe=+Ie[15888+(w*24|0)+16>>3],ne=-(xe+(v*0+q*0)),j=v*ne+0,D=q*ne+0,ne=xe*ne+1,te=+Cn(+(ne*ne+(j*j+D*D))),te=te>0?1/te:0,j=j*te,D=D*te,te=ne*te,ne=+Hn(+Z),Z=+lr(+Z),Ee=+Hn(+P),le=+lr(+P),T=Ee*v+le*(ne*j+Z*(xe*D-q*te)),P=Ee*q+le*(ne*D+Z*(v*te-xe*j)),D=Ee*xe+le*(ne*te+Z*(q*j-v*D)),v=+Cn(+(D*D+(T*T+P*P))),v=v>0?1/v:0,Ie[E>>3]=T*v,Ie[E+8>>3]=P*v,Ie[E+16>>3]=D*v}function qt(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0,kt=0,Rt=0,Wt=0,Kt=0,tn=0,Zn=0,On=0,Rr=0,fr=0,Kn=0,Qn=0,kn=0,pi=0,xr=0,Er=0,_i=0,zi=0,rs=0,Di=0,Vi=0,Wr=0,Bs=0;if(_i=Re,Re=Re+256|0,P=_i+240|0,Zn=_i+224|0,pi=_i,xr=_i+208|0,Er=_i+192|0,On=_i+168|0,Rr=_i+152|0,fr=_i+136|0,Kn=_i+120|0,Qn=_i+104|0,kn=_i+80|0,m[P>>2]=w,m[Zn>>2]=m[A>>2],m[Zn+4>>2]=m[A+4>>2],m[Zn+8>>2]=m[A+8>>2],m[Zn+12>>2]=m[A+12>>2],un(Zn,P,pi),m[E>>2]=0,Zn=N+S+((N|0)==5&1)|0,(Zn|0)<=(S|0)){Re=_i;return}je=m[P>>2]|0,ke=xr+4|0,Ue=xr+8|0,we=xr+12|0,Je=Er+8|0,xt=S+5|0,Ye=16848+(je<<2)|0,Ke=On+8|0,kt=16928+(je<<2)|0,Rt=Rr+8|0,Wt=fr+8|0,Kt=Kn+8|0,tn=Er+8|0,ne=On+8|0,xe=On+16|0,le=kn+8|0,Ee=kn+16|0,te=S,N=0,D=0,v=0,T=0;e:for(;;){Z=pi+(((te|0)%5|0)<<4)|0,m[xr>>2]=m[Z>>2],m[xr+4>>2]=m[Z+4>>2],m[xr+8>>2]=m[Z+8>>2],m[xr+12>>2]=m[Z+12>>2];do;while((gn(xr,je,0,1)|0)==2);if((te|0)>(S|0)&($r(w)|0)!=0){if(Z=m[xr>>2]|0,A=m[ke>>2]|0,j=m[Ue>>2]|0,P=m[we>>2]|0,zi=+(v-T|0),Ie[Er>>3]=+(D-T|0)-zi*.5,Ie[Je>>3]=zi*.8660254037844386,T=m[17008+(Z*80|0)+(N<<2)>>2]|0,q=m[18608+(Z*80|0)+(T*20|0)>>2]|0,v=m[18608+(Z*80|0)+(T*20|0)+16>>2]|0,(v|0)>0){D=0,N=j;do Vi=P+A|0,Wr=(Vi|0)<0,j=N+A-(Wr?Vi:0)|0,Di=(j|0)<0,rs=P+N-(Wr?Vi:0)-(Di?j:0)|0,P=(rs|0)<0,A=(Wr?0:Vi)-(Di?j:0)-(P?rs:0)|0,N=(Di?0:j)-(P?rs:0)|0,rs=P?0:rs,P=(N|0)<(A|0)?N:A,P=(rs|0)<(P|0)?rs:P,j=(P|0)>0,A=A-(j?P:0)|0,N=N-(j?P:0)|0,P=rs-(j?P:0)|0,D=D+1|0;while((D|0)<(v|0))}else N=j;switch(Wr=(m[Ye>>2]|0)*3|0,rs=(cs(Wr,m[18608+(Z*80|0)+(T*20|0)+4>>2]|0)|0)+A|0,j=(cs(Wr,m[18608+(Z*80|0)+(T*20|0)+8>>2]|0)|0)+N|0,Wr=(cs(Wr,m[18608+(Z*80|0)+(T*20|0)+12>>2]|0)|0)+P|0,T=(rs|0)<0,j=j-(T?rs:0)|0,Di=(j|0)<0,Wr=Wr+(T?0-rs|0:0)+(Di?0-j|0:0)|0,Vi=(Wr|0)<0,rs=(T?0:rs)-(Di?j:0)-(Vi?Wr:0)|0,j=(Di?0:j)-(Vi?Wr:0)|0,Wr=Vi?0:Wr,Vi=(j|0)<(rs|0)?j:rs,Vi=(Wr|0)<(Vi|0)?Wr:Vi,Di=(Vi|0)>0,Wr=Wr-(Di?Vi:0)|0,zi=+(j-(Di?Vi:0)-Wr|0),Ie[On>>3]=+(rs-(Di?Vi:0)-Wr|0)-zi*.5,Ie[Ke>>3]=zi*.8660254037844386,zi=+(m[kt>>2]|0),Ie[Rr>>3]=zi*3,Ie[Rt>>3]=0,Bs=zi*-1.5,Ie[fr>>3]=Bs,Ie[Wt>>3]=zi*2.598076211353316,Ie[Kn>>3]=Bs,Ie[Kt>>3]=zi*-2.598076211353316,m[17008+(q*80|0)+(Z<<2)>>2]|0){case 1:{A=fr,N=Rr;break}case 3:{A=Kn,N=fr;break}case 2:{A=Rr,N=Kn;break}default:{A=12;break e}}bf(Er,On,N,A,Qn),Et(Qn,q,je,1,kn),Wr=m[E>>2]|0,zi=+Os(+ +Ie[Ee>>3]),Bs=+Pi(+ +Ie[le>>3],+ +Ie[kn>>3]),Ie[E+8+(Wr<<4)>>3]=zi,Ie[E+8+(Wr<<4)+8>>3]=Bs,m[E>>2]=(m[E>>2]|0)+1}if((te|0)<(xt|0)&&(Wr=m[we>>2]|0,zi=+((m[Ue>>2]|0)-Wr|0),Ie[Er>>3]=+((m[ke>>2]|0)-Wr|0)-zi*.5,Ie[tn>>3]=zi*.8660254037844386,Et(Er,m[xr>>2]|0,je,1,On),Wr=m[E>>2]|0,zi=+Os(+ +Ie[xe>>3]),Bs=+Pi(+ +Ie[ne>>3],+ +Ie[On>>3]),Ie[E+8+(Wr<<4)>>3]=zi,Ie[E+8+(Wr<<4)+8>>3]=Bs,m[E>>2]=(m[E>>2]|0)+1),te=te+1|0,(te|0)>=(Zn|0)){A=3;break}else N=m[xr>>2]|0,D=m[ke>>2]|0,v=m[Ue>>2]|0,T=m[we>>2]|0}if((A|0)==3){Re=_i;return}else(A|0)==12&&Dt(27073,27120,599,27130)}function un(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0;le=Re,Re=Re+128|0,N=le+64|0,E=le,P=N,D=20208,v=P+60|0;do m[P>>2]=m[D>>2],P=P+4|0,D=D+4|0;while((P|0)<(v|0));P=E,D=20272,v=P+60|0;do m[P>>2]=m[D>>2],P=P+4|0,D=D+4|0;while((P|0)<(v|0));if(q=($r(m[w>>2]|0)|0)==0,q=q?N:E,ne=A+4|0,P=m[ne>>2]|0,Z=A+8|0,N=m[Z>>2]|0,te=A+12|0,E=m[te>>2]|0,D=N+(P<<1)|0,m[ne>>2]=D,N=E+(N<<1)|0,m[Z>>2]=N,P=(E<<1)+P|0,m[te>>2]=P,E=N-D|0,v=P-D|0,(D|0)<0&&(m[Z>>2]=E,m[te>>2]=v,m[ne>>2]=0,N=E,D=0,P=v),v=D-N|0,E=P-N|0,(N|0)<0?(m[ne>>2]=v,m[te>>2]=E,m[Z>>2]=0,N=0):(E=P,v=D),D=v-E|0,P=N-E|0,(E|0)<0?(m[ne>>2]=D,m[Z>>2]=P,m[te>>2]=0,E=0):(P=N,D=v),N=(P|0)<(D|0)?P:D,N=(E|0)<(N|0)?E:N,(N|0)>0&&(E=E-N|0,P=P-N|0,D=D-N|0,m[ne>>2]=D,m[Z>>2]=P,m[te>>2]=E),T=(P<<1)+D|0,v=E+(D<<1)|0,m[ne>>2]=v,m[Z>>2]=T,P=(E<<1)+P|0,m[te>>2]=P,N=T-v|0,E=P-v|0,(v|0)<0?(m[Z>>2]=N,m[te>>2]=E,m[ne>>2]=0,v=0,P=E):N=T,D=v-N|0,E=P-N|0,(N|0)<0?(m[ne>>2]=D,m[te>>2]=E,m[Z>>2]=0,v=D,N=0):E=P,D=v-E|0,P=N-E|0,(E|0)<0?(m[ne>>2]=D,m[Z>>2]=P,m[te>>2]=0,E=0):(P=N,D=v),N=(P|0)<(D|0)?P:D,N=(E|0)<(N|0)?E:N,(N|0)>0&&(m[ne>>2]=D-N,m[Z>>2]=P-N,m[te>>2]=E-N),$r(m[w>>2]|0)|0&&(P=m[ne>>2]|0,D=m[Z>>2]|0,E=m[te>>2]|0,N=(D*3|0)+P|0,P=E+(P*3|0)|0,m[ne>>2]=P,m[Z>>2]=N,D=(E*3|0)+D|0,m[te>>2]=D,E=N-P|0,v=D-P|0,(P|0)<0?(m[Z>>2]=E,m[te>>2]=v,m[ne>>2]=0,N=E,T=0):(T=P,v=D),P=T-N|0,E=v-N|0,(N|0)<0?(m[ne>>2]=P,m[te>>2]=E,m[Z>>2]=0,T=P,D=0):(D=N,E=v),P=T-E|0,N=D-E|0,(E|0)<0?(m[ne>>2]=P,m[Z>>2]=N,m[te>>2]=0,D=N,E=0):P=T,N=(D|0)<(P|0)?D:P,N=(E|0)<(N|0)?E:N,(N|0)>0&&(m[ne>>2]=P-N,m[Z>>2]=D-N,m[te>>2]=E-N),m[w>>2]=(m[w>>2]|0)+1),m[S>>2]=m[A>>2],E=m[Z>>2]|0,N=m[te>>2]|0,w=m[q+4>>2]|0,j=m[q+8>>2]|0,D=(m[q>>2]|0)+(m[ne>>2]|0)|0,T=S+4|0,m[T>>2]=D,E=w+E|0,w=S+8|0,m[w>>2]=E,N=j+N|0,j=S+12|0,m[j>>2]=N,P=E-D|0,(D|0)<0&&(N=N-D|0,m[w>>2]=P,m[j>>2]=N,m[T>>2]=0,E=P,D=0),(E|0)<0&&(D=D-E|0,m[T>>2]=D,N=N-E|0,m[j>>2]=N,m[w>>2]=0,E=0),v=D-N|0,P=E-N|0,(N|0)<0?(m[T>>2]=v,m[w>>2]=P,m[j>>2]=0,D=v,N=0):P=E,E=(P|0)<(D|0)?P:D,E=(N|0)<(E|0)?N:E,(E|0)>0&&(m[T>>2]=D-E,m[w>>2]=P-E,m[j>>2]=N-E),m[S+16>>2]=m[A>>2],E=m[Z>>2]|0,N=m[te>>2]|0,w=m[q+16>>2]|0,j=m[q+20>>2]|0,D=(m[q+12>>2]|0)+(m[ne>>2]|0)|0,T=S+20|0,m[T>>2]=D,E=w+E|0,w=S+24|0,m[w>>2]=E,N=j+N|0,j=S+28|0,m[j>>2]=N,P=E-D|0,(D|0)<0&&(N=N-D|0,m[w>>2]=P,m[j>>2]=N,m[T>>2]=0,E=P,D=0),(E|0)<0&&(D=D-E|0,m[T>>2]=D,N=N-E|0,m[j>>2]=N,m[w>>2]=0,E=0),v=D-N|0,P=E-N|0,(N|0)<0?(m[T>>2]=v,m[w>>2]=P,m[j>>2]=0,D=v,N=0):P=E,E=(P|0)<(D|0)?P:D,E=(N|0)<(E|0)?N:E,(E|0)>0&&(m[T>>2]=D-E,m[w>>2]=P-E,m[j>>2]=N-E),m[S+32>>2]=m[A>>2],E=m[Z>>2]|0,N=m[te>>2]|0,w=m[q+28>>2]|0,j=m[q+32>>2]|0,D=(m[q+24>>2]|0)+(m[ne>>2]|0)|0,T=S+36|0,m[T>>2]=D,E=w+E|0,w=S+40|0,m[w>>2]=E,N=j+N|0,j=S+44|0,m[j>>2]=N,P=E-D|0,(D|0)<0&&(N=N-D|0,m[w>>2]=P,m[j>>2]=N,m[T>>2]=0,E=P,D=0),(E|0)<0&&(D=D-E|0,m[T>>2]=D,N=N-E|0,m[j>>2]=N,m[w>>2]=0,E=0),v=D-N|0,P=E-N|0,(N|0)<0?(m[T>>2]=v,m[w>>2]=P,m[j>>2]=0,D=v,N=0):P=E,E=(P|0)<(D|0)?P:D,E=(N|0)<(E|0)?N:E,(E|0)>0&&(m[T>>2]=D-E,m[w>>2]=P-E,m[j>>2]=N-E),m[S+48>>2]=m[A>>2],E=m[Z>>2]|0,N=m[te>>2]|0,w=m[q+40>>2]|0,j=m[q+44>>2]|0,D=(m[q+36>>2]|0)+(m[ne>>2]|0)|0,T=S+52|0,m[T>>2]=D,E=w+E|0,w=S+56|0,m[w>>2]=E,N=j+N|0,j=S+60|0,m[j>>2]=N,P=E-D|0,(D|0)<0&&(N=N-D|0,m[w>>2]=P,m[j>>2]=N,m[T>>2]=0,E=P,D=0),(E|0)<0&&(D=D-E|0,m[T>>2]=D,N=N-E|0,m[j>>2]=N,m[w>>2]=0,E=0),v=D-N|0,P=E-N|0,(N|0)<0?(m[T>>2]=v,m[w>>2]=P,m[j>>2]=0,D=v,N=0):P=E,E=(P|0)<(D|0)?P:D,E=(N|0)<(E|0)?N:E,(E|0)>0&&(m[T>>2]=D-E,m[w>>2]=P-E,m[j>>2]=N-E),m[S+64>>2]=m[A>>2],P=m[Z>>2]|0,N=m[te>>2]|0,j=m[q+52>>2]|0,T=m[q+56>>2]|0,D=(m[q+48>>2]|0)+(m[ne>>2]|0)|0,w=S+68|0,m[w>>2]=D,P=j+P|0,j=S+72|0,m[j>>2]=P,N=T+N|0,T=S+76|0,m[T>>2]=N,E=P-D|0,(D|0)<0?(N=N-D|0,m[j>>2]=E,m[T>>2]=N,m[w>>2]=0,P=0):(E=P,P=D),(E|0)<0&&(P=P-E|0,m[w>>2]=P,N=N-E|0,m[T>>2]=N,m[j>>2]=0,E=0),v=P-N|0,D=E-N|0,(N|0)<0?(m[w>>2]=v,m[j>>2]=D,m[T>>2]=0,P=v,N=0):D=E,E=(D|0)<(P|0)?D:P,E=(N|0)<(E|0)?N:E,(E|0)<=0){Re=le;return}m[w>>2]=P-E,m[j>>2]=D-E,m[T>>2]=N-E,Re=le}function gn(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0;if(te=m[16928+(w<<2)>>2]|0,Z=(N|0)!=0,te=Z?te*3|0:te,q=A+4|0,v=m[q>>2]|0,j=A+8|0,P=m[j>>2]|0,Z){if(D=A+12|0,N=m[D>>2]|0,E=P+v+N|0,(E|0)==(te|0))return te=1,te|0;T=D}else T=A+12|0,E=m[T>>2]|0,N=E,E=P+v+E|0;if((E|0)<=(te|0))return te=0,te|0;do if((N|0)>0){if(E=m[A>>2]|0,(P|0)>0){E=18608+(E*80|0)+60|0,D=v;break}E=18608+(E*80|0)+40|0,S?(D=v-te|0,S=P+D|0,ne=(S|0)<0,P=N+P-(ne?S:0)|0,v=(P|0)<0,N=N+D-(ne?S:0)-(v?P:0)|0,D=(N|0)<0,S=(ne?0:S)-(v?P:0)-(D?N:0)|0,P=(v?0:P)-(D?N:0)|0,N=D?0:N,D=(P|0)<(S|0)?P:S,D=(N|0)<(D|0)?N:D,v=(D|0)>0,P=P-(v?D:0)|0,N=N-(v?D:0)|0,D=S-(v?D:0)+te|0,m[q>>2]=D,m[j>>2]=P,m[T>>2]=N):D=v}else E=18608+((m[A>>2]|0)*80|0)+20|0,D=v;while(!1);if(m[A>>2]=m[E>>2],v=m[E+16>>2]|0,(v|0)>0){S=0;do ne=N+D|0,le=(ne|0)<0,Ue=le?ne:0,xe=P+D-Ue|0,Ee=(xe|0)<0,A=Ee?xe:0,D=N+P-Ue-A|0,P=(D|0)<0,N=P?0:D,D=P?D:0,P=(Ee?0:xe)-D|0,D=(le?0:ne)-A-D|0,A=(P|0)<(D|0)?P:D,A=(N|0)<(A|0)?N:A,(A|0)>0&&(D=D-A|0,P=P-A|0,N=N-A|0),S=S+1|0;while((S|0)<(v|0));m[q>>2]=D,m[j>>2]=P,m[T>>2]=N}return xe=m[16848+(w<<2)>>2]|0,xe=Z?xe*3|0:xe,Ee=cs(xe,m[E+8>>2]|0)|0,Ue=cs(xe,m[E+12>>2]|0)|0,D=(cs(xe,m[E+4>>2]|0)|0)+D|0,m[q>>2]=D,P=Ee+P|0,m[j>>2]=P,N=Ue+N|0,m[T>>2]=N,E=P-D|0,(D|0)<0?(N=N-D|0,m[j>>2]=E,m[T>>2]=N,m[q>>2]=0,P=0):(E=P,P=D),(E|0)<0?(A=P-E|0,m[q>>2]=A,N=N-E|0,m[T>>2]=N,m[j>>2]=0,D=0):(A=P,D=E),P=A-N|0,E=D-N|0,(N|0)<0?(m[q>>2]=P,m[j>>2]=E,m[T>>2]=0,N=0):(E=D,P=A),D=(E|0)<(P|0)?E:P,D=(N|0)<(D|0)?N:D,(D|0)>0&&(P=P-D|0,E=E-D|0,N=N-D|0,m[q>>2]=P,m[j>>2]=E,m[T>>2]=N),Z?(Ue=(E+P+N|0)==(te|0)?1:2,Ue|0):(Ue=2,Ue|0)}function dr(A,w){A=A|0,w=w|0;var S=0;do S=gn(A,w,0,1)|0;while((S|0)==2);return S|0}function ar(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0,kt=0,Rt=0,Wt=0,Kt=0,tn=0,Zn=0,On=0,Rr=0,fr=0,Kn=0,Qn=0,kn=0,pi=0,xr=0,Er=0;if(kn=Re,Re=Re+272|0,P=kn+256|0,D=kn+240|0,fr=kn,Kn=kn+224|0,Qn=kn+208|0,Rt=kn+184|0,Wt=kn+168|0,Kt=kn+152|0,tn=kn+136|0,Zn=kn+120|0,On=kn+96|0,m[P>>2]=w,m[D>>2]=m[A>>2],m[D+4>>2]=m[A+4>>2],m[D+8>>2]=m[A+8>>2],m[D+12>>2]=m[A+12>>2],Dr(D,P,fr),m[E>>2]=0,kt=N+S+((N|0)==6&1)|0,(kt|0)<=(S|0)){Re=kn;return}Ue=m[P>>2]|0,we=S+6|0,ke=Qn+8|0,je=Rt+8|0,Je=16928+(Ue<<2)|0,xt=Wt+8|0,Ye=Kt+8|0,Ke=tn+8|0,xe=m[D>>2]|0,te=Kn+4|0,ne=Kn+8|0,le=Kn+12|0,Ee=Qn+8|0,T=Rt+8|0,q=Rt+16|0,j=On+8|0,Z=On+16|0,D=0,v=S,N=-1;e:for(;;){if(P=(v|0)%6|0,A=fr+(P<<4)|0,m[Kn>>2]=m[A>>2],m[Kn+4>>2]=m[A+4>>2],m[Kn+8>>2]=m[A+8>>2],m[Kn+12>>2]=m[A+12>>2],A=D,D=gn(Kn,Ue,0,1)|0,(v|0)>(S|0)&($r(w)|0)!=0&&(Rr=m[Kn>>2]|0,(A|0)!=1&(Rr|0)!=(N|0))){switch(Er=(P+5|0)%6|0,A=m[fr+(Er<<4)+12>>2]|0,pi=+((m[fr+(Er<<4)+8>>2]|0)-A|0),Ie[Qn>>3]=+((m[fr+(Er<<4)+4>>2]|0)-A|0)-pi*.5,Ie[ke>>3]=pi*.8660254037844386,A=m[fr+(P<<4)+12>>2]|0,pi=+((m[fr+(P<<4)+8>>2]|0)-A|0),Ie[Rt>>3]=+((m[fr+(P<<4)+4>>2]|0)-A|0)-pi*.5,Ie[je>>3]=pi*.8660254037844386,pi=+(m[Je>>2]|0),Ie[Wt>>3]=pi*3,Ie[xt>>3]=0,xr=pi*-1.5,Ie[Kt>>3]=xr,Ie[Ye>>3]=pi*2.598076211353316,Ie[tn>>3]=xr,Ie[Ke>>3]=pi*-2.598076211353316,m[17008+(xe*80|0)+(((N|0)==(xe|0)?Rr:N)<<2)>>2]|0){case 1:{A=Kt,N=Wt;break}case 3:{A=tn,N=Kt;break}case 2:{A=Wt,N=tn;break}default:{A=8;break e}}bf(Qn,Rt,N,A,Zn),!(up(Qn,Zn)|0)&&!(up(Rt,Zn)|0)&&(Et(Zn,xe,Ue,1,On),Er=m[E>>2]|0,pi=+Os(+ +Ie[Z>>3]),xr=+Pi(+ +Ie[j>>3],+ +Ie[On>>3]),Ie[E+8+(Er<<4)>>3]=pi,Ie[E+8+(Er<<4)+8>>3]=xr,m[E>>2]=(m[E>>2]|0)+1)}if((v|0)<(we|0)&&(Er=m[le>>2]|0,pi=+((m[ne>>2]|0)-Er|0),Ie[Qn>>3]=+((m[te>>2]|0)-Er|0)-pi*.5,Ie[Ee>>3]=pi*.8660254037844386,Et(Qn,m[Kn>>2]|0,Ue,1,Rt),Er=m[E>>2]|0,pi=+Os(+ +Ie[q>>3]),xr=+Pi(+ +Ie[T>>3],+ +Ie[Rt>>3]),Ie[E+8+(Er<<4)>>3]=pi,Ie[E+8+(Er<<4)+8>>3]=xr,m[E>>2]=(m[E>>2]|0)+1),v=v+1|0,(v|0)>=(kt|0)){A=3;break}else N=m[Kn>>2]|0}if((A|0)==3){Re=kn;return}else(A|0)==8&&Dt(27157,27120,766,27202)}function Dr(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0;xe=Re,Re=Re+160|0,N=xe+80|0,E=xe,P=N,D=20336,v=P+72|0;do m[P>>2]=m[D>>2],P=P+4|0,D=D+4|0;while((P|0)<(v|0));P=E,D=20416,v=P+72|0;do m[P>>2]=m[D>>2],P=P+4|0,D=D+4|0;while((P|0)<(v|0));Z=($r(m[w>>2]|0)|0)==0,Z=Z?N:E,le=A+4|0,P=m[le>>2]|0,te=A+8|0,N=m[te>>2]|0,ne=A+12|0,E=m[ne>>2]|0,D=N+(P<<1)|0,m[le>>2]=D,N=E+(N<<1)|0,m[te>>2]=N,P=(E<<1)+P|0,m[ne>>2]=P,E=N-D|0,v=P-D|0,(D|0)<0&&(m[te>>2]=E,m[ne>>2]=v,m[le>>2]=0,N=E,D=0,P=v),v=D-N|0,E=P-N|0,(N|0)<0?(m[le>>2]=v,m[ne>>2]=E,m[te>>2]=0,N=0):(E=P,v=D),D=v-E|0,P=N-E|0,(E|0)<0?(m[le>>2]=D,m[te>>2]=P,m[ne>>2]=0,E=0):(P=N,D=v),N=(P|0)<(D|0)?P:D,N=(E|0)<(N|0)?E:N,(N|0)>0&&(E=E-N|0,P=P-N|0,D=D-N|0,m[le>>2]=D,m[te>>2]=P,m[ne>>2]=E),T=(P<<1)+D|0,v=E+(D<<1)|0,m[le>>2]=v,m[te>>2]=T,P=(E<<1)+P|0,m[ne>>2]=P,N=T-v|0,E=P-v|0,(v|0)<0?(m[te>>2]=N,m[ne>>2]=E,m[le>>2]=0,v=0,P=E):N=T,D=v-N|0,E=P-N|0,(N|0)<0?(m[le>>2]=D,m[ne>>2]=E,m[te>>2]=0,v=D,N=0):E=P,D=v-E|0,P=N-E|0,(E|0)<0?(m[le>>2]=D,m[te>>2]=P,m[ne>>2]=0,E=0):(P=N,D=v),N=(P|0)<(D|0)?P:D,N=(E|0)<(N|0)?E:N,(N|0)>0&&(m[le>>2]=D-N,m[te>>2]=P-N,m[ne>>2]=E-N),$r(m[w>>2]|0)|0&&(P=m[le>>2]|0,D=m[te>>2]|0,E=m[ne>>2]|0,N=(D*3|0)+P|0,P=E+(P*3|0)|0,m[le>>2]=P,m[te>>2]=N,D=(E*3|0)+D|0,m[ne>>2]=D,E=N-P|0,v=D-P|0,(P|0)<0?(m[te>>2]=E,m[ne>>2]=v,m[le>>2]=0,N=E,T=0):(T=P,v=D),P=T-N|0,E=v-N|0,(N|0)<0?(m[le>>2]=P,m[ne>>2]=E,m[te>>2]=0,T=P,D=0):(D=N,E=v),P=T-E|0,N=D-E|0,(E|0)<0?(m[le>>2]=P,m[te>>2]=N,m[ne>>2]=0,D=N,E=0):P=T,N=(D|0)<(P|0)?D:P,N=(E|0)<(N|0)?E:N,(N|0)>0&&(m[le>>2]=P-N,m[te>>2]=D-N,m[ne>>2]=E-N),m[w>>2]=(m[w>>2]|0)+1),T=0;do m[S+(T<<4)>>2]=m[A>>2],E=m[te>>2]|0,N=m[ne>>2]|0,j=m[Z+(T*12|0)+4>>2]|0,q=m[Z+(T*12|0)+8>>2]|0,D=(m[Z+(T*12|0)>>2]|0)+(m[le>>2]|0)|0,w=S+(T<<4)+4|0,m[w>>2]=D,E=j+E|0,j=S+(T<<4)+8|0,m[j>>2]=E,N=q+N|0,q=S+(T<<4)+12|0,m[q>>2]=N,P=E-D|0,(D|0)<0&&(N=N-D|0,m[j>>2]=P,m[q>>2]=N,m[w>>2]=0,E=P,D=0),(E|0)<0&&(D=D-E|0,m[w>>2]=D,N=N-E|0,m[q>>2]=N,m[j>>2]=0,E=0),v=D-N|0,P=E-N|0,(N|0)<0?(m[w>>2]=v,m[j>>2]=P,m[q>>2]=0,D=v,N=0):P=E,E=(P|0)<(D|0)?P:D,E=(N|0)<(E|0)?N:E,(E|0)>0&&(m[w>>2]=D-E,m[j>>2]=P-E,m[q>>2]=N-E),T=T+1|0;while((T|0)!=6);Re=xe}function Gr(A,w){return A=A|0,w=w|0,w=pn(A|0,w|0,52)|0,_e()|0,w&15|0}function Ni(A,w){return A=A|0,w=w|0,w=pn(A|0,w|0,45)|0,_e()|0,w&127|0}function sa(A,w,S,N){return A=A|0,w=w|0,S=S|0,N=N|0,(S+-1|0)>>>0>14?(N=4,N|0):(S=pn(A|0,w|0,(15-S|0)*3|0)|0,_e()|0,m[N>>2]=S&7,N=0,N|0)}function us(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0;if(A>>>0>15)return N=4,N|0;if(w>>>0>121)return N=17,N|0;D=xn(A|0,0,52)|0,E=_e()|0,v=xn(w|0,0,45)|0,E=E|(_e()|0)|134225919;e:do if((A|0)>=1){for(v=1,D=(Nt[20496+w>>0]|0)!=0,P=-1;;){if(w=m[S+(v+-1<<2)>>2]|0,w>>>0>6){E=18,w=10;break}if(!((w|0)==0|D^1))if((w|0)==1){E=19,w=10;break}else D=0;if(j=(15-v|0)*3|0,T=xn(7,0,j|0)|0,E=E&~(_e()|0),w=xn(w|0,((w|0)<0)<<31>>31|0,j|0)|0,P=w|P&~T,E=_e()|0|E,(v|0)<(A|0))v=v+1|0;else break e}if((w|0)==10)return E|0}else P=-1;while(!1);return j=N,m[j>>2]=P,m[j+4>>2]=E,j=0,j|0}function Fi(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0;return!(!0&(w&-16777216|0)==134217728)||(N=pn(A|0,w|0,52)|0,_e()|0,N=N&15,S=pn(A|0,w|0,45)|0,_e()|0,S=S&127,S>>>0>121)?(A=0,A|0):(D=(N^15)*3|0,E=pn(A|0,w|0,D|0)|0,D=xn(E|0,_e()|0,D|0)|0,E=_e()|0,P=ds(-1227133514,-1171,D|0,E|0)|0,!((D&613566756&P|0)==0&(E&4681&(_e()|0)|0)==0)||(D=(N*3|0)+19|0,P=xn(~A|0,~w|0,D|0)|0,D=pn(P|0,_e()|0,D|0)|0,!((N|0)==15|(D|0)==0&(_e()|0)==0))?(D=0,D|0):!(Nt[20496+S>>0]|0)||(w=w&8191,(A|0)==0&(w|0)==0)?(D=1,D|0):(D=hp(A|0,w|0)|0,_e()|0,((63-D|0)%3|0|0)!=0|0))}function Ns(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0;return!0&(w&-16777216|0)==134217728&&(N=pn(A|0,w|0,52)|0,_e()|0,N=N&15,S=pn(A|0,w|0,45)|0,_e()|0,S=S&127,S>>>0<=121)&&(D=(N^15)*3|0,E=pn(A|0,w|0,D|0)|0,D=xn(E|0,_e()|0,D|0)|0,E=_e()|0,P=ds(-1227133514,-1171,D|0,E|0)|0,(D&613566756&P|0)==0&(E&4681&(_e()|0)|0)==0)&&(D=(N*3|0)+19|0,P=xn(~A|0,~w|0,D|0)|0,D=pn(P|0,_e()|0,D|0)|0,(N|0)==15|(D|0)==0&(_e()|0)==0)&&(!(Nt[20496+S>>0]|0)||(S=w&8191,(A|0)==0&(S|0)==0)||(D=hp(A|0,S|0)|0,_e()|0,(63-D|0)%3|0|0))||qd(A,w)|0?(D=1,D|0):(D=(X(A,w)|0)!=0&1,D|0)}function ps(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0;if(E=xn(w|0,0,52)|0,P=_e()|0,S=xn(S|0,0,45)|0,S=P|(_e()|0)|134225919,(w|0)<1){P=-1,N=S,w=A,m[w>>2]=P,A=A+4|0,m[A>>2]=N;return}for(P=1,E=-1;D=(15-P|0)*3|0,v=xn(7,0,D|0)|0,S=S&~(_e()|0),D=xn(N|0,0,D|0)|0,E=E&~v|D,S=S|(_e()|0),(P|0)!=(w|0);)P=P+1|0;v=A,D=v,m[D>>2]=E,v=v+4|0,m[v>>2]=S}function Bi(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0;if(P=pn(A|0,w|0,52)|0,_e()|0,P=P&15,S>>>0>15)return N=4,N|0;if((P|0)<(S|0))return N=12,N|0;if((P|0)==(S|0))return m[N>>2]=A,m[N+4>>2]=w,N=0,N|0;if(E=xn(S|0,0,52)|0,E=E|A,A=_e()|0|w&-15728641,(P|0)>(S|0))do w=xn(7,0,(14-S|0)*3|0)|0,S=S+1|0,E=w|E,A=_e()|0|A;while((S|0)<(P|0));return m[N>>2]=E,m[N+4>>2]=A,N=0,N|0}function Xs(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0;if(P=pn(A|0,w|0,52)|0,_e()|0,P=P&15,!((S|0)<16&(P|0)<=(S|0)))return N=4,N|0;E=S-P|0,S=pn(A|0,w|0,45)|0,_e()|0;e:do if(!(nr(S&127)|0))S=Ua(7,0,E,((E|0)<0)<<31>>31)|0,E=_e()|0;else{t:do if(P|0){for(S=1;D=xn(7,0,(15-S|0)*3|0)|0,!!((D&A|0)==0&((_e()|0)&w|0)==0);)if(S>>>0

>>0)S=S+1|0;else break t;S=Ua(7,0,E,((E|0)<0)<<31>>31)|0,E=_e()|0;break e}while(!1);S=Ua(7,0,E,((E|0)<0)<<31>>31)|0,S=si(S|0,_e()|0,5,0)|0,S=Pn(S|0,_e()|0,-5,-1)|0,S=Qc(S|0,_e()|0,6,0)|0,S=Pn(S|0,_e()|0,1,0)|0,E=_e()|0}while(!1);return D=N,m[D>>2]=S,m[D+4>>2]=E,D=0,D|0}function Hr(A,w){A=A|0,w=w|0;var S=0,N=0,E=0;if(E=pn(A|0,w|0,45)|0,_e()|0,!(nr(E&127)|0))return E=0,E|0;E=pn(A|0,w|0,52)|0,_e()|0,E=E&15;e:do if(!E)S=0;else for(N=1;;){if(S=pn(A|0,w|0,(15-N|0)*3|0)|0,_e()|0,S=S&7,S|0)break e;if(N>>>0>>0)N=N+1|0;else{S=0;break}}while(!1);return E=(S|0)==0&1,E|0}function Ka(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0;if(D=Re,Re=Re+16|0,P=D,ec(P,A,w,S),w=P,A=m[w>>2]|0,w=m[w+4>>2]|0,(A|0)==0&(w|0)==0)return Re=D,0;E=0,S=0;do v=N+(E<<3)|0,m[v>>2]=A,m[v+4>>2]=w,E=Pn(E|0,S|0,1,0)|0,S=_e()|0,fd(P),v=P,A=m[v>>2]|0,w=m[v+4>>2]|0;while(!((A|0)==0&(w|0)==0));return Re=D,0}function _c(A,w,S,N){return A=A|0,w=w|0,S=S|0,N=N|0,(N|0)<(S|0)?(S=w,N=A,wt(S|0),N|0):(S=xn(-1,-1,((N-S|0)*3|0)+3|0)|0,N=xn(~S|0,~(_e()|0)|0,(15-N|0)*3|0)|0,S=~(_e()|0)&w,N=~N&A,wt(S|0),N|0)}function Ba(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0;return E=pn(A|0,w|0,52)|0,_e()|0,E=E&15,(S|0)<16&(E|0)<=(S|0)?((E|0)<(S|0)&&(E=xn(-1,-1,((S+-1-E|0)*3|0)+3|0)|0,E=xn(~E|0,~(_e()|0)|0,(15-S|0)*3|0)|0,w=~(_e()|0)&w,A=~E&A),E=xn(S|0,0,52)|0,S=w&-15728641|(_e()|0),m[N>>2]=A|E,m[N+4>>2]=S,N=0,N|0):(N=4,N|0)}function Ja(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0,kt=0,Rt=0,Wt=0,Kt=0,tn=0;if((S|0)==0&(N|0)==0)return tn=0,tn|0;if(E=A,P=m[E>>2]|0,E=m[E+4>>2]|0,!0&(E&15728640|0)==0){if(!((N|0)>0|(N|0)==0&S>>>0>0)||(tn=w,m[tn>>2]=P,m[tn+4>>2]=E,(S|0)==1&(N|0)==0))return tn=0,tn|0;E=1,P=0;do Wt=A+(E<<3)|0,Kt=m[Wt+4>>2]|0,tn=w+(E<<3)|0,m[tn>>2]=m[Wt>>2],m[tn+4>>2]=Kt,E=Pn(E|0,P|0,1,0)|0,P=_e()|0;while((P|0)<(N|0)|(P|0)==(N|0)&E>>>0>>0);return E=0,E|0}if(Rt=S<<3,Kt=gi(Rt)|0,!Kt)return tn=13,tn|0;if(ql(Kt|0,A|0,Rt|0)|0,Wt=bs(S,8)|0,!Wt)return yn(Kt),tn=13,tn|0;e:for(;;){E=Kt,j=m[E>>2]|0,E=m[E+4>>2]|0,Ke=pn(j|0,E|0,52)|0,_e()|0,Ke=Ke&15,kt=Ke+-1|0,Ye=(Ke|0)!=0,xt=(N|0)>0|(N|0)==0&S>>>0>0;t:do if(Ye&xt){if(we=xn(kt|0,0,52)|0,ke=_e()|0,kt>>>0>15){if(!((j|0)==0&(E|0)==0)){tn=16;break e}for(P=0,A=0;;){if(P=Pn(P|0,A|0,1,0)|0,A=_e()|0,!((A|0)<(N|0)|(A|0)==(N|0)&P>>>0>>0))break t;if(D=Kt+(P<<3)|0,Je=m[D>>2]|0,D=m[D+4>>2]|0,!((Je|0)==0&(D|0)==0)){E=D,tn=16;break e}}}for(v=j,A=E,P=0,D=0;;){if(!((v|0)==0&(A|0)==0)){if(!(!0&(A&117440512|0)==0)){tn=21;break e}if(q=pn(v|0,A|0,52)|0,_e()|0,q=q&15,(q|0)<(kt|0)){E=12,tn=27;break e}if((q|0)!=(kt|0)&&(v=v|we,A=A&-15728641|ke,q>>>0>=Ke>>>0)){T=kt;do Je=xn(7,0,(14-T|0)*3|0)|0,T=T+1|0,v=Je|v,A=_e()|0|A;while(T>>>0>>0)}if(te=Mc(v|0,A|0,S|0,N|0)|0,ne=_e()|0,T=Wt+(te<<3)|0,q=T,Z=m[q>>2]|0,q=m[q+4>>2]|0,!((Z|0)==0&(q|0)==0)){Ee=0,Ue=0;do{if((Ee|0)>(N|0)|(Ee|0)==(N|0)&Ue>>>0>S>>>0){tn=31;break e}if((Z|0)==(v|0)&(q&-117440513|0)==(A|0)){le=pn(Z|0,q|0,56)|0,_e()|0,le=le&7,xe=le+1|0,Je=pn(Z|0,q|0,45)|0,_e()|0;n:do if(!(nr(Je&127)|0))q=7;else{if(Z=pn(Z|0,q|0,52)|0,_e()|0,Z=Z&15,!Z){q=6;break}for(q=1;;){if(Je=xn(7,0,(15-q|0)*3|0)|0,!((Je&v|0)==0&((_e()|0)&A|0)==0)){q=7;break n}if(q>>>0>>0)q=q+1|0;else{q=6;break}}}while(!1);if((le+2|0)>>>0>q>>>0){tn=41;break e}Je=xn(xe|0,0,56)|0,A=_e()|0|A&-117440513,je=T,m[je>>2]=0,m[je+4>>2]=0,v=Je|v}else te=Pn(te|0,ne|0,1,0)|0,te=Kc(te|0,_e()|0,S|0,N|0)|0,ne=_e()|0;Ue=Pn(Ue|0,Ee|0,1,0)|0,Ee=_e()|0,T=Wt+(te<<3)|0,q=T,Z=m[q>>2]|0,q=m[q+4>>2]|0}while(!((Z|0)==0&(q|0)==0))}Je=T,m[Je>>2]=v,m[Je+4>>2]=A}if(P=Pn(P|0,D|0,1,0)|0,D=_e()|0,!((D|0)<(N|0)|(D|0)==(N|0)&P>>>0>>0))break t;A=Kt+(P<<3)|0,v=m[A>>2]|0,A=m[A+4>>2]|0}}while(!1);if(Je=Pn(S|0,N|0,5,0)|0,je=_e()|0,je>>>0<0|(je|0)==0&Je>>>0<11){tn=85;break}if(Je=Qc(S|0,N|0,6,0)|0,_e()|0,Je=bs(Je,8)|0,!Je){tn=48;break}do if(xt){for(xe=0,A=0,le=0,Ee=0;;){if(q=Wt+(xe<<3)|0,D=q,P=m[D>>2]|0,D=m[D+4>>2]|0,(P|0)==0&(D|0)==0)je=le;else{Z=pn(P|0,D|0,56)|0,_e()|0,Z=Z&7,v=Z+1|0,te=D&-117440513,je=pn(P|0,D|0,45)|0,_e()|0;t:do if(nr(je&127)|0){if(ne=pn(P|0,D|0,52)|0,_e()|0,ne=ne&15,ne|0)for(T=1;;){if(je=xn(7,0,(15-T|0)*3|0)|0,!((P&je|0)==0&(te&(_e()|0)|0)==0))break t;if(T>>>0>>0)T=T+1|0;else break}D=xn(v|0,0,56)|0,P=D|P,D=_e()|0|te,v=q,m[v>>2]=P,m[v+4>>2]=D,v=Z+2|0}while(!1);(v|0)==7?(je=Je+(A<<3)|0,m[je>>2]=P,m[je+4>>2]=D&-117440513,A=Pn(A|0,le|0,1,0)|0,je=_e()|0):je=le}if(xe=Pn(xe|0,Ee|0,1,0)|0,Ee=_e()|0,(Ee|0)<(N|0)|(Ee|0)==(N|0)&xe>>>0>>0)le=je;else break}if(xt){if(Ue=kt>>>0>15,we=xn(kt|0,0,52)|0,ke=_e()|0,!Ye){for(P=0,T=0,v=0,D=0;(j|0)==0&(E|0)==0||(kt=w+(P<<3)|0,m[kt>>2]=j,m[kt+4>>2]=E,P=Pn(P|0,T|0,1,0)|0,T=_e()|0),v=Pn(v|0,D|0,1,0)|0,D=_e()|0,!!((D|0)<(N|0)|(D|0)==(N|0)&v>>>0>>0);)E=Kt+(v<<3)|0,j=m[E>>2]|0,E=m[E+4>>2]|0;E=je;break}for(P=0,T=0,D=0,v=0;;){do if(!((j|0)==0&(E|0)==0)){if(ne=pn(j|0,E|0,52)|0,_e()|0,ne=ne&15,Ue|(ne|0)<(kt|0)){tn=80;break e}if((ne|0)!=(kt|0)){if(q=j|we,Z=E&-15728641|ke,ne>>>0>=Ke>>>0){te=kt;do Ye=xn(7,0,(14-te|0)*3|0)|0,te=te+1|0,q=Ye|q,Z=_e()|0|Z;while(te>>>0>>0)}}else q=j,Z=E;le=Mc(q|0,Z|0,S|0,N|0)|0,te=0,ne=0,Ee=_e()|0;do{if((te|0)>(N|0)|(te|0)==(N|0)&ne>>>0>S>>>0){tn=81;break e}if(Ye=Wt+(le<<3)|0,xe=m[Ye+4>>2]|0,(xe&-117440513|0)==(Z|0)&&(m[Ye>>2]|0)==(q|0)){tn=65;break}Ye=Pn(le|0,Ee|0,1,0)|0,le=Kc(Ye|0,_e()|0,S|0,N|0)|0,Ee=_e()|0,ne=Pn(ne|0,te|0,1,0)|0,te=_e()|0,Ye=Wt+(le<<3)|0}while(!((m[Ye>>2]|0)==(q|0)&&(m[Ye+4>>2]|0)==(Z|0)));if((tn|0)==65&&(tn=0,!0&(xe&117440512|0)==100663296))break;Ye=w+(P<<3)|0,m[Ye>>2]=j,m[Ye+4>>2]=E,P=Pn(P|0,T|0,1,0)|0,T=_e()|0}while(!1);if(D=Pn(D|0,v|0,1,0)|0,v=_e()|0,!((v|0)<(N|0)|(v|0)==(N|0)&D>>>0>>0))break;E=Kt+(D<<3)|0,j=m[E>>2]|0,E=m[E+4>>2]|0}E=je}else P=0,E=je}else P=0,A=0,E=0;while(!1);if(Eh(Wt|0,0,Rt|0)|0,ql(Kt|0,Je|0,A<<3|0)|0,yn(Je),(A|0)==0&(E|0)==0){tn=89;break}else w=w+(P<<3)|0,N=E,S=A}if((tn|0)==16)!0&(E&117440512|0)==0?(E=4,tn=27):tn=21;else if((tn|0)==31)Dt(27634,27225,620,27235);else{if((tn|0)==41)return yn(Kt),yn(Wt),tn=10,tn|0;if((tn|0)==48)return yn(Kt),yn(Wt),tn=13,tn|0;(tn|0)==80?Dt(27634,27225,711,27235):(tn|0)==81?Dt(27634,27225,723,27235):(tn|0)==85&&(ql(w|0,Kt|0,S<<3|0)|0,tn=89)}return(tn|0)==21?(yn(Kt),yn(Wt),tn=5,tn|0):(tn|0)==27?(yn(Kt),yn(Wt),tn=E,tn|0):(tn|0)==89?(yn(Kt),yn(Wt),tn=0,tn|0):0}function vl(A,w,S,N,E,P,D){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0,D=D|0;var v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0;if(xe=Re,Re=Re+16|0,le=xe,!((S|0)>0|(S|0)==0&w>>>0>0))return le=0,Re=xe,le|0;if((D|0)>=16)return le=12,Re=xe,le|0;te=0,ne=0,Z=0,v=0;e:for(;;){if(j=A+(te<<3)|0,T=m[j>>2]|0,j=m[j+4>>2]|0,q=pn(T|0,j|0,52)|0,_e()|0,(q&15|0)>(D|0)){v=12,T=11;break}if(ec(le,T,j,D),q=le,j=m[q>>2]|0,q=m[q+4>>2]|0,(j|0)==0&(q|0)==0)T=Z;else{T=Z;do{if(!((v|0)<(P|0)|(v|0)==(P|0)&T>>>0>>0)){T=10;break e}Z=N+(T<<3)|0,m[Z>>2]=j,m[Z+4>>2]=q,T=Pn(T|0,v|0,1,0)|0,v=_e()|0,fd(le),Z=le,j=m[Z>>2]|0,q=m[Z+4>>2]|0}while(!((j|0)==0&(q|0)==0))}if(te=Pn(te|0,ne|0,1,0)|0,ne=_e()|0,(ne|0)<(S|0)|(ne|0)==(S|0)&te>>>0>>0)Z=T;else{v=0,T=11;break}}return(T|0)==10?(le=14,Re=xe,le|0):(T|0)==11?(Re=xe,v|0):0}function Jo(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0;te=Re,Re=Re+16|0,Z=te;e:do if((S|0)>0|(S|0)==0&w>>>0>0){for(j=0,D=0,P=0,q=0;;){if(T=A+(j<<3)|0,v=m[T>>2]|0,T=m[T+4>>2]|0,!((v|0)==0&(T|0)==0)&&(T=(Xs(v,T,N,Z)|0)==0,v=Z,D=Pn(m[v>>2]|0,m[v+4>>2]|0,D|0,P|0)|0,P=_e()|0,!T)){P=12;break}if(j=Pn(j|0,q|0,1,0)|0,q=_e()|0,!((q|0)<(S|0)|(q|0)==(S|0)&j>>>0>>0))break e}return Re=te,P|0}else D=0,P=0;while(!1);return m[E>>2]=D,m[E+4>>2]=P,E=0,Re=te,E|0}function Bl(A,w){return A=A|0,w=w|0,w=pn(A|0,w|0,52)|0,_e()|0,w&1|0}function Li(A,w){A=A|0,w=w|0;var S=0,N=0,E=0;if(E=pn(A|0,w|0,52)|0,_e()|0,E=E&15,!E)return E=0,E|0;for(N=1;;){if(S=pn(A|0,w|0,(15-N|0)*3|0)|0,_e()|0,S=S&7,S|0){N=5;break}if(N>>>0>>0)N=N+1|0;else{S=0,N=5;break}}return(N|0)==5?S|0:0}function Xc(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;if(q=pn(A|0,w|0,52)|0,_e()|0,q=q&15,!q)return j=w,q=A,wt(j|0),q|0;for(j=1,S=0;;){switch(N=(15-j|0)*3|0,v=xn(7,0,N|0)|0,T=_e()|0,P=A&~v,D=w&~T,A=pn(A|0,w|0,N|0)|0,_e()|0,A&7){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}default:A=A&7}N=xn(A|0,0,N|0)|0,E=_e()|0,A=N|P,w=E|D;e:do if(!S)if((N&v|0)==0&(E&T|0)==0)S=0;else if(D=pn(A|0,w|0,52)|0,_e()|0,D=D&15,!D)S=1;else{S=1;t:for(;;){switch(T=pn(A|0,w|0,(15-S|0)*3|0)|0,_e()|0,T&7){case 1:break t;case 0:break;default:{S=1;break e}}if(S>>>0>>0)S=S+1|0;else{S=1;break e}}for(P=1;;){switch(E=(15-P|0)*3|0,S=pn(A|0,w|0,E|0)|0,_e()|0,N=xn(7,0,E|0)|0,N=A&~N,w=w&~(_e()|0),S&7){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}default:A=S&7}if(A=xn(A|0,0,E|0)|0,A=A|N,w=_e()|0|w,P>>>0>>0)P=P+1|0;else{S=1;break e}}}while(!1);if(j>>>0>>0)j=j+1|0;else break}return wt(w|0),A|0}function yl(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0;if(D=pn(A|0,w|0,52)|0,_e()|0,D=D&15,!D)return P=w,D=A,wt(P|0),D|0;for(P=1;;){switch(E=(15-P|0)*3|0,S=pn(A|0,w|0,E|0)|0,_e()|0,N=xn(7,0,E|0)|0,N=A&~N,w=w&~(_e()|0),S&7){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}default:A=S&7}if(A=xn(A|0,0,E|0)|0,A=A|N,w=_e()|0|w,P>>>0>>0)P=P+1|0;else break}return wt(w|0),A|0}function Co(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;if(q=pn(A|0,w|0,52)|0,_e()|0,q=q&15,!q)return j=w,q=A,wt(j|0),q|0;for(j=1,S=0;;){switch(N=(15-j|0)*3|0,v=xn(7,0,N|0)|0,T=_e()|0,P=A&~v,D=w&~T,A=pn(A|0,w|0,N|0)|0,_e()|0,A&7){case 1:{A=3;break}case 3:{A=2;break}case 2:{A=6;break}case 6:{A=4;break}case 4:{A=5;break}case 5:{A=1;break}default:A=A&7}N=xn(A|0,0,N|0)|0,E=_e()|0,A=N|P,w=E|D;e:do if(!S)if((N&v|0)==0&(E&T|0)==0)S=0;else if(D=pn(A|0,w|0,52)|0,_e()|0,D=D&15,!D)S=1;else{S=1;t:for(;;){switch(T=pn(A|0,w|0,(15-S|0)*3|0)|0,_e()|0,T&7){case 1:break t;case 0:break;default:{S=1;break e}}if(S>>>0>>0)S=S+1|0;else{S=1;break e}}for(P=1;;){switch(S=(15-P|0)*3|0,N=xn(7,0,S|0)|0,N=A&~N,E=w&~(_e()|0),A=pn(A|0,w|0,S|0)|0,_e()|0,A&7){case 1:{A=3;break}case 3:{A=2;break}case 2:{A=6;break}case 6:{A=4;break}case 4:{A=5;break}case 5:{A=1;break}default:A=A&7}if(A=xn(A|0,0,S|0)|0,A=A|N,w=_e()|0|E,P>>>0>>0)P=P+1|0;else{S=1;break e}}}while(!1);if(j>>>0>>0)j=j+1|0;else break}return wt(w|0),A|0}function ms(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0;if(D=pn(A|0,w|0,52)|0,_e()|0,D=D&15,!D)return P=w,D=A,wt(P|0),D|0;for(P=1;;){switch(N=(15-P|0)*3|0,S=xn(7,0,N|0)|0,S=A&~S,E=w&~(_e()|0),A=pn(A|0,w|0,N|0)|0,_e()|0,A&7){case 1:{A=3;break}case 3:{A=2;break}case 2:{A=6;break}case 6:{A=4;break}case 4:{A=5;break}case 5:{A=1;break}default:A=A&7}if(A=xn(A|0,0,N|0)|0,A=A|S,w=_e()|0|E,P>>>0>>0)P=P+1|0;else break}return wt(w|0),A|0}function Ms(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0;if(je=Re,Re=Re+16|0,ke=je,xn(w|0,0,52)|0,S=_e()|0|134225919,!w)return(m[A+4>>2]|0)>2||(m[A+8>>2]|0)>2||(m[A+12>>2]|0)>2?(we=0,ke=0,wt(we|0),Re=je,ke|0):(xn(Xo(A)|0,0,45)|0,we=_e()|0|S,ke=-1,wt(we|0),Re=je,ke|0);m[ke>>2]=m[A>>2],m[ke+4>>2]=m[A+4>>2],m[ke+8>>2]=m[A+8>>2],m[ke+12>>2]=m[A+12>>2],we=ke+4|0;e:do if((w|0)>0)for(xe=ke+8|0,Ee=ke+12|0,le=w,Z=m[xe>>2]|0,te=m[Ee>>2]|0,w=-1,q=m[ke+4>>2]|0;;){ne=le,le=le+-1|0,A=q-te|0,N=Z-te|0,ne&1?(P=zr(+((A*3|0)-N|0)*.14285714285714285)|0,m[we>>2]=P,A=zr(+((N<<1)+A|0)*.14285714285714285)|0,m[xe>>2]=A,m[Ee>>2]=0,N=A-P|0,E=0-P|0,(P|0)<0?(m[xe>>2]=N,m[Ee>>2]=E,m[we>>2]=0,A=N,D=0):(D=P,E=0),P=D-A|0,N=E-A|0,(A|0)<0?(m[we>>2]=P,m[Ee>>2]=N,m[xe>>2]=0,D=P,P=0):(N=E,P=A),A=D-N|0,E=P-N|0,(N|0)<0?(m[we>>2]=A,m[xe>>2]=E,m[Ee>>2]=0,P=0):(E=P,A=D,P=N),N=(E|0)<(A|0)?E:A,N=(P|0)<(N|0)?P:N,(N|0)>0&&(P=P-N|0,E=E-N|0,A=A-N|0,m[we>>2]=A,m[xe>>2]=E,m[Ee>>2]=P),xt=E+(A*3|0)|0,Je=(xt|0)<0,j=P+(E*3|0)-(Je?xt:0)|0,T=(j|0)<0,N=(P*3|0)+A-(Je?xt:0)-(T?j:0)|0,v=(N|0)<0,Ye=v?0:N,D=(T?0:j)-(v?N:0)|0,N=(Je?0:xt)-(T?j:0)-(v?N:0)|0,v=(D|0)<(N|0)?D:N,v=(Ye|0)<(v|0)?Ye:v,j=(v|0)>0,T=j?v:0,D=D-(j?v:0)|0,v=Ye-(j?v:0)|0,j=P):(v=zr(+((A<<1)+N|0)*.14285714285714285)|0,m[we>>2]=v,E=zr(+((N*3|0)-A|0)*.14285714285714285)|0,m[xe>>2]=E,m[Ee>>2]=0,N=E-v|0,A=0-v|0,(v|0)<0?(m[xe>>2]=N,m[Ee>>2]=A,m[we>>2]=0,E=N,v=0):A=0,D=v-E|0,N=A-E|0,(E|0)<0?(m[we>>2]=D,m[Ee>>2]=N,m[xe>>2]=0,P=N,E=0):(P=A,D=v),A=D-P|0,N=E-P|0,(P|0)<0?(m[we>>2]=A,m[xe>>2]=N,m[Ee>>2]=0,E=N,P=0):A=D,N=(E|0)<(A|0)?E:A,N=(P|0)<(N|0)?P:N,(N|0)>0&&(P=P-N|0,E=E-N|0,A=A-N|0,m[we>>2]=A,m[xe>>2]=E,m[Ee>>2]=P),xt=P+(A*3|0)|0,Ye=(xt|0)<0,j=(E*3|0)+A-(Ye?xt:0)|0,T=(j|0)<0,N=(P*3|0)+E-(Ye?xt:0)-(T?j:0)|0,v=(N|0)<0,Je=v?0:N,D=(T?0:j)-(v?N:0)|0,N=(Ye?0:xt)-(T?j:0)-(v?N:0)|0,v=(D|0)<(N|0)?D:N,v=(Je|0)<(v|0)?Je:v,j=(v|0)>0,T=j?v:0,D=D-(j?v:0)|0,v=Je-(j?v:0)|0,j=P),N=q+(T-N)|0,P=(N|0)<0,T=Z-D-(P?N:0)|0,D=(T|0)<0,te=te-v+(P?0-N|0:0)+(D?0-T|0:0)|0,q=(te|0)<0,v=q?0:te,Ye=(D?0:T)-(q?te:0)|0,te=(P?0:N)-(D?T:0)-(q?te:0)|0,q=(Ye|0)<(te|0)?Ye:te,q=(v|0)<(q|0)?v:q,T=(q|0)>0,te=te-(T?q:0)|0,D=(15-ne|0)*3|0,N=xn(7,0,D|0)|0,N=w&~N,P=S&~(_e()|0),Z=(te|0)<0,xt=Z?te:0,Ye=Ye-(T?q:0)-xt|0,Je=(Ye|0)<0,xt=(Je?0-Ye|0:0)+(v-(T?q:0)-xt)|0,S=(xt|0)<0,w=S?0:xt,xt=S?xt:0,S=(Je?0:Ye)-xt|0,xt=(Z?0:te)-(Je?Ye:0)-xt|0,Ye=(S|0)<(xt|0)?S:xt,Ye=(w|0)<(Ye|0)?w:Ye,Ye=(Ye|0)>0?Ye:0,w=w-Ye|0,S=S-Ye|0;t:do switch(xt-Ye|0){case 0:switch(S|0){case 0:{w=w|0?(w|0)==1?1:7:0;break t}case 1:{w=w|0?(w|0)==1?3:7:2;break t}default:{Ue=36;break t}}case 1:switch(S|0){case 0:{w=w|0?(w|0)==1?5:7:4;break t}case 1:if(w){Ue=36;break t}else{w=6;break t}default:{Ue=36;break t}}default:Ue=36}while(!1);if((Ue|0)==36&&(Ue=0,w=7),w=xn(w|0,0,D|0)|0,w=w|N,S=_e()|0|P,(ne|0)<=1)break e;Z=E,te=j,q=A}else w=-1,A=m[we>>2]|0;while(!1);e:do if((A|0)<=2&&(m[ke+8>>2]|0)<=2&&(m[ke+12>>2]|0)<=2){if(N=Xo(ke)|0,A=xn(N|0,0,45)|0,w=A|w,A=_e()|0|S&-1040385,T=Dn(ke)|0,!(nr(N)|0)){if((T|0)<=0)break;for(v=0;;){D=pn(w|0,A|0,52)|0,_e()|0,D=D&15;t:do if(D)for(P=1;;){switch(E=(15-P|0)*3|0,S=pn(w|0,A|0,E|0)|0,_e()|0,N=xn(7,0,E|0)|0,w=w&~N,N=A&~(_e()|0),S&7){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}default:A=S&7}if(A=xn(A|0,0,E|0)|0,w=A|w,A=_e()|0|N,P>>>0>>0)P=P+1|0;else break t}while(!1);if(v=v+1|0,(v|0)==(T|0))break e}}D=pn(w|0,A|0,52)|0,_e()|0,D=D&15;t:do if(D){S=1;n:for(;;){switch(Ye=pn(w|0,A|0,(15-S|0)*3|0)|0,_e()|0,Ye&7){case 1:break n;case 0:break;default:break t}if(S>>>0>>0)S=S+1|0;else break t}if(Es(N,m[ke>>2]|0)|0)for(P=1;;){switch(S=(15-P|0)*3|0,N=xn(7,0,S|0)|0,N=w&~N,E=A&~(_e()|0),A=pn(w|0,A|0,S|0)|0,_e()|0,A&7){case 1:{A=3;break}case 3:{A=2;break}case 2:{A=6;break}case 6:{A=4;break}case 4:{A=5;break}case 5:{A=1;break}default:A=A&7}if(w=xn(A|0,0,S|0)|0,w=w|N,A=_e()|0|E,P>>>0>>0)P=P+1|0;else break t}else for(P=1;;){switch(E=(15-P|0)*3|0,S=pn(w|0,A|0,E|0)|0,_e()|0,N=xn(7,0,E|0)|0,w=w&~N,N=A&~(_e()|0),S&7){case 1:{A=5;break}case 5:{A=4;break}case 4:{A=6;break}case 6:{A=2;break}case 2:{A=3;break}case 3:{A=1;break}default:A=S&7}if(A=xn(A|0,0,E|0)|0,w=A|w,A=_e()|0|N,P>>>0>>0)P=P+1|0;else break t}}while(!1);if((T|0)>0){S=0;do w=Xc(w,A)|0,A=_e()|0,S=S+1|0;while((S|0)!=(T|0))}}else w=0,A=0;while(!1);return xt=A,Ye=w,wt(xt|0),Re=je,Ye|0}function $r(A){return A=A|0,(A|0)%2|0|0}function wc(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0;if(q=Re,Re=Re+64|0,v=q+24|0,T=q+48|0,j=q,w>>>0>15)return j=4,Re=q,j|0;if(P=+Ie[A>>3],Ie[An>>3]=P,(m[An+4>>2]&2146435072|0)==2146435072||(N=+Ie[A+8>>3],Ie[An>>3]=N,(m[An+4>>2]&2146435072|0)==2146435072))return j=3,Re=q,j|0;E=+Hn(+P),Z=E*+Hn(+N),E=E*+lr(+N),N=+lr(+P),Ie[j>>3]=Z,Ie[j+8>>3]=E,Ie[j+16>>3]=N,Ie[An>>3]=Z;do if((m[An+4>>2]&2146435072|0)!=2146435072&&(Ie[An>>3]=N,A=m[An+4>>2]|0,Ie[An>>3]=E,!((m[An+4>>2]&2146435072|0)==2146435072|!0&(A&2146435072|0)==2146435072)))if(m[v>>2]=m[j>>2],m[v+4>>2]=m[j+4>>2],m[v+8>>2]=m[j+8>>2],m[v+12>>2]=m[j+12>>2],m[v+16>>2]=m[j+16>>2],m[v+20>>2]=m[j+20>>2],Oe(v,w,T),T=Ms(T,w)|0,j=_e()|0,m[S>>2]=T,m[S+4>>2]=j,(T|0)==0&(j|0)==0)Dt(27634,27225,1073,27248);else{D=0;break}else D=2;while(!1);return j=D,Re=q,j|0}function Na(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0;if(ne=S+4|0,le=pn(A|0,w|0,52)|0,_e()|0,le=le&15,te=pn(A|0,w|0,45)|0,_e()|0,N=(le|0)==0,nr(te&127)|0){if(N)return le=1,le|0;N=1}else{if(N)return le=0,le|0;!(m[ne>>2]|0)&&!(m[S+8>>2]|0)?N=(m[S+12>>2]|0)!=0&1:N=1}for(te=S+8|0,Z=S+12|0,q=1,S=m[ne>>2]|0,D=m[te>>2]|0,P=m[Z>>2]|0;E=S*3|0,v=D*3|0,j=P*3|0,q&1?(T=D+E|0,m[ne>>2]=T,P=P+v|0,m[te>>2]=P,E=j+S|0,m[Z>>2]=E,S=P-T|0,D=E-T|0,(T|0)<0?(m[te>>2]=S,m[Z>>2]=D,m[ne>>2]=0,v=0,E=D):(S=P,v=T),D=v-S|0,P=E-S|0,(S|0)<0?(m[ne>>2]=D,m[Z>>2]=P,m[te>>2]=0,v=D,E=0):(P=E,E=S),S=v-P|0,D=E-P|0,(P|0)<0?(m[ne>>2]=S,m[te>>2]=D,m[Z>>2]=0,P=0):(D=E,S=v),E=(D|0)<(S|0)?D:S,E=(P|0)<(E|0)?P:E,(E|0)>0&&(P=P-E|0,D=D-E|0,S=S-E|0,m[ne>>2]=S,m[te>>2]=D,m[Z>>2]=P)):(T=v+S|0,v=P+E|0,m[ne>>2]=v,m[te>>2]=T,E=j+D|0,m[Z>>2]=E,S=T-v|0,P=E-v|0,(v|0)<0?(m[te>>2]=S,m[Z>>2]=P,m[ne>>2]=0,v=0,E=P):S=T,D=v-S|0,P=E-S|0,(S|0)<0?(m[ne>>2]=D,m[Z>>2]=P,m[te>>2]=0,v=D,E=0):(P=E,E=S),S=v-P|0,D=E-P|0,(P|0)<0?(m[ne>>2]=S,m[te>>2]=D,m[Z>>2]=0,P=0):(D=E,S=v),E=(D|0)<(S|0)?D:S,E=(P|0)<(E|0)?P:E,(E|0)>0&&(P=P-E|0,D=D-E|0,S=S-E|0,m[ne>>2]=S,m[te>>2]=D,m[Z>>2]=P)),E=pn(A|0,w|0,(15-q|0)*3|0)|0,_e()|0,E=E&7,(E+-1|0)>>>0<6&&(T=m[22032+(E*12|0)+4>>2]|0,j=m[22032+(E*12|0)+8>>2]|0,v=(m[22032+(E*12|0)>>2]|0)+S|0,m[ne>>2]=v,D=T+D|0,m[te>>2]=D,S=j+P|0,m[Z>>2]=S,P=D-v|0,E=S-v|0,(v|0)<0&&(m[te>>2]=P,m[Z>>2]=E,m[ne>>2]=0,v=0,S=E,D=P),E=v-D|0,P=S-D|0,(D|0)<0?(m[ne>>2]=E,m[Z>>2]=P,m[te>>2]=0,v=E,D=0):P=S,S=v-P|0,E=D-P|0,(P|0)<0?(m[ne>>2]=S,m[te>>2]=E,m[Z>>2]=0,D=E,P=0):S=v,E=(D|0)<(S|0)?D:S,E=(P|0)<(E|0)?P:E,(E|0)>0&&(P=P-E|0,D=D-E|0,S=S-E|0,m[ne>>2]=S,m[te>>2]=D,m[Z>>2]=P)),q>>>0>>0;)q=q+1|0;return N|0}function po(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0;if(le=Re,Re=Re+16|0,Z=le,te=pn(A|0,w|0,45)|0,_e()|0,te=te&127,te>>>0>121)return m[S>>2]=0,m[S+4>>2]=0,m[S+8>>2]=0,m[S+12>>2]=0,ne=5,Re=le,ne|0;e:do if(nr(te)|0&&(v=pn(A|0,w|0,52)|0,_e()|0,v=v&15,(v|0)!=0)){N=1;t:for(;;){switch(ne=pn(A|0,w|0,(15-N|0)*3|0)|0,_e()|0,ne&7){case 5:break t;case 0:break;default:{j=w;break e}}if(N>>>0>>0)N=N+1|0;else{j=w;break e}}for(D=1,N=w;;){switch(w=(15-D|0)*3|0,E=xn(7,0,w|0)|0,E=A&~E,P=N&~(_e()|0),N=pn(A|0,N|0,w|0)|0,_e()|0,N&7){case 1:{N=3;break}case 3:{N=2;break}case 2:{N=6;break}case 6:{N=4;break}case 4:{N=5;break}case 5:{N=1;break}default:N=N&7}if(A=xn(N|0,0,w|0)|0,A=A|E,N=_e()|0|P,D>>>0>>0)D=D+1|0;else{j=N;break e}}}else j=w;while(!1);if(ne=7696+(te*28|0)|0,m[S>>2]=m[ne>>2],m[S+4>>2]=m[ne+4>>2],m[S+8>>2]=m[ne+8>>2],m[S+12>>2]=m[ne+12>>2],!(Na(A,j,S)|0))return ne=0,Re=le,ne|0;if(ne=S+4|0,m[Z>>2]=m[ne>>2],m[Z+4>>2]=m[ne+4>>2],m[Z+8>>2]=m[ne+8>>2],T=pn(A|0,j|0,52)|0,_e()|0,q=T&15,T&1?(P=m[ne>>2]|0,v=S+8|0,E=m[v>>2]|0,T=S+12|0,w=m[T>>2]|0,N=(E*3|0)+P|0,P=w+(P*3|0)|0,m[ne>>2]=P,m[v>>2]=N,E=(w*3|0)+E|0,m[T>>2]=E,w=N-P|0,D=E-P|0,(P|0)<0&&(m[v>>2]=w,m[T>>2]=D,m[ne>>2]=0,N=w,P=0,E=D),D=P-N|0,w=E-N|0,(N|0)<0?(m[ne>>2]=D,m[T>>2]=w,m[v>>2]=0,N=0):(w=E,D=P),P=D-w|0,E=N-w|0,(w|0)<0?(m[ne>>2]=P,m[v>>2]=E,m[T>>2]=0,w=0):(E=N,P=D),N=(E|0)<(P|0)?E:P,N=(w|0)<(N|0)?w:N,(N|0)>0&&(m[ne>>2]=P-N,m[v>>2]=E-N,m[T>>2]=w-N),E=q+1|0):E=q,!(nr(te)|0))N=0;else{e:do if(!q)N=0;else for(w=1;;){if(N=pn(A|0,j|0,(15-w|0)*3|0)|0,_e()|0,N=N&7,N|0)break e;if(w>>>0>>0)w=w+1|0;else{N=0;break}}while(!1);N=(N|0)==4&1}if(!(gn(S,E,N,0)|0))(E|0)!=(q|0)&&(m[ne>>2]=m[Z>>2],m[ne+4>>2]=m[Z+4>>2],m[ne+8>>2]=m[Z+8>>2]);else{if(nr(te)|0)do;while(gn(S,E,0,0)|0);(E|0)!=(q|0)&&(v=S+12|0,A=m[v>>2]|0,N=(m[ne>>2]|0)-A|0,D=S+8|0,A=(m[D>>2]|0)-A|0,w=zr(+((N<<1)+A|0)*.14285714285714285)|0,m[ne>>2]=w,N=zr(+((A*3|0)-N|0)*.14285714285714285)|0,m[D>>2]=N,m[v>>2]=0,A=N-w|0,E=0-w|0,(w|0)<0?(m[D>>2]=A,m[v>>2]=E,m[ne>>2]=0,N=A,w=0):E=0,P=w-N|0,A=E-N|0,(N|0)<0?(m[ne>>2]=P,m[v>>2]=A,m[D>>2]=0,w=P,N=0):A=E,P=w-A|0,E=N-A|0,(A|0)<0?(m[ne>>2]=P,m[D>>2]=E,m[v>>2]=0,w=P,A=0):E=N,N=(E|0)<(w|0)?E:w,N=(A|0)<(N|0)?A:N,(N|0)>0&&(m[ne>>2]=w-N,m[D>>2]=E-N,m[v>>2]=A-N))}return ne=0,Re=le,ne|0}function Po(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0;return D=Re,Re=Re+48|0,N=D+24|0,E=D,P=po(A,w,N)|0,P?(Re=D,P|0):(P=pn(A|0,w|0,52)|0,_e()|0,at(N,P&15,E),T=+Os(+ +Ie[E+16>>3]),v=+Pi(+ +Ie[E+8>>3],+ +Ie[E>>3]),Ie[S>>3]=T,Ie[S+8>>3]=v,P=0,Re=D,P|0)}function Ul(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0;if(D=Re,Re=Re+16|0,P=D,N=po(A,w,P)|0,N|0)return P=N,Re=D,P|0;N=pn(A|0,w|0,45)|0,_e()|0,N=(nr(N&127)|0)==0,E=pn(A|0,w|0,52)|0,_e()|0,E=E&15;e:do if(!N){if(E|0)for(N=1;;){if(v=xn(7,0,(15-N|0)*3|0)|0,!((v&A|0)==0&((_e()|0)&w|0)==0))break e;if(N>>>0>>0)N=N+1|0;else break}return qt(P,E,0,5,S),v=0,Re=D,v|0}while(!1);return ar(P,E,0,6,S),v=0,Re=D,v|0}function Yc(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0;if(E=pn(A|0,w|0,45)|0,_e()|0,!(nr(E&127)|0))return E=2,m[S>>2]=E,0;if(E=pn(A|0,w|0,52)|0,_e()|0,E=E&15,!E)return E=5,m[S>>2]=E,0;for(N=1;;){if(P=xn(7,0,(15-N|0)*3|0)|0,!((P&A|0)==0&((_e()|0)&w|0)==0)){N=2,A=6;break}if(N>>>0>>0)N=N+1|0;else{N=5,A=6;break}}return(A|0)==6&&(m[S>>2]=N),0}function hd(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0;Z=Re,Re=Re+128|0,j=Z+112|0,P=Z+96|0,q=Z,E=pn(A|0,w|0,52)|0,_e()|0,v=E&15,m[j>>2]=v,D=pn(A|0,w|0,45)|0,_e()|0,D=D&127;e:do if(nr(D)|0){if(v|0)for(N=1;;){if(T=xn(7,0,(15-N|0)*3|0)|0,!((T&A|0)==0&((_e()|0)&w|0)==0)){E=0;break e}if(N>>>0>>0)N=N+1|0;else break}if(E&1)E=1;else return T=xn(v+1|0,0,52)|0,q=_e()|0|w&-15728641,j=xn(7,0,(14-v|0)*3|0)|0,q=hd((T|A)&~j,q&~(_e()|0),S)|0,Re=Z,q|0}else E=0;while(!1);if(N=po(A,w,P)|0,!N){E?(un(P,j,q),T=5):(Dr(P,j,q),T=6);e:do if(nr(D)|0)if(!v)A=5;else for(N=1;;){if(D=xn(7,0,(15-N|0)*3|0)|0,!((D&A|0)==0&((_e()|0)&w|0)==0)){A=2;break e}if(N>>>0>>0)N=N+1|0;else{A=5;break}}else A=2;while(!1);Eh(S|0,-1,A<<2|0)|0;e:do if(E)for(P=0;;){if(D=q+(P<<4)|0,dr(D,m[j>>2]|0)|0,D=m[D>>2]|0,v=m[S>>2]|0,(v|0)==-1|(v|0)==(D|0))N=S;else{E=0;do{if(E=E+1|0,E>>>0>=A>>>0){N=1;break e}N=S+(E<<2)|0,v=m[N>>2]|0}while(!((v|0)==-1|(v|0)==(D|0)))}if(m[N>>2]=D,P=P+1|0,P>>>0>=T>>>0){N=0;break}}else for(P=0;;){if(D=q+(P<<4)|0,gn(D,m[j>>2]|0,0,1)|0,D=m[D>>2]|0,v=m[S>>2]|0,(v|0)==-1|(v|0)==(D|0))N=S;else{E=0;do{if(E=E+1|0,E>>>0>=A>>>0){N=1;break e}N=S+(E<<2)|0,v=m[N>>2]|0}while(!((v|0)==-1|(v|0)==(D|0)))}if(m[N>>2]=D,P=P+1|0,P>>>0>=T>>>0){N=0;break}}while(!1)}return q=N,Re=Z,q|0}function el(){return 12}function Ys(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0;if(A>>>0>15)return v=4,v|0;if(xn(A|0,0,52)|0,v=_e()|0|134225919,!A){S=0,N=0;do nr(N)|0&&(xn(N|0,0,45)|0,D=v|(_e()|0),A=w+(S<<3)|0,m[A>>2]=-1,m[A+4>>2]=D,S=S+1|0),N=N+1|0;while((N|0)!=122);return S=0,S|0}S=0,D=0;do{if(nr(D)|0){for(xn(D|0,0,45)|0,N=1,E=-1,P=v|(_e()|0);T=xn(7,0,(15-N|0)*3|0)|0,E=E&~T,P=P&~(_e()|0),(N|0)!=(A|0);)N=N+1|0;T=w+(S<<3)|0,m[T>>2]=E,m[T+4>>2]=P,S=S+1|0}D=D+1|0}while((D|0)!=122);return S=0,S|0}function tl(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0;if(we=Re,Re=Re+16|0,Ee=we,Ue=pn(A|0,w|0,52)|0,_e()|0,Ue=Ue&15,S>>>0>15)return Ue=4,Re=we,Ue|0;if((Ue|0)<(S|0))return Ue=12,Re=we,Ue|0;if((Ue|0)!=(S|0))if(P=xn(S|0,0,52)|0,P=P|A,v=_e()|0|w&-15728641,(Ue|0)>(S|0)){T=S;do xe=xn(7,0,(14-T|0)*3|0)|0,T=T+1|0,P=xe|P,v=_e()|0|v;while((T|0)<(Ue|0));xe=P}else xe=P;else xe=A,v=w;le=pn(xe|0,v|0,45)|0,_e()|0;e:do if(nr(le&127)|0){if(T=pn(xe|0,v|0,52)|0,_e()|0,T=T&15,T|0)for(P=1;;){if(le=xn(7,0,(15-P|0)*3|0)|0,!((le&xe|0)==0&((_e()|0)&v|0)==0)){j=33;break e}if(P>>>0>>0)P=P+1|0;else break}if(le=N,m[le>>2]=0,m[le+4>>2]=0,(Ue|0)>(S|0)){for(le=w&-15728641,ne=Ue;;){if(te=ne,ne=ne+-1|0,ne>>>0>15|(Ue|0)<(ne|0)){j=19;break}if((Ue|0)!=(ne|0))if(P=xn(ne|0,0,52)|0,P=P|A,T=_e()|0|le,(Ue|0)<(te|0))Z=P;else{j=ne;do Z=xn(7,0,(14-j|0)*3|0)|0,j=j+1|0,P=Z|P,T=_e()|0|T;while((j|0)<(Ue|0));Z=P}else Z=A,T=w;if(q=pn(Z|0,T|0,45)|0,_e()|0,!(nr(q&127)|0))P=0;else{q=pn(Z|0,T|0,52)|0,_e()|0,q=q&15;t:do if(!q)P=0;else for(j=1;;){if(P=pn(Z|0,T|0,(15-j|0)*3|0)|0,_e()|0,P=P&7,P|0)break t;if(j>>>0>>0)j=j+1|0;else{P=0;break}}while(!1);P=(P|0)==0&1}if(T=pn(A|0,w|0,(15-te|0)*3|0)|0,_e()|0,T=T&7,(T|0)==7){E=5,j=42;break}if(P=(P|0)!=0,(T|0)==1&P){E=5,j=42;break}if(Z=T+(((T|0)!=0&P)<<31>>31)|0,Z|0&&(j=Ue-te|0,j=Ua(7,0,j,((j|0)<0)<<31>>31)|0,q=_e()|0,P?(P=si(j|0,q|0,5,0)|0,P=Pn(P|0,_e()|0,-5,-1)|0,P=Qc(P|0,_e()|0,6,0)|0,P=Pn(P|0,_e()|0,1,0)|0,T=_e()|0):(P=j,T=q),te=Z+-1|0,te=si(j|0,q|0,te|0,((te|0)<0)<<31>>31|0)|0,te=Pn(P|0,T|0,te|0,_e()|0)|0,Z=_e()|0,q=N,q=Pn(te|0,Z|0,m[q>>2]|0,m[q+4>>2]|0)|0,Z=_e()|0,te=N,m[te>>2]=q,m[te+4>>2]=Z),(ne|0)<=(S|0)){j=37;break}}if((j|0)==19)Dt(27634,27225,1407,27259);else if((j|0)==37){D=N,E=m[D+4>>2]|0,D=m[D>>2]|0;break}else if((j|0)==42)return Re=we,E|0}else E=0,D=0}else j=33;while(!1);e:do if((j|0)==33)if(le=N,m[le>>2]=0,m[le+4>>2]=0,(Ue|0)>(S|0)){for(P=Ue;;){if(E=pn(A|0,w|0,(15-P|0)*3|0)|0,_e()|0,E=E&7,(E|0)==7){E=5;break}if(D=Ue-P|0,D=Ua(7,0,D,((D|0)<0)<<31>>31)|0,E=si(D|0,_e()|0,E|0,0)|0,D=_e()|0,le=N,D=Pn(m[le>>2]|0,m[le+4>>2]|0,E|0,D|0)|0,E=_e()|0,le=N,m[le>>2]=D,m[le+4>>2]=E,P=P+-1|0,(P|0)<=(S|0))break e}return Re=we,E|0}else E=0,D=0;while(!1);return Xs(xe,v,Ue,Ee)|0&&Dt(27634,27225,1367,27274),Ue=Ee,Ee=m[Ue+4>>2]|0,((E|0)>-1|(E|0)==-1&D>>>0>4294967295)&((Ee|0)>(E|0)|((Ee|0)==(E|0)?(m[Ue>>2]|0)>>>0>D>>>0:0))?(Ue=0,Re=we,Ue|0):(Dt(27634,27225,1447,27259),0)}function Sc(A,w,S,N,E,P){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0;var D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0;if(Z=Re,Re=Re+16|0,D=Z,E>>>0>15)return P=4,Re=Z,P|0;if(v=pn(S|0,N|0,52)|0,_e()|0,v=v&15,(v|0)>(E|0))return P=12,Re=Z,P|0;if(Xs(S,N,E,D)|0&&Dt(27634,27225,1367,27274),q=D,j=m[q+4>>2]|0,!(((w|0)>-1|(w|0)==-1&A>>>0>4294967295)&((j|0)>(w|0)|((j|0)==(w|0)?(m[q>>2]|0)>>>0>A>>>0:0))))return P=2,Re=Z,P|0;q=E-v|0,E=xn(E|0,0,52)|0,T=_e()|0|N&-15728641,j=P,m[j>>2]=E|S,m[j+4>>2]=T,j=pn(S|0,N|0,45)|0,_e()|0;e:do if(nr(j&127)|0){if(v|0)for(D=1;;){if(j=xn(7,0,(15-D|0)*3|0)|0,!((j&S|0)==0&((_e()|0)&N|0)==0))break e;if(D>>>0>>0)D=D+1|0;else break}if((q|0)<1)return P=0,Re=Z,P|0;for(j=v^15,N=-1,T=1,D=1;;){v=q-T|0,v=Ua(7,0,v,((v|0)<0)<<31>>31)|0,S=_e()|0;do if(D)if(D=si(v|0,S|0,5,0)|0,D=Pn(D|0,_e()|0,-5,-1)|0,D=Qc(D|0,_e()|0,6,0)|0,E=_e()|0,(w|0)>(E|0)|(w|0)==(E|0)&A>>>0>D>>>0){w=Pn(A|0,w|0,-1,-1)|0,w=ds(w|0,_e()|0,D|0,E|0)|0,D=_e()|0,te=P,le=m[te>>2]|0,te=m[te+4>>2]|0,xe=(j+N|0)*3|0,ne=xn(7,0,xe|0)|0,te=te&~(_e()|0),N=Qc(w|0,D|0,v|0,S|0)|0,A=_e()|0,E=Pn(N|0,A|0,2,0)|0,xe=xn(E|0,_e()|0,xe|0)|0,te=_e()|0|te,E=P,m[E>>2]=xe|le&~ne,m[E+4>>2]=te,A=si(N|0,A|0,v|0,S|0)|0,A=ds(w|0,D|0,A|0,_e()|0)|0,D=0,w=_e()|0;break}else{xe=P,ne=m[xe>>2]|0,xe=m[xe+4>>2]|0,le=xn(7,0,(j+N|0)*3|0)|0,xe=xe&~(_e()|0),D=P,m[D>>2]=ne&~le,m[D+4>>2]=xe,D=1;break}else ne=P,E=m[ne>>2]|0,ne=m[ne+4>>2]|0,N=(j+N|0)*3|0,te=xn(7,0,N|0)|0,ne=ne&~(_e()|0),xe=Qc(A|0,w|0,v|0,S|0)|0,D=_e()|0,N=xn(xe|0,D|0,N|0)|0,ne=_e()|0|ne,le=P,m[le>>2]=N|E&~te,m[le+4>>2]=ne,D=si(xe|0,D|0,v|0,S|0)|0,A=ds(A|0,w|0,D|0,_e()|0)|0,D=0,w=_e()|0;while(!1);if((q|0)>(T|0))N=~T,T=T+1|0;else{w=0;break}}return Re=Z,w|0}while(!1);if((q|0)<1)return xe=0,Re=Z,xe|0;for(E=v^15,D=1;;)if(le=q-D|0,le=Ua(7,0,le,((le|0)<0)<<31>>31)|0,xe=_e()|0,T=P,S=m[T>>2]|0,T=m[T+4>>2]|0,v=(E-D|0)*3|0,N=xn(7,0,v|0)|0,T=T&~(_e()|0),te=Qc(A|0,w|0,le|0,xe|0)|0,ne=_e()|0,v=xn(te|0,ne|0,v|0)|0,T=_e()|0|T,j=P,m[j>>2]=v|S&~N,m[j+4>>2]=T,xe=si(te|0,ne|0,le|0,xe|0)|0,A=ds(A|0,w|0,xe|0,_e()|0)|0,w=_e()|0,(q|0)<=(D|0)){w=0;break}else D=D+1|0;return Re=Z,w|0}function ec(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0;E=pn(w|0,S|0,52)|0,_e()|0,E=E&15,(w|0)==0&(S|0)==0|((N|0)>15|(E|0)>(N|0))?(P=-1,w=-1,S=0,E=0):(w=_c(w,S,E+1|0,N)|0,D=(_e()|0)&-15728641,S=xn(N|0,0,52)|0,S=w|S,D=D|(_e()|0),w=(Hr(S,D)|0)==0,P=E,w=w?-1:N,E=D),D=A,m[D>>2]=S,m[D+4>>2]=E,m[A+8>>2]=P,m[A+12>>2]=w}function mo(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0;if(E=pn(A|0,w|0,52)|0,_e()|0,E=E&15,P=N+8|0,m[P>>2]=E,(A|0)==0&(w|0)==0|((S|0)>15|(E|0)>(S|0))){S=N,m[S>>2]=0,m[S+4>>2]=0,m[P>>2]=-1,m[N+12>>2]=-1;return}if(A=_c(A,w,E+1|0,S)|0,P=(_e()|0)&-15728641,E=xn(S|0,0,52)|0,E=A|E,P=P|(_e()|0),A=N,m[A>>2]=E,m[A+4>>2]=P,A=N+12|0,Hr(E,P)|0){m[A>>2]=S;return}else{m[A>>2]=-1;return}}function fd(A){A=A|0;var w=0,S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0;if(S=A,w=m[S>>2]|0,S=m[S+4>>2]|0,!((w|0)==0&(S|0)==0)&&(N=pn(w|0,S|0,52)|0,_e()|0,N=N&15,v=xn(1,0,(N^15)*3|0)|0,w=Pn(v|0,_e()|0,w|0,S|0)|0,S=_e()|0,v=A,m[v>>2]=w,m[v+4>>2]=S,v=A+8|0,D=m[v>>2]|0,!((N|0)<(D|0)))){for(T=A+12|0,P=N;;){if((P|0)==(D|0)){N=5;break}if(j=(P|0)==(m[T>>2]|0),E=(15-P|0)*3|0,N=pn(w|0,S|0,E|0)|0,_e()|0,N=N&7,j&((N|0)==1&!0)){N=7;break}if(!((N|0)==7&!0)){N=10;break}if(j=xn(1,0,E|0)|0,w=Pn(w|0,S|0,j|0,_e()|0)|0,S=_e()|0,j=A,m[j>>2]=w,m[j+4>>2]=S,(P|0)>(D|0))P=P+-1|0;else{N=10;break}}if((N|0)==5){j=A,m[j>>2]=0,m[j+4>>2]=0,m[v>>2]=-1,m[T>>2]=-1;return}else if((N|0)==7){D=xn(1,0,E|0)|0,D=Pn(w|0,S|0,D|0,_e()|0)|0,v=_e()|0,j=A,m[j>>2]=D,m[j+4>>2]=v,m[T>>2]=P+-1;return}else if((N|0)==10)return}}function Ma(A){A=+A;var w=0;return w=A<0?A+6.283185307179586:A,+(A>=6.283185307179586?w+-6.283185307179586:w)}function Ui(A,w){switch(A=+A,w=w|0,w|0){case 1:{A=A<0?A+6.283185307179586:A;break}case 2:{A=A>0?A+-6.283185307179586:A;break}}return+A}function bl(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0;return E=+Ie[w>>3],N=+Ie[A>>3],P=+lr(+((E-N)*.5)),S=+lr(+((+Ie[w+8>>3]-+Ie[A+8>>3])*.5)),S=P*P+S*(+Hn(+E)*+Hn(+N)*S),+(+Pi(+ +Cn(+S),+ +Cn(+(1-S)))*2)}function ys(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0;return E=+Ie[w>>3],N=+Ie[A>>3],P=+lr(+((E-N)*.5)),S=+lr(+((+Ie[w+8>>3]-+Ie[A+8>>3])*.5)),S=P*P+S*(+Hn(+E)*+Hn(+N)*S),+(+Pi(+ +Cn(+S),+ +Cn(+(1-S)))*2*6371.007180918475)}function nl(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0;return E=+Ie[w>>3],N=+Ie[A>>3],P=+lr(+((E-N)*.5)),S=+lr(+((+Ie[w+8>>3]-+Ie[A+8>>3])*.5)),S=P*P+S*(+Hn(+E)*+Hn(+N)*S),+(+Pi(+ +Cn(+S),+ +Cn(+(1-S)))*2*6371.007180918475*1e3)}function _l(A,w){return A=A|0,w=w|0,A>>>0>15?(w=4,w|0):(Ie[w>>3]=+Ie[20624+(A<<3)>>3],w=0,w|0)}function Ro(A,w){return A=A|0,w=w|0,A>>>0>15?(w=4,w|0):(Ie[w>>3]=+Ie[20752+(A<<3)>>3],w=0,w|0)}function pd(A,w){return A=A|0,w=w|0,A>>>0>15?(w=4,w|0):(Ie[w>>3]=+Ie[20880+(A<<3)>>3],w=0,w|0)}function zl(A,w){return A=A|0,w=w|0,A>>>0>15?(w=4,w|0):(Ie[w>>3]=+Ie[21008+(A<<3)>>3],w=0,w|0)}function rl(A,w){A=A|0,w=w|0;var S=0;return A>>>0>15?(w=4,w|0):(S=Ua(7,0,A,((A|0)<0)<<31>>31)|0,S=si(S|0,_e()|0,120,0)|0,A=_e()|0,m[w>>2]=S|2,m[w+4>>2]=A,w=0,w|0)}function Tc(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;if(v=Re,Re=Re+176|0,D=v,A=vs(A,w,D)|0,A|0)return D=A,Re=v,D|0;if(Ie[S>>3]=0,A=m[D>>2]|0,(A|0)<=1)return D=0,Re=v,D|0;w=A+-1|0,A=0,N=+Ie[D+8>>3],E=+Ie[D+16>>3],P=0;do A=A+1|0,j=N,N=+Ie[D+8+(A<<4)>>3],q=+lr(+((N-j)*.5)),T=E,E=+Ie[D+8+(A<<4)+8>>3],T=+lr(+((E-T)*.5)),T=q*q+T*(+Hn(+N)*+Hn(+j)*T),P=P+ +Pi(+ +Cn(+T),+ +Cn(+(1-T)))*2;while((A|0)<(w|0));return Ie[S>>3]=P,D=0,Re=v,D|0}function Hi(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;if(v=Re,Re=Re+176|0,D=v,A=vs(A,w,D)|0,A|0)return D=A,P=+Ie[S>>3],P=P*6371.007180918475,Ie[S>>3]=P,Re=v,D|0;if(Ie[S>>3]=0,A=m[D>>2]|0,(A|0)<=1)return D=0,P=0,P=P*6371.007180918475,Ie[S>>3]=P,Re=v,D|0;w=A+-1|0,A=0,N=+Ie[D+8>>3],E=+Ie[D+16>>3],P=0;do A=A+1|0,j=N,N=+Ie[D+8+(A<<4)>>3],q=+lr(+((N-j)*.5)),T=E,E=+Ie[D+8+(A<<4)+8>>3],T=+lr(+((E-T)*.5)),T=q*q+T*(+Hn(+j)*+Hn(+N)*T),P=P+ +Pi(+ +Cn(+T),+ +Cn(+(1-T)))*2;while((A|0)!=(w|0));return Ie[S>>3]=P,D=0,q=P,q=q*6371.007180918475,Ie[S>>3]=q,Re=v,D|0}function tc(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;if(v=Re,Re=Re+176|0,D=v,A=vs(A,w,D)|0,A|0)return D=A,P=+Ie[S>>3],P=P*6371.007180918475,P=P*1e3,Ie[S>>3]=P,Re=v,D|0;if(Ie[S>>3]=0,A=m[D>>2]|0,(A|0)<=1)return D=0,P=0,P=P*6371.007180918475,P=P*1e3,Ie[S>>3]=P,Re=v,D|0;w=A+-1|0,A=0,N=+Ie[D+8>>3],E=+Ie[D+16>>3],P=0;do A=A+1|0,j=N,N=+Ie[D+8+(A<<4)>>3],q=+lr(+((N-j)*.5)),T=E,E=+Ie[D+8+(A<<4)+8>>3],T=+lr(+((E-T)*.5)),T=q*q+T*(+Hn(+j)*+Hn(+N)*T),P=P+ +Pi(+ +Cn(+T),+ +Cn(+(1-T)))*2;while((A|0)!=(w|0));return Ie[S>>3]=P,D=0,q=P,q=q*6371.007180918475,q=q*1e3,Ie[S>>3]=q,Re=v,D|0}function Eu(A){A=A|0;var w=0,S=0,N=0,E=0,P=0,D=0,v=0;if(A)for(P=A+4|0,D=A+8|0,N=1,E=A;;){if(w=m[E>>2]|0,w|0)do{if(S=m[w>>2]|0,S|0)do v=S,S=m[S+16>>2]|0,yn(v);while(S|0);v=w,w=m[w+8>>2]|0,yn(v)}while(w|0);if(w=E,E=m[E+8>>2]|0,N?(m[A>>2]=0,m[P>>2]=0,m[D>>2]=0):yn(w),E)N=0;else break}}function Zc(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0;if(m[w>>2]=0,Ee=w+4|0,m[Ee>>2]=0,Ue=w+8|0,m[Ue>>2]=0,xe=m[A>>2]|0,(xe|0)<=0)return w=0,w|0;le=A+4|0,A=w,ne=0;e:for(;;){if(ne){if(S=bs(1,12)|0,!S){S=5;break}m[A+8>>2]=S,A=S}if(T=m[le>>2]|0,j=bs(1,12)|0,!j){A=13,S=37;break}if(te=A+4|0,N=m[te>>2]|0,m[(N|0?N+8|0:A)>>2]=j,m[te>>2]=j,N=m[T+(ne<<4)>>2]|0,(N|0)<3){A=1,S=37;break}E=T+(ne<<4)+4|0,P=j+4|0,S=0,D=0;do{if(v=D,D=gi(24)|0,!D){A=13,S=37;break e}fp(D|0,(m[E>>2]|0)+(S<<4)|0,16)|0,m[D+16>>2]=0,v?m[v+16>>2]=D:m[j>>2]=D,m[P>>2]=D,S=S+1|0}while((S|0)<(N|0));if(Z=m[T+(ne<<4)+8>>2]|0,(Z|0)>0){q=T+(ne<<4)+12|0,T=0;do{if(N=m[q>>2]|0,S=j,j=bs(1,12)|0,!j){A=13,S=37;break e}if(m[S+8>>2]=j,m[te>>2]=j,v=m[N+(T<<3)>>2]|0,(v|0)<3){A=1,S=37;break e}N=N+(T<<3)+4|0,E=j+4|0,S=0,P=0;do{if(D=P,P=gi(24)|0,!P){A=13,S=37;break e}fp(P|0,(m[N>>2]|0)+(S<<4)|0,16)|0,m[P+16>>2]=0,D?m[D+16>>2]=P:m[j>>2]=P,m[E>>2]=P,S=S+1|0}while((S|0)<(v|0));T=T+1|0}while((T|0)<(Z|0))}if(ne=ne+1|0,(ne|0)>=(xe|0)){A=0,S=50;break}}if((S|0)==5){if(!w)return w=13,w|0;for(N=1,E=w;;){if(A=m[E>>2]|0,A|0)do{if(S=m[A>>2]|0,S|0)do xe=S,S=m[S+16>>2]|0,yn(xe);while(S|0);xe=A,A=m[A+8>>2]|0,yn(xe)}while(A|0);if(A=E,E=m[E+8>>2]|0,N?(m[w>>2]=0,m[Ee>>2]=0,m[Ue>>2]=0):yn(A),E)N=0;else{A=13;break}}return A|0}else if((S|0)==37){if(!w)return w=A,w|0;for(E=1,P=w;;){if(S=m[P>>2]|0,S|0)do{if(N=m[S>>2]|0,N|0)do xe=N,N=m[N+16>>2]|0,yn(xe);while(N|0);xe=S,S=m[S+8>>2]|0,yn(xe)}while(S|0);if(S=P,P=m[P+8>>2]|0,E?(m[w>>2]=0,m[Ee>>2]=0,m[Ue>>2]=0):yn(S),P)E=0;else break}return A|0}else if((S|0)==50)return A|0;return 0}function ua(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0;if(Ue=Re,Re=Re+16|0,Ee=Ue,q=pn(A|0,w|0,52)|0,_e()|0,q=q&15,ne=pn(S|0,N|0,52)|0,_e()|0,(q|0)!=(ne&15|0))return Ee=12,Re=Ue,Ee|0;if(T=pn(A|0,w|0,45)|0,_e()|0,T=T&127,j=pn(S|0,N|0,45)|0,_e()|0,j=j&127,T>>>0>121|j>>>0>121)return Ee=5,Re=Ue,Ee|0;if(ne=(T|0)!=(j|0),ne){if(D=Su(T,j)|0,(D|0)==7)return Ee=1,Re=Ue,Ee|0;v=Su(j,T)|0,(v|0)==7?Dt(27291,27315,164,27325):(xe=D,P=v)}else xe=0,P=0;Z=nr(T)|0,te=nr(j)|0,m[Ee>>2]=0,m[Ee+4>>2]=0,m[Ee+8>>2]=0,m[Ee+12>>2]=0;do if(xe){j=m[4272+(T*28|0)+(xe<<2)>>2]|0,D=(j|0)>0;e:do if(te)if(D)for(T=0,v=S,D=N;;){switch(v=Co(v,D)|0,D=_e()|0,P|0){case 5:case 1:{P=3;break}case 3:{P=2;break}case 2:{P=6;break}case 6:{P=4;break}case 4:{P=5;break}}if(T=T+1|0,(T|0)==(j|0)){j=P,T=v,v=D;break e}}else j=P,T=S,v=N;else if(D)for(T=0,v=S,D=N;;){switch(v=ms(v,D)|0,D=_e()|0,P|0){case 1:{P=3;break}case 3:{P=2;break}case 2:{P=6;break}case 6:{P=4;break}case 4:{P=5;break}case 5:{P=1;break}}if(T=T+1|0,(T|0)==(j|0)){j=P,T=v,v=D;break e}}else j=P,T=S,v=N;while(!1);if(Na(T,v,Ee)|0,ne||Dt(27340,27315,194,27325),D=(Z|0)!=0,P=(te|0)!=0,D&P&&Dt(27367,27315,195,27325),D){if(P=Li(A,w)|0,(P|0)==7){P=5;break}if(Nt[21968+(P*7|0)+xe>>0]|0){P=1;break}te=m[21136+(P*28|0)+(xe<<2)>>2]|0,ne=te}else if(P){if(P=Li(T,v)|0,(P|0)==7){P=5;break}if(Nt[21968+(P*7|0)+j>>0]|0){P=1;break}ne=0,te=m[21136+(j*28|0)+(P<<2)>>2]|0}else ne=0,te=0;if((ne|te|0)>=0){if((te|0)>0){S=Ee+4|0,N=Ee+8|0,Z=Ee+12|0,j=0,v=m[S>>2]|0,D=m[N>>2]|0,P=m[Z>>2]|0;do le=D+v|0,w=(le|0)<0,we=w?le:0,D=P+D-we|0,A=(D|0)<0,T=A?D:0,v=P+v-we-T|0,we=(v|0)<0,P=we?0:v,v=we?v:0,D=(A?0:D)-v|0,v=(w?0:le)-T-v|0,T=(D|0)<(v|0)?D:v,T=(P|0)<(T|0)?P:T,(T|0)>0&&(v=v-T|0,D=D-T|0,P=P-T|0),j=j+1|0;while((j|0)!=(te|0));m[S>>2]=v,m[N>>2]=D,m[Z>>2]=P}if((xe+-1|0)>>>0<6?(P=m[22032+(xe*12|0)>>2]|0,v=m[22032+(xe*12|0)+4>>2]|0,we=m[22032+(xe*12|0)+8>>2]|0,D=(v|0)<(P|0)?v:P,D=(we|0)<(D|0)?we:D,D=(D|0)>0?D:0,P=P-D|0,v=v-D|0,D=we-D|0):(P=0,v=0,D=0),q)for(;;)if(T=P*3|0,j=v*3|0,S=D*3|0,$r(q)|0?(w=T+v|0,A=(w|0)<0,we=j+D-(A?w:0)|0,le=(we|0)<0,v=P+S-(A?w:0)-(le?we:0)|0,D=(v|0)<0,xe=D?0:v,T=(le?0:we)-(D?v:0)|0,v=(A?0:w)-(le?we:0)-(D?v:0)|0,D=(T|0)<(v|0)?T:v,D=(xe|0)<(D|0)?xe:D,we=(D|0)>0,P=we?D:0,T=T-(we?D:0)|0,D=xe-(we?D:0)|0):(le=T+D|0,w=(le|0)<0,we=j+P-(w?le:0)|0,P=(we|0)<0,v=S+v-(w?le:0)-(P?we:0)|0,D=(v|0)<0,xe=D?0:v,T=(P?0:we)-(D?v:0)|0,v=(w?0:le)-(P?we:0)-(D?v:0)|0,D=(T|0)<(v|0)?T:v,D=(xe|0)<(D|0)?xe:D,we=(D|0)>0,P=we?D:0,T=T-(we?D:0)|0,D=xe-(we?D:0)|0),P=v-P|0,(q|0)>1)q=q+-1|0,v=T;else{v=T;break}if((ne|0)>0){T=0;do w=P+v|0,A=(w|0)<0,we=v+D-(A?w:0)|0,le=(we|0)<0,xe=P+D-(A?w:0)-(le?we:0)|0,P=(xe|0)<0,D=P?0:xe,v=(le?0:we)-(P?xe:0)|0,xe=(A?0:w)-(le?we:0)-(P?xe:0)|0,P=(v|0)<(xe|0)?v:xe,P=(D|0)<(P|0)?D:P,we=(P|0)>0,D=D-(we?P:0)|0,v=v-(we?P:0)|0,P=xe-(we?P:0)|0,T=T+1|0;while((T|0)!=(ne|0))}S=Ee+4|0,q=Ee+8|0,xe=m[q>>2]|0,N=Ee+12|0,we=m[N>>2]|0,T=(m[S>>2]|0)+P|0,m[S>>2]=T,v=xe+v|0,m[q>>2]=v,P=we+D|0,m[N>>2]=P,D=v-T|0,(T|0)<0?(P=P-T|0,m[q>>2]=D,m[N>>2]=P,m[S>>2]=0,v=0):(D=v,v=T),(D|0)<0&&(v=v-D|0,m[S>>2]=v,P=P-D|0,m[N>>2]=P,m[q>>2]=0,D=0),j=v-P|0,T=D-P|0,(P|0)<0?(m[S>>2]=j,m[q>>2]=T,m[N>>2]=0,v=j,P=0):T=D,D=(T|0)<(v|0)?T:v,D=(P|0)<(D|0)?P:D,(D|0)>0&&(m[S>>2]=v-D,m[q>>2]=T-D,m[N>>2]=P-D),le=77}else P=5}else if(Na(S,N,Ee)|0,(Z|0)!=0&(te|0)!=0)if((j|0)!=(T|0)&&Dt(27398,27315,264,27325),D=Li(A,w)|0,P=Li(S,N)|0,(D|0)==7|(P|0)==7)P=5;else if(Nt[21968+(D*7|0)+P>>0]|0)P=1;else if(S=m[21136+(D*28|0)+(P<<2)>>2]|0,(S|0)>0){q=Ee+4|0,N=Ee+8|0,Z=Ee+12|0,j=0,v=m[q>>2]|0,D=m[N>>2]|0,P=m[Z>>2]|0;do xe=D+v|0,le=(xe|0)<0,A=le?xe:0,D=P+D-A|0,w=(D|0)<0,T=w?D:0,v=P+v-A-T|0,A=(v|0)<0,P=A?0:v,v=A?v:0,D=(w?0:D)-v|0,v=(le?0:xe)-T-v|0,T=(D|0)<(v|0)?D:v,T=(P|0)<(T|0)?P:T,(T|0)>0&&(v=v-T|0,D=D-T|0,P=P-T|0),j=j+1|0;while((j|0)!=(S|0));m[q>>2]=v,m[N>>2]=D,m[Z>>2]=P,le=77}else le=77;else le=77;while(!1);return(le|0)==77&&(P=Ee+4|0,m[E>>2]=m[P>>2],m[E+4>>2]=m[P+4>>2],m[E+8>>2]=m[P+8>>2],P=0),we=P,Re=Ue,we|0}function da(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0;if(P=pn(A|0,w|0,52)|0,_e()|0,P=P&15,je=pn(A|0,w|0,45)|0,_e()|0,je=je&127,je>>>0>121)return N=5,N|0;if(Ee=nr(je)|0,xn(P|0,0,52)|0,v=_e()|0|134225919,D=N,m[D>>2]=-1,m[D+4>>2]=v,D=m[S>>2]|0,v=m[S+4>>2]|0,S=m[S+8>>2]|0,!P){w=(D|0)<0,Ue=w?D:0,ke=v-Ue|0,Ee=(ke|0)<0,Ue=(Ee?0-ke|0:0)+(S-Ue)|0,S=(Ue|0)<0,E=S?0:Ue,Ue=S?Ue:0,S=(Ee?0:ke)-Ue|0,Ue=(w?0:D)-(Ee?ke:0)-Ue|0,ke=(S|0)<(Ue|0)?S:Ue,ke=(E|0)<(ke|0)?E:ke,ke=(ke|0)>0?ke:0,E=E-ke|0,S=S-ke|0;e:do switch(Ue-ke|0){case 0:switch(S|0){case 0:if(E){E=(E|0)==1?1:7,we=11;break e}else{E=0;break e}case 1:if(E){E=(E|0)==1?3:7,we=11;break e}else{E=2;break e}default:return N=1,N|0}case 1:switch(S|0){case 0:if(E){E=(E|0)==1?5:7,we=11;break e}else{E=4;break e}case 1:{if(E)E=1;else{E=6;break e}return E|0}default:return N=1,N|0}default:return N=1,N|0}while(!1);return(we|0)==11&&(E|0)==7||(E=Jl(je,E)|0,(E|0)==127)?(N=1,N|0):(ke=xn(E|0,0,45)|0,je=_e()|0,we=N,je=m[we+4>>2]&-1040385|je,m[N>>2]=m[we>>2]|ke,m[N+4>>2]=je,N=0,N|0)}for(;;){if(xe=P,P=P+-1|0,le=D-S|0,ne=v-S|0,T=le>>>0>715827881|ne>>>0>715827881,$r(xe)|0){if(T){if(q=(le|0)>0,Z=2147483647-le|0,te=-2147483648-le|0,q?(Z|0)<(le|0):(te|0)>(le|0)){E=1,we=107;break}if(Ke=le<<1,q?(2147483647-Ke|0)<(le|0):(-2147483648-Ke|0)>(le|0)){E=1,we=107;break}if((ne|0)>0?(2147483647-ne|0)<(ne|0):(-2147483648-ne|0)>(ne|0)){E=1,we=107;break}if(T=le*3|0,j=ne<<1,(q?(Z|0)<(j|0):(te|0)>(j|0))||((le|0)>-1?(T|-2147483648|0)>=(ne|0):(T^-2147483648|0)<(ne|0))){E=1,we=107;break}}else T=le*3|0,j=ne<<1;if(Z=zr(+(T-ne|0)*.14285714285714285)|0,q=zr(+(j+le|0)*.14285714285714285)|0,j=(q|0)<(Z|0),T=j?Z:q,j=j?q:Z,(j|0)<0){if((j|0)==-2147483648||((T|0)>0?(2147483647-T|0)<(j|0):(-2147483648-T|0)>(j|0))){we=24;break}if((T|0)>-1?(T|-2147483648|0)>=(j|0):(T^-2147483648|0)<(j|0)){we=24;break}}te=(Z|0)<0,ne=q-(te?Z:0)|0,xt=(ne|0)<0,Je=(te?0-Z|0:0)-(xt?ne:0)|0,le=(Je|0)<0,te=(te?0:Z)-(xt?ne:0)-(le?Je:0)|0,ne=(xt?0:ne)-(le?Je:0)|0,Je=le?0:Je,le=(ne|0)<(te|0)?ne:te,le=(Je|0)<(le|0)?Je:le,xt=(le|0)>0,te=te-(xt?le:0)|0,ne=ne-(xt?le:0)|0,le=Je-(xt?le:0)|0,xt=(te*3|0)+ne|0,Je=(xt|0)<0,Ke=(ne*3|0)+le-(Je?xt:0)|0,T=(Ke|0)<0,Z=(le*3|0)+te-(Je?xt:0)-(T?Ke:0)|0,q=(Z|0)<0,Ye=q?0:Z,j=(T?0:Ke)-(q?Z:0)|0,Z=(Je?0:xt)-(T?Ke:0)-(q?Z:0)|0,q=(j|0)<(Z|0)?j:Z,q=(Ye|0)<(q|0)?Ye:q,Ke=(q|0)>0,T=Ke?q:0,j=j-(Ke?q:0)|0,q=Ye-(Ke?q:0)|0}else{if(T){if(j=(le|0)>0,j?(2147483647-le|0)<(le|0):(-2147483648-le|0)>(le|0)){E=1,we=107;break}if(T=le<<1,q=(ne|0)>0,q?(2147483647-ne|0)<(ne|0):(-2147483648-ne|0)>(ne|0)){E=1,we=107;break}if(te=ne<<1,q?(2147483647-te|0)<(ne|0):(-2147483648-te|0)>(ne|0)){E=1,we=107;break}if(j?(2147483647-T|0)<(ne|0):(-2147483648-T|0)>(ne|0)){E=1,we=107;break}if(j=ne*3|0,(ne|0)>-1?(j|-2147483648|0)>=(le|0):(j^-2147483648|0)<(le|0)){E=1,we=107;break}}else T=le<<1,j=ne*3|0;if(Z=zr(+(T+ne|0)*.14285714285714285)|0,q=zr(+(j-le|0)*.14285714285714285)|0,j=(q|0)<(Z|0),T=j?Z:q,j=j?q:Z,(j|0)<0){if((j|0)==-2147483648||((T|0)>0?(2147483647-T|0)<(j|0):(-2147483648-T|0)>(j|0))){we=36;break}if((T|0)>-1?(T|-2147483648|0)>=(j|0):(T^-2147483648|0)<(j|0)){we=36;break}}te=(Z|0)<0,ne=q-(te?Z:0)|0,Ye=(ne|0)<0,Ke=(te?0-Z|0:0)-(Ye?ne:0)|0,le=(Ke|0)<0,te=(te?0:Z)-(Ye?ne:0)-(le?Ke:0)|0,ne=(Ye?0:ne)-(le?Ke:0)|0,Ke=le?0:Ke,le=(ne|0)<(te|0)?ne:te,le=(Ke|0)<(le|0)?Ke:le,Ye=(le|0)>0,te=te-(Ye?le:0)|0,ne=ne-(Ye?le:0)|0,le=Ke-(Ye?le:0)|0,Ye=(te*3|0)+le|0,Ke=(Ye|0)<0,Je=(ne*3|0)+te-(Ke?Ye:0)|0,T=(Je|0)<0,Z=(le*3|0)+ne-(Ke?Ye:0)-(T?Je:0)|0,q=(Z|0)<0,xt=q?0:Z,j=(T?0:Je)-(q?Z:0)|0,Z=(Ke?0:Ye)-(T?Je:0)-(q?Z:0)|0,q=(j|0)<(Z|0)?j:Z,q=(xt|0)<(q|0)?xt:q,Je=(q|0)>0,T=Je?q:0,j=j-(Je?q:0)|0,q=xt-(Je?q:0)|0}T=D+(T-Z)|0,Ye=(T|0)<0,j=v-j-(Ye?T:0)|0,Z=(j|0)<0,Je=S-q+(Ye?0-T|0:0)+(Z?0-j|0:0)|0,D=(Je|0)<0,q=D?0:Je,Ke=(Z?0:j)-(D?Je:0)|0,Je=(Ye?0:T)-(Z?j:0)-(D?Je:0)|0,D=(Ke|0)<(Je|0)?Ke:Je,D=(q|0)<(D|0)?q:D,S=(D|0)>0,Je=Je-(S?D:0)|0,j=N,Z=m[j>>2]|0,j=m[j+4>>2]|0,v=(15-xe|0)*3|0,T=xn(7,0,v|0)|0,T=Z&~T,j=j&~(_e()|0),Z=(Je|0)<0,Ye=Z?Je:0,Ke=Ke-(S?D:0)-Ye|0,xt=(Ke|0)<0,Ye=(xt?0-Ke|0:0)+(q-(S?D:0)-Ye)|0,D=(Ye|0)<0,S=D?0:Ye,Ye=D?Ye:0,D=(xt?0:Ke)-Ye|0,Ye=(Z?0:Je)-(xt?Ke:0)-Ye|0,Ke=(D|0)<(Ye|0)?D:Ye,Ke=(S|0)<(Ke|0)?S:Ke,Ke=(Ke|0)>0?Ke:0,S=S-Ke|0,D=D-Ke|0;e:do switch(Ye-Ke|0){case 0:switch(D|0){case 0:{S=S|0?(S|0)==1?1:7:0;break e}case 1:{S=S|0?(S|0)==1?3:7:2;break e}default:{we=45;break e}}case 1:switch(D|0){case 0:{S=S|0?(S|0)==1?5:7:4;break e}case 1:if(S){we=45;break e}else{S=6;break e}default:{we=45;break e}}default:we=45}while(!1);if((we|0)==45&&(we=0,S=7),xt=xn(S|0,0,v|0)|0,Ye=_e()|0|j,Ke=N,m[Ke>>2]=xt|T,m[Ke+4>>2]=Ye,(xe|0)<=1){we=47;break}else D=te,v=ne,S=le}if((we|0)==24)Dt(27634,27425,416,27447);else if((we|0)==36)Dt(27634,27425,464,27461);else if((we|0)==47){if((te|0)>1|(ne|0)>1|(le|0)>1)return Ke=1,Ke|0;Je=(te|0)<0,Ye=Je?te:0,Ke=ne-Ye|0,xt=(Ke|0)<0,Ye=(xt?0-Ke|0:0)+(le-Ye)|0,P=(Ye|0)<0,S=P?0:Ye,Ye=P?Ye:0,P=(xt?0:Ke)-Ye|0,Ye=(Je?0:te)-(xt?Ke:0)-Ye|0,Ke=(P|0)<(Ye|0)?P:Ye,Ke=(S|0)<(Ke|0)?S:Ke,Ke=(Ke|0)>0?Ke:0,S=S-Ke|0,P=P-Ke|0;e:do switch(Ye-Ke|0){case 0:switch(P|0){case 0:{P=S|0?(S|0)==1?1:7:0;break e}case 1:{P=S|0?(S|0)==1?3:7:2;break e}default:{we=55;break e}}case 1:switch(P|0){case 0:{P=S|0?(S|0)==1?5:7:4;break e}case 1:if(S){we=55;break e}else{P=6;break e}default:{we=55;break e}}default:we=55}while(!1);(we|0)==55&&(P=7),v=Jl(je,P)|0,(v|0)==127?j=0:j=nr(v)|0;e:do if(P){if(Ee){if(S=Li(A,w)|0,(S|0)==7)return Ke=5,Ke|0;D=m[21344+(S*28|0)+(P<<2)>>2]|0;t:do if((D|0)>0)for(S=P,P=0;;){switch(S|0){case 1:{S=5;break}case 5:{S=4;break}case 4:{S=6;break}case 6:{S=2;break}case 2:{S=3;break}case 3:{S=1;break}}if(P=P+1|0,(P|0)==(D|0))break t}else S=P;while(!1);if((S|0)==1)return Ke=9,Ke|0;P=Jl(je,S)|0,(P|0)==127&&Dt(27476,27315,415,27506),nr(P)|0?Dt(27521,27315,416,27506):(E=P,ke=D,Ue=S)}else E=v,ke=0,Ue=P;if(T=m[4272+(je*28|0)+(Ue<<2)>>2]|0,(T|0)<=-1&&Dt(27552,27315,423,27506),!j){if((ke|0)<0)return Ke=5,Ke|0;if(ke|0){D=N,S=0,P=m[D>>2]|0,D=m[D+4>>2]|0;do P=yl(P,D)|0,D=_e()|0,Ke=N,m[Ke>>2]=P,m[Ke+4>>2]=D,S=S+1|0;while((S|0)<(ke|0))}if((T|0)<=0){we=104;break}for(D=N,S=0,P=m[D>>2]|0,D=m[D+4>>2]|0;;)if(P=yl(P,D)|0,D=_e()|0,Ke=N,m[Ke>>2]=P,m[Ke+4>>2]=D,S=S+1|0,(S|0)==(T|0)){we=104;break e}}if(v=Su(E,je)|0,(v|0)==7&&Dt(27291,27315,432,27506),S=N,P=m[S>>2]|0,S=m[S+4>>2]|0,(T|0)>0){D=0;do P=yl(P,S)|0,S=_e()|0,Ke=N,m[Ke>>2]=P,m[Ke+4>>2]=S,D=D+1|0;while((D|0)!=(T|0))}if(S=Li(P,S)|0,(S|0)==7&&Dt(27634,27315,444,27506),P=Hc(E)|0,P=m[(P?21760:21552)+(v*28|0)+(S<<2)>>2]|0,(P|0)<0&&Dt(27634,27315,458,27506),!P)we=104;else{v=N,S=0,D=m[v>>2]|0,v=m[v+4>>2]|0;do D=Xc(D,v)|0,v=_e()|0,Ke=N,m[Ke>>2]=D,m[Ke+4>>2]=v,S=S+1|0;while((S|0)<(P|0));we=104}}else if((Ee|0)!=0&(j|0)!=0){if(E=Li(A,w)|0,S=N,S=Li(m[S>>2]|0,m[S+4>>2]|0)|0,(E|0)==7|(S|0)==7||(S=m[21344+(E*28|0)+(S<<2)>>2]|0,(S|0)<0))return Ke=5,Ke|0;if(!S)E=v,we=105;else{D=N,E=0,P=m[D>>2]|0,D=m[D+4>>2]|0;do P=yl(P,D)|0,D=_e()|0,Ke=N,m[Ke>>2]=P,m[Ke+4>>2]=D,E=E+1|0;while((E|0)<(S|0));E=v,we=104}}else E=v,we=104;while(!1);return(we|0)==104&&j&&(we=105),(we|0)==105&&(Ke=N,(Li(m[Ke>>2]|0,m[Ke+4>>2]|0)|0)==1)?(Ke=9,Ke|0):(Ye=N,Je=m[Ye>>2]|0,Ye=m[Ye+4>>2]&-1040385,xt=xn(E|0,0,45)|0,Ye=Ye|(_e()|0),Ke=N,m[Ke>>2]=Je|xt,m[Ke+4>>2]=Ye,Ke=0,Ke|0)}else if((we|0)==107)return E|0;return 0}function ts(A,w,S,N,E,P){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0;var D=0,v=0;return v=Re,Re=Re+16|0,D=v,E|0?(D=15,Re=v,D|0):(A=ua(A,w,S,N,D)|0,A||(E=m[D+4>>2]|0,A=m[D+8>>2]|0,m[P>>2]=(m[D>>2]|0)-A,m[P+4>>2]=E-A,A=0),D=A,Re=v,D|0)}function Br(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0;return Z=Re,Re=Re+16|0,q=Z,N|0?(q=15,Re=Z,q|0):(v=m[S>>2]|0,D=m[S+4>>2]|0,m[q>>2]=v,T=q+4|0,m[T>>2]=D,j=q+8|0,m[j>>2]=0,S=(D|0)<(v|0),N=S?v:D,S=S?D:v,(S|0)<0?!((S|0)==-2147483648||((N|0)>0?(2147483647-N|0)<(S|0):(-2147483648-N|0)>(S|0)))&&!((N|0)>-1?(N|-2147483648|0)>=(S|0):(N^-2147483648|0)<(S|0))?P=5:N=1:P=5,(P|0)==5&&(N=D-v|0,P=0-v|0,(v|0)<0?(m[T>>2]=N,m[j>>2]=P,m[q>>2]=0,v=0):(N=D,P=0),D=v-N|0,S=P-N|0,(N|0)<0?(m[q>>2]=D,m[j>>2]=S,m[T>>2]=0,v=D,N=0):S=P,D=v-S|0,P=N-S|0,(S|0)<0?(m[q>>2]=D,m[T>>2]=P,m[j>>2]=0,S=0):(P=N,D=v),N=(P|0)<(D|0)?P:D,N=(S|0)<(N|0)?S:N,(N|0)>0&&(m[q>>2]=D-N,m[T>>2]=P-N,m[j>>2]=S-N),N=da(A,w,q,E)|0),q=N,Re=Z,q|0)}function xi(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0;return T=Re,Re=Re+32|0,D=T+12|0,v=T,P=ua(A,w,A,w,D)|0,P|0?(v=P,Re=T,v|0):(A=ua(A,w,S,N,v)|0,A|0?(v=A,Re=T,v|0):(A=(m[D>>2]|0)-(m[v>>2]|0)|0,j=(A|0)<0,N=j?0-A|0:0,S=N+((m[D+4>>2]|0)-(m[v+4>>2]|0))|0,w=(S|0)<0,N=(m[D+8>>2]|0)-(m[v+8>>2]|0)+N+(w?0-S|0:0)|0,P=(N|0)<0,D=P?0:N,N=P?N:0,P=(w?0:S)-N|0,N=(j?0:A)-(w?S:0)-N|0,v=(P|0)<(N|0)?P:N,v=(D|0)<(v|0)?D:v,v=(v|0)>0?v:0,D=D-v|0,P=P-v|0,v=N-v|0,v=(v|0)>-1?v:0-v|0,P=(P|0)>-1?P:0-P|0,D=(D|0)>-1?D:0-D|0,D=(P|0)>(D|0)?P:D,D=(v|0)>(D|0)?v:D,v=E,m[v>>2]=D,m[v+4>>2]=((D|0)<0)<<31>>31,v=0,Re=T,v|0))}function Jr(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0;return D=Re,Re=Re+16|0,P=D,A=xi(A,w,S,N,P)|0,A|0?(P=A,Re=D,P|0):(S=P,S=Pn(m[S>>2]|0,m[S+4>>2]|0,1,0)|0,N=_e()|0,P=E,m[P>>2]=S,m[P+4>>2]=N,P=0,Re=D,P|0)}function wl(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0;return T=Re,Re=Re+16|0,P=T,D=xi(A,w,S,N,P)|0,D|0?(E=D,Re=T,E|0):(D=P,P=m[D>>2]|0,D=m[D+4>>2]|0,(P|0)==0&(D|0)==0?(m[E>>2]=A,m[E+4>>2]=w,E=0,Re=T,E|0):(v=Nu(A,w,S,N,P,D,E,0,0,1,0)|0,v?(E=(Nu(S,N,A,w,P,D,E,P,D,-1,-1)|0)==0,E=E?0:v,Re=T,E|0):(E=0,Re=T,E|0)))}function Nu(A,w,S,N,E,P,D,v,T,j,q){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0,D=D|0,v=v|0,T=T|0,j=j|0,q=q|0;var Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0,kt=0,Rt=0,Wt=0,Kt=0;if(Wt=Re,Re=Re+48|0,Z=Wt+24|0,te=Wt+12|0,Rt=Wt,m[Z>>2]=0,m[Z+4>>2]=0,m[Z+8>>2]=0,m[te>>2]=0,m[te+4>>2]=0,m[te+8>>2]=0,ua(A,w,A,w,Z)|0&&Dt(27634,27315,696,27575),ua(A,w,S,N,te)|0&&Dt(27634,27315,701,27575),xe=Z+8|0,N=m[xe>>2]|0,S=N-(m[Z>>2]|0)|0,m[Z>>2]=S,kt=Z+4|0,N=(m[kt>>2]|0)-N|0,m[kt>>2]=N,kt=N+S|0,Z=0-kt|0,m[xe>>2]=Z,xe=te+8|0,we=m[xe>>2]|0,Ue=we-(m[te>>2]|0)|0,m[te>>2]=Ue,Ke=te+4|0,we=(m[Ke>>2]|0)-we|0,m[Ke>>2]=we,Ke=we+Ue|0,m[xe>>2]=0-Ke,Ye=1/(+(E>>>0)+4294967296*+(P|0)),Je=Ye*+(Ue-S|0),xt=Ye*+(we-N|0),Ye=Ye*+(kt-Ke|0),m[Rt>>2]=S,Ke=Rt+4|0,m[Ke>>2]=N,kt=Rt+8|0,m[kt>>2]=Z,(P|0)<0)return j=0,Re=Wt,j|0;for(je=+(S|0),ke=+(N|0),Ee=+(Z|0),Ue=0,we=0;;){if(le=+(Ue>>>0)+4294967296*+(we|0),Kt=Je*le+je,ne=xt*le+ke,le=Ye*le+Ee,N=~~+eo(+Kt),Z=~~+eo(+ne),S=~~+eo(+le),Kt=+Mn(+(+(N|0)-Kt)),ne=+Mn(+(+(Z|0)-ne)),le=+Mn(+(+(S|0)-le)),Kt>ne&Kt>le?(te=S+Z|0,N=0-te|0):(te=0-N|0,ne>le&&(Z=te-S|0)),m[Ke>>2]=Z,m[Rt>>2]=te,m[kt>>2]=0,S=N+Z|0,(N|0)>0?(m[Ke>>2]=S,m[kt>>2]=N,m[Rt>>2]=0,te=0):(S=Z,N=0),(S|0)<0?(Z=te-S|0,m[Rt>>2]=Z,N=N-S|0,m[kt>>2]=N,m[Ke>>2]=0,te=Z-N|0,S=0-N|0,(N|0)<0?(m[Rt>>2]=te,m[Ke>>2]=S,m[kt>>2]=0,xe=S,N=0):(xe=0,te=Z)):xe=S,S=(xe|0)<(te|0)?xe:te,S=(N|0)<(S|0)?N:S,(S|0)>0&&(m[Rt>>2]=te-S,m[Ke>>2]=xe-S,m[kt>>2]=N-S),S=si(Ue|0,we|0,j|0,q|0)|0,S=Pn(S|0,_e()|0,v|0,T|0)|0,_e()|0,S=da(A,w,Rt,D+(S<<3)|0)|0,S|0){N=20;break}if(xe=Ue,Ue=Pn(Ue|0,we|0,1,0)|0,te=we,we=_e()|0,!((te|0)<(P|0)|(te|0)==(P|0)&xe>>>0>>0)){S=0,N=20;break}}return(N|0)==20?(Re=Wt,S|0):0}function Ua(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0;if((S|0)==0&(N|0)==0)return E=0,P=1,wt(E|0),P|0;P=A,E=w,A=1,w=0;do D=(S&1|0)==0&!0,A=si((D?1:P)|0,(D?0:E)|0,A|0,w|0)|0,w=_e()|0,S=dp(S|0,N|0,1)|0,N=_e()|0,P=si(P|0,E|0,P|0,E|0)|0,E=_e()|0;while(!((S|0)==0&(N|0)==0));return wt(w|0),A|0}function xf(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0;v=Re,Re=Re+16|0,P=v,D=pn(A|0,w|0,52)|0,_e()|0,D=D&15;do if(D){if(E=Po(A,w,P)|0,!E){j=+Ie[P>>3],T=1/+Hn(+j),q=+Ie[26032+(D<<3)>>3],Ie[S>>3]=j+q,Ie[S+8>>3]=j-q,j=+Ie[P+8>>3],T=q*T,Ie[S+16>>3]=T+j,Ie[S+24>>3]=j-T;break}return D=E,Re=v,D|0}else{if(E=pn(A|0,w|0,45)|0,_e()|0,E=E&127,E>>>0>121)return D=5,Re=v,D|0;P=22128+(E<<5)|0,m[S>>2]=m[P>>2],m[S+4>>2]=m[P+4>>2],m[S+8>>2]=m[P+8>>2],m[S+12>>2]=m[P+12>>2],m[S+16>>2]=m[P+16>>2],m[S+20>>2]=m[P+20>>2],m[S+24>>2]=m[P+24>>2],m[S+28>>2]=m[P+28>>2];break}while(!1);return Qa(S,N?1.4:1.1),N=26160+(D<<3)|0,(m[N>>2]|0)==(A|0)&&(m[N+4>>2]|0)==(w|0)&&(Ie[S>>3]=1.5707963267948966),D=26288+(D<<3)|0,(m[D>>2]|0)==(A|0)&&(m[D+4>>2]|0)==(w|0)&&(Ie[S+8>>3]=-1.5707963267948966),+Ie[S>>3]!=1.5707963267948966&&+Ie[S+8>>3]!=-1.5707963267948966?(D=0,Re=v,D|0):(Ie[S+16>>3]=3.141592653589793,Ie[S+24>>3]=-3.141592653589793,D=0,Re=v,D|0)}function go(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0;j=Re,Re=Re+48|0,D=j+32|0,P=j+40|0,v=j,ps(D,0,0,0),T=m[D>>2]|0,D=m[D+4>>2]|0;do if(S>>>0<=15){if(E=gd(N)|0,E|0){N=v,m[N>>2]=0,m[N+4>>2]=0,m[v+8>>2]=E,m[v+12>>2]=-1,N=v+16|0,T=v+29|0,m[N>>2]=0,m[N+4>>2]=0,m[N+8>>2]=0,Nt[N+12>>0]=0,Nt[T>>0]=Nt[P>>0]|0,Nt[T+1>>0]=Nt[P+1>>0]|0,Nt[T+2>>0]=Nt[P+2>>0]|0;break}if(E=bs((m[w+8>>2]|0)+1|0,32)|0,E){Sl(w,E),q=v,m[q>>2]=T,m[q+4>>2]=D,m[v+8>>2]=0,m[v+12>>2]=S,m[v+16>>2]=N,m[v+20>>2]=w,m[v+24>>2]=E,Nt[v+28>>0]=0,T=v+29|0,Nt[T>>0]=Nt[P>>0]|0,Nt[T+1>>0]=Nt[P+1>>0]|0,Nt[T+2>>0]=Nt[P+2>>0]|0;break}else{N=v,m[N>>2]=0,m[N+4>>2]=0,m[v+8>>2]=13,m[v+12>>2]=-1,N=v+16|0,T=v+29|0,m[N>>2]=0,m[N+4>>2]=0,m[N+8>>2]=0,Nt[N+12>>0]=0,Nt[T>>0]=Nt[P>>0]|0,Nt[T+1>>0]=Nt[P+1>>0]|0,Nt[T+2>>0]=Nt[P+2>>0]|0;break}}else T=v,m[T>>2]=0,m[T+4>>2]=0,m[v+8>>2]=4,m[v+12>>2]=-1,T=v+16|0,q=v+29|0,m[T>>2]=0,m[T+4>>2]=0,m[T+8>>2]=0,Nt[T+12>>0]=0,Nt[q>>0]=Nt[P>>0]|0,Nt[q+1>>0]=Nt[P+1>>0]|0,Nt[q+2>>0]=Nt[P+2>>0]|0;while(!1);_h(v),m[A>>2]=m[v>>2],m[A+4>>2]=m[v+4>>2],m[A+8>>2]=m[v+8>>2],m[A+12>>2]=m[v+12>>2],m[A+16>>2]=m[v+16>>2],m[A+20>>2]=m[v+20>>2],m[A+24>>2]=m[v+24>>2],m[A+28>>2]=m[v+28>>2],Re=j}function _h(A){A=A|0;var w=0,S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0;if(je=Re,Re=Re+336|0,ne=je+168|0,le=je,N=A,S=m[N>>2]|0,N=m[N+4>>2]|0,(S|0)==0&(N|0)==0){Re=je;return}if(w=A+28|0,Nt[w>>0]|0?(S=md(S,N)|0,N=_e()|0):Nt[w>>0]=1,ke=A+20|0,!(m[m[ke>>2]>>2]|0)){w=A+24|0,S=m[w>>2]|0,S|0&&yn(S),we=A,m[we>>2]=0,m[we+4>>2]=0,m[A+8>>2]=0,m[ke>>2]=0,m[A+12>>2]=-1,m[A+16>>2]=0,m[w>>2]=0,Re=je;return}we=A+16|0,w=m[we>>2]|0,E=w&15;e:do if((S|0)==0&(N|0)==0)Ue=A+24|0;else{xe=A+12|0,Z=(E|0)==3,q=w&255,T=(E|1|0)==3,te=A+24|0,j=(E+-1|0)>>>0<3,D=(E|2|0)==3,v=le+8|0;t:for(;;){if(P=pn(S|0,N|0,52)|0,_e()|0,P=P&15,(P|0)==(m[xe>>2]|0)){switch(q&15){case 0:case 2:case 3:{if(E=Po(S,N,ne)|0,E|0){Ee=15;break t}if(vf(m[ke>>2]|0,m[te>>2]|0,ne)|0){Ee=19;break t}break}}if(T&&(E=m[(m[ke>>2]|0)+4>>2]|0,m[ne>>2]=m[E>>2],m[ne+4>>2]=m[E+4>>2],m[ne+8>>2]=m[E+8>>2],m[ne+12>>2]=m[E+12>>2],xl(26896,ne)|0)){if(wc(m[(m[ke>>2]|0)+4>>2]|0,P,le)|0){Ee=25;break}if(E=le,(m[E>>2]|0)==(S|0)&&(m[E+4>>2]|0)==(N|0)){Ee=29;break}}if(j){if(E=Ul(S,N,ne)|0,E|0){Ee=32;break}if(xf(S,N,le,0)|0){Ee=36;break}if(D&&u0(m[ke>>2]|0,m[te>>2]|0,ne,le)|0){Ee=42;break}if(T&&cp(m[ke>>2]|0,m[te>>2]|0,ne,le)|0){Ee=42;break}}if(Z){if(w=xf(S,N,ne,1)|0,E=m[te>>2]|0,w|0){Ee=45;break}if(Hs(E,ne)|0){if(Qo(le,ne),Zo(ne,m[te>>2]|0)|0){Ee=53;break}if(vf(m[ke>>2]|0,m[te>>2]|0,v)|0){Ee=53;break}if(cp(m[ke>>2]|0,m[te>>2]|0,le,ne)|0){Ee=53;break}}}}do if((P|0)<(m[xe>>2]|0)){if(w=xf(S,N,ne,1)|0,E=m[te>>2]|0,w|0){Ee=58;break t}if(!(Hs(E,ne)|0)){Ee=73;break}if(Zo(m[te>>2]|0,ne)|0&&(Qo(le,ne),u0(m[ke>>2]|0,m[te>>2]|0,le,ne)|0)){Ee=65;break t}if(S=Ba(S,N,P+1|0,le)|0,S|0){Ee=67;break t}N=le,S=m[N>>2]|0,N=m[N+4>>2]|0}else Ee=73;while(!1);if((Ee|0)==73&&(Ee=0,S=md(S,N)|0,N=_e()|0),(S|0)==0&(N|0)==0){Ue=te;break e}}switch(Ee|0){case 15:{w=m[te>>2]|0,w|0&&yn(w),Ee=A,m[Ee>>2]=0,m[Ee+4>>2]=0,m[ke>>2]=0,m[xe>>2]=-1,m[we>>2]=0,m[te>>2]=0,m[A+8>>2]=E,Ee=20;break}case 19:{m[A>>2]=S,m[A+4>>2]=N,Ee=20;break}case 25:{Dt(27634,27600,470,27611);break}case 29:{m[A>>2]=S,m[A+4>>2]=N,Re=je;return}case 32:{w=m[te>>2]|0,w|0&&yn(w),Ue=A,m[Ue>>2]=0,m[Ue+4>>2]=0,m[ke>>2]=0,m[xe>>2]=-1,m[we>>2]=0,m[te>>2]=0,m[A+8>>2]=E,Re=je;return}case 36:{Dt(27634,27600,493,27611);break}case 42:{m[A>>2]=S,m[A+4>>2]=N,Re=je;return}case 45:{E|0&&yn(E),Ee=A,m[Ee>>2]=0,m[Ee+4>>2]=0,m[ke>>2]=0,m[xe>>2]=-1,m[we>>2]=0,m[te>>2]=0,m[A+8>>2]=w,Ee=55;break}case 53:{m[A>>2]=S,m[A+4>>2]=N,Ee=55;break}case 58:{E|0&&yn(E),Ee=A,m[Ee>>2]=0,m[Ee+4>>2]=0,m[ke>>2]=0,m[xe>>2]=-1,m[we>>2]=0,m[te>>2]=0,m[A+8>>2]=w,Ee=71;break}case 65:{m[A>>2]=S,m[A+4>>2]=N,Ee=71;break}case 67:{w=m[te>>2]|0,w|0&&yn(w),Ue=A,m[Ue>>2]=0,m[Ue+4>>2]=0,m[ke>>2]=0,m[xe>>2]=-1,m[we>>2]=0,m[te>>2]=0,m[A+8>>2]=S,Re=je;return}}if((Ee|0)==20){Re=je;return}else if((Ee|0)==55){Re=je;return}else if((Ee|0)==71){Re=je;return}}while(!1);w=m[Ue>>2]|0,w|0&&yn(w),Ee=A,m[Ee>>2]=0,m[Ee+4>>2]=0,m[A+8>>2]=0,m[ke>>2]=0,m[A+12>>2]=-1,m[we>>2]=0,m[Ue>>2]=0,Re=je}function md(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0;Z=Re,Re=Re+16|0,q=Z,N=pn(A|0,w|0,52)|0,_e()|0,N=N&15,S=pn(A|0,w|0,45)|0,_e()|0;do if(N){for(;S=xn(N+4095|0,0,52)|0,E=_e()|0|w&-15728641,P=(15-N|0)*3|0,D=xn(7,0,P|0)|0,v=_e()|0,S=S|A|D,E=E|v,T=pn(A|0,w|0,P|0)|0,_e()|0,T=T&7,N=N+-1|0,!(T>>>0<6);)if(N)w=E,A=S;else{j=4;break}if((j|0)==4){S=pn(S|0,E|0,45)|0,_e()|0;break}return q=(T|0)==0&(Hr(S,E)|0)!=0,q=xn((q?2:1)+T|0,0,P|0)|0,j=_e()|0|w&~v,q=q|A&~D,wt(j|0),Re=Z,q|0}while(!1);return S=S&127,S>>>0>120?(j=0,q=0,wt(j|0),Re=Z,q|0):(ps(q,0,S+1|0,0),j=m[q+4>>2]|0,q=m[q>>2]|0,wt(j|0),Re=Z,q|0)}function lp(A,w,S,N,E,P){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0;var D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0;Ee=Re,Re=Re+160|0,Z=Ee+80|0,v=Ee+64|0,te=Ee+112|0,xe=Ee,go(Z,A,w,S),j=Z,ec(v,m[j>>2]|0,m[j+4>>2]|0,w),j=v,T=m[j>>2]|0,j=m[j+4>>2]|0,D=m[Z+8>>2]|0,ne=te+4|0,m[ne>>2]=m[Z>>2],m[ne+4>>2]=m[Z+4>>2],m[ne+8>>2]=m[Z+8>>2],m[ne+12>>2]=m[Z+12>>2],m[ne+16>>2]=m[Z+16>>2],m[ne+20>>2]=m[Z+20>>2],m[ne+24>>2]=m[Z+24>>2],m[ne+28>>2]=m[Z+28>>2],ne=xe,m[ne>>2]=T,m[ne+4>>2]=j,ne=xe+8|0,m[ne>>2]=D,A=xe+12|0,w=te,S=A+36|0;do m[A>>2]=m[w>>2],A=A+4|0,w=w+4|0;while((A|0)<(S|0));if(te=xe+48|0,m[te>>2]=m[v>>2],m[te+4>>2]=m[v+4>>2],m[te+8>>2]=m[v+8>>2],m[te+12>>2]=m[v+12>>2],(T|0)==0&(j|0)==0)return xe=D,Re=Ee,xe|0;S=xe+16|0,q=xe+24|0,Z=xe+28|0,D=0,v=0,w=T,A=j;do{if(!((D|0)<(E|0)|(D|0)==(E|0)&v>>>0>>0)){le=4;break}if(j=v,v=Pn(v|0,D|0,1,0)|0,D=_e()|0,j=P+(j<<3)|0,m[j>>2]=w,m[j+4>>2]=A,fd(te),A=te,w=m[A>>2]|0,A=m[A+4>>2]|0,(w|0)==0&(A|0)==0){if(_h(S),w=S,A=m[w>>2]|0,w=m[w+4>>2]|0,(A|0)==0&(w|0)==0){le=10;break}mo(A,w,m[Z>>2]|0,te),A=te,w=m[A>>2]|0,A=m[A+4>>2]|0}j=xe,m[j>>2]=w,m[j+4>>2]=A}while(!((w|0)==0&(A|0)==0));return(le|0)==4?(A=xe+40|0,w=m[A>>2]|0,w|0&&yn(w),le=xe+16|0,m[le>>2]=0,m[le+4>>2]=0,m[q>>2]=0,m[xe+36>>2]=0,m[Z>>2]=-1,m[xe+32>>2]=0,m[A>>2]=0,mo(0,0,0,te),m[xe>>2]=0,m[xe+4>>2]=0,m[ne>>2]=0,xe=14,Re=Ee,xe|0):((le|0)==10&&(m[xe>>2]=0,m[xe+4>>2]=0,m[ne>>2]=m[q>>2]),xe=m[ne>>2]|0,Re=Ee,xe|0)}function Ao(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0;if(Z=Re,Re=Re+48|0,T=Z+32|0,v=Z+40|0,j=Z,!(m[A>>2]|0))return q=N,m[q>>2]=0,m[q+4>>2]=0,q=0,Re=Z,q|0;ps(T,0,0,0),D=T,E=m[D>>2]|0,D=m[D+4>>2]|0;do if(w>>>0>15)q=j,m[q>>2]=0,m[q+4>>2]=0,m[j+8>>2]=4,m[j+12>>2]=-1,q=j+16|0,S=j+29|0,m[q>>2]=0,m[q+4>>2]=0,m[q+8>>2]=0,Nt[q+12>>0]=0,Nt[S>>0]=Nt[v>>0]|0,Nt[S+1>>0]=Nt[v+1>>0]|0,Nt[S+2>>0]=Nt[v+2>>0]|0,S=4,q=9;else{if(S=gd(S)|0,S|0){T=j,m[T>>2]=0,m[T+4>>2]=0,m[j+8>>2]=S,m[j+12>>2]=-1,T=j+16|0,q=j+29|0,m[T>>2]=0,m[T+4>>2]=0,m[T+8>>2]=0,Nt[T+12>>0]=0,Nt[q>>0]=Nt[v>>0]|0,Nt[q+1>>0]=Nt[v+1>>0]|0,Nt[q+2>>0]=Nt[v+2>>0]|0,q=9;break}if(S=bs((m[A+8>>2]|0)+1|0,32)|0,!S){q=j,m[q>>2]=0,m[q+4>>2]=0,m[j+8>>2]=13,m[j+12>>2]=-1,q=j+16|0,S=j+29|0,m[q>>2]=0,m[q+4>>2]=0,m[q+8>>2]=0,Nt[q+12>>0]=0,Nt[S>>0]=Nt[v>>0]|0,Nt[S+1>>0]=Nt[v+1>>0]|0,Nt[S+2>>0]=Nt[v+2>>0]|0,S=13,q=9;break}Sl(A,S),ne=j,m[ne>>2]=E,m[ne+4>>2]=D,D=j+8|0,m[D>>2]=0,m[j+12>>2]=w,m[j+20>>2]=A,m[j+24>>2]=S,Nt[j+28>>0]=0,E=j+29|0,Nt[E>>0]=Nt[v>>0]|0,Nt[E+1>>0]=Nt[v+1>>0]|0,Nt[E+2>>0]=Nt[v+2>>0]|0,m[j+16>>2]=3,te=+Fs(S),te=te*+$c(S),P=+Mn(+ +Ie[S>>3]),P=te/+Hn(+ +Io(+P,+ +Mn(+ +Ie[S+8>>3])))*6371.007180918475*6371.007180918475,E=j+12|0,S=m[E>>2]|0;e:do if((S|0)>0)do{if(_l(S+-1|0,T)|0,!(P/+Ie[T>>3]>10))break e;ne=m[E>>2]|0,S=ne+-1|0,m[E>>2]=S}while((ne|0)>1);while(!1);if(_h(j),E=N,m[E>>2]=0,m[E+4>>2]=0,E=j,S=m[E>>2]|0,E=m[E+4>>2]|0,!((S|0)==0&(E|0)==0))do Xs(S,E,w,T)|0,v=T,A=N,v=Pn(m[A>>2]|0,m[A+4>>2]|0,m[v>>2]|0,m[v+4>>2]|0)|0,A=_e()|0,ne=N,m[ne>>2]=v,m[ne+4>>2]=A,_h(j),ne=j,S=m[ne>>2]|0,E=m[ne+4>>2]|0;while(!((S|0)==0&(E|0)==0));S=m[D>>2]|0}while(!1);return ne=S,Re=Z,ne|0}function il(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0;if(!(xl(w,S)|0)||(w=Za(w)|0,N=+Ie[S>>3],E=+Ie[S+8>>3],E=w&E<0?E+6.283185307179586:E,te=m[A>>2]|0,(te|0)<=0))return te=0,te|0;if(Z=m[A+4>>2]|0,w){w=0,q=E,S=-1,A=0;e:for(;;){for(j=A;D=+Ie[Z+(j<<4)>>3],E=+Ie[Z+(j<<4)+8>>3],A=(S+2|0)%(te|0)|0,P=+Ie[Z+(A<<4)>>3],v=+Ie[Z+(A<<4)+8>>3],D>P?(T=D,D=v):(T=P,P=D,D=E,E=v),N=N==P|N==T?N+2220446049250313e-31:N,!!(NT);)if(S=j+1|0,(S|0)>=(te|0)){S=22;break e}else A=j,j=S,S=A;if(v=D<0?D+6.283185307179586:D,D=E<0?E+6.283185307179586:E,q=v==q|D==q?q+-2220446049250313e-31:q,T=v+(D-v)*((N-P)/(T-P)),(T<0?T+6.283185307179586:T)>q&&(w=w^1),A=j+1|0,(A|0)>=(te|0)){S=22;break}else S=j}if((S|0)==22)return w|0}else{w=0,q=E,S=-1,A=0;e:for(;;){for(j=A;D=+Ie[Z+(j<<4)>>3],E=+Ie[Z+(j<<4)+8>>3],A=(S+2|0)%(te|0)|0,P=+Ie[Z+(A<<4)>>3],v=+Ie[Z+(A<<4)+8>>3],D>P?(T=D,D=v):(T=P,P=D,D=E,E=v),N=N==P|N==T?N+2220446049250313e-31:N,!!(NT);)if(S=j+1|0,(S|0)>=(te|0)){S=22;break e}else A=j,j=S,S=A;if(q=D==q|E==q?q+-2220446049250313e-31:q,D+(E-D)*((N-P)/(T-P))>q&&(w=w^1),A=j+1|0,(A|0)>=(te|0)){S=22;break}else S=j}if((S|0)==22)return w|0}return 0}function Mu(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0;if(le=m[A>>2]|0,!le){m[w>>2]=0,m[w+4>>2]=0,m[w+8>>2]=0,m[w+12>>2]=0,m[w+16>>2]=0,m[w+20>>2]=0,m[w+24>>2]=0,m[w+28>>2]=0;return}if(xe=w+8|0,Ie[xe>>3]=17976931348623157e292,Ee=w+24|0,Ie[Ee>>3]=17976931348623157e292,Ie[w>>3]=-17976931348623157e292,Ue=w+16|0,Ie[Ue>>3]=-17976931348623157e292,!((le|0)<=0)){for(te=m[A+4>>2]|0,j=17976931348623157e292,q=-17976931348623157e292,Z=0,A=-1,P=17976931348623157e292,D=17976931348623157e292,T=-17976931348623157e292,N=-17976931348623157e292,ne=0;S=+Ie[te+(ne<<4)>>3],v=+Ie[te+(ne<<4)+8>>3],A=A+2|0,E=+Ie[te+(((A|0)==(le|0)?0:A)<<4)+8>>3],S>3]=S,P=S),v>3]=v,D=v),S>T?Ie[w>>3]=S:S=T,v>N&&(Ie[Ue>>3]=v,N=v),j=v>0&vq?v:q,Z=Z|+Mn(+(v-E))>3.141592653589793,A=ne+1|0,(A|0)!=(le|0);)we=ne,T=S,ne=A,A=we;Z&&(Ie[Ue>>3]=q,Ie[Ee>>3]=j)}}function gd(A){return A=A|0,(A>>>0<4?0:15)|0}function Sl(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0;if(le=m[A>>2]|0,le){if(xe=w+8|0,Ie[xe>>3]=17976931348623157e292,Ee=w+24|0,Ie[Ee>>3]=17976931348623157e292,Ie[w>>3]=-17976931348623157e292,Ue=w+16|0,Ie[Ue>>3]=-17976931348623157e292,(le|0)>0){for(E=m[A+4>>2]|0,te=17976931348623157e292,ne=-17976931348623157e292,N=0,S=-1,T=17976931348623157e292,j=17976931348623157e292,Z=-17976931348623157e292,D=-17976931348623157e292,we=0;P=+Ie[E+(we<<4)>>3],q=+Ie[E+(we<<4)+8>>3],xt=S+2|0,v=+Ie[E+(((xt|0)==(le|0)?0:xt)<<4)+8>>3],P>3]=P,T=P),q>3]=q,j=q),P>Z?Ie[w>>3]=P:P=Z,q>D&&(Ie[Ue>>3]=q,D=q),te=q>0&qne?q:ne,N=N|+Mn(+(q-v))>3.141592653589793,S=we+1|0,(S|0)!=(le|0);)xt=we,Z=P,we=S,S=xt;N&&(Ie[Ue>>3]=ne,Ie[Ee>>3]=te)}}else m[w>>2]=0,m[w+4>>2]=0,m[w+8>>2]=0,m[w+12>>2]=0,m[w+16>>2]=0,m[w+20>>2]=0,m[w+24>>2]=0,m[w+28>>2]=0;if(xt=A+8|0,S=m[xt>>2]|0,!((S|0)<=0)){Je=A+12|0,je=0;do if(E=m[Je>>2]|0,N=je,je=je+1|0,Ee=w+(je<<5)|0,Ue=m[E+(N<<3)>>2]|0,Ue){if(we=w+(je<<5)+8|0,Ie[we>>3]=17976931348623157e292,A=w+(je<<5)+24|0,Ie[A>>3]=17976931348623157e292,Ie[Ee>>3]=-17976931348623157e292,ke=w+(je<<5)+16|0,Ie[ke>>3]=-17976931348623157e292,(Ue|0)>0){for(le=m[E+(N<<3)+4>>2]|0,te=17976931348623157e292,ne=-17976931348623157e292,E=0,N=-1,xe=0,T=17976931348623157e292,j=17976931348623157e292,q=-17976931348623157e292,D=-17976931348623157e292;P=+Ie[le+(xe<<4)>>3],Z=+Ie[le+(xe<<4)+8>>3],N=N+2|0,v=+Ie[le+(((N|0)==(Ue|0)?0:N)<<4)+8>>3],P>3]=P,T=P),Z>3]=Z,j=Z),P>q?Ie[Ee>>3]=P:P=q,Z>D&&(Ie[ke>>3]=Z,D=Z),te=Z>0&Zne?Z:ne,E=E|+Mn(+(Z-v))>3.141592653589793,N=xe+1|0,(N|0)!=(Ue|0);)Ye=xe,xe=N,q=P,N=Ye;E&&(Ie[ke>>3]=ne,Ie[A>>3]=te)}}else m[Ee>>2]=0,m[Ee+4>>2]=0,m[Ee+8>>2]=0,m[Ee+12>>2]=0,m[Ee+16>>2]=0,m[Ee+20>>2]=0,m[Ee+24>>2]=0,m[Ee+28>>2]=0,S=m[xt>>2]|0;while((je|0)<(S|0))}}function vf(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0;if(!(il(A,w,S)|0))return E=0,E|0;if(E=A+8|0,(m[E>>2]|0)<=0)return E=1,E|0;for(N=A+12|0,A=0;;){if(P=A,A=A+1|0,il((m[N>>2]|0)+(P<<3)|0,w+(A<<5)|0,S)|0){A=0,N=6;break}if((A|0)>=(m[E>>2]|0)){A=1,N=6;break}}return(N|0)==6?A|0:0}function u0(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0;if(j=Re,Re=Re+16|0,v=j,D=S+8|0,!(il(A,w,D)|0))return T=0,Re=j,T|0;T=A+8|0;e:do if((m[T>>2]|0)>0){for(P=A+12|0,E=0;;){if(q=E,E=E+1|0,il((m[P>>2]|0)+(q<<3)|0,w+(E<<5)|0,D)|0){E=0;break}if((E|0)>=(m[T>>2]|0))break e}return Re=j,E|0}while(!1);if(Cu(A,w,S,N)|0)return q=0,Re=j,q|0;m[v>>2]=m[S>>2],m[v+4>>2]=D,E=m[T>>2]|0;e:do if((E|0)>0)for(A=A+12|0,D=0,P=E;;){if(E=m[A>>2]|0,(m[E+(D<<3)>>2]|0)>0){if(il(v,N,m[E+(D<<3)+4>>2]|0)|0){E=0;break e}if(E=D+1|0,Cu((m[A>>2]|0)+(D<<3)|0,w+(E<<5)|0,S,N)|0){E=0;break e}P=m[T>>2]|0}else E=D+1|0;if((E|0)<(P|0))D=E;else{E=1;break}}else E=1;while(!1);return q=E,Re=j,q|0}function Cu(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0,xt=0,Ye=0,Ke=0;if(xt=Re,Re=Re+176|0,we=xt+172|0,E=xt+168|0,ke=xt,!(Hs(w,N)|0))return A=0,Re=xt,A|0;if(fo(w,N,we,E),ql(ke|0,S|0,168)|0,(m[S>>2]|0)>0){w=0;do Ye=ke+8+(w<<4)+8|0,Ue=+Ui(+Ie[Ye>>3],m[E>>2]|0),Ie[Ye>>3]=Ue,w=w+1|0;while((w|0)<(m[S>>2]|0))}xe=+Ie[N>>3],Ee=+Ie[N+8>>3],Ue=+Ui(+Ie[N+16>>3],m[E>>2]|0),ne=+Ui(+Ie[N+24>>3],m[E>>2]|0);e:do if((m[A>>2]|0)>0){if(N=A+4|0,E=m[ke>>2]|0,(E|0)<=0){for(w=0;;)if(w=w+1|0,(w|0)>=(m[A>>2]|0)){w=0;break e}}for(S=0;;){if(w=m[N>>2]|0,te=+Ie[w+(S<<4)>>3],le=+Ui(+Ie[w+(S<<4)+8>>3],m[we>>2]|0),w=m[N>>2]|0,S=S+1|0,Ye=(S|0)%(m[A>>2]|0)|0,P=+Ie[w+(Ye<<4)>>3],D=+Ui(+Ie[w+(Ye<<4)+8>>3],m[we>>2]|0),!(te>=xe)|!(P>=xe)&&!(te<=Ee)|!(P<=Ee)&&!(le<=ne)|!(D<=ne)&&!(le>=Ue)|!(D>=Ue)){Z=P-te,j=D-le,w=0;do if(Ke=w,w=w+1|0,Ye=(w|0)==(E|0)?0:w,P=+Ie[ke+8+(Ke<<4)+8>>3],D=+Ie[ke+8+(Ye<<4)+8>>3]-P,v=+Ie[ke+8+(Ke<<4)>>3],T=+Ie[ke+8+(Ye<<4)>>3]-v,q=Z*D-j*T,q!=0&&(je=le-P,Je=te-v,T=(je*T-D*Je)/q,!(T<0|T>1))&&(q=(Z*je-j*Je)/q,q>=0&q<=1)){w=1;break e}while((w|0)<(E|0))}if((S|0)>=(m[A>>2]|0)){w=0;break}}}else w=0;while(!1);return Ke=w,Re=xt,Ke|0}function cp(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0;if(Cu(A,w,S,N)|0)return P=1,P|0;if(P=A+8|0,(m[P>>2]|0)<=0)return P=0,P|0;for(E=A+12|0,A=0;;){if(D=A,A=A+1|0,Cu((m[E>>2]|0)+(D<<3)|0,w+(A<<5)|0,S,N)|0){A=1,E=6;break}if((A|0)>=(m[P>>2]|0)){A=0,E=6;break}}return(E|0)==6?A|0:0}function wh(){return 8}function Ad(){return 16}function sl(){return 168}function Lo(){return 8}function d0(){return 16}function Gd(){return 12}function yf(){return 8}function Sh(A){return A=A|0,+(+((m[A>>2]|0)>>>0)+4294967296*+(m[A+4>>2]|0))}function xd(A){A=A|0;var w=0,S=0;return S=+Ie[A>>3],w=+Ie[A+8>>3],+ +Cn(+(S*S+w*w))}function bf(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0;j=+Ie[A>>3],T=+Ie[w>>3]-j,v=+Ie[A+8>>3],D=+Ie[w+8>>3]-v,Z=+Ie[S>>3],P=+Ie[N>>3]-Z,te=+Ie[S+8>>3],q=+Ie[N+8>>3]-te,P=(P*(v-te)-(j-Z)*q)/(T*q-D*P),Ie[E>>3]=j+T*P,Ie[E+8>>3]=v+D*P}function up(A,w){return A=A|0,w=w|0,+Mn(+(+Ie[A>>3]-+Ie[w>>3]))<11920928955078125e-23?(w=+Mn(+(+Ie[A+8>>3]-+Ie[w+8>>3]))<11920928955078125e-23,w|0):(w=0,w|0)}function h0(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0;if(P=Re,Re=Re+16|0,E=P,N=Hr(A,w)|0,(S+-1|0)>>>0>5||(N=(N|0)!=0,(S|0)==1&N))return E=-1,Re=P,E|0;do if(vd(A,w,E)|0)N=-1;else if(N){N=((m[26416+(S<<2)>>2]|0)+5-(m[E>>2]|0)|0)%5|0;break}else{N=((m[26448+(S<<2)>>2]|0)+6-(m[E>>2]|0)|0)%6|0;break}while(!1);return E=N,Re=P,E|0}function vd(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0;if(q=Re,Re=Re+32|0,v=q+16|0,T=q,N=po(A,w,v)|0,N|0)return S=N,Re=q,S|0;P=Ni(A,w)|0,j=Li(A,w)|0,Yo(P,T),N=es(P,m[v>>2]|0)|0;do if(nr(P)|0){do switch(P|0){case 4:{E=0;break}case 14:{E=1;break}case 24:{E=2;break}case 38:{E=3;break}case 49:{E=4;break}case 58:{E=5;break}case 63:{E=6;break}case 72:{E=7;break}case 83:{E=8;break}case 97:{E=9;break}case 107:{E=10;break}case 117:{E=11;break}default:Dt(27634,27636,75,27645)}while(!1);if(D=m[26480+(E*24|0)+8>>2]|0,w=m[26480+(E*24|0)+16>>2]|0,A=m[v>>2]|0,(A|0)!=(m[T>>2]|0)&&(T=Hc(P)|0,A=m[v>>2]|0,T|(A|0)==(w|0)&&(N=(N+1|0)%6|0)),(j|0)==3&(A|0)==(w|0)){N=(N+5|0)%6|0;break}(j|0)==5&(A|0)==(D|0)&&(N=(N+1|0)%6|0)}while(!1);return m[S>>2]=N,S=0,Re=q,S|0}function ko(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0;if(ke=Re,Re=Re+32|0,we=ke+24|0,Ee=ke+20|0,le=ke+8|0,ne=ke+16|0,te=ke,T=(Hr(A,w)|0)==0,T=T?6:5,q=pn(A|0,w|0,52)|0,_e()|0,q=q&15,T>>>0<=S>>>0)return N=2,Re=ke,N|0;Z=(q|0)==0,!Z&&(xe=xn(7,0,(q^15)*3|0)|0,(xe&A|0)==0&((_e()|0)&w|0)==0)?E=S:P=4;e:do if((P|0)==4){if(E=(Hr(A,w)|0)!=0,((E?4:5)|0)<(S|0)||vd(A,w,we)|0||(P=(m[we>>2]|0)+S|0,E?E=26768+(((P|0)%5|0)<<2)|0:E=26800+(((P|0)%6|0)<<2)|0,xe=m[E>>2]|0,(xe|0)==7))return N=1,Re=ke,N|0;m[Ee>>2]=0,E=sr(A,w,xe,Ee,le)|0;do if(!E){if(v=le,j=m[v>>2]|0,v=m[v+4>>2]|0,D=v>>>0>>0|(v|0)==(w|0)&j>>>0>>0,P=D?j:A,D=D?v:w,!Z&&(Z=xn(7,0,(q^15)*3|0)|0,(j&Z|0)==0&(v&(_e()|0)|0)==0))E=S;else{if(v=(S+-1+T|0)%(T|0)|0,E=Hr(A,w)|0,(v|0)<0&&Dt(27634,27636,248,27661),T=(E|0)!=0,((T?4:5)|0)<(v|0)&&Dt(27634,27636,248,27661),vd(A,w,we)|0&&Dt(27634,27636,248,27661),E=(m[we>>2]|0)+v|0,T?E=26768+(((E|0)%5|0)<<2)|0:E=26800+(((E|0)%6|0)<<2)|0,v=m[E>>2]|0,(v|0)==7&&Dt(27634,27636,248,27661),m[ne>>2]=0,E=sr(A,w,v,ne,te)|0,E|0)break;j=te,T=m[j>>2]|0,j=m[j+4>>2]|0;do if(j>>>0>>0|(j|0)==(D|0)&T>>>0

>>0){if(Hr(T,j)|0?P=js(T,j,A,w)|0:P=m[26864+((((m[ne>>2]|0)+(m[26832+(v<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,E=Hr(T,j)|0,(P+-1|0)>>>0>5){E=-1,P=T,D=j;break}if(E=(E|0)!=0,(P|0)==1&E){E=-1,P=T,D=j;break}do if(vd(T,j,we)|0)E=-1;else if(E){E=((m[26416+(P<<2)>>2]|0)+5-(m[we>>2]|0)|0)%5|0;break}else{E=((m[26448+(P<<2)>>2]|0)+6-(m[we>>2]|0)|0)%6|0;break}while(!1);P=T,D=j}else E=S;while(!1);v=le,j=m[v>>2]|0,v=m[v+4>>2]|0}if((P|0)==(j|0)&(D|0)==(v|0)){if(T=(Hr(j,v)|0)!=0,T?A=js(j,v,A,w)|0:A=m[26864+((((m[Ee>>2]|0)+(m[26832+(xe<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,E=Hr(j,v)|0,(A+-1|0)>>>0<=5&&(Ue=(E|0)!=0,!((A|0)==1&Ue)))do if(vd(j,v,we)|0)E=-1;else if(Ue){E=((m[26416+(A<<2)>>2]|0)+5-(m[we>>2]|0)|0)%5|0;break}else{E=((m[26448+(A<<2)>>2]|0)+6-(m[we>>2]|0)|0)%6|0;break}while(!1);else E=-1;E=E+1|0,E=(E|0)==6|T&(E|0)==5?0:E}w=D,A=P;break e}while(!1);return N=E,Re=ke,N|0}while(!1);return Ue=xn(E|0,0,56)|0,we=_e()|0|w&-2130706433|536870912,m[N>>2]=Ue|A,m[N+4>>2]=we,N=0,Re=ke,N|0}function b(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0;return P=(Hr(A,w)|0)==0,N=ko(A,w,0,S)|0,E=(N|0)==0,P?!E||(N=ko(A,w,1,S+8|0)|0,N|0)||(N=ko(A,w,2,S+16|0)|0,N|0)||(N=ko(A,w,3,S+24|0)|0,N|0)||(N=ko(A,w,4,S+32|0)|0,N)?(P=N,P|0):ko(A,w,5,S+40|0)|0:!E||(N=ko(A,w,1,S+8|0)|0,N|0)||(N=ko(A,w,2,S+16|0)|0,N|0)||(N=ko(A,w,3,S+24|0)|0,N|0)||(N=ko(A,w,4,S+32|0)|0,N|0)?(P=N,P|0):(P=S+40|0,m[P>>2]=0,m[P+4>>2]=0,P=0,P|0)}function F(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0,T=0;return T=Re,Re=Re+192|0,E=T,P=T+168|0,D=pn(A|0,w|0,56)|0,_e()|0,D=D&7,v=w&-2130706433|134217728,N=po(A,v,P)|0,N|0?(v=N,Re=T,v|0):(w=pn(A|0,w|0,52)|0,_e()|0,w=w&15,Hr(A,v)|0?qt(P,w,D,1,E):ar(P,w,D,1,E),v=E+8|0,m[S>>2]=m[v>>2],m[S+4>>2]=m[v+4>>2],m[S+8>>2]=m[v+8>>2],m[S+12>>2]=m[v+12>>2],v=0,Re=T,v|0)}function X(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0;return E=Re,Re=Re+16|0,S=E,!(!0&(w&2013265920|0)==536870912)||(N=w&-2130706433|134217728,!(Fi(A,N)|0))?(N=0,Re=E,N|0):(P=pn(A|0,w|0,56)|0,_e()|0,P=(ko(A,N,P&7,S)|0)==0,N=S,N=P&((m[N>>2]|0)==(A|0)?(m[N+4>>2]|0)==(w|0):0)&1,Re=E,N|0)}function he(){return 27680}function Me(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0;Z=Re,Re=Re+208|0,T=Z,j=Z+192|0,D=cs(S,w)|0,v=j,m[v>>2]=1,m[v+4>>2]=0;e:do if(D|0){for(v=0-S|0,m[T+4>>2]=S,m[T>>2]=S,E=2,w=S,P=S;w=w+S+P|0,m[T+(E<<2)>>2]=w,w>>>0>>0;)te=P,E=E+1|0,P=w,w=te;if(P=A+D+v|0,P>>>0>A>>>0){D=P,E=1,w=1;do{do if((w&3|0)!=3)if(w=E+-1|0,(m[T+(w<<2)>>2]|0)>>>0<(D-A|0)>>>0?He(A,S,N,E,T):Jt(A,S,N,j,E,0,T),(E|0)==1){rn(j,1),E=0;break}else{rn(j,w),E=1;break}else He(A,S,N,E,T),Mt(j,2),E=E+2|0;while(!1);w=m[j>>2]|1,m[j>>2]=w,A=A+S|0}while(A>>>0

>>0)}else E=1,w=1;for(Jt(A,S,N,j,E,0,T),P=j+4|0;;){if((E|0)==1&(w|0)==1)if(m[P>>2]|0)q=19;else break e;else(E|0)<2?q=19:(rn(j,2),te=E+-2|0,m[j>>2]=m[j>>2]^7,Mt(j,1),Jt(A+(0-(m[T+(te<<2)>>2]|0))+v|0,S,N,j,E+-1|0,1,T),rn(j,1),w=m[j>>2]|1,m[j>>2]=w,A=A+v|0,Jt(A,S,N,j,te,1,T),E=te);(q|0)==19&&(q=0,w=_n(j)|0,Mt(j,w),A=A+v|0,E=w+E|0,w=m[j>>2]|0)}}while(!1);Re=Z}function He(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0;Z=Re,Re=Re+240|0,q=Z,m[q>>2]=A;e:do if((N|0)>1)for(j=0-w|0,v=A,P=N,N=1,D=A;;){if(v=v+j|0,T=P+-2|0,A=v+(0-(m[E+(T<<2)>>2]|0))|0,(Hd[S&3](D,A)|0)>-1&&(Hd[S&3](D,v)|0)>-1||(D=q+(N<<2)|0,(Hd[S&3](A,v)|0)>-1?(m[D>>2]=A,P=P+-1|0):(m[D>>2]=v,A=v,P=T),N=N+1|0,(P|0)<=1))break e;v=A,D=m[q>>2]|0}else N=1;while(!1);wr(w,q,N),Re=Z}function Mt(A,w){A=A|0,w=w|0;var S=0,N=0,E=0;E=A+4|0,w>>>0>31?(N=m[E>>2]|0,m[A>>2]=N,m[E>>2]=0,w=w+-32|0,S=0):(S=m[E>>2]|0,N=m[A>>2]|0),m[A>>2]=S<<32-w|N>>>w,m[E>>2]=S>>>w}function Jt(A,w,S,N,E,P,D){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0,P=P|0,D=D|0;var v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0;ne=Re,Re=Re+240|0,Z=ne+232|0,te=ne,le=m[N>>2]|0,m[Z>>2]=le,T=m[N+4>>2]|0,j=Z+4|0,m[j>>2]=T,m[te>>2]=A;e:do if((le|0)!=1|(T|0)!=0&&(q=0-w|0,v=A+(0-(m[D+(E<<2)>>2]|0))|0,(Hd[S&3](v,A)|0)>=1))for(N=1,P=(P|0)==0,T=v;;){if(P&(E|0)>1){if(P=A+q|0,v=m[D+(E+-2<<2)>>2]|0,(Hd[S&3](P,T)|0)>-1){v=10;break e}if((Hd[S&3](P+(0-v)|0,T)|0)>-1){v=10;break e}}if(P=N+1|0,m[te+(N<<2)>>2]=T,le=_n(Z)|0,Mt(Z,le),E=le+E|0,!((m[Z>>2]|0)!=1|(m[j>>2]|0)!=0)){N=P,A=T,v=10;break e}if(A=T+(0-(m[D+(E<<2)>>2]|0))|0,(Hd[S&3](A,m[te>>2]|0)|0)<1){A=T,N=P,P=0,v=9;break}else le=T,N=P,P=1,T=A,A=le}else N=1,v=9;while(!1);(v|0)==9&&!(P|0)&&(v=10),(v|0)==10&&(wr(w,te,N),He(A,w,S,E,D)),Re=ne}function rn(A,w){A=A|0,w=w|0;var S=0,N=0,E=0;E=A+4|0,w>>>0>31?(N=m[A>>2]|0,m[E>>2]=N,m[A>>2]=0,w=w+-32|0,S=0):(S=m[A>>2]|0,N=m[E>>2]|0),m[E>>2]=S>>>(32-w|0)|N<>2]=S<>2]|0)+-1|0)|0,w?w|0:(w=Xn(m[A+4>>2]|0)|0,(w|0?w+32|0:0)|0)}function Xn(A){A=A|0;var w=0;if(A)if(A&1)A=0;else for(w=A,A=0;A=A+1|0,!(w&2);)w=w>>>1;else A=32;return A|0}function wr(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0,v=0;D=Re,Re=Re+256|0,N=D;e:do if((S|0)>=2&&(P=w+(S<<2)|0,m[P>>2]=N,A|0))for(;;){E=A>>>0<256?A:256,ql(N|0,m[w>>2]|0,E|0)|0,N=0;do v=w+(N<<2)|0,N=N+1|0,ql(m[v>>2]|0,m[w+(N<<2)>>2]|0,E|0)|0,m[v>>2]=(m[v>>2]|0)+E;while((N|0)!=(S|0));if(A=A-E|0,!A)break e;N=m[P>>2]|0}while(!1);Re=D}function zr(A){return A=+A,~~+l1(+A)|0}function gi(A){A=A|0;var w=0,S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0,xe=0,Ee=0,Ue=0,we=0,ke=0,je=0,Je=0;Je=Re,Re=Re+16|0,te=Je;do if(A>>>0<245){if(j=A>>>0<11?16:A+11&-8,A=j>>>3,Z=m[6921]|0,S=Z>>>A,S&3|0)return w=(S&1^1)+A|0,A=27724+(w<<1<<2)|0,S=A+8|0,N=m[S>>2]|0,E=N+8|0,P=m[E>>2]|0,(P|0)==(A|0)?m[6921]=Z&~(1<>2]=A,m[S>>2]=P),je=w<<3,m[N+4>>2]=je|3,je=N+je+4|0,m[je>>2]=m[je>>2]|1,je=E,Re=Je,je|0;if(q=m[6923]|0,j>>>0>q>>>0){if(S|0)return w=2<>>12&16,w=w>>>v,S=w>>>5&8,w=w>>>S,P=w>>>2&4,w=w>>>P,A=w>>>1&2,w=w>>>A,N=w>>>1&1,N=(S|v|P|A|N)+(w>>>N)|0,w=27724+(N<<1<<2)|0,A=w+8|0,P=m[A>>2]|0,v=P+8|0,S=m[v>>2]|0,(S|0)==(w|0)?(A=Z&~(1<>2]=w,m[A>>2]=S,A=Z),je=N<<3,D=je-j|0,m[P+4>>2]=j|3,E=P+j|0,m[E+4>>2]=D|1,m[P+je>>2]=D,q|0&&(N=m[6926]|0,w=q>>>3,S=27724+(w<<1<<2)|0,w=1<>2]|0):(m[6921]=A|w,w=S,A=S+8|0),m[A>>2]=N,m[w+12>>2]=N,m[N+8>>2]=w,m[N+12>>2]=S),m[6923]=D,m[6926]=E,je=v,Re=Je,je|0;if(P=m[6922]|0,P){for(S=(P&0-P)+-1|0,E=S>>>12&16,S=S>>>E,N=S>>>5&8,S=S>>>N,D=S>>>2&4,S=S>>>D,v=S>>>1&2,S=S>>>v,T=S>>>1&1,T=m[27988+((N|E|D|v|T)+(S>>>T)<<2)>>2]|0,S=T,v=T,T=(m[T+4>>2]&-8)-j|0;A=m[S+16>>2]|0,!(!A&&(A=m[S+20>>2]|0,!A));)D=(m[A+4>>2]&-8)-j|0,E=D>>>0>>0,S=A,v=E?A:v,T=E?D:T;if(D=v+j|0,D>>>0>v>>>0){E=m[v+24>>2]|0,w=m[v+12>>2]|0;do if((w|0)==(v|0)){if(A=v+20|0,w=m[A>>2]|0,!w&&(A=v+16|0,w=m[A>>2]|0,!w)){S=0;break}for(;;)if(N=w+20|0,S=m[N>>2]|0,S)w=S,A=N;else if(N=w+16|0,S=m[N>>2]|0,S)w=S,A=N;else break;m[A>>2]=0,S=w}else S=m[v+8>>2]|0,m[S+12>>2]=w,m[w+8>>2]=S,S=w;while(!1);do if(E|0){if(w=m[v+28>>2]|0,A=27988+(w<<2)|0,(v|0)==(m[A>>2]|0)){if(m[A>>2]=S,!S){m[6922]=P&~(1<>2]|0)==(v|0)?je:E+20|0)>>2]=S,!S)break;m[S+24>>2]=E,w=m[v+16>>2]|0,w|0&&(m[S+16>>2]=w,m[w+24>>2]=S),w=m[v+20>>2]|0,w|0&&(m[S+20>>2]=w,m[w+24>>2]=S)}while(!1);return T>>>0<16?(je=T+j|0,m[v+4>>2]=je|3,je=v+je+4|0,m[je>>2]=m[je>>2]|1):(m[v+4>>2]=j|3,m[D+4>>2]=T|1,m[D+T>>2]=T,q|0&&(N=m[6926]|0,w=q>>>3,S=27724+(w<<1<<2)|0,w=1<>2]|0):(m[6921]=w|Z,w=S,A=S+8|0),m[A>>2]=N,m[w+12>>2]=N,m[N+8>>2]=w,m[N+12>>2]=S),m[6923]=T,m[6926]=D),je=v+8|0,Re=Je,je|0}else Z=j}else Z=j}else Z=j}else if(A>>>0<=4294967231)if(A=A+11|0,j=A&-8,N=m[6922]|0,N){E=0-j|0,A=A>>>8,A?j>>>0>16777215?T=31:(Z=(A+1048320|0)>>>16&8,xe=A<>>16&4,xe=xe<>>16&2,T=14-(v|Z|T)+(xe<>>15)|0,T=j>>>(T+7|0)&1|T<<1):T=0,S=m[27988+(T<<2)>>2]|0;e:do if(!S)S=0,A=0,xe=61;else for(A=0,v=j<<((T|0)==31?0:25-(T>>>1)|0),P=0;;){if(D=(m[S+4>>2]&-8)-j|0,D>>>0>>0)if(D)A=S,E=D;else{A=S,E=0,xe=65;break e}if(xe=m[S+20>>2]|0,S=m[S+16+(v>>>31<<2)>>2]|0,P=(xe|0)==0|(xe|0)==(S|0)?P:xe,S)v=v<<1;else{S=P,xe=61;break}}while(!1);if((xe|0)==61){if((S|0)==0&(A|0)==0){if(A=2<>>12&16,Z=Z>>>D,P=Z>>>5&8,Z=Z>>>P,v=Z>>>2&4,Z=Z>>>v,T=Z>>>1&2,Z=Z>>>T,S=Z>>>1&1,A=0,S=m[27988+((P|D|v|T|S)+(Z>>>S)<<2)>>2]|0}S?xe=65:(v=A,D=E)}if((xe|0)==65)for(P=S;;)if(Z=(m[P+4>>2]&-8)-j|0,S=Z>>>0>>0,E=S?Z:E,A=S?P:A,S=m[P+16>>2]|0,S||(S=m[P+20>>2]|0),S)P=S;else{v=A,D=E;break}if(v|0&&D>>>0<((m[6923]|0)-j|0)>>>0&&(q=v+j|0,q>>>0>v>>>0)){P=m[v+24>>2]|0,w=m[v+12>>2]|0;do if((w|0)==(v|0)){if(A=v+20|0,w=m[A>>2]|0,!w&&(A=v+16|0,w=m[A>>2]|0,!w)){w=0;break}for(;;)if(E=w+20|0,S=m[E>>2]|0,S)w=S,A=E;else if(E=w+16|0,S=m[E>>2]|0,S)w=S,A=E;else break;m[A>>2]=0}else je=m[v+8>>2]|0,m[je+12>>2]=w,m[w+8>>2]=je;while(!1);do if(P){if(A=m[v+28>>2]|0,S=27988+(A<<2)|0,(v|0)==(m[S>>2]|0)){if(m[S>>2]=w,!w){N=N&~(1<>2]|0)==(v|0)?je:P+20|0)>>2]=w,!w)break;m[w+24>>2]=P,A=m[v+16>>2]|0,A|0&&(m[w+16>>2]=A,m[A+24>>2]=w),A=m[v+20>>2]|0,A&&(m[w+20>>2]=A,m[A+24>>2]=w)}while(!1);e:do if(D>>>0<16)je=D+j|0,m[v+4>>2]=je|3,je=v+je+4|0,m[je>>2]=m[je>>2]|1;else{if(m[v+4>>2]=j|3,m[q+4>>2]=D|1,m[q+D>>2]=D,w=D>>>3,D>>>0<256){S=27724+(w<<1<<2)|0,A=m[6921]|0,w=1<>2]|0):(m[6921]=A|w,w=S,A=S+8|0),m[A>>2]=q,m[w+12>>2]=q,m[q+8>>2]=w,m[q+12>>2]=S;break}if(w=D>>>8,w?D>>>0>16777215?S=31:(ke=(w+1048320|0)>>>16&8,je=w<>>16&4,je=je<>>16&2,S=14-(we|ke|S)+(je<>>15)|0,S=D>>>(S+7|0)&1|S<<1):S=0,w=27988+(S<<2)|0,m[q+28>>2]=S,A=q+16|0,m[A+4>>2]=0,m[A>>2]=0,A=1<>2]=q,m[q+24>>2]=w,m[q+12>>2]=q,m[q+8>>2]=q;break}w=m[w>>2]|0;t:do if((m[w+4>>2]&-8|0)!=(D|0)){for(N=D<<((S|0)==31?0:25-(S>>>1)|0);S=w+16+(N>>>31<<2)|0,A=m[S>>2]|0,!!A;)if((m[A+4>>2]&-8|0)==(D|0)){w=A;break t}else N=N<<1,w=A;m[S>>2]=q,m[q+24>>2]=w,m[q+12>>2]=q,m[q+8>>2]=q;break e}while(!1);ke=w+8|0,je=m[ke>>2]|0,m[je+12>>2]=q,m[ke>>2]=q,m[q+8>>2]=je,m[q+12>>2]=w,m[q+24>>2]=0}while(!1);return je=v+8|0,Re=Je,je|0}else Z=j}else Z=j;else Z=-1;while(!1);if(S=m[6923]|0,S>>>0>=Z>>>0)return w=S-Z|0,A=m[6926]|0,w>>>0>15?(je=A+Z|0,m[6926]=je,m[6923]=w,m[je+4>>2]=w|1,m[A+S>>2]=w,m[A+4>>2]=Z|3):(m[6923]=0,m[6926]=0,m[A+4>>2]=S|3,je=A+S+4|0,m[je>>2]=m[je>>2]|1),je=A+8|0,Re=Je,je|0;if(D=m[6924]|0,D>>>0>Z>>>0)return we=D-Z|0,m[6924]=we,je=m[6927]|0,ke=je+Z|0,m[6927]=ke,m[ke+4>>2]=we|1,m[je+4>>2]=Z|3,je=je+8|0,Re=Je,je|0;if(m[7039]|0?A=m[7041]|0:(m[7041]=4096,m[7040]=4096,m[7042]=-1,m[7043]=-1,m[7044]=0,m[7032]=0,m[7039]=te&-16^1431655768,A=4096),v=Z+48|0,T=Z+47|0,P=A+T|0,E=0-A|0,j=P&E,j>>>0<=Z>>>0||(A=m[7031]|0,A|0&&(q=m[7029]|0,te=q+j|0,te>>>0<=q>>>0|te>>>0>A>>>0)))return je=0,Re=Je,je|0;e:do if(m[7032]&4)w=0,xe=143;else{S=m[6927]|0;t:do if(S){for(N=28132;te=m[N>>2]|0,!(te>>>0<=S>>>0&&(te+(m[N+4>>2]|0)|0)>>>0>S>>>0);)if(A=m[N+8>>2]|0,A)N=A;else{xe=128;break t}if(w=P-D&E,w>>>0<2147483647)if(A=Nh(w|0)|0,(A|0)==((m[N>>2]|0)+(m[N+4>>2]|0)|0)){if((A|0)!=-1){D=w,P=A,xe=145;break e}}else N=A,xe=136;else w=0}else xe=128;while(!1);do if((xe|0)==128)if(S=Nh(0)|0,(S|0)!=-1&&(w=S,ne=m[7040]|0,le=ne+-1|0,w=(le&w|0?(le+w&0-ne)-w|0:0)+j|0,ne=m[7029]|0,le=w+ne|0,w>>>0>Z>>>0&w>>>0<2147483647)){if(te=m[7031]|0,te|0&&le>>>0<=ne>>>0|le>>>0>te>>>0){w=0;break}if(A=Nh(w|0)|0,(A|0)==(S|0)){D=w,P=S,xe=145;break e}else N=A,xe=136}else w=0;while(!1);do if((xe|0)==136){if(S=0-w|0,!(v>>>0>w>>>0&(w>>>0<2147483647&(N|0)!=-1)))if((N|0)==-1){w=0;break}else{D=w,P=N,xe=145;break e}if(A=m[7041]|0,A=T-w+A&0-A,A>>>0>=2147483647){D=w,P=N,xe=145;break e}if((Nh(A|0)|0)==-1){Nh(S|0)|0,w=0;break}else{D=A+w|0,P=N,xe=145;break e}}while(!1);m[7032]=m[7032]|4,xe=143}while(!1);if((xe|0)==143&&j>>>0<2147483647&&(we=Nh(j|0)|0,le=Nh(0)|0,Ee=le-we|0,Ue=Ee>>>0>(Z+40|0)>>>0,!((we|0)==-1|Ue^1|we>>>0>>0&((we|0)!=-1&(le|0)!=-1)^1))&&(D=Ue?Ee:w,P=we,xe=145),(xe|0)==145){w=(m[7029]|0)+D|0,m[7029]=w,w>>>0>(m[7030]|0)>>>0&&(m[7030]=w),T=m[6927]|0;e:do if(T){for(w=28132;;){if(A=m[w>>2]|0,S=m[w+4>>2]|0,(P|0)==(A+S|0)){xe=154;break}if(N=m[w+8>>2]|0,N)w=N;else break}if((xe|0)==154&&(ke=w+4|0,(m[w+12>>2]&8|0)==0)&&P>>>0>T>>>0&A>>>0<=T>>>0){m[ke>>2]=S+D,je=(m[6924]|0)+D|0,we=T+8|0,we=we&7|0?0-we&7:0,ke=T+we|0,we=je-we|0,m[6927]=ke,m[6924]=we,m[ke+4>>2]=we|1,m[T+je+4>>2]=40,m[6928]=m[7043];break}for(P>>>0<(m[6925]|0)>>>0&&(m[6925]=P),S=P+D|0,w=28132;;){if((m[w>>2]|0)==(S|0)){xe=162;break}if(A=m[w+8>>2]|0,A)w=A;else break}if((xe|0)==162&&!(m[w+12>>2]&8|0)){m[w>>2]=P,q=w+4|0,m[q>>2]=(m[q>>2]|0)+D,q=P+8|0,q=P+(q&7|0?0-q&7:0)|0,w=S+8|0,w=S+(w&7|0?0-w&7:0)|0,j=q+Z|0,v=w-q-Z|0,m[q+4>>2]=Z|3;t:do if((T|0)==(w|0))je=(m[6924]|0)+v|0,m[6924]=je,m[6927]=j,m[j+4>>2]=je|1;else{if((m[6926]|0)==(w|0)){je=(m[6923]|0)+v|0,m[6923]=je,m[6926]=j,m[j+4>>2]=je|1,m[j+je>>2]=je;break}if(A=m[w+4>>2]|0,(A&3|0)==1){D=A&-8,N=A>>>3;n:do if(A>>>0<256)if(A=m[w+8>>2]|0,S=m[w+12>>2]|0,(S|0)==(A|0)){m[6921]=m[6921]&~(1<>2]=S,m[S+8>>2]=A;break}else{P=m[w+24>>2]|0,A=m[w+12>>2]|0;do if((A|0)==(w|0)){if(S=w+16|0,N=S+4|0,A=m[N>>2]|0,A)S=N;else if(A=m[S>>2]|0,!A){A=0;break}for(;;)if(E=A+20|0,N=m[E>>2]|0,N)A=N,S=E;else if(E=A+16|0,N=m[E>>2]|0,N)A=N,S=E;else break;m[S>>2]=0}else je=m[w+8>>2]|0,m[je+12>>2]=A,m[A+8>>2]=je;while(!1);if(!P)break;S=m[w+28>>2]|0,N=27988+(S<<2)|0;do if((m[N>>2]|0)!=(w|0)){if(je=P+16|0,m[((m[je>>2]|0)==(w|0)?je:P+20|0)>>2]=A,!A)break n}else{if(m[N>>2]=A,A|0)break;m[6922]=m[6922]&~(1<>2]=P,S=w+16|0,N=m[S>>2]|0,N|0&&(m[A+16>>2]=N,m[N+24>>2]=A),S=m[S+4>>2]|0,!S)break;m[A+20>>2]=S,m[S+24>>2]=A}while(!1);w=w+D|0,E=D+v|0}else E=v;if(w=w+4|0,m[w>>2]=m[w>>2]&-2,m[j+4>>2]=E|1,m[j+E>>2]=E,w=E>>>3,E>>>0<256){S=27724+(w<<1<<2)|0,A=m[6921]|0,w=1<>2]|0):(m[6921]=A|w,w=S,A=S+8|0),m[A>>2]=j,m[w+12>>2]=j,m[j+8>>2]=w,m[j+12>>2]=S;break}w=E>>>8;do if(!w)N=0;else{if(E>>>0>16777215){N=31;break}ke=(w+1048320|0)>>>16&8,je=w<>>16&4,je=je<>>16&2,N=14-(we|ke|N)+(je<>>15)|0,N=E>>>(N+7|0)&1|N<<1}while(!1);if(w=27988+(N<<2)|0,m[j+28>>2]=N,A=j+16|0,m[A+4>>2]=0,m[A>>2]=0,A=m[6922]|0,S=1<>2]=j,m[j+24>>2]=w,m[j+12>>2]=j,m[j+8>>2]=j;break}w=m[w>>2]|0;n:do if((m[w+4>>2]&-8|0)!=(E|0)){for(N=E<<((N|0)==31?0:25-(N>>>1)|0);S=w+16+(N>>>31<<2)|0,A=m[S>>2]|0,!!A;)if((m[A+4>>2]&-8|0)==(E|0)){w=A;break n}else N=N<<1,w=A;m[S>>2]=j,m[j+24>>2]=w,m[j+12>>2]=j,m[j+8>>2]=j;break t}while(!1);ke=w+8|0,je=m[ke>>2]|0,m[je+12>>2]=j,m[ke>>2]=j,m[j+8>>2]=je,m[j+12>>2]=w,m[j+24>>2]=0}while(!1);return je=q+8|0,Re=Je,je|0}for(w=28132;A=m[w>>2]|0,!(A>>>0<=T>>>0&&(je=A+(m[w+4>>2]|0)|0,je>>>0>T>>>0));)w=m[w+8>>2]|0;E=je+-47|0,A=E+8|0,A=E+(A&7|0?0-A&7:0)|0,E=T+16|0,A=A>>>0>>0?T:A,w=A+8|0,S=D+-40|0,we=P+8|0,we=we&7|0?0-we&7:0,ke=P+we|0,we=S-we|0,m[6927]=ke,m[6924]=we,m[ke+4>>2]=we|1,m[P+S+4>>2]=40,m[6928]=m[7043],S=A+4|0,m[S>>2]=27,m[w>>2]=m[7033],m[w+4>>2]=m[7034],m[w+8>>2]=m[7035],m[w+12>>2]=m[7036],m[7033]=P,m[7034]=D,m[7036]=0,m[7035]=w,w=A+24|0;do ke=w,w=w+4|0,m[w>>2]=7;while((ke+8|0)>>>0>>0);if((A|0)!=(T|0)){if(P=A-T|0,m[S>>2]=m[S>>2]&-2,m[T+4>>2]=P|1,m[A>>2]=P,w=P>>>3,P>>>0<256){S=27724+(w<<1<<2)|0,A=m[6921]|0,w=1<>2]|0):(m[6921]=A|w,w=S,A=S+8|0),m[A>>2]=T,m[w+12>>2]=T,m[T+8>>2]=w,m[T+12>>2]=S;break}if(w=P>>>8,w?P>>>0>16777215?N=31:(ke=(w+1048320|0)>>>16&8,je=w<>>16&4,je=je<>>16&2,N=14-(we|ke|N)+(je<>>15)|0,N=P>>>(N+7|0)&1|N<<1):N=0,S=27988+(N<<2)|0,m[T+28>>2]=N,m[T+20>>2]=0,m[E>>2]=0,w=m[6922]|0,A=1<>2]=T,m[T+24>>2]=S,m[T+12>>2]=T,m[T+8>>2]=T;break}w=m[S>>2]|0;t:do if((m[w+4>>2]&-8|0)!=(P|0)){for(N=P<<((N|0)==31?0:25-(N>>>1)|0);S=w+16+(N>>>31<<2)|0,A=m[S>>2]|0,!!A;)if((m[A+4>>2]&-8|0)==(P|0)){w=A;break t}else N=N<<1,w=A;m[S>>2]=T,m[T+24>>2]=w,m[T+12>>2]=T,m[T+8>>2]=T;break e}while(!1);ke=w+8|0,je=m[ke>>2]|0,m[je+12>>2]=T,m[ke>>2]=T,m[T+8>>2]=je,m[T+12>>2]=w,m[T+24>>2]=0}}else je=m[6925]|0,(je|0)==0|P>>>0>>0&&(m[6925]=P),m[7033]=P,m[7034]=D,m[7036]=0,m[6930]=m[7039],m[6929]=-1,m[6934]=27724,m[6933]=27724,m[6936]=27732,m[6935]=27732,m[6938]=27740,m[6937]=27740,m[6940]=27748,m[6939]=27748,m[6942]=27756,m[6941]=27756,m[6944]=27764,m[6943]=27764,m[6946]=27772,m[6945]=27772,m[6948]=27780,m[6947]=27780,m[6950]=27788,m[6949]=27788,m[6952]=27796,m[6951]=27796,m[6954]=27804,m[6953]=27804,m[6956]=27812,m[6955]=27812,m[6958]=27820,m[6957]=27820,m[6960]=27828,m[6959]=27828,m[6962]=27836,m[6961]=27836,m[6964]=27844,m[6963]=27844,m[6966]=27852,m[6965]=27852,m[6968]=27860,m[6967]=27860,m[6970]=27868,m[6969]=27868,m[6972]=27876,m[6971]=27876,m[6974]=27884,m[6973]=27884,m[6976]=27892,m[6975]=27892,m[6978]=27900,m[6977]=27900,m[6980]=27908,m[6979]=27908,m[6982]=27916,m[6981]=27916,m[6984]=27924,m[6983]=27924,m[6986]=27932,m[6985]=27932,m[6988]=27940,m[6987]=27940,m[6990]=27948,m[6989]=27948,m[6992]=27956,m[6991]=27956,m[6994]=27964,m[6993]=27964,m[6996]=27972,m[6995]=27972,je=D+-40|0,we=P+8|0,we=we&7|0?0-we&7:0,ke=P+we|0,we=je-we|0,m[6927]=ke,m[6924]=we,m[ke+4>>2]=we|1,m[P+je+4>>2]=40,m[6928]=m[7043];while(!1);if(w=m[6924]|0,w>>>0>Z>>>0)return we=w-Z|0,m[6924]=we,je=m[6927]|0,ke=je+Z|0,m[6927]=ke,m[ke+4>>2]=we|1,m[je+4>>2]=Z|3,je=je+8|0,Re=Je,je|0}return je=he()|0,m[je>>2]=12,je=0,Re=Je,je|0}function yn(A){A=A|0;var w=0,S=0,N=0,E=0,P=0,D=0,v=0,T=0;if(A){S=A+-8|0,E=m[6925]|0,A=m[A+-4>>2]|0,w=A&-8,T=S+w|0;do if(A&1)v=S,D=S;else{if(N=m[S>>2]|0,!(A&3)||(D=S+(0-N)|0,P=N+w|0,D>>>0>>0))return;if((m[6926]|0)==(D|0)){if(A=T+4|0,w=m[A>>2]|0,(w&3|0)!=3){v=D,w=P;break}m[6923]=P,m[A>>2]=w&-2,m[D+4>>2]=P|1,m[D+P>>2]=P;return}if(S=N>>>3,N>>>0<256)if(A=m[D+8>>2]|0,w=m[D+12>>2]|0,(w|0)==(A|0)){m[6921]=m[6921]&~(1<>2]=w,m[w+8>>2]=A,v=D,w=P;break}E=m[D+24>>2]|0,A=m[D+12>>2]|0;do if((A|0)==(D|0)){if(w=D+16|0,S=w+4|0,A=m[S>>2]|0,A)w=S;else if(A=m[w>>2]|0,!A){A=0;break}for(;;)if(N=A+20|0,S=m[N>>2]|0,S)A=S,w=N;else if(N=A+16|0,S=m[N>>2]|0,S)A=S,w=N;else break;m[w>>2]=0}else v=m[D+8>>2]|0,m[v+12>>2]=A,m[A+8>>2]=v;while(!1);if(E){if(w=m[D+28>>2]|0,S=27988+(w<<2)|0,(m[S>>2]|0)==(D|0)){if(m[S>>2]=A,!A){m[6922]=m[6922]&~(1<>2]|0)==(D|0)?v:E+20|0)>>2]=A,!A){v=D,w=P;break}m[A+24>>2]=E,w=D+16|0,S=m[w>>2]|0,S|0&&(m[A+16>>2]=S,m[S+24>>2]=A),w=m[w+4>>2]|0,w?(m[A+20>>2]=w,m[w+24>>2]=A,v=D,w=P):(v=D,w=P)}else v=D,w=P}while(!1);if(!(D>>>0>=T>>>0)&&(A=T+4|0,N=m[A>>2]|0,!!(N&1))){if(N&2)m[A>>2]=N&-2,m[v+4>>2]=w|1,m[D+w>>2]=w,E=w;else{if((m[6927]|0)==(T|0)){if(T=(m[6924]|0)+w|0,m[6924]=T,m[6927]=v,m[v+4>>2]=T|1,(v|0)!=(m[6926]|0))return;m[6926]=0,m[6923]=0;return}if((m[6926]|0)==(T|0)){T=(m[6923]|0)+w|0,m[6923]=T,m[6926]=D,m[v+4>>2]=T|1,m[D+T>>2]=T;return}E=(N&-8)+w|0,S=N>>>3;do if(N>>>0<256)if(w=m[T+8>>2]|0,A=m[T+12>>2]|0,(A|0)==(w|0)){m[6921]=m[6921]&~(1<>2]=A,m[A+8>>2]=w;break}else{P=m[T+24>>2]|0,A=m[T+12>>2]|0;do if((A|0)==(T|0)){if(w=T+16|0,S=w+4|0,A=m[S>>2]|0,A)w=S;else if(A=m[w>>2]|0,!A){S=0;break}for(;;)if(N=A+20|0,S=m[N>>2]|0,S)A=S,w=N;else if(N=A+16|0,S=m[N>>2]|0,S)A=S,w=N;else break;m[w>>2]=0,S=A}else S=m[T+8>>2]|0,m[S+12>>2]=A,m[A+8>>2]=S,S=A;while(!1);if(P|0){if(A=m[T+28>>2]|0,w=27988+(A<<2)|0,(m[w>>2]|0)==(T|0)){if(m[w>>2]=S,!S){m[6922]=m[6922]&~(1<>2]|0)==(T|0)?N:P+20|0)>>2]=S,!S)break;m[S+24>>2]=P,A=T+16|0,w=m[A>>2]|0,w|0&&(m[S+16>>2]=w,m[w+24>>2]=S),A=m[A+4>>2]|0,A|0&&(m[S+20>>2]=A,m[A+24>>2]=S)}}while(!1);if(m[v+4>>2]=E|1,m[D+E>>2]=E,(v|0)==(m[6926]|0)){m[6923]=E;return}}if(A=E>>>3,E>>>0<256){S=27724+(A<<1<<2)|0,w=m[6921]|0,A=1<>2]|0):(m[6921]=w|A,A=S,w=S+8|0),m[w>>2]=v,m[A+12>>2]=v,m[v+8>>2]=A,m[v+12>>2]=S;return}A=E>>>8,A?E>>>0>16777215?N=31:(D=(A+1048320|0)>>>16&8,T=A<>>16&4,T=T<>>16&2,N=14-(P|D|N)+(T<>>15)|0,N=E>>>(N+7|0)&1|N<<1):N=0,A=27988+(N<<2)|0,m[v+28>>2]=N,m[v+20>>2]=0,m[v+16>>2]=0,w=m[6922]|0,S=1<>2]=v,m[v+24>>2]=A,m[v+12>>2]=v,m[v+8>>2]=v;else{A=m[A>>2]|0;t:do if((m[A+4>>2]&-8|0)!=(E|0)){for(N=E<<((N|0)==31?0:25-(N>>>1)|0);S=A+16+(N>>>31<<2)|0,w=m[S>>2]|0,!!w;)if((m[w+4>>2]&-8|0)==(E|0)){A=w;break t}else N=N<<1,A=w;m[S>>2]=v,m[v+24>>2]=A,m[v+12>>2]=v,m[v+8>>2]=v;break e}while(!1);D=A+8|0,T=m[D>>2]|0,m[T+12>>2]=v,m[D>>2]=v,m[v+8>>2]=T,m[v+12>>2]=A,m[v+24>>2]=0}while(!1);if(T=(m[6929]|0)+-1|0,m[6929]=T,!(T|0)){for(A=28140;A=m[A>>2]|0,A;)A=A+8|0;m[6929]=-1}}}}function bs(A,w){A=A|0,w=w|0;var S=0;return A?(S=cs(w,A)|0,(w|A)>>>0>65535&&(S=((S>>>0)/(A>>>0)|0|0)==(w|0)?S:-1)):S=0,A=gi(S)|0,!A||!(m[A+-4>>2]&3)||Eh(A|0,0,S|0)|0,A|0}function Vl(A,w){A=A|0,w=w|0;var S=0,N=0;return A?w>>>0>4294967231?(w=he()|0,m[w>>2]=12,w=0,w|0):(S=Th(A+-8|0,w>>>0<11?16:w+11&-8)|0,S|0?(w=S+8|0,w|0):(S=gi(w)|0,S?(N=m[A+-4>>2]|0,N=(N&-8)-(N&3|0?4:8)|0,ql(S|0,A|0,(N>>>0>>0?N:w)|0)|0,yn(A),w=S,w|0):(w=0,w|0))):(w=gi(w)|0,w|0)}function Th(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0,T=0,j=0,q=0,Z=0;if(q=A+4|0,Z=m[q>>2]|0,S=Z&-8,v=A+S|0,!(Z&3))return w>>>0<256?(A=0,A|0):(S>>>0>=(w+4|0)>>>0&&(S-w|0)>>>0<=m[7041]<<1>>>0||(A=0),A|0);if(S>>>0>=w>>>0)return S=S-w|0,S>>>0<=15||(j=A+w|0,m[q>>2]=Z&1|w|2,m[j+4>>2]=S|3,Z=v+4|0,m[Z>>2]=m[Z>>2]|1,Pm(j,S)),A|0;if((m[6927]|0)==(v|0))return j=(m[6924]|0)+S|0,S=j-w|0,N=A+w|0,j>>>0<=w>>>0?(A=0,A|0):(m[q>>2]=Z&1|w|2,m[N+4>>2]=S|1,m[6927]=N,m[6924]=S,A|0);if((m[6926]|0)==(v|0))return N=(m[6923]|0)+S|0,N>>>0>>0?(A=0,A|0):(S=N-w|0,S>>>0>15?(j=A+w|0,N=A+N|0,m[q>>2]=Z&1|w|2,m[j+4>>2]=S|1,m[N>>2]=S,N=N+4|0,m[N>>2]=m[N>>2]&-2,N=j):(m[q>>2]=Z&1|N|2,N=A+N+4|0,m[N>>2]=m[N>>2]|1,N=0,S=0),m[6923]=S,m[6926]=N,A|0);if(N=m[v+4>>2]|0,N&2|0||(T=(N&-8)+S|0,T>>>0>>0))return A=0,A|0;j=T-w|0,E=N>>>3;do if(N>>>0<256)if(N=m[v+8>>2]|0,S=m[v+12>>2]|0,(S|0)==(N|0)){m[6921]=m[6921]&~(1<>2]=S,m[S+8>>2]=N;break}else{D=m[v+24>>2]|0,S=m[v+12>>2]|0;do if((S|0)==(v|0)){if(N=v+16|0,E=N+4|0,S=m[E>>2]|0,S)N=E;else if(S=m[N>>2]|0,!S){E=0;break}for(;;)if(P=S+20|0,E=m[P>>2]|0,E)S=E,N=P;else if(P=S+16|0,E=m[P>>2]|0,E)S=E,N=P;else break;m[N>>2]=0,E=S}else E=m[v+8>>2]|0,m[E+12>>2]=S,m[S+8>>2]=E,E=S;while(!1);if(D|0){if(S=m[v+28>>2]|0,N=27988+(S<<2)|0,(m[N>>2]|0)==(v|0)){if(m[N>>2]=E,!E){m[6922]=m[6922]&~(1<>2]|0)==(v|0)?P:D+20|0)>>2]=E,!E)break;m[E+24>>2]=D,S=v+16|0,N=m[S>>2]|0,N|0&&(m[E+16>>2]=N,m[N+24>>2]=E),S=m[S+4>>2]|0,S|0&&(m[E+20>>2]=S,m[S+24>>2]=E)}}while(!1);return j>>>0<16?(m[q>>2]=Z&1|T|2,Z=A+T+4|0,m[Z>>2]=m[Z>>2]|1,A|0):(v=A+w|0,m[q>>2]=Z&1|w|2,m[v+4>>2]=j|3,Z=A+T+4|0,m[Z>>2]=m[Z>>2]|1,Pm(v,j),A|0)}function Pm(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0,D=0,v=0;v=A+w|0,S=m[A+4>>2]|0;do if(S&1)D=A;else{if(E=m[A>>2]|0,!(S&3))return;if(D=A+(0-E)|0,w=E+w|0,(m[6926]|0)==(D|0)){if(A=v+4|0,S=m[A>>2]|0,(S&3|0)!=3)break;m[6923]=w,m[A>>2]=S&-2,m[D+4>>2]=w|1,m[v>>2]=w;return}if(N=E>>>3,E>>>0<256)if(A=m[D+8>>2]|0,S=m[D+12>>2]|0,(S|0)==(A|0)){m[6921]=m[6921]&~(1<>2]=S,m[S+8>>2]=A;break}P=m[D+24>>2]|0,A=m[D+12>>2]|0;do if((A|0)==(D|0)){if(S=D+16|0,N=S+4|0,A=m[N>>2]|0,A)S=N;else if(A=m[S>>2]|0,!A){A=0;break}for(;;)if(E=A+20|0,N=m[E>>2]|0,N)A=N,S=E;else if(E=A+16|0,N=m[E>>2]|0,N)A=N,S=E;else break;m[S>>2]=0}else E=m[D+8>>2]|0,m[E+12>>2]=A,m[A+8>>2]=E;while(!1);if(P){if(S=m[D+28>>2]|0,N=27988+(S<<2)|0,(m[N>>2]|0)==(D|0)){if(m[N>>2]=A,!A){m[6922]=m[6922]&~(1<>2]|0)==(D|0)?E:P+20|0)>>2]=A,!A)break;m[A+24>>2]=P,S=D+16|0,N=m[S>>2]|0,N|0&&(m[A+16>>2]=N,m[N+24>>2]=A),S=m[S+4>>2]|0,S&&(m[A+20>>2]=S,m[S+24>>2]=A)}}while(!1);if(A=v+4|0,N=m[A>>2]|0,N&2)m[A>>2]=N&-2,m[D+4>>2]=w|1,m[D+w>>2]=w,E=w;else{if((m[6927]|0)==(v|0)){if(v=(m[6924]|0)+w|0,m[6924]=v,m[6927]=D,m[D+4>>2]=v|1,(D|0)!=(m[6926]|0))return;m[6926]=0,m[6923]=0;return}if((m[6926]|0)==(v|0)){v=(m[6923]|0)+w|0,m[6923]=v,m[6926]=D,m[D+4>>2]=v|1,m[D+v>>2]=v;return}E=(N&-8)+w|0,S=N>>>3;do if(N>>>0<256)if(A=m[v+8>>2]|0,w=m[v+12>>2]|0,(w|0)==(A|0)){m[6921]=m[6921]&~(1<>2]=w,m[w+8>>2]=A;break}else{P=m[v+24>>2]|0,w=m[v+12>>2]|0;do if((w|0)==(v|0)){if(A=v+16|0,S=A+4|0,w=m[S>>2]|0,w)A=S;else if(w=m[A>>2]|0,!w){S=0;break}for(;;)if(N=w+20|0,S=m[N>>2]|0,S)w=S,A=N;else if(N=w+16|0,S=m[N>>2]|0,S)w=S,A=N;else break;m[A>>2]=0,S=w}else S=m[v+8>>2]|0,m[S+12>>2]=w,m[w+8>>2]=S,S=w;while(!1);if(P|0){if(w=m[v+28>>2]|0,A=27988+(w<<2)|0,(m[A>>2]|0)==(v|0)){if(m[A>>2]=S,!S){m[6922]=m[6922]&~(1<>2]|0)==(v|0)?N:P+20|0)>>2]=S,!S)break;m[S+24>>2]=P,w=v+16|0,A=m[w>>2]|0,A|0&&(m[S+16>>2]=A,m[A+24>>2]=S),w=m[w+4>>2]|0,w|0&&(m[S+20>>2]=w,m[w+24>>2]=S)}}while(!1);if(m[D+4>>2]=E|1,m[D+E>>2]=E,(D|0)==(m[6926]|0)){m[6923]=E;return}}if(w=E>>>3,E>>>0<256){S=27724+(w<<1<<2)|0,A=m[6921]|0,w=1<>2]|0):(m[6921]=A|w,w=S,A=S+8|0),m[A>>2]=D,m[w+12>>2]=D,m[D+8>>2]=w,m[D+12>>2]=S;return}if(w=E>>>8,w?E>>>0>16777215?N=31:(P=(w+1048320|0)>>>16&8,v=w<>>16&4,v=v<>>16&2,N=14-(S|P|N)+(v<>>15)|0,N=E>>>(N+7|0)&1|N<<1):N=0,w=27988+(N<<2)|0,m[D+28>>2]=N,m[D+20>>2]=0,m[D+16>>2]=0,A=m[6922]|0,S=1<>2]=D,m[D+24>>2]=w,m[D+12>>2]=D,m[D+8>>2]=D;return}w=m[w>>2]|0;e:do if((m[w+4>>2]&-8|0)!=(E|0)){for(N=E<<((N|0)==31?0:25-(N>>>1)|0);S=w+16+(N>>>31<<2)|0,A=m[S>>2]|0,!!A;)if((m[A+4>>2]&-8|0)==(E|0)){w=A;break e}else N=N<<1,w=A;m[S>>2]=D,m[D+24>>2]=w,m[D+12>>2]=D,m[D+8>>2]=D;return}while(!1);P=w+8|0,v=m[P>>2]|0,m[v+12>>2]=D,m[P>>2]=D,m[D+8>>2]=v,m[D+12>>2]=w,m[D+24>>2]=0}function Pn(A,w,S,N){return A=A|0,w=w|0,S=S|0,N=N|0,S=A+S>>>0,wt(w+N+(S>>>0>>0|0)>>>0|0),S|0|0}function ds(A,w,S,N){return A=A|0,w=w|0,S=S|0,N=N|0,N=w-N-(S>>>0>A>>>0|0)>>>0,wt(N|0),A-S>>>0|0|0}function Ec(A){return A=A|0,(A?31-(Ii(A^A-1)|0)|0:32)|0}function Nc(A,w,S,N,E){A=A|0,w=w|0,S=S|0,N=N|0,E=E|0;var P=0,D=0,v=0,T=0,j=0,q=0,Z=0,te=0,ne=0,le=0;if(q=A,T=w,j=T,D=S,te=N,v=te,!j)return P=(E|0)!=0,v?P?(m[E>>2]=A|0,m[E+4>>2]=w&0,te=0,E=0,wt(te|0),E|0):(te=0,E=0,wt(te|0),E|0):(P&&(m[E>>2]=(q>>>0)%(D>>>0),m[E+4>>2]=0),te=0,E=(q>>>0)/(D>>>0)>>>0,wt(te|0),E|0);P=(v|0)==0;do if(D){if(!P){if(P=(Ii(v|0)|0)-(Ii(j|0)|0)|0,P>>>0<=31){Z=P+1|0,v=31-P|0,w=P-31>>31,D=Z,A=q>>>(Z>>>0)&w|j<>>(Z>>>0)&w,P=0,v=q<>2]=A|0,m[E+4>>2]=T|w&0,te=0,E=0,wt(te|0),E|0):(te=0,E=0,wt(te|0),E|0)}if(P=D-1|0,P&D|0){v=(Ii(D|0)|0)+33-(Ii(j|0)|0)|0,le=64-v|0,Z=32-v|0,T=Z>>31,ne=v-32|0,w=ne>>31,D=v,A=Z-1>>31&j>>>(ne>>>0)|(j<>>(v>>>0))&w,w=w&j>>>(v>>>0),P=q<>>(ne>>>0))&T|q<>31;break}return E|0&&(m[E>>2]=P&q,m[E+4>>2]=0),(D|0)==1?(ne=T|w&0,le=A|0|0,wt(ne|0),le|0):(le=Ec(D|0)|0,ne=j>>>(le>>>0)|0,le=j<<32-le|q>>>(le>>>0)|0,wt(ne|0),le|0)}else{if(P)return E|0&&(m[E>>2]=(j>>>0)%(D>>>0),m[E+4>>2]=0),ne=0,le=(j>>>0)/(D>>>0)>>>0,wt(ne|0),le|0;if(!q)return E|0&&(m[E>>2]=0,m[E+4>>2]=(j>>>0)%(v>>>0)),ne=0,le=(j>>>0)/(v>>>0)>>>0,wt(ne|0),le|0;if(P=v-1|0,!(P&v))return E|0&&(m[E>>2]=A|0,m[E+4>>2]=P&j|w&0),ne=0,le=j>>>((Ec(v|0)|0)>>>0),wt(ne|0),le|0;if(P=(Ii(v|0)|0)-(Ii(j|0)|0)|0,P>>>0<=30){w=P+1|0,v=31-P|0,D=w,A=j<>>(w>>>0),w=j>>>(w>>>0),P=0,v=q<>2]=A|0,m[E+4>>2]=T|w&0,ne=0,le=0,wt(ne|0),le|0):(ne=0,le=0,wt(ne|0),le|0)}while(!1);if(!D)j=v,T=0,v=0;else{Z=S|0|0,q=te|N&0,j=Pn(Z|0,q|0,-1,-1)|0,S=_e()|0,T=v,v=0;do N=T,T=P>>>31|T<<1,P=v|P<<1,N=A<<1|N>>>31|0,te=A>>>31|w<<1|0,ds(j|0,S|0,N|0,te|0)|0,le=_e()|0,ne=le>>31|((le|0)<0?-1:0)<<1,v=ne&1,A=ds(N|0,te|0,ne&Z|0,(((le|0)<0?-1:0)>>31|((le|0)<0?-1:0)<<1)&q|0)|0,w=_e()|0,D=D-1|0;while(D|0);j=T,T=0}return D=0,E|0&&(m[E>>2]=A,m[E+4>>2]=w),ne=(P|0)>>>31|(j|D)<<1|(D<<1|P>>>31)&0|T,le=(P<<1|0)&-2|v,wt(ne|0),le|0}function Qc(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0;return j=w>>31|((w|0)<0?-1:0)<<1,T=((w|0)<0?-1:0)>>31|((w|0)<0?-1:0)<<1,P=N>>31|((N|0)<0?-1:0)<<1,E=((N|0)<0?-1:0)>>31|((N|0)<0?-1:0)<<1,v=ds(j^A|0,T^w|0,j|0,T|0)|0,D=_e()|0,A=P^j,w=E^T,ds((Nc(v,D,ds(P^S|0,E^N|0,P|0,E|0)|0,_e()|0,0)|0)^A|0,(_e()|0)^w|0,A|0,w|0)|0}function ns(A,w){A=A|0,w=w|0;var S=0,N=0,E=0,P=0;return P=A&65535,E=w&65535,S=cs(E,P)|0,N=A>>>16,A=(S>>>16)+(cs(E,N)|0)|0,E=w>>>16,w=cs(E,P)|0,wt((A>>>16)+(cs(E,N)|0)+(((A&65535)+w|0)>>>16)|0),A+w<<16|S&65535|0|0}function si(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0;return E=A,P=S,S=ns(E,P)|0,A=_e()|0,wt((cs(w,P)|0)+(cs(N,E)|0)+A|A&0|0),S|0|0|0}function Kc(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0,D=0,v=0,T=0,j=0;return E=Re,Re=Re+16|0,v=E|0,D=w>>31|((w|0)<0?-1:0)<<1,P=((w|0)<0?-1:0)>>31|((w|0)<0?-1:0)<<1,j=N>>31|((N|0)<0?-1:0)<<1,T=((N|0)<0?-1:0)>>31|((N|0)<0?-1:0)<<1,A=ds(D^A|0,P^w|0,D|0,P|0)|0,w=_e()|0,Nc(A,w,ds(j^S|0,T^N|0,j|0,T|0)|0,_e()|0,v)|0,N=ds(m[v>>2]^D|0,m[v+4>>2]^P|0,D|0,P|0)|0,S=_e()|0,Re=E,wt(S|0),N|0}function Mc(A,w,S,N){A=A|0,w=w|0,S=S|0,N=N|0;var E=0,P=0;return P=Re,Re=Re+16|0,E=P|0,Nc(A,w,S,N,E)|0,Re=P,wt(m[E+4>>2]|0),m[E>>2]|0|0}function dp(A,w,S){return A=A|0,w=w|0,S=S|0,(S|0)<32?(wt(w>>S|0),A>>>S|(w&(1<>S-32|0)}function pn(A,w,S){return A=A|0,w=w|0,S=S|0,(S|0)<32?(wt(w>>>S|0),A>>>S|(w&(1<>>S-32|0)}function xn(A,w,S){return A=A|0,w=w|0,S=S|0,(S|0)<32?(wt(w<>>32-S|0),A<=0?+Rn(A+.5):+ra(A-.5)}function ql(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0;if((S|0)>=8192)return Sn(A|0,w|0,S|0)|0,A|0;if(P=A|0,E=A+S|0,(A&3)==(w&3)){for(;A&3;){if(!S)return P|0;Nt[A>>0]=Nt[w>>0]|0,A=A+1|0,w=w+1|0,S=S-1|0}for(S=E&-4|0,N=S-64|0;(A|0)<=(N|0);)m[A>>2]=m[w>>2],m[A+4>>2]=m[w+4>>2],m[A+8>>2]=m[w+8>>2],m[A+12>>2]=m[w+12>>2],m[A+16>>2]=m[w+16>>2],m[A+20>>2]=m[w+20>>2],m[A+24>>2]=m[w+24>>2],m[A+28>>2]=m[w+28>>2],m[A+32>>2]=m[w+32>>2],m[A+36>>2]=m[w+36>>2],m[A+40>>2]=m[w+40>>2],m[A+44>>2]=m[w+44>>2],m[A+48>>2]=m[w+48>>2],m[A+52>>2]=m[w+52>>2],m[A+56>>2]=m[w+56>>2],m[A+60>>2]=m[w+60>>2],A=A+64|0,w=w+64|0;for(;(A|0)<(S|0);)m[A>>2]=m[w>>2],A=A+4|0,w=w+4|0}else for(S=E-4|0;(A|0)<(S|0);)Nt[A>>0]=Nt[w>>0]|0,Nt[A+1>>0]=Nt[w+1>>0]|0,Nt[A+2>>0]=Nt[w+2>>0]|0,Nt[A+3>>0]=Nt[w+3>>0]|0,A=A+4|0,w=w+4|0;for(;(A|0)<(E|0);)Nt[A>>0]=Nt[w>>0]|0,A=A+1|0,w=w+1|0;return P|0}function fp(A,w,S){A=A|0,w=w|0,S=S|0;var N=0;if((w|0)<(A|0)&(A|0)<(w+S|0)){for(N=A,w=w+S|0,A=A+S|0;(S|0)>0;)A=A-1|0,w=w-1|0,S=S-1|0,Nt[A>>0]=Nt[w>>0]|0;A=N}else ql(A,w,S)|0;return A|0}function Eh(A,w,S){A=A|0,w=w|0,S=S|0;var N=0,E=0,P=0,D=0;if(P=A+S|0,w=w&255,(S|0)>=67){for(;A&3;)Nt[A>>0]=w,A=A+1|0;for(N=P&-4|0,D=w|w<<8|w<<16|w<<24,E=N-64|0;(A|0)<=(E|0);)m[A>>2]=D,m[A+4>>2]=D,m[A+8>>2]=D,m[A+12>>2]=D,m[A+16>>2]=D,m[A+20>>2]=D,m[A+24>>2]=D,m[A+28>>2]=D,m[A+32>>2]=D,m[A+36>>2]=D,m[A+40>>2]=D,m[A+44>>2]=D,m[A+48>>2]=D,m[A+52>>2]=D,m[A+56>>2]=D,m[A+60>>2]=D,A=A+64|0;for(;(A|0)<(N|0);)m[A>>2]=D,A=A+4|0}for(;(A|0)<(P|0);)Nt[A>>0]=w,A=A+1|0;return P-S|0}function l1(A){return A=+A,A>=0?+Rn(A+.5):+ra(A-.5)}function Nh(A){A=A|0;var w=0,S=0,N=0;return N=vn()|0,S=m[Ln>>2]|0,w=S+A|0,(A|0)>0&(w|0)<(S|0)|(w|0)<0?(Tn(w|0)|0,Xt(12),-1):(w|0)>(N|0)&&!(hn(w|0)|0)?(Xt(12),-1):(m[Ln>>2]=w,S|0)}function p2(A,w,S){return A=A|0,w=w|0,S=S|0,Hd[A&3](w|0,S|0)|0}function py(A,w){return Ge(0),0}var Hd=[py,Wc,ca,ia];return{___divdi3:Qc,___muldi3:si,___remdi3:Kc,___uremdi3:Mc,_areNeighborCells:dd,_bitshift64Ashr:dp,_bitshift64Lshr:pn,_bitshift64Shl:xn,_calloc:bs,_cellAreaKm2:Fa,_cellAreaM2:Wo,_cellAreaRads2:Sa,_cellToBoundary:Ul,_cellToCenterChild:Ba,_cellToChildPos:tl,_cellToChildren:Ka,_cellToChildrenSize:Xs,_cellToLatLng:Po,_cellToLocalIj:ts,_cellToParent:Bi,_cellToVertex:ko,_cellToVertexes:b,_cellsToDirectedEdge:Ta,_cellsToLinkedMultiPolygon:fi,_childPosToCell:Sc,_compactCells:Ja,_constructCell:us,_destroyLinkedMultiPolygon:Eu,_directedEdgeToBoundary:vs,_directedEdgeToCells:Ea,_edgeLengthKm:Hi,_edgeLengthM:tc,_edgeLengthRads:Tc,_emscripten_replace_memory:Wn,_free:yn,_getBaseCellNumber:Ni,_getDirectedEdgeDestination:Tu,_getDirectedEdgeOrigin:Ko,_getHexagonAreaAvgKm2:_l,_getHexagonAreaAvgM2:Ro,_getHexagonEdgeLengthAvgKm:pd,_getHexagonEdgeLengthAvgM:zl,_getIcosahedronFaces:hd,_getIndexDigit:sa,_getNumCells:rl,_getPentagons:Ys,_getRes0Cells:Ya,_getResolution:Gr,_greatCircleDistanceKm:ys,_greatCircleDistanceM:nl,_greatCircleDistanceRads:bl,_gridDisk:Kr,_gridDiskDistances:Ir,_gridDistance:xi,_gridPathCells:wl,_gridPathCellsSize:Jr,_gridRing:Ai,_gridRingUnsafe:fs,_i64Add:Pn,_i64Subtract:ds,_isPentagon:Hr,_isResClassIII:Bl,_isValidCell:Fi,_isValidDirectedEdge:qd,_isValidIndex:Ns,_isValidVertex:X,_latLngToCell:wc,_llvm_ctlz_i64:hp,_llvm_maxnum_f64:fy,_llvm_minnum_f64:Io,_llvm_round_f64:eo,_localIjToCell:Br,_malloc:gi,_maxFaceCount:Yc,_maxGridDiskSize:ii,_maxPolygonToCellsSize:oi,_maxPolygonToCellsSizeExperimental:Ao,_memcpy:ql,_memmove:fp,_memset:Eh,_originToDirectedEdges:Ws,_pentagonCount:el,_polygonToCells:ja,_polygonToCellsExperimental:lp,_readInt64AsDoubleFromPointer:Sh,_res0CellCount:Gs,_reverseDirectedEdge:ce,_round:l1,_sbrk:Nh,_sizeOfCellBoundary:sl,_sizeOfCoordIJ:yf,_sizeOfGeoLoop:Lo,_sizeOfGeoPolygon:d0,_sizeOfH3Index:wh,_sizeOfLatLng:Ad,_sizeOfLinkedGeoPolygon:Gd,_uncompactCells:vl,_uncompactCellsSize:Jo,_vertexToLatLng:F,dynCall_iii:p2,establishStackSpace:Nr,stackAlloc:Ar,stackRestore:zn,stackSave:Un}}(Pe,nt,G);e.___divdi3=qe.___divdi3,e.___muldi3=qe.___muldi3,e.___remdi3=qe.___remdi3,e.___uremdi3=qe.___uremdi3,e._areNeighborCells=qe._areNeighborCells,e._bitshift64Ashr=qe._bitshift64Ashr,e._bitshift64Lshr=qe._bitshift64Lshr,e._bitshift64Shl=qe._bitshift64Shl,e._calloc=qe._calloc,e._cellAreaKm2=qe._cellAreaKm2,e._cellAreaM2=qe._cellAreaM2,e._cellAreaRads2=qe._cellAreaRads2,e._cellToBoundary=qe._cellToBoundary,e._cellToCenterChild=qe._cellToCenterChild,e._cellToChildPos=qe._cellToChildPos,e._cellToChildren=qe._cellToChildren,e._cellToChildrenSize=qe._cellToChildrenSize,e._cellToLatLng=qe._cellToLatLng,e._cellToLocalIj=qe._cellToLocalIj,e._cellToParent=qe._cellToParent,e._cellToVertex=qe._cellToVertex,e._cellToVertexes=qe._cellToVertexes,e._cellsToDirectedEdge=qe._cellsToDirectedEdge,e._cellsToLinkedMultiPolygon=qe._cellsToLinkedMultiPolygon,e._childPosToCell=qe._childPosToCell,e._compactCells=qe._compactCells,e._constructCell=qe._constructCell,e._destroyLinkedMultiPolygon=qe._destroyLinkedMultiPolygon,e._directedEdgeToBoundary=qe._directedEdgeToBoundary,e._directedEdgeToCells=qe._directedEdgeToCells,e._edgeLengthKm=qe._edgeLengthKm,e._edgeLengthM=qe._edgeLengthM,e._edgeLengthRads=qe._edgeLengthRads;var yt=e._emscripten_replace_memory=qe._emscripten_replace_memory;e._free=qe._free,e._getBaseCellNumber=qe._getBaseCellNumber,e._getDirectedEdgeDestination=qe._getDirectedEdgeDestination,e._getDirectedEdgeOrigin=qe._getDirectedEdgeOrigin,e._getHexagonAreaAvgKm2=qe._getHexagonAreaAvgKm2,e._getHexagonAreaAvgM2=qe._getHexagonAreaAvgM2,e._getHexagonEdgeLengthAvgKm=qe._getHexagonEdgeLengthAvgKm,e._getHexagonEdgeLengthAvgM=qe._getHexagonEdgeLengthAvgM,e._getIcosahedronFaces=qe._getIcosahedronFaces,e._getIndexDigit=qe._getIndexDigit,e._getNumCells=qe._getNumCells,e._getPentagons=qe._getPentagons,e._getRes0Cells=qe._getRes0Cells,e._getResolution=qe._getResolution,e._greatCircleDistanceKm=qe._greatCircleDistanceKm,e._greatCircleDistanceM=qe._greatCircleDistanceM,e._greatCircleDistanceRads=qe._greatCircleDistanceRads,e._gridDisk=qe._gridDisk,e._gridDiskDistances=qe._gridDiskDistances,e._gridDistance=qe._gridDistance,e._gridPathCells=qe._gridPathCells,e._gridPathCellsSize=qe._gridPathCellsSize,e._gridRing=qe._gridRing,e._gridRingUnsafe=qe._gridRingUnsafe,e._i64Add=qe._i64Add,e._i64Subtract=qe._i64Subtract,e._isPentagon=qe._isPentagon,e._isResClassIII=qe._isResClassIII,e._isValidCell=qe._isValidCell,e._isValidDirectedEdge=qe._isValidDirectedEdge,e._isValidIndex=qe._isValidIndex,e._isValidVertex=qe._isValidVertex,e._latLngToCell=qe._latLngToCell,e._llvm_ctlz_i64=qe._llvm_ctlz_i64,e._llvm_maxnum_f64=qe._llvm_maxnum_f64,e._llvm_minnum_f64=qe._llvm_minnum_f64,e._llvm_round_f64=qe._llvm_round_f64,e._localIjToCell=qe._localIjToCell,e._malloc=qe._malloc,e._maxFaceCount=qe._maxFaceCount,e._maxGridDiskSize=qe._maxGridDiskSize,e._maxPolygonToCellsSize=qe._maxPolygonToCellsSize,e._maxPolygonToCellsSizeExperimental=qe._maxPolygonToCellsSizeExperimental,e._memcpy=qe._memcpy,e._memmove=qe._memmove,e._memset=qe._memset,e._originToDirectedEdges=qe._originToDirectedEdges,e._pentagonCount=qe._pentagonCount,e._polygonToCells=qe._polygonToCells,e._polygonToCellsExperimental=qe._polygonToCellsExperimental,e._readInt64AsDoubleFromPointer=qe._readInt64AsDoubleFromPointer,e._res0CellCount=qe._res0CellCount,e._reverseDirectedEdge=qe._reverseDirectedEdge,e._round=qe._round,e._sbrk=qe._sbrk,e._sizeOfCellBoundary=qe._sizeOfCellBoundary,e._sizeOfCoordIJ=qe._sizeOfCoordIJ,e._sizeOfGeoLoop=qe._sizeOfGeoLoop,e._sizeOfGeoPolygon=qe._sizeOfGeoPolygon,e._sizeOfH3Index=qe._sizeOfH3Index,e._sizeOfLatLng=qe._sizeOfLatLng,e._sizeOfLinkedGeoPolygon=qe._sizeOfLinkedGeoPolygon,e._uncompactCells=qe._uncompactCells,e._uncompactCellsSize=qe._uncompactCellsSize,e._vertexToLatLng=qe._vertexToLatLng,e.establishStackSpace=qe.establishStackSpace;var Qt=e.stackAlloc=qe.stackAlloc,Be=e.stackRestore=qe.stackRestore,pt=e.stackSave=qe.stackSave;if(e.dynCall_iii=qe.dynCall_iii,e.asm=qe,e.cwrap=C,e.setValue=p,e.getValue=g,st){Se(st)||(st=s(st));{At();var rt=function(it){it.byteLength&&(it=new Uint8Array(it)),K.set(it,h),e.memoryInitializerRequest&&delete e.memoryInitializerRequest.response,Lt()},zt=function(){a(st,rt,function(){throw"could not load memory initializer "+st})},Yt=tt(st);if(Yt)rt(Yt.buffer);else if(e.memoryInitializerRequest){var Bt=function(){var it=e.memoryInitializerRequest,Ot=it.response;if(it.status!==200&&it.status!==0){var nn=tt(e.memoryInitializerRequestURL);if(nn)Ot=nn.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+it.status+", retrying "+st),zt();return}}rt(Ot)};e.memoryInitializerRequest.response?setTimeout(Bt,0):e.memoryInitializerRequest.addEventListener("load",Bt)}else zt()}}var $e;et=function it(){$e||ut(),$e||(et=it)};function ut(it){if(ft>0||(ge(),ft>0))return;function Ot(){$e||($e=!0,!x&&(Te(),ze(),e.onRuntimeInitialized&&e.onRuntimeInitialized(),Xe()))}e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1),Ot()},1)):Ot()}e.run=ut;function Gt(it){throw e.onAbort&&e.onAbort(it),it+="",o(it),l(it),x=!0,"abort("+it+"). Build with -s ASSERTIONS=1 for more info."}if(e.abort=Gt,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return ut(),n}(typeof hs=="object"?hs:{}),Zr="number",Ur=Zr,sb=Zr,ei=Zr,ti=Zr,Ic=Zr,ur=Zr,qst=[["sizeOfH3Index",Zr],["sizeOfLatLng",Zr],["sizeOfCellBoundary",Zr],["sizeOfGeoLoop",Zr],["sizeOfGeoPolygon",Zr],["sizeOfLinkedGeoPolygon",Zr],["sizeOfCoordIJ",Zr],["readInt64AsDoubleFromPointer",Zr],["isValidCell",sb,[ei,ti]],["isValidIndex",sb,[ei,ti]],["latLngToCell",Ur,[Zr,Zr,Ic,ur]],["cellToLatLng",Ur,[ei,ti,ur]],["cellToBoundary",Ur,[ei,ti,ur]],["maxGridDiskSize",Ur,[Zr,ur]],["gridDisk",Ur,[ei,ti,Zr,ur]],["gridDiskDistances",Ur,[ei,ti,Zr,ur,ur]],["gridRing",Ur,[ei,ti,Zr,ur]],["gridRingUnsafe",Ur,[ei,ti,Zr,ur]],["maxPolygonToCellsSize",Ur,[ur,Ic,Zr,ur]],["polygonToCells",Ur,[ur,Ic,Zr,ur]],["maxPolygonToCellsSizeExperimental",Ur,[ur,Ic,Zr,ur]],["polygonToCellsExperimental",Ur,[ur,Ic,Zr,Zr,Zr,ur]],["cellsToLinkedMultiPolygon",Ur,[ur,Zr,ur]],["destroyLinkedMultiPolygon",null,[ur]],["compactCells",Ur,[ur,ur,Zr,Zr]],["uncompactCells",Ur,[ur,Zr,Zr,ur,Zr,Ic]],["uncompactCellsSize",Ur,[ur,Zr,Zr,Ic,ur]],["isPentagon",sb,[ei,ti]],["isResClassIII",sb,[ei,ti]],["getBaseCellNumber",Zr,[ei,ti]],["getResolution",Zr,[ei,ti]],["getIndexDigit",Zr,[ei,ti,Zr]],["constructCell",Ur,[Zr,Zr,ur,ur]],["maxFaceCount",Ur,[ei,ti,ur]],["getIcosahedronFaces",Ur,[ei,ti,ur]],["cellToParent",Ur,[ei,ti,Ic,ur]],["cellToChildren",Ur,[ei,ti,Ic,ur]],["cellToCenterChild",Ur,[ei,ti,Ic,ur]],["cellToChildrenSize",Ur,[ei,ti,Ic,ur]],["cellToChildPos",Ur,[ei,ti,Ic,ur]],["childPosToCell",Ur,[Zr,Zr,ei,ti,Ic,ur]],["areNeighborCells",Ur,[ei,ti,ei,ti,ur]],["cellsToDirectedEdge",Ur,[ei,ti,ei,ti,ur]],["getDirectedEdgeOrigin",Ur,[ei,ti,ur]],["getDirectedEdgeDestination",Ur,[ei,ti,ur]],["isValidDirectedEdge",sb,[ei,ti]],["directedEdgeToCells",Ur,[ei,ti,ur]],["originToDirectedEdges",Ur,[ei,ti,ur]],["directedEdgeToBoundary",Ur,[ei,ti,ur]],["reverseDirectedEdge",Ur,[ei,ti,ur]],["gridDistance",Ur,[ei,ti,ei,ti,ur]],["gridPathCells",Ur,[ei,ti,ei,ti,ur]],["gridPathCellsSize",Ur,[ei,ti,ei,ti,ur]],["cellToLocalIj",Ur,[ei,ti,ei,ti,Zr,ur]],["localIjToCell",Ur,[ei,ti,ur,Zr,ur]],["getHexagonAreaAvgM2",Ur,[Ic,ur]],["getHexagonAreaAvgKm2",Ur,[Ic,ur]],["getHexagonEdgeLengthAvgM",Ur,[Ic,ur]],["getHexagonEdgeLengthAvgKm",Ur,[Ic,ur]],["greatCircleDistanceM",Zr,[ur,ur]],["greatCircleDistanceKm",Zr,[ur,ur]],["greatCircleDistanceRads",Zr,[ur,ur]],["cellAreaM2",Ur,[ei,ti,ur]],["cellAreaKm2",Ur,[ei,ti,ur]],["cellAreaRads2",Ur,[ei,ti,ur]],["edgeLengthM",Ur,[ei,ti,ur]],["edgeLengthKm",Ur,[ei,ti,ur]],["edgeLengthRads",Ur,[ei,ti,ur]],["getNumCells",Ur,[Ic,ur]],["getRes0Cells",Ur,[ur]],["res0CellCount",Zr],["getPentagons",Ur,[Zr,ur]],["pentagonCount",Zr],["cellToVertex",Ur,[ei,ti,Zr,ur]],["cellToVertexes",Ur,[ei,ti,ur]],["vertexToLatLng",Ur,[ei,ti,ur]],["isValidVertex",sb,[ei,ti]]],Gst=0,Hst=1,$st=2,Wst=3,jve=4,Xst=5,Yst=6,Zst=7,Qst=8,Kst=9,Jst=10,eat=11,tat=12,nat=13,rat=14,iat=15,sat=16,aat=17,oat=18,lat=19,Fl={};Fl[Gst]="Success";Fl[Hst]="The operation failed but a more specific error is not available";Fl[$st]="Argument was outside of acceptable range";Fl[Wst]="Latitude or longitude arguments were outside of acceptable range";Fl[jve]="Resolution argument was outside of acceptable range";Fl[Xst]="Cell argument was not valid";Fl[Yst]="Directed edge argument was not valid";Fl[Zst]="Undirected edge argument was not valid";Fl[Qst]="Vertex argument was not valid";Fl[Kst]="Pentagon distortion was encountered";Fl[Jst]="Duplicate input";Fl[eat]="Cell arguments were not neighbors";Fl[tat]="Cell arguments had incompatible resolutions";Fl[nat]="Memory allocation failed";Fl[rat]="Bounds of provided memory were insufficient";Fl[iat]="Mode or flags argument was not valid";Fl[sat]="Index argument was not valid";Fl[aat]="Base cell number was outside of acceptable range";Fl[oat]="Child indexing digits invalid";Fl[lat]="Child indexing digits refer to a deleted subsequence";var cat=1e3,Fve=1001,Bve=1002,mR={};mR[cat]="Unknown unit";mR[Fve]="Array length out of bounds";mR[Bve]="Got unexpected null value for H3 index";var uat="Unknown error";function Uve(n,e,t){var r=t&&"value"in t,i=new Error((n[e]||uat)+" (code: "+e+(r?", value: "+t.value:"")+")");return i.code=e,i}function zve(n,e){var t=arguments.length===2?{value:e}:{};return Uve(Fl,n,t)}function Vve(n,e){var t=arguments.length===2?{value:e}:{};return Uve(mR,n,t)}function _S(n){if(n!==0)throw zve(n)}var Ah={};qst.forEach(function(e){Ah[e[0]]=hs.cwrap.apply(hs,e)});var r_=16,wS=4,d3=8,dat=8,CC=Ah.sizeOfH3Index(),MW=Ah.sizeOfLatLng(),hat=Ah.sizeOfCellBoundary(),fat=Ah.sizeOfGeoPolygon(),h4=Ah.sizeOfGeoLoop();Ah.sizeOfLinkedGeoPolygon();Ah.sizeOfCoordIJ();function pat(n){if(typeof n!="number"||n<0||n>15||Math.floor(n)!==n)throw zve(jve,n);return n}function mat(n){if(!n)throw Vve(Bve);return n}var gat=Math.pow(2,32)-1;function Aat(n){if(n>gat)throw Vve(Fve,n);return n}var xat=/[^0-9a-fA-F]/;function qve(n){if(Array.isArray(n)&&n.length===2&&Number.isInteger(n[0])&&Number.isInteger(n[1]))return n;if(typeof n!="string"||xat.test(n))return[0,0];var e=parseInt(n.substring(0,n.length-8),r_),t=parseInt(n.substring(n.length-8),r_);return[t,e]}function Vle(n){if(n>=0)return n.toString(r_);n=n&2147483647;var e=Gve(8,n.toString(r_)),t=(parseInt(e[0],r_)+8).toString(r_);return e=t+e.substring(1),e}function vat(n,e){return Vle(e)+Gve(8,Vle(n))}function Gve(n,e){for(var t=n-e.length,r="",i=0;i0){o=hs._calloc(t,h4);for(var l=0;l0){for(var a=hs.getValue(n+r,"i32"),o=0;o0){const{width:o,height:l}=e.context;t.bufferWidth=o,t.bufferHeight=l}const{environmentIntensity:s,environmentRotation:a}=e.scene;t.environmentIntensity=s,t.environmentRotation=a.clone(),t.lights=this.getLightsData(e.lightsNode.getLights(),[]),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const i=e[r];t[r]={id:i.isInterleavedBufferAttribute?i.data.uuid:i.id,version:i.isInterleavedBufferAttribute?i.data.version:i.version}}return t}containsNode(e){const t=e.material;for(const r in t)if(t[r]&&t[r].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getGeometryData(e){let t=Wle.get(e);return t===void 0&&(t={_renderId:-1,_equal:!1,attributes:this.getAttributesData(e.attributes),indexId:e.index?e.index.id:null,indexVersion:e.index?e.index.version:null,drawRange:{start:e.drawRange.start,count:e.drawRange.count}},Wle.set(e,t)),t}getMaterialData(e){let t=$le.get(e);if(t===void 0){t={_renderId:-1,_equal:!1};for(const r of this.refreshUniforms){const i=e[r];i!=null&&(typeof i=="object"&&i.clone!==void 0?i.isTexture===!0?t[r]={id:i.id,version:0}:t[r]=i.clone():t[r]=i)}$le.set(e,t)}return t}equals(e,t,r){const{object:i,material:s,geometry:a}=e,o=this.getRenderObjectData(e);if(o.worldMatrix.equals(i.matrixWorld)!==!0)return o.worldMatrix.copy(i.matrixWorld),!1;const l=this.getMaterialData(e.material);if(l._renderId!==r){l._renderId=r;for(const d in l){const h=l[d],p=s[d];if(d!=="_renderId"&&d!=="_equal"){if(h.equals!==void 0){if(h.equals(p)===!1)return h.copy(p),l._equal=!1,!1}else if(p.isTexture===!0){if(h.id!==p.id||h.version!==p.version)return h.id=p.id,h.version=p.version,l._equal=!1,!1}else if(h!==p)return l[d]=p,l._equal=!1,!1}}if(l.transmission>0){const{width:d,height:h}=e.context;if(o.bufferWidth!==d||o.bufferHeight!==h)return o.bufferWidth=d,o.bufferHeight=h,l._equal=!1,!1}l._equal=!0}else if(l._equal===!1)return!1;if(o.geometryId!==a.id)return o.geometryId=a.id,!1;const c=this.getGeometryData(e.geometry);if(c._renderId!==r){c._renderId=r;const d=a.attributes,h=c.attributes;let p=0,g=0;for(const k in d)p++;for(const k in h){g++;const B=h[k],U=d[k];if(U===void 0)return delete h[k],c._equal=!1,!1;const z=U.isInterleavedBufferAttribute?U.data.uuid:U.id,O=U.isInterleavedBufferAttribute?U.data.version:U.version;if(B.id!==z||B.version!==O)return B.id=z,B.version=O,c._equal=!1,!1}if(g!==p)return c.attributes=this.getAttributesData(d),c._equal=!1,!1;const x=a.index,_=c.indexId,y=c.indexVersion,M=x?x.id:null,C=x?x.version:null;if(_!==M||y!==C)return c.indexId=M,c.indexVersion=C,c._equal=!1,!1;if(c.drawRange.start!==a.drawRange.start||c.drawRange.count!==a.drawRange.count)return c.drawRange.start=a.drawRange.start,c.drawRange.count=a.drawRange.count,c._equal=!1,!1;c._equal=!0}else if(c._equal===!1)return!1;if(o.morphTargetInfluences){let d=!1;for(let h=0;h{const r=t.match(e);if(!r)return null;const i=r[1]||r[2]||"",s=r[3].split("?")[0],a=parseInt(r[4],10),o=parseInt(r[5],10),l=s.split("/").pop();return{fn:i,file:l,line:a,column:o}}).filter(t=>t&&!Lat.some(r=>r.test(t.file)))}class Ol{constructor(e=null){this.isStackTrace=!0,this.stack=kat(e||new Error().stack)}getLocation(){if(this.stack.length===0)return"[Unknown location]";const e=this.stack[0],t=e.fn;return`${t?`"${t}()" at `:""}"${e.file}:${e.line}"`}getError(e){if(this.stack.length===0)return e;const t=this.stack.map(r=>{const i=`${r.file}:${r.line}:${r.column}`;return r.fn?` at ${r.fn} (${i})`:` at ${i}`}).join(` `);return`${e} ${t}`}}function CW(n,e=0){let t=3735928559^e,r=1103547991^e;if(Array.isArray(n))for(let i=0,s;i>>16,2246822507),t^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&r)+(t>>>0)}const G3=n=>CW(n),p6=n=>CW(n),f4=(...n)=>CW(n),Iat=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),Xle=new WeakMap;function Yve(n){return Iat.get(n)}function RC(n){if(/[iu]?vec\d/.test(n))return n.startsWith("ivec")?Int32Array:n.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(n)||/float/.test(n))return Float32Array;if(/uint/.test(n))return Uint32Array;if(/int/.test(n))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${n}`)}function Zve(n){if(/float|int|uint|bool/.test(n))return 1;if(/vec2/.test(n))return 2;if(/vec3/.test(n))return 3;if(/vec4/.test(n)||/mat2/.test(n))return 4;if(/mat3/.test(n))return 9;if(/mat4/.test(n))return 16;on(`TSL: Unsupported type: ${n}`,new Ol)}function Dat(n){if(/float|int|uint|bool/.test(n))return 1;if(/vec2/.test(n))return 2;if(/vec3/.test(n))return 3;if(/vec4/.test(n)||/mat2/.test(n))return 4;if(/mat3/.test(n))return 12;if(/mat4/.test(n))return 16;on(`TSL: Unsupported type: ${n}`,new Ol)}function Oat(n){if(/float|int|uint|bool/.test(n))return 1;if(/vec2/.test(n))return 2;if(/vec3/.test(n)||/vec4/.test(n))return 4;if(/mat2/.test(n))return 2;if(/mat3/.test(n)||/mat4/.test(n))return 4;on(`TSL: Unsupported type: ${n}`,new Ol)}function uA(n){if(n==null)return null;const e=typeof n;return n.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":n.isVector2===!0?"vec2":n.isVector3===!0?"vec3":n.isVector4===!0?"vec4":n.isMatrix2===!0?"mat2":n.isMatrix3===!0?"mat3":n.isMatrix4===!0?"mat4":n.isColor===!0?"color":n instanceof ArrayBuffer?"ArrayBuffer":null}function PW(n,...e){const t=n?n.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),n==="color"?new Fn(...e):t==="vec2"?new en(...e):t==="vec3"?new Fe(...e):t==="vec4"?new gr(...e):t==="mat2"?new pS(...e):t==="mat3"?new ni(...e):t==="mat4"?new ir(...e):n==="bool"?e[0]||!1:n==="float"||n==="int"||n==="uint"?e[0]||0:n==="string"?e[0]||"":n==="ArrayBuffer"?Fat(e[0]):null}function Qve(n){let e=Xle.get(n);return e===void 0&&(e={},Xle.set(n,e)),e}function jat(n){let e="";const t=new Uint8Array(n);for(let r=0;re.charCodeAt(0)).buffer}const Mb={VERTEX:"vertex",FRAGMENT:"fragment"},Or={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},Bat={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Au={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},Kve=["fragment","vertex"],wN=["setup","analyze","generate"],SN=[...Kve,"compute"],sy=["x","y","z","w"],Uat={analyze:"setup",generate:"analyze"};let zat=0;class mr extends zd{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=Or.NONE,this.updateBeforeType=Or.NONE,this.updateAfterType=Or.NONE,this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._uuid=null,this._cacheKeyVersion=0,this.id=zat++,this.stackTrace=null,mr.captureStackTrace===!0&&(this.stackTrace=new Ol)}set needsUpdate(e){e===!0&&this.version++}get uuid(){return this._uuid===null&&(this._uuid=Q0.generateUUID()),this._uuid}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,Or.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Or.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Or.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const r of Object.getOwnPropertyNames(this)){const i=this[r];if(!(r.startsWith("_")===!0||e.has(i))){if(Array.isArray(i)===!0)for(let s=0;s0&&(e.inputNodes=r)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const i=[];for(const s of e.inputNodes[r])i.push(t[s]);this[r]=i}else if(typeof e.inputNodes[r]=="object"){const i={};for(const s in e.inputNodes[r]){const a=e.inputNodes[r][s];i[s]=t[a]}this[r]=i}else{const i=e.inputNodes[r];this[r]=t[i]}}}toJSON(e){const{uuid:t,type:r}=this,i=e===void 0||typeof e=="string";i&&(e={textures:{},images:{},nodes:{}});let s=e.nodes[t];s===void 0&&(s={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},i!==!0&&(e.nodes[s.uuid]=s),this.serialize(s),delete s.meta);function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}if(i){const o=a(e.textures),l=a(e.images),c=a(e.nodes);o.length>0&&(s.textures=o),l.length>0&&(s.images=l),c.length>0&&(s.nodes=c)}return s}}mr.captureStackTrace=!1;class ay extends mr{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}generateNodeType(e){return this.node.getElementType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),r=this.node.build(e),i=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${r}[ ${i} ]`}}class Jve extends mr{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}generateNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const i of this.convertTo.split("|"))(r===null||e.getTypeLength(t)===e.getTypeLength(i))&&(r=i);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,i=this.getNodeType(e),s=r.build(e,i);return e.format(s,i,t)}}class $o extends mr{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const i=e.getVectorType(this.getNodeType(e,t)),s=e.getDataFromNode(this);if(s.propertyName!==void 0)return e.format(s.propertyName,i,t);if(i!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,i),o=e.getVarFromNode(this,null,i),l=e.getPropertyName(o);return e.addLineFlowCode(`${l} = ${a}`,this),s.snippet=a,s.propertyName=l,e.format(s.propertyName,i,t)}}return super.build(e,t)}}class Vat extends $o{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}generateNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,r)=>t+e.getTypeLength(r.getNodeType(e)),0))}generate(e,t){const r=this.getNodeType(e),i=e.getTypeLength(r),s=this.nodes,a=e.getComponentType(r),o=[];let l=0;for(const u of s){if(l>=i){on(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`,this.stackTrace);break}let d=u.getNodeType(e),h=e.getTypeLength(d),p;if(l+h>i&&(on(`TSL: Length of '${r}()' data exceeds maximum length of output type.`,this.stackTrace),h=i-l,d=e.getTypeFromLength(h)),l+=h,p=u.build(e,d),e.getComponentType(d)!==a){const x=e.getTypeFromLength(h,a);p=e.format(p,d,x)}o.push(p)}const c=`${e.getType(r)}( ${o.join(", ")} )`;return e.format(c,r,t)}}const qat=sy.join("");class eye extends mr{static get type(){return"SplitNode"}constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(sy.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}generateNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}getScope(){return this.node.getScope()}generate(e,t){const r=this.node,i=e.getTypeLength(r.getNodeType(e));let s=null;if(i>1){let a=null;this.getVectorLength()>=i&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const l=r.build(e,a);this.components.length===i&&this.components===qat.slice(0,this.components.length)?s=e.format(l,a,t):s=e.format(`${l}.${this.components}`,this.getNodeType(e),t)}else s=r.build(e,t);return s}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Gat extends $o{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}generateNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:i}=this,s=this.getNodeType(e),a=e.getComponentType(i.getNodeType(e)),o=e.getTypeFromLength(r.length,a),l=i.build(e,o),c=t.build(e,s),u=e.getTypeLength(s),d=[];for(let h=0;hn.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),Zle=n=>Wat(n).split("").sort().join("");mr.prototype.assign=function(...n){if(this.isStackNode!==!0)return GA!==null?GA.assign(this,...n):on("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn().",new Ol),this;{const e=GV.get("assign");return this.addToStack(e(...n))}};mr.prototype.toVarIntent=function(){return this};mr.prototype.get=function(n){return new $at(this,n)};const p4={};function R8(n,e,t){p4[n]=p4[e]=p4[t]={get(){this._cache=this._cache||{};let a=this._cache[n];return a===void 0&&(a=new eye(this,n),this._cache[n]=a),a},set(a){this[n].assign(or(a))}};const r=n.toUpperCase(),i=e.toUpperCase(),s=t.toUpperCase();mr.prototype["set"+r]=mr.prototype["set"+i]=mr.prototype["set"+s]=function(a){const o=Zle(n);return new Gat(this,o,or(a))},mr.prototype["flip"+r]=mr.prototype["flip"+i]=mr.prototype["flip"+s]=function(){const a=Zle(n);return new Hat(this,a)}}const wp=["x","y","z","w"],Sp=["r","g","b","a"],Tp=["s","t","p","q"];for(let n=0;n<4;n++){let e=wp[n],t=Sp[n],r=Tp[n];R8(e,t,r);for(let i=0;i<4;i++){e=wp[n]+wp[i],t=Sp[n]+Sp[i],r=Tp[n]+Tp[i],R8(e,t,r);for(let s=0;s<4;s++){e=wp[n]+wp[i]+wp[s],t=Sp[n]+Sp[i]+Sp[s],r=Tp[n]+Tp[i]+Tp[s],R8(e,t,r);for(let a=0;a<4;a++)e=wp[n]+wp[i]+wp[s]+wp[a],t=Sp[n]+Sp[i]+Sp[s]+Sp[a],r=Tp[n]+Tp[i]+Tp[s]+Tp[a],R8(e,t,r)}}}for(let n=0;n<32;n++)p4[n]={get(){this._cache=this._cache||{};let e=this._cache[n];return e===void 0&&(e=new ay(this,new Mm(n,"uint")),this._cache[n]=e),e},set(e){this[n].assign(or(e))}};Object.defineProperties(mr.prototype,p4);const Xat=function(n,e=null){const t=uA(n);return t==="node"?n:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?or(HV(n,e)):t==="shader"?n.isFn?n:Pt(n):n},Yat=function(n,e=null){for(const t in n)n[t]=or(n[t],e);return n},Zat=function(n,e=null){const t=n.length;for(let r=0;rl?(on(`TSL: "${d}" parameter length exceeds limit.`,new Ol),u.slice(0,l)):u}return e===null?s=(...u)=>i(new n(...Bx(c(u)))):t!==null?(t=or(t),s=(...u)=>i(new n(e,...Bx(c(u)),t))):s=(...u)=>i(new n(e,...Bx(c(u)))),s.setParameterLength=(...u)=>(u.length===1?o=l=u[0]:u.length===2&&([o,l]=u),s),s.setName=u=>(a=u,s),s},Qat=function(n,...e){return new n(...Bx(e))};class Kat extends mr{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}generateNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:r}=this,i=e.getNodeProperties(t),s=e.getClosestSubBuild(t.subBuilds)||"",a=s||"default";if(i[a])return i[a];const o=e.subBuildFn,l=e.fnCall;e.subBuildFn=s,e.fnCall=this;let c=null;if(t.layout){if(r){const h=t.layout.inputs;if(nye(r)){const p=r;for(let g=0;g{let M;return Symbol.iterator===_?M=function*(){yield void 0}:M=Reflect.get(x,_,y),M}}),d=r?eot(r):null,h=Array.isArray(r)?r.length>0:r!==null,p=t.jsFunc,g=h||p.length>1?p(d,u):p(u);c=or(g)}return e.subBuildFn=o,e.fnCall=l,t.once&&(i[a]=c),c}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}build(e,t=null){let r=null;const i=e.getBuildStage(),s=e.getNodeProperties(this),a=e.getSubBuildOutput(this),o=this.getOutputNode(e),l=e.fnCall;if(e.fnCall=this,i==="setup"){const c=e.getSubBuildProperty("initialized",this);if(s[c]!==!0&&(s[c]=!0,s[a]=this.getOutputNode(e),s[a].build(e),this.shaderNode.subBuilds))for(const u of e.chaining){const d=e.getDataFromNode(u,"any");d.subBuilds=d.subBuilds||new Set;for(const h of this.shaderNode.subBuilds)d.subBuilds.add(h)}r=s[a]}else i==="analyze"?o.build(e,t):i==="generate"&&(r=o.build(e,t)||"");return e.fnCall=l,r}}function nye(n){return n[0]&&(n[0].isNode||Object.getPrototypeOf(n[0])!==Object.prototype)}function Jat(n){let e;return xR(n),nye(n)?e=[...n]:e=n[0],e}function eot(n){let e=0;return xR(n),new Proxy(n,{get:(t,r,i)=>{let s;if(r==="length")return s=n.length,s;if(Symbol.iterator===r)s=function*(){for(const a of n)yield or(a)};else{if(n.length>0)if(Object.getPrototypeOf(n[0])===Object.prototype){const a=n[0];a[r]===void 0?s=a[e++]:s=Reflect.get(a,r,i)}else n[0]instanceof mr&&(n[r]===void 0?s=n[e++]:s=Reflect.get(n,r,i));else s=Reflect.get(t,r,i);s=or(s)}return s}})}class tot extends mr{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new Kat(this,e)}setup(){return this.call()}}const not=[!1,!0],rot=[0,1,2,3],iot=[-1,-2],rye=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],LW=new Map;for(const n of not)LW.set(n,new Mm(n));const kW=new Map;for(const n of rot)kW.set(n,new Mm(n,"uint"));const IW=new Map([...kW].map(n=>new Mm(n.value,"int")));for(const n of iot)IW.set(n,new Mm(n,"int"));const gR=new Map([...IW].map(n=>new Mm(n.value)));for(const n of rye)gR.set(n,new Mm(n));for(const n of rye)gR.set(-n,new Mm(-n));const AR={bool:LW,uint:kW,ints:IW,float:gR},Qle=new Map([...LW,...gR]),HV=(n,e)=>Qle.has(n)?Qle.get(n):n.isNode===!0?n:new Mm(n,e),Kl=function(n,e=null){return(...t)=>{for(const i of t)if(i===void 0)return on(`TSL: Invalid parameter for the type "${n}".`,new Ol),new Mm(0,n);if((t.length===0||!["bool","float","int","uint"].includes(n)&&t.every(i=>{const s=typeof i;return s!=="object"&&s!=="function"}))&&(t=[PW(n,...t)]),t.length===1&&e!==null&&e.has(t[0]))return B5(e.get(t[0]));if(t.length===1){const i=HV(t[0],n);return i.nodeType===n?B5(i):B5(new Jve(i,n))}const r=t.map(i=>HV(i));return B5(new Vat(r,n))}};function h3(n){return n&&n.isNode&&n.traverse(e=>{e.isConstNode&&(n=e.value)}),!!n}const iye=n=>n!=null?n.nodeType||n.convertTo||(typeof n=="string"?n:null):null;function i_(n,e){return new tot(n,e)}const or=(n,e=null)=>Xat(n,e),B5=(n,e=null)=>or(n,e).toVarIntent(),xR=(n,e=null)=>new Yat(n,e),Bx=(n,e=null)=>new Zat(n,e),Ti=(n,e=null,t=null,r=null)=>new tye(n,e,t,r),Vn=(n,...e)=>new Qat(n,...e),Nn=(n,e=null,t=null,r={})=>new tye(n,e,t,{...r,intent:!0}),DW=(n,e)=>new Proxy(n,{get(t,r,i){return Reflect.get(e,r,i)},set(t,r,i){return Reflect.set(e,r,i)}});let sot=0;class aot extends mr{constructor(e,t=null){super();let r=null;t!==null&&(typeof t=="object"?r=t.return:(typeof t=="string"?r=t:on("TSL: Invalid layout type.",new Ol),t=null)),this.shaderNode=new i_(e,r),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const r={name:"fn"+sot++,type:t,inputs:[]};for(const i in e)i!=="return"&&r.inputs.push({name:i,type:e[i]});e=r}return this.shaderNode.setLayout(e),this}generateNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return on('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".',this.stackTrace),e.generateConst(t)}}function Pt(n,e=null){const t=new aot(n,e);return new Proxy(()=>{},{apply(r,i,s){return t.call(...s)},get(r,i,s){return Reflect.get(t,i,s)},set(r,i,s,a){return Reflect.set(t,i,s,a)}})}const SS=n=>{GA=n},OW=()=>GA,pr=(...n)=>GA.If(...n),oot=(...n)=>GA.Switch(...n);function vR(n){return GA&&GA.addToStack(n),n}cn("toStack",vR);const sye=new Kl("color"),Ze=new Kl("float",AR.float),Tt=new Kl("int",AR.ints),bn=new Kl("uint",AR.uint),uf=new Kl("bool",AR.bool),jn=new Kl("vec2"),bo=new Kl("ivec2"),jW=new Kl("uvec2"),aye=new Kl("bvec2"),Ct=new Kl("vec3"),FW=new Kl("ivec3"),oy=new Kl("uvec3"),BW=new Kl("bvec3"),er=new Kl("vec4"),UW=new Kl("ivec4"),zW=new Kl("uvec4"),oye=new Kl("bvec4"),yR=new Kl("mat2"),Vc=new Kl("mat3"),RA=new Kl("mat4");cn("toColor",sye);cn("toFloat",Ze);cn("toInt",Tt);cn("toUint",bn);cn("toBool",uf);cn("toVec2",jn);cn("toIVec2",bo);cn("toUVec2",jW);cn("toBVec2",aye);cn("toVec3",Ct);cn("toIVec3",FW);cn("toUVec3",oy);cn("toBVec3",BW);cn("toVec4",er);cn("toIVec4",UW);cn("toUVec4",zW);cn("toBVec4",oye);cn("toMat2",yR);cn("toMat3",Vc);cn("toMat4",RA);const lye=Ti(ay).setParameterLength(2),cye=(n,e)=>new Jve(or(n),e),lot=(n,e)=>new eye(or(n),e);cn("element",lye);cn("convert",cye);const cot=n=>(sn("TSL: append() has been renamed to Stack().",new Ol),vR(n));cn("append",n=>(sn("TSL: .append() has been renamed to .toStack().",new Ol),vR(n)));class Ts extends mr{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1,i=null){super(e),this.name=t,this.varying=r,this.placeholderNode=or(i),this.isPropertyNode=!0,this.global=!0}getNodeType(e){const t=super.getNodeType(e);return t==="output"?e.getOutputType():t}customCacheKey(){return G3(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;if(this.varying===!0)t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0;else if(t=e.getVarFromNode(this,this.name),this.placeholderNode!==null&&e.hasWriteUsage(this)===!1){const r=this.placeholderNode.build(e,this.getNodeType(e));e.addLineFlowCode(`${e.getPropertyName(t)} = ${r}`,this)}return e.getPropertyName(t)}}const i1=(n,e,t=null)=>new Ts(n,e,!1,t),ly=(n,e,t=null)=>new Ts(n,e,!0,t),Qs=Vn(Ts,"vec4","DiffuseColor"),hx=Vn(Ts,"vec3","DiffuseContribution"),$V=Vn(Ts,"vec3","EmissiveColor"),qp=Vn(Ts,"float","Roughness"),dg=Vn(Ts,"float","Metalness"),LC=Vn(Ts,"float","Clearcoat"),S_=Vn(Ts,"float","ClearcoatRoughness"),Bh=Vn(Ts,"vec3","Sheen"),J1=Vn(Ts,"float","SheenRoughness"),bR=Vn(Ts,"float","Iridescence"),kC=Vn(Ts,"float","IridescenceIOR"),IC=Vn(Ts,"float","IridescenceThickness"),DC=Vn(Ts,"float","AlphaT"),H1=Vn(Ts,"float","Anisotropy"),m4=Vn(Ts,"vec3","AnisotropyT"),Ux=Vn(Ts,"vec3","AnisotropyB"),HA=Vn(Ts,"color","SpecularColor"),Nx=Vn(Ts,"color","SpecularColorBlended"),Mx=Vn(Ts,"float","SpecularF90"),OC=Vn(Ts,"float","Shininess"),T_=Vn(Ts,"output","Output"),zx=Vn(Ts,"float","dashSize"),TS=Vn(Ts,"float","gapSize"),uot=Vn(Ts,"float","pointWidth"),g4=Vn(Ts,"float","IOR"),jC=Vn(Ts,"float","Transmission"),VW=Vn(Ts,"float","Thickness"),qW=Vn(Ts,"float","AttenuationDistance"),GW=Vn(Ts,"color","AttenuationColor"),HW=Vn(Ts,"float","Dispersion"),WV=Vn(Ts,"float","AmbientOcclusion",!1,1);class uye extends mr{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1,i=null){super("string"),this.name=e,this.shared=t,this.order=r,this.updateType=i,this.isUniformGroup=!0}update(){this.needsUpdate=!0}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}const dye=(n,e=1,t=null)=>new uye(n,!1,e,t),_R=(n,e=0,t=null)=>new uye(n,!0,e,t),dot=_R("frame",0,Or.FRAME),yr=_R("render",0,Or.RENDER),hye=dye("object",1,Or.OBJECT);class m6 extends RW{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=hye}setName(e){return this.name=e,this}label(e){return sn('TSL: "label()" has been deprecated. Use "setName()" instead.',new Ol),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(r=>{const i=e(r,this);i!==void 0&&(this.value=i)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const r=this.getNodeType(e),i=this.getUniformHash(e);let s=e.getNodeFromHash(i);s===void 0&&(e.setHashNode(this,i),s=this);const a=s.getInputType(e),o=e.getUniformFromNode(s,a,e.shaderStage,this.name||e.context.nodeName),l=e.getPropertyName(o);e.context.nodeName!==void 0&&delete e.context.nodeName;let c=l;if(r==="bool"){const u=e.getDataFromNode(this);let d=u.propertyName;if(d===void 0){const h=e.getVarFromNode(this,null,"bool");d=e.getPropertyName(h),u.propertyName=d,c=e.format(l,a,r),e.addLineFlowCode(`${d} = ${c}`,this)}c=d}return e.format(c,r,t)}}const hr=(n,e)=>{const t=iye(e||n);if(t===n&&(n=PW(t)),n&&n.isNode===!0){let r=n.value;n.traverse(i=>{i.isConstNode===!0&&(r=i.value)}),n=r}return new m6(n,t)};class Kle extends $o{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}generateNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const fye=(...n)=>{let e;if(n.length===1){const t=n[0];e=new Kle(null,t.length,t)}else{const t=n[0],r=n[1];e=new Kle(t,r)}return or(e)};cn("toArray",(n,e)=>fye(Array(e).fill(n)));class hot extends $o{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}generateNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return sy.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,i=t.getScope(),s=e.getDataFromNode(i);s.assign=!0;const a=e.getNodeProperties(this);a.sourceNode=r,a.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:i}=e.getNodeProperties(this),s=this.needsSplitAssign(e),a=r.build(e),o=r.getNodeType(e),l=i.build(e,o),c=i.getNodeType(e),u=e.getDataFromNode(this);let d;if(u.initialized===!0)t!=="void"&&(d=a);else if(s){const h=e.getVarFromNode(this,null,o),p=e.getPropertyName(h);e.addLineFlowCode(`${p} = ${l}`,this);const g=r.node,_=g.node.context({assign:!0}).build(e);for(let y=0;y{const u=c.type,d=u==="pointer";let h;return d?h="&"+l.build(e):h=l.build(e,u),h};if(Array.isArray(s)){if(s.length>i.length)on("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),s.length=i.length;else if(s.length(e=e.length>1||e[0]&&e[0].isNode===!0?Bx(e):xR(e[0]),new fot(or(n),e));cn("call",mye);const pot={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class To extends $o{static get type(){return"OperatorNode"}constructor(e,t,r,...i){if(super(),i.length>0){let s=new To(e,t,r);for(let a=0;a>"||r==="<<")return e.getIntegerType(a);if(r==="&&"||r==="||"||r==="^^")return"bool";if(r==="!"){const l=e.getTypeLength(a);return l>1?`bvec${l}`:"bool"}else if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){const l=Math.max(e.getTypeLength(a),e.getTypeLength(o));return l>1?`bvec${l}`:"bool"}else{if(e.isMatrix(a)){if(o==="float")return a;if(e.isVector(o))return e.getVectorFromMatrix(a);if(e.isMatrix(o))return a}else if(e.isMatrix(o)){if(a==="float")return o;if(e.isVector(a))return e.getVectorFromMatrix(o)}return e.getTypeLength(o)>e.getTypeLength(a)?o:a}}generate(e,t){const r=this.op,{aNode:i,bNode:s}=this,a=this.getNodeType(e,t);let o=null,l=null;a!=="void"?(o=i.getNodeType(e),l=s?s.getNodeType(e):null,r==="<"||r===">"||r==="<="||r===">="||r==="=="||r==="!="?e.isVector(o)?l=o:e.isVector(l)?o=l:o!==l&&(o=l="float"):r===">>"||r==="<<"?(o=a,l=e.changeComponentType(l,"uint")):r==="%"?(o=a,l=e.isInteger(o)&&e.isInteger(l)?l:o):e.isMatrix(o)?l==="float"?l="float":e.isVector(l)?l=e.getVectorFromMatrix(o):e.isMatrix(l)||(o=l=a):e.isMatrix(l)?o==="float"?o="float":e.isVector(o)?o=e.getVectorFromMatrix(l):o=l=a:o=l=a):o=l=a;const c=i.build(e,o),u=s?s.build(e,l):null,d=e.getFunctionOperator(r);if(t!=="void"){const h=e.renderer.coordinateSystem===gu;if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">=")return h?e.isVector(o)?e.format(`${this.getOperatorMethod(e,t)}( ${c}, ${u} )`,a,t):e.format(`( ${c} ${r} ${u} )`,a,t):e.format(`( ${c} ${r} ${u} )`,a,t);if(r==="%")return e.isInteger(l)?e.format(`( ${c} % ${u} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${c}, ${u} )`,a,t);if(r==="!")return h&&e.isVector(o)?e.format(`not( ${c} )`,t):e.format(`( ${r} ${c} )`,o,t);if(r==="~")return e.format(`( ${r} ${c} )`,o,t);if(d)return e.format(`${d}( ${c}, ${u} )`,a,t);if(e.isMatrix(o)&&l==="float")return e.format(`( ${u} ${r} ${c} )`,a,t);if(o==="float"&&e.isMatrix(l))return e.format(`${c} ${r} ${u}`,a,t);{let p=`( ${c} ${r} ${u} )`;return!h&&a==="bool"&&e.isVector(o)&&e.isVector(l)&&(p=`all${p}`),e.format(p,a,t)}}else if(o!=="void")return d?e.format(`${d}( ${c}, ${u} )`,a,t):e.isMatrix(o)&&l==="float"?e.format(`${u} ${r} ${c}`,a,t):e.format(`${c} ${r} ${u}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const jl=Nn(To,"+").setParameterLength(2,1/0).setName("add"),Qi=Nn(To,"-").setParameterLength(2,1/0).setName("sub"),Vr=Nn(To,"*").setParameterLength(2,1/0).setName("mul"),df=Nn(To,"/").setParameterLength(2,1/0).setName("div"),wR=Nn(To,"%").setParameterLength(2).setName("mod"),gye=Nn(To,"==").setParameterLength(2).setName("equal"),Aye=Nn(To,"!=").setParameterLength(2).setName("notEqual"),xye=Nn(To,"<").setParameterLength(2).setName("lessThan"),$W=Nn(To,">").setParameterLength(2).setName("greaterThan"),vye=Nn(To,"<=").setParameterLength(2).setName("lessThanEqual"),yye=Nn(To,">=").setParameterLength(2).setName("greaterThanEqual"),bye=Nn(To,"&&").setParameterLength(2,1/0).setName("and"),_ye=Nn(To,"||").setParameterLength(2,1/0).setName("or"),wye=Nn(To,"!").setParameterLength(1).setName("not"),Sye=Nn(To,"^^").setParameterLength(2).setName("xor"),Tye=Nn(To,"&").setParameterLength(2).setName("bitAnd"),Eye=Nn(To,"~").setParameterLength(1).setName("bitNot"),Nye=Nn(To,"|").setParameterLength(2).setName("bitOr"),Mye=Nn(To,"^").setParameterLength(2).setName("bitXor"),Cye=Nn(To,"<<").setParameterLength(2).setName("shiftLeft"),Pye=Nn(To,">>").setParameterLength(2).setName("shiftRight"),Rye=Pt(([n])=>(n.addAssign(1),n)),Lye=Pt(([n])=>(n.subAssign(1),n)),kye=Pt(([n])=>{const e=Tt(n).toConst();return n.addAssign(1),e}),Iye=Pt(([n])=>{const e=Tt(n).toConst();return n.subAssign(1),e});cn("add",jl);cn("sub",Qi);cn("mul",Vr);cn("div",df);cn("mod",wR);cn("equal",gye);cn("notEqual",Aye);cn("lessThan",xye);cn("greaterThan",$W);cn("lessThanEqual",vye);cn("greaterThanEqual",yye);cn("and",bye);cn("or",_ye);cn("not",wye);cn("xor",Sye);cn("bitAnd",Tye);cn("bitNot",Eye);cn("bitOr",Nye);cn("bitXor",Mye);cn("shiftLeft",Cye);cn("shiftRight",Pye);cn("incrementBefore",Rye);cn("decrementBefore",Lye);cn("increment",kye);cn("decrement",Iye);class Vt extends $o{static get type(){return"MathNode"}constructor(e,t,r=null,i=null){if(super(),(e===Vt.MAX||e===Vt.MIN)&&arguments.length>3){let s=new Vt(e,t,r);for(let a=3;aa&&s>o?t:a>o?r:o>s?i:t}generateNodeType(e){const t=this.method;return t===Vt.LENGTH||t===Vt.DISTANCE||t===Vt.DOT?"float":t===Vt.CROSS?"vec3":t===Vt.ALL||t===Vt.ANY?"bool":t===Vt.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:i}=this;let s=null;if(i===Vt.ONE_MINUS)s=Qi(1,t);else if(i===Vt.RECIPROCAL)s=df(1,t);else if(i===Vt.DIFFERENCE)s=ya(Qi(t,r));else if(i===Vt.TRANSFORM_DIRECTION){let a,o;e.isMatrix(t.getNodeType(e))?(a=t,o=r):(a=r,o=t),s=sd(Vr(a,er(Ct(o),0)).xyz)}return s!==null?s:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let i=this.method;const s=this.getNodeType(e),a=this.getInputType(e),o=this.aNode,l=this.bNode,c=this.cNode,u=e.renderer.coordinateSystem;if(i===Vt.NEGATE)return e.format("( - "+o.build(e,a)+" )",s,t);{const d=[];return i===Vt.CROSS?d.push(o.build(e,s),l.build(e,s)):u===gu&&i===Vt.STEP?d.push(o.build(e,e.getTypeLength(o.getNodeType(e))===1?"float":a),l.build(e,a)):u===gu&&(i===Vt.MIN||i===Vt.MAX)?d.push(o.build(e,a),l.build(e,e.getTypeLength(l.getNodeType(e))===1?"float":a)):i===Vt.REFRACT?d.push(o.build(e,a),l.build(e,a),c.build(e,"float")):i===Vt.MIX?d.push(o.build(e,a),l.build(e,a),c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a)):(u===mh&&i===Vt.ATAN&&l!==null&&(i="atan2"),e.shaderStage!=="fragment"&&(i===Vt.DFDX||i===Vt.DFDY)&&(sn(`TSL: '${i}' is not supported in the ${e.shaderStage} stage.`,this.stackTrace),i="/*"+i+"*/"),d.push(o.build(e,a)),l!==null&&d.push(l.build(e,a)),c!==null&&d.push(c.build(e,a))),e.format(`${e.getMethod(i,s)}( ${d.join(", ")} )`,s,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Vt.ALL="all";Vt.ANY="any";Vt.RADIANS="radians";Vt.DEGREES="degrees";Vt.EXP="exp";Vt.EXP2="exp2";Vt.LOG="log";Vt.LOG2="log2";Vt.SQRT="sqrt";Vt.INVERSE_SQRT="inversesqrt";Vt.FLOOR="floor";Vt.CEIL="ceil";Vt.NORMALIZE="normalize";Vt.FRACT="fract";Vt.SIN="sin";Vt.SINH="sinh";Vt.COS="cos";Vt.COSH="cosh";Vt.TAN="tan";Vt.TANH="tanh";Vt.ASIN="asin";Vt.ASINH="asinh";Vt.ACOS="acos";Vt.ACOSH="acosh";Vt.ATAN="atan";Vt.ATANH="atanh";Vt.ABS="abs";Vt.SIGN="sign";Vt.LENGTH="length";Vt.NEGATE="negate";Vt.ONE_MINUS="oneMinus";Vt.DFDX="dFdx";Vt.DFDY="dFdy";Vt.ROUND="round";Vt.RECIPROCAL="reciprocal";Vt.TRUNC="trunc";Vt.FWIDTH="fwidth";Vt.TRANSPOSE="transpose";Vt.DETERMINANT="determinant";Vt.INVERSE="inverse";Vt.EQUALS="equals";Vt.MIN="min";Vt.MAX="max";Vt.STEP="step";Vt.REFLECT="reflect";Vt.DISTANCE="distance";Vt.DIFFERENCE="difference";Vt.DOT="dot";Vt.CROSS="cross";Vt.POW="pow";Vt.TRANSFORM_DIRECTION="transformDirection";Vt.MIX="mix";Vt.CLAMP="clamp";Vt.REFRACT="refract";Vt.SMOOTHSTEP="smoothstep";Vt.FACEFORWARD="faceforward";const SR=Ze(1e-6),mot=Ze(1e6),FC=Ze(Math.PI),got=Ze(Math.PI*2),Aot=Ze(Math.PI*2),xot=Ze(Math.PI*.5),Dye=Nn(Vt,Vt.ALL).setParameterLength(1),Oye=Nn(Vt,Vt.ANY).setParameterLength(1),jye=Nn(Vt,Vt.RADIANS).setParameterLength(1),Fye=Nn(Vt,Vt.DEGREES).setParameterLength(1),WW=Nn(Vt,Vt.EXP).setParameterLength(1),f3=Nn(Vt,Vt.EXP2).setParameterLength(1),TR=Nn(Vt,Vt.LOG).setParameterLength(1),am=Nn(Vt,Vt.LOG2).setParameterLength(1),Fd=Nn(Vt,Vt.SQRT).setParameterLength(1),XW=Nn(Vt,Vt.INVERSE_SQRT).setParameterLength(1),om=Nn(Vt,Vt.FLOOR).setParameterLength(1),ER=Nn(Vt,Vt.CEIL).setParameterLength(1),sd=Nn(Vt,Vt.NORMALIZE).setParameterLength(1),J0=Nn(Vt,Vt.FRACT).setParameterLength(1),Pd=Nn(Vt,Vt.SIN).setParameterLength(1),Bye=Nn(Vt,Vt.SINH).setParameterLength(1),R0=Nn(Vt,Vt.COS).setParameterLength(1),Uye=Nn(Vt,Vt.COSH).setParameterLength(1),zye=Nn(Vt,Vt.TAN).setParameterLength(1),Vye=Nn(Vt,Vt.TANH).setParameterLength(1),qye=Nn(Vt,Vt.ASIN).setParameterLength(1),Gye=Nn(Vt,Vt.ASINH).setParameterLength(1),YW=Nn(Vt,Vt.ACOS).setParameterLength(1),Hye=Nn(Vt,Vt.ACOSH).setParameterLength(1),ZW=Nn(Vt,Vt.ATAN).setParameterLength(1,2),$ye=Nn(Vt,Vt.ATANH).setParameterLength(1),ya=Nn(Vt,Vt.ABS).setParameterLength(1),QW=Nn(Vt,Vt.SIGN).setParameterLength(1),lm=Nn(Vt,Vt.LENGTH).setParameterLength(1),KW=Nn(Vt,Vt.NEGATE).setParameterLength(1),Wye=Nn(Vt,Vt.ONE_MINUS).setParameterLength(1),JW=Nn(Vt,Vt.DFDX).setParameterLength(1),eX=Nn(Vt,Vt.DFDY).setParameterLength(1),Xye=Nn(Vt,Vt.ROUND).setParameterLength(1),Yye=Nn(Vt,Vt.RECIPROCAL).setParameterLength(1),tX=Nn(Vt,Vt.TRUNC).setParameterLength(1),nX=Nn(Vt,Vt.FWIDTH).setParameterLength(1),Zye=Nn(Vt,Vt.TRANSPOSE).setParameterLength(1),Qye=Nn(Vt,Vt.DETERMINANT).setParameterLength(1),Kye=Nn(Vt,Vt.INVERSE).setParameterLength(1),xh=Nn(Vt,Vt.MIN).setParameterLength(2,1/0),Eo=Nn(Vt,Vt.MAX).setParameterLength(2,1/0),jv=Nn(Vt,Vt.STEP).setParameterLength(2),Jye=Nn(Vt,Vt.REFLECT).setParameterLength(2),ebe=Nn(Vt,Vt.DISTANCE).setParameterLength(2),tbe=Nn(Vt,Vt.DIFFERENCE).setParameterLength(2),n0=Nn(Vt,Vt.DOT).setParameterLength(2),Zg=Nn(Vt,Vt.CROSS).setParameterLength(2),Gf=Nn(Vt,Vt.POW).setParameterLength(2),rX=n=>Vr(n,n),nbe=n=>Vr(n,n,n),iX=n=>Vr(n,n,n,n),rbe=Nn(Vt,Vt.TRANSFORM_DIRECTION).setParameterLength(2),ibe=(n,e)=>sd(Vr(e,er(Ct(n),0)).xyz),sbe=(n,e)=>sd(er(Ct(n),0).mul(e).xyz),abe=n=>Vr(QW(n),Gf(ya(n),1/3)),sX=n=>n0(n,n),ki=Nn(Vt,Vt.MIX).setParameterLength(3),ep=(n,e=0,t=1)=>new Vt(Vt.CLAMP,or(n),or(e),or(t)),NR=n=>ep(n),aX=Nn(Vt,Vt.REFRACT).setParameterLength(3),hf=Nn(Vt,Vt.SMOOTHSTEP).setParameterLength(3),oX=Nn(Vt,Vt.FACEFORWARD).setParameterLength(3),obe=Pt(([n])=>{const r=43758.5453,i=n0(n.xy,jn(12.9898,78.233)),s=wR(i,FC);return J0(Pd(s).mul(r))}),lbe=(n,e,t)=>ki(e,t,n),cbe=(n,e,t)=>hf(e,t,n),ube=(n,e)=>jv(e,n),vot=oX,yot=XW;cn("all",Dye);cn("any",Oye);cn("radians",jye);cn("degrees",Fye);cn("exp",WW);cn("exp2",f3);cn("log",TR);cn("log2",am);cn("sqrt",Fd);cn("inverseSqrt",XW);cn("floor",om);cn("ceil",ER);cn("normalize",sd);cn("fract",J0);cn("sin",Pd);cn("sinh",Bye);cn("cos",R0);cn("cosh",Uye);cn("tan",zye);cn("tanh",Vye);cn("asin",qye);cn("asinh",Gye);cn("acos",YW);cn("acosh",Hye);cn("atan",ZW);cn("atanh",$ye);cn("abs",ya);cn("sign",QW);cn("length",lm);cn("lengthSq",sX);cn("negate",KW);cn("oneMinus",Wye);cn("dFdx",JW);cn("dFdy",eX);cn("round",Xye);cn("reciprocal",Yye);cn("trunc",tX);cn("fwidth",nX);cn("min",xh);cn("max",Eo);cn("step",ube);cn("reflect",Jye);cn("distance",ebe);cn("dot",n0);cn("cross",Zg);cn("pow",Gf);cn("pow2",rX);cn("pow3",nbe);cn("pow4",iX);cn("transformDirection",rbe);cn("transformNormalByViewMatrix",ibe);cn("transformNormalByInverseViewMatrix",sbe);cn("mix",lbe);cn("clamp",ep);cn("refract",aX);cn("smoothstep",cbe);cn("faceForward",oX);cn("difference",tbe);cn("saturate",NR);cn("cbrt",abe);cn("transpose",Zye);cn("determinant",Qye);cn("inverse",Kye);cn("rand",obe);class bot extends mr{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}generateNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const i=t.getNodeType(e);if(r!==null){const s=r.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(i))return s}return i}setup(e){const t=this.condNode,r=this.ifNode.isolate(),i=this.elseNode?this.elseNode.isolate():null,s=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=s,i!==null&&(e.getDataFromNode(i).parentNodeBlock=s);const a=e.context.uniformFlow,o=e.getNodeProperties(this);o.condNode=t,o.ifNode=a?r:r.context({nodeBlock:r}),o.elseNode=i?a?i:i.context({nodeBlock:i}):null}generate(e,t){const r=this.getNodeType(e),i=e.getDataFromNode(this);if(i.nodeProperty!==void 0)return i.nodeProperty;const{condNode:s,ifNode:a,elseNode:o}=e.getNodeProperties(this),l=e.currentFunctionNode,c=t!=="void",u=c?i1(r).build(e):"";i.nodeProperty=u;const d=s.build(e,"bool");if(e.context.uniformFlow&&o!==null){const g=a.build(e,r),x=o.build(e,r),_=e.getTernary(d,g,x);return e.format(_,r,t)}e.addFlowCode(` ${e.tab}if ( ${d} ) { `).addFlowTab();let p=a.build(e,r);if(p&&(c?p=u+" = "+p+";":(p="return "+p+";",l===null&&(sn("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),p="// "+p))),e.removeFlowTab().addFlowCode(e.tab+" "+p+` `+e.tab+"}"),o!==null){e.addFlowCode(` else { `).addFlowTab();let g=o.build(e,r);g&&(c?g=u+" = "+g+";":(g="return "+g+";",l===null&&(sn("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values.",this.stackTrace),g="// "+g))),e.removeFlowTab().addFlowCode(e.tab+" "+g+` `+e.tab+`} `)}else e.addFlowCode(` `);return e.format(u,r,t)}}const rd=Ti(bot).setParameterLength(2,3);cn("select",rd);class lX extends mr{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}generateNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),i=this.node.build(e,t);return e.setContext(r),i}}const s1=(n=null,e={})=>{let t=n;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new lX(t,e)},dbe=n=>s1(n,{uniformFlow:!0}),cX=(n,e)=>s1(n,{nodeName:e});function hbe(n,e,t=null){return s1(t,{getShadow:({light:r,shadowColorNode:i})=>e===r?i.mul(n):i})}function fbe(n,e=null){return s1(e,{getAO:(t,{material:r})=>r.transparent===!0?t:t!==null?t.mul(n):n})}function pbe(n,e){return sn('TSL: "label()" has been deprecated. Use "setName()" instead.'),cX(n,e)}cn("context",s1);cn("label",pbe);cn("uniformFlow",dbe);cn("setName",cX);cn("builtinShadowContext",(n,e,t)=>hbe(e,t,n));cn("builtinAOContext",(n,e)=>fbe(e,n));class TN extends mr{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}generateNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){return e.getDataFromNode(this).assign}build(...e){const t=e[0],r=this.getShared(t);if(this!==r)return r.build(...e);if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let i=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const o=t.getDataFromNode(this);o.forceDeclaration=!0,i=!0}const s=t.getBaseStack();i?s.addToStackBefore(this):s.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:i}=this,{renderer:s}=e,a=s.backend.isWebGPUBackend===!0;let o=!1,l=!1;i&&(o=e.isDeterministic(t),l=a?i:o);const c=this.getNodeType(e);if(c=="void")return this.isIntent(e)!==!0&&on('TSL: ".toVar()" can not be used with void type.',this.stackTrace),t.build(e);const u=e.getVectorType(c),d=t.build(e,u),h=e.getVarFromNode(this,r,u,void 0,l),p=e.getPropertyName(h);let g=p;if(l)if(a)g=o?`const ${p}`:`let ${p}`;else{const x=t.getArrayCount(e);g=`const ${e.getVar(h.type,p,x)}`}return e.addLineFlowCode(`${g} = ${d}`,this),p}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const uX=Ti(TN),mbe=(n,e=null)=>uX(n,e).toStack(),gbe=(n,e=null)=>uX(n,e,!0).toStack(),Abe=n=>uX(n).setIntent(!0).toStack();cn("toVar",mbe);cn("toConst",gbe);cn("toVarIntent",Abe);class _ot extends mr{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}generateNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const Vx=(n,e,t=null)=>new _ot(or(n),e,t);class wot extends mr{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=Vx(e,"VERTEX"),this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}generateNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(r===void 0){const i=this.name,s=this.getNodeType(e),a=this.interpolationType,o=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,i,s,a,o),t.node=Vx(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation=e.shaderStage==="fragment"),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Mb.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Mb.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),i=this.setupVarying(e);if(r[t]===void 0){const s=this.getNodeType(e),a=e.getPropertyName(i,Mb.VERTEX);if(e.shaderStage===Mb.VERTEX){const o=r.node.build(e,s);e.addLineFlowCode(`${a} = ${o}`,this)}else e.flowNodeFromShaderStage(Mb.VERTEX,r.node,s,a);r[t]=a}return e.getPropertyName(i)}}const a2=Ti(wot).setParameterLength(1,2),xbe=n=>a2(n);cn("toVarying",a2);cn("toVertexStage",xbe);const vbe=Pt(([n])=>{const e=n.mul(.9478672986).add(.0521327014).pow(2.4),t=n.mul(.0773993808),r=n.lessThanEqual(.04045);return ki(e,t,r)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),ybe=Pt(([n])=>{const e=n.pow(.41666).mul(1.055).sub(.055),t=n.mul(12.92),r=n.lessThanEqual(.0031308);return ki(e,t,r)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),dX="WorkingColorSpace",Sot="OutputColorSpace";class hX extends $o{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===dX?Sr.workingColorSpace:t===Sot?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),i=this.resolveColorSpace(e,this.target);let s=t;return Sr.enabled===!1||r===i||!r||!i||(Sr.getTransfer(r)===rr&&(s=er(vbe(s.rgb),s.a)),Sr.getPrimaries(r)!==Sr.getPrimaries(i)&&(s=er(Vc(Sr._getMatrix(new ni,r,i)).mul(s.rgb),s.a)),Sr.getTransfer(i)===rr&&(s=er(ybe(s.rgb),s.a))),s}}const bbe=(n,e)=>new hX(or(n),dX,e),MR=(n,e)=>new hX(or(n),e,dX),Tot=(n,e,t)=>new hX(or(n),e,t);cn("workingToColorSpace",bbe);cn("colorSpaceToWorking",MR);let Eot=class extends ay{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,r,i)}};class _be extends mr{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=Or.OBJECT}setGroup(e){return this.group=e,this}element(e){return new Eot(this,or(e))}setNodeType(e){const t=hr(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let i=1;inew _be(n,e,t);class Mot extends _be{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(yr)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const wbe=(n,e,t=null)=>new Mot(n,e,t);class Cot extends $o{static get type(){return"ToneMappingNode"}constructor(e,t=Tbe,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return f4(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===cc)return t;let i=null;const s=e.renderer.library.getToneMappingFunction(r);return s!==null?i=er(s(t.rgb,this.exposureNode),t.a):(on("ToneMappingNode: Unsupported Tone Mapping configuration.",r),i=t),i}}const Sbe=(n,e,t)=>new Cot(n,or(e),or(t)),Tbe=wbe("toneMappingExposure","float");cn("toneMapping",(n,e,t)=>Sbe(e,t,n));const Jle=new WeakMap;function ece(n,e){let t=Jle.get(n);return t===void 0&&(t=new U3(n,e),Jle.set(n,t)),t}class C1 extends RW{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=i,this.usage=UA,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){let t;if(this.bufferStride===0&&this.bufferOffset===0){let r=e.globalCache.getData(this.value);r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}generateNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),r=e.getTypeLength(t),i=this.value,s=this.bufferStride||r,a=this.bufferOffset;let o;i.isInterleavedBuffer===!0?o=i:i.isBufferAttribute===!0?o=ece(i.array,s):o=ece(i,s);const l=new kl(o,r,a);o.setUsage(this.usage),this.attribute=l,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.context.nodeName;r!==void 0&&delete e.context.nodeName;const i=e.getBufferAttributeFromNode(this,t,r),s=e.getPropertyName(i);let a=null;if(e.shaderStage==="vertex"||e.shaderStage==="compute")this.name=s,a=s;else{let o;r&&(o=r+"Varying"),a=a2(this,o).build(e,t)}return a}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}function CR(n,e=null,t=0,r=0,i=UA,s=!1){return e==="mat3"||e===null&&n.itemSize===9?Vc(new C1(n,"vec3",9,0).setUsage(i).setInstanced(s),new C1(n,"vec3",9,3).setUsage(i).setInstanced(s),new C1(n,"vec3",9,6).setUsage(i).setInstanced(s)):e==="mat4"||e===null&&n.itemSize===16?RA(new C1(n,"vec4",16,0).setUsage(i).setInstanced(s),new C1(n,"vec4",16,4).setUsage(i).setInstanced(s),new C1(n,"vec4",16,8).setUsage(i).setInstanced(s),new C1(n,"vec4",16,12).setUsage(i).setInstanced(s)):new C1(n,e,t,r).setUsage(i)}const fX=(n,e=null,t=0,r=0)=>CR(n,e,t,r),Pot=(n,e=null,t=0,r=0)=>CR(n,e,t,r,F3),PR=(n,e=null,t=0,r=0)=>CR(n,e,t,r,UA,!0),pX=(n,e=null,t=0,r=0)=>CR(n,e,t,r,F3,!0);cn("toAttribute",n=>fX(n.value));class io extends mr{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let i;if(r===io.VERTEX)i=e.getVertexIndex();else if(r===io.INSTANCE)i=e.getInstanceIndex();else if(r===io.DRAW)i=e.getDrawIndex();else if(r===io.INVOCATION_LOCAL)i=e.getInvocationLocalIndex();else if(r===io.INVOCATION_SUBGROUP)i=e.getInvocationSubgroupIndex();else if(r===io.SUBGROUP)i=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+r);let s;return e.shaderStage==="vertex"||e.shaderStage==="compute"?s=i:s=a2(this).build(e,t),s}}io.VERTEX="vertex";io.INSTANCE="instance";io.SUBGROUP="subgroup";io.INVOCATION_LOCAL="invocationLocal";io.INVOCATION_SUBGROUP="invocationSubgroup";io.DRAW="draw";const Ebe=Vn(io,io.VERTEX),H0=Vn(io,io.INSTANCE),Rot=Vn(io,io.SUBGROUP),Lot=Vn(io,io.INVOCATION_SUBGROUP),kot=Vn(io,io.INVOCATION_LOCAL),Nbe=Vn(io,io.DRAW);class Iot extends mr{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.dispatchSize=null,this.version=1,this.name="",this.updateBeforeType=Or.OBJECT,this.onInitFunction=null,this.countNode=null}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return sn('TSL: "label()" has been deprecated. Use "setName()" instead.',new Ol),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){this.count!==null&&this.countNode===null&&(this.countNode=hr(this.count,"uint").onObjectUpdate(()=>this.count));const t=this.computeNode.build(e);if(t){const r=e.getNodeProperties(this);r.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if(r==="compute"){const i=this.computeNode.build(e,"void");if(i!==""&&e.addLineFlowCode(i,this),this.count!==null&&e.allowEarlyReturns===!0){const s=this.countNode.build(e,"uint"),a=H0.build(e,"uint");e.flow.code=`${e.tab}if ( ${a} >= ${s} ) { return; } ${e.flow.code}`}}else{const s=e.getNodeProperties(this).outputComputeNode;if(s)return s.build(e,t)}}}const mX=(n,e=[64])=>{(e.length===0||e.length>3)&&on("TSL: compute() workgroupSize must have 1, 2, or 3 elements",new Ol);for(let t=0;t{const r=mX(n,t);return typeof e=="number"?r.count=e:r.dispatchSize=e,r};cn("compute",Mbe);cn("computeKernel",mX);class Dot extends mr{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}generateNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const i=this.node.getNodeType(e);return e.setCache(t),i}build(e,...t){const r=e.getCache(),i=e.getCacheFromNode(this,this.parent);e.setCache(i);const s=this.node.build(e,...t);return e.setCache(r),s}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const E_=n=>new Dot(or(n));function Cbe(n,e=!0){return sn('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),E_(n).setParent(e)}cn("cache",Cbe);cn("isolate",E_);class Oot extends mr{static get type(){return"BypassNode"}constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}generateNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return t!==""&&e.addLineFlowCode(t,this),this.outputNode.build(e)}}const Pbe=Ti(Oot).setParameterLength(2);cn("bypass",Pbe);const gX=Pt(([n,e,t,r=Ze(0),i=Ze(1),s=uf(!1)])=>{let a=n.sub(e).div(t.sub(e));return h3(s)&&(a=a.clamp()),a.mul(i.sub(r)).add(r)});function Rbe(n,e,t,r=Ze(0),i=Ze(1)){return gX(n,e,t,r,i,!0)}cn("remap",gX);cn("remapClamp",Rbe);class EN extends mr{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),i=this.snippet;if(r==="void")e.addLineFlowCode(i,this);else return e.format(i,r,t)}}const Yh=Ti(EN).setParameterLength(1,2),Lbe=n=>(n?rd(n,Yh("discard")):Yh("discard")).toStack(),jot=()=>Yh("return").toStack();cn("discard",Lbe);const AX=Pt(([n])=>er(n.rgb.mul(n.a),n.a),{color:"vec4",return:"vec4"}),kbe=Pt(([n])=>n.a.equal(0).select(er(0),er(n.rgb.div(n.a),n.a)),{color:"vec4",return:"vec4"});class Fot extends $o{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;t=er(t.rgb,t.a.clamp(0,1)),t=kbe(t);const r=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||cc,i=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||Rd;return r!==cc&&(t=t.toneMapping(r)),i!==Rd&&i!==Sr.workingColorSpace&&(t=t.workingToColorSpace(i)),t=AX(t),t}}const xX=(n,e=null,t=null)=>new Fot(or(n),e,t);cn("renderOutput",xX);class Bot extends $o{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}generateNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e);if(t!==null)t(e,r);else{const i="--- TSL debug - "+e.shaderStage+" shader ---",s="-".repeat(i.length);let a="";a+="// #"+i+`# `,a+=e.flow.code.replace(/^\t/mg,"")+` `,a+="/* ... */ "+r+` /* ... */ `,a+="// #"+s+`# `,r3(a)}return r}}const Ibe=(n,e=null)=>new Bot(or(n),e).toStack();cn("debug",Ibe);class Dbe extends zd{constructor(){super(),this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class Uot extends mr{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=Or.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}generateNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==Dbe&&ji('TSL: ".toInspector()" is only available with WebGPU.'),t}}function Obe(n,e="",t=null){return n=or(n),n.before(new Uot(n,e,t))}cn("toInspector",Obe);function zot(n){sn("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",n)}class jbe extends mr{static get type(){return"AttributeNode"}constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}generateNodeType(e){let t=this.nodeType;if(t===null){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const i=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(i)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const s=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(s),o=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(o.name,a,r):a2(this).build(e,r)}else return sn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}const ef=(n,e=null)=>new jbe(n,e),na=(n=0)=>ef("uv"+(n>0?n:""),"vec2");class Vot extends mr{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),i=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${i} )`,this.getNodeType(e),t)}}const Fv=Ti(Vot).setParameterLength(1,2);class qot extends m6{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=Or.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&r.width!==void 0){const{width:i,height:s}=r;this.value=Math.log2(Math.max(i,s))}}}const vX=Ti(qot).setParameterLength(1);class Fbe extends Error{constructor(e,t=null){super(e),this.name="NodeError",this.stackTrace=t}}const yX=new Aa;class Am extends m6{static get type(){return"TextureNode"}constructor(e=yX,t=null,r=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.gatherNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Or.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}generateNodeType(){return this.value.isDepthTexture===!0?this.gatherNode===null?"float":"vec4":this.value.type===xs?"uvec4":this.value.type===ml?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return na(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=hr(this.value.matrix)),this._matrixUniform.mul(Ct(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=hr(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(Tt(Fv(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||r.isTexture!==!0)throw new Fbe("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().",this.stackTrace);const i=Pt(()=>{let l=this.uvNode;return(l===null||e.context.forceUVContext===!0)&&e.context.getUV&&(l=e.context.getUV(this,e)),l||(l=this.getDefaultUV()),this.updateMatrix===!0&&(l=this.getTransformedUV(l)),l=this.setupUV(e,l),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?Or.OBJECT:Or.NONE,l})();let s=this.levelNode;s===null&&e.context.getTextureLevel&&(s=e.context.getTextureLevel(this));let a=null,o=null;if(this.compareNode!==null)if(e.renderer.hasCompatibility(n2.TEXTURE_COMPARE))a=this.compareNode;else{const l=r.compareFunction;l===null||l===t6||l===n1||l===t3||l===mm?o=this.compareNode:(a=this.compareNode,ji('TSL: Only "LessCompare", "LessEqualCompare", "GreaterCompare" and "GreaterEqualCompare" are supported for depth texture comparison fallback.'))}t.uvNode=i,t.levelNode=s,t.biasNode=this.biasNode,t.compareNode=a,t.compareStepNode=o,t.gradNode=this.gradNode,t.gatherNode=this.gatherNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,i,s,a,o,l,c,u,d){const h=this.value;let p;return s?p=e.generateTextureBias(h,t,r,s,a,u):l?p=e.generateTextureGrad(h,t,r,l,a,u):c?o?p=e.generateTextureGatherCompare(h,t,r,o,a,u,d):p=e.generateTextureGather(h,t,r,c,a,u,d):o?p=e.generateTextureCompare(h,t,r,o,a,u):this.sampler===!1?p=e.generateTextureLoad(h,t,r,i,a,u):i?p=e.generateTextureLevel(h,t,r,i,a,u):p=e.generateTexture(h,t,r,a,u),p}generate(e,t){const r=this.value,i=e.getNodeProperties(this),s=super.generate(e,"property");if(/^sampler/.test(t))return s+"_sampler";if(e.isReference(t))return s;{const a=e.getDataFromNode(this);let o=this.getNodeType(e),l=a.propertyName;if(l===void 0){const{uvNode:u,levelNode:d,biasNode:h,compareNode:p,compareStepNode:g,depthNode:x,gradNode:_,gatherNode:y,offsetNode:M}=i,C=this.generateUV(e,u),k=d?d.build(e,"float"):null,B=h?h.build(e,"float"):null,U=x?x.build(e,"int"):null,z=p?p.build(e,"float"):null,O=g?g.build(e,"float"):null,V=_?[_[0].build(e,"vec2"),_[1].build(e,"vec2")]:null,$=y?y.build(e,"int"):null,G=M?this.generateOffset(e,M):null,H=this._flipYUniform?this._flipYUniform.build(e,"bool"):null;$&&(o="vec4");let K=U;K===null&&r.isArrayTexture&&this.isTexture3DNode!==!0&&(K="0");const W=e.getVarFromNode(this);l=e.getPropertyName(W);let J=this.generateSnippet(e,s,C,k,B,K,z,V,$,G,H);if(O!==null){const ie=r.compareFunction;ie===t3||ie===mm?J=jv(Yh(J,o),Yh(O,"float")).build(e,o):J=jv(Yh(O,"float"),Yh(J,o)).build(e,o)}e.addLineFlowCode(`${l} = ${J}`,this),a.snippet=J,a.propertyName=l}let c=l;return e.needsToWorkingColorSpace(r)&&(c=MR(Yh(c,o),r.colorSpace).setup(e).build(e,o)),e.format(c,o,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}sample(e){const t=this.clone();return t.uvNode=or(e),t.referenceNode=this.getBase(),or(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=or(e).mul(vX(t)),t.referenceNode=this.getBase();const r=t.value;return t.generateMipmaps===!1&&(r&&r.generateMipmaps===!1||r.minFilter===Ss||r.magFilter===Ss)&&(sn("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),or(t)}level(e){const t=this.clone();return t.levelNode=or(e),t.referenceNode=this.getBase(),or(t)}size(e){return Fv(this,e)}bias(e){const t=this.clone();return t.biasNode=or(e),t.referenceNode=this.getBase(),or(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=or(e),t.referenceNode=this.getBase(),or(t)}grad(e,t){const r=this.clone();return r.gradNode=[or(e),or(t)],r.referenceNode=this.getBase(),or(r)}gather(e=0){const t=this.clone();return t.gatherNode=or(e),t.referenceNode=this.getBase(),or(t)}depth(e){const t=this.clone();return t.depthNode=or(e),t.referenceNode=this.getBase(),or(t)}offset(e){const t=this.clone();return t.offsetNode=or(e),t.referenceNode=this.getBase(),or(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const r=this._flipYUniform;r!==null&&(r.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}const Got=Ti(Am).setParameterLength(1,4).setName("texture"),as=(n=yX,e=null,t=null,r=null)=>{let i;return n&&n.isTextureNode===!0?(i=or(n.clone()),i.referenceNode=n.getBase(),e!==null&&(i.uvNode=or(e)),t!==null&&(i.levelNode=or(t)),r!==null&&(i.biasNode=or(r))):i=Got(n,e,t,r),i},Hot=(n=yX)=>as(n),dl=(...n)=>as(...n).setSampler(!1),$ot=(n,e,t)=>as(n,e).level(t),Wot=n=>(n.isNode===!0?n:as(n)).convert("sampler"),Xot=n=>(n.isNode===!0?n:as(n)).convert("samplerComparison");class bX extends m6{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const H3=(n,e,t)=>new bX(n,e,t);class Yot extends ay{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(e),i=this.node.getPaddedType();return e.format(t,i,r)}}class Zot extends bX{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?uA(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=Or.RENDER,this.isArrayBufferNode=!0}generateNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if(r==="float"||r==="int"||r==="uint")for(let i=0;inew Zot(n,e);class Qot extends mr{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const a1=Ti(Qot).setParameterLength(1);let qw,Gw;class La extends mr{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}generateNodeType(){return this.scope===La.DPR?"float":this.scope===La.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Or.NONE;return(this.scope===La.SIZE||this.scope===La.VIEWPORT||this.scope===La.DPR)&&(e=Or.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===La.VIEWPORT?t!==null?Gw.copy(t.viewport):(e.getViewport(Gw),Gw.multiplyScalar(e.getPixelRatio())):this.scope===La.DPR?this._output.value=e.getPixelRatio():t!==null?(qw.width=t.width,qw.height=t.height):e.getDrawingBufferSize(qw)}setup(){const e=this.scope;let t=null;return e===La.SIZE?t=hr(qw||(qw=new en)):e===La.VIEWPORT?t=hr(Gw||(Gw=new gr)):e===La.DPR?t=hr(1):t=jn(cy.div(Bv)),this._output=t,t}generate(e){if(this.scope===La.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(Bv).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}La.COORDINATE="coordinate";La.VIEWPORT="viewport";La.SIZE="size";La.UV="uv";La.DPR="dpr";const _X=Vn(La,La.DPR),F0=Vn(La,La.UV),Bv=Vn(La,La.SIZE),cy=Vn(La,La.COORDINATE),N_=Vn(La,La.VIEWPORT),wX=N_.zw,Bbe=cy.sub(N_.xy),Kot=Bbe.div(wX),Jot=Pt(()=>(sn('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.',new Ol),Bv),"vec2").once()();let PF=null,L8=null,RF=null,k8=null,LF=null,I8=null,kF=null,D8=null,IF=null,O8=null,DF=null,j8=null,OF=null,F8=null;const o2=hr(0,"uint").setName("u_cameraIndex").setGroup(_R("cameraIndex")).toVarying("v_cameraIndex"),eA=hr("float").setName("cameraNear").setGroup(yr).onRenderUpdate(({camera:n})=>n.near),tA=hr("float").setName("cameraFar").setGroup(yr).onRenderUpdate(({camera:n})=>n.far),Id=Pt(({camera:n})=>{let e;if(n.isArrayCamera&&n.cameras.length>0){const t=[];for(const r of n.cameras)t.push(r.projectionMatrix);L8===null?L8=pu(t).setGroup(yr).setName("cameraProjectionMatrices"):L8.array=t,e=L8.element(n.isMultiViewCamera?a1("gl_ViewID_OVR"):o2)}else PF===null&&(PF=hr(n.projectionMatrix).setName("cameraProjectionMatrix").setGroup(yr).onRenderUpdate(({camera:t})=>t.projectionMatrix)),e=PF;return e}).once()(),Ube=Pt(({camera:n})=>{let e;if(n.isArrayCamera&&n.cameras.length>0){const t=[];for(const r of n.cameras)t.push(r.projectionMatrixInverse);k8===null?k8=pu(t).setGroup(yr).setName("cameraProjectionMatricesInverse"):k8.array=t,e=k8.element(n.isMultiViewCamera?a1("gl_ViewID_OVR"):o2)}else RF===null&&(RF=hr(n.projectionMatrixInverse).setName("cameraProjectionMatrixInverse").setGroup(yr).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse)),e=RF;return e}).once()(),l2=Pt(({camera:n})=>{let e;if(n.isArrayCamera&&n.cameras.length>0){const t=[];for(const r of n.cameras)t.push(r.matrixWorldInverse);I8===null?I8=pu(t).setGroup(yr).setName("cameraViewMatrices"):I8.array=t,e=I8.element(n.isMultiViewCamera?a1("gl_ViewID_OVR"):o2)}else LF===null&&(LF=hr(n.matrixWorldInverse).setName("cameraViewMatrix").setGroup(yr).onRenderUpdate(({camera:t})=>t.matrixWorldInverse)),e=LF;return e}).once()(),g6=Pt(({camera:n})=>{let e;if(n.isArrayCamera&&n.cameras.length>0){const t=[];for(const r of n.cameras)t.push(r.matrixWorld);D8===null?D8=pu(t).setGroup(yr).setName("cameraWorldMatrices"):D8.array=t,e=D8.element(n.isMultiViewCamera?a1("gl_ViewID_OVR"):o2)}else kF===null&&(kF=hr(n.matrixWorld).setName("cameraWorldMatrix").setGroup(yr).onRenderUpdate(({camera:t})=>t.matrixWorld)),e=kF;return e}).once()(),elt=Pt(({camera:n})=>{let e;if(n.isArrayCamera&&n.cameras.length>0){const t=[];for(const r of n.cameras)t.push(r.normalMatrix);O8===null?O8=pu(t).setGroup(yr).setName("cameraNormalMatrices"):O8.array=t,e=O8.element(n.isMultiViewCamera?a1("gl_ViewID_OVR"):o2)}else IF===null&&(IF=hr(n.normalMatrix).setName("cameraNormalMatrix").setGroup(yr).onRenderUpdate(({camera:t})=>t.normalMatrix)),e=IF;return e}).once()(),zbe=Pt(({camera:n})=>{let e;if(n.isArrayCamera&&n.cameras.length>0){const t=[];for(let r=0,i=n.cameras.length;r{const s=r.cameras,a=i.array;for(let o=0,l=s.length;or.value.setFromMatrixPosition(t.matrixWorld))),e=DF;return e}).once()(),tlt=Pt(({camera:n})=>{let e;if(n.isArrayCamera&&n.cameras.length>0){const t=[];for(const r of n.cameras)t.push(r.viewport);F8===null?F8=pu(t,"vec4").setGroup(yr).setName("cameraViewports"):F8.array=t,e=F8.element(o2)}else OF===null&&(OF=er(0,0,Bv.x,Bv.y).toConst("cameraViewport")),e=OF;return e}).once()(),tce=new Vo;class Yi extends mr{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Or.OBJECT,this.uniformNode=new m6(null)}generateNodeType(){const e=this.scope;if(e===Yi.WORLD_MATRIX)return"mat4";if(e===Yi.POSITION||e===Yi.VIEW_POSITION||e===Yi.DIRECTION||e===Yi.SCALE)return"vec3";if(e===Yi.RADIUS)return"float"}update(e){const t=this.object3d,r=this.uniformNode,i=this.scope;if(i===Yi.WORLD_MATRIX)r.value=t.matrixWorld;else if(i===Yi.POSITION)r.value=r.value||new Fe,r.value.setFromMatrixPosition(t.matrixWorld);else if(i===Yi.SCALE)r.value=r.value||new Fe,r.value.setFromMatrixScale(t.matrixWorld);else if(i===Yi.DIRECTION)r.value=r.value||new Fe,t.getWorldDirection(r.value);else if(i===Yi.VIEW_POSITION){const s=e.camera;r.value=r.value||new Fe,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(s.matrixWorldInverse)}else if(i===Yi.RADIUS){const s=e.object.geometry;s.boundingSphere===null&&s.computeBoundingSphere(),tce.copy(s.boundingSphere).applyMatrix4(t.matrixWorld),r.value=tce.radius}}generate(e){const t=this.scope;return t===Yi.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===Yi.POSITION||t===Yi.VIEW_POSITION||t===Yi.DIRECTION||t===Yi.SCALE?this.uniformNode.nodeType="vec3":t===Yi.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}Yi.WORLD_MATRIX="worldMatrix";Yi.POSITION="position";Yi.SCALE="scale";Yi.VIEW_POSITION="viewPosition";Yi.DIRECTION="direction";Yi.RADIUS="radius";const nlt=Ti(Yi,Yi.DIRECTION).setParameterLength(1),rlt=Ti(Yi,Yi.WORLD_MATRIX).setParameterLength(1),ilt=Ti(Yi,Yi.POSITION).setParameterLength(1),slt=Ti(Yi,Yi.SCALE).setParameterLength(1),alt=Ti(Yi,Yi.VIEW_POSITION).setParameterLength(1),olt=Ti(Yi,Yi.RADIUS).setParameterLength(1);class r0 extends Yi{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const llt=Vn(r0,r0.DIRECTION),Hf=Vn(r0,r0.WORLD_MATRIX),clt=Vn(r0,r0.POSITION),ult=Vn(r0,r0.SCALE),dlt=Vn(r0,r0.VIEW_POSITION),hlt=Vn(r0,r0.RADIUS),Vbe=hr(new ni).onObjectUpdate(({object:n},e)=>e.value.getNormalMatrix(n.matrixWorld)),flt=hr(new ir).onObjectUpdate(({object:n},e)=>e.value.copy(n.matrixWorld).invert()),xm=Pt(n=>n.context.modelViewMatrix||qbe).once()().toVar("modelViewMatrix"),qbe=l2.mul(Hf),XV=Pt(n=>(n.context.isHighPrecisionModelViewMatrix=!0,hr("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),YV=Pt(n=>{const e=n.context.isHighPrecisionModelViewMatrix;return hr("mat3").onObjectUpdate(({object:t,camera:r})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Gbe=Pt(n=>n.shaderStage!=="fragment"?(ji("TSL: `clipSpace` is only available in fragment stage."),er()):n.context.clipSpace.toVarying("v_clipSpace")).once()(),Yu=ef("position","vec3"),oo=Yu.toVarying("positionLocal"),Uv=Yu.toVarying("positionPrevious"),cm=Pt(n=>Hf.mul(oo).xyz.toVarying(n.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),SX=Pt(()=>oo.transformDirection(Hf).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),gl=Pt(n=>{if(n.shaderStage==="fragment"&&n.material.vertexNode){const e=Ube.mul(Gbe);return e.xyz.div(e.w).toVar("positionView")}return n.context.setupPositionView().toVarying("v_positionView")},"vec3").once(["POSITION","VERTEX"])(),fa=Pt(n=>{let e;return n.camera.isOrthographicCamera?e=Ct(0,0,1):e=gl.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class plt extends mr{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===Ds?"false":e.getFrontFacing()}}const Hbe=Vn(plt),TX=Ze(Hbe).mul(2).sub(1),uy=Pt(([n],{material:e})=>{const t=e.side;return t===Ds?n=n.mul(-1):t===ao&&(n=n.mul(TX)),n}),mlt=n=>(ji('TSL: "directionToFaceDirection()" has been renamed to "negateOnBackSide()".'),uy(n)),RR=ef("normal","vec3"),ud=Pt(n=>n.geometry.hasAttribute("normal")===!1?(sn('TSL: Vertex attribute "normal" not found on geometry.'),Ct(0,1,0)):RR,"vec3").once()().toVar("normalLocal"),$be=gl.dFdx().cross(gl.dFdy()).normalize().toVar("normalFlat"),p3=Pt(n=>{let e;return n.isFlatShading()?e=$be:e=NX(ud).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),Wbe=Pt(n=>{let e=p3.transformNormalByInverseViewMatrix(l2);return n.isFlatShading()!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),ss=Pt(n=>{let e;return n.subBuildFn==="NORMAL"||n.subBuildFn==="VERTEX"?(e=p3,n.isFlatShading()!==!0&&(e=uy(e))):e=n.context.setupNormal().context({getUV:null,getTextureLevel:null}),e},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),c2=ss.transformNormalByInverseViewMatrix(l2).toVar("normalWorld"),nA=Pt(({subBuildFn:n,context:e})=>{let t;return n==="NORMAL"||n==="VERTEX"?t=ss:t=e.setupClearcoatNormal().context({getUV:null,getTextureLevel:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),EX=Pt(([n,e=Hf])=>Vc(e).inverse().transpose().mul(n).normalize());cn("transformNormal",EX);const NX=Pt(([n],e)=>{const t=e.context.modelNormalViewMatrix;return t?n.transformNormalByViewMatrix(t):Vbe.mul(n).transformNormalByViewMatrix(l2)}),glt=Pt(()=>(sn('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),ss)).once(["NORMAL","VERTEX"])(),Alt=Pt(()=>(sn('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),c2)).once(["NORMAL","VERTEX"])(),xlt=Pt(()=>(sn('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),nA)).once(["NORMAL","VERTEX"])(),jF=new ir,Xbe=hr(0).onReference(({material:n})=>n).onObjectUpdate(({material:n})=>n.refractionRatio),NN=hr(1).onReference(({material:n})=>n).onObjectUpdate(function({material:n,scene:e}){return n.envMap?n.envMapIntensity:e.environmentIntensity}),BC=hr(new ir).onReference(function(n){return n.material}).onObjectUpdate(function({material:n,scene:e}){const r=(e.environment!==null||e.environmentNode&&e.environmentNode.isNode)&&n.envMap===null?e.environmentRotation:n.envMapRotation;return r?jF.makeRotationFromEuler(r).transpose():jF.identity(),jF}),Ybe=fa.negate().reflect(ss),Zbe=fa.negate().refract(ss,Xbe),Qbe=Ybe.transformDirection(g6).toVar("reflectVector"),Kbe=Zbe.transformDirection(g6).toVar("refractVector"),Jbe=new r1;class vlt extends Am{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,i=null){super(e,t,r,i),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===ph?Qbe:e.mapping===e0?Kbe:(on('CubeTextureNode: Mapping "%s" not supported.',e.mapping),Ct(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return r.isDepthTexture===!0?e.renderer.coordinateSystem===mh?Ct(t.x,t.y.negate(),t.z):t:(t=BC.mul(t),(e.renderer.coordinateSystem===mh||!r.isRenderTargetTexture)&&(t=Ct(t.x.negate(),t.yz)),t)}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const MX=Ti(vlt).setParameterLength(1,4).setName("cubeTexture"),kd=(n=Jbe,e=null,t=null,r=null)=>{let i;return n&&n.isCubeTextureNode===!0?(i=or(n.clone()),i.referenceNode=n,e!==null&&(i.uvNode=or(e)),t!==null&&(i.levelNode=or(t)),r!==null&&(i.biasNode=or(r))):i=MX(n,e,t,r),i},ylt=(n=Jbe)=>MX(n);class blt extends ay{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}generateNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(e),i=this.getNodeType(e);return e.format(t,r,i)}}class LR extends mr{static get type(){return"ReferenceNode"}constructor(e,t,r=null,i=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=i,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=Or.OBJECT}element(e){return new blt(this,or(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return sn('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=H3(null,e,this.count):Array.isArray(this.getValueFromReference())?(t=pu(null,e),t.updateType=Or.OBJECT):e==="texture"?t=as(null):e==="cubeTexture"?t=kd(null):t=hr(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}generateNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let i=1;inew LR(n,e,t),e_e=(n,e,t,r)=>new LR(n,e,r,t);class _lt extends LR{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const tg=(n,e,t=null)=>new _lt(n,e,t),t_e=na(),wlt=gl.dFdx(),Slt=gl.dFdy(),n_e=t_e.dFdx(),r_e=t_e.dFdy(),i_e=ss,s_e=Slt.cross(i_e),a_e=i_e.cross(wlt),ZV=s_e.mul(n_e.x).add(a_e.mul(r_e.x)),QV=s_e.mul(n_e.y).add(a_e.mul(r_e.y)),nce=ZV.dot(ZV).max(QV.dot(QV)),o_e=nce.equal(0).select(0,nce.inverseSqrt()),Tlt=ZV.mul(o_e).toVar("tangentViewFrame"),Elt=QV.mul(o_e).toVar("bitangentViewFrame"),kR=ef("tangent","vec4"),$A=kR.xyz.toVar("tangentLocal"),IR=Pt(n=>{let e;return n.subBuildFn==="VERTEX"||n.geometry.hasAttribute("tangent")?e=xm.mul(er($A,0)).xyz.toVarying("v_tangentView").normalize():e=Tlt,n.isFlatShading()!==!0&&(e=uy(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),l_e=IR.transformDirection(g6).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),DR=Pt(([n,e],t)=>{let r=n.mul(kR.w).xyz;return t.subBuildFn==="NORMAL"&&t.isFlatShading()!==!0&&(r=r.toVarying(e)),r}).once(["NORMAL"]),Nlt=DR(RR.cross(kR),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),Mlt=DR(ud.cross($A),"v_bitangentLocal").normalize().toVar("bitangentLocal"),c_e=Pt(n=>{let e;return n.subBuildFn==="VERTEX"||n.geometry.hasAttribute("tangent")?e=DR(ss.cross(IR),"v_bitangentView").normalize():e=Elt,n.isFlatShading()!==!0&&(e=uy(e)),e},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),Clt=DR(c2.cross(l_e),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Cx=Vc(IR,c_e,ss).toVar("TBNViewMatrix"),u_e=fa.mul(Cx),Plt=(n,e)=>n.sub(u_e.mul(e)),d_e=Pt(()=>{let n=Ux.cross(fa);return n=n.cross(Ux).normalize(),n=ki(n,ss,H1.mul(qp.oneMinus()).oneMinus().pow2().pow2()).normalize(),n}).once()(),CX=n=>or(n).mul(.5).add(.5),h_e=n=>or(n).mul(2).sub(1),KV=n=>Ct(n,Fd(NR(Ze(1).sub(n0(n,n))))),Rlt=n=>(ji('TSL: "directionToColor()" has been renamed to "packNormalToRGB()".'),CX(n)),Llt=n=>(ji('TSL: "colorToDirection()" has been renamed to "unpackRGBToNormal()".'),h_e(n));class klt extends $o{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Xf,this.unpackNormalMode=mN}setup(e){const{normalMapType:t,scaleNode:r,unpackNormalMode:i}=this;let s=this.node.mul(2).sub(1);if(t===Xf?i===T$?s=KV(s.xy):i===M2e?s=KV(s.yw):i!==mN&&on(`THREE.NodeMaterial: Unexpected unpack normal mode: ${i}`):i!==mN&&on(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${i}'`),r!==null){let o=r;e.isFlatShading()===!0&&(o=uy(o)),s=Ct(s.xy.mul(o),s.z)}let a=null;return t===S$?a=NX(s):t===Xf?a=Cx.mul(s).normalize():(on(`NodeMaterial: Unsupported normal map type: ${t}`),a=ss),a}}const JV=Ti(klt).setParameterLength(1,2),Ilt=Pt(({textureNode:n,bumpScale:e})=>{const t=i=>n.isolate().context({getUV:s=>i(s.uvNode||na()),forceUVContext:!0}),r=Ze(t(i=>i));return jn(Ze(t(i=>i.add(i.dFdx()))).sub(r),Ze(t(i=>i.add(i.dFdy()))).sub(r)).mul(e)}),Dlt=Pt(n=>{const{surf_pos:e,surf_norm:t,dHdxy:r}=n,i=e.dFdx().normalize(),s=e.dFdy().normalize(),a=t,o=s.cross(a),l=a.cross(i),c=i.dot(o).mul(TX),u=c.sign().mul(r.x.mul(o).add(r.y.mul(l)));return c.abs().mul(t).sub(u).normalize()});class Olt extends $o{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(e){if(e.material.wireframe===!0)return ss;const t=this.scaleNode!==null?this.scaleNode:1,r=Ilt({textureNode:this.textureNode,bumpScale:t});return Dlt({surf_pos:gl,surf_norm:ss,dHdxy:r})}}const PX=Ti(Olt).setParameterLength(1,2),rce=new Map;class fn extends mr{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=rce.get(e);return r===void 0&&(r=tg(e,t),rce.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let i=null;if(r===fn.COLOR){const s=t.color!==void 0?this.getColor(r):Ct();t.map&&t.map.isTexture===!0?i=s.mul(this.getTexture("map")):i=s}else if(r===fn.OPACITY){const s=this.getFloat(r);t.alphaMap&&t.alphaMap.isTexture===!0?i=s.mul(this.getTexture("alpha")):i=s}else if(r===fn.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?i=this.getTexture("specular").r:i=Ze(1);else if(r===fn.SPECULAR_INTENSITY){const s=this.getFloat(r);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?i=s.mul(this.getTexture(r).a):i=s}else if(r===fn.SPECULAR_COLOR){const s=this.getColor(r);t.specularColorMap&&t.specularColorMap.isTexture===!0?i=s.mul(this.getTexture(r).rgb):i=s}else if(r===fn.ROUGHNESS){const s=this.getFloat(r);t.roughnessMap&&t.roughnessMap.isTexture===!0?i=s.mul(this.getTexture(r).g):i=s}else if(r===fn.METALNESS){const s=this.getFloat(r);t.metalnessMap&&t.metalnessMap.isTexture===!0?i=s.mul(this.getTexture(r).b):i=s}else if(r===fn.EMISSIVE){const s=this.getFloat("emissiveIntensity"),a=this.getColor(r).mul(s);t.emissiveMap&&t.emissiveMap.isTexture===!0?i=a.mul(this.getTexture(r)):i=a}else if(r===fn.NORMAL)t.normalMap?(i=JV(this.getTexture("normal"),this.getCache("normalScale","vec2")),i.normalMapType=t.normalMapType,(t.normalMap.format==dc||t.normalMap.format==zg||t.normalMap.format==Ug)&&(i.unpackNormalMode=T$)):t.bumpMap?i=PX(this.getTexture("bump").r,this.getFloat("bumpScale")):i=ss;else if(r===fn.CLEARCOAT){const s=this.getFloat(r);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?i=s.mul(this.getTexture(r).r):i=s}else if(r===fn.CLEARCOAT_ROUGHNESS){const s=this.getFloat(r);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(r).r):i=s}else if(r===fn.CLEARCOAT_NORMAL)t.clearcoatNormalMap?i=JV(this.getTexture(r),this.getCache(r+"Scale","vec2")):i=ss;else if(r===fn.SHEEN){const s=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?i=s.mul(this.getTexture("sheenColor").rgb):i=s}else if(r===fn.SHEEN_ROUGHNESS){const s=this.getFloat(r);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?i=s.mul(this.getTexture(r).a):i=s,i=i.clamp(1e-4,1)}else if(r===fn.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const s=this.getTexture(r);i=yR(Cb.x,Cb.y,Cb.y.negate(),Cb.x).mul(s.rg.mul(2).sub(jn(1)).normalize().mul(s.b))}else i=Cb;else if(r===fn.IRIDESCENCE_THICKNESS){const s=ka("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=ka("0","float",t.iridescenceThicknessRange);i=s.sub(a).mul(this.getTexture(r).g).add(a)}else i=s}else if(r===fn.TRANSMISSION){const s=this.getFloat(r);t.transmissionMap?i=s.mul(this.getTexture(r).r):i=s}else if(r===fn.THICKNESS){const s=this.getFloat(r);t.thicknessMap?i=s.mul(this.getTexture(r).g):i=s}else if(r===fn.IOR)i=this.getFloat(r);else if(r===fn.LIGHT_MAP)t.lightMap?i=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity")):i=Ct(0);else if(r===fn.AO)t.aoMap?i=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1):i=Ze(1);else if(r===fn.LINE_DASH_OFFSET)i=t.dashOffset?this.getFloat(r):Ze(0);else{const s=this.getNodeType(e);i=this.getCache(r,s)}return i}}fn.ALPHA_TEST="alphaTest";fn.COLOR="color";fn.OPACITY="opacity";fn.SHININESS="shininess";fn.SPECULAR="specular";fn.SPECULAR_STRENGTH="specularStrength";fn.SPECULAR_INTENSITY="specularIntensity";fn.SPECULAR_COLOR="specularColor";fn.REFLECTIVITY="reflectivity";fn.ROUGHNESS="roughness";fn.METALNESS="metalness";fn.NORMAL="normal";fn.CLEARCOAT="clearcoat";fn.CLEARCOAT_ROUGHNESS="clearcoatRoughness";fn.CLEARCOAT_NORMAL="clearcoatNormal";fn.EMISSIVE="emissive";fn.ROTATION="rotation";fn.SHEEN="sheen";fn.SHEEN_ROUGHNESS="sheenRoughness";fn.ANISOTROPY="anisotropy";fn.IRIDESCENCE="iridescence";fn.IRIDESCENCE_IOR="iridescenceIOR";fn.IRIDESCENCE_THICKNESS="iridescenceThickness";fn.IOR="ior";fn.TRANSMISSION="transmission";fn.THICKNESS="thickness";fn.ATTENUATION_DISTANCE="attenuationDistance";fn.ATTENUATION_COLOR="attenuationColor";fn.LINE_SCALE="scale";fn.LINE_DASH_SIZE="dashSize";fn.LINE_GAP_SIZE="gapSize";fn.LINE_WIDTH="linewidth";fn.LINE_DASH_OFFSET="dashOffset";fn.POINT_SIZE="size";fn.DISPERSION="dispersion";fn.LIGHT_MAP="light";fn.AO="ao";const f_e=Vn(fn,fn.ALPHA_TEST),p_e=Vn(fn,fn.COLOR),m_e=Vn(fn,fn.SHININESS),g_e=Vn(fn,fn.EMISSIVE),RX=Vn(fn,fn.OPACITY),A_e=Vn(fn,fn.SPECULAR),eq=Vn(fn,fn.SPECULAR_INTENSITY),x_e=Vn(fn,fn.SPECULAR_COLOR),A4=Vn(fn,fn.SPECULAR_STRENGTH),MN=Vn(fn,fn.REFLECTIVITY),v_e=Vn(fn,fn.ROUGHNESS),y_e=Vn(fn,fn.METALNESS),b_e=Vn(fn,fn.NORMAL),__e=Vn(fn,fn.CLEARCOAT),w_e=Vn(fn,fn.CLEARCOAT_ROUGHNESS),S_e=Vn(fn,fn.CLEARCOAT_NORMAL),T_e=Vn(fn,fn.ROTATION),E_e=Vn(fn,fn.SHEEN),N_e=Vn(fn,fn.SHEEN_ROUGHNESS),M_e=Vn(fn,fn.ANISOTROPY),C_e=Vn(fn,fn.IRIDESCENCE),P_e=Vn(fn,fn.IRIDESCENCE_IOR),R_e=Vn(fn,fn.IRIDESCENCE_THICKNESS),L_e=Vn(fn,fn.TRANSMISSION),k_e=Vn(fn,fn.THICKNESS),I_e=Vn(fn,fn.IOR),D_e=Vn(fn,fn.ATTENUATION_DISTANCE),O_e=Vn(fn,fn.ATTENUATION_COLOR),LX=Vn(fn,fn.LINE_SCALE),kX=Vn(fn,fn.LINE_DASH_SIZE),IX=Vn(fn,fn.LINE_GAP_SIZE),UC=Vn(fn,fn.LINE_WIDTH),DX=Vn(fn,fn.LINE_DASH_OFFSET),j_e=Vn(fn,fn.POINT_SIZE),F_e=Vn(fn,fn.DISPERSION),OX=Vn(fn,fn.LIGHT_MAP),B_e=Vn(fn,fn.AO),Cb=hr(new en).onReference(function(n){return n.material}).onRenderUpdate(function({material:n}){this.value.set(n.anisotropy*Math.cos(n.anisotropyRotation),n.anisotropy*Math.sin(n.anisotropyRotation))}),U_e=Pt(n=>n.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class $l extends mr{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===$l.OBJECT?this.updateType=Or.OBJECT:e===$l.MATERIAL?this.updateType=Or.RENDER:e===$l.FRAME?this.updateType=Or.FRAME:e===$l.BEFORE_OBJECT?this.updateBeforeType=Or.OBJECT:e===$l.BEFORE_MATERIAL?this.updateBeforeType=Or.RENDER:e===$l.BEFORE_FRAME&&(this.updateBeforeType=Or.FRAME)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}$l.OBJECT="object";$l.MATERIAL="material";$l.FRAME="frame";$l.BEFORE_OBJECT="beforeObject";$l.BEFORE_MATERIAL="beforeMaterial";$l.BEFORE_FRAME="beforeFrame";const $3=(n,e)=>new $l(n,e).toStack(),A6=n=>$3($l.OBJECT,n),jlt=n=>$3($l.MATERIAL,n),z_e=n=>$3($l.FRAME,n),Flt=n=>$3($l.BEFORE_OBJECT,n),Blt=n=>$3($l.BEFORE_MATERIAL,n),Ult=n=>$3($l.BEFORE_FRAME,n);class zlt extends ay{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const i=e.isContextAssign();if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&i!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?r=e.generatePBO(this):r=this.node.build(e):r=super.generate(e),i!==!0){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}const Vlt=Ti(zlt).setParameterLength(2);class qlt extends bX{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let i,s=null;t&&t.isStructTypeNode?(i="struct",s=t,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(i=Yve(e.itemSize),r=e.count):i=t,super(e,i,r),this.isStorageBufferNode=!0,this.structTypeNode=s,this.access=Au.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){let t;if(this.bufferCount===0){let r=e.globalCache.getData(this.value);r===void 0&&(r={node:this},e.globalCache.setData(this.value,r)),t=r.node.id}else t=this.id;return String(t)}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return Vlt(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(Au.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=fX(this.value),this._varying=a2(this._attribute)),{attribute:this._attribute,varying:this._varying}}generateNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generateNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),i=r.build(e);return e.registerTransform(i,t),i}}const LA=(n,e=null,t=0)=>new qlt(n,e,t),tq=new WeakMap,ice=new WeakMap,nq=new WeakMap;function V_e(n,e){let t;const r=Math.max(e.count,1);if(e.isStorageInstancedBufferAttribute===!0)t=LA(e,"mat4",r).element(H0);else if(r*16*4<=n.getUniformBufferLimit())t=H3(e.array,"mat4",r).element(H0);else{let a=tq.get(e);a||(a=new VA(e.array,16,1),tq.set(e,a));const o=e.usage===F3?pX:PR,l=[o(a,"vec4",16,0),o(a,"vec4",16,4),o(a,"vec4",16,8),o(a,"vec4",16,12)];t=RA(...l)}return t}function Glt(n,e,t){let r=nq.get(n);if(r===void 0){const i=e.clone();r={previousInstanceMatrix:i,node:V_e(t,i)},nq.set(n,r)}return r.node}const jX=ly("vec3","vInstanceColor"),q_e=Pt(([n,e=null],t)=>{const r=n.isStorageInstancedBufferAttribute===!0,i=e&&e.isStorageInstancedBufferAttribute===!0,s=V_e(t,n);let a=null;r||Math.max(n.count,1)*16*4>t.getUniformBufferLimit()&&(a=tq.get(n));let o=null,l=null;if(e)if(i)o=LA(e,"vec3",Math.max(e.count,1)).element(H0);else{let u=ice.get(e);u||(u=new jd(e.array,3),ice.set(e,u)),l=u;const d=e.usage===F3?pX:PR;o=Ct(d(u,"vec3",3,0))}(a!==null||l!==null)&&z_e(()=>{a!==null&&(a.clearUpdateRanges(),a.updateRanges.push(...n.updateRanges),n.version!==a.version&&(a.version=n.version)),e&&l!==null&&(l.clearUpdateRanges(),l.updateRanges.push(...e.updateRanges),e.version!==l.version&&(l.version=e.version))});const c=s.mul(oo).xyz;if(oo.assign(c),t.needsPreviousData()){const u=t.object;A6(({object:h})=>{nq.get(h).previousInstanceMatrix.array.set(n.array)});const d=Glt(u,n,t);Uv.assign(d.mul(Uv).xyz)}if(t.hasGeometryAttribute("normal")){const u=EX(ud,s);ud.assign(u)}o!==null&&jX.assign(o)},"void"),G_e=Pt(([n])=>{const{instanceMatrix:e,instanceColor:t}=n;q_e(e,t)},"void"),Hlt=Pt(([n,e])=>{const t=Tt(Fv(dl(n),0).x).toConst(),r=Tt(e),i=r.mod(t).toConst(),s=r.div(t).toConst();return dl(n,bo(i,s))}),$lt=Pt(([n,e])=>{const t=Tt(Fv(dl(n),0).x).toConst(),r=Tt(e).mod(t).toConst(),i=Tt(e).div(t).toConst();return dl(n,bo(r,i)).x}),FX=ly("vec4","vBatchColor"),H_e=Pt(([n],e)=>{const t=e.getDrawIndex()===null?H0:Nbe,r=$lt(n._indirectTexture,Tt(t)),i=n._matricesTexture,s=Tt(Fv(dl(i),0).x).toConst(),a=Ze(r).mul(4).toInt().toConst(),o=a.mod(s).toConst(),l=a.div(s).toConst(),c=RA(dl(i,bo(o,l)),dl(i,bo(o.add(1),l)),dl(i,bo(o.add(2),l)),dl(i,bo(o.add(3),l))),u=n._colorsTexture;if(u!==null){const g=Hlt(u,r);FX.assign(g)}const d=Vc(c);oo.assign(c.mul(oo));const h=ud.div(Ct(d[0].dot(d[0]),d[1].dot(d[1]),d[2].dot(d[2]))),p=d.mul(h).xyz;ud.assign(p),e.hasGeometryAttribute("tangent")&&$A.mulAssign(d)},"void"),zC=new WeakMap,VC=new WeakMap;function BX(n,e,t,r,i,s){const a=n.element(i.x),o=n.element(i.y),l=n.element(i.z),c=n.element(i.w),u=t.mul(e),d=jl(a.mul(s.x).mul(u),o.mul(s.y).mul(u),l.mul(s.z).mul(u),c.mul(s.w).mul(u));return r.mul(d).xyz}function $_e(n,e,t,r,i,s,a){const o=n.element(s.x),l=n.element(s.y),c=n.element(s.z),u=n.element(s.w);let d=jl(a.x.mul(o),a.y.mul(l),a.z.mul(c),a.w.mul(u));d=i.mul(d).mul(r);const h=d.transformDirection(e).xyz,p=d.transformDirection(t).xyz;return{skinNormal:h,skinTangent:p}}function W_e(n,e,t,r,i){const s=n.skeleton;let a=VC.get(s);if(a===void 0){s.update();const o=new Float32Array(s.boneMatrices);a={previousBoneMatrices:o,node:H3(o,"mat4",s.bones.length)},VC.set(s,a)}return BX(a.node,Uv,e,t,r,i)}const X_e=Pt(([n],e)=>{const t=ef("skinIndex","uvec4"),r=ef("skinWeight","vec4"),i=ka("bindMatrix","mat4"),s=ka("bindMatrixInverse","mat4"),a=e_e("skeleton.boneMatrices","mat4",n.skeleton.bones.length);if(A6(({object:l,frameId:c})=>{const u=l.skeleton;if(zC.get(u)!==c){zC.set(u,c);const d=VC.get(u);d!==void 0&&d.previousBoneMatrices.set(u.boneMatrices),u.update()}}),e.needsPreviousData()){const l=W_e(n,i,s,t,r);Uv.assign(l)}const o=BX(a,oo,i,s,t,r);if(oo.assign(o),e.hasGeometryAttribute("normal")){const{skinNormal:l,skinTangent:c}=$_e(a,ud,$A,i,s,t,r);ud.assign(l),e.hasGeometryAttribute("tangent")&&$A.assign(c)}},"void"),Wlt=Pt(([n,e=null],t)=>{const r=LA(new jd(n.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(H0).toVar(),i=LA(new jd(new Uint32Array(n.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(H0).toVar(),s=LA(new jd(n.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(H0).toVar(),a=hr(n.bindMatrix,"mat4"),o=hr(n.bindMatrixInverse,"mat4"),l=H3(n.skeleton.boneMatrices,"mat4",n.skeleton.bones.length),c=n.skeleton;if(A6(({frameId:d})=>{if(zC.get(c)!==d){zC.set(c,d);const h=VC.get(c);h!==void 0&&h.previousBoneMatrices.set(c.boneMatrices),c.update()}}),t.needsPreviousData()){const d=W_e(n,a,o,i,s);Uv.assign(d)}const u=BX(l,r,a,o,i,s);if(e!==null&&e.assign(u),t.hasGeometryAttribute("normal")){const{skinNormal:d,skinTangent:h}=$_e(l,ud,$A,a,o,i,s);ud.assign(d),t.hasGeometryAttribute("tangent")&&$A.assign(h)}return u});class Xlt extends mr{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const r={};for(let o=0,l=this.params.length-1;oNumber(d)?g=">=":g="<"));let _;if(c)_=`while ( ${d} )`;else{const y={start:u,end:d},M=y.start,C=y.end;let k;const B=()=>g.includes("<")?"+=":"-=";if(x!=null)switch(typeof x){case"function":k=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":k=h+" "+B()+" "+e.generateConst(p,x);break;case"string":k=h+" "+x;break;default:x.isNode?k=h+" "+B()+" "+x.build(e):(on("TSL: 'Loop( { update: ... } )' is not a function, string or number.",this.stackTrace),k="break /* invalid update */")}else p==="int"||p==="uint"?x=g.includes("<")?"++":"--":x=B()+" 1.",k=h+" "+x;const U=e.getVar(p,h)+" = "+M,z=h+" "+g+" "+C;_=`for ( ${U}; ${z}; ${k} )`}e.addFlowCode((a===0?` `:"")+e.tab+_+` { `).addFlowTab()}const s=i.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(` `+e.tab+s);for(let a=0,o=this.params.length-1;anew Xlt(Bx(n,"int")).toStack(),Ylt=()=>Yh("continue").toStack(),Y_e=()=>Yh("break").toStack(),FF=new WeakMap,Lh=new gr,sce=new WeakMap,ace=Pt(({bufferMap:n,influence:e,stride:t,width:r,depth:i,offset:s})=>{const a=Tt(Ebe).mul(t).add(s),o=a.div(r),l=a.sub(o.mul(r));return dl(n,bo(l,o)).depth(i).xyz.mul(e)});function Zlt(n){const e=n.morphAttributes.position!==void 0,t=n.morphAttributes.normal!==void 0,r=n.morphAttributes.color!==void 0,i=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,s=i!==void 0?i.length:0;let a=FF.get(n);if(a===void 0||a.count!==s){let y=function(){x.dispose(),FF.delete(n),n.removeEventListener("dispose",y)};a!==void 0&&a.texture.dispose();const o=n.morphAttributes.position||[],l=n.morphAttributes.normal||[],c=n.morphAttributes.color||[];let u=0;e===!0&&(u=1),t===!0&&(u=2),r===!0&&(u=3);let d=n.attributes.position.count*u,h=1;const p=4096;d>p&&(h=Math.ceil(d/p),d=p);const g=new Float32Array(d*h*4*s),x=new n6(g,d,h,s);x.type=ea,x.needsUpdate=!0;const _=u*4;for(let M=0;M{const{geometry:e}=n,t=e.morphAttributes.position!==void 0,r=e.hasAttribute("normal")&&e.morphAttributes.normal!==void 0,i=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,s=i!==void 0?i.length:0;if(s===0)return;let a=sce.get(n);(a===void 0||a.count!==s)&&(a={base:hr(1),influences:n.morphTargetInfluences?pu(n.morphTargetInfluences,"float"):null,count:s},sce.set(n,a));const{base:o,influences:l}=a,{texture:c,stride:u,size:d}=Zlt(e);t===!0&&oo.mulAssign(o),r===!0&&ud.mulAssign(o);const h=Tt(d.width);ta(s,({i:p})=>{const g=Ze(0).toVar();n.count>1&&n.morphTexture!==null&&n.morphTexture!==void 0?g.assign(dl(n.morphTexture,bo(Tt(p).add(1),Tt(H0))).r):g.assign(l.element(p).toVar()),pr(g.notEqual(0),()=>{t===!0&&oo.addAssign(ace({bufferMap:c,influence:g,stride:u,width:h,depth:p,offset:Tt(0)})),r===!0&&ud.addAssign(ace({bufferMap:c,influence:g,stride:u,width:h,depth:p,offset:Tt(1)}))})}),A6(({object:p})=>{const{base:g,influences:x}=a;p.geometry.morphTargetsRelative?g.value=1:g.value=1-p.morphTargetInfluences.reduce((_,y)=>_+y,0),x&&(x.array=p.morphTargetInfluences,x.update())})},"void");class W3 extends mr{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class Qlt extends W3{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class Klt extends lX{static get type(){return"LightingContextNode"}constructor(e,t=null,r=[],i=null,s=null){super(e),this.lightingModel=t,this.materialLightings=r,this.backdropNode=i,this.backdropAlphaNode=s,this._value=null}getContext(){const{materialLightings:e,backdropNode:t,backdropAlphaNode:r}=this,i=Ct().toVar("directDiffuse"),s=Ct().toVar("directSpecular"),a=Ct().toVar("indirectDiffuse"),o=Ct().toVar("indirectSpecular"),l={directDiffuse:i,directSpecular:s,indirectDiffuse:a,indirectSpecular:o};return{radiance:Ct().toVar("radiance"),irradiance:Ct().toVar("irradiance"),iblIrradiance:Ct().toVar("iblIrradiance"),ambientOcclusion:Ze(1).toVar("ambientOcclusion"),reflectedLight:l,materialLightings:e,backdrop:t,backdropAlpha:r}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}const Q_e=Ti(Klt);class Jlt extends W3{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const G2=new en;class OR extends Am{static get type(){return"ViewportTextureNode"}constructor(e=F0,t=null,r=null){let i=null;r===null?(i=new UP,i.minFilter=Bc,r=i):i=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=i,this.isOutputTextureNode=!0,this.updateBeforeType=Or.RENDER,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),e===null)return t;if(r.has(e)===!1){const i=t.clone();r.set(e,i)}return r.get(e)}updateReference(e){const t=e.renderer,r=t.getRenderTarget(),i=t.getCanvasTarget(),s=r||i;return this.value=this.getTextureForReference(s),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget(),i=t.getCanvasTarget(),s=r||i;s===null?t.getDrawingBufferSize(G2):s.getDrawingBufferSize?s.getDrawingBufferSize(G2):G2.set(s.width,s.height);const a=this.getTextureForReference(s);(a.image.width!==G2.width||a.image.height!==G2.height)&&(a.image.width=G2.width,a.image.height=G2.height,a.needsUpdate=!0);const o=a.generateMipmaps;a.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(a),a.generateMipmaps=o}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const ect=Ti(OR).setParameterLength(0,3),UX=Ti(OR,null,null,{generateMipmaps:!0}).setParameterLength(0,3),tct=UX(),K_e=(n=F0,e=null)=>tct.sample(n,e);let BF=null;class nct extends OR{static get type(){return"ViewportDepthTextureNode"}constructor(e=F0,t=null,r=null){r===null&&(BF===null&&(BF=new zc),r=BF),super(e,t,r)}}const zX=Ti(nct).setParameterLength(0,3);class ah extends mr{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===ah.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let i=null;if(t===ah.DEPTH_BASE)r!==null&&(i=t3e().assign(r));else if(t===ah.DEPTH)e.isPerspectiveCamera?i=VX(gl.z,eA,tA):i=qx(gl.z,eA,tA);else if(t===ah.LINEAR_DEPTH)if(r!==null)if(e.isPerspectiveCamera){const s=jR(r,eA,tA);i=qx(s,eA,tA)}else i=r;else i=qx(gl.z,eA,tA);return i}}ah.DEPTH_BASE="depthBase";ah.DEPTH="depth";ah.LINEAR_DEPTH="linearDepth";const qx=(n,e,t)=>n.add(e).div(e.sub(t)),rct=(n,e,t)=>n.add(t).div(t.sub(e)),J_e=Pt(([n,e,t],r)=>r.renderer.reversedDepthBuffer===!0?t.sub(e).mul(n).sub(t):e.sub(t).mul(n).sub(e)),VX=(n,e,t)=>e.add(n).mul(t).div(t.sub(e).mul(n)),e3e=(n,e,t)=>e.mul(n.add(t)).div(n.mul(e.sub(t))),jR=Pt(([n,e,t],r)=>r.renderer.reversedDepthBuffer===!0?e.mul(t).div(e.sub(t).mul(n).sub(e)):e.mul(t).div(t.sub(e).mul(n).sub(t))),FR=(n,e,t)=>{e=e.max(1e-6).toVar();const r=am(n.negate().div(e)),i=am(t.div(e));return r.div(i)},ict=(n,e,t)=>{const r=n.mul(TR(t.div(e)));return Ze(Math.E).pow(r).mul(e).negate()},t3e=Ti(ah,ah.DEPTH_BASE),qX=Vn(ah,ah.DEPTH),qC=Ti(ah,ah.LINEAR_DEPTH).setParameterLength(0,1),sct=qC(zX());qX.assign=n=>t3e(n);class Zf extends mr{static get type(){return"ClippingNode"}constructor(e=Zf.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:i}=t;return this.hardwareClipping=e.hardwareClipping,this.scope===Zf.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,i):this.scope===Zf.HARDWARE?this.setupHardwareClipping(i,e):this.setupDefault(r,i)}setupAlphaToCoverage(e,t){return Pt(()=>{const r=Ze().toVar("distanceToPlane"),i=Ze().toVar("distanceToGradient"),s=Ze(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const l=pu(t).setGroup(yr);ta(a,({i:c})=>{const u=l.element(c);r.assign(gl.dot(u.xyz).negate().add(u.w)),i.assign(r.fwidth().div(2)),s.mulAssign(hf(i.negate(),i,r))})}const o=e.length;if(o>0){const l=pu(e).setGroup(yr),c=Ze(1).toVar("intersectionClipOpacity");ta(o,({i:u})=>{const d=l.element(u);r.assign(gl.dot(d.xyz).negate().add(d.w)),i.assign(r.fwidth().div(2)),c.mulAssign(hf(i.negate(),i,r).oneMinus())}),s.mulAssign(c.oneMinus())}Qs.a.mulAssign(s),Qs.a.equal(0).discard()})()}setupDefault(e,t){return Pt(()=>{const r=t.length;if(this.hardwareClipping===!1&&r>0){const s=pu(t).setGroup(yr);ta(r,({i:a})=>{const o=s.element(a);gl.dot(o.xyz).greaterThan(o.w).discard()})}const i=e.length;if(i>0){const s=pu(e).setGroup(yr),a=uf(!0).toVar("clipped");ta(i,({i:o})=>{const l=s.element(o);a.assign(gl.dot(l.xyz).greaterThan(l.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),Pt(()=>{const i=pu(e).setGroup(yr),s=a1(t.getClipDistance());ta(r,({i:a})=>{const o=i.element(a),l=gl.dot(o.xyz).sub(o.w).negate();s.element(a).assign(l)})})()}}Zf.ALPHA_TO_COVERAGE="alphaToCoverage";Zf.DEFAULT="default";Zf.HARDWARE="hardware";const act=()=>new Zf,oct=()=>new Zf(Zf.ALPHA_TO_COVERAGE),lct=()=>new Zf(Zf.HARDWARE),cct=.05,oce=Pt(([n])=>J0(Vr(1e4,Pd(Vr(17,n.x).add(Vr(.1,n.y)))).mul(jl(.1,ya(Pd(Vr(13,n.y).add(n.x))))))),lce=Pt(([n])=>oce(jn(oce(n.xy),n.z))),uct=Pt(([n])=>{const e=Eo(lm(JW(n.xyz)),lm(eX(n.xyz))),t=Ze(1).div(Ze(cct).mul(e)).toVar("pixScale"),r=jn(f3(om(am(t))),f3(ER(am(t)))),i=jn(lce(om(r.x.mul(n.xyz))),lce(om(r.y.mul(n.xyz)))),s=J0(am(t)),a=jl(Vr(s.oneMinus(),i.x),Vr(s,i.y)),o=xh(s,s.oneMinus()),l=Ct(a.mul(a).div(Vr(2,o).mul(Qi(1,o))),a.sub(Vr(.5,o)).div(Qi(1,o)),Qi(1,Qi(1,a).mul(Qi(1,a)).div(Vr(2,o).mul(Qi(1,o))))),c=a.lessThan(o.oneMinus()).select(a.lessThan(o).select(l.x,l.y),l.z);return ep(c,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class dct extends jbe{static get type(){return"VertexColorNode"}constructor(e){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e),r=e.hasGeometryAttribute(t);let i;return r===!0?i=super.generate(e):i=e.generateConst(this.nodeType,new gr(1,1,1,1)),i}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const n3e=(n=0)=>new dct(n);class Ho extends fc{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.maskShadowNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,this.contextNode=null}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const r=this[t];r&&r.isNode===!0&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(G3(t.slice(0,-4)),r.getCacheKey());return this.type+p6(e)}build(e){this.setup(e)}setupObserver(e){return new Rat(e)}setup(e){e.context.setupNormal=()=>Vx(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const i=this.setupVertex(e),s=Vx(this.vertexNode||i,"VERTEX");e.context.clipSpace=s,e.stack.outputNode=s,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const o=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(r!==null?r.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupAmbientOcclusion(e),this.setupVariants(e);const l=this.setupLighting(e);o!==null&&e.stack.addToStack(o);const c=er(l,Qs.a).max(0);a=this.setupOutput(e,c),T_.assign(a);const u=this.outputNode!==null;if(u&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),r!==null){const d=t.getMRT(),h=this.mrtNode;d!==null?(u&&T_.assign(a),a=d,h!==null&&(a=d.merge(h))):h!==null&&(a=h)}}else{let l=this.fragmentNode;l.isOutputStructNode!==!0&&(l=l.convert(e.getOutputType())),a=this.setupOutput(e,l)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let i=null;if(t.length>0||r.length>0){const s=e.renderer.currentSamples;this.alphaToCoverage&&s>1?i=oct():e.stack.addToStack(act())}return i}setupHardwareClipping(e){if(e.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(lct()),e.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let i=this.depthNode;if(i===null){const s=t.getMRT();s&&s.has("depth")?i=s.get("depth"):t.logarithmicDepthBuffer===!0&&(r.isPerspectiveCamera?i=FR(gl.z,eA,tA):i=qx(gl.z,eA,tA))}i!==null&&qX.assign(i).toStack()}setupPositionView(){return xm.mul(oo).xyz}setupModelViewProjection(){return Id.mul(gl)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.position=e.removeStack(),U_e}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&Z_e(t),t.isSkinnedMesh===!0&&X_e(t),this.displacementMap){const i=tg("displacementMap","texture"),s=tg("displacementScale","float"),a=tg("displacementBias","float");oo.addAssign(ud.normalize().mul(i.x.mul(s).add(a)))}return t.isBatchedMesh&&H_e(t),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&G_e(t),this.positionNode!==null&&oo.assign(Vx(this.positionNode,"POSITION","vec3")),oo}setupDiffuseColor(e){const{object:t,geometry:r}=e;this.maskNode!==null&&uf(this.maskNode).not().discard();let i=this.colorNode?er(this.colorNode):p_e;this.vertexColors===!0&&r.hasAttribute("color")&&(i=i.mul(n3e())),t.instanceColor&&(i=jX.mul(i)),t.isBatchedMesh&&t._colorsTexture&&(i=FX.mul(i)),Qs.assign(i);const s=this.opacityNode?Ze(this.opacityNode):RX;Qs.a.assign(Qs.a.mul(s));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode!==null?Ze(this.alphaTestNode):f_e,this.alphaToCoverage===!0?(Qs.a=hf(a,a.add(nX(Qs.a)),Qs.a),Qs.a.lessThanEqual(0).discard()):Qs.a.lessThanEqual(a).discard()),this.alphaHash===!0&&Qs.a.lessThan(uct(oo)).discard(),e.isOpaque()&&Qs.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?Ct(0):Qs.rgb}setupNormal(){return this.normalNode?Ct(this.normalNode):b_e}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?tg("envMap","cubeTexture"):tg("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Jlt(OX)),t}setupMaterialLightings(e){const t=[];if(e.renderer.lighting.enabled===!1)return t;const r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const i=this.setupLightMap(e);return i&&i.isLightingNode&&t.push(i),e.context.ambientOcclusion&&t.push(new Qlt(e.context.ambientOcclusion)),t}setupAmbientOcclusion(e){let t=this.aoNode;t===null&&e.material.aoMap&&(t=B_e),e.context.getAO&&(t=e.context.getAO(t,e)),t!==null&&(WV.assign(t),e.context.ambientOcclusion=WV)}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:i,emissiveNode:s}=this,a=this.lights===!0||this.lightsNode!==null,o=this.lights===!0?this.setupMaterialLightings(e):[],l=a?this.lightsNode||e.lightsNode:null;let c=this.setupOutgoingLight(e);if(l&&(o.length>0||l.getScope().hasLights)){const u=this.setupLightingModel(e)||null;c=Q_e(l,u,o,r,i)}else r!==null&&(c=Ct(i!==null?ki(c,r,i):r));return(s&&s.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&($V.assign(Ct(s||g_e)),c=c.add($V)),c}setupFog(e,t){const r=e.fogNode;return r&&(T_.assign(t),t=er(r.toVar())),t}setupPremultipliedAlpha(e,t){return AX(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const r in e){const i=e[r];this[r]===void 0&&(this[r]=i,i&&i.clone&&(this[r]=i.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const r in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,r)===void 0&&t[r].get!==void 0&&Object.defineProperty(this.constructor.prototype,r,t[r])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const r=fc.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:s,childNode:a}of this._getNodeChildren())r.inputNodes[s]=a.toJSON(e).uuid;function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(t){const s=i(e.textures),a=i(e.images),o=i(e.nodes);s.length>0&&(r.textures=s),a.length>0&&(r.images=a),o.length>0&&(r.nodes=o)}return r}copy(e){const t=Object.getOwnPropertyDescriptors(this.constructor.prototype);for(const r in t)if(t[r].set!==void 0&&e[r]!==void 0){const i=e[r];this[r]&&this[r].copy!==void 0?this[r].copy(i):this[r]=i}for(const r in this)if(!/^(?:is[A-Z]|_)|^(?:id|uuid|version|type|userData|clippingPlanes)$/.test(r)&&this[r]!==void 0&&e[r]!==void 0){const i=e[r];this[r]&&this[r].copy!==void 0?this[r].copy(i):this[r]=i}return this.clippingPlanes=e.clippingPlanes?e.clippingPlanes.map(r=>r.clone()):null,this.userData=JSON.parse(JSON.stringify(e.userData)),this}}const hct=new Ac;class fct extends Ho{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(hct),this.setValues(e)}}const pct=new W$;class mct extends Ho{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(pct),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?Ze(this.offsetNode):DX,t=this.dashScaleNode?Ze(this.dashScaleNode):LX,r=this.dashSizeNode?Ze(this.dashSizeNode):kX,i=this.gapSizeNode?Ze(this.gapSizeNode):IX;zx.assign(r),TS.assign(i);const s=a2(ef("lineDistance").mul(t));(e?s.add(e):s).mod(zx.add(TS)).greaterThan(zx).discard()}}const CN=ly("vec3","worldStart"),rq=ly("vec3","worldEnd"),r3e=ly("float","lineDistance"),lx=ly("vec4","worldPos"),cce=Pt(({start:n,end:e})=>{const t=Id.element(2).element(2),r=Id.element(3).element(2);return t.greaterThan(0).select(r.negate().div(t.add(1)),r.mul(-.5).div(t)).sub(n.z).div(e.z.sub(n.z))},{start:"vec4",end:"vec4",return:"float"}),gct=Pt(({p1:n,p2:e,p3:t,p4:r})=>{const i=n.sub(t),s=r.sub(t),a=e.sub(n),o=i.dot(s),l=s.dot(a),c=i.dot(a),u=s.dot(s),h=a.dot(a).mul(u).sub(l.mul(l)),g=o.mul(l).sub(c.mul(u)).div(h).clamp(),x=o.add(l.mul(g)).div(u).clamp();return jn(g,x)},{p1:"vec3",p2:"vec3",p3:"vec3",p4:"vec3",return:"vec2"});Pt(({material:n})=>{const e=n._useDash,t=n._useWorldUnits,r=ef("instanceStart"),i=ef("instanceEnd"),s=er(xm.mul(er(r,1))).toVar("start"),a=er(xm.mul(er(i,1))).toVar("end");let o,l;e&&(o=Ze(ef("instanceDistanceStart")).toVar("distanceStart"),l=Ze(ef("instanceDistanceEnd")).toVar("distanceEnd")),t&&(CN.assign(s.xyz),rq.assign(a.xyz));const c=N_.z.div(N_.w),u=Id.element(2).element(3).equal(-1);if(pr(u,()=>{pr(s.z.lessThan(0).and(a.z.greaterThan(0)),()=>{const y=cce({start:s,end:a});a.assign(er(ki(s.xyz,a.xyz,y),a.w)),e&&l.assign(ki(o,l,y))}).ElseIf(a.z.lessThan(0).and(s.z.greaterThanEqual(0)),()=>{const y=cce({start:a,end:s});s.assign(er(ki(a.xyz,s.xyz,y),s.w)),e&&o.assign(ki(l,o,y))})}),e){const y=n.dashScaleNode?Ze(n.dashScaleNode):LX,M=n.offsetNode?Ze(n.offsetNode):DX;let C=Yu.y.lessThan(.5).select(y.mul(o),y.mul(l));C=C.add(M),r3e.assign(C)}const d=Id.mul(s),h=Id.mul(a),p=d.xyz.div(d.w),g=h.xyz.div(h.w),x=g.xy.sub(p.xy).toVar();x.x.assign(x.x.mul(c)),x.assign(x.normalize());const _=er().toVar();if(t){const y=a.xyz.sub(s.xyz).normalize(),M=ki(s.xyz,a.xyz,.5).normalize(),C=y.cross(M).normalize(),k=y.cross(C);lx.assign(Yu.y.lessThan(.5).select(s,a));const B=UC.mul(.5);lx.addAssign(er(Yu.x.lessThan(0).select(C.mul(B),C.mul(B).negate()),0)),e||(lx.addAssign(er(Yu.y.lessThan(.5).select(y.mul(B).negate(),y.mul(B)),0)),lx.addAssign(er(k.mul(B),0)),pr(Yu.y.greaterThan(1).or(Yu.y.lessThan(0)),()=>{lx.subAssign(er(k.mul(2).mul(B),0))})),_.assign(Id.mul(lx));const U=Ct().toVar();U.assign(Yu.y.lessThan(.5).select(p,g)),_.z.assign(U.z.mul(_.w))}else{const y=jn(x.y,x.x.negate()).toVar("offset");x.x.assign(x.x.div(c)),y.x.assign(y.x.div(c)),y.assign(Yu.x.lessThan(0).select(y.negate(),y)),pr(Yu.y.lessThan(0),()=>{y.assign(y.sub(x))}).ElseIf(Yu.y.greaterThan(1),()=>{y.assign(y.add(x))}),y.assign(y.mul(UC)),y.assign(y.div(N_.w.div(_X))),_.assign(Yu.y.lessThan(.5).select(d,h)),y.assign(y.mul(_.w)),_.assign(_.add(er(y,0,0)))}return _})();Pt(({material:n,renderer:e})=>{const t=n._useAlphaToCoverage,r=n._useDash,i=n._useWorldUnits,s=na();if(r){const o=n.dashSizeNode?Ze(n.dashSizeNode):kX,l=n.gapSizeNode?Ze(n.gapSizeNode):IX;zx.assign(o),TS.assign(l),s.y.lessThan(-1).or(s.y.greaterThan(1)).discard(),r3e.mod(zx.add(TS)).greaterThan(zx).discard()}const a=Ze(1).toVar("alpha");if(i){const o=lx.xyz.normalize().mul(1e5),l=rq.sub(CN),c=gct({p1:CN,p2:rq,p3:Ct(0,0,0),p4:o}),u=CN.add(l.mul(c.x)),d=o.mul(c.y),g=u.sub(d).length().div(UC);if(!r)if(t&&e.currentSamples>0){const x=g.fwidth();a.assign(hf(x.negate().add(.5),x.add(.5),g).oneMinus())}else g.greaterThan(.5).discard()}else if(t&&e.currentSamples>0){const o=s.x,l=s.y.greaterThan(0).select(s.y.sub(1),s.y.add(1)),c=o.mul(o).add(l.mul(l)),u=Ze(c.fwidth()).toVar("dlen");pr(s.y.abs().greaterThan(1),()=>{a.assign(hf(u.oneMinus(),u.add(1),c).oneMinus())})}else pr(s.y.abs().greaterThan(1),()=>{const o=s.x,l=s.y.greaterThan(0).select(s.y.sub(1),s.y.add(1));o.mul(o).add(l.mul(l)).greaterThan(1).discard()});return a})();const Act=new H$;class xct extends Ho{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Act),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Ze(this.opacityNode):RX;Qs.assign(MR(er(CX(ss),e),ic))}}const GX=Pt(([n=SX])=>{const e=n.z.atan(n.x).mul(1/(Math.PI*2)).add(.5),t=n.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return jn(e,t)}),iq=Pt(([n=na()])=>{const e=n.x.sub(.5).mul(Math.PI*2),t=n.y.sub(.5).mul(Math.PI),r=t.cos(),i=r.mul(e.cos()),s=t.sin(),a=r.mul(e.sin());return Ct(i,s,a)});class i3e extends mf{constructor(e=1,t={}){super(e,e,t),this.isCubeRenderTarget=!0;const r={width:e,height:e,depth:1},i=[r,r,r,r,r,r];this.texture=new r1(i),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,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;const s=new Em(5,5,5),a=GX(SX),o=new Ho;o.colorNode=as(t,a,0),o.side=Ds,o.blending=Yl;const l=new ui(s,o),c=new B3;c.add(l),t.minFilter===Bc&&(t.minFilter=Ci);const u=new sW(1,10,this),d=e.getMRT();return e.setMRT(null),u.update(e,c),e.setMRT(d),t.minFilter=r,t.generateMipmaps=i,l.geometry.dispose(),l.material.dispose(),this}clear(e,t=!0,r=!0,i=!0){const s=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,r,i);e.setRenderTarget(s)}}const x4=new WeakMap;class vct extends $o{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=kd(null);const t=new r1;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Or.RENDER}updateBefore(e){const{renderer:t,material:r}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const s=i.isTextureNode?i.value:r[i.property];if(s&&s.isTexture){const a=s.mapping;if(a===MA||a===CA){if(x4.has(s)){const o=x4.get(s);uce(o,s.mapping),this._cubeTexture=o}else{const o=s.image;if(yct(o)){const l=new i3e(o.height);l.fromEquirectangularTexture(t,s),uce(l.texture,s.mapping),this._cubeTexture=l.texture,x4.set(s,l.texture),s.addEventListener("dispose",s3e)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function yct(n){return n==null?!1:n.height>0}function s3e(n){const e=n.target;e.removeEventListener("dispose",s3e);const t=x4.get(e);t!==void 0&&(x4.delete(e),t.dispose())}function uce(n,e){e===MA?n.mapping=ph:e===CA&&(n.mapping=e0)}const a3e=Ti(vct).setParameterLength(1);class HX extends W3{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=a3e(this.envNode)}}class bct extends W3{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Ze(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class BR{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class o3e extends BR{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,i=e.irradianceLightMap;r.indirectDiffuse.assign(er(0)),i?r.indirectDiffuse.addAssign(i):r.indirectDiffuse.addAssign(er(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(Qs.rgb)}finish(e){const{material:t,context:r}=e,i=r.outgoingLight,s=e.context.environment;if(s)switch(t.combine){case k3:i.rgb.assign(ki(i.rgb,i.rgb.mul(s.rgb),A4.mul(MN)));break;case y$:i.rgb.assign(ki(i.rgb,s.rgb,A4.mul(MN)));break;case b$:i.rgb.addAssign(s.rgb.mul(A4.mul(MN)));break;default:sn("BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const _ct=new oc;class wct extends Ho{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(_ct),this.setValues(e)}setupNormal(){return uy(p3)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new HX(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new bct(OX)),t}setupOutgoingLight(){return Qs.rgb}setupLightingModel(){return new o3e}}const m3=Pt(({f0:n,f90:e,dotVH:t})=>{const r=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return n.mul(r.oneMinus()).add(e.mul(r))}),zv=Pt(n=>n.diffuseColor.mul(1/Math.PI)),Sct=()=>Ze(.25),Tct=Pt(({dotNH:n})=>OC.mul(Ze(.5)).add(1).mul(Ze(1/Math.PI)).mul(n.pow(OC))),Ect=Pt(({lightDirection:n})=>{const e=n.add(fa).normalize(),t=ss.dot(e).clamp(),r=fa.dot(e).clamp(),i=m3({f0:HA,f90:1,dotVH:r}),s=Sct(),a=Tct({dotNH:t});return i.mul(s).mul(a)});class l3e extends o3e{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=ss.dot(e).clamp().mul(t);r.directDiffuse.addAssign(s.mul(zv({diffuseColor:Qs.rgb}))),this.specular===!0&&r.directSpecular.addAssign(s.mul(Ect({lightDirection:e})).mul(A4))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(zv({diffuseColor:Qs}))),i.indirectDiffuse.mulAssign(t)}}const Nct=new op;class Mct extends Ho{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Nct),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new HX(t):null}setupLightingModel(){return new l3e(!1)}}const Cct=new eR;class Pct extends Ho{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Cct),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new HX(t):null}setupLightingModel(){return new l3e}setupVariants(){const e=(this.shininessNode?Ze(this.shininessNode):m_e).max(1e-4);OC.assign(e);const t=this.specularNode||A_e;HA.assign(t)}}const c3e=Pt(n=>{if(n.geometry.hasAttribute("normal")===!1)return Ze(0);const e=p3.dFdx().abs().max(p3.dFdy().abs());return e.x.max(e.y).max(e.z)}),$X=Pt(n=>{const{roughness:e}=n,t=c3e();let r=e.max(.0525);return r=r.add(t),r=r.min(1),r}),u3e=Pt(({alpha:n,dotNL:e,dotNV:t})=>{const r=n.pow2(),i=e.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt()),s=t.mul(r.add(r.oneMinus().mul(e.pow2())).sqrt());return df(.5,i.add(s).max(SR))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),Rct=Pt(({alphaT:n,alphaB:e,dotTV:t,dotBV:r,dotTL:i,dotBL:s,dotNV:a,dotNL:o})=>{const l=o.mul(Ct(n.mul(t),e.mul(r),a).length()),c=a.mul(Ct(n.mul(i),e.mul(s),o).length());return df(.5,l.add(c).max(SR))}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),d3e=Pt(({alpha:n,dotNH:e})=>{const t=n.pow2(),r=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),Lct=Ze(1/Math.PI),kct=Pt(({alphaT:n,alphaB:e,dotNH:t,dotTH:r,dotBH:i})=>{const s=n.mul(e),a=Ct(e.mul(r),n.mul(i),s.mul(t)),o=a.dot(a),l=s.div(o);return Lct.mul(s.mul(l.pow2()))}).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),WX=Pt(({lightDirection:n,f0:e,f90:t,roughness:r,f:i,normalView:s=ss,USE_IRIDESCENCE:a,USE_ANISOTROPY:o})=>{const l=r.pow2(),c=n.add(fa).normalize(),u=s.dot(n).clamp(),d=s.dot(fa).clamp(),h=s.dot(c).clamp(),p=fa.dot(c).clamp();let g=m3({f0:e,f90:t,dotVH:p}),x,_;if(h3(a)&&(g=bR.mix(g,i)),h3(o)){const y=m4.dot(n),M=m4.dot(fa),C=m4.dot(c),k=Ux.dot(n),B=Ux.dot(fa),U=Ux.dot(c);x=Rct({alphaT:DC,alphaB:l,dotTV:M,dotBV:B,dotTL:y,dotBL:k,dotNV:d,dotNL:u}),_=kct({alphaT:DC,alphaB:l,dotNH:h,dotTH:C,dotBH:U})}else x=u3e({alpha:l,dotNL:u,dotNV:d}),_=d3e({alpha:l,dotNH:h});return g.mul(x).mul(_)}),Ict=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]);let Ep=null;const ES=Pt(({roughness:n,dotNV:e})=>{Ep===null&&(Ep=new hh(Ict,16,16,dc,ba),Ep.name="DFG_LUT",Ep.minFilter=Ci,Ep.magFilter=Ci,Ep.wrapS=uc,Ep.wrapT=uc,Ep.generateMipmaps=!1,Ep.needsUpdate=!0);const t=jn(n,e);return as(Ep,t).rg}),Dct=Pt(({lightDirection:n,f0:e,f90:t,roughness:r,f:i,USE_IRIDESCENCE:s,USE_ANISOTROPY:a})=>{const o=WX({lightDirection:n,f0:e,f90:t,roughness:r,f:i,USE_IRIDESCENCE:s,USE_ANISOTROPY:a}),l=ss.dot(n).clamp(),c=ss.dot(fa).clamp(),u=ES({roughness:r,dotNV:c}),d=ES({roughness:r,dotNV:l}),h=e.mul(u.x).add(t.mul(u.y)),p=e.mul(d.x).add(t.mul(d.y)),g=u.x.add(u.y),x=d.x.add(d.y),_=Ze(1).sub(g),y=Ze(1).sub(x),M=e.add(e.oneMinus().mul(.047619)),C=h.mul(p).mul(M).div(Ze(1).sub(_.mul(y).mul(M).mul(M)).add(SR)),k=_.mul(y),B=C.mul(k);return o.add(B)}),h3e=Pt(n=>{const{dotNV:e,specularColor:t,specularF90:r,roughness:i}=n,s=ES({dotNV:e,roughness:i});return t.mul(s.x).add(r.mul(s.y))}),sq=Pt(({f:n,f90:e,dotVH:t})=>{const r=t.oneMinus().saturate(),i=r.mul(r),s=r.mul(i,i).clamp(0,.9999);return n.sub(Ct(e).mul(s)).div(s.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),Oct=Pt(({roughness:n,dotNH:e})=>{const t=n.pow2(),r=Ze(1).div(t),s=e.pow2().oneMinus().max(.0078125);return Ze(2).add(r).mul(s.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),jct=Pt(({dotNV:n,dotNL:e})=>Ze(1).div(Ze(4).mul(e.add(n).sub(e.mul(n))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),Fct=Pt(({lightDirection:n})=>{const e=n.add(fa).normalize(),t=ss.dot(n).clamp(),r=ss.dot(fa).clamp(),i=ss.dot(e).clamp(),s=Oct({roughness:J1,dotNH:i}),a=jct({dotNV:r,dotNL:t});return Bh.mul(s).mul(a)}),dce=Pt(({N:n,V:e,roughness:t})=>{const s=.0078125,a=n.dot(e).saturate(),o=jn(t,a.oneMinus().sqrt());return o.assign(o.mul(.984375).add(s)),o}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),Bct=Pt(({f:n})=>{const e=n.length();return Eo(e.mul(e).add(n.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),B8=Pt(({v1:n,v2:e})=>{const t=n.dot(e),r=t.abs().toVar(),i=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),s=r.add(4.1616724).mul(r).add(3.417594).toVar(),a=i.div(s),o=t.greaterThan(0).select(a,Eo(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return n.cross(e).mul(o)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),UF=Pt(({N:n,V:e,P:t,mInv:r,p0:i,p1:s,p2:a,p3:o})=>{const l=s.sub(i).toVar(),c=o.sub(i).toVar(),u=l.cross(c),d=Ct().toVar();return pr(u.dot(t.sub(i)).greaterThanEqual(0),()=>{const h=e.sub(n.mul(e.dot(n))).normalize(),p=n.cross(h).negate(),g=r.mul(Vc(h,p,n).transpose()).toVar(),x=g.mul(i.sub(t)).normalize().toVar(),_=g.mul(s.sub(t)).normalize().toVar(),y=g.mul(a.sub(t)).normalize().toVar(),M=g.mul(o.sub(t)).normalize().toVar(),C=Ct(0).toVar();C.addAssign(B8({v1:x,v2:_})),C.addAssign(B8({v1:_,v2:y})),C.addAssign(B8({v1:y,v2:M})),C.addAssign(B8({v1:M,v2:x})),d.assign(Ct(Bct({f:C})))}),d}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),UR=1/6,f3e=n=>Vr(UR,Vr(n,Vr(n,n.negate().add(3)).sub(3)).add(1)),aq=n=>Vr(UR,Vr(n,Vr(n,Vr(3,n).sub(6))).add(4)),p3e=n=>Vr(UR,Vr(n,Vr(n,Vr(-3,n).add(3)).add(3)).add(1)),oq=n=>Vr(UR,Gf(n,3)),hce=n=>f3e(n).add(aq(n)),fce=n=>p3e(n).add(oq(n)),pce=n=>jl(-1,aq(n).div(f3e(n).add(aq(n)))),mce=n=>jl(1,oq(n).div(p3e(n).add(oq(n)))),gce=(n,e,t)=>{const r=n.uvNode,i=Vr(r,e.zw).add(.5),s=om(i),a=J0(i),o=hce(a.x),l=fce(a.x),c=pce(a.x),u=mce(a.x),d=pce(a.y),h=mce(a.y),p=jn(s.x.add(c),s.y.add(d)).sub(.5).mul(e.xy),g=jn(s.x.add(u),s.y.add(d)).sub(.5).mul(e.xy),x=jn(s.x.add(c),s.y.add(h)).sub(.5).mul(e.xy),_=jn(s.x.add(u),s.y.add(h)).sub(.5).mul(e.xy),y=hce(a.y).mul(jl(o.mul(n.sample(p).level(t)),l.mul(n.sample(g).level(t)))),M=fce(a.y).mul(jl(o.mul(n.sample(x).level(t)),l.mul(n.sample(_).level(t))));return y.add(M)},XX=Pt(([n,e])=>{const t=jn(n.size(Tt(e))),r=jn(n.size(Tt(e.add(1)))),i=df(1,t),s=df(1,r),a=gce(n,er(i,t),om(e)),o=gce(n,er(s,r),ER(e));return J0(e).mix(a,o)}),Uct=Pt(([n,e])=>{const t=e.mul(vX(n));return XX(n,t)}),Ace=Pt(([n,e,t,r,i])=>{const s=Ct(aX(e.negate(),sd(n),df(1,r))),a=Ct(lm(i[0].xyz),lm(i[1].xyz),lm(i[2].xyz));return sd(s).mul(t.mul(a))}).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),zct=Pt(([n,e])=>n.mul(ep(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Vct=UX(),qct=K_e(),xce=Pt(([n,e,t],{material:r})=>{const s=(r.side===Ds?Vct:qct).sample(n),a=am(Bv.x).mul(zct(e,t));return XX(s,a)}),vce=Pt(([n,e,t])=>(pr(t.notEqual(0),()=>{const r=TR(e).negate().div(t);return WW(r.negate().mul(n))}),Ct(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Gct=Pt(([n,e,t,r,i,s,a,o,l,c,u,d,h,p,g])=>{let x,_;if(g){x=er().toVar(),_=Ct().toVar();const B=u.sub(1).mul(g.mul(.025)),U=Ct(u.sub(B),u,u.add(B));ta({start:0,end:3},({i:z})=>{const O=U.element(z),V=Ace(n,e,d,O,o),$=a.add(V),G=c.mul(l.mul(er($,1))),H=jn(G.xy.div(G.w)).toVar();H.addAssign(1),H.divAssign(2),H.assign(jn(H.x,H.y.oneMinus()));const K=xce(H,t,O);x.element(z).assign(K.element(z)),x.a.addAssign(K.a),_.element(z).assign(r.element(z).mul(vce(lm(V),h,p).element(z)))}),x.a.divAssign(3)}else{const B=Ace(n,e,d,u,o),U=a.add(B),z=c.mul(l.mul(er(U,1))),O=jn(z.xy.div(z.w)).toVar();O.addAssign(1),O.divAssign(2),O.assign(jn(O.x,O.y.oneMinus())),x=xce(O,t,u),_=r.mul(vce(lm(B),h,p))}const y=_.rgb.mul(x.rgb),M=n.dot(e).clamp(),C=Ct(h3e({dotNV:M,specularColor:i,specularF90:s,roughness:t})),k=_.r.add(_.g,_.b).div(3);return er(C.oneMinus().mul(y),x.a.oneMinus().mul(k).oneMinus())}),Hct=Vc(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),$ct=n=>{const e=n.sqrt();return Ct(1).add(e).div(Ct(1).sub(e))},yce=(n,e)=>n.sub(e).div(n.add(e)).pow2(),Wct=(n,e)=>{const t=n.mul(2*Math.PI*1e-9),r=Ct(54856e-17,44201e-17,52481e-17),i=Ct(1681e3,1795300,2208400),s=Ct(43278e5,93046e5,66121e5),a=Ze(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let o=r.mul(s.mul(2*Math.PI).sqrt()).mul(i.mul(t).add(e).cos()).mul(t.pow2().negate().mul(s).exp());return o=Ct(o.x.add(a),o.y,o.z).div(10685e-11),Hct.mul(o)},bce=Pt(({outsideIOR:n,eta2:e,cosTheta1:t,thinFilmThickness:r,baseF0:i})=>{const s=ki(n,e,hf(0,.03,r)),o=n.div(s).pow2().mul(t.pow2().oneMinus()).oneMinus();pr(o.lessThan(0),()=>Ct(1));const l=o.sqrt(),c=yce(s,n),u=m3({f0:c,f90:1,dotVH:t}),d=u.oneMinus(),h=s.lessThan(n).select(Math.PI,0),p=Ze(Math.PI).sub(h),g=$ct(i.clamp(0,.9999)),x=yce(g,s.toVec3()),_=m3({f0:x,f90:1,dotVH:l}),y=Ct(g.x.lessThan(s).select(Math.PI,0),g.y.lessThan(s).select(Math.PI,0),g.z.lessThan(s).select(Math.PI,0)),M=s.mul(r,l,2),C=Ct(p).add(y),k=u.mul(_).clamp(1e-5,.9999),B=k.sqrt(),U=d.pow2().mul(_).div(Ct(1).sub(k)),O=u.add(U).toVar(),V=U.sub(d).toVar();return ta({start:1,end:2,condition:"<=",name:"m"},({m:$})=>{V.mulAssign(B);const G=Wct(Ze($).mul(M),Ze($).mul(C)).mul(2);O.addAssign(V.mul(G))}),O.max(Ct(0))}).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Hw=Pt(({normal:n,viewDir:e,roughness:t})=>{const r=n.dot(e).saturate(),i=t.mul(t),s=t.add(.1).reciprocal(),a=Ze(-1.9362).add(t.mul(1.0678)).add(i.mul(.4573)).sub(s.mul(.8469)),o=Ze(-.6014).add(t.mul(.5538)).sub(i.mul(.467)).sub(s.mul(.1255));return a.mul(r).add(o).exp().saturate()}),$w=Ct(.04),U8=Ze(1);class m3e extends BR{constructor(e=!1,t=!1,r=!1,i=!1,s=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=i,this.transmission=s,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=Ct().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=Ct().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=Ct().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=Ct().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=Ct().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=ss.dot(fa).clamp(),r=bce({outsideIOR:Ze(1),eta2:kC,cosTheta1:t,thinFilmThickness:IC,baseF0:HA}),i=bce({outsideIOR:Ze(1),eta2:kC,cosTheta1:t,thinFilmThickness:IC,baseF0:Qs.rgb});this.iridescenceFresnel=ki(r,i,dg),this.iridescenceF0Dielectric=sq({f:r,f90:1,dotVH:t}),this.iridescenceF0Metallic=sq({f:i,f90:1,dotVH:t}),this.iridescenceF0=ki(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,dg)}if(this.transmission===!0){const t=cm,r=zbe.sub(cm).normalize(),i=c2,s=e.context;s.backdrop=Gct(i,r,qp,hx,Nx,Mx,t,Hf,l2,Id,g4,VW,GW,qW,this.dispersion?HW:null),s.backdropAlpha=jC,Qs.a.mulAssign(ki(1,s.backdrop.a,jC))}super.start(e)}computeMultiscattering(e,t,r,i,s=null){const a=ss.dot(fa).clamp(),o=ES({roughness:qp,dotNV:a}),l=s?bR.mix(i,s):i,c=l.mul(o.x).add(r.mul(o.y)),d=o.x.add(o.y).oneMinus(),h=l.add(l.oneMinus().mul(.047619)),p=c.mul(h).div(d.mul(h).oneMinus());e.addAssign(c),t.addAssign(p.mul(d))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const s=ss.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(s.mul(Fct({lightDirection:e})));const a=Hw({normal:ss,viewDir:fa,roughness:J1}),o=Hw({normal:ss,viewDir:e,roughness:J1}),l=Bh.r.max(Bh.g).max(Bh.b).mul(a.max(o)).oneMinus();s.mulAssign(l)}if(this.clearcoat===!0){const o=nA.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(o.mul(WX({lightDirection:e,f0:$w,f90:U8,roughness:S_,normalView:nA})))}r.directDiffuse.addAssign(s.mul(zv({diffuseColor:hx}))),r.directSpecular.addAssign(s.mul(Dct({lightDirection:e,f0:Nx,f90:1,roughness:qp,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:i,reflectedLight:s,ltc_1:a,ltc_2:o}){const l=t.add(r).sub(i),c=t.sub(r).sub(i),u=t.sub(r).add(i),d=t.add(r).add(i),h=ss,p=fa,g=gl.toVar(),x=dce({N:h,V:p,roughness:qp}),_=a.sample(x).toVar(),y=o.sample(x).toVar(),M=Vc(Ct(_.x,0,_.y),Ct(0,1,0),Ct(_.z,0,_.w)).toVar(),C=Nx.mul(y.x).add(Mx.sub(Nx).mul(y.y)).toVar();if(s.directSpecular.addAssign(e.mul(C).mul(UF({N:h,V:p,P:g,mInv:M,p0:l,p1:c,p2:u,p3:d}))),s.directDiffuse.addAssign(e.mul(hx).mul(UF({N:h,V:p,P:g,mInv:Vc(1,0,0,0,1,0,0,0,1),p0:l,p1:c,p2:u,p3:d}))),this.clearcoat===!0){const k=nA,B=dce({N:k,V:p,roughness:S_}),U=a.sample(B),z=o.sample(B),O=Vc(Ct(U.x,0,U.y),Ct(0,1,0),Ct(U.z,0,U.w)),V=$w.mul(z.x).add(U8.sub($w).mul(z.y));this.clearcoatSpecularDirect.addAssign(e.mul(V).mul(UF({N:k,V:p,P:g,mInv:O,p0:l,p1:c,p2:u,p3:d})))}}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context,i=t.mul(zv({diffuseColor:hx})).toVar();if(this.sheen===!0){const s=Hw({normal:ss,viewDir:fa,roughness:J1}),a=Bh.r.max(Bh.g).max(Bh.b).mul(s).oneMinus();i.mulAssign(a)}r.indirectDiffuse.addAssign(i)}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:i}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(r.mul(Bh,Hw({normal:ss,viewDir:fa,roughness:J1}))),this.clearcoat===!0){const _=nA.dot(fa).clamp(),y=h3e({dotNV:_,specularColor:$w,specularF90:U8,roughness:S_});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(y))}const s=Ct().toVar("singleScatteringDielectric"),a=Ct().toVar("multiScatteringDielectric"),o=Ct().toVar("singleScatteringMetallic"),l=Ct().toVar("multiScatteringMetallic");this.computeMultiscattering(s,a,Mx,HA,this.iridescenceF0Dielectric),this.computeMultiscattering(o,l,Mx,Qs.rgb,this.iridescenceF0Metallic);const c=ki(s,o,dg),u=ki(a,l,dg),d=s.add(a),h=hx.mul(d.oneMinus()),p=r.mul(1/Math.PI),g=t.mul(c).add(u.mul(p)).toVar(),x=h.mul(p).toVar();if(this.sheen===!0){const _=Hw({normal:ss,viewDir:fa,roughness:J1}),y=Bh.r.max(Bh.g).max(Bh.b).mul(_).oneMinus();g.mulAssign(y),x.mulAssign(y)}i.indirectSpecular.addAssign(g),i.indirectDiffuse.addAssign(x)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,s=ss.dot(fa).clamp().add(t),a=qp.mul(-16).oneMinus().negate().exp2(),o=t.sub(s.pow(a).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(o)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const r=nA.dot(fa).clamp(),i=m3({dotVH:r,f0:$w,f90:U8}),s=t.mul(LC.mul(i).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(LC));t.assign(s)}if(this.sheen===!0){const r=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(r)}}}const _ce=Ze(1),lq=Ze(-2),z8=Ze(.8),zF=Ze(-1),V8=Ze(.4),VF=Ze(2),q8=Ze(.305),qF=Ze(3),wce=Ze(.21),Xct=Ze(4),Sce=Ze(4),Yct=Ze(16),Zct=Pt(([n])=>{const e=Ct(ya(n)).toVar(),t=Ze(-1).toVar();return pr(e.x.greaterThan(e.z),()=>{pr(e.x.greaterThan(e.y),()=>{t.assign(rd(n.x.greaterThan(0),0,3))}).Else(()=>{t.assign(rd(n.y.greaterThan(0),1,4))})}).Else(()=>{pr(e.z.greaterThan(e.y),()=>{t.assign(rd(n.z.greaterThan(0),2,5))}).Else(()=>{t.assign(rd(n.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),Qct=Pt(([n,e])=>{const t=jn().toVar();return pr(e.equal(0),()=>{t.assign(jn(n.z,n.y).div(ya(n.x)))}).ElseIf(e.equal(1),()=>{t.assign(jn(n.x.negate(),n.z.negate()).div(ya(n.y)))}).ElseIf(e.equal(2),()=>{t.assign(jn(n.x.negate(),n.y).div(ya(n.z)))}).ElseIf(e.equal(3),()=>{t.assign(jn(n.z.negate(),n.y).div(ya(n.x)))}).ElseIf(e.equal(4),()=>{t.assign(jn(n.x.negate(),n.z).div(ya(n.y)))}).Else(()=>{t.assign(jn(n.x,n.y).div(ya(n.z)))}),Vr(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),Kct=Pt(([n])=>{const e=Ze(0).toVar();return pr(n.greaterThanEqual(z8),()=>{e.assign(_ce.sub(n).mul(zF.sub(lq)).div(_ce.sub(z8)).add(lq))}).ElseIf(n.greaterThanEqual(V8),()=>{e.assign(z8.sub(n).mul(VF.sub(zF)).div(z8.sub(V8)).add(zF))}).ElseIf(n.greaterThanEqual(q8),()=>{e.assign(V8.sub(n).mul(qF.sub(VF)).div(V8.sub(q8)).add(VF))}).ElseIf(n.greaterThanEqual(wce),()=>{e.assign(q8.sub(n).mul(Xct.sub(qF)).div(q8.sub(wce)).add(qF))}).Else(()=>{e.assign(Ze(-2).mul(am(Vr(1.16,n))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),g3e=Pt(([n,e])=>{const t=n.toVar();t.assign(Vr(2,t).sub(1));const r=Ct(t,1).toVar();return pr(e.equal(0),()=>{r.assign(r.zyx)}).ElseIf(e.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),A3e=Pt(([n,e,t,r,i,s])=>{const a=Ze(t),o=Ct(e),l=ep(Kct(a),lq,s),c=J0(l),u=om(l),d=Ct(NS(n,o,u,r,i,s)).toVar();return pr(c.notEqual(0),()=>{const h=Ct(NS(n,o,u.add(1),r,i,s)).toVar();d.assign(ki(d,h,c))}),d}),NS=Pt(([n,e,t,r,i,s])=>{const a=Ze(t).toVar(),o=Ct(e),l=Ze(Zct(o)).toVar(),c=Ze(Eo(Sce.sub(a),0)).toVar();a.assign(Eo(a,Sce));const u=Ze(f3(a)).toVar(),d=jn(Qct(o,l).mul(u.sub(2)).add(1)).toVar();return pr(l.greaterThan(2),()=>{d.y.addAssign(u),l.subAssign(3)}),d.x.addAssign(l.mul(u)),d.x.addAssign(c.mul(Vr(3,Yct))),d.y.addAssign(Vr(4,f3(s).sub(u))),d.x.mulAssign(r),d.y.mulAssign(i),n.sample(d).grad(jn(),jn())}),GF=Pt(({envMap:n,mipInt:e,outputDirection:t,theta:r,axis:i,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=R0(r),c=t.mul(l).add(i.cross(t).mul(Pd(r))).add(i.mul(i.dot(t).mul(l.oneMinus())));return NS(n,c,e,s,a,o)}),x3e=Pt(({n,latitudinal:e,poleAxis:t,outputDirection:r,weights:i,samples:s,dTheta:a,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})=>{const h=Ct(rd(e,t,Zg(t,r))).toVar();pr(h.equal(Ct(0)),()=>{h.assign(Ct(r.z,0,r.x.negate()))}),h.assign(sd(h));const p=Ct().toVar();return p.addAssign(i.element(0).mul(GF({theta:0,axis:h,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),ta({start:Tt(1),end:n},({i:g})=>{pr(g.greaterThanEqual(s),()=>{Y_e()});const x=Ze(a.mul(Ze(g))).toVar();p.addAssign(i.element(g).mul(GF({theta:x.mul(-1),axis:h,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d}))),p.addAssign(i.element(g).mul(GF({theta:x,axis:h,outputDirection:r,mipInt:o,envMap:l,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:d})))}),er(p,1)}),Jct=Pt(([n])=>{const e=bn(n).toVar();return e.assign(e.shiftLeft(bn(16)).bitOr(e.shiftRight(bn(16)))),e.assign(e.bitAnd(bn(1431655765)).shiftLeft(bn(1)).bitOr(e.bitAnd(bn(2863311530)).shiftRight(bn(1)))),e.assign(e.bitAnd(bn(858993459)).shiftLeft(bn(2)).bitOr(e.bitAnd(bn(3435973836)).shiftRight(bn(2)))),e.assign(e.bitAnd(bn(252645135)).shiftLeft(bn(4)).bitOr(e.bitAnd(bn(4042322160)).shiftRight(bn(4)))),e.assign(e.bitAnd(bn(16711935)).shiftLeft(bn(8)).bitOr(e.bitAnd(bn(4278255360)).shiftRight(bn(8)))),Ze(e).mul(23283064365386963e-26)}),eut=Pt(([n,e])=>jn(Ze(n).div(Ze(e)),Jct(n))),tut=Pt(([n,e,t])=>{const r=t.mul(t).toConst(),i=Ct(1,0,0).toConst(),s=Zg(e,i).toConst(),a=Fd(n.x).toConst(),o=Vr(2,3.14159265359).mul(n.y).toConst(),l=a.mul(R0(o)).toConst(),c=a.mul(Pd(o)).toVar(),u=Vr(.5,e.z.add(1)).toConst();c.assign(u.oneMinus().mul(Fd(l.mul(l).oneMinus())).add(u.mul(c)));const d=i.mul(l).add(s.mul(c)).add(e.mul(Fd(Eo(0,l.mul(l).add(c.mul(c)).oneMinus()))));return sd(Ct(r.mul(d.x),r.mul(d.y),Eo(0,d.z)))}),v3e=Pt(({roughness:n,mipInt:e,envMap:t,N_immutable:r,GGX_SAMPLES:i,CUBEUV_TEXEL_WIDTH:s,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:o})=>{const l=Ct(r).toVar(),c=Ct(0).toVar(),u=Ze(0).toVar();return pr(n.lessThan(.001),()=>{c.assign(NS(t,l,e,s,a,o))}).Else(()=>{const d=rd(ya(l.z).lessThan(.999),Ct(0,0,1),Ct(1,0,0)),h=sd(Zg(d,l)).toVar(),p=Zg(l,h).toVar();ta({start:bn(0),end:i},({i:g})=>{const x=eut(g,i),_=tut(x,Ct(0,0,1),n),y=sd(h.mul(_.x).add(p.mul(_.y)).add(l.mul(_.z))),M=sd(y.mul(n0(l,y).mul(2)).sub(l)),C=Eo(n0(l,M),0);pr(C.greaterThan(0),()=>{const k=NS(t,M,e,s,a,o);c.addAssign(k.mul(C)),u.addAssign(C)})}),pr(u.greaterThan(0),()=>{c.assign(c.div(u))})}),er(c,1)}),dA=4,Tce=[.125,.215,.35,.446,.526,.582],fx=20,nut=512,Ww=new Yf(-1,1,1,-1,0,1),rut=new Ga(90,1),Ece=new Fn;let HF=null,$F=0,WF=0;const iut=new Fe,GC=new WeakMap,sut=[3,1,5,0,4,2],XF=g3e(na(),ef("faceIndex")).normalize(),zR=Ct(XF.x,XF.y,XF.z);class aut{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,i=100,s={}){const{size:a=256,position:o=iut,renderTarget:l=null}=s;if(this._setSize(a),this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Use "await renderer.init();" before using this method.');HF=this._renderer.getRenderTarget(),$F=this._renderer.getActiveCubeFace(),WF=this._renderer.getActiveMipmapLevel();const c=l||this._allocateTarget(!0);return this._init(c),this._sceneToCubeUV(e,r,i,c,o),t>0&&this._blur(c,0,0,t),this._applyPMREM(c),this._cleanup(c),c}async fromSceneAsync(e,t=0,r=.1,i=100,s={}){return ji('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this.fromScene(e,t,r,i,s)}fromEquirectangular(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromEquirectangularAsync(e,t=null){return ji('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}fromCubemap(e,t=null){if(this._hasInitialized===!1)throw new Error('THREE.PMREMGenerator: .fromCubemap() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this._fromTexture(e,t)}async fromCubemapAsync(e,t=null){return ji('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),await this._renderer.init(),this._fromTexture(e,t)}async compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Mce(),await this._compileMaterial(this._cubemapMaterial))}async compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Cce(),await 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())}_setSizeFromTexture(e){e.mapping===ph||e.mapping===e0?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(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?y:0,y,y),c.render(e,a)}c.autoClear=u,e.background=g}_textureToCubeUV(e,t){const r=this._renderer,i=e.mapping===ph||e.mapping===e0;i?this._cubemapMaterial===null&&(this._cubemapMaterial=Mce(e)):this._equirectMaterial===null&&(this._equirectMaterial=Cce(e));const s=i?this._cubemapMaterial:this._equirectMaterial;s.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=s;const o=this._cubeSize;this._setViewport(t,0,0,3*o,2*o),r.setRenderTarget(t),r.render(a,Ww)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const i=this._lodMeshes.length;for(let s=1;sg-dA?r-g+dA:0),y=4*(this._cubeSize-x);e.texture.frame=(e.texture.frame||0)+1,l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=g-t,this._setViewport(s,_,y,3*x,2*x),i.setRenderTarget(s),i.render(o,Ww),s.texture.frame=(s.texture.frame||0)+1,l.envMap.value=s.texture,l.roughness.value=0,l.mipInt.value=g-r,this._setViewport(e,_,y,3*x,2*x),i.setRenderTarget(e),i.render(o,Ww)}_blur(e,t,r,i,s){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,r,i,"latitudinal",s),this._halfBlur(a,e,r,r,i,"longitudinal",s)}_halfBlur(e,t,r,i,s,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&on("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[i];d.material=c;const h=GC.get(c),p=this._sizeLods[r]-1,g=isFinite(s)?Math.PI/(2*p):2*Math.PI/(2*fx-1),x=s/g,_=isFinite(s)?1+Math.floor(u*x):fx;_>fx&&sn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${_} samples when the maximum is set to ${fx}`);const y=[];let M=0;for(let z=0;zC-dA?i-C+dA:0),U=4*(this._cubeSize-k);this._setViewport(t,B,U,3*k,2*k),l.setRenderTarget(t),l.render(d,Ww)}_setViewport(e,t,r,i,s){this._renderer.isWebGLRenderer?(e.viewport.set(t,e.height-s-r,i,s),e.scissor.set(t,e.height-s-r,i,s)):(e.viewport.set(t,r,i,s),e.scissor.set(t,r,i,s))}}function out(n){const e=[],t=[],r=[];let i=n;const s=n-dA+1+Tce.length;for(let a=0;an-dA?l=Tce[a-n+dA-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],p=6,g=6,x=3,_=2,y=1,M=new Float32Array(x*g*p),C=new Float32Array(_*g*p),k=new Float32Array(y*g*p);for(let U=0;U2?0:-1,V=[z,O,0,z+2/3,O,0,z+2/3,O+1,0,z,O,0,z+2/3,O+1,0,z,O+1,0],$=sut[U];M.set(V,x*g*$),C.set(h,_*g*$);const G=[$,$,$,$,$,$];k.set(G,y*g*$)}const B=new Pr;B.setAttribute("position",new Gi(M,x)),B.setAttribute("uv",new Gi(C,_)),B.setAttribute("faceIndex",new Gi(k,y)),r.push(new ui(B,null)),i>dA&&i--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function Nce(n,e,t){const r={magFilter:Ci,minFilter:Ci,generateMipmaps:!1,type:ba,format:Oa,colorSpace:Rv,depthBuffer:t},i=new mf(n,e,r);return i.texture.mapping=pm,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function VR(n){const e=new Ho;return e.depthTest=!1,e.depthWrite=!1,e.blending=Yl,e.name=`PMREM_${n}`,e}function lut(n,e,t){const r=pu(new Array(fx).fill(0)),i=hr(new Fe(0,1,0)),s=hr(0),a=Ze(fx),o=hr(0),l=hr(1),c=as(),u=hr(0),d=Ze(1/e),h=Ze(1/t),p=Ze(n),g={n:a,latitudinal:o,weights:r,poleAxis:i,outputDirection:zR,dTheta:s,samples:l,envMap:c,mipInt:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:p},x=VR("blur");return x.fragmentNode=x3e({...g,latitudinal:o.equal(1)}),GC.set(x,g),x}function cut(n,e,t){const r=as(),i=hr(0),s=hr(0),a=Ze(1/e),o=Ze(1/t),l=Ze(n),c={envMap:r,roughness:i,mipInt:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:l},u=VR("ggx");return u.fragmentNode=v3e({...c,N_immutable:zR,GGX_SAMPLES:bn(nut)}),GC.set(u,c),u}function Mce(n){const e=VR("cubemap");return e.fragmentNode=kd(n,zR),e}function Cce(n){const e=VR("equirect");return e.fragmentNode=as(n,GX(zR),0),e}const Pce=new WeakMap;function uut(n){const e=Math.log2(n)-2,t=1/n;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function dut(n,e,t){const r=hut(e);let i=r.get(n);if((i!==void 0?i.pmremVersion:-1)!==n.pmremVersion){const a=n.image;if(n.isCubeTexture)if(put(a))i=t.fromCubemap(n,i);else return null;else if(mut(a))i=t.fromEquirectangular(n,i);else return null;if(i.pmremVersion=n.pmremVersion,r.has(n)===!1){const o=()=>{n.removeEventListener("dispose",o);const l=r.get(n);l!==void 0&&(l.dispose(),r.delete(n))};n.addEventListener("dispose",o)}r.set(n,i)}return i.texture}function hut(n){let e=Pce.get(n);return e===void 0&&(e=new WeakMap,Pce.set(n,e)),e}class fut extends $o{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const i=new Aa;i.isRenderTargetTexture=!0,this._texture=as(i),this._width=hr(0),this._height=hr(0),this._maxMip=hr(0),this.updateBeforeType=Or.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=uut(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,i=this._value;r!==i.pmremVersion&&(i.isPMREMTexture===!0||i.mapping===pm?t=i:t=dut(i,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new aut(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=this._pmrem.isRenderTargetTexture?BC.mul(Ct(t.x,t.y.negate(),t.z)):BC.mul(t);let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),A3e(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function put(n){if(n==null)return!1;let e=0;const t=6;for(let r=0;r0}const YX=Ti(fut).setParameterLength(1,3),Rce=new WeakMap;class gut extends W3{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const d=r.isTextureNode?r.value:t[r.property],h=this._getPMREMNodeCache(e.renderer);let p=h.get(d);p===void 0&&(p=YX(d),h.set(d,p)),r=p}const s=t.useAnisotropy===!0||t.anisotropy>0?d_e:ss,a=r.context(Lce(qp,s)).mul(NN),o=r.context(Aut(c2)).mul(Math.PI).mul(NN),l=E_(a),c=E_(o);e.context.radiance.addAssign(l),e.context.iblIrradiance.addAssign(c);const u=e.context.lightingModel.clearcoatRadiance;if(u){const d=r.context(Lce(S_,nA)).mul(NN),h=E_(d);u.addAssign(h)}}_getPMREMNodeCache(e){let t=Rce.get(e);return t===void 0&&(t=new WeakMap,Rce.set(e,t)),t}}const Lce=(n,e)=>{let t=null;return{getUV:()=>(t===null&&(t=fa.negate().reflect(e),t=iX(n).mix(t,e).normalize(),t=t.transformDirection(g6)),t),getTextureLevel:()=>n}},Aut=n=>({getUV:()=>n,getTextureLevel:()=>Ze(1)}),xut=new JP;class y3e extends Ho{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(xut),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new gut(t):null}setupLightingModel(){return new m3e}setupSpecular(){const e=ki(Ct(.04),Qs.rgb,dg);HA.assign(Ct(.04)),Nx.assign(e),Mx.assign(1)}setupVariants(){const e=this.metalnessNode?Ze(this.metalnessNode):y_e;dg.assign(e);let t=this.roughnessNode?Ze(this.roughnessNode):v_e;t=$X({roughness:t}),qp.assign(t),this.setupSpecular(),hx.assign(Qs.rgb.mul(e.oneMinus()))}}const vut=new q$;class yut extends y3e{static get type(){return"MeshPhysicalNodeMaterial"}constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(vut),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?Ze(this.iorNode):I_e;g4.assign(e),HA.assign(xh(rX(g4.sub(1).div(g4.add(1))).mul(x_e),Ct(1)).mul(eq)),Nx.assign(ki(HA,Qs.rgb,dg)),Mx.assign(ki(eq,1,dg))}setupLightingModel(){return new m3e(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?Ze(this.clearcoatNode):__e,r=this.clearcoatRoughnessNode?Ze(this.clearcoatRoughnessNode):w_e;LC.assign(t),S_.assign($X({roughness:r}))}if(this.useSheen){const t=this.sheenNode?Ct(this.sheenNode):E_e,r=this.sheenRoughnessNode?Ze(this.sheenRoughnessNode):N_e;Bh.assign(t),J1.assign(r)}if(this.useIridescence){const t=this.iridescenceNode?Ze(this.iridescenceNode):C_e,r=this.iridescenceIORNode?Ze(this.iridescenceIORNode):P_e,i=this.iridescenceThicknessNode?Ze(this.iridescenceThicknessNode):R_e;bR.assign(t),kC.assign(r),IC.assign(i)}if(this.useAnisotropy){const t=(this.anisotropyNode?jn(this.anisotropyNode):M_e).toVar();H1.assign(t.length()),pr(H1.equal(0),()=>{t.assign(jn(1,0))}).Else(()=>{t.divAssign(jn(H1)),H1.assign(H1.saturate())}),DC.assign(H1.pow2().mix(qp.pow2(),1)),m4.assign(Cx[0].mul(t.x).add(Cx[1].mul(t.y))),Ux.assign(Cx[1].mul(t.x).sub(Cx[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?Ze(this.transmissionNode):L_e,r=this.thicknessNode?Ze(this.thicknessNode):k_e,i=this.attenuationDistanceNode?Ze(this.attenuationDistanceNode):D_e,s=this.attenuationColorNode?Ct(this.attenuationColorNode):O_e;if(jC.assign(t),VW.assign(r),qW.assign(i),GW.assign(s),this.useDispersion){const a=this.dispersionNode?Ze(this.dispersionNode):F_e;HW.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?Ct(this.clearcoatNormalNode):S_e}setup(e){e.context.setupClearcoatNormal=()=>Vx(this.setupClearcoatNormal(e),"NORMAL","vec3"),super.setup(e)}}const but=Pt(({normal:n,lightDirection:e,builder:t})=>{const r=n.dot(e),i=jn(r.mul(.5).add(.5),0);if(t.material.gradientMap){const s=tg("gradientMap","texture").context({getUV:()=>i});return Ct(s.r)}else{const s=i.fwidth().mul(.5);return ki(Ct(.7),Ct(1),hf(Ze(.7).sub(s.x),Ze(.7).add(s.x),i.x))}});class _ut extends BR{direct({lightDirection:e,lightColor:t,reflectedLight:r},i){const s=but({normal:RR,lightDirection:e,builder:i}).mul(t);r.directDiffuse.addAssign(s.mul(zv({diffuseColor:Qs.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:i}=e.context;i.indirectDiffuse.addAssign(r.mul(zv({diffuseColor:Qs}))),i.indirectDiffuse.mulAssign(t)}}const wut=new G$;class Sut extends Ho{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(wut),this.setValues(e)}setupLightingModel(){return new _ut}}const b3e=Pt(()=>{const n=Ct(fa.z,0,fa.x.negate()).normalize(),e=fa.cross(n);return jn(n.dot(ss),e.dot(ss)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),Tut=new $$;class Eut extends Ho{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Tut),this.setValues(e)}setupVariants(e){const t=b3e;let r;e.material.matcap?r=tg("matcap","texture").context({getUV:()=>t}):r=Ct(ki(.2,.8,t.y)),Qs.rgb.mulAssign(r.rgb)}}class Nut extends $o{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}generateNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if(this.getNodeType(e)==="vec2"){const s=t.cos(),a=t.sin();return yR(s,a,a.negate(),s).mul(r)}else{const s=t,a=RA(er(1,0,0,0),er(0,R0(s.x),Pd(s.x).negate(),0),er(0,Pd(s.x),R0(s.x),0),er(0,0,0,1)),o=RA(er(R0(s.y),0,Pd(s.y),0),er(0,1,0,0),er(Pd(s.y).negate(),0,R0(s.y),0),er(0,0,0,1)),l=RA(er(R0(s.z),Pd(s.z).negate(),0,0),er(Pd(s.z),R0(s.z),0,0),er(0,0,1,0),er(0,0,0,1));return a.mul(o).mul(l).mul(er(r,1)).xyz}}}const x6=Ti(Nut).setParameterLength(2),Mut=new FP;class _3e extends Ho{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(Mut),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:i,rotationNode:s,scaleNode:a,sizeAttenuation:o}=this,l=xm.mul(Ct(i||0));let c=jn(Hf[0].xyz.length(),Hf[1].xyz.length());a!==null&&(c=c.mul(jn(a))),r.isPerspectiveCamera&&o===!1&&(c=c.mul(l.z.negate()));let u=Yu.xy;if(t.center&&t.center.isVector2===!0){const p=Not("center","vec2",t);u=u.sub(p.sub(.5))}u=u.mul(c);const d=Ze(s||T_e),h=x6(u,d);return er(l.xy.add(h),l.zw)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const Cut=new i6,Put=new en;class Rut extends _3e{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(Cut),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return xm.mul(Ct(e||oo)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:i,scaleNode:s,sizeNode:a,sizeAttenuation:o}=this;let l=super.setupVertex(e);if(t.isNodeMaterial!==!0)return l;let c=a!==null?jn(a):j_e;c=c.mul(_X),r.isPerspectiveCamera&&o===!0&&(c=c.mul(Lut.div(gl.z.negate()))),s&&s.isNode&&(c=c.mul(jn(s)));let u=Yu.xy;if(i&&i.isNode){const d=Ze(i);u=x6(u,d)}return u=u.mul(c),u=u.div(wX.div(2)),u=u.mul(l.w),l=l.add(er(u,0,0)),l}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const Lut=hr(1).onFrameUpdate(function({renderer:n}){const e=n.getSize(Put);this.value=.5*e.y});class kut extends BR{constructor(){super(),this.shadowNode=Ze(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Qs.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Qs.rgb)}}const Iut=new z$;class Dut extends Ho{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(Iut),this.setValues(e)}setupLightingModel(){return new kut}}i1("vec3");i1("vec3");i1("vec3");class Out{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context=typeof self<"u"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){this._context!==null&&this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class WA{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let r=this.weakMaps[t];return r===void 0&&(r=new WeakMap,this.weakMaps[t]=r),r}get(e){let t=this._getWeakMap(e);for(let r=0;r{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.getNodeBuilderState().hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getIndirectOffset(){return this._geometries.getIndirectOffset(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],i=new Set,s={};for(const a of e){let o;if(a.node&&a.node.attribute?o=a.node.attribute:(o=t.getAttribute(a.name),o!==void 0&&(o.isInterleavedBufferAttribute?s[a.name]=o.data.uuid:s[a.name]=o.id)),o===void 0)continue;r.push(o);const l=o.isInterleavedBufferAttribute?o.data:o;i.add(l)}return this.attributes=r,this.attributesId=s,this.vertexBuffers=Array.from(i.values()),r}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:i,drawRange:s}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),o=this.getIndex(),l=o!==null;let c=1;if(r.isInstancedBufferGeometry===!0?c=r.instanceCount:e.count!==void 0&&(c=Math.max(0,e.count)),c===0)return null;if(a.instanceCount=c,e.isBatchedMesh===!0)return a;let u=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(u=2);let d=s.start*u,h=(s.start+s.count)*u;i!==null&&(d=Math.max(d,i.start*u),h=Math.min(h,(i.start+i.count)*u));const p=r.attributes.position;let g=1/0;l?g=o.count:p!=null&&(g=p.count),d=Math.max(d,0),h=Math.min(h,g);const x=h-d;return x<0||x===1/0?null:(a.vertexCount=x,a.firstVertex=d,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const i=e.attributes[r];t+=r+",",i.data&&(t+=i.data.stride+","),i.offset&&(t+=i.offset+","),i.itemSize&&(t+=i.itemSize+","),i.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const i=e.morphAttributes[r];t+="morph-"+r+",";for(let s=0,a=i.length;s1)&&(i+=e.uuid+","),i+=this.context.id+",",i+=e.receiveShadow+",",G3(i)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(r===void 0)return!0;const i=r.isInterleavedBufferAttribute?r.data.uuid:r.id;if(e[t]!==i)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=f4(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=f4(e,1)),e=f4(e,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this._sourceMaterial!==null&&this._sourceMaterial.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}const Np=[];class Uut{constructor(e,t,r,i,s,a){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=i,this.bindings=s,this.info=a,this.chainMaps={}}get(e,t,r,i,s,a,o,l){const c=this.getChainMap(l);Np[0]=e,Np[1]=t,Np[2]=a,Np[3]=s;let u=c.get(Np);return u===void 0?(u=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,i,s,a,o,l),c.set(Np,u)):(u.camera=i,u.updateClipping(o),u.needsGeometryUpdate&&u.setGeometry(e.geometry),(u.version!==t.version||u.needsUpdate)&&(u.initialCacheKey!==u.getCacheKey()?(u.dispose(),u=this.get(e,t,r,i,s,a,o,l)):u.version=t.version)),Np[0]=null,Np[1]=null,Np[2]=null,Np[3]=null,u}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new WA)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,i,s,a,o,l,c,u,d){const h=this.getChainMap(d),p=new But(e,t,r,i,s,a,o,l,c,u);return p.onDispose=()=>{this.pipelines.delete(p),this.bindings.deleteForRender(p),this.nodes.delete(p),h.delete(p.getChainArray())},p}}class u2{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const $f={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},rA=16,zut=211,Vut=212;class qut extends u2{constructor(e,t){super(),this.backend=e,this.info=t}delete(e){const t=super.delete(e);return t!==null&&(this.backend.destroyAttribute(e),this.info.destroyAttribute(e)),t}update(e,t){const r=this.get(e);if(r.version===void 0)t===$f.VERTEX?(this.backend.createAttribute(e),this.info.createAttribute(e)):t===$f.INDEX?(this.backend.createIndexAttribute(e),this.info.createIndexAttribute(e)):t===$f.STORAGE?(this.backend.createStorageAttribute(e),this.info.createStorageAttribute(e)):t===$f.INDIRECT&&(this.backend.createIndirectStorageAttribute(e),this.info.createIndirectStorageAttribute(e)),r.version=this._getBufferAttribute(e).version;else{const i=this._getBufferAttribute(e);(r.version=65535?jP:OP)(e,1);return i.version=w3e(n),i.__id=S3e(n),i}class Gut extends u2{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,r=this.get(t);r.initialized=!0,this.info.memory.geometries++;const i=()=>{this.info.memory.geometries--;const s=t.index,a=e.getAttributes();s!==null&&this.attributes.delete(s);for(const l of a)this.attributes.delete(l);const o=this.wireframes.get(t);o!==void 0&&this.attributes.delete(o),t.removeEventListener("dispose",i),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",i),this._geometryDisposeListeners.set(t,i)}updateAttributes(e){const t=e.getAttributes();for(const s of t)s.isStorageBufferAttribute||s.isStorageInstancedBufferAttribute?this.updateAttribute(s,$f.STORAGE):this.updateAttribute(s,$f.VERTEX);const r=this.getIndex(e);r!==null&&this.updateAttribute(r,$f.INDEX);const i=e.geometry.indirect;i!==null&&this.updateAttribute(i,$f.INDIRECT)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:r}=e;let i=t.index;if(r.wireframe===!0){const s=this.wireframes;let a=s.get(t);a===void 0?(a=Ice(t),s.set(t,a)):(a.version!==w3e(t)||a.__id!==S3e(t))&&(this.attributes.delete(a),a=Ice(t),s.set(t,a)),i=a}return i}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class Hut{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={attributes:0,attributesSize:0,geometries:0,indexAttributes:0,indexAttributesSize:0,indirectStorageAttributes:0,indirectStorageAttributesSize:0,programs:0,programsSize:0,readbackBuffers:0,readbackBuffersSize:0,renderTargets:0,storageAttributes:0,storageAttributesSize:0,textures:0,texturesSize:0,uniformBuffers:0,uniformBuffersSize:0,total:0},this.memoryMap=new Map}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):on("WebGPUInfo: Unknown object type.")}reset(){this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0;for(const e in this.memory)this.memory[e]=0;this.memoryMap.clear()}createTexture(e){const t=this._getTextureMemorySize(e);this.memoryMap.set(e,t),this.memory.textures++,this.memory.total+=t,this.memory.texturesSize+=t}destroyTexture(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.textures--,this.memory.total-=t,this.memory.texturesSize-=t}_createAttribute(e,t){const r=this._getAttributeMemorySize(e);this.memoryMap.set(e,{size:r,type:t}),this.memory[t]++,this.memory.total+=r,this.memory[t+"Size"]+=r}createAttribute(e){this._createAttribute(e,"attributes")}createIndexAttribute(e){this._createAttribute(e,"indexAttributes")}createStorageAttribute(e){this._createAttribute(e,"storageAttributes")}createIndirectStorageAttribute(e){this._createAttribute(e,"indirectStorageAttributes")}destroyAttribute(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory[t.type]--,this.memory.total-=t.size,this.memory[t.type+"Size"]-=t.size)}createReadbackBuffer(e){const t=e.maxByteLength;this.memoryMap.set(e,{size:t,type:"readbackBuffers"}),this.memory.readbackBuffers++,this.memory.total+=t,this.memory.readbackBuffersSize+=t}destroyReadbackBuffer(e){const{size:t}=this.memoryMap.get(e);this.memoryMap.delete(e),this.memory.readbackBuffers--,this.memory.total-=t,this.memory.readbackBuffersSize-=t}createUniformBuffer(e){const t=e.byteLength;this.memoryMap.set(e,{size:t,type:"uniformBuffers"}),this.memory.uniformBuffers++,this.memory.total+=t,this.memory.uniformBuffersSize+=t}destroyUniformBuffer(e){const t=this.memoryMap.get(e);t&&(this.memoryMap.delete(e),this.memory.uniformBuffers--,this.memory.total-=t.size,this.memory.uniformBuffersSize-=t.size)}createProgram(e){const t=e.code.length;this.memoryMap.set(e,t),this.memory.programs++,this.memory.total+=t,this.memory.programsSize+=t}destroyProgram(e){const t=this.memoryMap.get(e)||0;this.memoryMap.delete(e),this.memory.programs--,this.memory.total-=t,this.memory.programsSize-=t}_getTextureMemorySize(e){if(e.isCompressedTexture)return 1;let t=1;e.type===gg||e.type===ma?t=1:e.type===Ag||e.type===Jh||e.type===ba?t=2:(e.type===ml||e.type===xs||e.type===ea)&&(t=4);let r=4;e.format===e6||e.format===e1||e.format===Tm||e.format===hc||e.format===mu?r=1:e.format===dc||e.format===t1?r=2:(e.format===t2||e.format===NP)&&(r=3);let i=t*r;e.type===I3||e.type===D3?i=2:(e.type===Od||e.type===O3||e.type===j3)&&(i=4);const s=e.width||1,a=e.height||1,o=e.isCubeTexture?6:e.depth||1;let l=s*a*o*i;const c=e.mipmaps;if(c&&c.length>0){let u=0;for(let d=0;d>d),g=h.height||Math.max(1,a>>d);u+=p*g*o*i}}l+=u}else e.generateMipmaps&&(l=l*1.333);return Math.round(l)}_getAttributeMemorySize(e){return e.isInterleavedBufferAttribute&&(e=e.data),e.array?e.array.byteLength:e.count&&e.itemSize?e.count*e.itemSize*4:0}}class T3e{constructor(e){this.cacheKey=e,this.usedTimes=0}}class $ut extends T3e{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class Wut extends T3e{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Xut=0;class YF{constructor(e,t,r,i=null,s=null){this.id=Xut++,this.code=e,this.stage=t,this.name=r,this.transforms=i,this.attributes=s,this.usedTimes=0}}class Yut extends u2{constructor(e,t,r){super(),this.backend=e,this.nodes=t,this.info=r,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:r}=this,i=this.get(e);if(this._needsComputeUpdate(e)){const s=i.pipeline;s&&(s.usedTimes--,s.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let o=this.programs.compute.get(a.computeShader);o===void 0&&(s&&s.computeProgram.usedTimes===0&&this._releaseProgram(s.computeProgram),o=new YF(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,o),r.createProgram(o),this.info.createProgram(o));const l=this._getComputeCacheKey(e,o);let c=this.caches.get(l);c===void 0&&(s&&s.usedTimes===0&&this._releasePipeline(s),c=this._getComputePipeline(e,o,l,t)),c.usedTimes++,o.usedTimes++,i.version=e.version,i.pipeline=c}return i.pipeline}getForRender(e,t=null){const{backend:r}=this,i=this.get(e);if(this._needsRenderUpdate(e)){const s=i.pipeline;s&&(s.usedTimes--,s.vertexProgram.usedTimes--,s.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),o=e.material?e.material.name:"";let l=this.programs.vertex.get(a.vertexShader);l===void 0&&(s&&s.vertexProgram.usedTimes===0&&this._releaseProgram(s.vertexProgram),l=new YF(a.vertexShader,"vertex",o),this.programs.vertex.set(a.vertexShader,l),r.createProgram(l),this.info.createProgram(l));let c=this.programs.fragment.get(a.fragmentShader);c===void 0&&(s&&s.fragmentProgram.usedTimes===0&&this._releaseProgram(s.fragmentProgram),c=new YF(a.fragmentShader,"fragment",o),this.programs.fragment.set(a.fragmentShader,c),r.createProgram(c),this.info.createProgram(c));const u=this._getRenderCacheKey(e,l,c);let d=this.caches.get(u);d===void 0?(s&&s.usedTimes===0&&this._releasePipeline(s),d=this._getRenderPipeline(e,l,c,u,t)):e.pipeline=d,d.usedTimes++,l.usedTimes++,c.usedTimes++,i.pipeline=d}return i.pipeline}isReady(e){const r=this.get(e).pipeline;if(r===void 0)return!1;const i=this.backend.get(r);return i.pipeline!==void 0&&i.pipeline!==null}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,r,i){r=r||this._getComputeCacheKey(e,t);let s=this.caches.get(r);return s===void 0&&(s=new Wut(r,t),this.caches.set(r,s),this.backend.createComputePipeline(s,i)),s}_getRenderPipeline(e,t,r,i,s){i=i||this._getRenderCacheKey(e,t,r);let a=this.caches.get(i);return a===void 0&&(a=new $ut(i,t,r),this.caches.set(i,a),e.pipeline=a,this.backend.createRenderPipeline(e,s)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t),this.info.destroyProgram(e)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class Zut extends u2{constructor(e,t,r,i,s,a){super(),this.backend=e,this.textures=r,this.pipelines=s,this.attributes=i,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings(),r=this.get(e);return r.initialized!==!0&&(this._createBindings(t),r.initialized=!0),t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings,r=this.get(e);return(r.initialized!==!0||r.bindings!==t)&&(r.bindings!==void 0&&this._destroyBindings(r.bindings),this._createBindings(t),r.initialized=!0,r.bindings=t),t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const r=this.get(e).bindings||this.nodes.getForCompute(e).bindings;this._destroyBindings(r),this.delete(e)}deleteForRender(e){const t=e.getBindings();this._destroyBindings(t),this.delete(e)}_createBindings(e){for(const t of e){const r=this.get(t);if(r.bindGroup===void 0){for(const i of t.bindings)if(i.isUniformBuffer)this.backend.createUniformBuffer(i),this.info.createUniformBuffer(i);else if(i.isSampledTexture)this.textures.updateTexture(i.texture);else if(i.isSampler)this.textures.updateSampler(i);else if(i.isStorageBuffer){const s=i.attribute,a=s.isIndirectStorageBufferAttribute?$f.INDIRECT:$f.STORAGE;this.attributes.update(s,a)}this.backend.createBindings(t,e,0),r.bindGroup=t,r.usedTimes=1}else r.usedTimes++}}_destroyBindings(e){for(const t of e){const r=this.get(t);if(r.usedTimes--,r.usedTimes===0){for(const i of t.bindings)i.isUniformBuffer?(this.backend.destroyUniformBuffer(i),this.info.destroyUniformBuffer(i),i.release()):i.isSampler&&(i.isSampledTexture!==!0&&this.backend.destroySampler(i),i.release());this.backend.deleteBindGroupData(t),this.delete(t)}}}_updateBindings(e){for(const t of e)this._update(t,e)}_update(e,t){const{backend:r}=this;let i=!1,s=!0,a=0,o=0;for(const l of e.bindings)if(this.nodes.updateGroup(l)!==!1){if(l.isStorageBuffer){const u=l.attribute,d=u.isIndirectStorageBufferAttribute?$f.INDIRECT:$f.STORAGE,h=r.get(l);this.attributes.update(u,d),h.attribute!==u&&(h.attribute=u,i=!0)}if(l.isUniformBuffer)l.update()&&r.updateBinding(l);else if(l.isSampledTexture){const u=l.update(),d=l.texture,h=this.textures.get(d);if(u&&(this.textures.updateTexture(d),l.generation!==h.generation&&(l.generation=h.generation,i=!0),h.bindGroups.add(e)),r.get(d).externalTexture!==void 0||h.isDefaultTexture?s=!1:(a=a*10+d.id,o+=d.version),d.isStorageTexture===!0&&d.mipmapsAutoUpdate===!0){const g=this.get(d);l.store===!0?g.needsMipmap=!0:this.textures.needsMipmaps(d)&&g.needsMipmap===!0&&(this.backend.generateMipmaps(d),g.needsMipmap=!1)}}else if(l.isSampler&&l.update()){const d=this.textures.updateSampler(l);l.samplerKey!==d&&(l.samplerKey=d,i=!0)}l.isBuffer&&l.updateRanges.length>0&&l.clearUpdateRanges()}i===!0&&this.backend.updateBindings(e,t,s?a:0,o)}}const Qut=Object.freeze([]);function Kut(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?n.z-e.z:n.id-e.id}function Dce(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Oce(n){return(n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode)&&n.side===ao&&n.forceSinglePass===!1}class Jut{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lighting=e,this.lightsNode=e.getNode(t),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0,this._lastOcclusionObject=null}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,i,s,a,o){let l=this.renderItems[this.renderItemsIndex];return l===void 0?(l={id:e.id,object:e,geometry:t,material:r,groupOrder:i,renderOrder:e.renderOrder,z:s,group:a,clippingContext:o},this.renderItems[this.renderItemsIndex]=l):(l.id=e.id,l.object=e,l.geometry=t,l.material=r,l.groupOrder=i,l.renderOrder=e.renderOrder,l.z=s,l.group=a,l.clippingContext=o),this.renderItemsIndex++,l}push(e,t,r,i,s,a,o){const l=this.getNextRenderItem(e,t,r,i,s,a,o);e.occlusionTest===!0&&this._lastOcclusionObject!==e&&(this.occlusionQueryCount++,this._lastOcclusionObject=e),r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(Oce(r)&&this.transparentDoublePass.push(l),this.transparent.push(l)):this.opaque.push(l)}unshift(e,t,r,i,s,a,o){const l=this.getNextRenderItem(e,t,r,i,s,a,o);r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(Oce(r)&&this.transparentDoublePass.unshift(l),this.transparent.unshift(l)):this.opaque.unshift(l)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t,r){this.opaque.length>1&&this.opaque.sort(e||Kut),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||Dce),this.transparent.length>1&&this.transparent.sort(t||Dce),r&&(this.opaque.reverse(),this.transparentDoublePass.reverse(),this.transparent.reverse())}finish(){this.lightsNode.setLights(this.lighting.enabled?this.lightsArray:Qut);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,c=o.height>>t;let u=e.depthTexture||s[t];const d=e.depthBuffer===!0||e.stencilBuffer===!0;let h=!1;const p=u!==void 0&&u.image!==void 0&&u.image.depth>1,g=o.depth>1&&(e.useArrayDepthTexture||e.multiview||p);u===void 0&&d&&(u=new zc,u.format=e.stencilBuffer?mu:hc,u.type=e.stencilBuffer?Od:xs,u.image.width=l,u.image.height=c,u.image.depth=o.depth,u.renderTarget=e,s[t]=u),u&&(u.isArrayTexture=g),(r.width!==o.width||o.height!==r.height)&&(h=!0,u&&(u.needsUpdate=!0,u.image.width=l,u.image.height=c,u.image.depth=g?o.depth:1)),r.width=o.width,r.height=o.height,r.textures=a,r.depthTexture=u||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==i&&(h=!0,u&&(u.needsUpdate=!0),r.sampleCount=i);const x={sampleCount:i};if(e.isXRRenderTarget!==!0){for(let _=0;_{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(r.initialized===!0&&r.version===e.version)return;const i=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,s=this.backend;if(i&&r.initialized===!0&&s.destroyTexture(e),e.isFramebufferTexture){const c=this.renderer.getRenderTarget();c?e.type=c.texture.type:e.type=ma}if(e.isHTMLTexture&&e.image){const c=this.renderer.domElement;if("requestPaint"in c){if(c.hasAttribute("layoutsubtree")||c.setAttribute("layoutsubtree","true"),e.image.parentNode!==c&&c.appendChild(e.image),this._htmlTextures.size===0){const u=this._htmlTextures;c.onpaint=d=>{const h=d&&d.changedElements;for(const p of u)(!h||h.includes(p.image))&&(p.needsUpdate=!0)}}this._htmlTextures.add(e)}}const{width:a,height:o,depth:l}=this.getSize(e);if(t.width=a,t.height=o,t.depth=l,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,o):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,i||e.isStorageTexture===!0||e.isExternalTexture===!0)s.createTexture(e,t),r.generation=e.version;else if(e.version>0){const c=e.image;if(c===void 0)sn("Renderer: Texture marked for update but image is undefined.");else if(c.complete===!1)sn("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const d=[];for(const h of e.images)d.push(h);t.images=d}else t.image=c;(r.isDefaultTexture===void 0||r.isDefaultTexture===!0)&&(s.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),e.source.dataReady===!0&&s.updateTexture(e,t);const u=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!u&&s.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else s.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;r.initialized!==!0&&(r.initialized=!0,r.generation=e.version,r.bindGroups=new Set,this.info.createTexture(e),e.isVideoTexture&&Sr.enabled===!0&&Sr.getTransfer(e.colorSpace)!==rr&&sn("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=idt){let r=e.images?e.images[0]:e.image;return r?(r.image!==void 0&&(r=r.image),e.isHTMLTexture?(t.width=r.offsetWidth||1,t.height=r.offsetHeight||1,t.depth=1):typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):typeof VideoFrame<"u"&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let i;return e.mipmaps.length>0?i=e.mipmaps.length:e.isCompressedTexture===!0?i=1:i=Math.floor(Math.log2(Math.max(t,r)))+1,i}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),r=t.textures,i=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let s=0;s{i.isOverrideContextNode===!0&&e.push(i.value.overrideNodes)});const t=new Map(e.flatMap(i=>Array.from(i.entries()))),r=super.getFlowContextData();return r.overrideNodes=t,r}}function M3e(n,e=null,t=null){if(e&&e.isNode){const r=e;e=()=>r}return new N3e(new Map([[n,e]]),t)}cn("overrideNode",(n,e,t)=>M3e(e,t,n));function C3e(n,e=null){const t=new Map;for(const[r,i]of n){const s=i!==null?typeof i=="function"?i:()=>i:null;t.set(r,s)}return new N3e(t,e)}cn("overrideNodes",(n,e)=>C3e(e,n));class P3e extends Ts{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){const r=this.getNodeType(e),i=e.getStructTypeNode(r);let s;return i!==null?s=i.getMemberType(e,t):(on(`TSL: Member "${t}" not found in struct "${r}".`,new Ol),s="float"),s}getHash(){return String(this.id)}generate(){return this.name}}const adt=(n,e)=>new P3e(n,e);class odt extends mr{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=null,this._nodeDataLibrary=new Map,this.isStackNode=!0}getElementType(e){return this.outputNode?this.outputNode.getElementType(e):"void"}generateNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.outputNode?this.outputNode.getMemberType(e,t):"void"}addToStack(e,t=-1){if(e.isNode!==!0)return on("TSL: Invalid node added to stack.",new Ol),this;if(t===-1)if(this._currentNode){let r=this._nodeDataLibrary.get(this._currentNode);r===void 0&&(r={delta:0},this._nodeDataLibrary.set(this._currentNode,r)),r.delta++,t=this.nodes.indexOf(this._currentNode)+r.delta}else t=this.nodes.length;return this.nodes.splice(t,0,e),this}addToStackBefore(e){const t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){const r=new i_(t);return this._currentCond=rd(e,r),this.addToStack(this._currentCond)}ElseIf(e,t){const r=new i_(t),i=rd(e,r);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new i_(e),this}Switch(e){return this._expressionNode=or(e),this}Case(...e){const t=[];if(e.length>=2)for(let o=0;otypeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}class cdt extends mr{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=ldt(e),this.name=t,this.isStructTypeNode=!0}getLength(){let e=1,t=0;for(const r of this.membersLayout){const i=r.type,s=Dat(i),a=Oat(i);e=Math.max(e,a);const l=t%e%a;l!==0&&(t+=a-l),t+=s}return Math.ceil(t/e)*e}getMemberType(e,t){const r=this.membersLayout.find(i=>i.name===t);return r?r.type:"void"}generateNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class udt extends mr{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}generateNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}_getChildren(){const e=super._getChildren(),t=e.find(r=>r.childNode===this.structTypeNode);return e.splice(e.indexOf(t),1),e.push(t),e}generate(e){const t=e.getVarFromNode(this),r=t.type,i=e.getPropertyName(t);return e.addLineFlowCode(`${i} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}const ddt=(n,e=null)=>{const t=new cdt(n,e);return DW((...i)=>{let s=null;if(i.length>0)if(i[0].isNode){s={};const a=Object.keys(n);for(let o=0;onew v6(n,"int","float"),O3e=n=>new v6(n,"uint","float"),Adt=n=>new v6(n,"float","int"),xdt=n=>new v6(n,"float","uint"),G8={};class sf extends Vt{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,r){r==="int"?t.assign(D3e(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return bn;case"int":return Tt;case"uvec2":return jW;case"uvec3":return oy;case"uvec4":return zW;case"ivec2":return bo;case"ivec3":return FW;case"ivec4":return UW}}_createTrailingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return Pt(([s])=>{const a=bn(0);this._resolveElementType(s,a,t);const o=Ze(a.bitAnd(KW(a))),c=O3e(o).shiftRight(23).sub(127);return r(c)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const r=this._returnDataNode(t);return Pt(([s])=>{pr(s.equal(bn(0)),()=>bn(32));const a=bn(0),o=bn(0);return this._resolveElementType(s,a,t),pr(a.shiftRight(16).equal(0),()=>{o.addAssign(16),a.shiftLeftAssign(16)}),pr(a.shiftRight(24).equal(0),()=>{o.addAssign(8),a.shiftLeftAssign(8)}),pr(a.shiftRight(28).equal(0),()=>{o.addAssign(4),a.shiftLeftAssign(4)}),pr(a.shiftRight(30).equal(0),()=>{o.addAssign(2),a.shiftLeftAssign(2)}),pr(a.shiftRight(31).equal(0),()=>{o.addAssign(1)}),r(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const r=this._returnDataNode(t);return Pt(([s])=>{const a=bn(0);this._resolveElementType(s,a,t),a.assign(a.sub(a.shiftRight(bn(1)).bitAnd(bn(1431655765)))),a.assign(a.bitAnd(bn(858993459)).add(a.shiftRight(bn(2)).bitAnd(bn(858993459))));const o=a.add(a.shiftRight(bn(4))).bitAnd(bn(252645135)).mul(bn(16843009)).shiftRight(bn(24));return r(o)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,r,i){const s=this._returnDataNode(t);return Pt(([o])=>{if(r===1)return s(i(o));{const l=s(0),c=["x","y","z","w"];for(let u=0;ud(r))()}}sf.COUNT_TRAILING_ZEROS="countTrailingZeros";sf.COUNT_LEADING_ZEROS="countLeadingZeros";sf.COUNT_ONE_BITS="countOneBits";const vdt=Nn(sf,sf.COUNT_TRAILING_ZEROS).setParameterLength(1),ydt=Nn(sf,sf.COUNT_LEADING_ZEROS).setParameterLength(1),bdt=Nn(sf,sf.COUNT_ONE_BITS).setParameterLength(1),_dt=Pt(([n])=>{const e=n.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/2**32)}),cq=(n,e)=>Gf(Vr(4,n.mul(Qi(1,n))),e),wdt=(n,e)=>n.lessThan(.5)?cq(n.mul(2),e).div(2):Qi(1,cq(Vr(Qi(1,n),2),e).div(2)),Sdt=(n,e,t)=>Gf(df(Gf(n,e),jl(Gf(n,e),Gf(Qi(1,n),t))),1/e),Tdt=(n,e)=>Pd(FC.mul(e.mul(n).sub(1))).div(FC.mul(e.mul(n).sub(1)));class QX extends $o{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}generateNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const Edt=Nn(QX,"snorm").setParameterLength(1),Ndt=Nn(QX,"unorm").setParameterLength(1),Mdt=Nn(QX,"float16").setParameterLength(1);class KX extends $o{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}generateNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const Cdt=Nn(KX,"snorm").setParameterLength(1),Pdt=Nn(KX,"unorm").setParameterLength(1),Rdt=Nn(KX,"float16").setParameterLength(1),Jm=Pt(([n])=>n.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),Ldt=Pt(([n])=>Ct(Jm(n.z.add(Jm(n.y.mul(1)))),Jm(n.z.add(Jm(n.x.mul(1)))),Jm(n.y.add(Jm(n.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),kdt=Pt(([n,e,t])=>{const r=Ct(n).toVar(),i=Ze(1.4).toVar(),s=Ze(0).toVar(),a=Ct(r).toVar();return ta({start:Ze(0),end:Ze(3),type:"float",condition:"<="},()=>{const o=Ct(Ldt(a.mul(2))).toVar();r.addAssign(o.add(t.mul(Ze(.1).mul(e)))),a.mulAssign(1.8),i.mulAssign(1.5),r.mulAssign(1.2);const l=Ze(Jm(r.z.add(Jm(r.x.add(Jm(r.y)))))).toVar();s.addAssign(l.div(i)),a.addAssign(.14)}),s}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class Idt extends mr{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}generateNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let r=this._candidateFn;if(r===null){let i=null,s=-1;for(const a of this.functionNodes){const l=a.shaderNode.layout;if(l===null)throw new Error("THREE.FunctionOverloadingNode: FunctionNode must be a layout.");const c=l.inputs;if(t.length===c.length){let u=0;for(let d=0;ds&&(i=a,s=u)}}this._candidateFn=r=i}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const Ddt=Ti(Idt),wu=n=>(...e)=>Ddt(n,...e),X3=hr(0).setGroup(yr).onRenderUpdate(n=>n.time),Odt=hr(0).setGroup(yr).onRenderUpdate(n=>n.deltaTime),j3e=hr(0,"uint").setGroup(yr).onRenderUpdate(n=>n.frameId),jdt=(n=X3)=>n.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),Fdt=(n=X3)=>n.fract().round(),Bdt=(n=X3)=>n.add(.5).fract().mul(2).sub(1).abs(),Udt=(n=X3)=>n.fract();function zdt(n,e=null){return s1(e,{getUV:typeof n=="function"?n:()=>n})}const Vdt=Pt(([n,e,t=jn(.5)])=>x6(n.sub(t),e).add(t)),qdt=Pt(([n,e,t=jn(.5)])=>{const r=n.sub(t),i=r.dot(r),a=i.mul(i).mul(e);return n.add(r.mul(a))}),Gdt=Pt(({position:n=null,horizontal:e=!0,vertical:t=!1})=>{let r;n!==null?(r=Hf.toVar(),r[3][0]=n.x,r[3][1]=n.y,r[3][2]=n.z):r=Hf;const i=l2.mul(r);return h3(e)&&(i[0][0]=Hf[0].length(),i[0][1]=0,i[0][2]=0),h3(t)&&(i[1][0]=0,i[1][1]=Hf[1].length(),i[1][2]=0),i[2][0]=0,i[2][1]=0,i[2][2]=1,Id.mul(i).mul(oo)}),Hdt=Pt(([n=null])=>{const e=qC();return qC(zX(n)).sub(e).lessThan(0).select(F0,n)}),$dt=Pt(([n,e=na(),t=Ze(0)])=>{const r=n.x,i=n.y,s=t.mod(r.mul(i)).floor(),a=s.mod(r),o=i.sub(s.add(1).div(r).ceil()),l=n.reciprocal(),c=jn(a,o);return e.add(c).mul(l)}),F3e=Pt(([n,e=null,t=null,r=Ze(1),i=oo,s=ud])=>{let a=s.abs().normalize();a=a.div(a.dot(Ct(1)));const o=i.yz.mul(r),l=i.zx.mul(r),c=i.xy.mul(r),u=n.value,d=e!==null?e.value:u,h=t!==null?t.value:u,p=as(u,o).mul(a.x),g=as(d,l).mul(a.y),x=as(h,c).mul(a.z);return jl(p,g,x)}),Wdt=(...n)=>F3e(...n),ob=new Bf,H2=new Fe,lb=new Fe,ZF=new Fe,Xw=new ir,H8=new Fe(0,0,-1),Mp=new gr,Yw=new Fe,$8=new Fe,Zw=new gr,W8=new en,HC=new mf,Xdt=F0.flipX();HC.depthTexture=new zc(1,1);let X8=!1;class JX extends Am{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||HC.texture,Xdt),this._reflectorBaseNode=e.reflector||new Ydt(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=new JX({defaultTexture:HC.depthTexture,reflector:this._reflectorBaseNode})}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class Ydt extends mr{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new os,resolutionScale:i=1,generateMipmaps:s=!1,bounces:a=!0,depth:o=!1,samples:l=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=i,t.resolution!==void 0&&(ji('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=s,this.bounces=a,this.depth=o,this.samples=l,this.updateBeforeType=a?Or.RENDER:Or.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolutionScale;t.getDrawingBufferSize(W8),e.setSize(Math.round(W8.width*r),Math.round(W8.height*r))}setup(e){return this._updateResolution(HC,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new mf(0,0,{type:ba,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=y2e,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new zc),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&X8)return!1;X8=!0;const{scene:t,camera:r,renderer:i,material:s}=e,{target:a}=this,o=this.getVirtualCamera(r),l=this.getRenderTarget(o);i.getDrawingBufferSize(W8),this._updateResolution(l,i),lb.setFromMatrixPosition(a.matrixWorld),ZF.setFromMatrixPosition(r.matrixWorld),Xw.extractRotation(a.matrixWorld),H2.set(0,0,1),H2.applyMatrix4(Xw),Yw.subVectors(lb,ZF);const c=Yw.dot(H2)>0;let u=!1;if(c===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){X8=!1;return}u=!0}Yw.reflect(H2).negate(),Yw.add(lb),Xw.extractRotation(r.matrixWorld),H8.set(0,0,-1),H8.applyMatrix4(Xw),H8.add(ZF),$8.subVectors(lb,H8),$8.reflect(H2).negate(),$8.add(lb),o.coordinateSystem=r.coordinateSystem,o.position.copy(Yw),o.up.set(0,1,0),o.up.applyMatrix4(Xw),o.up.reflect(H2),o.lookAt($8),o.near=r.near,o.far=r.far,o.updateMatrixWorld(),o.projectionMatrix.copy(r.projectionMatrix),ob.setFromNormalAndCoplanarPoint(H2,lb),ob.applyMatrix4(o.matrixWorldInverse),Mp.set(ob.normal.x,ob.normal.y,ob.normal.z,ob.constant);const d=o.projectionMatrix;Zw.x=(Math.sign(Mp.x)+d.elements[8])/d.elements[0],Zw.y=(Math.sign(Mp.y)+d.elements[9])/d.elements[5],Zw.z=-1,Zw.w=(1+d.elements[10])/d.elements[14],Mp.multiplyScalar(1/Mp.dot(Zw));const h=0;d.elements[2]=Mp.x,d.elements[6]=Mp.y,d.elements[10]=i.coordinateSystem===mh?Mp.z-h:Mp.z+1-h,d.elements[14]=Mp.w,this.textureNode.value=l.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=l.depthTexture),s.visible=!1;const p=i.getRenderTarget(),g=i.getMRT(),x=i.autoClear;i.setMRT(null),i.setRenderTarget(l),i.autoClear=!0;const _=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",u?(i.clear(),this.hasOutput=!1):(i.render(t,o),this.hasOutput=!0),t.name=_,i.setMRT(g),i.setRenderTarget(p),i.autoClear=x,s.visible=!0,X8=!1,this.forceUpdate=!1}get resolution(){return ji('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){ji('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const Zdt=n=>new JX(n),QF=new Yf(-1,1,1,-1,0,1);class Qdt extends Pr{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new tr([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new tr(t,2))}}const Kdt=new Qdt;class eY extends ui{constructor(e=null){super(Kdt,e),this.camera=QF,this.isQuadMesh=!0}async renderAsync(e){ji('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await e.init(),e.render(this,QF)}render(e){e.render(this,QF)}}const Jdt=new en;class eht extends Am{static get type(){return"RTTNode"}constructor(e,t=null,r=null,i={type:ba}){const s=new mf(t,r,i);super(s.texture,na()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.renderTarget=s,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._resolutionScale=1,this._rttNode=null,this._quadMesh=new eY(new Ho),this.updateBeforeType=Or.RENDER}get autoResize(){return this.width===null}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){const r=Math.floor(e*this._resolutionScale),i=Math.floor(t*this._resolutionScale);this.renderTarget.setSize(r,i),this.textureNeedsUpdate=!0}setResolutionScale(e){return this._resolutionScale=e,this.autoResize===!1&&this.setSize(this.width,this.height),this}getResolutionScale(){return this._resolutionScale}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;this.textureNeedsUpdate=!1;const t=e.getRenderTarget();if(this.autoResize===!0){const i=e.getDrawingBufferSize(Jdt),s=Math.floor(i.width*this._resolutionScale),a=Math.floor(i.height*this._resolutionScale);(s!==this.renderTarget.width||a!==this.renderTarget.height)&&(this.renderTarget.setSize(s,a),this.textureNeedsUpdate=!0)}let r="RTT";this.node.name&&(r=this.node.name+" [ "+r+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=r,e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new Am(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const B3e=(n,...e)=>new eht(or(n),...e),tht=(n,...e)=>n.isSampleNode||n.isTextureNode?n:n.isPassNode?n.getTextureNode():B3e(n,...e),Pb=Pt(([n,e,t],r)=>{let i;r.renderer.coordinateSystem===mh?(n=jn(n.x,n.y.oneMinus()).mul(2).sub(1),i=er(Ct(n,e),1)):i=er(Ct(n.x,n.y.oneMinus(),e).mul(2).sub(1),1);const s=er(t.mul(i));return s.xyz.div(s.w)}),nht=Pt(([n,e])=>{const t=e.mul(er(n,1)),r=t.xy.div(t.w).mul(.5).add(.5).toVar();return jn(r.x,r.y.oneMinus())}),rht=Pt(([n,e,t])=>{const r=Fv(dl(e)),i=bo(n.mul(r)).toVar(),s=dl(e,i).toVar(),a=dl(e,i.sub(bo(2,0))).toVar(),o=dl(e,i.sub(bo(1,0))).toVar(),l=dl(e,i.add(bo(1,0))).toVar(),c=dl(e,i.add(bo(2,0))).toVar(),u=dl(e,i.add(bo(0,2))).toVar(),d=dl(e,i.add(bo(0,1))).toVar(),h=dl(e,i.sub(bo(0,1))).toVar(),p=dl(e,i.sub(bo(0,2))).toVar(),g=ya(Qi(Ze(2).mul(o).sub(a),s)).toVar(),x=ya(Qi(Ze(2).mul(l).sub(c),s)).toVar(),_=ya(Qi(Ze(2).mul(d).sub(u),s)).toVar(),y=ya(Qi(Ze(2).mul(h).sub(p),s)).toVar(),M=Pb(n,s,t).toVar(),C=g.lessThan(x).select(M.sub(Pb(n.sub(jn(Ze(1).div(r.x),0)),o,t)),M.negate().add(Pb(n.add(jn(Ze(1).div(r.x),0)),l,t))),k=_.lessThan(y).select(M.sub(Pb(n.add(jn(0,Ze(1).div(r.y))),d,t)),M.negate().add(Pb(n.sub(jn(0,Ze(1).div(r.y))),h,t)));return sd(Zg(C,k))}),tY=Pt(([n])=>J0(Ze(52.9829189).mul(J0(n0(n,jn(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),k0=Pt(([n,e,t])=>{const r=Ze(2.399963229728653),i=Fd(Ze(n).add(.5).div(Ze(e))),s=Ze(n).mul(r).add(t);return jn(R0(s),Pd(s)).mul(i)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class iht extends mr{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(na())}sample(e){return this.callback(e)}}const sht=(n,e=null)=>new iht(n,or(e));class RN extends jd{constructor(e,t,r=Float32Array){const i=ArrayBuffer.isView(e)?e:new r(e*t);super(i,t),this.isStorageInstancedBufferAttribute=!0}}class aht extends Gi{constructor(e,t,r=Float32Array){const i=ArrayBuffer.isView(e)?e:new r(e*t);super(i,t),this.isStorageBufferAttribute=!0}}const oht=(n,e="float")=>{let t,r;e.isStructTypeNode===!0?(t=e.getLength(),r=RC("float")):(t=Zve(e),r=RC(e));const i=new aht(n,t,r);return LA(i,e,n)},lht=(n,e="float")=>{let t,r;e.isStructTypeNode===!0?(t=e.getLength(),r=RC("float")):(t=Zve(e),r=RC(e));const i=new RN(n,t,r);return LA(i,e,i.count)};class cht extends mr{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const uht=Vn(cht),KF=new ir,U3e=hr(0).setGroup(yr).onRenderUpdate(({scene:n})=>n.backgroundBlurriness),uq=hr(1).setGroup(yr).onRenderUpdate(({scene:n})=>n.backgroundIntensity),z3e=hr(new ir).setGroup(yr).onRenderUpdate(({scene:n})=>{const e=n.background;return e!==null&&e.isTexture&&e.mapping!==KS||n.backgroundNode&&n.backgroundNode.isNode?KF.makeRotationFromEuler(n.backgroundRotation).transpose():KF.identity(),KF});class V3e extends Am{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=Au.WRITE_ONLY}getInputType(){return"storageTexture"}getTransformedUV(e){return e}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){return this.storeNode!==null?(this.generateStore(e),""):super.generate(e,t)}generateSnippet(e,t,r,i,s,a,o,l,c){const u=this.value;return e.generateStorageTextureLoad(u,t,r,i,a,c)}toReadWrite(){return this.setAccess(Au.READ_WRITE)}toReadOnly(){return this.setAccess(Au.READ_ONLY)}toWriteOnly(){return this.setAccess(Au.WRITE_ONLY)}store(e,t){const r=this.clone();return r.referenceNode=this.getBase(),r.uvNode=e,r.storeNode=t,t!==null&&r.toStack(),r}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:i,depthNode:s}=t,a=super.generate(e,"property"),o=r.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),l=i.build(e,"vec4"),c=s?s.build(e,"int"):null,u=e.generateTextureStore(this.value,a,o,c,l);e.addLineFlowCode(u,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e.access=this.access,e}}const q3e=Ti(V3e).setParameterLength(1,3),dht=(n,e,t)=>{let r;return n.isStorageTextureNode===!0?r=n.store(e,t):(r=q3e(n,e,t),t!==null&&r.toStack()),r};class hht extends V3e{static get type(){return"StorageTexture3DNode"}constructor(e,t,r=null){super(e,t,r),this.isStorageTexture3DNode=!0}getDefaultUV(){return Ct(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}}const fht=Ti(hht).setParameterLength(1,3),pht=Pt(({texture:n,uv:e})=>{const r=Ct().toVar();return pr(e.x.lessThan(1e-4),()=>{r.assign(Ct(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{r.assign(Ct(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{r.assign(Ct(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{r.assign(Ct(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{r.assign(Ct(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{r.assign(Ct(0,0,-1))}).Else(()=>{const s=n.sample(e.add(Ct(-.01,0,0))).r.sub(n.sample(e.add(Ct(.01,0,0))).r),a=n.sample(e.add(Ct(0,-.01,0))).r.sub(n.sample(e.add(Ct(0,.01,0))).r),o=n.sample(e.add(Ct(0,0,-.01))).r.sub(n.sample(e.add(Ct(0,0,.01))).r);r.assign(Ct(s,a,o))}),r.normalize()});class mht extends Am{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return Ct(.5,.5,.5)}setUpdateMatrix(){}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return pht({texture:this,uv:e})}}const nY=Ti(mht).setParameterLength(1,3),ght=(...n)=>nY(...n).setSampler(!1),Aht=(n,e,t)=>nY(n,e).level(t);class xht extends LR{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const vht=(n,e,t)=>new xht(n,e,t),jce=new WeakMap;class yht extends $o{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Or.OBJECT,this.updateAfterType=Or.OBJECT,this.previousModelWorldMatrix=hr(new ir),this.previousProjectionMatrix=hr(new ir).setGroup(yr),this.previousCameraViewMatrix=hr(new ir)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const i=Fce(r);this.previousModelWorldMatrix.value.copy(i);const s=G3e(t);s.frameId!==e&&(s.frameId=e,s.previousProjectionMatrix===void 0?(s.previousProjectionMatrix=new ir,s.previousCameraViewMatrix=new ir,s.currentProjectionMatrix=new ir,s.currentCameraViewMatrix=new ir,s.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(s.previousProjectionMatrix.copy(s.currentProjectionMatrix),s.previousCameraViewMatrix.copy(s.currentCameraViewMatrix)),s.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),s.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(s.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(s.previousCameraViewMatrix))}updateAfter({object:e}){Fce(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Id:hr(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(xm).mul(oo),i=this.previousProjectionMatrix.mul(t).mul(Uv),s=r.xy.div(r.w),a=i.xy.div(i.w);return Qi(s,a)}}function G3e(n){let e=jce.get(n);return e===void 0&&(e={},jce.set(n,e)),e}function Fce(n,e=0){const t=G3e(n);let r=t[e];return r===void 0&&(t[e]=r=new ir,t[e].copy(n.matrixWorld)),r}const bht=Vn(yht),_ht=Pt(([n,e])=>xh(1,n.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),wht=Pt(([n,e])=>xh(n.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Sht=Pt(([n,e])=>n.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Tht=Pt(([n,e])=>ki(n.mul(2).mul(e),n.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),jv(.5,n))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),Eht=Pt(([n,e])=>{const t=e.a.add(n.a.mul(e.a.oneMinus()));return er(e.rgb.mul(e.a).add(n.rgb.mul(n.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),Nht=Pt(([n])=>rY(n.rgb)),Mht=Pt(([n,e=Ze(1)])=>e.mix(rY(n.rgb),n.rgb).max(0)),Cht=Pt(([n,e=Ze(0)])=>{const t=jl(n.r,n.g,n.b).div(3),r=n.r.max(n.g.max(n.b)),i=r.sub(t).mul(e).mul(-3);return ki(n.rgb,r,i).max(0)}),Pht=Pt(([n,e=Ze(1)])=>{const t=Ct(.57735,.57735,.57735),r=e.cos();return Ct(n.rgb.mul(r).add(t.cross(n.rgb).mul(e.sin()).add(t.mul(n0(t,n.rgb).mul(r.oneMinus()))))).max(0)}),rY=(n,e=Ct(Sr.getLuminanceCoefficients(new Fe)))=>n0(n,e),Rht=Pt(([n,e=Ct(1),t=Ct(0),r=Ct(1),i=Ze(1),s=Ct(Sr.getLuminanceCoefficients(new Fe,Rv))])=>{const a=n.rgb.dot(Ct(s)),o=Eo(n.rgb.mul(e).add(t),0),l=o.pow(r);return pr(o.r.greaterThan(0),()=>{o.r.assign(l.r)}),pr(o.g.greaterThan(0),()=>{o.g.assign(l.g)}),pr(o.b.greaterThan(0),()=>{o.b.assign(l.b)}),o.assign(a.add(o.sub(a).mul(i)).max(0)),er(o.rgb,n.a)}),Lht=Pt(([n,e])=>n.mul(e).floor().div(e));let Y8=null;class kht extends OR{static get type(){return"ViewportSharedTextureNode"}constructor(e=F0,t=null){Y8===null&&(Y8=new UP),super(e,t,Y8)}getTextureForReference(){return Y8}updateReference(){return this}}const Iht=Ti(kht).setParameterLength(0,2),Z8=new en;class H3e extends Am{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.isPassTextureNode=!0,this.setUpdateMatrix(!1)}setup(e){const t=e.getNodeProperties(this);return t.passNode=this.passNode,super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class Bce extends H3e{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r,this.isPassMultipleTextureNode=!0}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.gatherNode=this.gatherNode,e.offsetNode=this.offsetNode,e}}class tp extends $o{static get type(){return"PassNode"}constructor(e,t,r,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=i,this._width=1,this._height=1;const s=new mf(this._width,this._height,{type:ba,...i});s.texture.name="output";let a=null;(this.scope===tp.DEPTH||i.depthBuffer!==!1)&&(a=new zc,a.isRenderTargetTexture=!0,a.name="depth",s.depthTexture=a),this.renderTarget=s,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:s.texture},a!==null&&(this._textures.depth=a),this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=hr(0),this._cameraFar=hr(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=Or.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return sn("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return sn("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];if(t===void 0){if(e==="depth")throw new Error("THREE.PassNode: Depth texture is not available for this pass.");t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const r=this._textures[e],i=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[i]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new Bce(this,e),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=new Bce(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const r=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=jR(this.getTextureNode(e),r,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const r=this._cameraNear,i=this._cameraFar,s=this.getViewZNode(e);this._linearDepthNodes[e]=t=qx(s,r,i)}return t}async compileAsync(e){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),await e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),e.reversedDepthBuffer===!0&&this.renderTarget.depthTexture!==null&&(this.renderTarget.depthTexture.type=ea),this.scope===tp.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let i;const s=t.getOutputRenderTarget();s&&s.isXRRenderTarget===!0?(i=t.xr.getCamera(),t.xr.updateCamera(i),Z8.set(s.width,s.height)):(i=this.camera,t.getDrawingBufferSize(Z8)),this.setSize(Z8.width,Z8.height);const a=t.getRenderTarget(),o=t.getMRT(),l=t.autoClear,c=t.transparent,u=t.opaque,d=i.layers.mask,h=t.contextNode,p=r.overrideMaterial;this._cameraNear.value=i.near,this._cameraFar.value=i.far,this._layers!==null&&(i.layers.mask=this._layers.mask);for(const x in this._previousTextures)this.toggleTexture(x);this.overrideMaterial!==null&&(r.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:s1({...t.contextNode.getFlowContextData(),...this.contextNode.getFlowContextData()})}),t.contextNode=this._contextNodeCache.context);const g=r.name;r.name=this.name?this.name:r.name,t.render(r,i),r.name=g,r.overrideMaterial=p,t.setRenderTarget(a),t.setMRT(o),t.autoClear=l,t.transparent=c,t.opaque=u,t.contextNode=h,i.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._resolutionScale),i=Math.floor(this._height*this._resolutionScale);this.renderTarget.setSize(r,i),this._scissor!==null?(this.renderTarget.scissor.copy(this._scissor).multiplyScalar(this._resolutionScale).floor(),this.renderTarget.scissorTest=!0):this.renderTarget.scissorTest=!1,this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport).multiplyScalar(this._resolutionScale).floor()}setScissor(e,t,r,i){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new gr),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,i))}setViewport(e,t,r,i){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new gr),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,i))}dispose(){this.renderTarget.dispose()}}tp.COLOR="color";tp.DEPTH="depth";const Dht=(n,e,t)=>new tp(tp.COLOR,n,e,t),Oht=(n,e)=>new H3e(n,e),jht=(n,e,t)=>new tp(tp.DEPTH,n,e,t);class Fht extends tp{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,i,s){super(tp.COLOR,e,t),this.colorNode=r,this.thicknessNode=i,this.alphaNode=s,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((i,s,a,o,l,c,u,d)=>{if((l.isMeshToonMaterial||l.isMeshToonNodeMaterial)&&l.wireframe===!1){const h=this._getOutlineMaterial(l);t.renderObject(i,s,a,o,h,c,u,d)}t.renderObject(i,s,a,o,l,c,u,d)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Ho;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=Ds;const t=ud.negate(),r=Id.mul(xm),i=Ze(1),s=r.mul(er(oo,1)),a=r.mul(er(oo.add(t),1)),o=sd(s.sub(a));return e.vertexNode=s.add(o.mul(this.thicknessNode).mul(s.w).mul(i)),e.colorNode=er(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const Bht=(n,e,t=new Fn(0,0,0),r=.003,i=1)=>new Fht(n,e,or(t),or(r),or(i)),$3e=Pt(([n,e])=>n.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),W3e=Pt(([n,e])=>(n=n.mul(e),n.div(n.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),X3e=Pt(([n,e])=>{n=n.mul(e),n=n.sub(.004).max(0);const t=n.mul(n.mul(6.2).add(.5)),r=n.mul(n.mul(6.2).add(1.7)).add(.06);return t.div(r).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Uht=Pt(([n])=>{const e=n.mul(n.add(.0245786)).sub(90537e-9),t=n.mul(n.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),Y3e=Pt(([n,e])=>{const t=Vc(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=Vc(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return n=n.mul(e).div(.6),n=t.mul(n),n=Uht(n),n=r.mul(n),n.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),zht=Vc(Ct(1.6605,-.1246,-.0182),Ct(-.5876,1.1329,-.1006),Ct(-.0728,-.0083,1.1187)),Vht=Vc(Ct(.6274,.0691,.0164),Ct(.3293,.9195,.088),Ct(.0433,.0113,.8956)),qht=Pt(([n])=>{const e=Ct(n).toVar(),t=Ct(e.mul(e)).toVar(),r=Ct(t.mul(t)).toVar();return Ze(15.5).mul(r.mul(t)).sub(Vr(40.14,r.mul(e))).add(Vr(31.96,r).sub(Vr(6.868,t.mul(e))).add(Vr(.4298,t).add(Vr(.1191,e).sub(.00232))))}),Z3e=Pt(([n,e])=>{const t=Ct(n).toVar(),r=Vc(Ct(.856627153315983,.137318972929847,.11189821299995),Ct(.0951212405381588,.761241990602591,.0767994186031903),Ct(.0482516061458583,.101439036467562,.811302368396859)),i=Vc(Ct(1.1271005818144368,-.1413297634984383,-.14132976349843826),Ct(-.11060664309660323,1.157823702216272,-.11060664309660294),Ct(-.016493938717834573,-.016493938717834257,1.2519364065950405)),s=Ze(-12.47393),a=Ze(4.026069);return t.mulAssign(e),t.assign(Vht.mul(t)),t.assign(r.mul(t)),t.assign(Eo(t,1e-10)),t.assign(am(t)),t.assign(t.sub(s).div(a.sub(s))),t.assign(ep(t,0,1)),t.assign(qht(t)),t.assign(i.mul(t)),t.assign(Gf(Eo(Ct(0),t),Ct(2.2))),t.assign(zht.mul(t)),t.assign(ep(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),Q3e=Pt(([n,e])=>{const t=Ze(.76),r=Ze(.15);n=n.mul(e);const i=xh(n.r,xh(n.g,n.b)),s=rd(i.lessThan(.08),i.sub(Vr(6.25,i.mul(i))),.04);n.subAssign(s);const a=Eo(n.r,Eo(n.g,n.b));pr(a.lessThan(t),()=>n);const o=Qi(1,t),l=Qi(1,o.mul(o).div(a.add(o.sub(t))));n.mulAssign(l.div(a));const c=Qi(1,df(1,r.mul(a.sub(l)).add(1)));return ki(n,Ct(l),c)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Va extends mr{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const i of t)i.build(e);const r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}const qR=Ti(Va).setParameterLength(1,3),Ght=(n,e)=>qR(n,e,"js"),Hht=(n,e)=>qR(n,e,"wgsl"),$ht=(n,e)=>qR(n,e,"glsl");class K3e extends Va{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}generateNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return r===void 0&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),i=r.name,s=r.type,a=e.getCodeFromNode(this,s);i!==""&&(a.name=i);const o=e.getPropertyName(a),l=this.getNodeFunction(e).getCode(o);return a.code=l+` `,t==="property"?o:e.format(`${o}()`,s,t)}}const J3e=(n,e=[],t="")=>{const r=new K3e(n,e,t);return DW((...s)=>r.call(...s),r)},Wht=(n,e)=>J3e(n,e,"glsl"),Xht=(n,e)=>J3e(n,e,"wgsl");function iY(n){let e;const t=n.context.getViewZ;return t!==void 0&&(e=t(this)),(e||gl.z).negate()}const ewe=Pt(([n,e],t)=>{const r=iY(t);return hf(n,e,r)}),twe=Pt(([n],e)=>{const t=iY(e);return n.mul(n,t,t).negate().exp().oneMinus()}),Yht=Pt(([n,e],t)=>{const r=iY(t),s=e.sub(cm.y).max(0).toConst().mul(r).toConst();return n.mul(n,s,s).negate().exp().oneMinus()}),dq=Pt(([n,e])=>er(e.toFloat().mix(T_.rgb,n.toVec3()),T_.a));let $2=null,W2=null;class Zht extends mr{static get type(){return"RangeNode"}constructor(e=Ze(),t=Ze()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),i=e.getTypeLength(uA(t.value)),s=e.getTypeLength(uA(r.value));return i>s?i:s}generateNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(r=>{r.isConstNode===!0&&(t=r)}),t===null)throw new Fbe('THREE.TSL: No "ConstNode" found in node graph.',this.stackTrace);return t}setup(e){const t=e.object;let r=null;if(t.count>1){const i=this.getConstNode(this.minNode),s=this.getConstNode(this.maxNode),a=i.value,o=s.value,l=e.getTypeLength(uA(a)),c=e.getTypeLength(uA(o));$2=$2||new gr,W2=W2||new gr,$2.setScalar(0),W2.setScalar(0),l===1?$2.setScalar(a):a.isColor?$2.set(a.r,a.g,a.b,1):$2.set(a.x,a.y,a.z||0,a.w||0),c===1?W2.setScalar(o):o.isColor?W2.set(o.r,o.g,o.b,1):W2.set(o.x,o.y,o.z||0,o.w||0);const u=4,d=u*t.count,h=new Float32Array(d);for(let x=0;xnew Kht(n,e),Jht=y6("numWorkgroups","uvec3"),eft=y6("workgroupId","uvec3"),tft=y6("globalId","uvec3"),nft=y6("localId","uvec3"),rft=y6("subgroupSize","uint");class ift extends mr{constructor(e){super(),this.scope=e,this.isBarrierNode=!0}setup(e){e.allowEarlyReturns=!1,e.allowGlobalVariables=!1}generate(e){const{scope:t}=this,{renderer:r}=e;r.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier `):e.addLineFlowCode(`${t}Barrier()`,this)}}const sY=Ti(ift),sft=()=>sY("workgroup").toStack(),aft=()=>sY("storage").toStack(),oft=()=>sY("texture").toStack();class lft extends ay{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const i=e.isContextAssign();if(r=super.generate(e),i!==!0){const s=this.getNodeType(e);r=e.format(r,s,t)}return r}}class cft extends mr{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return sn('TSL: "label()" has been deprecated. Use "setName()" instead.',new Ol),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return new lft(this,e)}generate(e){const t=this.name!==""?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const uft=(n,e)=>new cft("Workgroup",n,e);class vc extends mr{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}generateNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,i=this.method,s=this.getNodeType(e),a=this.getInputType(e),o=this.pointerNode,l=this.valueNode,c=[];c.push(`&${o.build(e,a)}`),l!==null&&c.push(l.build(e,a));const u=`${e.getMethod(i,s)}( ${c.join(", ")} )`;if(r?r.length===1&&r[0].isStackNode===!0:!1)e.addLineFlowCode(u,this);else return t.constNode===void 0&&(t.constNode=Yh(u,s).toConst()),t.constNode.build(e)}}vc.ATOMIC_LOAD="atomicLoad";vc.ATOMIC_STORE="atomicStore";vc.ATOMIC_ADD="atomicAdd";vc.ATOMIC_SUB="atomicSub";vc.ATOMIC_MAX="atomicMax";vc.ATOMIC_MIN="atomicMin";vc.ATOMIC_AND="atomicAnd";vc.ATOMIC_OR="atomicOr";vc.ATOMIC_XOR="atomicXor";const dft=Ti(vc),Cm=(n,e,t)=>dft(n,e,t).toStack(),hft=n=>Cm(vc.ATOMIC_LOAD,n,null),fft=(n,e)=>Cm(vc.ATOMIC_STORE,n,e),pft=(n,e)=>Cm(vc.ATOMIC_ADD,n,e),mft=(n,e)=>Cm(vc.ATOMIC_SUB,n,e),gft=(n,e)=>Cm(vc.ATOMIC_MAX,n,e),Aft=(n,e)=>Cm(vc.ATOMIC_MIN,n,e),xft=(n,e)=>Cm(vc.ATOMIC_AND,n,e),vft=(n,e)=>Cm(vc.ATOMIC_OR,n,e),yft=(n,e)=>Cm(vc.ATOMIC_XOR,n,e);class $n extends $o{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null,i=e.isMatrix(t)?0:e.getTypeLength(t),s=e.isMatrix(r)?0:e.getTypeLength(r);return i>s?t:r}generateNodeType(e){const t=this.method;return t===$n.SUBGROUP_ELECT?"bool":t===$n.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,i=this.getNodeType(e),s=this.getInputType(e),a=this.aNode,o=this.bNode,l=[];if(r===$n.SUBGROUP_BROADCAST||r===$n.SUBGROUP_SHUFFLE||r===$n.QUAD_BROADCAST){const u=o.getNodeType(e);l.push(a.build(e,i),o.build(e,u==="float"?"int":i))}else r===$n.SUBGROUP_SHUFFLE_XOR||r===$n.SUBGROUP_SHUFFLE_DOWN||r===$n.SUBGROUP_SHUFFLE_UP?l.push(a.build(e,i),o.build(e,"uint")):(a!==null&&l.push(a.build(e,s)),o!==null&&l.push(o.build(e,s)));const c=l.length===0?"()":`( ${l.join(", ")} )`;return e.format(`${e.getMethod(r,i)}${c}`,i,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}$n.SUBGROUP_ELECT="subgroupElect";$n.SUBGROUP_BALLOT="subgroupBallot";$n.SUBGROUP_ADD="subgroupAdd";$n.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd";$n.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd";$n.SUBGROUP_MUL="subgroupMul";$n.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul";$n.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul";$n.SUBGROUP_AND="subgroupAnd";$n.SUBGROUP_OR="subgroupOr";$n.SUBGROUP_XOR="subgroupXor";$n.SUBGROUP_MIN="subgroupMin";$n.SUBGROUP_MAX="subgroupMax";$n.SUBGROUP_ALL="subgroupAll";$n.SUBGROUP_ANY="subgroupAny";$n.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst";$n.QUAD_SWAP_X="quadSwapX";$n.QUAD_SWAP_Y="quadSwapY";$n.QUAD_SWAP_DIAGONAL="quadSwapDiagonal";$n.SUBGROUP_BROADCAST="subgroupBroadcast";$n.SUBGROUP_SHUFFLE="subgroupShuffle";$n.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor";$n.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp";$n.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown";$n.QUAD_BROADCAST="quadBroadcast";const bft=Nn($n,$n.SUBGROUP_ELECT).setParameterLength(0),_ft=Nn($n,$n.SUBGROUP_BALLOT).setParameterLength(1),wft=Nn($n,$n.SUBGROUP_ADD).setParameterLength(1),Sft=Nn($n,$n.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),Tft=Nn($n,$n.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),Eft=Nn($n,$n.SUBGROUP_MUL).setParameterLength(1),Nft=Nn($n,$n.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),Mft=Nn($n,$n.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),Cft=Nn($n,$n.SUBGROUP_AND).setParameterLength(1),Pft=Nn($n,$n.SUBGROUP_OR).setParameterLength(1),Rft=Nn($n,$n.SUBGROUP_XOR).setParameterLength(1),Lft=Nn($n,$n.SUBGROUP_MIN).setParameterLength(1),kft=Nn($n,$n.SUBGROUP_MAX).setParameterLength(1),Ift=Nn($n,$n.SUBGROUP_ALL).setParameterLength(0),Dft=Nn($n,$n.SUBGROUP_ANY).setParameterLength(0),Oft=Nn($n,$n.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),jft=Nn($n,$n.QUAD_SWAP_X).setParameterLength(1),Fft=Nn($n,$n.QUAD_SWAP_Y).setParameterLength(1),Bft=Nn($n,$n.QUAD_SWAP_DIAGONAL).setParameterLength(1),Uft=Nn($n,$n.SUBGROUP_BROADCAST).setParameterLength(2),zft=Nn($n,$n.SUBGROUP_SHUFFLE).setParameterLength(2),Vft=Nn($n,$n.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),qft=Nn($n,$n.SUBGROUP_SHUFFLE_UP).setParameterLength(2),Gft=Nn($n,$n.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),Hft=Nn($n,$n.QUAD_BROADCAST).setParameterLength(1);let Q8;function GR(n){Q8=Q8||new WeakMap;let e=Q8.get(n);return e===void 0&&Q8.set(n,e={}),e}function HR(n){const e=GR(n);return e.shadowMatrix||(e.shadowMatrix=hr("mat4").setGroup(yr).onRenderUpdate(t=>((n.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(n.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(n.shadow.camera.coordinateSystem=t.camera.coordinateSystem,n.shadow.camera.updateProjectionMatrix()),n.shadow.updateMatrices(n)),n.shadow.matrix)))}function nwe(n,e=cm){const t=HR(n).mul(e);return t.xyz.div(t.w)}function aY(n){const e=GR(n);return e.position||(e.position=hr(new Fe).setGroup(yr).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(n.matrixWorld)))}function rwe(n){const e=GR(n);return e.targetPosition||(e.targetPosition=hr(new Fe).setGroup(yr).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(n.target.matrixWorld)))}function oY(n){const e=GR(n);return e.viewPosition||(e.viewPosition=hr(new Fe).setGroup(yr).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new Fe,r.value.setFromMatrixPosition(n.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}const lY=n=>l2.transformDirection(aY(n).sub(rwe(n))),$ft=i1("vec3","totalDiffuse"),Wft=i1("vec3","totalSpecular"),Xft=i1("vec3","outgoingLight"),Yft=n=>n.sort((e,t)=>e.id-t.id),Zft=(n,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===n)return t;return null},JF=new WeakMap,Qw=[];class cY extends mr{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=$ft,this.totalSpecularNode=Wft,this.outgoingLightNode=Xft,this._lights=[],this.global=!0}customCacheKey(){const e=this._lights;for(let r=0;r0}}const Qft=(n=[])=>new cY().setLights(n);class Kft extends mr{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Or.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){uY.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||cm)}}const uY=i1("vec3","shadowPositionWorld");function Jft(n,e={}){return e.toneMapping=n.toneMapping,e.toneMappingExposure=n.toneMappingExposure,e.outputColorSpace=n.outputColorSpace,e.renderTarget=n.getRenderTarget(),e.activeCubeFace=n.getActiveCubeFace(),e.activeMipmapLevel=n.getActiveMipmapLevel(),e.renderObjectFunction=n.getRenderObjectFunction(),e.pixelRatio=n.getPixelRatio(),e.mrt=n.getMRT(),e.clearColor=n.getClearColor(e.clearColor||new Fn),e.clearAlpha=n.getClearAlpha(),e.autoClear=n.autoClear,e.scissorTest=n.getScissorTest(),e}function e0t(n,e){return e=Jft(n,e),n.setMRT(null),n.setRenderObjectFunction(null),n.setClearColor(0,1),n.autoClear=!0,e}function t0t(n,e){n.toneMapping=e.toneMapping,n.toneMappingExposure=e.toneMappingExposure,n.outputColorSpace=e.outputColorSpace,n.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),n.setRenderObjectFunction(e.renderObjectFunction),n.setPixelRatio(e.pixelRatio),n.setMRT(e.mrt),n.setClearColor(e.clearColor,e.clearAlpha),n.autoClear=e.autoClear,n.setScissorTest(e.scissorTest)}function n0t(n,e={}){return e.background=n.background,e.backgroundNode=n.backgroundNode,e.overrideMaterial=n.overrideMaterial,e}function r0t(n,e){return e=n0t(n,e),n.background=null,n.backgroundNode=null,n.overrideMaterial=null,e}function i0t(n,e){n.background=e.background,n.backgroundNode=e.backgroundNode,n.overrideMaterial=e.overrideMaterial}function s0t(n,e,t){return t=e0t(n,t),t=r0t(e,t),t}function a0t(n,e,t){t0t(n,t),i0t(e,t)}const $C=new WeakMap,iwe=Pt(({depthTexture:n,shadowCoord:e,depthLayer:t})=>{let r=as(n,e.xy).setName("t_basic");return n.isArrayTexture&&(r=r.depth(t)),r.compare(e.z)}),swe=Pt(({depthTexture:n,shadowCoord:e,shadow:t,depthLayer:r})=>{const i=(u,d)=>{let h=as(n,u);return n.isArrayTexture&&(h=h.depth(r)),h.compare(d)},s=ka("mapSize","vec2",t).setGroup(yr),a=ka("radius","float",t).setGroup(yr),o=jn(1).div(s),l=a.mul(o.x),c=tY(cy.xy).mul(6.28318530718);return jl(i(e.xy.add(k0(0,5,c).mul(l)),e.z),i(e.xy.add(k0(1,5,c).mul(l)),e.z),i(e.xy.add(k0(2,5,c).mul(l)),e.z),i(e.xy.add(k0(3,5,c).mul(l)),e.z),i(e.xy.add(k0(4,5,c).mul(l)),e.z)).mul(1/5)}),awe=Pt(({depthTexture:n,shadowCoord:e,shadow:t,depthLayer:r})=>{const i=ka("mapSize","vec2",t).setGroup(yr),s=jn(1).div(i),a=e.xy,o=J0(a.mul(i).add(.5)).toConst();a.subAssign(o.sub(.5).mul(s));const l=p=>{let g=as(n,a).offset(p).gather();return n.isArrayTexture&&(g=g.depth(r)),g.compare(e.z)},c=l(bo(-1,1)).toConst(),u=l(bo(1,1)).toConst(),d=l(bo(-1,-1)).toConst(),h=l(bo(1,-1)).toConst();return jl(ki(c.x,u.y,o.x).add(c.y).add(u.x).mul(o.y),ki(c.w,u.z,o.x).add(c.z).add(u.w),ki(d.x,h.y,o.x).add(d.y).add(h.x),ki(d.w,h.z,o.x).add(d.z).add(h.w).mul(o.y.oneMinus())).mul(1/9)}),owe=Pt(({depthTexture:n,shadowCoord:e,depthLayer:t},r)=>{let i=as(n).sample(e.xy);n.isArrayTexture&&(i=i.depth(t)),i=i.rg;const s=i.x,a=Eo(1e-7,i.y.mul(i.y)),o=r.renderer.reversedDepthBuffer?jv(s,e.z):jv(e.z,s),l=Ze(1).toVar();return pr(o.notEqual(1),()=>{const c=e.z.sub(s);let u=a.div(a.add(c.mul(c)));u=ep(Qi(u,.3).div(.65)),l.assign(Eo(o,u))}),l}),lwe=n=>{let e=$C.get(n);return e===void 0&&(e=new Ho,e.colorNode=er(0,0,0,1),e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.blending=Yl,e.fog=!1,$C.set(n,e)),e},cwe=n=>{const e=$C.get(n);e!==void 0&&(e.dispose(),$C.delete(n))},Uce=new WA,cb=[],uwe=(n,e,t,r)=>{cb[0]=n,cb[1]=e;let i=Uce.get(cb);return(i===void 0||i.shadowType!==t||i.useVelocity!==r)&&(i=(s,a,o,l,c,u,d,h,p)=>{(s.castShadow===!0||s.receiveShadow&&t===Vf)&&(r&&(Qve(s).useVelocity=!0),s.onBeforeShadow(n,s,o,e.camera,l,a.overrideMaterial,u),n.renderObject(s,a,o,l,c,u,d,h,p),s.onAfterShadow(n,s,o,e.camera,l,a.overrideMaterial,u))},i.shadowType=t,i.useVelocity=r,Uce.set(cb,i)),cb[0]=null,cb[1]=null,i},o0t=Pt(({samples:n,radius:e,size:t,shadowPass:r,depthLayer:i})=>{const s=Ze(0).toVar("meanVertical"),a=Ze(0).toVar("squareMeanVertical"),o=n.lessThanEqual(Ze(1)).select(Ze(0),Ze(2).div(n.sub(1))),l=n.lessThanEqual(Ze(1)).select(Ze(0),Ze(-1));ta({start:Tt(0),end:Tt(n),type:"int",condition:"<"},({i:u})=>{const d=l.add(Ze(u).mul(o));let h=r.sample(jl(cy.xy,jn(0,d).mul(e)).div(t));r.value.isArrayTexture&&(h=h.depth(i)),h=h.x,s.addAssign(h),a.addAssign(h.mul(h))}),s.divAssign(n),a.divAssign(n);const c=Fd(a.sub(s.mul(s)).max(0));return jn(s,c)}),l0t=Pt(({samples:n,radius:e,size:t,shadowPass:r,depthLayer:i})=>{const s=Ze(0).toVar("meanHorizontal"),a=Ze(0).toVar("squareMeanHorizontal"),o=n.lessThanEqual(Ze(1)).select(Ze(0),Ze(2).div(n.sub(1))),l=n.lessThanEqual(Ze(1)).select(Ze(0),Ze(-1));ta({start:Tt(0),end:Tt(n),type:"int",condition:"<"},({i:u})=>{const d=l.add(Ze(u).mul(o));let h=r.sample(jl(cy.xy,jn(d,0).mul(e)).div(t));r.value.isArrayTexture&&(h=h.depth(i)),s.addAssign(h.x),a.addAssign(jl(h.y.mul(h.y),h.x.mul(h.x)))}),s.divAssign(n),a.divAssign(n);const c=Fd(a.sub(s.mul(s)).max(0));return jn(s,c)}),c0t=[iwe,swe,awe,owe];let eB;const K8=new eY;class dwe extends Kft{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:i,shadow:s,depthLayer:a}){const o=i.x.greaterThanEqual(0).and(i.x.lessThanEqual(1)).and(i.y.greaterThanEqual(0)).and(i.y.lessThanEqual(1)).and(i.z.lessThanEqual(1)),l=t({depthTexture:r,shadowCoord:i,shadow:s,depthLayer:a});return o.select(l,Ze(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:i}=e,s=r.biasNode||ka("bias","float",r).setGroup(yr);let a=t,o;if(r.camera.isOrthographicCamera||i.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),o=a.z;else{const l=a.w;a=a.xy.div(l);const c=ka("near","float",r.camera).setGroup(yr),u=ka("far","float",r.camera).setGroup(yr);o=FR(l.negate(),c,u)}return a=Ct(a.x,a.y.oneMinus(),i.reversedDepthBuffer?o.sub(s):o.add(s)),a}getShadowFilterFn(e){return c0t[e]}setupRenderTarget(e,t){const r=new zc(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?mm:n1;const i=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return i.texture.name="ShadowMap",i.texture.type=e.mapType,i.depthTexture=r,{shadowMap:i,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:i,shadow:s}=this,{depthTexture:a,shadowMap:o}=this.setupRenderTarget(s,e),l=t.shadowMap.type,c=t.hasCompatibility(n2.TEXTURE_COMPARE);if((l===EA||l===y_)&&c?(a.minFilter=Ci,a.magFilter=Ci):(a.minFilter=Ss,a.magFilter=Ss),s.camera.coordinateSystem=r.coordinateSystem,s.camera.updateProjectionMatrix(),l===Vf&&s.isPointLightShadow!==!0){a.compareFunction=null,o.depth>1?(o._vsmShadowMapVertical||(o._vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:dc,type:ba,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=o._vsmShadowMapVertical,o._vsmShadowMapHorizontal||(o._vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:dc,type:ba,depth:o.depth,depthBuffer:!1}),o._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=o._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:dc,type:ba,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(s.mapSize.width,s.mapSize.height,{format:dc,type:ba,depthBuffer:!1}));let U=as(a);a.isArrayTexture&&(U=U.depth(this.depthLayer));let z=as(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(z=z.depth(this.depthLayer));const O=ka("blurSamples","float",s).setGroup(yr),V=ka("radius","float",s).setGroup(yr),$=ka("mapSize","vec2",s).setGroup(yr);let G=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Ho);G.fragmentNode=o0t({samples:O,radius:V,size:$,shadowPass:U,depthLayer:this.depthLayer}).context(e.getSharedContext()),G.name="VSMVertical",G=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Ho),G.fragmentNode=l0t({samples:O,radius:V,size:$,shadowPass:z,depthLayer:this.depthLayer}).context(e.getSharedContext()),G.name="VSMHorizontal"}const u=ka("intensity","float",s).setGroup(yr),d=ka("normalBias","float",s).setGroup(yr),h=HR(i),p=c2.mul(d);let g;!t.highPrecision||e.material.receivedShadowPositionNode||e.context.shadowPositionWorld?g=h.mul(uY.add(p)):g=hr("mat4").onObjectUpdate(({object:z},O)=>O.value.multiplyMatrices(h.value,z.matrixWorld)).mul(oo).add(h.mul(er(p,0)));const x=this.setupShadowCoord(e,g),_=s.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(_===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const y=l===Vf&&s.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,M=this.setupShadowFilter(e,{filterFn:_,shadowTexture:o.texture,depthTexture:y,shadowCoord:x,shadow:s,depthLayer:this.depthLayer});let C;t.shadowMap.transmitted===!0&&(o.texture.isCubeTexture?C=kd(o.texture,x.xyz):(C=as(o.texture,x),a.isArrayTexture&&(C=C.depth(this.depthLayer))));let k;C?k=ki(1,M.rgb.mix(C,1),u.mul(C.a)).toVar():k=ki(1,M,u).toVar(),this.shadowMap=o,this.shadow.map=o;const B=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return C&&k.toInspector(`${B} / Color`,()=>this.shadowMap.texture.isCubeTexture?kd(this.shadowMap.texture,iq()):as(this.shadowMap.texture)),k.toInspector(`${B} / Depth`,()=>{const U=ka("near","float",this.shadow.camera),z=ka("far","float",this.shadow.camera);let O;this.shadowMap.texture.isCubeTexture?O=kd(this.shadowMap.depthTexture,iq()).r:O=as(this.shadowMap.depthTexture).r;let V;return this.shadow.camera.isPerspectiveCamera?V=jR(O,U,z):V=J_e(O,U,z),V=qx(V,U,z),V.oneMinus()})}setup(e){if(e.renderer.shadowMap.enabled!==!1)return Pt(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),r===null&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:i}=this,{renderer:s,scene:a}=e;t.updateMatrices(i),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const o=a.name;a.name=`Shadow Map [ ${i.name||"ID: "+i.id} ]`,s.render(a,t.camera),a.name=o}updateShadow(e){const{shadowMap:t,light:r,shadow:i}=this,{renderer:s,scene:a,camera:o}=e,l=s.shadowMap.type,c=t.depthTexture.version;this._depthVersionCached=c;const u=i.camera.layers.mask;i.camera.layers.mask&4294967294||(i.camera.layers.mask=o.layers.mask);const d=s.getRenderObjectFunction(),h=s.getMRT(),p=h?h.has("velocity"):!1;eB=s0t(s,a,eB),a.overrideMaterial=lwe(r),s.setRenderObjectFunction(uwe(s,i,l,p)),s.setClearColor(0,0),s.setRenderTarget(t),this.renderShadow(e),s.setRenderObjectFunction(d),l===Vf&&i.isPointLightShadow!==!0&&this.vsmPass(s),i.camera.layers.mask=u,a0t(s,a,eB)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),K8.material=this.vsmMaterialVertical,K8.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),K8.material=this.vsmMaterialHorizontal,K8.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,cwe(this.light),this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const hwe=(n,e)=>new dwe(n,e),u0t=new Fn,zce=new ir,Kw=new Fe,tB=new Fe,d0t=[new Fe(1,0,0),new Fe(-1,0,0),new Fe(0,-1,0),new Fe(0,1,0),new Fe(0,0,1),new Fe(0,0,-1)],h0t=[new Fe(0,-1,0),new Fe(0,-1,0),new Fe(0,0,-1),new Fe(0,0,1),new Fe(0,-1,0),new Fe(0,-1,0)],f0t=[new Fe(1,0,0),new Fe(-1,0,0),new Fe(0,1,0),new Fe(0,-1,0),new Fe(0,0,1),new Fe(0,0,-1)],p0t=[new Fe(0,-1,0),new Fe(0,-1,0),new Fe(0,0,1),new Fe(0,0,-1),new Fe(0,-1,0),new Fe(0,-1,0)],fwe=Pt(({depthTexture:n,bd3D:e,dp:t})=>kd(n,e).compare(t)),pwe=Pt(({depthTexture:n,bd3D:e,dp:t,shadow:r})=>{const i=ka("radius","float",r).setGroup(yr),s=ka("mapSize","vec2",r).setGroup(yr),a=i.div(s.x),o=ya(e),l=sd(Zg(e,o.x.greaterThan(o.z).select(Ct(0,1,0),Ct(1,0,0)))),c=Zg(e,l),u=tY(cy.xy).mul(6.28318530718),d=k0(0,5,u),h=k0(1,5,u),p=k0(2,5,u),g=k0(3,5,u),x=k0(4,5,u);return kd(n,e.add(l.mul(d.x).add(c.mul(d.y)).mul(a))).compare(t).add(kd(n,e.add(l.mul(h.x).add(c.mul(h.y)).mul(a))).compare(t)).add(kd(n,e.add(l.mul(p.x).add(c.mul(p.y)).mul(a))).compare(t)).add(kd(n,e.add(l.mul(g.x).add(c.mul(g.y)).mul(a))).compare(t)).add(kd(n,e.add(l.mul(x.x).add(c.mul(x.y)).mul(a))).compare(t)).mul(1/5)}),m0t=Pt(({filterFn:n,depthTexture:e,shadowCoord:t,shadow:r},i)=>{const s=t.xyz.toConst(),a=s.abs().toConst(),o=a.x.max(a.y).max(a.z),l=hr("float").setGroup(yr).onRenderUpdate(()=>r.camera.near),c=hr("float").setGroup(yr).onRenderUpdate(()=>r.camera.far),u=ka("bias","float",r).setGroup(yr),d=Ze(1).toVar();return pr(o.sub(c).lessThanEqual(0).and(o.sub(l).greaterThanEqual(0)),()=>{let h;i.renderer.reversedDepthBuffer?(h=e3e(o.negate(),l,c),h.subAssign(u)):i.renderer.logarithmicDepthBuffer?(h=FR(o.negate(),l,c),h.addAssign(u)):(h=VX(o.negate(),l,c),h.addAssign(u));const p=s.normalize();d.assign(n({depthTexture:e,bd3D:p,dp:h,shadow:r}))}),d});class g0t extends dwe{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===A$?fwe:pwe}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:i,shadow:s}){return m0t({filterFn:t,depthTexture:r,shadowCoord:i,shadow:s})}setupRenderTarget(e,t){const r=new L$(e.mapSize.width);r.name="PointShadowDepthTexture",r.compareFunction=t.renderer.reversedDepthBuffer?mm:n1;const i=t.createCubeRenderTarget(e.mapSize.width);return i.texture.name="PointShadowMap",i.depthTexture=r,{shadowMap:i,depthTexture:r}}renderShadow(e){const{shadow:t,shadowMap:r,light:i}=this,{renderer:s,scene:a}=e,o=t.camera,l=t.matrix,c=s.coordinateSystem===mh,u=c?d0t:f0t,d=c?h0t:p0t;r.setSize(t.mapSize.width,t.mapSize.width);const h=s.autoClear,p=s.getClearColor(u0t),g=s.getClearAlpha();s.autoClear=!1,s.setClearColor(t.clearColor,t.clearAlpha);for(let x=0;x<6;x++){s.setRenderTarget(r,x),s.clear();const _=i.distance||o.far;_!==o.far&&(o.far=_,o.updateProjectionMatrix()),Kw.setFromMatrixPosition(i.matrixWorld),o.position.copy(Kw),tB.copy(o.position),tB.add(u[x]),o.up.copy(d[x]),o.lookAt(tB),o.updateMatrixWorld(),l.makeTranslation(-Kw.x,-Kw.y,-Kw.z),zce.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),t._frustum.setFromProjectionMatrix(zce,o.coordinateSystem,o.reversedDepth);const y=a.name;a.name=`Point Light Shadow [ ${i.name||"ID: "+i.id} ] - Face ${x+1}`,s.render(a,o),a.name=y}s.autoClear=h,s.setClearColor(p,g)}}const mwe=(n,e)=>new g0t(n,e);class dy extends W3{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new Fn,this.colorNode=e&&e.colorNode||hr(this.color).setGroup(yr),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Or.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return oY(this.light).sub(e.context.positionView||gl)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return hwe(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){const i=this.light.shadow.shadowNode;let s;i!==void 0?s=or(i):s=this.setupShadowNode(),this.shadowNode=s,this.shadowColorNode=r=this.colorNode.mul(s),this.baseColorNode=this.colorNode}e.context.getShadow&&(r=e.context.getShadow(this,e)),this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const dY=Pt(({lightDistance:n,cutoffDistance:e,decayExponent:t})=>{const r=n.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(r.mul(n.div(e).pow4().oneMinus().clamp().pow2()),r)}),gwe=({color:n,lightVector:e,cutoffDistance:t,decayExponent:r})=>{const i=e.normalize(),s=e.length(),a=dY({lightDistance:s,cutoffDistance:t,decayExponent:r}),o=n.mul(a);return{lightDirection:i,lightColor:o}};class A0t extends dy{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=hr(0).setGroup(yr),this.decayExponentNode=hr(2).setGroup(yr)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return mwe(this.light)}setupDirect(e){return gwe({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const x0t=Pt(([n=na()])=>{const e=n.mul(2),t=e.x.floor(),r=e.y.floor();return t.add(r).mod(2).sign()}),v0t=Pt(([n=na()],{renderer:e,material:t})=>{const r=sX(n.mul(2).sub(1));let i;if(t.alphaToCoverage&&e.currentSamples>0){const s=Ze(r.fwidth()).toVar();i=hf(s.oneMinus(),s.add(1),r).oneMinus()}else i=rd(r.greaterThan(1),0,1);return i}),v4=Pt(([n,e,t])=>{const r=Ze(t).toVar(),i=Ze(e).toVar(),s=uf(n).toVar();return rd(s,i,r).uniformFlow()}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),WC=Pt(([n,e])=>{const t=uf(e).toVar(),r=Ze(n).toVar();return rd(t,r.negate(),r).uniformFlow()}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Il=Pt(([n])=>{const e=Ze(n).toVar();return Tt(om(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),ho=Pt(([n,e])=>{const t=Ze(n).toVar();return e.assign(Il(t)),t.sub(Ze(e))}),y0t=Pt(([n,e,t,r,i,s])=>{const a=Ze(s).toVar(),o=Ze(i).toVar(),l=Ze(r).toVar(),c=Ze(t).toVar(),u=Ze(e).toVar(),d=Ze(n).toVar(),h=Ze(Qi(1,o)).toVar();return Qi(1,a).mul(d.mul(h).add(u.mul(o))).add(a.mul(c.mul(h).add(l.mul(o))))}).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),b0t=Pt(([n,e,t,r,i,s])=>{const a=Ze(s).toVar(),o=Ze(i).toVar(),l=Ct(r).toVar(),c=Ct(t).toVar(),u=Ct(e).toVar(),d=Ct(n).toVar(),h=Ze(Qi(1,o)).toVar();return Qi(1,a).mul(d.mul(h).add(u.mul(o))).add(a.mul(c.mul(h).add(l.mul(o))))}).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]}),Awe=wu([y0t,b0t]),_0t=Pt(([n,e,t,r,i,s,a,o,l,c,u])=>{const d=Ze(u).toVar(),h=Ze(c).toVar(),p=Ze(l).toVar(),g=Ze(o).toVar(),x=Ze(a).toVar(),_=Ze(s).toVar(),y=Ze(i).toVar(),M=Ze(r).toVar(),C=Ze(t).toVar(),k=Ze(e).toVar(),B=Ze(n).toVar(),U=Ze(Qi(1,p)).toVar(),z=Ze(Qi(1,h)).toVar();return Ze(Qi(1,d)).toVar().mul(z.mul(B.mul(U).add(k.mul(p))).add(h.mul(C.mul(U).add(M.mul(p))))).add(d.mul(z.mul(y.mul(U).add(_.mul(p))).add(h.mul(x.mul(U).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),w0t=Pt(([n,e,t,r,i,s,a,o,l,c,u])=>{const d=Ze(u).toVar(),h=Ze(c).toVar(),p=Ze(l).toVar(),g=Ct(o).toVar(),x=Ct(a).toVar(),_=Ct(s).toVar(),y=Ct(i).toVar(),M=Ct(r).toVar(),C=Ct(t).toVar(),k=Ct(e).toVar(),B=Ct(n).toVar(),U=Ze(Qi(1,p)).toVar(),z=Ze(Qi(1,h)).toVar();return Ze(Qi(1,d)).toVar().mul(z.mul(B.mul(U).add(k.mul(p))).add(h.mul(C.mul(U).add(M.mul(p))))).add(d.mul(z.mul(y.mul(U).add(_.mul(p))).add(h.mul(x.mul(U).add(g.mul(p))))))}).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),xwe=wu([_0t,w0t]),S0t=Pt(([n,e,t])=>{const r=Ze(t).toVar(),i=Ze(e).toVar(),s=bn(n).toVar(),a=bn(s.bitAnd(bn(7))).toVar(),o=Ze(v4(a.lessThan(bn(4)),i,r)).toVar(),l=Ze(Vr(2,v4(a.lessThan(bn(4)),r,i))).toVar();return WC(o,uf(a.bitAnd(bn(1)))).add(WC(l,uf(a.bitAnd(bn(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),T0t=Pt(([n,e,t,r])=>{const i=Ze(r).toVar(),s=Ze(t).toVar(),a=Ze(e).toVar(),o=bn(n).toVar(),l=bn(o.bitAnd(bn(15))).toVar(),c=Ze(v4(l.lessThan(bn(8)),a,s)).toVar(),u=Ze(v4(l.lessThan(bn(4)),s,v4(l.equal(bn(12)).or(l.equal(bn(14))),a,i))).toVar();return WC(c,uf(l.bitAnd(bn(1)))).add(WC(u,uf(l.bitAnd(bn(2)))))}).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),jc=wu([S0t,T0t]),E0t=Pt(([n,e,t])=>{const r=Ze(t).toVar(),i=Ze(e).toVar(),s=oy(n).toVar();return Ct(jc(s.x,i,r),jc(s.y,i,r),jc(s.z,i,r))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),N0t=Pt(([n,e,t,r])=>{const i=Ze(r).toVar(),s=Ze(t).toVar(),a=Ze(e).toVar(),o=oy(n).toVar();return Ct(jc(o.x,a,s,i),jc(o.y,a,s,i),jc(o.z,a,s,i))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),kf=wu([E0t,N0t]),M0t=Pt(([n])=>{const e=Ze(n).toVar();return Vr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),C0t=Pt(([n])=>{const e=Ze(n).toVar();return Vr(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),P0t=Pt(([n])=>{const e=Ct(n).toVar();return Vr(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),vwe=wu([M0t,P0t]),R0t=Pt(([n])=>{const e=Ct(n).toVar();return Vr(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]}),ywe=wu([C0t,R0t]),Hh=Pt(([n,e])=>{const t=Tt(e).toVar(),r=bn(n).toVar();return r.shiftLeft(t).bitOr(r.shiftRight(Tt(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),bwe=Pt(([n,e,t])=>{n.subAssign(t),n.bitXorAssign(Hh(t,Tt(4))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Hh(n,Tt(6))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Hh(e,Tt(8))),e.addAssign(n),n.subAssign(t),n.bitXorAssign(Hh(t,Tt(16))),t.addAssign(e),e.subAssign(n),e.bitXorAssign(Hh(n,Tt(19))),n.addAssign(t),t.subAssign(e),t.bitXorAssign(Hh(e,Tt(4))),e.addAssign(n)}),b6=Pt(([n,e,t])=>{const r=bn(t).toVar(),i=bn(e).toVar(),s=bn(n).toVar();return r.bitXorAssign(i),r.subAssign(Hh(i,Tt(14))),s.bitXorAssign(r),s.subAssign(Hh(r,Tt(11))),i.bitXorAssign(s),i.subAssign(Hh(s,Tt(25))),r.bitXorAssign(i),r.subAssign(Hh(i,Tt(16))),s.bitXorAssign(r),s.subAssign(Hh(r,Tt(4))),i.bitXorAssign(s),i.subAssign(Hh(s,Tt(14))),r.bitXorAssign(i),r.subAssign(Hh(i,Tt(24))),r}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),ad=Pt(([n])=>{const e=bn(n).toVar();return Ze(e).div(Ze(bn(Tt(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),um=Pt(([n])=>{const e=Ze(n).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),L0t=Pt(([n])=>{const e=Tt(n).toVar(),t=bn(bn(1)).toVar(),r=bn(bn(Tt(3735928559)).add(t.shiftLeft(bn(2))).add(bn(13))).toVar();return b6(r.add(bn(e)),r,r)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),k0t=Pt(([n,e])=>{const t=Tt(e).toVar(),r=Tt(n).toVar(),i=bn(bn(2)).toVar(),s=bn().toVar(),a=bn().toVar(),o=bn().toVar();return s.assign(a.assign(o.assign(bn(Tt(3735928559)).add(i.shiftLeft(bn(2))).add(bn(13))))),s.addAssign(bn(r)),a.addAssign(bn(t)),b6(s,a,o)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),I0t=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Tt(e).toVar(),s=Tt(n).toVar(),a=bn(bn(3)).toVar(),o=bn().toVar(),l=bn().toVar(),c=bn().toVar();return o.assign(l.assign(c.assign(bn(Tt(3735928559)).add(a.shiftLeft(bn(2))).add(bn(13))))),o.addAssign(bn(s)),l.addAssign(bn(i)),c.addAssign(bn(r)),b6(o,l,c)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),D0t=Pt(([n,e,t,r])=>{const i=Tt(r).toVar(),s=Tt(t).toVar(),a=Tt(e).toVar(),o=Tt(n).toVar(),l=bn(bn(4)).toVar(),c=bn().toVar(),u=bn().toVar(),d=bn().toVar();return c.assign(u.assign(d.assign(bn(Tt(3735928559)).add(l.shiftLeft(bn(2))).add(bn(13))))),c.addAssign(bn(o)),u.addAssign(bn(a)),d.addAssign(bn(s)),bwe(c,u,d),c.addAssign(bn(i)),b6(c,u,d)}).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),O0t=Pt(([n,e,t,r,i])=>{const s=Tt(i).toVar(),a=Tt(r).toVar(),o=Tt(t).toVar(),l=Tt(e).toVar(),c=Tt(n).toVar(),u=bn(bn(5)).toVar(),d=bn().toVar(),h=bn().toVar(),p=bn().toVar();return d.assign(h.assign(p.assign(bn(Tt(3735928559)).add(u.shiftLeft(bn(2))).add(bn(13))))),d.addAssign(bn(c)),h.addAssign(bn(l)),p.addAssign(bn(o)),bwe(d,h,p),d.addAssign(bn(a)),h.addAssign(bn(s)),b6(d,h,p)}).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]}),oa=wu([L0t,k0t,I0t,D0t,O0t]),j0t=Pt(([n,e])=>{const t=Tt(e).toVar(),r=Tt(n).toVar(),i=bn(oa(r,t)).toVar(),s=oy().toVar();return s.x.assign(i.bitAnd(Tt(255))),s.y.assign(i.shiftRight(Tt(8)).bitAnd(Tt(255))),s.z.assign(i.shiftRight(Tt(16)).bitAnd(Tt(255))),s}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),F0t=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Tt(e).toVar(),s=Tt(n).toVar(),a=bn(oa(s,i,r)).toVar(),o=oy().toVar();return o.x.assign(a.bitAnd(Tt(255))),o.y.assign(a.shiftRight(Tt(8)).bitAnd(Tt(255))),o.z.assign(a.shiftRight(Tt(16)).bitAnd(Tt(255))),o}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),If=wu([j0t,F0t]),B0t=Pt(([n])=>{const e=jn(n).toVar(),t=Tt().toVar(),r=Tt().toVar(),i=Ze(ho(e.x,t)).toVar(),s=Ze(ho(e.y,r)).toVar(),a=Ze(um(i)).toVar(),o=Ze(um(s)).toVar(),l=Ze(Awe(jc(oa(t,r),i,s),jc(oa(t.add(Tt(1)),r),i.sub(1),s),jc(oa(t,r.add(Tt(1))),i,s.sub(1)),jc(oa(t.add(Tt(1)),r.add(Tt(1))),i.sub(1),s.sub(1)),a,o)).toVar();return vwe(l)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),U0t=Pt(([n])=>{const e=Ct(n).toVar(),t=Tt().toVar(),r=Tt().toVar(),i=Tt().toVar(),s=Ze(ho(e.x,t)).toVar(),a=Ze(ho(e.y,r)).toVar(),o=Ze(ho(e.z,i)).toVar(),l=Ze(um(s)).toVar(),c=Ze(um(a)).toVar(),u=Ze(um(o)).toVar(),d=Ze(xwe(jc(oa(t,r,i),s,a,o),jc(oa(t.add(Tt(1)),r,i),s.sub(1),a,o),jc(oa(t,r.add(Tt(1)),i),s,a.sub(1),o),jc(oa(t.add(Tt(1)),r.add(Tt(1)),i),s.sub(1),a.sub(1),o),jc(oa(t,r,i.add(Tt(1))),s,a,o.sub(1)),jc(oa(t.add(Tt(1)),r,i.add(Tt(1))),s.sub(1),a,o.sub(1)),jc(oa(t,r.add(Tt(1)),i.add(Tt(1))),s,a.sub(1),o.sub(1)),jc(oa(t.add(Tt(1)),r.add(Tt(1)),i.add(Tt(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return ywe(d)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]}),hY=wu([B0t,U0t]),z0t=Pt(([n])=>{const e=jn(n).toVar(),t=Tt().toVar(),r=Tt().toVar(),i=Ze(ho(e.x,t)).toVar(),s=Ze(ho(e.y,r)).toVar(),a=Ze(um(i)).toVar(),o=Ze(um(s)).toVar(),l=Ct(Awe(kf(If(t,r),i,s),kf(If(t.add(Tt(1)),r),i.sub(1),s),kf(If(t,r.add(Tt(1))),i,s.sub(1)),kf(If(t.add(Tt(1)),r.add(Tt(1))),i.sub(1),s.sub(1)),a,o)).toVar();return vwe(l)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),V0t=Pt(([n])=>{const e=Ct(n).toVar(),t=Tt().toVar(),r=Tt().toVar(),i=Tt().toVar(),s=Ze(ho(e.x,t)).toVar(),a=Ze(ho(e.y,r)).toVar(),o=Ze(ho(e.z,i)).toVar(),l=Ze(um(s)).toVar(),c=Ze(um(a)).toVar(),u=Ze(um(o)).toVar(),d=Ct(xwe(kf(If(t,r,i),s,a,o),kf(If(t.add(Tt(1)),r,i),s.sub(1),a,o),kf(If(t,r.add(Tt(1)),i),s,a.sub(1),o),kf(If(t.add(Tt(1)),r.add(Tt(1)),i),s.sub(1),a.sub(1),o),kf(If(t,r,i.add(Tt(1))),s,a,o.sub(1)),kf(If(t.add(Tt(1)),r,i.add(Tt(1))),s.sub(1),a,o.sub(1)),kf(If(t,r.add(Tt(1)),i.add(Tt(1))),s,a.sub(1),o.sub(1)),kf(If(t.add(Tt(1)),r.add(Tt(1)),i.add(Tt(1))),s.sub(1),a.sub(1),o.sub(1)),l,c,u)).toVar();return ywe(d)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),_6=wu([z0t,V0t]),q0t=Pt(([n])=>{const e=Ze(n).toVar(),t=Tt(Il(e)).toVar();return ad(oa(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),G0t=Pt(([n])=>{const e=jn(n).toVar(),t=Tt(Il(e.x)).toVar(),r=Tt(Il(e.y)).toVar();return ad(oa(t,r))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),H0t=Pt(([n])=>{const e=Ct(n).toVar(),t=Tt(Il(e.x)).toVar(),r=Tt(Il(e.y)).toVar(),i=Tt(Il(e.z)).toVar();return ad(oa(t,r,i))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),$0t=Pt(([n])=>{const e=er(n).toVar(),t=Tt(Il(e.x)).toVar(),r=Tt(Il(e.y)).toVar(),i=Tt(Il(e.z)).toVar(),s=Tt(Il(e.w)).toVar();return ad(oa(t,r,i,s))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]}),W0t=wu([q0t,G0t,H0t,$0t]),X0t=Pt(([n])=>{const e=Ze(n).toVar(),t=Tt(Il(e)).toVar();return Ct(ad(oa(t,Tt(0))),ad(oa(t,Tt(1))),ad(oa(t,Tt(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),Y0t=Pt(([n])=>{const e=jn(n).toVar(),t=Tt(Il(e.x)).toVar(),r=Tt(Il(e.y)).toVar();return Ct(ad(oa(t,r,Tt(0))),ad(oa(t,r,Tt(1))),ad(oa(t,r,Tt(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),Z0t=Pt(([n])=>{const e=Ct(n).toVar(),t=Tt(Il(e.x)).toVar(),r=Tt(Il(e.y)).toVar(),i=Tt(Il(e.z)).toVar();return Ct(ad(oa(t,r,i,Tt(0))),ad(oa(t,r,i,Tt(1))),ad(oa(t,r,i,Tt(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),Q0t=Pt(([n])=>{const e=er(n).toVar(),t=Tt(Il(e.x)).toVar(),r=Tt(Il(e.y)).toVar(),i=Tt(Il(e.z)).toVar(),s=Tt(Il(e.w)).toVar();return Ct(ad(oa(t,r,i,s,Tt(0))),ad(oa(t,r,i,s,Tt(1))),ad(oa(t,r,i,s,Tt(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]}),$R=wu([X0t,Y0t,Z0t,Q0t]),XC=Pt(([n,e,t,r])=>{const i=Ze(r).toVar(),s=Ze(t).toVar(),a=Tt(e).toVar(),o=Ct(n).toVar(),l=Ze(0).toVar(),c=Ze(1).toVar();return ta(a,()=>{l.addAssign(c.mul(hY(o))),c.mulAssign(i),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),WR=Pt(([n,e,t,r])=>{const i=Ze(r).toVar(),s=Ze(t).toVar(),a=Tt(e).toVar(),o=Ct(n).toVar(),l=Ct(0).toVar(),c=Ze(1).toVar();return ta(a,()=>{l.addAssign(c.mul(_6(o))),c.mulAssign(i),o.mulAssign(s)}),l}).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),K0t=Pt(([n,e,t,r])=>{const i=Ze(r).toVar(),s=Ze(t).toVar(),a=Tt(e).toVar(),o=Ct(n).toVar();return jn(XC(o,a,s,i),XC(o.add(Ct(Tt(19),Tt(193),Tt(17))),a,s,i))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),J0t=Pt(([n,e,t,r])=>{const i=Ze(r).toVar(),s=Ze(t).toVar(),a=Tt(e).toVar(),o=Ct(n).toVar(),l=Ct(WR(o,a,s,i)).toVar(),c=Ze(XC(o.add(Ct(Tt(19),Tt(193),Tt(17))),a,s,i)).toVar();return er(l,c)}).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),ept=Pt(([n,e,t,r,i,s,a])=>{const o=Tt(a).toVar(),l=Ze(s).toVar(),c=Tt(i).toVar(),u=Tt(r).toVar(),d=Tt(t).toVar(),h=Tt(e).toVar(),p=jn(n).toVar(),g=Ct($R(jn(h.add(u),d.add(c)))).toVar(),x=jn(g.x,g.y).toVar();x.subAssign(.5),x.mulAssign(l),x.addAssign(.5);const _=jn(jn(Ze(h),Ze(d)).add(x)).toVar(),y=jn(_.sub(p)).toVar();return pr(o.equal(Tt(2)),()=>ya(y.x).add(ya(y.y))),pr(o.equal(Tt(3)),()=>Eo(ya(y.x),ya(y.y))),n0(y,y)}).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),tpt=Pt(([n,e,t,r,i,s,a,o,l])=>{const c=Tt(l).toVar(),u=Ze(o).toVar(),d=Tt(a).toVar(),h=Tt(s).toVar(),p=Tt(i).toVar(),g=Tt(r).toVar(),x=Tt(t).toVar(),_=Tt(e).toVar(),y=Ct(n).toVar(),M=Ct($R(Ct(_.add(p),x.add(h),g.add(d)))).toVar();M.subAssign(.5),M.mulAssign(u),M.addAssign(.5);const C=Ct(Ct(Ze(_),Ze(x),Ze(g)).add(M)).toVar(),k=Ct(C.sub(y)).toVar();return pr(c.equal(Tt(2)),()=>ya(k.x).add(ya(k.y)).add(ya(k.z))),pr(c.equal(Tt(3)),()=>Eo(ya(k.x),ya(k.y),ya(k.z))),n0(k,k)}).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),Y3=wu([ept,tpt]),npt=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Ze(e).toVar(),s=jn(n).toVar(),a=Tt().toVar(),o=Tt().toVar(),l=jn(ho(s.x,a),ho(s.y,o)).toVar(),c=Ze(1e6).toVar();return ta({start:-1,end:Tt(1),name:"x",condition:"<="},({x:u})=>{ta({start:-1,end:Tt(1),name:"y",condition:"<="},({y:d})=>{const h=Ze(Y3(l,u,d,a,o,i,r)).toVar();c.assign(xh(c,h))})}),pr(r.equal(Tt(0)),()=>{c.assign(Fd(c))}),c}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),rpt=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Ze(e).toVar(),s=jn(n).toVar(),a=Tt().toVar(),o=Tt().toVar(),l=jn(ho(s.x,a),ho(s.y,o)).toVar(),c=jn(1e6,1e6).toVar();return ta({start:-1,end:Tt(1),name:"x",condition:"<="},({x:u})=>{ta({start:-1,end:Tt(1),name:"y",condition:"<="},({y:d})=>{const h=Ze(Y3(l,u,d,a,o,i,r)).toVar();pr(h.lessThan(c.x),()=>{c.y.assign(c.x),c.x.assign(h)}).ElseIf(h.lessThan(c.y),()=>{c.y.assign(h)})})}),pr(r.equal(Tt(0)),()=>{c.assign(Fd(c))}),c}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),ipt=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Ze(e).toVar(),s=jn(n).toVar(),a=Tt().toVar(),o=Tt().toVar(),l=jn(ho(s.x,a),ho(s.y,o)).toVar(),c=Ct(1e6,1e6,1e6).toVar();return ta({start:-1,end:Tt(1),name:"x",condition:"<="},({x:u})=>{ta({start:-1,end:Tt(1),name:"y",condition:"<="},({y:d})=>{const h=Ze(Y3(l,u,d,a,o,i,r)).toVar();pr(h.lessThan(c.x),()=>{c.z.assign(c.y),c.y.assign(c.x),c.x.assign(h)}).ElseIf(h.lessThan(c.y),()=>{c.z.assign(c.y),c.y.assign(h)}).ElseIf(h.lessThan(c.z),()=>{c.z.assign(h)})})}),pr(r.equal(Tt(0)),()=>{c.assign(Fd(c))}),c}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),spt=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Ze(e).toVar(),s=Ct(n).toVar(),a=Tt().toVar(),o=Tt().toVar(),l=Tt().toVar(),c=Ct(ho(s.x,a),ho(s.y,o),ho(s.z,l)).toVar(),u=Ze(1e6).toVar();return ta({start:-1,end:Tt(1),name:"x",condition:"<="},({x:d})=>{ta({start:-1,end:Tt(1),name:"y",condition:"<="},({y:h})=>{ta({start:-1,end:Tt(1),name:"z",condition:"<="},({z:p})=>{const g=Ze(Y3(c,d,h,p,a,o,l,i,r)).toVar();u.assign(xh(u,g))})})}),pr(r.equal(Tt(0)),()=>{u.assign(Fd(u))}),u}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),apt=wu([npt,spt]),opt=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Ze(e).toVar(),s=Ct(n).toVar(),a=Tt().toVar(),o=Tt().toVar(),l=Tt().toVar(),c=Ct(ho(s.x,a),ho(s.y,o),ho(s.z,l)).toVar(),u=jn(1e6,1e6).toVar();return ta({start:-1,end:Tt(1),name:"x",condition:"<="},({x:d})=>{ta({start:-1,end:Tt(1),name:"y",condition:"<="},({y:h})=>{ta({start:-1,end:Tt(1),name:"z",condition:"<="},({z:p})=>{const g=Ze(Y3(c,d,h,p,a,o,l,i,r)).toVar();pr(g.lessThan(u.x),()=>{u.y.assign(u.x),u.x.assign(g)}).ElseIf(g.lessThan(u.y),()=>{u.y.assign(g)})})})}),pr(r.equal(Tt(0)),()=>{u.assign(Fd(u))}),u}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),lpt=wu([rpt,opt]),cpt=Pt(([n,e,t])=>{const r=Tt(t).toVar(),i=Ze(e).toVar(),s=Ct(n).toVar(),a=Tt().toVar(),o=Tt().toVar(),l=Tt().toVar(),c=Ct(ho(s.x,a),ho(s.y,o),ho(s.z,l)).toVar(),u=Ct(1e6,1e6,1e6).toVar();return ta({start:-1,end:Tt(1),name:"x",condition:"<="},({x:d})=>{ta({start:-1,end:Tt(1),name:"y",condition:"<="},({y:h})=>{ta({start:-1,end:Tt(1),name:"z",condition:"<="},({z:p})=>{const g=Ze(Y3(c,d,h,p,a,o,l,i,r)).toVar();pr(g.lessThan(u.x),()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(g)}).ElseIf(g.lessThan(u.y),()=>{u.z.assign(u.y),u.y.assign(g)}).ElseIf(g.lessThan(u.z),()=>{u.z.assign(g)})})})}),pr(r.equal(Tt(0)),()=>{u.assign(Fd(u))}),u}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),fY=wu([ipt,cpt]),upt=Pt(([n,e,t,r,i,s,a,o,l,c,u])=>{const d=Tt(n).toVar(),h=jn(e).toVar(),p=jn(t).toVar(),g=jn(r).toVar(),x=Ze(i).toVar(),_=Ze(s).toVar(),y=Ze(a).toVar(),M=uf(o).toVar(),C=Tt(l).toVar(),k=Ze(c).toVar(),B=Ze(u).toVar(),U=h.mul(p).add(g),z=Ze(0).toVar();return pr(d.equal(Tt(0)),()=>{z.assign(_6(U))}),pr(d.equal(Tt(1)),()=>{z.assign($R(U))}),pr(d.equal(Tt(2)),()=>{z.assign(fY(U,x,Tt(0)))}),pr(d.equal(Tt(3)),()=>{z.assign(WR(Ct(U,0),C,k,B))}),z.assign(z.mul(y.sub(_)).add(_)),pr(M,()=>{z.assign(ep(z,_,y))}),z}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),dpt=Pt(([n,e,t,r,i,s,a,o,l,c,u])=>{const d=Tt(n).toVar(),h=Ct(e).toVar(),p=Ct(t).toVar(),g=Ct(r).toVar(),x=Ze(i).toVar(),_=Ze(s).toVar(),y=Ze(a).toVar(),M=uf(o).toVar(),C=Tt(l).toVar(),k=Ze(c).toVar(),B=Ze(u).toVar(),U=h.mul(p).add(g),z=Ze(0).toVar();return pr(d.equal(Tt(0)),()=>{z.assign(_6(U))}),pr(d.equal(Tt(1)),()=>{z.assign($R(U))}),pr(d.equal(Tt(2)),()=>{z.assign(fY(U,x,Tt(0)))}),pr(d.equal(Tt(3)),()=>{z.assign(WR(U,C,k,B))}),z.assign(z.mul(y.sub(_)).add(_)),pr(M,()=>{z.assign(ep(z,_,y))}),z}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),hpt=Pt(([n])=>{const e=n.y,t=n.z,r=Ct().toVar();return pr(e.lessThan(1e-4),()=>{r.assign(Ct(t,t,t))}).Else(()=>{let i=n.x;i=i.sub(om(i)).mul(6).toVar();const s=Tt(tX(i)),a=i.sub(Ze(s)),o=t.mul(e.oneMinus()),l=t.mul(e.mul(a).oneMinus()),c=t.mul(e.mul(a.oneMinus()).oneMinus());pr(s.equal(Tt(0)),()=>{r.assign(Ct(t,c,o))}).ElseIf(s.equal(Tt(1)),()=>{r.assign(Ct(l,t,o))}).ElseIf(s.equal(Tt(2)),()=>{r.assign(Ct(o,t,c))}).ElseIf(s.equal(Tt(3)),()=>{r.assign(Ct(o,l,t))}).ElseIf(s.equal(Tt(4)),()=>{r.assign(Ct(c,o,t))}).Else(()=>{r.assign(Ct(t,o,l))})}),r}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),fpt=Pt(([n])=>{const e=Ct(n).toVar(),t=Ze(e.x).toVar(),r=Ze(e.y).toVar(),i=Ze(e.z).toVar(),s=Ze(xh(t,xh(r,i))).toVar(),a=Ze(Eo(t,Eo(r,i))).toVar(),o=Ze(a.sub(s)).toVar(),l=Ze().toVar(),c=Ze().toVar(),u=Ze().toVar();return u.assign(a),pr(a.greaterThan(0),()=>{c.assign(o.div(a))}).Else(()=>{c.assign(0)}),pr(c.lessThanEqual(0),()=>{l.assign(0)}).Else(()=>{pr(t.greaterThanEqual(a),()=>{l.assign(r.sub(i).div(o))}).ElseIf(r.greaterThanEqual(a),()=>{l.assign(jl(2,i.sub(t).div(o)))}).Else(()=>{l.assign(jl(4,t.sub(r).div(o)))}),l.mulAssign(1/6),pr(l.lessThan(0),()=>{l.addAssign(1)})}),Ct(l,c,u)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),ppt=Pt(([n])=>{const e=Ct(n).toVar(),t=BW($W(e,Ct(.04045))).toVar(),r=Ct(e.div(12.92)).toVar(),i=Ct(Gf(Eo(e.add(Ct(.055)),Ct(0)).div(1.055),Ct(2.4))).toVar();return ki(r,i,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),_we=(n,e)=>{n=Ze(n),e=Ze(e);const t=jn(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return hf(n.sub(t),n.add(t),e)},wwe=(n,e,t,r)=>ki(n,e,t[r].clamp()),mpt=(n,e,t=na())=>wwe(n,e,t,"x"),gpt=(n,e,t=na())=>wwe(n,e,t,"y"),Apt=(n,e,t,r,i=na())=>{const s=i.x.clamp(),a=i.y.clamp(),o=ki(n,e,s),l=ki(t,r,s);return ki(o,l,a)},Swe=(n,e,t,r,i)=>ki(n,e,_we(t,r[i])),xpt=(n,e,t,r=na())=>Swe(n,e,t,r,"x"),vpt=(n,e,t,r=na())=>Swe(n,e,t,r,"y"),ypt=(n=1,e=0,t=na())=>t.mul(n).add(e),bpt=(n,e=1)=>(n=Ze(n),n.abs().pow(e).mul(n.sign())),_pt=(n,e=1,t=.5)=>Ze(n).sub(t).mul(e).add(t),wpt=(n=na(),e=1,t=0)=>hY(n.convert("vec2|vec3")).mul(e).add(t),Spt=(n=na(),e=1,t=0)=>_6(n.convert("vec2|vec3")).mul(e).add(t),Tpt=(n=na(),e=1,t=0)=>(n=n.convert("vec2|vec3"),er(_6(n),hY(n.add(jn(19,73)))).mul(e).add(t)),Ept=(n,e=na(),t=jn(1,1),r=jn(0,0),i=1,s=0,a=1,o=!1,l=1,c=2,u=.5)=>upt(n,e.convert("vec2|vec3"),t,r,i,s,a,o,l,c,u),Npt=(n,e=na(),t=jn(1,1),r=jn(0,0),i=1,s=0,a=1,o=!1,l=1,c=2,u=.5)=>dpt(n,e.convert("vec2|vec3"),t,r,i,s,a,o,l,c,u),Mpt=(n=na(),e=1)=>apt(n.convert("vec2|vec3"),e,Tt(1)),Cpt=(n=na(),e=1)=>lpt(n.convert("vec2|vec3"),e,Tt(1)),Ppt=(n=na(),e=1)=>fY(n.convert("vec2|vec3"),e,Tt(1)),Rpt=(n=na())=>W0t(n.convert("vec2|vec3")),Lpt=(n=na(),e=3,t=2,r=.5,i=1)=>XC(n,Tt(e),t,r).mul(i),kpt=(n=na(),e=3,t=2,r=.5,i=1)=>K0t(n,Tt(e),t,r).mul(i),Ipt=(n=na(),e=3,t=2,r=.5,i=1)=>WR(n,Tt(e),t,r).mul(i),Dpt=(n=na(),e=3,t=2,r=.5,i=1)=>J0t(n,Tt(e),t,r).mul(i),Opt=(n,e=Ze(0))=>jl(n,e),jpt=(n,e=Ze(0))=>Qi(n,e),Fpt=(n,e=Ze(1))=>Vr(n,e),Bpt=(n,e=Ze(1))=>df(n,e),Upt=(n,e=Ze(1))=>wR(n,e),zpt=(n,e=Ze(1))=>Gf(n,e),Vpt=(n=Ze(0),e=Ze(1))=>ZW(n,e),qpt=()=>X3,Gpt=()=>j3e,Hpt=(n,e=Ze(1))=>Qi(e,n),$pt=(n,e,t,r)=>n.greaterThan(e).mix(t,r),Wpt=(n,e,t,r)=>n.greaterThanEqual(e).mix(t,r),Xpt=(n,e,t,r)=>n.equal(e).mix(t,r),Ypt=(n,e=null)=>{if(typeof e=="string"){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=e.replace(/^out/,"").toLowerCase();if(t[r]!==void 0)return n.element(t[r])}if(typeof e=="number")return n.element(e);if(typeof e=="string"&&e.length===1){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(t[e]!==void 0)return n.element(t[e])}return n},Zpt=(n,e=jn(.5,.5),t=jn(1,1),r=Ze(0),i=jn(0,0))=>{let s=n;if(e&&(s=s.sub(e)),t&&(s=s.mul(t)),r){const a=r.mul(Math.PI/180),o=a.cos(),l=a.sin();s=jn(s.x.mul(o).sub(s.y.mul(l)),s.x.mul(l).add(s.y.mul(o)))}return e&&(s=s.add(e)),i&&(s=s.add(i)),s},Qpt=(n,e)=>{n=jn(n),e=Ze(e);const t=e.mul(Math.PI/180);return x6(n,t)},Kpt=(n,e,t)=>{n=Ct(n),e=Ze(e),t=Ct(t);const r=e.mul(Math.PI/180),i=t.normalize(),s=r.cos(),a=r.sin(),o=Ze(1).sub(s);return n.mul(s).add(i.cross(n).mul(a)).add(i.mul(i.dot(n)).mul(o))},Jpt=(n,e)=>(n=Ct(n),e=Ze(e),PX(n,e)),emt=Pt(([n,e,t])=>{const r=sd(n).toVar(),i=Qi(Ze(.5).mul(e.sub(t)),cm).div(r).toVar(),s=Qi(Ze(-.5).mul(e.sub(t)),cm).div(r).toVar(),a=Ct().toVar();a.x=r.x.greaterThan(Ze(0)).select(i.x,s.x),a.y=r.y.greaterThan(Ze(0)).select(i.y,s.y),a.z=r.z.greaterThan(Ze(0)).select(i.z,s.z);const o=xh(a.x,a.y,a.z).toVar();return cm.add(r.mul(o)).toVar().sub(t)}),Twe=Pt(([n,e])=>{const t=n.x,r=n.y,i=n.z;let s=e.element(0).mul(.886227);return s=s.add(e.element(1).mul(2*.511664).mul(r)),s=s.add(e.element(2).mul(2*.511664).mul(i)),s=s.add(e.element(3).mul(2*.511664).mul(t)),s=s.add(e.element(4).mul(2*.429043).mul(t).mul(r)),s=s.add(e.element(5).mul(2*.429043).mul(r).mul(i)),s=s.add(e.element(6).mul(i.mul(i).mul(.743125).sub(.247708))),s=s.add(e.element(7).mul(2*.429043).mul(t).mul(i)),s=s.add(e.element(8).mul(.429043).mul(Vr(t,t).sub(Vr(r,r)))),s});var ve=Object.freeze({__proto__:null,BRDF_GGX:WX,BRDF_Lambert:zv,BasicPointShadowFilter:fwe,BasicShadowFilter:iwe,Break:Y_e,Const:gbe,Continue:Ylt,DFGLUT:ES,D_GGX:d3e,Discard:Lbe,EPSILON:SR,F_Schlick:m3,Fn:Pt,HALF_PI:xot,INFINITY:mot,If:pr,Loop:ta,NodeAccess:Au,NodeShaderStage:Mb,NodeType:Bat,NodeUpdateType:Or,OnBeforeFrameUpdate:Ult,OnBeforeMaterialUpdate:Blt,OnBeforeObjectUpdate:Flt,OnFrameUpdate:z_e,OnMaterialUpdate:jlt,OnObjectUpdate:A6,PCFShadowFilter:swe,PCFSoftShadowFilter:awe,PI:FC,PI2:got,PointShadowFilter:pwe,Return:jot,Schlick_to_F0:sq,ShaderNode:i_,Stack:vR,Switch:oot,TBNViewMatrix:Cx,TWO_PI:Aot,VSMShadowFilter:owe,V_GGX_SmithCorrelated:u3e,Var:mbe,VarIntent:Abe,abs:ya,acesFilmicToneMapping:Y3e,acos:YW,acosh:Hye,add:jl,addMethodChaining:cn,addNodeElement:zot,agxToneMapping:Z3e,all:Dye,alphaT:DC,ambientOcclusion:WV,and:bye,anisotropy:H1,anisotropyB:Ux,anisotropyT:m4,any:Oye,append:cot,array:fye,asin:qye,asinh:Gye,assign:pye,atan:ZW,atanh:$ye,atomicAdd:pft,atomicAnd:xft,atomicFunc:Cm,atomicLoad:hft,atomicMax:gft,atomicMin:Aft,atomicOr:vft,atomicStore:fft,atomicSub:mft,atomicXor:yft,attenuationColor:GW,attenuationDistance:qW,attribute:ef,attributeArray:oht,backgroundBlurriness:U3e,backgroundIntensity:uq,backgroundRotation:z3e,batch:H_e,batchColor:FX,bentNormalView:d_e,billboarding:Gdt,bitAnd:Tye,bitNot:Eye,bitOr:Nye,bitXor:Mye,bitangentGeometry:Nlt,bitangentLocal:Mlt,bitangentView:c_e,bitangentWorld:Clt,bitcast:D3e,blendBurn:_ht,blendColor:Eht,blendDodge:wht,blendOverlay:Tht,blendScreen:Sht,blur:x3e,bool:uf,buffer:H3,bufferAttribute:fX,builtin:a1,builtinAOContext:fbe,builtinShadowContext:hbe,bumpMap:PX,bvec2:aye,bvec3:BW,bvec4:oye,bypass:Pbe,cache:Cbe,call:mye,cameraFar:tA,cameraIndex:o2,cameraNear:eA,cameraNormalMatrix:elt,cameraPosition:zbe,cameraProjectionMatrix:Id,cameraProjectionMatrixInverse:Ube,cameraViewMatrix:l2,cameraViewport:tlt,cameraWorldMatrix:g6,cbrt:abe,cdl:Rht,ceil:ER,checker:x0t,cineonToneMapping:X3e,clamp:ep,clearcoat:LC,clearcoatNormalView:nA,clearcoatRoughness:S_,clipSpace:Gbe,code:qR,color:sye,colorSpaceToWorking:MR,colorToDirection:Llt,compute:Mbe,computeKernel:mX,computeSkinning:Wlt,context:s1,convert:cye,convertColorSpace:Tot,convertToTexture:tht,cos:R0,cosh:Uye,countLeadingZeros:ydt,countOneBits:bdt,countTrailingZeros:vdt,cross:Zg,cubeTexture:kd,cubeTextureBase:MX,dFdx:JW,dFdy:eX,dashSize:zx,debug:Ibe,decrement:Iye,decrementBefore:Lye,defaultBuildStages:wN,defaultShaderStages:Kve,defined:h3,degrees:Fye,deltaTime:Odt,densityFogFactor:twe,depth:qX,depthPass:jht,determinant:Qye,difference:tbe,diffuseColor:Qs,diffuseContribution:hx,directPointLight:gwe,directionToColor:Rlt,directionToFaceDirection:mlt,dispersion:HW,disposeShadowMaterial:cwe,distance:ebe,div:df,dot:n0,drawIndex:Nbe,dynamicBufferAttribute:Pot,element:lye,emissive:$V,equal:gye,equirectDirection:iq,equirectUV:GX,exp:WW,exp2:f3,exponentialHeightFogFactor:Yht,expression:Yh,faceDirection:TX,faceForward:oX,faceforward:vot,float:Ze,floatBitsToInt:gdt,floatBitsToUint:O3e,floor:om,fog:dq,fract:J0,frameGroup:dot,frameId:j3e,frontFacing:Hbe,fwidth:nX,gain:wdt,gapSize:TS,getConstNodeType:iye,getCurrentStack:OW,getDirection:g3e,getDistanceAttenuation:dY,getGeometryRoughness:c3e,getNormalFromDepth:rht,getParallaxCorrectNormal:emt,getRoughness:$X,getScreenPosition:nht,getShIrradianceAt:Twe,getShadowMaterial:lwe,getShadowRenderObjectFunction:uwe,getTextureIndex:k3e,getViewPosition:Pb,ggxConvolution:v3e,globalId:tft,glsl:$ht,glslFn:Wht,grayscale:Nht,greaterThan:$W,greaterThanEqual:yye,hash:_dt,highpModelNormalViewMatrix:YV,highpModelViewMatrix:XV,hue:Pht,increment:kye,incrementBefore:Rye,inspector:Obe,instance:q_e,instanceColor:jX,instanceIndex:H0,instancedArray:lht,instancedBufferAttribute:PR,instancedDynamicBufferAttribute:pX,instancedMesh:G_e,int:Tt,intBitsToFloat:Adt,interleavedGradientNoise:tY,inverse:Kye,inverseSqrt:XW,inversesqrt:yot,invocationLocalIndex:kot,invocationSubgroupIndex:Lot,ior:g4,iridescence:bR,iridescenceIOR:kC,iridescenceThickness:IC,isolate:E_,ivec2:bo,ivec3:FW,ivec4:UW,js:Ght,label:pbe,length:lm,lengthSq:sX,lessThan:xye,lessThanEqual:vye,lightPosition:aY,lightProjectionUV:nwe,lightShadowMatrix:HR,lightTargetDirection:lY,lightTargetPosition:rwe,lightViewPosition:oY,lightingContext:Q_e,lights:Qft,linearDepth:qC,linearToneMapping:$3e,localId:nft,log:TR,log2:am,logarithmicDepthToViewZ:ict,luminance:rY,mat2:yR,mat3:Vc,mat4:RA,matcapUV:b3e,materialAO:B_e,materialAlphaTest:f_e,materialAnisotropy:M_e,materialAnisotropyVector:Cb,materialAttenuationColor:O_e,materialAttenuationDistance:D_e,materialClearcoat:__e,materialClearcoatNormal:S_e,materialClearcoatRoughness:w_e,materialColor:p_e,materialDispersion:F_e,materialEmissive:g_e,materialEnvIntensity:NN,materialEnvRotation:BC,materialIOR:I_e,materialIridescence:C_e,materialIridescenceIOR:P_e,materialIridescenceThickness:R_e,materialLightMap:OX,materialLineDashOffset:DX,materialLineDashSize:kX,materialLineGapSize:IX,materialLineScale:LX,materialLineWidth:UC,materialMetalness:y_e,materialNormal:b_e,materialOpacity:RX,materialPointSize:j_e,materialReference:tg,materialReflectivity:MN,materialRefractionRatio:Xbe,materialRotation:T_e,materialRoughness:v_e,materialSheen:E_e,materialSheenRoughness:N_e,materialShininess:m_e,materialSpecular:A_e,materialSpecularColor:x_e,materialSpecularIntensity:eq,materialSpecularStrength:A4,materialThickness:k_e,materialTransmission:L_e,max:Eo,maxMipLevel:vX,mediumpModelViewMatrix:qbe,metalness:dg,min:xh,mix:ki,mixElement:lbe,mod:wR,modelDirection:llt,modelNormalMatrix:Vbe,modelPosition:clt,modelRadius:hlt,modelScale:ult,modelViewMatrix:xm,modelViewPosition:dlt,modelViewProjection:U_e,modelWorldMatrix:Hf,modelWorldMatrixInverse:flt,morphReference:Z_e,mrt:I3e,mul:Vr,mx_aastep:_we,mx_add:Opt,mx_atan2:Vpt,mx_cell_noise_float:Rpt,mx_contrast:_pt,mx_divide:Bpt,mx_fractal_noise_float:Lpt,mx_fractal_noise_vec2:kpt,mx_fractal_noise_vec3:Ipt,mx_fractal_noise_vec4:Dpt,mx_frame:Gpt,mx_heighttonormal:Jpt,mx_hsvtorgb:hpt,mx_ifequal:Xpt,mx_ifgreater:$pt,mx_ifgreatereq:Wpt,mx_invert:Hpt,mx_modulo:Upt,mx_multiply:Fpt,mx_noise_float:wpt,mx_noise_vec3:Spt,mx_noise_vec4:Tpt,mx_place2d:Zpt,mx_power:zpt,mx_ramp4:Apt,mx_ramplr:mpt,mx_ramptb:gpt,mx_rgbtohsv:fpt,mx_rotate2d:Qpt,mx_rotate3d:Kpt,mx_safepower:bpt,mx_separate:Ypt,mx_splitlr:xpt,mx_splittb:vpt,mx_srgb_texture_to_lin_rec709:ppt,mx_subtract:jpt,mx_timer:qpt,mx_transform_uv:ypt,mx_unifiednoise2d:Ept,mx_unifiednoise3d:Npt,mx_worley_noise_float:Mpt,mx_worley_noise_vec2:Cpt,mx_worley_noise_vec3:Ppt,negate:KW,negateOnBackSide:uy,neutralToneMapping:Q3e,nodeArray:Bx,nodeImmutable:Vn,nodeObject:or,nodeObjectIntent:B5,nodeObjects:xR,nodeProxy:Ti,nodeProxyConstructor:DW,nodeProxyIntent:Nn,normalFlat:$be,normalGeometry:RR,normalLocal:ud,normalMap:JV,normalView:ss,normalViewGeometry:p3,normalWorld:c2,normalWorldGeometry:Wbe,normalize:sd,not:wye,notEqual:Aye,numWorkgroups:Jht,objectDirection:nlt,objectGroup:hye,objectPosition:ilt,objectRadius:olt,objectScale:slt,objectViewPosition:alt,objectWorldMatrix:rlt,oneMinus:Wye,or:_ye,orthographicDepthToViewZ:J_e,oscSawtooth:Udt,oscSine:jdt,oscSquare:Fdt,oscTriangle:Bdt,output:T_,outputStruct:hdt,overloadingFn:wu,overrideNode:M3e,overrideNodes:C3e,packHalf2x16:Mdt,packNormalToRGB:CX,packSnorm2x16:Edt,packUnorm2x16:Ndt,parabola:cq,parallaxDirection:u_e,parallaxUV:Plt,parameter:adt,pass:Dht,passTexture:Oht,pcurve:Sdt,perspectiveDepthToViewZ:jR,pmremTexture:YX,pointShadow:mwe,pointUV:uht,pointWidth:uot,positionGeometry:Yu,positionLocal:oo,positionPrevious:Uv,positionView:gl,positionViewDirection:fa,positionWorld:cm,positionWorldDirection:SX,posterize:Lht,pow:Gf,pow2:rX,pow3:nbe,pow4:iX,premultiplyAlpha:AX,property:i1,quadBroadcast:Hft,quadSwapDiagonal:Bft,quadSwapX:jft,quadSwapY:Fft,radians:jye,rand:obe,range:Qht,rangeFogFactor:ewe,reciprocal:Yye,reference:ka,referenceBuffer:e_e,reflect:Jye,reflectVector:Qbe,reflectView:Ybe,reflector:Zdt,refract:aX,refractVector:Kbe,refractView:Zbe,reinhardToneMapping:W3e,remap:gX,remapClamp:Rbe,renderGroup:yr,renderOutput:xX,rendererReference:wbe,replaceDefaultUV:zdt,rotate:x6,rotateUV:Vdt,roughness:qp,round:Xye,rtt:B3e,sRGBTransferEOTF:vbe,sRGBTransferOETF:ybe,sample:sht,sampler:Wot,samplerComparison:Xot,saturate:NR,saturation:Mht,screenCoordinate:cy,screenDPR:_X,screenSize:Bv,screenUV:F0,select:rd,setCurrentStack:SS,setName:cX,shaderStages:SN,shadow:hwe,shadowPositionWorld:uY,shapeCircle:v0t,sharedUniformGroup:_R,sheen:Bh,sheenRoughness:J1,shiftLeft:Cye,shiftRight:Pye,shininess:OC,sign:QW,sin:Pd,sinc:Tdt,sinh:Bye,skinning:X_e,smoothstep:hf,smoothstepElement:cbe,specularColor:HA,specularColorBlended:Nx,specularF90:Mx,spherizeUV:qdt,split:lot,spritesheetUV:$dt,sqrt:Fd,stack:PN,step:jv,stepElement:ube,storage:LA,storageBarrier:aft,storageTexture:q3e,storageTexture3D:fht,struct:ddt,sub:Qi,subBuild:Vx,subgroupAdd:wft,subgroupAll:Ift,subgroupAnd:Cft,subgroupAny:Dft,subgroupBallot:_ft,subgroupBroadcast:Uft,subgroupBroadcastFirst:Oft,subgroupElect:bft,subgroupExclusiveAdd:Tft,subgroupExclusiveMul:Mft,subgroupInclusiveAdd:Sft,subgroupInclusiveMul:Nft,subgroupIndex:Rot,subgroupMax:kft,subgroupMin:Lft,subgroupMul:Eft,subgroupOr:Pft,subgroupShuffle:zft,subgroupShuffleDown:Gft,subgroupShuffleUp:qft,subgroupShuffleXor:Vft,subgroupSize:rft,subgroupXor:Rft,tan:zye,tangentGeometry:kR,tangentLocal:$A,tangentView:IR,tangentWorld:l_e,tanh:Vye,texture:as,texture3D:nY,texture3DLevel:Aht,texture3DLoad:ght,textureBarrier:oft,textureBicubic:Uct,textureBicubicLevel:XX,textureCubeUV:A3e,textureLevel:$ot,textureLoad:dl,textureSize:Fv,textureStore:dht,thickness:VW,time:X3,toneMapping:Sbe,toneMappingExposure:Tbe,toonOutlinePass:Bht,transformDirection:rbe,transformNormal:EX,transformNormalByInverseViewMatrix:sbe,transformNormalByViewMatrix:ibe,transformNormalToView:NX,transformedClearcoatNormalView:xlt,transformedNormalView:glt,transformedNormalWorld:Alt,transmission:jC,transpose:Zye,triNoise3D:kdt,triplanarTexture:Wdt,triplanarTextures:F3e,trunc:tX,uint:bn,uintBitsToFloat:xdt,uniform:hr,uniformArray:pu,uniformCubeTexture:ylt,uniformFlow:dbe,uniformGroup:dye,uniformTexture:Hot,unpackHalf2x16:Rdt,unpackNormal:KV,unpackRGBToNormal:h_e,unpackSnorm2x16:Cdt,unpackUnorm2x16:Pdt,unpremultiplyAlpha:kbe,userData:vht,uv:na,uvec2:jW,uvec3:oy,uvec4:zW,varying:a2,varyingProperty:ly,vec2:jn,vec3:Ct,vec4:er,vectorComponents:sy,velocity:bht,vertexColor:n3e,vertexIndex:Ebe,vertexStage:xbe,vibrance:Cht,viewZToLogarithmicDepth:FR,viewZToOrthographicDepth:qx,viewZToPerspectiveDepth:VX,viewZToReversedOrthographicDepth:rct,viewZToReversedPerspectiveDepth:e3e,viewport:N_,viewportCoordinate:Bbe,viewportDepthTexture:zX,viewportLinearDepth:sct,viewportMipTexture:UX,viewportOpaqueMipTexture:K_e,viewportResolution:Jot,viewportSafeUV:Hdt,viewportSharedTexture:Iht,viewportSize:wX,viewportTexture:ect,viewportUV:Kot,vogelDiskSample:k0,wgsl:Hht,wgslFn:Xht,workgroupArray:uft,workgroupBarrier:sft,workgroupId:eft,workingToColorSpace:bbe,xor:Sye});const v0=new ZX;class tmt extends u2{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const i=this.renderer,s=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(s===null)i._clearColor.getRGB(v0),v0.a=i._clearColor.a;else if(s.isColor===!0)s.getRGB(v0),v0.a=1,a=!0;else if(s.isNode===!0){const l=this.get(e),c=s;v0.copy(i._clearColor);let u=l.backgroundMesh;if(u===void 0){let C=function(){s.removeEventListener("dispose",C),u.material.dispose(),u.geometry.dispose()};const h=er(c).mul(uq).context({getUV:()=>z3e.mul(Wbe),getTextureLevel:()=>U3e}),p=Id.element(3).element(3).equal(1),g=df(1,Id.element(1).element(1)).mul(3),x=p.select(oo.mul(g),oo),_=xm.mul(er(x,0));let y=Id.mul(er(_.xyz,1));y=y.setZ(y.w);const M=new Ho;M.name="Background.material",M.side=Ds,M.depthTest=!1,M.depthWrite=!1,M.allowOverride=!1,M.fog=!1,M.lights=!1,M.vertexNode=y,M.colorNode=h,l.backgroundMeshNode=h,l.backgroundMesh=u=new ui(new gf(1,32,32),M),u.frustumCulled=!1,u.name="Background.mesh",s.addEventListener("dispose",C)}const d=c.getCacheKey();l.backgroundCacheKey!==d&&(l.backgroundMeshNode.node=er(c).mul(uq),l.backgroundMeshNode.needsUpdate=!0,u.material.needsUpdate=!0,l.backgroundCacheKey=d),t.unshift(u,u.geometry,u.material,0,0,null,null)}else on("Renderer: Unsupported background configuration.",s);const o=i.xr.getEnvironmentBlendMode();if(o==="additive"?v0.set(0,0,0,1):o==="alpha-blend"&&v0.set(0,0,0,0),i.autoClear===!0||a===!0){const l=r.clearColorValue;l.r=v0.r,l.g=v0.g,l.b=v0.b,l.a=v0.a,(i.backend.isWebGLBackend===!0||i.alpha===!0)&&(l.r*=l.a,l.g*=l.a,l.b*=l.a),r.depthClearValue=i.getClearDepth(),r.stencilClearValue=i.getClearStencil(),r.clearColor=i.autoClearColor===!0,r.clearDepth=i.autoClearDepth===!0,r.clearStencil=i.autoClearStencil===!0}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let nmt=0;class hq{constructor(e="",t=[]){this.name=e,this.bindings=t,this.id=nmt++}}class rmt{constructor(e,t,r,i,s,a,o,l,c,u,d=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=d,this.nodeAttributes=i,this.bindings=s,this.updateNodes=a,this.updateBeforeNodes=o,this.updateAfterNodes=l,this.observer=c,this.hardwareClipping=u,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const i=new hq(t.name,[]);e.push(i);for(const s of t.bindings)i.bindings.push(s.clone())}else e.push(t);return e}}class Vce{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class imt{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class Ewe{constructor(e,t,r=!1,i=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=i}}class smt extends Ewe{constructor(e,t,r=null,i=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=i}}class amt{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let omt=0;class nB{constructor(e=null){this.id=omt++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class lmt{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class d2{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0,this.index=-1}setValue(e){this.value=e}getValue(){return this.value}}class cmt extends d2{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class umt extends d2{constructor(e,t=new en){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class dmt extends d2{constructor(e,t=new Fe){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class hmt extends d2{constructor(e,t=new gr){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class fmt extends d2{constructor(e,t=new Fn){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class pmt extends d2{constructor(e,t=new pS){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class mmt extends d2{constructor(e,t=new ni){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class gmt extends d2{constructor(e,t=new ir){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class Amt extends cmt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class xmt extends umt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class vmt extends dmt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class ymt extends hmt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class bmt extends fmt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class _mt extends pmt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class wmt extends mmt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class Smt extends gmt{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let Tmt=0;const qce=new WeakMap,Gce=new WeakMap,Emt=new WeakMap,Nmt=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),J8=n=>/e/g.test(n)?String(n).replace(/\+/g,""):(n=Number(n),n+(n%1?"":".0")),Nwe=n=>{if(n.writeUsageCount>0)return!0;if(n.subBuildsCache!==void 0){for(const e in n.subBuildsCache)if(Nwe(n.subBuildsCache[e]))return!0}return!1};class Mwe{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=new Set,this.sequentialNodes=new Set,this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.hardwareClipping=!1,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.types={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.declarations={},this.flow={code:""},this.chaining=[],this.stack=PN(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new nB,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:Tmt++})}isFlatShading(){return this.material.flatShading===!0||this.geometry.hasAttribute("normal")===!1}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===ac&&e.alphaToCoverage===!1}createRenderTarget(e,t,r){return new mf(e,t,r)}createCubeRenderTarget(e,t){return new i3e(e,t)}includes(e){return this.nodes.has(e)}getOutputType(e=0){let t="vec4";const r=this.renderer.getRenderTarget();if(r!==null){const i=r.textures[e].type,s=r.textures[e].format;let a="vec";i===ml?a="ivec":i===xs&&(a="uvec"),s===e1||s===Tm?i===ml?t="int":i===xs?t="uint":t="float":s===dc||s===t1?t=`${a}2`:s===t2||s===NP?t=`${a}3`:t=`${a}4`}return t}getOutputStructName(){}_getBindGroup(e,t){const r=t[0].groupNode;let i=r.shared;if(i)for(let a=1;ad.nodeUniform.node.id-h.nodeUniform.node.id);for(const d of u.uniforms)a+=d.nodeUniform.node.id}else a+=u.nodeUniform.id;const o=this.renderer._currentRenderContext||this.renderer;let l=qce.get(o);l===void 0&&(l=new Map,qce.set(o,l));const c=G3(a);s=l.get(c),s===void 0&&(s=new hq(e,t),l.set(c,s))}else s=new hq(e,t);return s}getBindGroupArray(e,t){const r=this.bindings[t];let i=r[e];return i===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(e===null){const t={},r=this.bindings;for(const i of SN)for(const s in r[i]){const a=r[i][s],o=t[s]||(t[s]=[]);for(const l of a)o.includes(l)===!1&&o.push(l)}e=[];for(const i in t){const s=t[i],a=this._getBindGroup(i,s);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,r)=>t.bindings[0].groupNode.order-r.bindings[0].groupNode.order);for(let t=0;t=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${J8(t.r)}, ${J8(t.g)}, ${J8(t.b)} )`;const r=this.getTypeLength(e),i=this.getComponentType(e),s=a=>this.generateConst(i,a);if(r===2)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)} )`;if(r===3)return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)} )`;if(r===4&&e!=="mat2")return`${this.getType(e)}( ${s(t.x)}, ${s(t.y)}, ${s(t.z)}, ${s(t.w)} )`;if(r>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(s).join(", ")} )`;if(r>4)return`${this.getType(e)}()`;throw new Error(`THREE.NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const r=this.attributes;for(const s of r)if(s.name===e)return s;const i=new Vce(e,t);return this.registerDeclaration(i),r.push(i),i}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;return e.isDepthTexture===!0?"float":t===ml?"int":t===xs?"uint":"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let r=Yve(e);const i=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(r=r.replace("vec","mat")),i+r}getTypeFromArray(e){return Nmt.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,i=e.itemSize,s=e.normalized;let a;return!(e instanceof C$)&&s!==!0&&(a=this.getTypeFromArray(r)),this.getTypeFromLength(i,a)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return r!==null?Number(r[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw new Error("THREE.NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=PN(this.stack);const e=OW();return this.stacks.push(e),SS(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const r=this.getDataFromNode(t);r.stack=e}return this.stack=e.parent,SS(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){r=r===null?e.isGlobal(this)?this.globalCache:this.cache:r;let i=r.getData(e);i===void 0&&(i={},r.setData(e,i)),i[t]===void 0&&(i[t]={});let s=i[t];if(this.subBuildLayers.length===0)return s;const a=i.any?i.any.subBuilds:null,o=this.getClosestSubBuild(a);return o&&(s.subBuildsCache===void 0&&(s.subBuildsCache={}),s=s.subBuildsCache[o]||(s.subBuildsCache[o]={}),s.subBuilds=a),s}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t,r=null){const i=this.getDataFromNode(e,"vertex");let s=i.bufferAttribute;if(s===void 0){const a=this.uniforms.index++;r===null&&(r="nodeAttribute"+a),s=new Vce(r,t,e),this.bufferAttributes.push(s),i.bufferAttribute=s}return s}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,i=this.shaderStage){const s=this.getDataFromNode(e,i,this.globalCache);let a=s.structType;if(a===void 0){const o=this.structs.index++;r===null&&(r="StructType"+o),a=new lmt(r,t),this.structs[i].push(a),this.types[i][r]=e,s.structType=a}return a}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,i=null){const s=this.getDataFromNode(e,r,this.globalCache);let a=s.uniform;if(a===void 0){const o=this.uniforms.index++;a=new imt(i||"nodeUniform"+o,t,e),this.uniforms[r].push(a),this.registerDeclaration(a),s.uniform=a}return a}getVarFromNode(e,t=null,r=e.getNodeType(this),i=this.shaderStage,s=!1){const a=this.getDataFromNode(e,i),o=this.getSubBuildProperty("variable",a.subBuilds);let l=a[o];if(l===void 0){const c=s?"_const":"_var",u=this.vars[i]||(this.vars[i]=[]),d=this.vars[c]||(this.vars[c]=0);t===null&&(t=(s?"nodeConst":"nodeVar")+d,this.vars[c]++),o!=="variable"&&(t=this.getSubBuildProperty(t,a.subBuilds));const h=e.getArrayCount(this);l=new Ewe(t,r,s,h),s||u.push(l),this.registerDeclaration(l),a[o]=l}return l}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,r=e.getNodeType(this),i=null,s=null){const a=this.getDataFromNode(e,"any"),o=this.getSubBuildProperty("varying",a.subBuilds);let l=a[o];if(l===void 0){const c=this.varyings,u=c.length;t===null&&(t="nodeVarying"+u),o!=="varying"&&(t=this.getSubBuildProperty(t,a.subBuilds)),l=new smt(t,r,i,s),c.push(l),this.registerDeclaration(l),a[o]=l}return l}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),i=e.name;let s=i,a=this.getPropertyName(e),o=1;for(;r[a]!==void 0;)s=i+"_"+o++,e.name=s,a=this.getPropertyName(e);s!==i&&sn(`TSL: Declaration name '${i}' of '${e.type}' already in use. Renamed to '${s}'.`),r[a]=e}getCodeFromNode(e,t,r=this.shaderStage){const i=this.getDataFromNode(e);let s=i.code;if(s===void 0){const a=this.codes[r]||(this.codes[r]=[]),o=a.length;s=new amt("nodeCode"+o,t),a.push(s),i.code=s}return s}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:i}=this.getDataFromNode(e);let s=!0,a=t;for(;a;){if(i.get(a)===!0){s=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(s)for(const o of r)this.addLineFlowCode(o)}addLineFlowCodeBlock(e,t,r){const i=this.getDataFromNode(e),s=i.flowCodes||(i.flowCodes=[]),a=i.flowCodeBlock||(i.flowCodeBlock=new WeakMap);s.push(t),a.set(r,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`; `),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=this.renderer.backend;let r=Gce.get(t);r===void 0&&(r=new WeakMap,Gce.set(t,r));let i=r.get(e);if(i===void 0){i=new K3e;const s=this.currentFunctionNode;this.currentFunctionNode=i,i.code=this.buildFunctionCode(e),this.currentFunctionNode=s,r.set(e,i)}return i}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let a=0;const o=Object.values(this);return{next:()=>({value:o[a],done:a++>=o.length})}}};for(const a of t.inputs)r[a.name]=new P3e(a.type,a.name);e.layout=null;const i=e.call(r),s=this.flowStagesNode(i,t.type);return e.layout=t,s}flowBuildStage(e,t,r=null){const i=this.getBuildStage();this.setBuildStage(t);const s=e.build(this,r);return this.setBuildStage(i),s}flowStagesNode(e,t=null){const r=this.flow,i=this.vars,s=this.declarations,a=this.cache,o=this.buildStage,l=this.stack,c={code:""};this.flow=c,this.vars={},this.declarations={},this.cache=new nB,this.stack=PN();for(const u of wN)this.setBuildStage(u),c.result=e.build(this,t);return c.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=i,this.declarations=s,this.cache=a,this.stack=l,this.setBuildStage(o),c}getFunctionOperator(){return null}buildFunctionCode(){sn("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,i={code:""};return this.flow=i,i.result=e.build(this,t),this.flow=r,i}flowNodeFromShaderStage(e,t,r=null,i=null){const s=this.tab,a=this.cache,o=this.shaderStage,l=this.context;this.setShaderStage(e);const c={...this.context};delete c.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=c;let u=null;if(this.buildStage==="generate"){const d=this.flowChildNode(t,r);i!==null&&(d.code+=`${this.tab+i} = ${d.result}; `),this.flowCode[e]=this.flowCode[e]+d.code,u=d}else u=t.build(this);return this.setShaderStage(o),this.cache=a,this.tab=s,this.context=l,u}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){sn("Abstract function.")}getVaryings(){sn("Abstract function.")}getVar(e,t,r=null){return`${r!==null?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e,t=!1){const r=[],i=this.vars[e];if(i!==void 0)for(const s of i)r.push(`${this.getVar(s.type,s.name,s.count)};`);return r.join(t?` `:` `)}getUniforms(){sn("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(t!==void 0)for(const i of t)r+=i.code+` `;return r}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){sn("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const r=this.subBuildLayers;for(let i=t.length-1;i>=0;i--){const s=t[i];if(r.includes(s))return s}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r;t!==null?r=this.getClosestSubBuild(t):r=this.subBuildFn;let i;return r?i=e?r+"_"+e:r:i=e,i}prebuild(){const{object:e,renderer:t,material:r}=this;if(t.contextNode.isContextNode===!0?this.context={...this.context,...t.contextNode.getFlowContextData()}:on('NodeBuilder: "renderer.contextNode" must be an instance of `context()`.'),r&&r.contextNode&&(r.contextNode.isContextNode===!0?this.context={...this.context,...r.contextNode.getFlowContextData()}:on('NodeBuilder: "material.contextNode" must be an instance of `context()`.')),r!==null){let i=t.library.fromMaterial(r);i===null&&(on(`NodeBuilder: Material "${r.type}" is not compatible.`),i=new Ho),i.build(this)}else this.addFlow("compute",e)}build(){this.prebuild();for(const e of wN){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of SN){this.setShaderStage(t);const r=this.flowNodes[t];for(const i of r)e==="generate"?this.flowNode(i):i.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}async buildAsync(){this.prebuild();for(const e of wN){this.setBuildStage(e),this.context.position&&this.context.position.isNode&&this.flowNodeFromShaderStage("vertex",this.context.position);for(const t of SN){this.setShaderStage(t);const r=this.flowNodes[t];for(const i of r)e==="generate"?this.flowNode(i):i.build(this);await G2e()}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=Emt.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){const r=this.getSharedDataFromNode(e);let i=r.cache;if(i===void 0){if(t==="float"||t==="int"||t==="uint")i=new Amt(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")i=new xmt(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")i=new vmt(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")i=new ymt(e);else if(t==="color")i=new bmt(e);else if(t==="mat2")i=new _mt(e);else if(t==="mat3")i=new wmt(e);else if(t==="mat4")i=new Smt(e);else throw new Error(`THREE.NodeBuilder: Uniform "${t}" not implemented.`);r.cache=i}return i}format(e,t,r){if(t=this.getVectorType(t),r=this.getVectorType(r),t===r||r===null||this.isReference(r))return e;const i=this.getTypeLength(t),s=this.getTypeLength(r);return i===16&&s===9?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:i===9&&s===4?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:i>4||s>4||s===0?e:i===s?`${this.getType(r)}( ${e} )`:i>s?(e=r==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,s)}`,this.format(e,this.getTypeFromLength(s,this.getComponentType(t)),r)):s===4&&i>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:i===2?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(i===1&&s>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${Sm} - Node System `}needsPreviousData(){const e=this.renderer.getMRT();return e&&e.has("velocity")||Qve(this.object).useVelocity===!0}}class Hce{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let r=e.get(t);return r===void 0&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===Or.FRAME){const i=this._getMaps(this.updateBeforeMap,r);if(i.frameId!==this.frameId){const s=i.frameId;i.frameId=this.frameId,e.updateBefore(this)===!1&&(i.frameId=s)}}else if(t===Or.RENDER){const i=this._getMaps(this.updateBeforeMap,r);if(i.renderId!==this.renderId){const s=i.renderId;i.renderId=this.renderId,e.updateBefore(this)===!1&&(i.renderId=s)}}else t===Or.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===Or.FRAME){const i=this._getMaps(this.updateAfterMap,r);i.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(i.frameId=this.frameId)}else if(t===Or.RENDER){const i=this._getMaps(this.updateAfterMap,r);i.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(i.renderId=this.renderId)}else t===Or.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===Or.FRAME){const i=this._getMaps(this.updateMap,r);i.frameId!==this.frameId&&e.update(this)!==!1&&(i.frameId=this.frameId)}else if(t===Or.RENDER){const i=this._getMaps(this.updateMap,r);i.renderId!==this.renderId&&e.update(this)!==!1&&(i.renderId=this.renderId)}else t===Or.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class pY{constructor(e,t,r=null,i="",s=!1){this.type=e,this.name=t,this.count=r,this.qualifier=i,this.isConst=s}}pY.isNodeFunctionInput=!0;class Mmt extends dy{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class Cmt extends dy{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:lY(this.light),lightColor:e}}}class Pmt extends dy{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=aY(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=hr(new Fn).setGroup(yr)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:r,lightDirectionNode:i}=this,a=c2.dot(i).mul(.5).add(.5),o=ki(r,t,a);e.context.irradiance.addAssign(o)}}class mY extends dy{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=hr(0).setGroup(yr),this.penumbraCosNode=hr(0).setGroup(yr),this.cutoffDistanceNode=hr(0).setGroup(yr),this.decayExponentNode=hr(0).setGroup(yr),this.colorNode=hr(this.color).setGroup(yr)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e,t){const{coneCosNode:r,penumbraCosNode:i}=this;return hf(r,i,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return r===void 0&&(r=nwe(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:i,light:s}=this,a=this.getLightVector(e),o=a.normalize(),l=o.dot(lY(s)),c=this.getSpotAttenuation(e,l),u=a.length(),d=dY({lightDistance:u,cutoffDistance:r,decayExponent:i});let h=t.mul(c).mul(d),p,g;return s.colorNode?(g=this.getLightCoord(e),p=s.colorNode(g)):s.map&&(g=this.getLightCoord(e),p=as(s.map,g.xy).onRenderUpdate(()=>s.map)),p&&(h=g.mul(2).sub(1).abs().lessThan(1).all().select(h.mul(p),h)),{lightColor:h,lightDirection:o}}}class Rmt extends mY{static get type(){return"IESSpotLightNode"}constructor(e=null){super(e),this._iesTextureNode=null}getSpotAttenuation(e,t){const r=this.light.iesMap;let i=null;if(r&&r.isTexture===!0){const s=t.acos().mul(1/Math.PI);this._iesTextureNode=as(r,jn(s,0),0),i=this._iesTextureNode.r}else i=super.getSpotAttenuation(e,t);return i}update(e){super.update(e),this._iesTextureNode!==null&&this.light.iesMap&&(this._iesTextureNode.value=this.light.iesMap)}}class Lmt extends dy{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let r=0;r<9;r++)t.push(new Fe);this.lightProbe=pu(t)}update(e){const{light:t}=this;super.update(e);for(let r=0;r<9;r++)this.lightProbe.array[r].copy(t.sh.coefficients[r]).multiplyScalar(t.intensity)}setup(e){const t=Twe(c2,this.lightProbe);e.context.irradiance.addAssign(t)}}const kmt=Pt(([n,e])=>{const t=n.abs().sub(e);return lm(Eo(t,0)).add(xh(Eo(t.x,t.y),0))});class Imt extends mY{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let r=1;t.map!==null&&(r=t.map.width/t.map.height),t.shadow.aspect=r}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=Ze(0),r=this.penumbraCosNode,i=HR(this.light).mul(e.context.positionWorld||cm);return pr(i.w.greaterThan(0),()=>{const s=i.xyz.div(i.w),a=kmt(s.xy.sub(jn(.5)),jn(.5)),o=df(-1,Qi(1,YW(r)).sub(1));t.assign(NR(a.mul(-2).mul(o)))}),t}}const rB=new ir,eE=new ir;let Jw=null;class Dmt extends dy{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=hr(new Fe).setGroup(yr),this.halfWidth=hr(new Fe).setGroup(yr),this.updateType=Or.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;eE.identity(),rB.copy(t.matrixWorld),rB.premultiply(r),eE.extractRotation(rB),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(eE),this.halfHeight.value.applyMatrix4(eE)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=as(Jw.LTC_FLOAT_1),r=as(Jw.LTC_FLOAT_2)):(t=as(Jw.LTC_HALF_1),r=as(Jw.LTC_HALF_2));const{colorNode:i,light:s}=this,a=oY(s);return{lightColor:i,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){Jw=e}}class Cwe{parseFunction(){sn("Abstract function.")}}class gY{constructor(e,t,r="",i=""){this.type=e,this.inputs=t,this.name=r,this.precision=i}getCode(){sn("Abstract function.")}}gY.isNodeFunction=!0;const Omt=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,jmt=/[a-z_0-9]+/ig,$ce="#pragma main",Fmt=n=>{n=n.trim();const e=n.indexOf($ce),t=e!==-1?n.slice(e+$ce.length):n,r=t.match(Omt);if(r!==null&&r.length===5){const i=r[4],s=[];let a=null;for(;(a=jmt.exec(i))!==null;)s.push(a);const o=[];let l=0;for(;l{let l=this._createNodeBuilder(e,e.material);try{t?await l.buildAsync():l.build()}catch(c){l=this._createNodeBuilder(e,new Ho),t?await l.buildAsync():l.build(),on("TSL: "+c)}return l};if(t)return o().then(l=>(i=this._createNodeBuilderState(l),s.set(a,i),i.usedTimes++,r.nodeBuilderState=i,i));{let l=this._createNodeBuilder(e,e.material);try{l.build()}catch(c){l=this._createNodeBuilder(e,new Ho),l.build();let u=c.stackTrace;!u&&c.stack&&(u=new Ol(c.stack)),on("TSL: "+c,u)}i=this._createNodeBuilderState(l),s.set(a,i)}}i.usedTimes++,r.nodeBuilderState=i}return i}getForRenderAsync(e){const t=this.getForRender(e,!0);return t.then?t:Promise.resolve(t)}getForRenderDeferred(e){const t=this.get(e);if(t.nodeBuilderState!==void 0)return t.nodeBuilderState;const r=this.getForRenderCacheKey(e),i=this.nodeBuilderCache.get(r);return i!==void 0?(i.usedTimes++,t.nodeBuilderState=i,i):(t.pendingBuild!==!0&&(t.pendingBuild=!0,this._buildQueue.push(()=>this.getForRenderAsync(e).then(()=>{t.pendingBuild=!1})),this._processBuildQueue()),null)}_processBuildQueue(){if(this._buildInProgress||this._buildQueue.length===0)return;this._buildInProgress=!0,this._buildQueue.shift()().then(()=>{this._buildInProgress=!1,this._processBuildQueue()})}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t!==void 0&&(t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e)))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(r===void 0||t.version!==e.version){const i=this.backend.createNodeBuilder(e,this.renderer);i.build(),r=this._createNodeBuilderState(i),t.nodeBuilderState=r,t.version=e.version}return r}_createNodeBuilderState(e){return new rmt(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.hardwareClipping,e.transforms)}getEnvironmentNode(e){if(this.renderer.lighting.enabled===!1)return null;this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){Nf[0]=e,Nf[1]=t;const r=this.renderer.info.calls,i=this.callHashCache.get(Nf)||{};if(i.callId!==r){if(Hm.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Hm.push(this.renderer.lighting.enabled?1:0),this.renderer.lighting.enabled){Hm.push(t.getCacheKey(!0)),Hm.push(this.renderer.shadowMap.enabled?1:0),Hm.push(this.renderer.shadowMap.type);const a=this.getEnvironmentNode(e);a&&Hm.push(a.getCacheKey())}const s=this.getFogNode(e);s&&Hm.push(s.getCacheKey()),i.callId=r,i.cacheKey=p6(Hm),this.callHashCache.set(Nf,i),Hm.length=0}return Nf[0]=null,Nf[1]=null,i.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const i=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==r||i){const s=this.getCacheNode("background",r,()=>{if(r.isCubeTexture===!0||r.mapping===MA||r.mapping===CA||r.mapping===pm){if(e.backgroundBlurriness>0||r.mapping===pm)return YX(r);{let a;return r.isCubeTexture===!0?a=kd(r):a=as(r),a3e(a)}}else{if(r.isTexture===!0)return as(r,F0.flipY()).setUpdateMatrix(!0);r.isColor!==!0&&on("WebGPUNodes: Unsupported background configuration.",r)}},i);t.backgroundNode=s,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,i=!1){const s=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=s.get(t);return(a===void 0||i)&&(a=r(),s.set(t,a)),a}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const i=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const s=ka("color","color",r).setGroup(yr),a=ka("density","float",r).setGroup(yr);return dq(s,twe(a))}else if(r.isFog){const s=ka("color","color",r).setGroup(yr),a=ka("near","float",r).setGroup(yr),o=ka("far","float",r).setGroup(yr);return dq(s,ewe(a,o))}else on("Renderer: Unsupported fog configuration.",r)});t.fogNode=i,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const i=this.getCacheNode("environment",r,()=>{if(r.isCubeTexture===!0)return kd(r);if(r.isTexture===!0)return as(r);on("Nodes: Unsupported environment configuration.",r)});t.environmentNode=i,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,i=null,s=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=r,a.camera=i,a.material=s,a}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace+","+e.xr.isPresenting}getOutputNode(e){const t=this.renderer;let r;return e.isArrayTexture?this.backend.isWebGLBackend?r=as(e,F0).depth(a1("gl_ViewID_OVR")).renderOutput(t.toneMapping,t.currentColorSpace):r=as(e,F0).depth(Wce).renderOutput(t.toneMapping,t.currentColorSpace):r=as(e,F0).renderOutput(t.toneMapping,t.currentColorSpace),r}setOutputLayerIndex(e){Wce.value=e}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const i of r.updateNodes)t.updateNode(i)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const i of r.updateNodes)t.updateNode(i)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new Hce,this.nodeBuilderCache=new Map,this.cacheLib={}}}const iB=new Bf;class YC{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewMatrix=new ir,this.viewNormalMatrix=new ni,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewMatrix=e.viewMatrix,this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass)}projectPlanes(e,t,r){const i=e.length;for(let s=0;s0&&(ji("THREE.XRManager: WebGPU XR does not support MSAA yet. Disabling MSAA for this XR session."),this._currentSamples===null&&(this._currentSamples=e.samples),e._samples=0)}}async _initWebGPUSession(e){const t=this.getWebGPUBinding(),r=t.createProjectionLayer({colorFormat:t.getPreferredColorFormat(),depthStencilFormat:"depth24plus"});this._glProjLayer=r,e.updateRenderState({layers:[r]}),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._xrRenderTarget=new mf(r.textureWidth,r.textureHeight,{depth:2,minFilter:Ci,magFilter:Ci,depthBuffer:!0,multiview:!1,useArrayDepthTexture:!0,samples:0}),this._xrRenderTarget.texture.isArrayTexture=!0,this._useMultiviewIfPossible===!0&&ji("THREE.XRManager: WebGPU XR does not support multiview yet. Disabling multiview for this XR session."),this._useMultiview=!1}_disposeWebGPUSession(){const e=this._renderer,t=this._xrRenderTarget;if(t===null||e.backend.isWebGPUBackend!==!0)return;const r=e.backend,i=e._textures,s=r.get?r.get(t):null;s&&(s.descriptors=void 0);const a=o=>{o!=null&&(r.delete&&r.delete(o),i.delete&&i.delete(o))};for(let o=0;oxX(d,r.toneMapping,r.outputColorSpace)}),Qce.set(l,c))}else c=l;r.contextNode=c,r.setRenderTarget(o.renderTarget),o.rendercall(),r.contextNode=l}r.setRenderTarget(a),r._setXRLayerSize(s.x,s.y),this.isPresenting=i}getSession(){return this._session}async setSession(e){const t=this._renderer;t.initialized===!1&&await t.init(),this._gl=t.getContext();const r=this._gl;if(this._session=e,e!==null){if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),this._validateWebGPUSession(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._isWebGPUSession())await this._initWebGPUSession(e);else if(this._supportsLayers===!0){let i=null,s=null,a=null;const o=r.getContextAttributes();await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation()),t.depth&&(a=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,i=t.stencil?mu:hc,s=t.stencil?Od:xs);const l={colorFormat:r.RGBA8,depthFormat:a,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(l.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const c=this._glBinding.createProjectionLayer(l),u=[c];this._glProjLayer=c,t.setPixelRatio(1),t._setXRLayerSize(c.textureWidth,c.textureHeight);const d=this._useMultiview?2:1,h=new zc(c.textureWidth,c.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,i,d);if(this._xrRenderTarget=new U5(c.textureWidth,c.textureHeight,{format:Oa,type:ma,colorSpace:t.outputColorSpace,depthTexture:h,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const p of this._layers)p.plane.material=new oc({color:16777215,side:p.type==="cylinder"?Ds:id}),p.plane.material.blending=NA,p.plane.material.blendEquation=Fc,p.plane.material.blendSrc=Bp,p.plane.material.blendDst=Bp,p.xrlayer=this._createXRLayer(p),u.unshift(p.xrlayer);e.updateRenderState({layers:u})}else{await t.backend.makeXRCompatible(),this.setFoveation(this.getFoveation());const i={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},s=new XRWebGLLayer(e,r,i);this._glBaseLayer=s,e.updateRenderState({baseLayer:s}),t.setPixelRatio(1),t._setXRLayerSize(s.framebufferWidth,s.framebufferHeight),this._xrRenderTarget=new U5(s.framebufferWidth,s.framebufferHeight,{format:Oa,type:ma,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:s.ignoreDepthValues===!1,resolveStencilBuffer:s.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=await e.requestReferenceSpace(this.getReferenceSpaceType())}t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}}updateCamera(e){const t=this._session;if(t===null)return;const r=e.near,i=e.far,s=this._cameraXR,a=this._cameraL,o=this._cameraR;s.near=o.near=a.near=r,s.far=o.far=a.far=i,s.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==s.near||this._currentDepthFar!==s.far)&&(t.updateRenderState({depthNear:s.near,depthFar:s.far}),this._currentDepthNear=s.near,this._currentDepthFar=s.far),s.layers.mask=e.layers.mask|6,a.layers.mask=s.layers.mask&-5,o.layers.mask=s.layers.mask&-3;const l=e.parent,c=s.cameras;Kce(s,l);for(let u=0;u=0&&(t[s]=null,e[s].disconnect(i))}for(let r=0;r=t.length){t.push(i),s=o;break}else if(t[o]===null){t[o]=i,s=o;break}if(s===-1)break}const a=e[s];a&&a.connect(i)}}function Kmt(n){return n.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(n.translation,n.quaternion),width:n.width/2,height:n.height/2,space:this._referenceSpace,viewPixelWidth:n.pixelwidth,viewPixelHeight:n.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(n.translation,n.quaternion),radius:n.radius,centralAngle:n.centralAngle,aspectRatio:n.aspectRatio,space:this._referenceSpace,viewPixelWidth:n.pixelwidth,viewPixelHeight:n.pixelheight,clearOnAccess:!1})}function Jmt(n,e){if(e===void 0)return;const t=this._cameraXR,r=this._renderer,i=r.backend,s=this._glBaseLayer,a=this.getReferenceSpace(),o=e.getViewerPose(a);if(this._xrFrame=e,o!==null){const l=o.views,c=this._isWebGPUSession()?this._getWebGPUViewData(l):null;this._glBaseLayer!==null&&c===null&&i.setXRTarget(s.framebuffer);let u=!1;l.length!==t.cameras.length&&(t.cameras.length=0,u=!0);for(let h=0;h{await this.compileAsync(_,x,g);const M=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,C=this._renderLists.get(g,x),k=this._renderContexts.get(M,this._mrt),B=g.overrideMaterial||_.material,U=this._objects.get(_,B,g,x,C.lightsNode,k,k.clippingContext),{fragmentShader:z,vertexShader:O}=U.getNodeBuilderState();return{fragmentShader:z,vertexShader:O}}}}async init(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise(async(e,t)=>{let r=this.backend;try{await r.init(this)}catch(i){if(this._getFallback!==null)try{this.backend=r=this._getFallback(i),await r.init(this)}catch(s){t(s);return}else{t(i);return}}this._nodes=new zmt(this,r),this._animation=new Out(this,this._nodes,this.info),this._attributes=new qut(r,this.info),this._background=new tmt(this,this._nodes),this._geometries=new Gut(this._attributes,this.info),this._textures=new sdt(this,r,this.info),this._pipelines=new Yut(r,this._nodes,this.info),this._bindings=new Zut(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new Uut(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new edt(this.lighting),this._bundles=new qmt,this._renderContexts=new rdt(this),this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)}),this._initPromise)}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,r=null){if(this._isDeviceLost===!0)return;this._initialized===!1&&await this.init();const i=this._nodes.nodeFrame,s=i.renderId,a=this._currentRenderContext,o=this._currentRenderObjectFunction,l=this._handleObjectFunction,c=this._compilationPromises;r===null&&(r=e);const u=e.isScene===!0?e:r.isScene===!0?r:Jce,h=this.needsFrameBufferTarget&&this._renderTarget===null?this._getFrameBufferTarget():this._renderTarget||this._outputRenderTarget,p=this._renderContexts.get(h,this._mrt),g=this._activeMipmapLevel,x=[];this._currentRenderContext=p,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=x,i.renderId++,i.update(),p.depth=this.depth,p.stencil=this.stencil,p.clippingContext||(p.clippingContext=new YC),p.clippingContext.updateGlobal(u,t),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t),u.onBeforeRender(this,e,t,h);const _=t.isArrayCamera?nE:tE;t.isArrayCamera?_.setFromArrayCamera(t):(db.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),_.setFromProjectionMatrix(db,t.coordinateSystem,t.reversedDepth));const y=this._renderLists.get(u,t);if(y.begin(),this._projectObject(e,t,0,y,p.clippingContext),r!==e&&r.traverseVisible(function(U){U.isLight&&U.layers.test(t.layers)&&y.pushLight(U)}),y.finish(),h!==null){this._textures.updateRenderTarget(h,g);const U=this._textures.get(h);p.textures=U.textures,p.depthTexture=U.depthTexture}else p.textures=null,p.depthTexture=null;r!==e?this._background.update(r,y,p):this._background.update(u,y,p);const M=y.opaque,C=y.transparent,k=y.transparentDoublePass,B=y.lightsNode;this.opaque===!0&&M.length>0&&this._renderObjects(M,t,u,B),this.transparent===!0&&C.length>0&&this._renderTransparents(C,k,t,u,B),i.renderId=s,this._currentRenderContext=a,this._currentRenderObjectFunction=o,this._handleObjectFunction=l,this._compilationPromises=c;for(const U of x){const z=this._objects.get(U.object,U.material,U.scene,U.camera,U.lightsNode,U.renderContext,U.clippingContext,U.passId);z.drawRange=U.object.geometry.drawRange,z.group=U.group,await this._nodes.getForRenderAsync(z),this._nodes.updateBefore(z),this._geometries.updateForRender(z),this._nodes.updateForRender(z),this._bindings.updateForRender(z);const O=[];this._pipelines.getForRender(z,O),O.length>0&&await Promise.all(O),this._nodes.updateAfter(z),await G2e()}}async renderAsync(e,t){ji('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.render(e,t)}async waitForGPU(){on("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){const t=this.contextNode.value;e===!0?(t.modelViewMatrix=XV,t.modelNormalViewMatrix=YV):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===XV&&e.modelNormalViewMatrix===YV}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return ji('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost: Message: ${e.message}`;e.reason&&(t+=` Reason: ${e.reason}`),on(t),this._isDeviceLost=!0}_onError(e){let t=`WebGPURenderer: Uncaptured ${e.api} ${e.type}`;e.message&&(t+=`: ${e.message}`),on(t)}_bundleNeedsUpdate(e,t){return t.bundleGPU===void 0||e.version!==t.version}_renderBundle(e,t,r){const{bundleGroup:i,camera:s,renderList:a}=e,o=this._currentRenderContext,l=this._bundles.get(i,s,o),c=this.backend.get(l);if(this._bundleNeedsUpdate(i,c)){this.backend.beginBundle(o),this._currentRenderBundle=l;const{transparentDoublePass:d,transparent:h,opaque:p}=a;this.opaque===!0&&p.length>0&&this._renderObjects(p,s,t,r),this.transparent===!0&&h.length>0&&this._renderTransparents(h,d,s,t,r),this._currentRenderBundle=null,this.backend.finishBundle(o,l),c.version=i.version}else{const{renderObjects:d}=c;for(let h=0,p=d.length;h{c.removeEventListener("dispose",_),u.dispose(),this._frameBufferTargets.delete(c)};c.addEventListener("dispose",_),this._frameBufferTargets.set(c,u)}const d=this.getOutputRenderTarget();u.depthBuffer=o,u.stencilBuffer=l,d!==null?u.setSize(d.width,d.height,d.depth):u.setSize(s,a,1);const h=this._outputRenderTarget?this._outputRenderTarget.viewport:c._viewport,p=this._outputRenderTarget?this._outputRenderTarget.scissor:c._scissor,g=this._outputRenderTarget?1:c._pixelRatio,x=this._outputRenderTarget?this._outputRenderTarget.scissorTest:c._scissorTest;return u.viewport.copy(h),u.scissor.copy(p),u.viewport.multiplyScalar(g),u.scissor.multiplyScalar(g),u.scissorTest=x,u.multiview=d!==null?d.multiview:!1,u.useArrayDepthTexture=d!==null?d.useArrayDepthTexture:!1,u.resolveDepthBuffer=d!==null?d.resolveDepthBuffer:!0,u._autoAllocateDepthBuffer=d!==null?d._autoAllocateDepthBuffer:!1,u}_renderScene(e,t,r=!0){if(this._isDeviceLost===!0)return;const i=r?this._getFrameBufferTarget():null,s=this._nodes.nodeFrame,a=s.renderId,o=this._currentRenderContext,l=this._currentRenderObjectFunction,c=this._handleObjectFunction;this.lighting.beginRender(e),this._callDepth++;const u=e.isScene===!0?e:Jce,d=this._renderTarget||this._outputRenderTarget,h=this._activeCubeFace,p=this._activeMipmapLevel;let g;if(i!==null?(g=i,this.setRenderTarget(g)):g=d,g!==null&&g.depthBuffer===!0){const K=this._textures.get(g);K.depthInitialized!==!0&&((this.autoClear===!1||this.autoClear===!0&&this.autoClearDepth===!1)&&this.clearDepth(),K.depthInitialized=!0)}const x=this._renderContexts.get(g,this._mrt,this._callDepth);this._currentRenderContext=x,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this._handleObjectFunction=this._renderObjectDirect,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,s.renderId=this.info.calls,this.backend.updateTimeStampUID(x),this.inspector.beginRender(this.backend.getTimestampUID(x),e,t,g),e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t=this._updateCamera(t);const _=this._canvasTarget;let y=_._viewport,M=_._scissor,C=_._pixelRatio;g!==null&&(y=g.viewport,M=g.scissor,C=1),this.getDrawingBufferSize(ub),sB.set(0,0,ub.width,ub.height);const k=y.minDepth===void 0?0:y.minDepth,B=y.maxDepth===void 0?1:y.maxDepth;x.viewportValue.copy(y).multiplyScalar(C).floor(),x.viewportValue.width>>=p,x.viewportValue.height>>=p,x.viewportValue.minDepth=k,x.viewportValue.maxDepth=B,x.viewport=x.viewportValue.equals(sB)===!1,x.scissorValue.copy(M).multiplyScalar(C).floor(),x.scissor=_._scissorTest&&x.scissorValue.equals(sB)===!1,x.scissorValue.width>>=p,x.scissorValue.height>>=p,x.clippingContext||(x.clippingContext=new YC),x.clippingContext.updateGlobal(u,t),u.onBeforeRender(this,e,t,g);const U=t.isArrayCamera?nE:tE;t.isArrayCamera?U.setFromArrayCamera(t):(db.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),U.setFromProjectionMatrix(db,t.coordinateSystem,t.reversedDepth));const z=this._renderLists.get(e,t);if(z.begin(),this._projectObject(e,t,0,z,x.clippingContext),z.finish(),this.sortObjects===!0&&z.sort(this._opaqueSort,this._transparentSort,t.reversedDepth),g!==null){this._textures.updateRenderTarget(g,p);const K=this._textures.get(g);x.textures=K.textures,x.depthTexture=K.depthTexture,x.width=K.width,x.height=K.height,x.renderTarget=g,x.depth=g.depthBuffer,x.stencil=g.stencilBuffer}else x.textures=null,x.depthTexture=null,x.width=ub.width,x.height=ub.height,x.depth=this.depth,x.stencil=this.stencil;x.width>>=p,x.height>>=p,x.activeCubeFace=h,x.activeMipmapLevel=p,x.occlusionQueryCount=z.occlusionQueryCount,x.scissorValue.max($m.set(0,0,0,0)),x.scissorValue.x+x.scissorValue.width>x.width&&(x.scissorValue.width=Math.max(x.width-x.scissorValue.x,0)),x.scissorValue.y+x.scissorValue.height>x.height&&(x.scissorValue.height=Math.max(x.height-x.scissorValue.y,0)),this._background.update(u,z,x),x.camera=t,this.backend.beginRender(x);const{bundles:O,lightsNode:V,transparentDoublePass:$,transparent:G,opaque:H}=z;return O.length>0&&this._renderBundles(O,u,V),this.opaque===!0&&H.length>0&&this._renderObjects(H,t,u,V),this.transparent===!0&&G.length>0&&this._renderTransparents(G,$,t,u,V),this.backend.finishRender(x),s.renderId=a,this._currentRenderContext=o,this._currentRenderObjectFunction=l,this._handleObjectFunction=c,this.lighting.finishRender(e),this._callDepth--,i!==null&&(this.setRenderTarget(d,h,p),this._renderOutput(g)),u.onAfterRender(this,e,t,g),this.inspector.finishRender(this.backend.getTimestampUID(x)),x}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._nodes.getOutputCacheKey();let r=this._quadCache.get(e.texture),i;if(r===void 0){i=new eY(new Ho),i.name="Output Color Transform",i.material.name="outputColorTransform",i.material.fragmentNode=this._nodes.getOutputNode(e.texture),r={quad:i,cacheKey:t},this._quadCache.set(e.texture,r);const o=()=>{i.material.dispose(),this._quadCache.delete(e.texture),e.texture.removeEventListener("dispose",o)};e.texture.addEventListener("dispose",o)}else i=r.quad,r.cacheKey!==t&&(i.material.fragmentNode=this._nodes.getOutputNode(e.texture),i.material.needsUpdate=!0,r.cacheKey=t);const s=this.autoClear,a=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderOutputLayers(i,e),this.autoClear=s,this.xr.enabled=a}getMaxAnisotropy(){return this.backend.capabilities.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){this._initialized===!1&&await this.init(),this._animation.setAnimationLoop(e)}getAnimationLoop(){return this._animation.getAnimationLoop()}async getArrayBufferAsync(e,t=null,r=0,i=-1){if(t!==null&&t.isReadbackBuffer&&this.info.memoryMap.has(t)===!1){this.info.createReadbackBuffer(t);const s=()=>{t.removeEventListener("dispose",s),this.info.destroyReadbackBuffer(t)};t.addEventListener("dispose",s)}if(r%4!==0||i>0&&i%4!==0)throw new Error('THREE.Renderer: "getArrayBufferAsync()" offset and count must be a multiple of 4.');return await this.backend.getArrayBufferAsync(e,t,r,i)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,i){this._canvasTarget.setScissor(e,t,r,i)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,i,s=0,a=1){this._canvasTarget.setViewport(e,t,r,i,s,a)}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this.reversedDepthBuffer===!0?1-this._clearDepth:this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,r=!0){if(this._initialized===!1)throw new Error('THREE.Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before using this method.');const i=this._renderTarget||this._getFrameBufferTarget();let s=null;if(i!==null){this._textures.updateRenderTarget(i);const a=this._textures.get(i);s=this._renderContexts.get(i,null,-1),s.textures=a.textures,s.depthTexture=a.depthTexture,s.width=a.width,s.height=a.height,s.renderTarget=i,s.depth=i.depthBuffer,s.stencil=i.stencilBuffer;const o=this.backend.getClearColor();s.clearColorValue.r=o.r,s.clearColorValue.g=o.g,s.clearColorValue.b=o.b,s.clearColorValue.a=o.a,s.clearDepthValue=this.getClearDepth(),s.clearStencilValue=this.getClearStencil(),s.activeCubeFace=this.getActiveCubeFace(),s.activeMipmapLevel=this.getActiveMipmapLevel(),i.depthBuffer===!0&&(a.depthInitialized=!0)}this.backend.clear(e,t,r,s),i!==null&&this._renderTarget===null&&this._renderOutput(i)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,r=!0){ji('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.clear(e,t,r)}async clearColorAsync(){ji('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)}async clearDepthAsync(){ji('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)}async clearStencilAsync(){ji('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)}get needsFrameBufferTarget(){const e=this.currentToneMapping!==cc,t=this.currentColorSpace!==Sr.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget!==null?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:cc}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:Sr.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){if(this._initialized===!0){this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose();for(const e of this._frameBufferTargets.keys())e.dispose();Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})}this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null);for(const e of this._frameBufferTargets.keys())e.dispose()}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return sn("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,i=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const s=this.backend,a=this._pipelines,o=this._bindings,l=this._nodes,c=Array.isArray(e)?e:[e];if(c[0]===void 0||c[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");s.beginCompute(e);for(const u of c){if(a.has(u)===!1){const p=()=>{u.removeEventListener("dispose",p),a.delete(u),o.deleteForCompute(u),l.delete(u)};u.addEventListener("dispose",p);const g=u.onInitFunction;g!==null&&g.call(u,{renderer:this})}l.updateForCompute(u),o.updateForCompute(u);const d=o.getForCompute(u),h=a.getForCompute(u,d);s.compute(e,u,d,h,t)}s.finishCompute(e),r.renderId=i,this.inspector.finishCompute(this.backend.getTimestampUID(e))}async computeAsync(e,t=null){this._initialized===!1&&await this.init(),this.compute(e,t)}async hasFeatureAsync(e){return ji('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.hasFeature(e)}async resolveTimestampsAsync(e="render"){return this._initialized===!1&&await this.init(),this.backend.resolveTimestampsAsync(e)}hasFeature(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}async initTextureAsync(e){ji('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),await this.init(),this.initTexture(e)}initTexture(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateTexture(e)}initRenderTarget(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .initRenderTarget() called before the backend is initialized. Use "await renderer.init();" before using this method.');this._textures.updateRenderTarget(e);const t=this._textures.get(e),r=this._renderContexts.get(e);r.textures=t.textures,r.depthTexture=t.depthTexture,r.width=t.width,r.height=t.height,r.renderTarget=e,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,this.backend.initRenderTarget(r)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=$m.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=$m.copy(t).floor();else{on("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=$m.set(0,0,e.image.width,e.image.height);let r=this._currentRenderContext,i;r!==null?i=r.renderTarget:(i=this._renderTarget||this._getFrameBufferTarget(),i!==null&&(this._textures.updateRenderTarget(i),r=this._textures.get(i))),this._textures.updateTexture(e,{renderTarget:i}),this.backend.copyFramebufferToTexture(e,r,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,i=null,s=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,i,s,a),this._inspector.copyTextureToTexture(e,t)}async readRenderTargetPixelsAsync(e,t,r,i,s,a=0,o=0){return this.backend.copyTextureToBuffer(e.textures[a],t,r,i,s,o)}_projectObject(e,t,r,i,s){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(s=s.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)i.pushLight(e);else if(e.isSprite){const l=t.isArrayCamera?nE:tE;if(!e.frustumCulled||l.intersectsSprite(e)){this.sortObjects===!0&&$m.setFromMatrixPosition(e.matrixWorld).applyMatrix4(db);const{geometry:c,material:u}=e;u.visible&&i.push(e,c,u,r,$m.z,null,s)}}else if(e.isLineLoop)on("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const l=t.isArrayCamera?nE:tE;if(!e.frustumCulled||l.intersectsObject(e)){const{geometry:c,material:u}=e;if(this.sortObjects===!0&&(c.boundingSphere===null&&c.computeBoundingSphere(),$m.copy(c.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(db)),Array.isArray(u)){const d=c.groups;for(let h=0,p=d.length;h0){for(const{material:a}of t)a.side=Ds;this._renderObjects(t,r,i,s,"backSide");for(const{material:a}of t)a.side=id;this._renderObjects(e,r,i,s);for(const{material:a}of t)a.side=ao}else this._renderObjects(e,r,i,s)}_renderObjects(e,t,r,i,s=null){for(let a=0,o=e.length;a(p.not().discard(),g))(c)}}e.depthNode&&e.depthNode.isNode&&(u=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?l=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(l=e.positionNode),r={version:t,colorNode:c,depthNode:u,positionNode:l},this._cacheShadowNodes.set(e,r)}return r}_updateCamera(e){const t=this.xr;if(t.isPresenting===!1){let r=!1;if(this.reversedDepthBuffer===!0&&e.reversedDepth!==!0){if(e._reversedDepth=!0,e.isArrayCamera)for(const s of e.cameras)s._reversedDepth=!0;r=!0}const i=this.coordinateSystem;if(e.coordinateSystem!==i){if(e.coordinateSystem=i,e.isArrayCamera)for(const s of e.cameras)s.coordinateSystem=i;r=!0}if(r===!0&&(e.updateProjectionMatrix(),e.isArrayCamera))for(const s of e.cameras)s.updateProjectionMatrix()}return e.parent===null&&e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.enabled===!0&&t.isPresenting===!0&&(t.cameraAutoUpdate===!0&&t.updateCamera(e),e=t.getCamera()),e}renderObject(e,t,r,i,s,a,o,l=null,c=null){let u=!1,d,h,p,g,x,_,y;const M=this._currentSourceMaterial;if(e.onBeforeRender(this,t,r,i,s,a),s.allowOverride===!0&&t.overrideMaterial!==null){this._currentSourceMaterial=s;const C=t.overrideMaterial;if(u=!0,d=C.isNodeMaterial?C.colorNode:null,h=C.isNodeMaterial?C.depthNode:null,p=C.isNodeMaterial?C.positionNode:null,g=t.overrideMaterial.side,x=C.displacementMap,_=C.displacementScale,y=C.displacementBias,s.positionNode&&s.positionNode.isNode&&(C.positionNode=s.positionNode),C.alphaTest=s.alphaTest,C.alphaMap=s.alphaMap,C.displacementMap=s.displacementMap,C.displacementScale=s.displacementScale,C.displacementBias=s.displacementBias,C.transparent=s.transparent||s.transmission>0||s.transmissionNode&&s.transmissionNode.isNode||s.backdropNode&&s.backdropNode.isNode,C.isShadowPassMaterial){const{colorNode:k,depthNode:B,positionNode:U}=this._getShadowNodes(s);this.shadowMap.type===Vf?C.side=s.shadowSide!==null?s.shadowSide:s.side:C.side=s.shadowSide!==null?s.shadowSide:tgt[s.side],k!==null&&(C.colorNode=k),B!==null&&(C.depthNode=B),U!==null&&(C.positionNode=U)}s=C}s.transparent===!0&&s.side===ao&&s.forceSinglePass===!1?(s.side=Ds,this._handleObjectFunction(e,s,t,r,o,a,l,"backSide"),s.side=id,this._handleObjectFunction(e,s,t,r,o,a,l,c),s.side=ao):this._handleObjectFunction(e,s,t,r,o,a,l,c),u&&(t.overrideMaterial.colorNode=d,t.overrideMaterial.depthNode=h,t.overrideMaterial.positionNode=p,t.overrideMaterial.side=g,t.overrideMaterial.displacementMap=x,t.overrideMaterial.displacementScale=_,t.overrideMaterial.displacementBias=y),this._currentSourceMaterial=M,e.onAfterRender(this,t,r,i,s,a)}hasCompatibility(e){if(this._initialized===!1)throw new Error('THREE.Renderer: .hasCompatibility() called before the backend is initialized. Use "await renderer.init();" before using this method.');return this.backend.hasCompatibility(e)}_renderObjectDirect(e,t,r,i,s,a,o,l){const c=this._objects.get(e,t,r,i,s,this._currentRenderContext,o,l);c.drawRange=e.geometry.drawRange,c.group=a,this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(c),c.bundle=this._currentRenderBundle.bundleGroup);const u=this._nodes.needsRefresh(c);u&&(this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c)),this._pipelines.updateForRender(c),this._pipelines.isReady(c)&&(this.backend.draw(c,this.info),u&&this._nodes.updateAfter(c))}_createObjectPipeline(e,t,r,i,s,a,o,l){if(this._compilationPromises!==null){this._compilationPromises.push({object:e,material:t,scene:r,camera:i,lightsNode:s,group:a,clippingContext:o,passId:l,renderContext:this._currentRenderContext});return}const c=this._objects.get(e,t,r,i,s,this._currentRenderContext,o,l);c.drawRange=e.geometry.drawRange,c.group=a,this._nodes.updateBefore(c),this._geometries.updateForRender(c),this._nodes.updateForRender(c),this._bindings.updateForRender(c),this._pipelines.getForRender(c,this._compilationPromises),this._nodes.updateAfter(c)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class Rwe{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function Lwe(n){return n+(rA-n%rA)%rA}class kwe extends Rwe{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return Lwe(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}release(){this._buffer=null}}class Iwe extends kwe{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let rgt=0;class Dwe extends Iwe{constructor(e,t){super("UniformBuffer_"+rgt++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get byteLength(){return Lwe(this.buffer.byteLength)}get buffer(){return this.nodeUniform.value}}class igt extends Iwe{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[],this._updateRangeCache=new Map,this._addedIndices=new Set}addUniformUpdateRange(e){const t=e.index;if(this._addedIndices.has(t))return;let r=this._updateRangeCache.get(t);r===void 0&&(r={start:0,count:0},this._updateRangeCache.set(t,r)),r.start=e.offset,r.count=e.itemSize,this._addedIndices.add(t),this.updateRanges.push(r)}clearUpdateRanges(){this._addedIndices.clear(),super.clearUpdateRanges()}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,i=this.uniforms.length;r0?d:"";o=`${c.name} { ${u} ${a.name}[${h}]; }; `}else{const c=a.groupNode.name;if(i[c]===void 0){const u=this.uniformGroups[c];if(u!==void 0){const d=[];for(const h of u.uniforms){const p=h.getType(),g=this.getVectorType(p),x=h.nodeUniform.node.precision;let _=`${g} ${h.name};`;x!==null&&(_=tue[x]+" "+_),d.push(" "+_)}i[c]=d}}l=!0}if(!l){const c=a.node.precision;c!==null&&(o=tue[c]+" "+o),o="uniform "+o,r.push(o)}}let s="";for(const a in i){const o=i[a];s+=this._getGLSLUniformStruct(a,o.join(` `))+` `}return s+=r.join(` `),s}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==ml){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const i=r.array;i instanceof Uint32Array||i instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const r=this.getAttributesArray();let i=0;for(const s of r)t+=`layout( location = ${i++} ) in ${s.type} ${s.name}; `}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(` ${r.type} ${r.name};`);return t.join(` `)}getStructs(e){const t=[],r=this.structs[e],i=[];for(const s of r)if(s.output)for(const a of s.members)i.push(`layout( location = ${a.index} ) out ${a.type} ${a.name};`);else{let a="struct "+s.name+` { `;a+=this.getStructMembers(s),a+=` }; `,t.push(a)}return e==="fragment"&&i.length===0&&i.push(`layout( location = 0 ) out ${this.getOutputType()} fragColor;`),` `+i.join(` `)+` `+t.join(` `)}getVaryings(e){let t="";const r=this.varyings;if(e==="vertex"||e==="compute")for(const i of r){e==="compute"&&(i.needsInterpolation=!0);const s=this.getType(i.type);if(i.needsInterpolation)if(i.interpolationType){const a=rue[i.interpolationType]||i.interpolationType,o=iue[i.interpolationSampling]||"";t+=`${a} ${o} out ${s} ${i.name}; `}else{const a=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${a}out ${s} ${i.name}; `}else t+=`${s} ${i.name}; `}else if(e==="fragment"){for(const i of r)if(i.needsInterpolation){const s=this.getType(i.type);if(i.interpolationType){const a=rue[i.interpolationType]||i.interpolationType,o=iue[i.interpolationSampling]||"";t+=`${a} ${o} in ${s} ${i.name}; `}else{const a=s.includes("int")||s.includes("uv")||s.includes("iv")?"flat ":"";t+=`${a}in ${s} ${i.name}; `}}}for(const i of this.builtins[e])t+=`${i}; `;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((r,i)=>r*i,1)}u`}getSubgroupSize(){on("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){on("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){on("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":"nodeUniformDrawId"}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,r=this.shaderStage){const i=this.extensions[r]||(this.extensions[r]=new Map);i.has(e)===!1&&i.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const i=this.renderer.backend.extensions;this.object.isBatchedMesh&&i.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(r!==void 0)for(const{name:i,behavior:s}of r.values())t.push(`#extension ${i} : ${s}`);return t.join(` `)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=nue[e];if(t===void 0){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance";break}if(r!==void 0){const i=this.renderer.backend.extensions;i.has(r)&&(i.get(r),t=!0)}nue[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r0&&(r+=` `),r+=` // flow -> ${c} `),r+=`${l.code} `,o===s&&t!=="compute"&&(r+=`// result `,t==="vertex"?(r+="gl_Position = ",r+=`${this.format(l.result,s.getNodeType(this),"vec4")};`):t==="fragment"&&(o.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${this.format(l.result,s.getNodeType(this),this.getOutputType())};`)))}const a=e[t];if(a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t,!0),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=r,t==="vertex"){const o=this.renderer.backend.extensions;this.object.isBatchedMesh&&o.has("WEBGL_multi_draw")===!1&&(a.uniforms+=` uniform uint nodeUniformDrawId; `)}}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,i=null){const s=super.getUniformFromNode(e,t,r,i),a=this.getDataFromNode(e,r,this.globalCache);let o=a.uniformGPU;if(o===void 0){const l=e.groupNode,c=l.name,u=this.getBindGroupArray(c,r);if(t==="texture")o=new XR(s.name,s.node,l),u.push(o);else if(t==="cubeTexture"||t==="cubeDepthTexture")o=new Fwe(s.name,s.node,l),u.push(o);else if(t==="texture3D")o=new fq(s.name,s.node,l),u.push(o);else if(t==="buffer"){s.name=`buffer${e.id}`;const d=this.getSharedDataFromNode(e);let h=d.buffer;h===void 0&&(e.name=`NodeBuffer_${e.id}`,h=new Dwe(e,l),h.name=e.name,d.buffer=h),u.push(h),o=h}else{let d=this.uniformGroups[c];d===void 0?(d=new Owe(c,l),this.uniformGroups[c]=d,u.push(d)):u.indexOf(d)===-1&&u.push(d),o=this.getNodeUniform(s,t);const h=o.name;d.uniforms.some(g=>g.name===h)||d.addUniform(o)}a.uniformGPU=o}return s}}let aB=null,hb=null;class Bwe{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[I0.RENDER]:null,[I0.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}async init(e){this.renderer=e}get coordinateSystem(){}beginRender(){}finishRender(){}setXRTarget(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}async copyTextureToBuffer(){}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}createUniformBuffer(){}destroyUniformBuffer(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let i;e.isComputeNode===!0?i="c:"+this.renderer.info.compute.frameCalls:i="r:"+this.renderer.info.render.frameCalls,t.timestampUID=i+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?I0.COMPUTE:I0.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}get hasTimestamp(){return!1}hasTimestampQuery(e){return this._getQueryPool(e).hasTimestampQuery(e)}isOccluded(){}async resolveTimestampsAsync(e="render"){if(!this.trackTimestamp){ji("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const r=await t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r}async getArrayBufferAsync(){}async hasFeatureAsync(){}hasFeature(){}getDrawingBufferSize(){return aB=aB||new en,this.renderer.getDrawingBufferSize(aB)}setScissorTest(){}getClearColor(){const e=this.renderer;return hb=hb||new ZX,e.getClearColor(hb),hb.getRGB(hb),hb}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:E$(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Sm} webgpu`),this.domElement=e),e}hasCompatibility(){return!1}initRenderTarget(){}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}deleteBindGroupData(){}dispose(){}}let hgt=0;class fgt{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class pgt{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:i}=r,s=e.array,a=e.usage||i.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,l=r.get(o);let c=l.bufferGPU;c===void 0&&(c=this._createBuffer(i,t,s,a),l.bufferGPU=c,l.bufferType=t,l.version=o.version);let u;if(s instanceof Float32Array)u=i.FLOAT;else if(typeof Float16Array<"u"&&s instanceof Float16Array)u=i.HALF_FLOAT;else if(s instanceof Uint16Array)e.isFloat16BufferAttribute?u=i.HALF_FLOAT:u=i.UNSIGNED_SHORT;else if(s instanceof Int16Array)u=i.SHORT;else if(s instanceof Uint32Array)u=i.UNSIGNED_INT;else if(s instanceof Int32Array)u=i.INT;else if(s instanceof Int8Array)u=i.BYTE;else if(s instanceof Uint8Array)u=i.UNSIGNED_BYTE;else if(s instanceof Uint8ClampedArray)u=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+s);let d={bufferGPU:c,bufferType:t,type:u,byteLength:s.byteLength,bytesPerElement:s.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:u===i.INT||u===i.UNSIGNED_INT||e.gpuType===ml,id:hgt++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const h=this._createBuffer(i,t,s,a);d=new fgt(d,h)}r.set(e,d)}updateAttribute(e){const t=this.backend,{gl:r}=t,i=e.array,s=e.isInterleavedBufferAttribute?e.data:e,a=t.get(s),o=a.bufferType,l=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(o,a.bufferGPU),l.length===0)r.bufferSubData(o,0,i);else{for(let c=0,u=l.length;c{t.buffer=null,t._mapped=!1,t.removeEventListener("release",h),t.removeEventListener("dispose",h)};t.addEventListener("release",h),t.addEventListener("dispose",h),d=new Uint8Array(new ArrayBuffer(u)),t.buffer=d.buffer}else d=new Uint8Array(t);return a.bindBuffer(a.COPY_READ_BUFFER,c),a.getBufferSubData(a.COPY_READ_BUFFER,r,d),a.bindBuffer(a.COPY_READ_BUFFER,null),a.bindBuffer(a.COPY_WRITE_BUFFER,null),t&&t.isReadbackBuffer?t:d.buffer}_createBuffer(e,t,r,i){const s=e.createBuffer();return e.bindBuffer(t,s),e.bufferData(t,r,i),e.bindBuffer(t,null),s}}let e5,Wm;class mgt{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.parameters={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthReversed=!1,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;e5={[Fc]:e.FUNC_ADD,[hP]:e.FUNC_SUBTRACT,[fP]:e.FUNC_REVERSE_SUBTRACT},Wm={[Bp]:e.ZERO,[pP]:e.ONE,[mP]:e.SRC_COLOR,[rv]:e.SRC_ALPHA,[bP]:e.SRC_ALPHA_SATURATE,[vP]:e.DST_COLOR,[AP]:e.DST_ALPHA,[gP]:e.ONE_MINUS_SRC_COLOR,[iv]:e.ONE_MINUS_SRC_ALPHA,[yP]:e.ONE_MINUS_DST_COLOR,[xP]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=new gr().fromArray(t),this.currentViewport=new gr().fromArray(r),this._tempVec4=new gr}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==m$?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===qM?t.cullFace(t.BACK):e===g$?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e,t,r){const i=this.gl,s=this.backend.drawBuffersIndexedExt;if(!s){ji("WebGPURenderer: Multiple Render Targets (MRT) blending configuration is not fully supported in compatibility mode. The material blending will be used for all render targets.");return}for(let a=0;a0?this.enable(i.SAMPLE_ALPHA_TO_COVERAGE):this.disable(i.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r)for(let l=0;l<8;l++)l{function s(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),i();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(s);return}e.deleteSync(t),r()}s()})}}let aue=!1,rE,oB,oue;class Agt{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,aue===!1&&(this._init(),aue=!0)}_init(){const e=this.gl;rE={[Fg]:e.REPEAT,[uc]:e.CLAMP_TO_EDGE,[Bg]:e.MIRRORED_REPEAT},oB={[Ss]:e.NEAREST,[JS]:e.NEAREST_MIPMAP_NEAREST,[qf]:e.NEAREST_MIPMAP_LINEAR,[Ci]:e.LINEAR,[PA]:e.LINEAR_MIPMAP_NEAREST,[Bc]:e.LINEAR_MIPMAP_LINEAR},oue={[CP]:e.NEVER,[LP]:e.ALWAYS,[t6]:e.LESS,[n1]:e.LEQUAL,[PP]:e.EQUAL,[mm]:e.GEQUAL,[t3]:e.GREATER,[RP]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return e.isCubeTexture===!0?r=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?r=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?r=t.TEXTURE_3D:r=t.TEXTURE_2D,r}getInternalFormat(e,t,r,i,s,a=!1){const{gl:o,extensions:l}=this;if(e!==null){if(o[e]!==void 0)return o[e];sn("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let c=null;i&&(c=l.get("EXT_texture_norm16"),c||sn("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let u=t;if(t===o.RED&&(r===o.FLOAT&&(u=o.R32F),r===o.HALF_FLOAT&&(u=o.R16F),r===o.UNSIGNED_BYTE&&(u=o.R8),r===o.BYTE&&(u=o.R8_SNORM),r===o.UNSIGNED_SHORT&&c&&(u=c.R16_EXT),r===o.SHORT&&c&&(u=c.R16_SNORM_EXT)),t===o.RED_INTEGER&&(r===o.UNSIGNED_BYTE&&(u=o.R8UI),r===o.UNSIGNED_SHORT&&(u=o.R16UI),r===o.UNSIGNED_INT&&(u=o.R32UI),r===o.BYTE&&(u=o.R8I),r===o.SHORT&&(u=o.R16I),r===o.INT&&(u=o.R32I)),t===o.RG&&(r===o.FLOAT&&(u=o.RG32F),r===o.HALF_FLOAT&&(u=o.RG16F),r===o.UNSIGNED_BYTE&&(u=o.RG8),r===o.BYTE&&(u=o.RG8_SNORM),r===o.UNSIGNED_SHORT&&c&&(u=c.RG16_EXT),r===o.SHORT&&c&&(u=c.RG16_SNORM_EXT)),t===o.RG_INTEGER&&(r===o.UNSIGNED_BYTE&&(u=o.RG8UI),r===o.UNSIGNED_SHORT&&(u=o.RG16UI),r===o.UNSIGNED_INT&&(u=o.RG32UI),r===o.BYTE&&(u=o.RG8I),r===o.SHORT&&(u=o.RG16I),r===o.INT&&(u=o.RG32I)),t===o.RGB){const d=a?Lv:Sr.getTransfer(s);r===o.FLOAT&&(u=o.RGB32F),r===o.HALF_FLOAT&&(u=o.RGB16F),r===o.UNSIGNED_BYTE&&(u=d===rr?o.SRGB8:o.RGB8),r===o.BYTE&&(u=o.RGB8_SNORM),r===o.UNSIGNED_SHORT&&c&&(u=c.RGB16_EXT),r===o.SHORT&&c&&(u=c.RGB16_SNORM_EXT),r===o.UNSIGNED_SHORT_5_6_5&&(u=o.RGB565),r===o.UNSIGNED_SHORT_5_5_5_1&&(u=o.RGB5_A1),r===o.UNSIGNED_SHORT_4_4_4_4&&(u=o.RGB4),r===o.UNSIGNED_INT_5_9_9_9_REV&&(u=o.RGB9_E5),r===o.UNSIGNED_INT_10F_11F_11F_REV&&(u=o.R11F_G11F_B10F)}if(t===o.RGB_INTEGER&&(r===o.UNSIGNED_BYTE&&(u=o.RGB8UI),r===o.UNSIGNED_SHORT&&(u=o.RGB16UI),r===o.UNSIGNED_INT&&(u=o.RGB32UI),r===o.BYTE&&(u=o.RGB8I),r===o.SHORT&&(u=o.RGB16I),r===o.INT&&(u=o.RGB32I)),t===o.RGBA){const d=a?Lv:Sr.getTransfer(s);r===o.FLOAT&&(u=o.RGBA32F),r===o.HALF_FLOAT&&(u=o.RGBA16F),r===o.UNSIGNED_BYTE&&(u=d===rr?o.SRGB8_ALPHA8:o.RGBA8),r===o.BYTE&&(u=o.RGBA8_SNORM),r===o.UNSIGNED_SHORT&&c&&(u=c.RGBA16_EXT),r===o.SHORT&&c&&(u=c.RGBA16_SNORM_EXT),r===o.UNSIGNED_SHORT_4_4_4_4&&(u=o.RGBA4),r===o.UNSIGNED_SHORT_5_5_5_1&&(u=o.RGB5_A1)}return t===o.RGBA_INTEGER&&(r===o.UNSIGNED_BYTE&&(u=o.RGBA8UI),r===o.UNSIGNED_SHORT&&(u=o.RGBA16UI),r===o.UNSIGNED_INT&&(u=o.RGBA32UI),r===o.BYTE&&(u=o.RGBA8I),r===o.SHORT&&(u=o.RGBA16I),r===o.INT&&(u=o.RGBA32I)),t===o.DEPTH_COMPONENT&&(r===o.UNSIGNED_SHORT&&(u=o.DEPTH_COMPONENT16),r===o.UNSIGNED_INT&&(u=o.DEPTH_COMPONENT24),r===o.FLOAT&&(u=o.DEPTH_COMPONENT32F)),t===o.DEPTH_STENCIL&&r===o.UNSIGNED_INT_24_8&&(u=o.DEPTH24_STENCIL8),(u===o.R16F||u===o.R32F||u===o.RG16F||u===o.RG32F||u===o.RGBA16F||u===o.RGBA32F)&&l.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:r,extensions:i,backend:s}=this,{state:a}=this.backend,o=Sr.getPrimaries(Sr.workingColorSpace),l=t.colorSpace===Rd?null:Sr.getPrimaries(t.colorSpace),c=t.colorSpace===Rd||o===l?r.NONE:r.BROWSER_DEFAULT_WEBGL;a.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),a.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),a.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),a.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,c),r.texParameteri(e,r.TEXTURE_WRAP_S,rE[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,rE[t.wrapT]),(e===r.TEXTURE_3D||e===r.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,rE[t.wrapR])),r.texParameteri(e,r.TEXTURE_MAG_FILTER,oB[t.magFilter]);const u=t.mipmaps!==void 0&&t.mipmaps.length>0,d=t.minFilter===Ci&&u?Bc:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,oB[d]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,oue[t.compareFunction])),i.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===Ss||t.minFilter!==qf&&t.minFilter!==Bc||t.type===ea&&i.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const h=i.get("EXT_texture_filter_anisotropic");r.texParameterf(e,h.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,s.capabilities.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:i}=this,s=this.getGLTextureType(e);let a=i[s];a===void 0&&(a=t.createTexture(),r.state.bindTexture(s,a),t.texParameteri(s,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(s,t.TEXTURE_MAG_FILTER,t.NEAREST),i[s]=a),r.set(e,{textureGPU:a,glTextureType:s})}createTexture(e,t){const{gl:r,backend:i}=this;let s,a,o,l,c;if(e.isExternalTexture===!0)s=e.sourceTexture,a=this.getGLTextureType(e);else{const{levels:u,width:d,height:h,depth:p}=t;o=i.utils.convert(e.format,e.colorSpace),l=i.utils.convert(e.type),c=this.getInternalFormat(e.internalFormat,o,l,e.normalized,e.colorSpace,e.isVideoTexture),s=r.createTexture(),a=this.getGLTextureType(e),i.state.bindTexture(a,s),this.setTextureParameters(a,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,u,c,d,h,p):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,u,c,d,h,p):e.isVideoTexture||r.texStorage2D(a,u,c,d,h)}i.set(e,{textureGPU:s,glTextureType:a,glFormat:o,glType:l,glInternalFormat:c})}copyBufferToTexture(e,t){const{gl:r,backend:i}=this,{state:s}=i,{textureGPU:a,glTextureType:o,glFormat:l,glType:c}=i.get(t),{width:u,height:d}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),i.state.bindTexture(o,a),s.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(o,0,0,0,u,d,l,c,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),i.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:i,height:s}=t,{textureGPU:a,glTextureType:o,glFormat:l,glType:c,glInternalFormat:u}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(o,a),this.setTextureParameters(o,e),e.isCompressedTexture){const d=e.mipmaps,h=t.image;for(let p=0;p0){const h=YM(d.width,d.height,e.format,e.type);for(const p of e.layerUpdates){const g=d.data.subarray(p*h/d.data.BYTES_PER_ELEMENT,(p+1)*h/d.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,p,d.width,d.height,1,l,c,g)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,d.width,d.height,d.depth,l,c,d.data)}else if(e.isData3DTexture){const d=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,d.width,d.height,d.depth,l,c,d.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(o,0,u,l,c,t.image);else if(e.isHTMLTexture)typeof r.texElementImage2D=="function"&&(r.texElementImage2D.length===3?r.texElementImage2D(r.TEXTURE_2D,r.RGBA8,t.image):r.texElementImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t.image));else{const d=e.mipmaps;if(d.length>0)for(let h=0,p=d.length;h0,h=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(d){const p=o!==0||l!==0;let g,x;if(e.isDepthTexture===!0?(g=i.DEPTH_BUFFER_BIT,x=i.DEPTH_ATTACHMENT,t.stencil&&(g|=i.STENCIL_BUFFER_BIT)):(g=i.COLOR_BUFFER_BIT,x=i.COLOR_ATTACHMENT0),p){const _=this.backend.get(t.renderTarget),y=_.framebuffers[t.getCacheKey()],M=_.msaaFrameBuffer;s.bindFramebuffer(i.DRAW_FRAMEBUFFER,y),s.bindFramebuffer(i.READ_FRAMEBUFFER,M);const C=h-l-u;i.blitFramebuffer(o,C,o+c,C+u,o,C,o+c,C+u,g,i.NEAREST),s.bindFramebuffer(i.READ_FRAMEBUFFER,y),s.bindTexture(i.TEXTURE_2D,a),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,o,C,c,u),s.unbindTexture()}else{const _=i.createFramebuffer();s.bindFramebuffer(i.DRAW_FRAMEBUFFER,_),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,x,i.TEXTURE_2D,a,0),i.blitFramebuffer(0,0,c,u,0,0,c,u,g,i.NEAREST),i.deleteFramebuffer(_)}}else s.bindTexture(i.TEXTURE_2D,a),i.copyTexSubImage2D(i.TEXTURE_2D,0,0,0,o,h-u-l,c,u),s.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,i=!1){const{gl:s}=this,a=t.renderTarget,{depthTexture:o,depthBuffer:l,stencilBuffer:c,width:u,height:d}=a;if(s.bindRenderbuffer(s.RENDERBUFFER,e),l&&!c){let h=s.DEPTH_COMPONENT24;i===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(s.RENDERBUFFER,a.samples,h,u,d):r>0?(o&&o.isDepthTexture&&o.type===s.FLOAT&&(h=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,r,h,u,d)):s.renderbufferStorage(s.RENDERBUFFER,h,u,d),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else l&&c&&(r>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,r,s.DEPTH24_STENCIL8,u,d):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,u,d),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e));s.bindRenderbuffer(s.RENDERBUFFER,null)}async copyTextureToBuffer(e,t,r,i,s,a){const{backend:o,gl:l}=this,{textureGPU:c,glFormat:u,glType:d}=this.backend.get(e),h=l.createFramebuffer();o.state.bindFramebuffer(l.READ_FRAMEBUFFER,h);const p=e.isCubeTexture?l.TEXTURE_CUBE_MAP_POSITIVE_X+a:l.TEXTURE_2D;l.framebufferTexture2D(l.READ_FRAMEBUFFER,l.COLOR_ATTACHMENT0,p,c,0);const g=this._getTypedArrayType(d),x=this._getBytesPerTexel(d,u),y=i*s*x,M=l.createBuffer();l.bindBuffer(l.PIXEL_PACK_BUFFER,M),l.bufferData(l.PIXEL_PACK_BUFFER,y,l.STREAM_READ),l.readPixels(t,r,i,s,u,d,0),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),await o.utils._clientWaitAsync();const C=new g(y/g.BYTES_PER_ELEMENT);return l.bindBuffer(l.PIXEL_PACK_BUFFER,M),l.getBufferSubData(l.PIXEL_PACK_BUFFER,0,C),l.bindBuffer(l.PIXEL_PACK_BUFFER,null),o.state.bindFramebuffer(l.READ_FRAMEBUFFER,null),l.deleteFramebuffer(h),C}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`THREE.WebGLTextureUtils: Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let i=0;if(e===r.UNSIGNED_BYTE&&(i=1),(e===r.UNSIGNED_SHORT_4_4_4_4||e===r.UNSIGNED_SHORT_5_5_5_1||e===r.UNSIGNED_SHORT_5_6_5||e===r.UNSIGNED_SHORT||e===r.HALF_FLOAT)&&(i=2),(e===r.UNSIGNED_INT||e===r.FLOAT)&&(i=4),t===r.RGBA)return i*4;if(t===r.RGB)return i*3;if(t===r.ALPHA)return i}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function iE(n){return n.isDataTexture?n.image.data:typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&n instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas?n:n.data}class xgt{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class vgt{constructor(e){this.backend=e,this.maxAnisotropy=null,this.maxUniformBlockSize=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}getUniformBufferLimit(){if(this.maxUniformBlockSize!==null)return this.maxUniformBlockSize;const e=this.backend.gl;return this.maxUniformBlockSize=e.getParameter(e.MAX_UNIFORM_BLOCK_SIZE),this.maxUniformBlockSize}}const lue={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class ygt{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:r,mode:i,object:s,type:a,info:o,index:l}=this;l!==0?r.drawElements(i,t,a,e):r.drawArrays(i,e,t),o.update(s,t,1)}renderInstances(e,t,r){const{gl:i,mode:s,type:a,index:o,object:l,info:c}=this;r!==0&&(o!==0?i.drawElementsInstanced(s,t,a,e,r):i.drawArraysInstanced(s,e,t,r),c.update(l,t,r))}renderMultiDraw(e,t,r){const{extensions:i,mode:s,object:a,info:o}=this;if(r===0)return;const l=i.get("WEBGL_multi_draw");if(l===null)for(let c=0;cthis.maxQueries)return ji(`WebGLTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;const r=this.queries[t];if(r)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(i){on("Error in beginQuery:",i),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(r){on("Error in endQuery:",r),this.queryStates.set(t,"inactive"),this.activeQuery=null}}async resolveQueriesAsync(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[s,a]of this.queryOffsets)if(this.queryStates.get(a)==="ended"){const l=this.queries[a];e.set(s,this.resolveQuery(l))}if(e.size===0)return this.lastValue;const t={},r=[];for(const[s,a]of e){const o=s.match(/^(.*):f(\d+)$/),l=parseInt(o[2]);r.includes(l)===!1&&r.push(l),t[l]===void 0&&(t[l]=0);const c=await a;this.timestamps.set(s,c),t[l]+=c}const i=t[r[r.length-1]];return this.lastValue=i,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,i}catch(e){return on("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}}async resolveQuery(e){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let r,i=!1;const s=()=>{r&&(clearTimeout(r),r=null)},a=l=>{i||(i=!0,s(),t(l))},o=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){r=setTimeout(o,1);return}const u=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(u)/1e6)}catch(l){on("Error checking query:",l),t(this.lastValue)}};o()})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class cue extends Bwe{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},i=t.context!==void 0?t.context:e.domElement.getContext("webgl2",r);function s(a){a.preventDefault();const o={api:"WebGL",message:a.statusMessage||"Unknown reason",reason:null,originalEvent:a};e.onDeviceLost(o)}this._onContextLost=s,e.domElement.addEventListener("webglcontextlost",s,!1),this.gl=i,this.extensions=new xgt(this),this.capabilities=new vgt(this),this.attributeUtils=new pgt(this),this.textureUtils=new Agt(this),this.bufferRenderer=new ygt(this),this.state=new mgt(this),this.utils=new ggt(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.extensions.get("EXT_clip_control"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed"),t.reversedDepthBuffer&&(this.extensions.has("EXT_clip_control")?e.reversedDepthBuffer=!0:(sn("WebGPURenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),e.reversedDepthBuffer=!1)),e.reversedDepthBuffer&&this.state.setReversedDepth(!0)}get coordinateSystem(){return gu}get hasTimestamp(){return this.disjoint!==null}async getArrayBufferAsync(e,t=null,r=0,i=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,i)}async makeXRCompatible(){this.gl.getContextAttributes().xrCompatible!==!0&&await this.gl.makeXRCompatible()}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const i=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:i.RGBA8}),r!==null){const s=e.stencilBuffer?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:s}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&sn("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new bgt(this.gl,e,2048));const r=this.timestampQueryPool[e];r.allocateQueriesForContext(t)!==null&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:s,height:a}=this.getDrawingBufferSize();t.viewport(0,0,s,a)}if(e.scissor)this.updateScissor(e);else{const{width:s,height:a}=this.getDrawingBufferSize();t.scissor(0,0,s,a)}this.initTimestampQuery(I0.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const i=e.occlusionQueryCount;i>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(i),r.occlusionQueryObjects=new Array(i),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,i=this.get(e),s=i.previousContext;r.resetVertexState();const a=e.occlusionQueryCount;a>0&&(a>i.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const o=e.textures;if(o!==null)for(let l=0;l{let l=0;for(let c=0;c1?t.renderInstances(r,i,s):t.render(r,i)}draw(e){const{object:t,pipeline:r,material:i,context:s,hardwareClippingPlanes:a}=e,{programGPU:o}=this.get(r),{gl:l,state:c}=this,u=this.get(s),d=e.getDrawParameters();if(d===null)return;this._bindUniforms(e.getBindings());const h=t.isMesh&&t.matrixWorld.determinantAffine()<0;c.setMaterial(i,h,a),s.mrt!==null&&s.textures!==null&&c.setMRTBlending(s.textures,s.mrt,i),c.useProgram(o);const p=e.getAttributes(),g=this.get(p);let x=g.vaoGPU;if(x===void 0){const z=this._getVaoKey(p);x=this.vaoCache[z],x===void 0&&(x=this._createVao(p),this.vaoCache[z]=x,g.vaoGPU=x)}const _=e.getIndex(),y=_!==null?this.get(_).bufferGPU:null;c.setVertexState(x,y);const M=u.lastOcclusionObject;if(M!==t&&M!==void 0){if(M!==null&&M.occlusionTest===!0&&(l.endQuery(l.ANY_SAMPLES_PASSED),u.occlusionQueryIndex++),t.occlusionTest===!0){const z=l.createQuery();l.beginQuery(l.ANY_SAMPLES_PASSED,z),u.occlusionQueries[u.occlusionQueryIndex]=z,u.occlusionQueryObjects[u.occlusionQueryIndex]=t}u.lastOcclusionObject=t}const C=this.bufferRenderer;t.isPoints?C.mode=l.POINTS:t.isLineSegments?C.mode=l.LINES:t.isLine?C.mode=l.LINE_STRIP:t.isLineLoop?C.mode=l.LINE_LOOP:i.wireframe===!0?(c.setLineWidth(i.wireframeLinewidth*this.renderer.getPixelRatio()),C.mode=l.LINES):C.mode=l.TRIANGLES;const{vertexCount:k,instanceCount:B}=d;let{firstVertex:U}=d;if(C.object=t,_!==null){U*=_.array.BYTES_PER_ELEMENT;const z=this.get(_);C.index=_.count,C.type=z.type}else C.index=0;if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const z=this.get(e.camera),O=e.camera.cameras,V=e.getBindingGroup("cameraIndex").bindings[0];if(z.indexesGPU===void 0||z.indexesGPU.length!==O.length){const J=new Uint32Array([0,0,0,0]),ie=[];for(let ae=0,Q=O.length;ae{const h=this.parallel,p=()=>{r.getProgramParameter(o,h.COMPLETION_STATUS_KHR)?(this._completeCompile(e,i),d()):requestAnimationFrame(p)};p()});t.push(u);return}this._completeCompile(e,i)}_handleSource(e,t){const r=e.split(` `),i=[],s=Math.max(t-6,0),a=Math.min(t+6,r.length);for(let o=s;o":" "} ${l}: ${r[o]}`)}return i.join(` `)}_getShaderErrors(e,t,r){const i=e.getShaderParameter(t,e.COMPILE_STATUS),a=(e.getShaderInfoLog(t)||"").trim();if(i&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return r.toUpperCase()+` `+a+` `+this._handleSource(e.getShaderSource(t),l)}else return a}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const i=this.gl,a=(i.getProgramInfoLog(e)||"").trim();if(i.getProgramParameter(e,i.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(i,e,r,t);else{const o=this._getShaderErrors(i,r,"vertex"),l=this._getShaderErrors(i,t,"fragment");on("WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(e,i.VALIDATE_STATUS)+` Program Info Log: `+a+` `+o+` `+l)}else a!==""&&sn("WebGLProgram: Program Info Log:",a)}}_completeCompile(e,t){const{state:r,gl:i}=this,s=this.get(t),{programGPU:a,fragmentShader:o,vertexShader:l}=s;i.getProgramParameter(a,i.LINK_STATUS)===!1&&this._logProgramError(a,o,l),r.useProgram(a);const c=e.getBindings();this._setupBindings(c,a),this.set(t,{programGPU:a,pipeline:a})}createComputePipeline(e,t){const{state:r,gl:i}=this,s={stage:"fragment",code:`#version 300 es precision highp float; void main() {}`};this.createProgram(s);const{computeProgram:a}=e,o=i.createProgram(),l=this.get(s).shaderGPU,c=this.get(a).shaderGPU,u=a.transforms,d=[],h=[];for(let _=0;_lue[i]===e),r=this.extensions;for(let i=0;i1,p=s.isXRRenderTarget===!0,g=p===!0&&s._hasExternalTextures===!0;let x=a.msaaFrameBuffer,_=a.depthRenderbuffer;const y=this.extensions.get("WEBGL_multisampled_render_to_texture"),M=this.extensions.get("OVR_multiview2"),C=this._useMultisampledExtension(s),k=E3e(e);let B;if(u?(a.cubeFramebuffers||(a.cubeFramebuffers={}),B=a.cubeFramebuffers[k]):p&&g===!1?B=this._xrFramebuffer:(a.framebuffers||(a.framebuffers={}),B=a.framebuffers[k]),B===void 0){B=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,B);const U=e.textures,z=[];if(u){a.cubeFramebuffers[k]=B;const{textureGPU:V}=this.get(U[0]),$=this.renderer._activeCubeFace,G=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+$,V,G)}else{a.framebuffers[k]=B;for(let V=0;V0&&C===!1&&!s.multiview){if(x===void 0){const U=[];x=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,x);const z=[],O=e.textures;for(let V=0;V0&&this._useMultisampledExtension(i)===!1){const a=s.framebuffers[e.getCacheKey()];let o=t.COLOR_BUFFER_BIT;i.resolveDepthBuffer&&(i.depthBuffer&&(o|=t.DEPTH_BUFFER_BIT),i.stencilBuffer&&i.resolveStencilBuffer&&(o|=t.STENCIL_BUFFER_BIT));const l=s.msaaFrameBuffer,c=s.msaaRenderbuffers,u=e.textures,d=u.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,l),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),d)for(let h=0;h0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const z5={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list"},dm=typeof self<"u"&&self.GPUShaderStage?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},ru={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},Sd={Store:"store"},Zs={Load:"load",Clear:"clear"},uue={CCW:"ccw",CW:"cw"},due={None:"none",Back:"back"},ZC={Uint16:"uint16",Uint32:"uint32"},St={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R16Unorm:"r16unorm",R16Snorm:"r16snorm",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RG16Unorm:"rg16unorm",RG16Snorm:"rg16snorm",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10UFloat:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA16Unorm:"rgba16unorm",RGBA16Snorm:"rgba16snorm",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-unorm-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},lB={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},Rf={Linear:"linear",Nearest:"nearest"},is={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},X2={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},hue={None:0,All:15},R1={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},cB={Storage:"storage",ReadOnlyStorage:"read-only-storage"},uB={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},fue={NonFiltering:"non-filtering",Comparison:"comparison"},Y2={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},pue={TwoD:"2d",ThreeD:"3d"},fu={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},_gt={All:"all"},sE={Vertex:"vertex",Instance:"instance"},QC={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},mue={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class wgt extends jwe{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class Sgt extends kwe{constructor(e,t){super(e,t?t.array:null),this._attribute=t,this.isStorageBuffer=!0}get attribute(){return this._attribute}}let Tgt=0;class Egt extends Sgt{constructor(e,t){super("StorageBuffer_"+Tgt++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Au.READ_WRITE,this.groupNode=t}get attribute(){return this.nodeUniform.value}get buffer(){return this.nodeUniform.value.array}}const dB=[null];class Ngt{constructor(e){this.backend=e,this._preferredCanvasFormat=null}getCurrentDepthStencilFormat(e){let t;return e.depth&&(e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.stencil?this.backend.renderer.reversedDepthBuffer===!0?t=St.Depth32FloatStencil8:t=St.Depth24PlusStencil8:this.backend.renderer.reversedDepthBuffer===!0?t=St.Depth32Float:t=St.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const s=this.backend.renderer,a=s.getRenderTarget();t=a?a.samples:s.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=this.getSampleCount(t||1);const r=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return e.textures!==null?e.textures.map(t=>this.getTextureFormatGPU(t)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return z5.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return z5.LineList;if(e.isLine)return z5.LineStrip;if(e.isMesh)return z5.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const t=this.backend.parameters.outputType;if(t===void 0)return this._preferredCanvasFormat===null&&(this._preferredCanvasFormat=navigator.gpu.getPreferredCanvasFormat()),this._preferredCanvasFormat;if(t===ma)return St.BGRA8Unorm;if(t===ba)return St.RGBA16Float;throw new Error("THREE.WebGPUUtils: Unsupported output buffer type.")}}function Gp(n,e){dB[0]=e,n.queue.submit(dB),dB[0]=null}class zwe{constructor(){this.label="",this.layout=null,this.entries=[]}reset(){this.label="",this.layout=null,this.entries.length=0}}class Z3{constructor(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}reset(){this.label="",this.size=0,this.usage=0,this.mappedAtCreation=!1}}class w6{constructor(){this.label=""}reset(){this.label=""}}class Vwe{constructor(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}reset(){this.label="",this.colorFormats=null,this.depthStencilFormat=void 0,this.sampleCount=1,this.depthReadOnly=!1,this.stencilReadOnly=!1}}class y4{constructor(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}reset(){this.view=null,this.depthSlice=void 0,this.resolveTarget=void 0,this.clearValue=void 0,this.loadOp=void 0,this.storeOp=void 0}}class b4{constructor(){this.label="",this.colorAttachments=[],this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}reset(){this.label="",this.colorAttachments.length=0,this.depthStencilAttachment=void 0,this.occlusionQuerySet=void 0,this.timestampWrites=void 0,this.maxDrawCount=5e7}}class qwe{constructor(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample=new Mgt,this.fragment=null}reset(){this.label="",this.layout=null,this.vertex=null,this.primitive={},this.depthStencil=void 0,this.multisample.reset(),this.fragment=null}}class Mgt{constructor(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}reset(){this.count=1,this.mask=4294967295,this.alphaToCoverageEnabled=!1}}class Gwe{constructor(){this.label="",this.code="",this.compilationHints=[]}reset(){this.label="",this.code="",this.compilationHints.length=0}}class AY{constructor(){this.label="",this.size={width:0,height:1,depthOrArrayLayers:1},this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats=[],this.textureBindingViewDimension=void 0}reset(){this.label="",this.size.width=0,this.size.height=1,this.size.depthOrArrayLayers=1,this.mipLevelCount=1,this.sampleCount=1,this.dimension="2d",this.format=void 0,this.usage=void 0,this.viewFormats.length=0,this.textureBindingViewDimension=void 0}}class xY{constructor(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}reset(){this.label="",this.format=void 0,this.dimension=void 0,this.usage=0,this.aspect="all",this.baseMipLevel=0,this.mipLevelCount=void 0,this.baseArrayLayer=0,this.arrayLayerCount=void 0,this.swizzle="rgba"}}const L1=new zwe,k1=new Z3,aE=new w6,hB=new Vwe,fB=new b4,fb=new qwe,t5=new y4,oE=new Gwe,pb=new AY,ol=new xY;class Cgt extends u2{constructor(e){super(),this.device=e;const t=` struct VarysStruct { @builtin( position ) Position: vec4f, @location( 0 ) vTex : vec2f, @location( 1 ) @interpolate(flat, either) vBaseArrayLayer: u32, }; @group( 0 ) @binding ( 2 ) var flipY: u32; @vertex fn mainVS( @builtin( vertex_index ) vertexIndex : u32, @builtin( instance_index ) instanceIndex : u32 ) -> VarysStruct { var Varys : VarysStruct; var pos = array( vec2f( -1, -1 ), vec2f( -1, 3 ), vec2f( 3, -1 ), ); let p = pos[ vertexIndex ]; let mult = select( vec2f( 0.5, -0.5 ), vec2f( 0.5, 0.5 ), flipY != 0 ); Varys.vTex = p * mult + vec2f( 0.5 ); Varys.Position = vec4f( p, 0, 1 ); Varys.vBaseArrayLayer = instanceIndex; return Varys; } @group( 0 ) @binding( 0 ) var imgSampler : sampler; @group( 0 ) @binding( 1 ) var img2d : texture_2d; @fragment fn main_2d( Varys: VarysStruct ) -> @location( 0 ) vec4 { return textureSample( img2d, imgSampler, Varys.vTex ); } @group( 0 ) @binding( 1 ) var img2dArray : texture_2d_array; @fragment fn main_2d_array( Varys: VarysStruct ) -> @location( 0 ) vec4 { return textureSample( img2dArray, imgSampler, Varys.vTex, Varys.vBaseArrayLayer ); } const faceMat = array( mat3x3f( 0, 0, -2, 0, -2, 0, 1, 1, 1 ), // pos-x mat3x3f( 0, 0, 2, 0, -2, 0, -1, 1, -1 ), // neg-x mat3x3f( 2, 0, 0, 0, 0, 2, -1, 1, -1 ), // pos-y mat3x3f( 2, 0, 0, 0, 0, -2, -1, -1, 1 ), // neg-y mat3x3f( 2, 0, 0, 0, -2, 0, -1, 1, 1 ), // pos-z mat3x3f( -2, 0, 0, 0, -2, 0, 1, 1, -1 ), // neg-z ); @group( 0 ) @binding( 1 ) var imgCube : texture_cube; @fragment fn main_cube( Varys: VarysStruct ) -> @location( 0 ) vec4 { return textureSample( imgCube, imgSampler, faceMat[ Varys.vBaseArrayLayer ] * vec3f( fract( Varys.vTex ), 1 ) ); } `;this.mipmapSampler=e.createSampler({minFilter:Rf.Linear}),this.flipYSampler=e.createSampler({minFilter:Rf.Nearest}),k1.size=4,k1.usage=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,this.flipUniformBuffer=e.createBuffer(k1),k1.reset(),e.queue.writeBuffer(this.flipUniformBuffer,0,new Uint32Array([1])),k1.size=4,k1.usage=GPUBufferUsage.UNIFORM,this.noFlipUniformBuffer=e.createBuffer(k1),k1.reset(),this.transferPipelines={},oE.label="mipmap",oE.code=t,this.mipmapShaderModule=e.createShaderModule(oE),oE.reset()}getTransferPipeline(e,t){t=t||"2d-array";const r=`${e}-${t}`;let i=this.transferPipelines[r];return i===void 0&&(fb.label=`mipmap-${e}-${t}`,fb.vertex={module:this.mipmapShaderModule},fb.fragment={module:this.mipmapShaderModule,entryPoint:`main_${t.replace("-","_")}`,targets:[{format:e}]},fb.layout="auto",i=this.device.createRenderPipeline(fb),fb.reset(),this.transferPipelines[r]=i),i}flipY(e,t,r=0){const i=t.format,{width:s,height:a}=t.size;pb.size.width=s,pb.size.height=a,pb.format=i,pb.usage=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING;const o=this.device.createTexture(pb);pb.reset();const l=this.getTransferPipeline(i,e.textureBindingViewDimension),c=this.getTransferPipeline(i,o.textureBindingViewDimension),u=this.device.createCommandEncoder(aE),d=(h,p,g,x,_,y)=>{const M=h.getBindGroupLayout(0);ol.dimension=p.textureBindingViewDimension||"2d-array",ol.mipLevelCount=1;const C=p.createView(ol);ol.reset(),L1.layout=M,L1.entries.push({binding:0,resource:this.flipYSampler},{binding:1,resource:C},{binding:2,resource:{buffer:y?this.flipUniformBuffer:this.noFlipUniformBuffer}});const k=this.device.createBindGroup(L1);L1.reset(),ol.dimension="2d",ol.mipLevelCount=1,ol.baseArrayLayer=_,ol.arrayLayerCount=1;const B=x.createView(ol);ol.reset(),t5.view=B,t5.loadOp=Zs.Clear,t5.storeOp=Sd.Store,fB.colorAttachments.push(t5);const U=u.beginRenderPass(fB);fB.reset(),t5.reset(),U.setPipeline(h),U.setBindGroup(0,k),U.draw(3,1,0,g),U.end()};d(l,e,r,o,0,!1),d(c,o,0,e,r,!0),Gp(this.device,u.finish()),o.destroy()}generateMipmaps(e,t=null){const r=this.get(e),i=r.layers||this._mipmapCreateBundles(e);let s=t;s===null&&(aE.label="mipmapEncoder",s=this.device.createCommandEncoder(aE),aE.reset()),this._mipmapRunBundles(s,i),t===null&&Gp(this.device,s.finish()),r.layers=i}_mipmapCreateBundles(e){const t=e.textureBindingViewDimension||"2d-array",r=this.getTransferPipeline(e.format,t),i=r.getBindGroupLayout(0),s=[];for(let a=1;a0)for(let a=0,o=i.length;a0){for(const a of e.layerUpdates)this._copyBufferToTexture(t.image,r.texture,s,a,e.flipY,a);e.clearLayerUpdates()}else for(let a=0;a0?(this._copyCompressedBufferToTexture(e.mipmaps,r.texture,s,e.layerUpdates),e.clearLayerUpdates()):this._copyCompressedBufferToTexture(e.mipmaps,r.texture,s);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,s);else if(e.isHTMLTexture){const a=this.backend.device,o=this.backend.renderer.domElement,l=e.image;if(typeof a.queue.copyElementImageToTexture!="function")return;if(!r.hasPaintCallback){r.hasPaintCallback=!0,o.requestPaint();return}const c=s.size.width,u=s.size.height;a.queue.copyElementImageToTexture.length===2?a.queue.copyElementImageToTexture({source:l},{destination:{texture:r.texture},width:c,height:u}):a.queue.copyElementImageToTexture(l,c,u,{texture:r.texture}),e.flipY&&this._flipY(r.texture,s)}else if(i.length>0)for(let a=0,o=i.length;a0?e.width:r.size.width,u=o>0?e.height:r.size.height;uE.source=e,uE.flipY=s,mb.texture=t,mb.mipLevel=o,mb.origin.z=i,mb.premultipliedAlpha=a,Xu.width=c,Xu.height=u;try{l.queue.copyExternalImageToTexture(uE,mb,Xu)}catch{}finally{uE.reset(),mb.reset(),Xu.reset()}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new Cgt(this.backend.device)),e}_generateMipmaps(e,t=null){this._getPassUtils().generateMipmaps(e,t)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,i,s,a=0,o=0){const l=this.backend.device,c=e.data,u=this._getBytesPerTexel(r.format),d=e.width*u;Zu.texture=t,Zu.mipLevel=o,Zu.origin.z=i,ng.offset=e.width*e.height*u*a,ng.bytesPerRow=d,Xu.width=e.width,Xu.height=e.height,l.queue.writeTexture(Zu,c,ng,Xu),Zu.reset(),ng.reset(),Xu.reset(),s===!0&&this._flipY(t,r,i)}_copyCompressedBufferToTexture(e,t,r,i=null){const s=this.backend.device,a=this._getBlockData(r.format),o=r.size.depthOrArrayLayers>1,l=i&&i.size>0?i:null;for(let c=0;c]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,Ugt=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,Aue={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"},zgt=n=>{n=n.trim();const e=n.match(Bgt);if(e!==null&&e.length===4){const t=e[2],r=[];let i=null;for(;(i=Ugt.exec(t))!==null;)r.push({name:i[1],type:i[2]});const s=[];for(let u=0;u "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class qgt extends Cwe{parseFunction(e){return new Vgt(e)}}const Ggt={[Au.READ_ONLY]:"read",[Au.WRITE_ONLY]:"write",[Au.READ_WRITE]:"read_write"},xue={[Fg]:"repeat",[uc]:"clamp",[Bg]:"mirror"},pB={vertex:dm.VERTEX,fragment:dm.FRAGMENT,compute:dm.COMPUTE},vue={instance:!0,swizzleAssign:!1,storageBuffer:!0},Hgt={"^^":"tsl_xor"},$gt={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",mat3:"mat3x3",mat4:"mat4x4"},yue={},n5={tsl_xor:new Va("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Va("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Va("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Va("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Va("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Va("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Va("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Va("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Va("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Va("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Va("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Va("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),inverse_mat2:new Va(` fn tsl_inverse_mat2( m : mat2x2 ) -> mat2x2 { let det = m[ 0 ][ 0 ] * m[ 1 ][ 1 ] - m[ 0 ][ 1 ] * m[ 1 ][ 0 ]; return mat2x2( m[ 1 ][ 1 ], - m[ 0 ][ 1 ], - m[ 1 ][ 0 ], m[ 0 ][ 0 ] ) * ( 1.0 / det ); } `),inverse_mat3:new Va(` fn tsl_inverse_mat3( m : mat3x3 ) -> mat3x3 { let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let b01 = a22 * a11 - a12 * a21; let b11 = - a22 * a10 + a12 * a20; let b21 = a21 * a10 - a11 * a20; let det = a00 * b01 + a01 * b11 + a02 * b21; return mat3x3( b01, ( - a22 * a01 + a02 * a21 ), ( a12 * a01 - a02 * a11 ), b11, ( a22 * a00 - a02 * a20 ), ( - a12 * a00 + a02 * a10 ), b21, ( - a21 * a00 + a01 * a20 ), ( a11 * a00 - a01 * a10 ) ) * ( 1.0 / det ); } `),inverse_mat4:new Va(` fn tsl_inverse_mat4( m : mat4x4 ) -> mat4x4 { let a00 = m[ 0 ][ 0 ]; let a01 = m[ 0 ][ 1 ]; let a02 = m[ 0 ][ 2 ]; let a03 = m[ 0 ][ 3 ]; let a10 = m[ 1 ][ 0 ]; let a11 = m[ 1 ][ 1 ]; let a12 = m[ 1 ][ 2 ]; let a13 = m[ 1 ][ 3 ]; let a20 = m[ 2 ][ 0 ]; let a21 = m[ 2 ][ 1 ]; let a22 = m[ 2 ][ 2 ]; let a23 = m[ 2 ][ 3 ]; let a30 = m[ 3 ][ 0 ]; let a31 = m[ 3 ][ 1 ]; let a32 = m[ 3 ][ 2 ]; let a33 = m[ 3 ][ 3 ]; let b00 = a00 * a11 - a01 * a10; let b01 = a00 * a12 - a02 * a10; let b02 = a00 * a13 - a03 * a10; let b03 = a01 * a12 - a02 * a11; let b04 = a01 * a13 - a03 * a11; let b05 = a02 * a13 - a03 * a12; let b06 = a20 * a31 - a21 * a30; let b07 = a20 * a32 - a22 * a30; let b08 = a20 * a33 - a23 * a30; let b09 = a21 * a32 - a22 * a31; let b10 = a21 * a33 - a23 * a31; let b11 = a22 * a33 - a23 * a32; let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; return mat4x4( a11 * b11 - a12 * b10 + a13 * b09, a02 * b10 - a01 * b11 - a03 * b09, a31 * b05 - a32 * b04 + a33 * b03, a22 * b04 - a21 * b05 - a23 * b03, a12 * b08 - a10 * b11 - a13 * b07, a00 * b11 - a02 * b08 + a03 * b07, a32 * b02 - a30 * b05 - a33 * b01, a20 * b05 - a22 * b02 + a23 * b01, a10 * b10 - a11 * b08 + a13 * b06, a01 * b08 - a00 * b10 - a03 * b06, a30 * b04 - a31 * b02 + a33 * b00, a21 * b02 - a20 * b04 - a23 * b00, a11 * b07 - a10 * b09 - a12 * b06, a00 * b09 - a01 * b07 + a02 * b06, a31 * b01 - a30 * b03 - a32 * b00, a20 * b03 - a21 * b01 + a22 * b00 ) * ( 1.0 / det ); } `),biquadraticTexture:new Va(` fn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f { let res = vec2f( iRes ); let uvScaled = coord * res; let uvWrapping = ( ( uvScaled % res ) + res ) % res; // https://www.shadertoy.com/view/WtyXRy let uv = uvWrapping - 0.5; let iuv = floor( uv ); let f = fract( uv ); let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level ); let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level ); let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level ); let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level ); return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); } `),biquadraticTextureArray:new Va(` fn tsl_biquadraticTexture_array( map : texture_2d_array, coord : vec2f, iRes : vec2u, layer : u32, level : u32 ) -> vec4f { let res = vec2f( iRes ); let uvScaled = coord * res; let uvWrapping = ( ( uvScaled % res ) + res ) % res; // https://www.shadertoy.com/view/WtyXRy let uv = uvWrapping - 0.5; let iuv = floor( uv ); let f = fract( uv ); let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, layer, level ); let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, layer, level ); let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, layer, level ); let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, layer, level ); return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y ); } `)},Wgt={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inverse_mat2:"tsl_inverse_mat2",inverse_mat3:"tsl_inverse_mat3",inverse_mat4:"tsl_inverse_mat4",inversesqrt:"inverseSqrt",bitcast:"bitcast",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let $we="";(typeof navigator<"u"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&($we+=`diagnostic( off, derivative_uniformity ); `);class Xgt extends Mwe{constructor(e,t){super(e,t,new qgt),this.uniformGroups={},this.uniformGroupsBindings={},this.builtins={},this.directives={},this.scopedArrays=new Map,this.allowEarlyReturns=!0,this.allowGlobalVariables=!0}_generateTextureSample(e,t,r,i,s,a=this.shaderStage){return a==="fragment"?i?s?`textureSample( ${t}, ${t}_sampler, ${r}, ${i}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${i} )`:s?`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",i)}generateTextureSampleLevel(e,t,r,i,s,a){return this.isUnfilterable(e)===!1?s?a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,a,i,s):this.generateTextureLod(e,t,r,s,a,i)}generateWrapFunction(e){const t=`tsl_coord_${xue[e.wrapS]}S_${xue[e.wrapT]}T_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}`;let r=yue[t];if(r===void 0){const i=[],s=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${s} ) -> ${s} { return ${s}( `;const o=(l,c)=>{l===Fg?(i.push(n5.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${c} )`):l===uc?(i.push(n5.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${c} )`):l===Bg?(i.push(n5.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${c} )`):(a+=` coord.${c}`,sn(`WebGPURenderer: Unsupported texture wrap type "${l}" for vertex shader.`))};o(e.wrapS,"x"),a+=`, `,o(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(a+=`, `,o(e.wrapR,"z")),a+=` ); } `,yue[t]=r=new Va(a,i)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const i=this.getDataFromNode(e,this.shaderStage,this.cache);i.dimensionsSnippet===void 0&&(i.dimensionsSnippet={});let s=i.dimensionsSnippet[r];if(i.dimensionsSnippet[r]===void 0){let a,o;const{primarySamples:l}=this.renderer.backend.utils.getTextureSampleData(e),c=l>1;e.is3DTexture||e.isData3DTexture?o="vec3":o="vec2",c||e.isStorageTexture?a=t:a=`${t}${r?`, u32( ${r} )`:""}`,s=new TN(new EN(`textureDimensions( ${a} )`,o)),i.dimensionsSnippet[r]=s,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(i.arrayLayerCount=new TN(new EN(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(i.cubeFaceCount=new TN(new EN("6u","u32")))}return s.build(this)}generateFilteredTexture(e,t,r,i,s="0u",a){const o=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,s);return i&&(r=`${r} + vec2(${i}) / ${l}`),a?(this._include("biquadraticTextureArray"),`tsl_biquadraticTexture_array( ${t}, ${o}( ${r} ), ${l}, u32( ${a} ), u32( ${s} ) )`):(this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${o}( ${r} ), ${l}, u32( ${s} ) )`)}generateTextureLod(e,t,r,i,s,a="0u"){if(e.isCubeTexture===!0){s&&(r=`${r} + vec3(${s})`);const p=e.isDepthTexture?"u32":"f32";return`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${p}( ${a} ) )`}const o=this.generateWrapFunction(e),l=this.generateTextureDimension(e,t,a),c=e.is3DTexture||e.isData3DTexture?"vec3":"vec2",u=c==="vec3"?"vec3( 1, 1, 1 )":"vec2( 1, 1 )";s&&(r=`${r} + ${c}(${s}) / ${c}( ${l} )`);const d=`${c}( 0 )`,h=`${c}( ${l} - ${u} )`;return r=`${c}( clamp( floor( ${o}( ${r} ) * ${c}( ${l} ) ), ${d}, ${h} ) )`,this.generateTextureLoad(e,t,r,a,i,null)}generateStorageTextureLoad(e,t,r,i,s,a){a&&(r=`${r} + ${a}`);let o;return s?o=`textureLoad( ${t}, ${r}, ${s} )`:o=`textureLoad( ${t}, ${r} )`,o}generateTextureLoad(e,t,r,i,s,a){i===null&&(i="0u"),a&&(r=`${r} + ${a}`);let o;return s?o=`textureLoad( ${t}, ${r}, ${s}, u32( ${i} ) )`:(o=`textureLoad( ${t}, ${r}, u32( ${i} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(o+=".x")),o}generateTextureStore(e,t,r,i,s){let a;return i?a=`textureStore( ${t}, ${r}, ${i}, ${s} )`:a=`textureStore( ${t}, ${r}, ${s} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null&&this.renderer.hasCompatibility(n2.TEXTURE_COMPARE)}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.type===ea||this.isSampleCompare(e)===!1&&e.minFilter===Ss&&e.magFilter===Ss||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,i,s,a=this.shaderStage){let o=null;return this.isUnfilterable(e)?o=this.generateTextureLod(e,t,r,i,s,"0",a):o=this._generateTextureSample(e,t,r,i,s,a),o}generateTextureGrad(e,t,r,i,s,a,o=this.shaderStage){if(o==="fragment")return s?a?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s}, ${i[0]}, ${i[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s}, ${i[0]}, ${i[1]} )`:a?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i[0]}, ${i[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${i[0]}, ${i[1]} )`;on(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${o} shader.`)}generateTextureCompare(e,t,r,i,s,a,o=this.shaderStage){if(o==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${i} )`;on(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${o} shader.`)}generateTextureGather(e,t,r,i,s,a){const o=e.isDepthTexture===!0?"":`${i}, `;return s?a?`textureGather( ${o}${t}, ${t}_sampler, ${r}, ${s}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${r}, ${s} )`:a?`textureGather( ${o}${t}, ${t}_sampler, ${r}, ${a} )`:`textureGather( ${o}${t}, ${t}_sampler, ${r})`}generateTextureGatherCompare(e,t,r,i,s,a){return s?a?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${i})`:a?`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureGatherCompare( ${t}, ${t}_sampler, ${r}, ${i})`}generateTextureLevel(e,t,r,i,s,a){return this.isUnfilterable(e)===!1?s?a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:a?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,a,i,s):this.generateTextureLod(e,t,r,s,a,i)}generateTextureBias(e,t,r,i,s,a,o=this.shaderStage){if(o==="fragment")return s?a?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${i}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${i} )`:a?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${i} )`;on(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${o} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const r=e.name,i=e.type;return i==="texture"||i==="cubeTexture"||i==="cubeDepthTexture"||i==="storageTexture"||i==="texture3D"?r:i==="buffer"||i==="storageBuffer"||i==="indirectStorageBuffer"?this.isCustomStruct(e)?r:r+".value":e.groupNode.name+"."+r}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=Hgt[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(sn("WebGPURenderer: Atomic operations are only supported in compute shaders."),Au.READ_WRITE):Au.READ_ONLY:e.access}getStorageAccess(e,t){return Ggt[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,i=null){const s=super.getUniformFromNode(e,t,r,i),a=this.getDataFromNode(e,r,this.globalCache);if(a.uniformGPU===void 0){let o;const l=e.groupNode,c=l.name,u=this.getBindGroupArray(c,r);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let d=null;const h=this.getNodeAccess(e,r);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?d=new fq(s.name,s.node,l,h):d=new XR(s.name,s.node,l,h):t==="cubeTexture"||t==="cubeDepthTexture"?d=new Fwe(s.name,s.node,l,h):t==="texture3D"&&(d=new fq(s.name,s.node,l,h)),d.store=e.isStorageTextureNode===!0,d.mipLevel=d.store?e.mipLevel:0,d.setVisibility(pB[r]),e.value.isCubeTexture===!0||this.isUnfilterable(e.value)===!1&&d.store===!1||e.gatherNode!==null){const g=new wgt(`${s.name}_sampler`,s.node,l);g.setVisibility(pB[r]),u.push(g,d),o=[g,d]}else u.push(d),o=[d]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const d=this.getSharedDataFromNode(e);let h=d.buffer;if(h===void 0){const p=t==="buffer"?Dwe:Egt;h=new p(e,l),d.buffer=h}h.setVisibility(h.getVisibility()|pB[r]),u.push(h),o=h,s.name=i||"NodeBuffer_"+s.id}else{let d=this.uniformGroups[c];d===void 0&&(d=new Owe(c,l),d.setVisibility(dm.VERTEX|dm.FRAGMENT|dm.COMPUTE),this.uniformGroups[c]=d),u.indexOf(d)===-1&&u.push(d),o=this.getNodeUniform(s,t);const h=o.name;d.uniforms.some(g=>g.name===h)||d.addUniform(o)}a.uniformGPU=o}return s}getBuiltin(e,t,r,i=this.shaderStage){const s=this.builtins[i]||(this.builtins[i]=new Map);return s.has(e)===!1&&s.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),i=[];for(const a of t.inputs)i.push(a.name+" : "+this.getType(a.type));let s=`fn ${t.name}( ${i.join(", ")} ) -> ${this.getType(t.type)} { ${r.vars} ${r.code} `;return r.result&&(s+=` return ${r.result}; `),s+=` } `,s}getInstanceIndex(){return this.shaderStage==="vertex"?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(r!==void 0)for(const i of r)t.push(`enable ${i};`);return t.join(` `)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(r!==void 0)for(const{name:i,property:s,type:a}of r.values())t.push(`@builtin( ${i} ) ${s} : ${a}`);return t.join(`, `)}getScopedArray(e,t,r,i){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:i}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:r,scope:i,bufferType:s,bufferCount:a}of this.scopedArrays.values()){const o=this.getType(s);t.push(`var<${i}> ${r}: array< ${o}, ${a} >;`)}return t.join(` `)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const r=this.getBuiltins("attribute");r&&t.push(r);const i=this.getAttributesArray();for(let s=0,a=i.length;s"),t.push(` ${i+r.name} : ${s}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`, `)}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const i=[];for(const s of r){let a=`struct ${s.name} { `;a+=this.getStructMembers(s),a+=` };`,i.push(a)}t=` `+i.join(` `)+` `}return t}getVar(e,t,r=null,i=""){let s=`var${i} ${t} : `;return r!==null?s+=this.generateArrayDeclaration(e,r):s+=this.getType(e),s}getVars(e,t=!1){let r="";t&&(r="");const i=[],s=this.vars[e];if(s!==void 0)for(const a of s)i.push(`${this.getVar(a.type,a.name,a.count,r)};`);return t?i.join(` `):` ${i.join(` `)} `}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","builtinClipSpace","vec4","vertex"),e==="vertex"||e==="fragment"){const s=this.varyings,a=this.vars[e];let o=0;for(let l=0;lr.value.itemSize;return i&&!s}getUniforms(e){const t=this.renderer.backend,r=this.uniforms[e],i=[],s=[],a=[],o={};for(const c of r){const u=c.groupNode.name,d=this.bindingsIndexes[u];if(c.type==="texture"||c.type==="cubeTexture"||c.type==="cubeDepthTexture"||c.type==="storageTexture"||c.type==="texture3D"){const h=c.node,p=h.value;(p.isCubeTexture===!0||this.isUnfilterable(p)===!1&&h.isStorageTextureNode!==!0||h.gatherNode!==null)&&(this.isSampleCompare(p)&&h.compareNode!==null?i.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${c.name}_sampler : sampler_comparison;`):i.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${c.name}_sampler : sampler;`));let x,_="";const{primarySamples:y}=t.utils.getTextureSampleData(p);if(y>1&&(_="_multisampled"),p.isCubeTexture===!0&&p.isDepthTexture===!0)x="texture_depth_cube";else if(p.isCubeTexture===!0)x="texture_cube";else if(p.isDepthTexture===!0)t.compatibilityMode&&p.compareFunction===null?x=`texture${_}_2d`:x=`texture_depth${_}_2d${p.isArrayTexture===!0?"_array":""}`;else if(c.node.isStorageTextureNode===!0){const M=pq(p,t.device),C=this.getStorageAccess(c.node,e),k=c.node.value.is3DTexture,B=c.node.value.isArrayTexture;x=`texture_storage_${k?"3d":`2d${B?"_array":""}`}<${M}, ${C}>`}else if(p.isArrayTexture===!0||p.isDataArrayTexture===!0||p.isCompressedArrayTexture===!0)x="texture_2d_array";else if(p.is3DTexture===!0||p.isData3DTexture===!0)x="texture_3d";else{const M=this.getComponentTypeFromTexture(p).charAt(0);x=`texture${_}_2d<${M}32>`}i.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var ${c.name} : ${x};`)}else if(c.type==="buffer"||c.type==="storageBuffer"||c.type==="indirectStorageBuffer"){const h=c.node,p=this.getType(h.getNodeType(this)),g=h.bufferCount,x=g>0&&c.type==="buffer"?", "+g:"",_=h.isStorageBufferNode?`storage, ${this.getStorageAccess(h,e)}`:"uniform";if(this.isCustomStruct(c))s.push(`@binding( ${d.binding++} ) @group( ${d.group} ) var<${_}> ${c.name} : ${p};`);else{const M=` value : array< ${h.isAtomic?`atomic<${p}>`:`${p}`}${x} >`;s.push(this._getWGSLStructBinding(c.name,M,_,d.binding++,d.group))}}else{const h=c.groupNode.name;if(o[h]===void 0){const p=this.uniformGroups[h];if(p!==void 0){const g=[];for(const _ of p.uniforms){const y=_.getType(),M=this.getType(this.getVectorType(y));g.push(` ${_.name} : ${M}`)}let x=this.uniformGroupsBindings[h];x===void 0&&(x={index:d.binding++,id:d.group},this.uniformGroupsBindings[h]=x),o[h]={index:x.index,id:x.id,snippets:g}}}}}for(const c in o){const u=o[c];a.push(this._getWGSLStructBinding(c,u.snippets.join(`, `),"uniform",u.index,u.id))}return[...i,...s,...a].join(` `)}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=this.allowGlobalVariables,i=e[t];i.uniforms=this.getUniforms(t),i.attributes=this.getAttributes(t),i.varyings=this.getVaryings(t),i.structs=this.getStructs(t),i.vars=this.getVars(t,r),i.codes=this.getCodes(t),i.directives=this.getDirectives(t),i.scopedArrays=this.getScopedArrays(t);let s=`// code `;s+=this.flowCode[t];const a=this.flowNodes[t],o=a[a.length-1],l=o.outputNode,c=l!==void 0&&l.isOutputStructNode===!0;for(const u of a){const d=this.getFlowData(u),h=u.name;if(h&&(s.length>0&&(s+=` `),s+=` // flow -> ${h} `),s+=`${d.code} `,u===o&&t!=="compute"){if(s+=`// result `,t==="vertex")s+=`varyings.builtinClipSpace = ${d.result};`;else if(t==="fragment")if(c)i.returnType=l.getNodeType(this),i.structs+="var output : "+i.returnType+";",s+=`return ${d.result};`;else{let p=` @location( 0 ) color: ${this.getType(this.getOutputType())}`;const g=this.getBuiltins("output");g&&(p+=`, `+g),i.returnType="OutputStruct",i.structs+=this._getWGSLStruct("OutputStruct",p),i.structs+=` var output : OutputStruct;`,s+=`output.color = ${this.format(d.result,o.getNodeType(this),this.getOutputType())}; return output;`}}}i.flow=s}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return t!==null&&(r=this._getWGSLMethod(e+"_"+t)),r===void 0&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return $gt[e]||e}isAvailable(e){let t=vue[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),vue[e]=t),t}_getWGSLMethod(e){return n5[e]!==void 0&&this._include(e),Wgt[e]}_include(e){const t=n5[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()} // directives ${e.directives} // structs ${e.structs} // uniforms ${e.uniforms} // varyings ${e.varyings} var varyings : VaryingsStruct; // vars ${e.vars} // codes ${e.codes} @vertex fn main( ${e.attributes} ) -> VaryingsStruct { // flow ${e.flow} return varyings; } `}_getWGSLFragmentCode(e){return`${this.getSignature()} // global ${$we} // structs ${e.structs} // uniforms ${e.uniforms} // vars ${e.vars} // codes ${e.codes} @fragment fn main( ${e.varyings} ) -> ${e.returnType} { // flow ${e.flow} } `}_getWGSLComputeCode(e,t){const[r,i,s]=t;return`${this.getSignature()} // directives ${e.directives} // system var instanceIndex : u32; // locals ${e.scopedArrays} // structs ${e.structs} // uniforms ${e.uniforms} // vars ${this.allowGlobalVariables?e.vars:""} // codes ${e.codes} @compute @workgroup_size( ${r}, ${i}, ${s} ) fn main( ${e.attributes} ) { // local vars ${this.allowGlobalVariables?"":e.vars} // system instanceIndex = globalId.x + globalId.y * ( ${r} * numWorkgroups.x ) + globalId.z * ( ${r} * numWorkgroups.x ) * ( ${i} * numWorkgroups.y ); // flow ${e.flow} } `}_getWGSLStruct(e,t){return` struct ${e} { ${t} };`}_getWGSLStructBinding(e,t,r,i=0,s=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)} @binding( ${i} ) @group( ${s} ) var<${r}> ${e} : ${a};`}}const Wu=new Z3,mB=new w6,Wwe=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array<"u"&&Wwe.set(Float16Array,["float16"]);const Ygt=new Map([[C$,["float16"]]]),Zgt=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class Qgt{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),i=this.backend,s=i.get(r);let a=s.buffer;if(a===void 0){const o=i.device;let l=r.array;if(e.normalized===!1){if(l.constructor===Int16Array||l.constructor===Int8Array)l=new Int32Array(l);else if((l.constructor===Uint16Array||l.constructor===Uint8Array)&&(l=new Uint32Array(l),t&GPUBufferUsage.INDEX))for(let h=0;h1&&r.itemSize*l.BYTES_PER_ELEMENT%4!==0){const h=r.itemSize*l.BYTES_PER_ELEMENT;c=Math.floor((h+3)/4)*4/l.BYTES_PER_ELEMENT}if(c!==void 0){const h=r.itemSize,p=new l.constructor(r.count*c);for(let g=0;g1&&d%4!==0&&(d=Math.floor((d+3)/4)*4)),s.normalized===!1&&(s.array.constructor===Int16Array||s.array.constructor===Uint16Array)&&(d=4),l={arrayStride:d,attributes:[],stepMode:h},r.set(o,l)}const c=this._getVertexFormat(s),u=s.isInterleavedBufferAttribute===!0?s.offset*a:0;l.attributes.push({shaderLocation:i,offset:u,format:c})}return Array.from(r.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}async getArrayBufferAsync(e,t=null,r=0,i=-1){const s=this.backend,a=s.device,l=s.get(this._getBufferAttribute(e)).buffer,c=i===-1?l.size-r:i;let u;if(t!==null&&t.isReadbackBuffer){const p=s.get(t);if(t._mapped===!0)throw new Error("THREE.WebGPUAttributeUtils: ReadbackBuffer must be released before being used again.");if(t._mapped=!0,p.readBufferGPU===void 0){Wu.label=`${t.name}_readback`,Wu.size=t.maxByteLength,Wu.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,u=a.createBuffer(Wu),Wu.reset();const g=()=>{t.buffer=null,t._mapped=!1,u.unmap()},x=()=>{t.buffer=null,t._mapped=!1,u.destroy(),s.delete(t),t.removeEventListener("release",g),t.removeEventListener("dispose",x)};t.addEventListener("release",g),t.addEventListener("dispose",x),p.readBufferGPU=u}else u=p.readBufferGPU}else Wu.label=`${e.name}_readback`,Wu.size=c,Wu.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,u=a.createBuffer(Wu),Wu.reset();mB.label=`readback_encoder_${e.name}`;const d=a.createCommandEncoder(mB);mB.reset(),d.copyBufferToBuffer(l,r,u,0,c);const h=d.finish();if(Gp(a,h),await u.mapAsync(GPUMapMode.READ,0,c),t===null){const g=u.getMappedRange(0,c).slice();return u.destroy(),g}else{if(t.isReadbackBuffer)return t.buffer=u.getMappedRange(0,c),t;{const p=u.getMappedRange(0,c);return new Uint8Array(t).set(new Uint8Array(p)),u.destroy(),t}}}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,i=e.array.constructor,s=e.constructor;let a;if(t===1)a=Zgt.get(i);else{const l=(Ygt.get(s)||Wwe.get(i))[r?1:0];if(l){const c=i.BYTES_PER_ELEMENT*t,d=Math.floor((c+3)/4)*4/i.BYTES_PER_ELEMENT;if(d%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");a=`${l}x${d}`}}return a||on("WebGPUAttributeUtils: Vertex format not supported yet."),a}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}const kh=new zwe,r5=new Z3,gb=new xY;class Kgt{constructor(e){this.layoutGPU=e,this.usedTimes=0}}class Jgt{constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,r=t.device,i=t.get(e);if(i.layout)return i.layout.layoutGPU;const s=this._createLayoutEntries(e),a=G3(JSON.stringify(s));let o=this._bindGroupLayoutCache.get(a);return o===void 0&&(o=new Kgt(r.createBindGroupLayout({entries:s})),this._bindGroupLayoutCache.set(a,o)),o.usedTimes++,i.layout=o,i.layoutKey=a,o.layoutGPU}createBindings(e,t,r,i=0){const{backend:s}=this,a=s.get(e),o=this.createBindingsLayout(e);let l;r>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[r]===i&&(l=a.groups[r])),l===void 0&&(l=this.createBindGroup(e,o),r>0&&(a.groups[r]=l,a.versions[r]=i)),a.group=l}updateBinding(e){const t=this.backend,r=t.device,i=e.buffer,s=t.get(e).buffer,a=e.updateRanges;if(a.length===0)r.queue.writeBuffer(s,0,i,0);else{const o=n3(i),l=o?1:i.BYTES_PER_ELEMENT;let c=a[0].start;for(let u=0,d=a.length;u1&&(h+=`-${l.texture.depthOrArrayLayers}`),h+=`-${u}-${d}`,c=l[h],c===void 0){const p=_gt.All;let g;o.isSampledCubeTexture?g=fu.Cube:o.texture.isArrayTexture||o.texture.isDataArrayTexture||o.texture.isCompressedArrayTexture?g=fu.TwoDArray:o.isSampledTexture3D?g=fu.ThreeD:g=fu.TwoD,gb.aspect=p,gb.dimension=g,gb.mipLevelCount=u,gb.baseMipLevel=d,c=l[h]=l.texture.createView(gb),gb.reset()}}kh.entries.push({binding:s,resource:c})}else if(o.isSampler){const l=r.get(o);kh.entries.push({binding:s,resource:l.sampler})}s++}const a=i.createBindGroup(kh);return kh.reset(),a}_createLayoutEntries(e){const t=[];let r=0;for(const i of e.bindings){const s=this.backend,a={binding:r,visibility:i.visibility};if(i.isUniformBuffer||i.isStorageBuffer){const o={};i.isStorageBuffer&&(i.visibility&dm.COMPUTE&&(i.access===Au.READ_WRITE||i.access===Au.WRITE_ONLY)?o.type=cB.Storage:o.type=cB.ReadOnlyStorage),a.buffer=o}else if(i.isSampledTexture&&i.store){const o={};o.format=this.backend.get(i.texture).texture.format;const l=i.access;l===Au.READ_WRITE?o.access=uB.ReadWrite:l===Au.WRITE_ONLY?o.access=uB.WriteOnly:o.access=uB.ReadOnly,i.texture.isArrayTexture?o.viewDimension=fu.TwoDArray:i.texture.is3DTexture&&(o.viewDimension=fu.ThreeD),a.storageTexture=o}else if(i.isSampledTexture){const o={},{primarySamples:l}=s.utils.getTextureSampleData(i.texture);if(l>1&&(o.multisampled=!0,i.texture.isDepthTexture||(o.sampleType=Y2.UnfilterableFloat)),i.texture.isDepthTexture)s.compatibilityMode&&i.texture.compareFunction===null?o.sampleType=Y2.UnfilterableFloat:o.sampleType=Y2.Depth;else{const c=i.texture.type;c===ml?o.sampleType=Y2.SInt:c===xs?o.sampleType=Y2.UInt:c===ea&&(this.backend.hasFeature("float32-filterable")?o.sampleType=Y2.Float:o.sampleType=Y2.UnfilterableFloat)}i.isSampledCubeTexture?o.viewDimension=fu.Cube:i.texture.isArrayTexture||i.texture.isDataArrayTexture||i.texture.isCompressedArrayTexture?o.viewDimension=fu.TwoDArray:i.isSampledTexture3D&&(o.viewDimension=fu.ThreeD),a.texture=o}else if(i.isSampler){const o={};i.texture.isDepthTexture&&(i.texture.compareFunction!==null&&i.textureNode.compareNode!==null&&s.hasCompatibility(n2.TEXTURE_COMPARE)?o.type=fue.Comparison:o.type=fue.NonFiltering),a.sampler=o}else on(`WebGPUBindingUtils: Unsupported binding "${i}".`);t.push(a),r++}return t}deleteBindGroupData(e){const{backend:t}=this,r=t.get(e);r.layout&&(r.layout.usedTimes--,r.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(r.layoutKey),r.layout=void 0,r.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class e1t{constructor(e){this.backend=e}getMaxAnisotropy(){return 16}getUniformBufferLimit(){return this.backend.device.limits.maxUniformBufferBindingSize}}class t1t{constructor(){this.label="",this.layout=null,this.compute=null}reset(){this.label="",this.layout=null,this.compute=null}}class n1t{constructor(){this.label="",this.bindGroupLayouts=null}reset(){this.label="",this.bindGroupLayouts=null}}const i5=new t1t,Ab=new n1t,xb=new Vwe,Ih=new qwe;class r1t{constructor(e){this.backend=e}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:i,geometry:s,pipeline:a}=e,{vertexProgram:o,fragmentProgram:l}=a,c=this.backend,u=c.device,d=c.utils,h=c.get(a),p=[];for(const J of e.getBindings()){const ie=c.get(J),{layoutGPU:ae}=ie.layout;p.push(ae)}const g=c.attributeUtils.createShaderVertexBuffers(e);let x;i.blending!==Yl&&(i.blending!==ac||i.transparent!==!1)&&(x=this._getBlending(i));let _={};i.stencilWrite===!0&&(_={compare:this._getStencilCompare(i),failOp:this._getStencilOperation(i.stencilFail),depthFailOp:this._getStencilOperation(i.stencilZFail),passOp:this._getStencilOperation(i.stencilZPass)});const y=this._getColorWriteMask(i),M=[];if(e.context.textures!==null){const J=e.context.textures,ie=e.context.mrt;for(let ae=0;ae1,Ih.layout=V;const $={},G=e.context.depth,H=e.context.stencil;(G===!0||H===!0)&&(G===!0&&($.format=z,$.depthWriteEnabled=i.depthWrite,$.depthCompare=U),H===!0&&($.stencilFront=_,$.stencilBack=_,$.stencilReadMask=i.stencilFuncMask,$.stencilWriteMask=i.stencilWriteMask),i.polygonOffset===!0&&B.topology===z5.TriangleList&&($.depthBias=i.polygonOffsetUnits,$.depthBiasSlopeScale=i.polygonOffsetFactor,$.depthBiasClamp=0),Ih.depthStencil=$),u.pushErrorScope("validation");const K=[{program:o,module:C.module},{program:l,module:k.module}],W=Ih.label;if(t===null)h.pipeline=u.createRenderPipeline(Ih),Ih.reset(),u.popErrorScope().then(J=>{J!==null&&(h.error=!0,on(`WebGPURenderer: Render pipeline creation failed (${W}): ${J.message}`),this._reportShaderDiagnostics(K,W))});else{const J=new Promise(async ie=>{try{let ae=null,Q=null;try{Q=u.createRenderPipelineAsync(Ih)}catch(oe){ae=oe}if(Ih.reset(),Q!==null)try{h.pipeline=await Q}catch(oe){ae=oe}const re=await u.popErrorScope();if(re!==null||ae!==null){h.error=!0;const oe=re&&re.message||ae&&ae.message||"unknown";on(`WebGPURenderer: Async render pipeline creation failed (${W}): ${oe}`),await this._reportShaderDiagnostics(K,W)}}finally{ie()}});t.push(J)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:i,device:s}=r,a=i.getCurrentDepthStencilFormat(e),o=i.getCurrentColorFormats(e),l=this._getSampleCount(e);xb.label=t,xb.colorFormats=o,xb.depthStencilFormat=a,xb.sampleCount=l;const c=s.createRenderBundleEncoder(xb);return xb.reset(),c}createComputePipeline(e,t){const r=this.backend,i=r.device,s=r.get(e.computeProgram).module,a=r.get(e),o=[];for(const d of t){const h=r.get(d),{layoutGPU:p}=h.layout;o.push(p)}const l=e.computeProgram,c=`computePipeline_${l.stage}${l.name?`_${l.name}`:""}`;i.pushErrorScope("validation"),Ab.bindGroupLayouts=o;const u=i.createPipelineLayout(Ab);Ab.reset(),i5.label=c,i5.compute=s,i5.layout=u,a.pipeline=i.createComputePipeline(i5),i5.reset(),i.popErrorScope().then(d=>{d!==null&&(a.error=!0,on(`WebGPURenderer: Compute pipeline creation failed (${c}): ${d.message}`),this._reportShaderDiagnostics([{program:l,module:s.module}],c))})}async _reportShaderDiagnostics(e,t){for(const{program:r,module:i}of e){const s=await i.getCompilationInfo();if(s.messages.length===0)continue;const a=r.code.split(` `);for(const o of s.messages){const l=o.lineNum>0?` at line ${o.lineNum}${o.linePos>0?`:${o.linePos}`:""}`:"",c=`WebGPURenderer [${t} / ${r.stage} ${o.type}]${l}: ${o.message}`;let u="";o.lineNum>0&&o.lineNum<=a.length&&(u=` ${a[o.lineNum-1]}`,o.linePos>0&&(u+=` ${" ".repeat(o.linePos-1)}^`)),(o.type==="error"?on:sn)(c+u)}}}_getBlending(e){let t,r;const i=e.blending,s=e.blendSrc,a=e.blendDst,o=e.blendEquation;if(i===NA){const l=e.blendSrcAlpha!==null?e.blendSrcAlpha:s,c=e.blendDstAlpha!==null?e.blendDstAlpha:a,u=e.blendEquationAlpha!==null?e.blendEquationAlpha:o;t={srcFactor:this._getBlendFactor(s),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(o)},r={srcFactor:this._getBlendFactor(l),dstFactor:this._getBlendFactor(c),operation:this._getBlendOperation(u)}}else{const l=e.premultipliedAlpha,c=(u,d,h,p)=>{t={srcFactor:u,dstFactor:d,operation:X2.Add},r={srcFactor:h,dstFactor:p,operation:X2.Add}};if(l)switch(i){case ac:c(is.One,is.OneMinusSrcAlpha,is.One,is.OneMinusSrcAlpha);break;case Kh:c(is.One,is.One,is.One,is.One);break;case cg:c(is.Zero,is.OneMinusSrc,is.Zero,is.One);break;case ug:c(is.Dst,is.OneMinusSrcAlpha,is.Zero,is.One);break}else switch(i){case ac:c(is.SrcAlpha,is.OneMinusSrcAlpha,is.One,is.OneMinusSrcAlpha);break;case Kh:c(is.SrcAlpha,is.One,is.One,is.One);break;case cg:on(`WebGPURenderer: "SubtractiveBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break;case ug:on(`WebGPURenderer: "MultiplyBlending" requires "${e.isMaterial?"material":"blendMode"}.premultipliedAlpha = true".`);break}}if(t!==void 0&&r!==void 0)return{color:t,alpha:r};on("WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case Bp:t=is.Zero;break;case pP:t=is.One;break;case mP:t=is.Src;break;case gP:t=is.OneMinusSrc;break;case rv:t=is.SrcAlpha;break;case iv:t=is.OneMinusSrcAlpha;break;case vP:t=is.Dst;break;case yP:t=is.OneMinusDst;break;case AP:t=is.DstAlpha;break;case xP:t=is.OneMinusDstAlpha;break;case bP:t=is.SrcAlphaSaturated;break;case zut:t=is.Constant;break;case Vut:t=is.OneMinusConstant;break;default:on("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case O2e:t=ru.Never;break;case HM:t=ru.Always;break;case j2e:t=ru.Less;break;case B2e:t=ru.LessEqual;break;case F2e:t=ru.Equal;break;case V2e:t=ru.GreaterEqual;break;case U2e:t=ru.Greater;break;case z2e:t=ru.NotEqual;break;default:on("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case q1:t=R1.Keep;break;case C2e:t=R1.Zero;break;case P2e:t=R1.Replace;break;case D2e:t=R1.Invert;break;case R2e:t=R1.IncrementClamp;break;case L2e:t=R1.DecrementClamp;break;case k2e:t=R1.IncrementWrap;break;case I2e:t=R1.DecrementWrap;break;default:on("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Fc:t=X2.Add;break;case hP:t=X2.Subtract;break;case fP:t=X2.ReverseSubtract;break;case x$:t=X2.Min;break;case v$:t=X2.Max;break;default:on("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const i={},s=this.backend.utils;i.topology=s.getPrimitiveTopology(e,r),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?ZC.Uint16:ZC.Uint32);let a=r.side===Ds;return e.isMesh&&e.matrixWorld.determinantAffine()<0&&(a=!a),i.frontFace=a===!0?uue.CW:uue.CCW,i.cullMode=r.side===ao?due.None:due.Back,i}_getColorWriteMask(e){return e.colorWrite===!0?hue.All:hue.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=ru.Always;else{const r=this.backend.parameters.reversedDepthBuffer?N$[e.depthFunc]:e.depthFunc;switch(r){case G_:t=ru.Never;break;case H_:t=ru.Always;break;case $_:t=ru.Less;break;case jg:t=ru.LessEqual;break;case W_:t=ru.Equal;break;case X_:t=ru.GreaterEqual;break;case Y_:t=ru.Greater;break;case Z_:t=ru.NotEqual;break;default:on("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class Xwe{constructor(){this.label="",this.type=void 0,this.count=0}reset(){this.label="",this.type=void 0,this.count=0}}const Cp=new Z3,i1t=new w6,s5=new Xwe;class s1t extends Uwe{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,s5.label=`queryset_global_timestamp_${t}`,s5.type="timestamp",s5.count=this.maxQueries,this.querySet=this.device.createQuerySet(s5),s5.reset();const i=this.maxQueries*8;Cp.label=`buffer_timestamp_resolve_${t}`,Cp.size=i,Cp.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,this.resolveBuffer=this.device.createBuffer(Cp),Cp.reset(),Cp.label=`buffer_timestamp_result_${t}`,Cp.size=i,Cp.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,this.resultBuffer=this.device.createBuffer(Cp),Cp.reset()}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return ji(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}async resolveQueriesAsync(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return await this.pendingResolve}finally{this.pendingResolve=null}}async _resolveQueries(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const i=this.device.createCommandEncoder(i1t);i.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),i.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const s=i.finish();if(Gp(this.device,s),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(await this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const a=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),o={},l=[];for(const[u,d]of e){const h=u.match(/^(.*):f(\d+)$/),p=parseInt(h[2]);l.includes(p)===!1&&l.push(p),o[p]===void 0&&(o[p]=0);const g=a[d],x=a[d+1],_=Number(x-g)/1e6;this.timestamps.set(u,_),o[p]+=_}const c=o[l[l.length-1]];return this.resultBuffer.unmap(),this.lastValue=c,this.frames=l,c}catch(e){return on("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}}async dispose(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{await this.pendingResolve}catch(e){on("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){on("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}}}class a1t{constructor(){this.label="",this.timestampWrites=void 0}reset(){this.label="",this.timestampWrites=void 0}}class dE{constructor(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}reset(){this.view=null,this.depthLoadOp=void 0,this.depthStoreOp=void 0,this.depthClearValue=void 0,this.depthReadOnly=!1,this.stencilLoadOp=void 0,this.stencilStoreOp=void 0,this.stencilClearValue=0,this.stencilReadOnly=!1}}class o1t{constructor(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}reset(){this.querySet=null,this.beginningOfPassWriteIndex=void 0,this.endOfPassWriteIndex=void 0}}const y0={r:0,g:0,b:0,a:1},Dh=new Z3,_d=new w6,hE=new a1t,a5=new Xwe,fE=new Gwe,pE=new o1t,Mf=new YR,Pp=new YR,no=new xY,Xm=new Hwe;class l1t extends Bwe{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=null,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new Ngt(this),this.attributeUtils=new Qgt(this),this.bindingUtils=new Jgt(this),this.capabilities=new e1t(this),this.pipelineUtils=new r1t(this),this.textureUtils=new Fgt(this),this.occludedResolveCache=new Map;const t=typeof navigator>"u"?!0:/Android/.test(navigator.userAgent)===!1;this._compatibility={[n2.TEXTURE_COMPARE]:t}}async init(e){await super.init(e);const t=this.parameters;let r;if(t.device===void 0){const i={powerPreference:t.powerPreference,featureLevel:"compatibility",xrCompatible:e.xr.enabled},s=typeof navigator<"u"?await navigator.gpu.requestAdapter(i):null;if(s===null)throw new Error("THREE.WebGPUBackend: Unable to create WebGPU adapter.");const a=Object.values(QC),o=[];for(const c of a)s.features.has(c)&&o.push(c);const l={requiredFeatures:o,requiredLimits:t.requiredLimits};r=await s.requestDevice(l)}else r=t.device;this.compatibilityMode=!r.features.has("core-features-and-limits"),this.compatibilityMode&&(e._samples=0),r.lost.then(i=>{if(i.reason==="destroyed")return;const s={api:"WebGPU",message:i.message||"Unknown reason",reason:i.reason||null,originalEvent:i};e.onDeviceLost(s)}),r.onuncapturederror=i=>{const s=i.error,a=s&&s.constructor?s.constructor.name:"GPUError",o=s&&s.message||"Unknown uncaptured GPU error";e.onError({api:"WebGPU",type:a,message:o,originalEvent:i})},this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(QC.TimestampQuery),this.updateSize()}setXRRenderTargetTextures(e,t,r=null){this.set(e.texture,{texture:t,format:t.format,externalTexture:!0,xrViewDescriptors:r,initialized:!0})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(r===void 0){const i=this.parameters;e.isDefaultCanvasTarget===!0&&i.context!==void 0?r=i.context:r=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${Sm} webgpu`);const s=i.alpha?"premultiplied":"opaque",a=i.outputType===ba?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:s,toneMapping:{mode:a}}),t.context=r}return r}get coordinateSystem(){return mh}get hasTimestamp(){return!0}async getArrayBufferAsync(e,t=null,r=0,i=-1){return await this.attributeUtils.getArrayBufferAsync(e,t,r,i)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),i=e.currentSamples;let s=r.descriptor;if(s===void 0||r.samples!==i){if(s=new b4,s.colorAttachments.push(new y4),e.depth===!0||e.stencil===!0){const l=new dE;l.view=this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView(),s.depthStencilAttachment=l}const o=s.colorAttachments[0];i>0?o.view=this.textureUtils.getColorBuffer().createView():o.resolveTarget=void 0,r.descriptor=s,r.samples=i}const a=s.colorAttachments[0];return i>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),s}_isRenderCameraDepthArray(e){const t=e.camera;return e.depthTexture&&e.depthTexture.isArrayTexture===!0&&t!==null&&t.isArrayCamera===!0}_hasExternalTexture(e){const t=e.textures;if(t===null)return!1;for(let r=0;r1)if(p===!0){const y=e.camera.cameras;for(let M=0;M0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,a5.label=`occlusionQuerySet_${e.id}`,a5.type="occlusion",a5.count=i,s=r.createQuerySet(a5),a5.reset(),t.occlusionQuerySet=s,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(i),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:Zs.Load}),this.initTimestampQuery(I0.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=s;const o=a.depthStencilAttachment;if(e.textures!==null){const c=a.colorAttachments;for(let u=0;u0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const i=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const s=[];for(let a=0;a0){const s=r*8;let a=this.occludedResolveCache.get(s);a===void 0&&(Dh.size=s,Dh.usage=GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC,a=this.device.createBuffer(Dh),Dh.reset(),this.occludedResolveCache.set(s,a)),Dh.size=s,Dh.usage=GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ;const o=this.device.createBuffer(Dh);Dh.reset(),t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,a,0),t.encoder.copyBufferToBuffer(a,0,o,0,s),t.occlusionQueryBuffer=o,this.resolveOccludedAsync(e)}if(Gp(this.device,t.encoder.finish()),e.textures!==null){const s=e.textures;for(let a=0;ag&&(s[0]=Math.min(p,g),s[1]=Math.ceil(p/g)),a.dispatchSize=s}s=a.dispatchSize}l.dispatchWorkgroups(s[0],s[1]||1,s[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),Gp(this.device,t.cmdEncoderGPU.finish())}_draw(e,t,r,i,s,a,o,l,c){const{object:u,material:d,context:h}=e,p=e.getIndex(),g=p!==null;c.pipeline!==i&&(l.setPipeline(i),c.pipeline=i);const x=c.bindingGroups;for(let _=0,y=s.length;_65535?4:2);for(let k=0;k0){const h=this.get(e.camera),p=e.camera.cameras,g=e.getBindingGroup("cameraIndex");if(h.indexesGPU===void 0||h.indexesGPU.length!==p.length){const _=this.get(g),y=[],M=new Uint32Array([0,0,0,0]);for(let C=0,k=p.length;C(sn("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new cue(e)));const r=new t(e);super(r,e),this.library=new d1t,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}/** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT */ve.BRDF_GGX;ve.BRDF_Lambert;ve.BasicPointShadowFilter;ve.BasicShadowFilter;ve.Break;ve.Const;ve.Continue;ve.DFGLUT;ve.D_GGX;ve.Discard;ve.EPSILON;ve.F_Schlick;const h1t=ve.Fn;ve.INFINITY;const f1t=ve.If,p1t=ve.Loop;ve.NodeAccess;ve.NodeShaderStage;ve.NodeType;ve.NodeUpdateType;ve.PCFShadowFilter;ve.PCFSoftShadowFilter;ve.PI;ve.PI2;ve.TWO_PI;ve.HALF_PI;ve.PointShadowFilter;ve.Return;ve.Schlick_to_F0;ve.ShaderNode;ve.Stack;ve.Switch;ve.TBNViewMatrix;ve.VSMShadowFilter;ve.V_GGX_SmithCorrelated;ve.Var;ve.VarIntent;ve.abs;ve.acesFilmicToneMapping;ve.acos;ve.acosh;ve.add;ve.addMethodChaining;ve.addNodeElement;ve.agxToneMapping;ve.all;ve.alphaT;ve.ambientOcclusion;ve.and;ve.anisotropy;ve.anisotropyB;ve.anisotropyT;ve.any;ve.append;ve.array;const m1t=ve.asin;ve.asinh;ve.assign;ve.atan;ve.atanh;ve.atomicAdd;ve.atomicAnd;ve.atomicFunc;ve.atomicLoad;ve.atomicMax;ve.atomicMin;ve.atomicOr;ve.atomicStore;ve.atomicSub;ve.atomicXor;ve.attenuationColor;ve.attenuationDistance;ve.attribute;ve.attributeArray;ve.backgroundBlurriness;ve.backgroundIntensity;ve.backgroundRotation;ve.batch;ve.bentNormalView;ve.billboarding;ve.bitAnd;ve.bitNot;ve.bitOr;ve.bitXor;ve.bitangentGeometry;ve.bitangentLocal;ve.bitangentView;ve.bitangentWorld;ve.bitcast;ve.blendBurn;ve.blendColor;ve.blendDodge;ve.blendOverlay;ve.blendScreen;ve.blur;ve.bool;ve.buffer;ve.bufferAttribute;ve.bumpMap;ve.builtin;ve.builtinAOContext;ve.builtinShadowContext;ve.bvec2;ve.bvec3;ve.bvec4;ve.bypass;ve.cache;ve.call;ve.cameraFar;ve.cameraIndex;ve.cameraNear;ve.cameraNormalMatrix;ve.cameraPosition;ve.cameraProjectionMatrix;ve.cameraProjectionMatrixInverse;ve.cameraViewMatrix;ve.cameraViewport;ve.cameraWorldMatrix;ve.cbrt;ve.cdl;ve.ceil;ve.checker;ve.cineonToneMapping;ve.clamp;ve.clearcoat;ve.clearcoatNormalView;ve.clearcoatRoughness;ve.clipSpace;ve.code;ve.color;ve.colorSpaceToWorking;ve.colorToDirection;ve.compute;ve.computeKernel;ve.computeSkinning;ve.context;ve.convert;ve.convertColorSpace;ve.convertToTexture;ve.countLeadingZeros;ve.countOneBits;ve.countTrailingZeros;const g1t=ve.cos;ve.cosh;ve.cross;ve.cubeTexture;ve.cubeTextureBase;ve.dFdx;ve.dFdy;ve.dashSize;ve.debug;ve.decrement;ve.decrementBefore;ve.defaultBuildStages;ve.defaultShaderStages;ve.defined;ve.degrees;ve.deltaTime;ve.densityFog;ve.densityFogFactor;ve.depth;ve.depthPass;ve.determinant;ve.difference;ve.diffuseColor;ve.directPointLight;ve.directionToColor;ve.directionToFaceDirection;ve.dispersion;ve.distance;ve.div;ve.dot;ve.drawIndex;ve.dynamicBufferAttribute;ve.element;ve.emissive;ve.equal;ve.equirectDirection;ve.equirectUV;const A1t=ve.exp;ve.exp2;ve.exponentialHeightFogFactor;ve.expression;ve.faceDirection;ve.faceForward;ve.faceforward;const x1t=ve.float;ve.floatBitsToInt;ve.floatBitsToUint;ve.floor;ve.fog;ve.fract;ve.frameGroup;ve.frameId;ve.frontFacing;ve.fwidth;ve.gain;ve.gapSize;ve.getConstNodeType;ve.getCurrentStack;ve.getDirection;ve.getDistanceAttenuation;ve.getGeometryRoughness;ve.getNormalFromDepth;ve.interleavedGradientNoise;ve.vogelDiskSample;ve.getParallaxCorrectNormal;ve.getRoughness;ve.getScreenPosition;ve.getShIrradianceAt;ve.getShadowMaterial;ve.getShadowRenderObjectFunction;ve.getTextureIndex;ve.getViewPosition;ve.globalId;ve.glsl;ve.glslFn;ve.grayscale;ve.greaterThan;ve.greaterThanEqual;ve.hash;ve.highpModelNormalViewMatrix;ve.highpModelViewMatrix;ve.hue;ve.increment;ve.incrementBefore;ve.instance;const v1t=ve.instanceIndex;ve.instancedArray;ve.instancedBufferAttribute;ve.instancedDynamicBufferAttribute;ve.instancedMesh;ve.int;ve.intBitsToFloat;ve.inverse;ve.inverseSqrt;ve.inversesqrt;ve.invocationLocalIndex;ve.invocationSubgroupIndex;ve.ior;ve.iridescence;ve.iridescenceIOR;ve.iridescenceThickness;ve.ivec2;ve.ivec3;ve.ivec4;ve.js;ve.label;ve.length;ve.lengthSq;ve.lessThan;ve.lessThanEqual;ve.lightPosition;ve.lightProjectionUV;ve.lightShadowMatrix;ve.lightTargetDirection;ve.lightTargetPosition;ve.lightViewPosition;ve.lightingContext;ve.lights;ve.linearDepth;ve.linearToneMapping;ve.localId;ve.log;ve.log2;ve.logarithmicDepthToViewZ;ve.luminance;ve.mat2;ve.mat3;ve.mat4;ve.matcapUV;ve.materialAO;ve.materialAlphaTest;ve.materialAnisotropy;ve.materialAnisotropyVector;ve.materialAttenuationColor;ve.materialAttenuationDistance;ve.materialClearcoat;ve.materialClearcoatNormal;ve.materialClearcoatRoughness;ve.materialColor;ve.materialDispersion;ve.materialEmissive;ve.materialEnvIntensity;ve.materialEnvRotation;ve.materialIOR;ve.materialIridescence;ve.materialIridescenceIOR;ve.materialIridescenceThickness;ve.materialLightMap;ve.materialLineDashOffset;ve.materialLineDashSize;ve.materialLineGapSize;ve.materialLineScale;ve.materialLineWidth;ve.materialMetalness;ve.materialNormal;ve.materialOpacity;ve.materialPointSize;ve.materialReference;ve.materialReflectivity;ve.materialRefractionRatio;ve.materialRotation;ve.materialRoughness;ve.materialSheen;ve.materialSheenRoughness;ve.materialShininess;ve.materialSpecular;ve.materialSpecularColor;ve.materialSpecularIntensity;ve.materialSpecularStrength;ve.materialThickness;ve.materialTransmission;ve.max;ve.maxMipLevel;ve.mediumpModelViewMatrix;ve.metalness;ve.min;ve.mix;ve.mixElement;ve.mod;ve.modelDirection;ve.modelNormalMatrix;ve.modelPosition;ve.modelRadius;ve.modelScale;ve.modelViewMatrix;ve.modelViewPosition;ve.modelViewProjection;ve.modelWorldMatrix;ve.modelWorldMatrixInverse;ve.morphReference;ve.mrt;ve.mul;ve.mx_aastep;ve.mx_add;ve.mx_atan2;ve.mx_cell_noise_float;ve.mx_contrast;ve.mx_divide;ve.mx_fractal_noise_float;ve.mx_fractal_noise_vec2;ve.mx_fractal_noise_vec3;ve.mx_fractal_noise_vec4;ve.mx_frame;ve.mx_heighttonormal;ve.mx_hsvtorgb;ve.mx_ifequal;ve.mx_ifgreater;ve.mx_ifgreatereq;ve.mx_invert;ve.mx_modulo;ve.mx_multiply;ve.mx_noise_float;ve.mx_noise_vec3;ve.mx_noise_vec4;ve.mx_place2d;ve.mx_power;ve.mx_ramp4;ve.mx_ramplr;ve.mx_ramptb;ve.mx_rgbtohsv;ve.mx_rotate2d;ve.mx_rotate3d;ve.mx_safepower;ve.mx_separate;ve.mx_splitlr;ve.mx_splittb;ve.mx_srgb_texture_to_lin_rec709;ve.mx_subtract;ve.mx_timer;ve.mx_transform_uv;ve.mx_unifiednoise2d;ve.mx_unifiednoise3d;ve.mx_worley_noise_float;ve.mx_worley_noise_vec2;ve.mx_worley_noise_vec3;const y1t=ve.negate;ve.negateOnBackSide;ve.neutralToneMapping;ve.nodeArray;ve.nodeImmutable;ve.nodeObject;ve.nodeObjectIntent;ve.nodeObjects;ve.nodeProxy;ve.nodeProxyIntent;ve.normalFlat;ve.normalGeometry;ve.normalLocal;ve.normalMap;ve.normalView;ve.normalViewGeometry;ve.normalWorld;ve.normalWorldGeometry;ve.normalize;ve.not;ve.notEqual;ve.numWorkgroups;ve.objectDirection;ve.objectGroup;ve.objectPosition;ve.objectRadius;ve.objectScale;ve.objectViewPosition;ve.objectWorldMatrix;ve.OnBeforeObjectUpdate;ve.OnBeforeMaterialUpdate;ve.OnObjectUpdate;ve.OnMaterialUpdate;ve.oneMinus;ve.or;ve.orthographicDepthToViewZ;ve.oscSawtooth;ve.oscSine;ve.oscSquare;ve.oscTriangle;ve.output;ve.outputStruct;ve.overloadingFn;ve.overrideNode;ve.overrideNodes;ve.packHalf2x16;ve.packSnorm2x16;ve.packUnorm2x16;ve.packNormalToRGB;ve.parabola;ve.parallaxDirection;ve.parallaxUV;ve.parameter;ve.pass;ve.passTexture;ve.pcurve;ve.perspectiveDepthToViewZ;ve.pmremTexture;ve.pointShadow;ve.pointUV;ve.pointWidth;ve.positionGeometry;ve.positionLocal;ve.positionPrevious;ve.positionView;ve.positionViewDirection;ve.positionWorld;ve.positionWorldDirection;ve.posterize;ve.pow;ve.pow2;ve.pow3;ve.pow4;ve.premultiplyAlpha;ve.property;ve.radians;ve.rand;ve.range;ve.rangeFog;ve.rangeFogFactor;ve.reciprocal;ve.reference;ve.referenceBuffer;ve.reflect;ve.reflectVector;ve.reflectView;ve.reflector;ve.refract;ve.refractVector;ve.refractView;ve.reinhardToneMapping;ve.remap;ve.remapClamp;ve.renderGroup;ve.renderOutput;ve.rendererReference;ve.replaceDefaultUV;ve.rotate;ve.rotateUV;ve.roughness;ve.round;ve.rtt;ve.sRGBTransferEOTF;ve.sRGBTransferOETF;ve.sample;ve.sampler;ve.samplerComparison;ve.saturate;ve.saturation;ve.screen;ve.screenCoordinate;ve.screenDPR;ve.screenSize;ve.screenUV;ve.select;ve.setCurrentStack;ve.setName;ve.shaderStages;ve.shadow;ve.shadowPositionWorld;ve.shapeCircle;ve.sharedUniformGroup;ve.sheen;ve.sheenRoughness;ve.shiftLeft;ve.shiftRight;ve.shininess;ve.sign;const b1t=ve.sin;ve.sinh;ve.sinc;ve.skinning;ve.smoothstep;ve.smoothstepElement;ve.specularColor;ve.specularF90;ve.spherizeUV;ve.split;ve.spritesheetUV;const _1t=ve.sqrt;ve.stack;ve.step;ve.stepElement;const w1t=ve.storage;ve.storageBarrier;ve.storageTexture;ve.storageTexture3D;ve.struct;ve.sub;ve.subgroupAdd;ve.subgroupAll;ve.subgroupAnd;ve.subgroupAny;ve.subgroupBallot;ve.subgroupBroadcast;ve.subgroupBroadcastFirst;ve.subBuild;ve.subgroupElect;ve.subgroupExclusiveAdd;ve.subgroupExclusiveMul;ve.subgroupInclusiveAdd;ve.subgroupInclusiveMul;ve.subgroupIndex;ve.subgroupMax;ve.subgroupMin;ve.subgroupMul;ve.subgroupOr;ve.subgroupShuffle;ve.subgroupShuffleDown;ve.subgroupShuffleUp;ve.subgroupShuffleXor;ve.subgroupSize;ve.subgroupXor;ve.tan;ve.tanh;ve.tangentGeometry;ve.tangentLocal;ve.tangentView;ve.tangentWorld;ve.texture;ve.texture3D;ve.textureBarrier;ve.textureBicubic;ve.textureBicubicLevel;ve.textureCubeUV;ve.textureLoad;ve.textureSize;ve.textureLevel;ve.textureStore;ve.thickness;ve.time;ve.toneMapping;ve.toneMappingExposure;ve.toonOutlinePass;ve.transformDirection;ve.transformNormal;ve.transformNormalByInverseViewMatrix;ve.transformNormalByViewMatrix;ve.transformNormalToView;ve.transformedClearcoatNormalView;ve.transformedNormalView;ve.transformedNormalWorld;ve.transmission;ve.transpose;ve.triNoise3D;ve.triplanarTexture;ve.triplanarTextures;ve.trunc;ve.uint;ve.uintBitsToFloat;const S1t=ve.uniform;ve.uniformArray;ve.uniformCubeTexture;ve.uniformGroup;ve.uniformFlow;ve.uniformTexture;ve.unpackHalf2x16;ve.unpackSnorm2x16;ve.unpackUnorm2x16;ve.unpackRGBToNormal;ve.unpremultiplyAlpha;ve.userData;ve.uv;ve.uvec2;ve.uvec3;ve.uvec4;ve.varying;ve.varyingProperty;ve.vec2;ve.vec3;ve.vec4;ve.vectorComponents;ve.velocity;ve.vertexColor;ve.vertexIndex;ve.vertexStage;ve.vibrance;ve.viewZToLogarithmicDepth;ve.viewZToOrthographicDepth;ve.viewZToPerspectiveDepth;ve.viewZToReversedOrthographicDepth;ve.viewZToReversedPerspectiveDepth;ve.viewport;ve.viewportCoordinate;ve.viewportDepthTexture;ve.viewportLinearDepth;ve.viewportMipTexture;ve.viewportOpaqueMipTexture;ve.viewportResolution;ve.viewportSafeUV;ve.viewportSharedTexture;ve.viewportSize;ve.viewportTexture;ve.viewportUV;ve.wgsl;ve.wgslFn;ve.workgroupArray;ve.workgroupBarrier;ve.workgroupId;ve.workingToColorSpace;ve.xor;const bue=new So,mE=new Fe;let Zwe=class extends d6{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],r=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(r),this.setAttribute("position",new tr(e,3)),this.setAttribute("uv",new tr(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,r=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),r.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const r=new VA(t,6,1);return this.setAttribute("instanceStart",new kl(r,3,0)),this.setAttribute("instanceEnd",new kl(r,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const r=new VA(t,6,1);return this.setAttribute("instanceColorStart",new kl(r,3,0)),this.setAttribute("instanceColorEnd",new kl(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new KP(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new So);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),bue.setFromBufferAttribute(t),this.boundingBox.union(bue))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Vo),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let s=0,a=e.count;s #include #include #include #include uniform float linewidth; uniform vec2 resolution; attribute vec3 instanceStart; attribute vec3 instanceEnd; attribute vec3 instanceColorStart; attribute vec3 instanceColorEnd; #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #ifdef USE_DASH uniform float dashScale; attribute float instanceDistanceStart; attribute float instanceDistanceEnd; varying float vLineDistance; #endif float trimSegmentAlpha( const in vec4 start, const in vec4 end ) { // compute the interpolation factor needed to trim the segment so it terminates // between the camera plane and the near plane // conservative estimate of the near plane float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column // we need different nearEstimate formula for reversed and default depth buffer // a is positive with a reversed depth buffer so it can be used for controlling the code flow float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a ); return ( nearEstimate - start.z ) / ( end.z - start.z ); } void main() { #ifdef USE_COLOR vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; #endif float aspect = resolution.x / resolution.y; // camera space vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); #ifdef USE_DASH float lineDistanceStart = dashScale * instanceDistanceStart; float lineDistanceEnd = dashScale * instanceDistanceEnd; #endif #ifdef WORLD_UNITS worldStart = start.xyz; worldEnd = end.xyz; #else vUv = uv; #endif // special case for perspective projection, and segments that terminate either in, or behind, the camera plane // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space // but we need to perform ndc-space calculations in the shader, so we must address this issue directly // perhaps there is a more elegant solution -- WestLangley bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column if ( perspective ) { if ( start.z < 0.0 && end.z >= 0.0 ) { float alpha = trimSegmentAlpha( start, end ); end.xyz = mix( start.xyz, end.xyz, alpha ); #ifdef USE_DASH lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha ); #endif } else if ( end.z < 0.0 && start.z >= 0.0 ) { float alpha = trimSegmentAlpha( end, start ); start.xyz = mix( end.xyz, start.xyz, alpha ); #ifdef USE_DASH lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha ); #endif } } #ifdef USE_DASH vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd; vUv = uv; #endif // clip space vec4 clipStart = projectionMatrix * start; vec4 clipEnd = projectionMatrix * end; // ndc space vec3 ndcStart = clipStart.xyz / clipStart.w; vec3 ndcEnd = clipEnd.xyz / clipEnd.w; // direction vec2 dir = ndcEnd.xy - ndcStart.xy; // account for clip-space aspect ratio dir.x *= aspect; dir = normalize( dir ); #ifdef WORLD_UNITS vec3 worldDir = normalize( end.xyz - start.xyz ); vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) ); vec3 worldUp = normalize( cross( worldDir, tmpFwd ) ); vec3 worldFwd = cross( worldDir, worldUp ); worldPos = position.y < 0.5 ? start: end; // height offset float hw = linewidth * 0.5; worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp; // don't extend the line if we're rendering dashes because we // won't be rendering the endcaps #ifndef USE_DASH // cap extension worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir; // add width to the box worldPos.xyz += worldFwd * hw; // endcaps if ( position.y > 1.0 || position.y < 0.0 ) { worldPos.xyz -= worldFwd * 2.0 * hw; } #endif // project the worldpos vec4 clip = projectionMatrix * worldPos; // shift the depth of the projected points so the line // segments overlap neatly vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; clip.z = clipPose.z * clip.w; #else vec2 offset = vec2( dir.y, - dir.x ); // undo aspect ratio adjustment dir.x /= aspect; offset.x /= aspect; // sign flip if ( position.x < 0.0 ) offset *= - 1.0; // endcaps if ( position.y < 0.0 ) { offset += - dir; } else if ( position.y > 1.0 ) { offset += dir; } // adjust for linewidth offset *= linewidth; // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... offset /= resolution.y; // select end vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; // back to clip space offset *= clip.w; clip.xy += offset; #endif gl_Position = clip; vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation #include #include #include } `,fragmentShader:` uniform vec3 diffuse; uniform float opacity; uniform float linewidth; #ifdef USE_DASH uniform float dashOffset; uniform float dashSize; uniform float gapSize; #endif varying float vLineDistance; #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #include #include #include #include #include vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { float mua; float mub; vec3 p13 = p1 - p3; vec3 p43 = p4 - p3; vec3 p21 = p2 - p1; float d1343 = dot( p13, p43 ); float d4321 = dot( p43, p21 ); float d1321 = dot( p13, p21 ); float d4343 = dot( p43, p43 ); float d2121 = dot( p21, p21 ); float denom = d2121 * d4343 - d4321 * d4321; float numer = d1343 * d4321 - d1321 * d4343; mua = numer / denom; mua = clamp( mua, 0.0, 1.0 ); mub = ( d1343 + d4321 * ( mua ) ) / d4343; mub = clamp( mub, 0.0, 1.0 ); return vec2( mua, mub ); } void main() { float alpha = opacity; vec4 diffuseColor = vec4( diffuse, alpha ); #include #ifdef USE_DASH if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX #endif #ifdef WORLD_UNITS // Find the closest points on the view ray and the line segment vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; vec3 lineDir = worldEnd - worldStart; vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); vec3 p1 = worldStart + lineDir * params.x; vec3 p2 = rayEnd * params.y; vec3 delta = p1 - p2; float len = length( delta ); float norm = len / linewidth; #ifndef USE_DASH #ifdef USE_ALPHA_TO_COVERAGE float dnorm = fwidth( norm ); alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); #else if ( norm > 0.5 ) { discard; } #endif #endif #else #ifdef USE_ALPHA_TO_COVERAGE // artifacts appear on some hardware if a derivative is taken within a conditional float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; float dlen = fwidth( len2 ); if ( abs( vUv.y ) > 1.0 ) { alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); } #else if ( abs( vUv.y ) > 1.0 ) { float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; if ( len2 > 1.0 ) discard; } #endif #endif #include #include gl_FragColor = vec4( diffuseColor.rgb, alpha ); #include #include #include #include } `};let vY=class extends Dl{constructor(e){super({type:"LineMaterial",uniforms:qg.clone(Ed.line.uniforms),vertexShader:Ed.line.vertexShader,fragmentShader:Ed.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE="":delete this.defines.USE_ALPHA_TO_COVERAGE)}};const gB=new gr,_ue=new Fe,wue=new Fe,iu=new gr,su=new gr,Rp=new gr,AB=new Fe,xB=new ir,uu=new uW,Sue=new Fe,gE=new So,AE=new Vo,Lp=new gr;let Hp,Gx;function Tue(n,e,t){return Lp.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),Lp.multiplyScalar(1/Lp.w),Lp.x=Gx/t.width,Lp.y=Gx/t.height,Lp.applyMatrix4(n.projectionMatrixInverse),Lp.multiplyScalar(1/Lp.w),Math.abs(Math.max(Lp.x,Lp.y))}function T1t(n,e){const t=n.matrixWorld,r=n.geometry,i=r.attributes.instanceStart,s=r.attributes.instanceEnd,a=Math.min(r.instanceCount,i.count);for(let o=0,l=a;od&&su.z>d)continue;if(iu.z>d){const C=iu.z-su.z,k=(iu.z-d)/C;iu.lerp(su,k)}else if(su.z>d){const C=su.z-iu.z,k=(su.z-d)/C;su.lerp(iu,k)}iu.applyMatrix4(r),su.applyMatrix4(r),iu.multiplyScalar(1/iu.w),su.multiplyScalar(1/su.w),iu.x*=s.x/2,iu.y*=s.y/2,su.x*=s.x/2,su.y*=s.y/2,uu.start.copy(iu),uu.start.z=0,uu.end.copy(su),uu.end.z=0;const x=uu.closestPointToPointParameter(AB,!0);uu.at(x,Sue);const _=Q0.lerp(iu.z,su.z,x),y=_>=-1&&_<=1,M=AB.distanceTo(Sue)n.length)&&(e=n.length);for(var t=0,r=Array(e);t3?(ie=re===J)&&(O=ae[(z=ae[4])?5:(z=3,3)],ae[4]=ae[5]=n):ae[0]<=Q&&((ie=W<2&&QJ||J>re)&&(ae[4]=W,ae[5]=J,H.n=re,z=0))}if(ie||W>1)return a;throw G=!0,J}return function(W,J,ie){if(V>1)throw TypeError("Generator is already running");for(G&&J===1&&K(J,ie),z=J,O=ie;(e=z<2?n:O)||!G;){U||(z?z<3?(z>1&&(H.n=-1),K(z,O)):H.n=O:H.v=O);try{if(V=2,U){if(z||(W="next"),e=U[W]){if(!(e=e.call(U,O)))throw TypeError("iterator result is not an object");if(!e.done)return e;O=e.value,z<2&&(z=0)}else z===1&&(e=U.return)&&e.call(U),z<2&&(O=TypeError("The iterator does not provide a '"+W+"' method"),z=1);U=n}else if((e=(G=H.n<0)?O:C.call(k,H))!==a)break}catch(ae){U=n,z=1,O=ae}finally{V=1}}return{value:e,done:G}}}(p,x,_),!0),M}var a={};function o(){}function l(){}function c(){}e=Object.getPrototypeOf;var u=[][r]?e(e([][r]())):(Uh(e={},r,function(){return this}),e),d=c.prototype=o.prototype=Object.create(u);function h(p){return Object.setPrototypeOf?Object.setPrototypeOf(p,c):(p.__proto__=c,Uh(p,i,"GeneratorFunction")),p.prototype=Object.create(d),p}return l.prototype=c,Uh(d,"constructor",c),Uh(c,"constructor",l),l.displayName="GeneratorFunction",Uh(c,i,"GeneratorFunction"),Uh(d),Uh(d,i,"Generator"),Uh(d,r,function(){return this}),Uh(d,"toString",function(){return"[object Generator]"}),(Aq=function(){return{w:s,m:h}})()}function Uh(n,e,t,r){var i=Object.defineProperty;try{i({},"",{})}catch{i=0}Uh=function(s,a,o,l){function c(u,d){Uh(s,u,function(h){return this._invoke(u,d,h)})}a?i?i(s,a,{value:o,enumerable:!l,configurable:!l,writable:!l}):s[a]=o:(c("next",0),c("throw",1),c("return",2))},Uh(n,e,t,r)}function xq(n,e){return xq=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},xq(n,e)}function co(n,e){return R1t(n)||F1t(n,e)||t5e(n,e)||B1t()}function G1t(n,e){for(;!{}.hasOwnProperty.call(n,e)&&(n=g3(n))!==null;);return n}function bB(n,e,t,r){var i=gq(g3(n.prototype),e,t);return typeof i=="function"?function(s){return i.apply(t,s)}:i}function xa(n){return L1t(n)||j1t(n)||t5e(n)||U1t()}function H1t(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function e5e(n){var e=H1t(n,"string");return typeof e=="symbol"?e:e+""}function t5e(n,e){if(n){if(typeof n=="string")return mq(n,e);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?mq(n,e):void 0}}var n5e=function(e){e instanceof Array?e.forEach(n5e):(e.map&&e.map.dispose(),e.dispose())},hA=function(e){e.geometry&&e.geometry.dispose(),e.material&&n5e(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(hA)},qo=function(e){if(e&&e.children)for(;e.children.length;){var t=e.children[0];e.remove(t),hA(t)}};function Vd(n,e){var t=new e;return{linkProp:function(i){return{default:t[i](),onChange:function(a,o){o[n][i](a)},triggerUpdate:!1}},linkMethod:function(i){return function(s){for(var a=s[n],o=arguments.length,l=new Array(o>1?o-1:0),c=1;c2&&arguments[2]!==void 0?arguments[2]:0,r=(90-n)*Math.PI/180,i=(90-e)*Math.PI/180,s=Wa*(1+t),a=Math.sin(r);return{x:s*a*Math.cos(i),y:s*Math.cos(r),z:s*a*Math.sin(i)}}function r5e(n){var e=n.x,t=n.y,r=n.z,i=Math.sqrt(e*e+t*t+r*r),s=Math.acos(t/i),a=Math.atan2(r,e);return{lat:90-s*180/Math.PI,lng:90-a*180/Math.PI-(a<-Math.PI/2?360:0),altitude:i/Wa-1}}function px(n){return n*Math.PI/180}var MS=window.THREE?window.THREE:{BackSide:Ds,BufferAttribute:Gi,Color:Fn,Mesh:ui,ShaderMaterial:Dl},$1t=` uniform float hollowRadius; varying vec3 vVertexWorldPosition; varying vec3 vVertexNormal; varying float vCameraDistanceToObjCenter; varying float vVertexAngularDistanceToHollowRadius; void main() { vVertexNormal = normalize(normalMatrix * normal); vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz; vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); vCameraDistanceToObjCenter = length(objCenterViewPosition); float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter); float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition))); vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`,W1t=` uniform vec3 color; uniform float coefficient; uniform float power; uniform float hollowRadius; varying vec3 vVertexNormal; varying vec3 vVertexWorldPosition; varying float vCameraDistanceToObjCenter; varying float vVertexAngularDistanceToHollowRadius; void main() { if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition; vec3 viewCameraToVertex = (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz; viewCameraToVertex = normalize(viewCameraToVertex); float intensity = pow( coefficient + dot(vVertexNormal, viewCameraToVertex), power ); gl_FragColor = vec4(color, intensity); }`;function X1t(n,e,t,r){return new MS.ShaderMaterial({depthWrite:!1,transparent:!0,vertexShader:$1t,fragmentShader:W1t,uniforms:{coefficient:{value:n},color:{value:new MS.Color(e)},power:{value:t},hollowRadius:{value:r}}})}function Y1t(n,e){for(var t=n.clone(),r=new Float32Array(n.attributes.position.count*3),i=0,s=r.length;i1&&arguments[1]!==void 0?arguments[1]:{},s=i.color,a=s===void 0?"gold":s,o=i.size,l=o===void 0?2:o,c=i.coefficient,u=c===void 0?.5:c,d=i.power,h=d===void 0?1:d,p=i.hollowRadius,g=p===void 0?0:p,x=i.backside,_=x===void 0?!0:x;QR(this,e),r=ZR(this,e);var y=Y1t(t,l),M=X1t(u,a,h,g);return _&&(M.side=MS.BackSide),r.geometry=y,r.material=M,r}return JR(e,n),KR(e)}(MS.Mesh),kp=window.THREE?window.THREE:{Color:Fn,Group:nd,LineBasicMaterial:Ac,LineSegments:o0,Mesh:ui,MeshPhongMaterial:eR,SphereGeometry:gf,SRGBColorSpace:ic,TextureLoader:ry},i5e=xc({props:{globeImageUrl:{},bumpImageUrl:{},showGlobe:{default:!0,onChange:function(e,t){t.globeGroup.visible=!!e},triggerUpdate:!1},showGraticules:{default:!1,onChange:function(e,t){t.graticulesObj.visible=!!e},triggerUpdate:!1},showAtmosphere:{default:!0,onChange:function(e,t){t.atmosphereObj&&(t.atmosphereObj.visible=!!e)},triggerUpdate:!1},atmosphereColor:{default:"lightskyblue"},atmosphereAltitude:{default:.15},globeCurvatureResolution:{default:4},globeTileEngineUrl:{onChange:function(e,t){t.tileEngine.tileUrl=e}},globeTileEngineMaxLevel:{default:17,onChange:function(e,t){t.tileEngine.maxLevel=e},triggerUpdate:!1},updatePov:{onChange:function(e,t){t.tileEngine.updatePov(e)},triggerUpdate:!1},onReady:{default:function(){},triggerUpdate:!1}},methods:{globeMaterial:function(e,t){return t!==void 0?(e.globeObj.material=t||e.defaultGlobeMaterial,this):e.globeObj.material},globeTileEngineClearCache:function(e){e.tileEngine.clearTiles()},_destructor:function(e){hA(e.globeObj),hA(e.tileEngine),hA(e.graticulesObj)}},stateInit:function(){var e=new kp.MeshPhongMaterial({color:0}),t=new kp.Mesh(void 0,e);t.rotation.y=-Math.PI/2;var r=new Hnt(Wa),i=new kp.Group;i.__globeObjType="globe",i.add(t),i.add(r);var s=new kp.LineSegments(new Eve(cnt(),Wa,2),new kp.LineBasicMaterial({color:"lightgrey",transparent:!0,opacity:.1}));return{globeGroup:i,globeObj:t,graticulesObj:s,defaultGlobeMaterial:e,tileEngine:r}},init:function(e,t){qo(e),t.scene=e,t.scene.add(t.globeGroup),t.scene.add(t.graticulesObj),t.ready=!1},update:function(e,t){var r=e.globeObj.material;if(e.tileEngine.visible=!(e.globeObj.visible=!e.globeTileEngineUrl),t.hasOwnProperty("globeCurvatureResolution")){var i;(i=e.globeObj.geometry)===null||i===void 0||i.dispose();var s=Math.max(4,Math.round(360/e.globeCurvatureResolution));e.globeObj.geometry=new kp.SphereGeometry(Wa,s,s/2),e.tileEngine.curvatureResolution=e.globeCurvatureResolution}if(t.hasOwnProperty("globeImageUrl")&&(e.globeImageUrl?new kp.TextureLoader().load(e.globeImageUrl,function(o){var l;o.colorSpace=kp.SRGBColorSpace,(l=r.map)===null||l===void 0||l.dispose(),r.map=o,r.color=null,r.needsUpdate=!0,!e.ready&&(e.ready=!0)&&setTimeout(e.onReady)}):!r.color&&(r.color=new kp.Color(0))),t.hasOwnProperty("bumpImageUrl")&&(e.bumpImageUrl?e.bumpImageUrl&&new kp.TextureLoader().load(e.bumpImageUrl,function(o){var l;(l=r.bumpMap)===null||l===void 0||l.dispose(),r.bumpMap=o,r.needsUpdate=!0}):(r.bumpMap=null,r.needsUpdate=!0)),(t.hasOwnProperty("atmosphereColor")||t.hasOwnProperty("atmosphereAltitude"))&&(e.atmosphereObj&&(e.scene.remove(e.atmosphereObj),hA(e.atmosphereObj)),e.atmosphereColor&&e.atmosphereAltitude)){var a=e.atmosphereObj=new Z1t(e.globeObj.geometry,{color:e.atmosphereColor,size:Wa*e.atmosphereAltitude,hollowRadius:Wa,coefficient:.1,power:3.5});a.visible=!!e.showAtmosphere,a.__globeObjType="atmosphere",e.scene.add(a)}!e.ready&&(!e.globeImageUrl||e.globeTileEngineUrl)&&(e.ready=!0,e.onReady())}}),vm=function(e){return isNaN(e)?parseInt(kr(e).toHex(),16):e},$0=function(e){return e&&isNaN(e)?kg(e).opacity:1},XA=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i,s=1,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.eE+-]+)\s*\)$/.exec(e.trim().toLowerCase());if(a){var o=a.slice(1),l=co(o,4),c=l[0],u=l[1],d=l[2],h=l[3];i=new Fn("rgb(".concat(+c,",").concat(+u,",").concat(+d,")")),s=Math.min(+h,1)}else i=new Fn(e);r&&i.convertLinearToSRGB();var p=i.toArray();return t?[].concat(xa(p),[s]):p};function Q1t(n,e,t){return n.opacity=e,n.transparent=e<1,n.depthWrite=e>=1,n}var Cue=window.THREE?window.THREE:{BufferAttribute:Gi};function ym(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Float32Array;if(e===1)return new Cue.BufferAttribute(new t(n),e);for(var r=new Cue.BufferAttribute(new t(n.length*e),e),i=0,s=n.length;i1&&arguments[1]!==void 0?arguments[1]:{},s=i.dataBindAttr,a=s===void 0?"__data":s,o=i.objBindAttr,l=o===void 0?"__threeObj":o,c=i.removeDelay,u=c===void 0?0:c;return QR(this,e),r=ZR(this,e),Gc(r,"scene",void 0),vB(r,_B,void 0),vB(r,xE,void 0),vB(r,vE,void 0),r.scene=t,yB(_B,r,a),yB(xE,r,l),yB(vE,r,u),r.onRemoveObj(function(){}),r}return JR(e,n),KR(e,[{key:"onCreateObj",value:function(r){var i=this;return bB(e,"onCreateObj",this)([function(s){var a=r(s);return s[o5(xE,i)]=a,a[o5(_B,i)]=s,i.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(r){var i=this;return bB(e,"onRemoveObj",this)([function(s,a){var o=bB(e,"getData",i)([s]);r(s,a);var l=function(){i.scene.remove(s),hA(s),delete o[o5(xE,i)]};o5(vE,i)?setTimeout(l,o5(vE,i)):l()}]),this}}])}(_it),b0=window.THREE?window.THREE:{BufferGeometry:Pr,CylinderGeometry:ey,Matrix4:ir,Mesh:ui,MeshLambertMaterial:op,Object3D:os,Vector3:Fe},Pue=Object.assign({},_W),Rue=Pue.BufferGeometryUtils||Pue,s5e=xc({props:{pointsData:{default:[]},pointLat:{default:"lat"},pointLng:{default:"lng"},pointColor:{default:function(){return"#ffffaa"}},pointAltitude:{default:.1},pointRadius:{default:.25},pointResolution:{default:12,triggerUpdate:!1},pointsMerge:{default:!1},pointsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;qo(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new bh(e,{objBindAttr:"__threeObjPoint"})},update:function(e,t){var r=En(e.pointLat),i=En(e.pointLng),s=En(e.pointAltitude),a=En(e.pointRadius),o=En(e.pointColor),l=new b0.CylinderGeometry(1,1,1,e.pointResolution);l.applyMatrix4(new b0.Matrix4().makeRotationX(Math.PI/2)),l.applyMatrix4(new b0.Matrix4().makeTranslation(0,0,-.5));var c=2*Math.PI*Wa/360,u={};if(!e.pointsMerge&&t.hasOwnProperty("pointsMerge")&&qo(e.scene),e.dataMapper.scene=e.pointsMerge?new b0.Object3D:e.scene,e.dataMapper.onCreateObj(p).onUpdateObj(g).digest(e.pointsData),e.pointsMerge){var d=e.pointsData.length?(Rue.mergeGeometries||Rue.mergeBufferGeometries)(e.pointsData.map(function(x){var _=e.dataMapper.getObj(x),y=_.geometry.clone();_.updateMatrix(),y.applyMatrix4(_.matrix);var M=XA(o(x));return y.setAttribute("color",ym(Array(y.getAttribute("position").count).fill(M),4)),y})):new b0.BufferGeometry,h=new b0.Mesh(d,new b0.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0}));h.__globeObjType="points",h.__data=e.pointsData,e.dataMapper.clear(),qo(e.scene),e.scene.add(h)}function p(){var x=new b0.Mesh(l);return x.__globeObjType="point",x}function g(x,_){var y=function(O){var V=x.__currentTargetD=O,$=V.r,G=V.alt,H=V.lat,K=V.lng;Object.assign(x.position,i0(H,K));var W=e.pointsMerge?new b0.Vector3(0,0,0):e.scene.localToWorld(new b0.Vector3(0,0,0));x.lookAt(W),x.scale.x=x.scale.y=Math.min(30,$)*c,x.scale.z=Math.max(G*Wa,.1)},M={alt:+s(_),r:+a(_),lat:+r(_),lng:+i(_)},C=x.__currentTargetD||Object.assign({},M,{alt:-.001});if(Object.keys(M).some(function(z){return C[z]!==M[z]})&&(e.pointsMerge||!e.pointsTransitionDuration||e.pointsTransitionDuration<0?y(M):e.tweenGroup.add(new cd(C).to(M,e.pointsTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(y).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.pointsMerge){var k=o(_),B=k?$0(k):0,U=!!B;x.visible=U,U&&(u.hasOwnProperty(k)||(u[k]=new b0.MeshLambertMaterial({color:vm(k),transparent:B<1,opacity:B})),x.material=u[k])}}}}),a5e=function(){return{uniforms:{dashOffset:{value:0},dashSize:{value:1},gapSize:{value:0},dashTranslate:{value:0}},vertexShader:` `.concat(di.common,` `).concat(di.logdepthbuf_pars_vertex,` uniform float dashTranslate; attribute vec4 color; varying vec4 vColor; attribute float relDistance; varying float vRelDistance; void main() { // pass through colors and distances vColor = color; vRelDistance = relDistance + dashTranslate; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); `).concat(di.logdepthbuf_vertex,` } `),fragmentShader:` `.concat(di.logdepthbuf_pars_fragment,` uniform float dashOffset; uniform float dashSize; uniform float gapSize; varying vec4 vColor; varying float vRelDistance; void main() { // ignore pixels in the gap if (vRelDistance < dashOffset) discard; if (mod(vRelDistance - dashOffset, dashSize + gapSize) > dashSize) discard; // set px color: [r, g, b, a], interpolated between vertices gl_FragColor = vColor; `).concat(di.logdepthbuf_fragment,` } `)}},vq=function(e){return e.uniforms.uSurfaceRadius={type:"float",value:0},e.vertexShader=(`attribute float surfaceRadius; varying float vSurfaceRadius; varying vec3 vPos; `+e.vertexShader).replace("void main() {",["void main() {","vSurfaceRadius = surfaceRadius;","vPos = position;"].join(` `)),e.fragmentShader=(`uniform float uSurfaceRadius; varying float vSurfaceRadius; varying vec3 vPos; `+e.fragmentShader).replace("void main() {",["void main() {","if (length(vPos) < max(uSurfaceRadius, vSurfaceRadius)) discard;"].join(` `)),e},J1t=function(e){return e.vertexShader=` attribute float r; const float PI = 3.1415926535897932384626433832795; float toRad(in float a) { return a * PI / 180.0; } vec3 Polar2Cartesian(in vec3 c) { // [lat, lng, r] float phi = toRad(90.0 - c.x); float theta = toRad(90.0 - c.y); float r = c.z; return vec3( // x,y,z r * sin(phi) * cos(theta), r * cos(phi), r * sin(phi) * sin(theta) ); } vec2 Cartesian2Polar(in vec3 p) { float r = sqrt(p.x * p.x + p.y * p.y + p.z * p.z); float phi = acos(p.y / r); float theta = atan(p.z, p.x); return vec2( // lat,lng 90.0 - phi * 180.0 / PI, 90.0 - theta * 180.0 / PI - (theta < -PI / 2.0 ? 360.0 : 0.0) ); } `.concat(e.vertexShader.replace("}",` vec3 pos = Polar2Cartesian(vec3(Cartesian2Polar(position), r)); gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0); } `),` `),e},_Y=function(e,t){return e.onBeforeCompile=function(r){e.userData.shader=t(r)},e},eAt=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(i){return i};if(e.userData.shader)t(e.userData.shader.uniforms);else{var r=e.onBeforeCompile;e.onBeforeCompile=function(i){r(i),t(i.uniforms)}}},tAt=["stroke"],_0=window.THREE?window.THREE:{BufferGeometry:Pr,CubicBezierCurve3:O$,Curve:l0,Group:nd,Line:K0,Mesh:ui,NormalBlending:ac,ShaderMaterial:Dl,TubeGeometry:c6,Vector3:Fe},nAt=u3.default||u3,o5e=xc({props:{arcsData:{default:[]},arcStartLat:{default:"startLat"},arcStartLng:{default:"startLng"},arcStartAltitude:{default:0},arcEndLat:{default:"endLat"},arcEndLng:{default:"endLng"},arcEndAltitude:{default:0},arcColor:{default:function(){return"#ffffaa"}},arcAltitude:{},arcAltitudeAutoScale:{default:.5},arcStroke:{},arcCurveResolution:{default:64,triggerUpdate:!1},arcCircularResolution:{default:6,triggerUpdate:!1},arcDashLength:{default:1},arcDashGap:{default:0},arcDashInitialGap:{default:0},arcDashAnimateTime:{default:0},arcsTransitionDuration:{default:1e3,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;e.sharedMaterial.dispose(),(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new nAt,sharedMaterial:new _0.ShaderMaterial(aa(aa({},a5e()),{},{transparent:!0,blending:_0.NormalBlending}))}},init:function(e,t){qo(e),t.scene=e,t.dataMapper=new bh(e,{objBindAttr:"__threeObjArc"}).onCreateObj(function(){var r=new _0.Group;return r.__globeObjType="arc",r}),t.ticker.onTick.add(function(r,i){t.dataMapper.entries().map(function(s){var a=co(s,2),o=a[1];return o}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],o=a.__dashAnimateStep*i,l=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=l+o})})},update:function(e){var t=En(e.arcStartLat),r=En(e.arcStartLng),i=En(e.arcStartAltitude),s=En(e.arcEndLat),a=En(e.arcEndLng),o=En(e.arcEndAltitude),l=En(e.arcAltitude),c=En(e.arcAltitudeAutoScale),u=En(e.arcStroke),d=En(e.arcColor),h=En(e.arcDashLength),p=En(e.arcDashGap),g=En(e.arcDashInitialGap),x=En(e.arcDashAnimateTime);e.dataMapper.onUpdateObj(function(C,k){var B=u(k),U=B!=null;if(!C.children.length||U!==(C.children[0].type==="Mesh")){qo(C);var z=U?new _0.Mesh:new _0.Line(new _0.BufferGeometry);z.material=e.sharedMaterial.clone(),C.add(z)}var O=C.children[0];Object.assign(O.material.uniforms,{dashSize:{value:h(k)},gapSize:{value:p(k)},dashOffset:{value:g(k)}});var V=x(k);O.__dashAnimateStep=V>0?1e3/V:0;var $=y(d(k),e.arcCurveResolution,U?e.arcCircularResolution+1:1),G=M(e.arcCurveResolution,U?e.arcCircularResolution+1:1,!0);O.geometry.setAttribute("color",$),O.geometry.setAttribute("relDistance",G);var H=function(ie){var ae=C.__currentTargetD=ie,Q=ae.stroke,re=z1t(ae,tAt),oe=_(re);U?(O.geometry&&O.geometry.dispose(),O.geometry=new _0.TubeGeometry(oe,e.arcCurveResolution,Q/2,e.arcCircularResolution),O.geometry.setAttribute("color",$),O.geometry.setAttribute("relDistance",G)):O.geometry.setFromPoints(oe.getPoints(e.arcCurveResolution))},K={stroke:B,alt:l(k),altAutoScale:+c(k),startLat:+t(k),startLng:+r(k),startAlt:+i(k),endLat:+s(k),endLng:+a(k),endAlt:+o(k)},W=C.__currentTargetD||Object.assign({},K,{altAutoScale:-.001});Object.keys(K).some(function(J){return W[J]!==K[J]})&&(!e.arcsTransitionDuration||e.arcsTransitionDuration<0?H(K):e.tweenGroup.add(new cd(W).to(K,e.arcsTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(H).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.arcsData);function _(C){var k=C.alt,B=C.altAutoScale,U=C.startLat,z=C.startLng,O=C.startAlt,V=C.endLat,$=C.endLng,G=C.endAlt,H=function(pe){var ge=co(pe,3),Te=ge[0],ze=ge[1],Xe=ge[2],Qe=i0(ze,Te,Xe),ot=Qe.x,bt=Qe.y,ht=Qe.z;return new _0.Vector3(ot,bt,ht)},K=[z,U],W=[$,V],J=k;if(J==null&&(J=qA(K,W)/2*B+Math.max(O,G)),J||O||G){var ie=AW(K,W),ae=function(pe,ge){return ge+(ge-pe)*(pe2&&arguments[2]!==void 0?arguments[2]:1,U=k+1,z;if(C instanceof Array||C instanceof Function){var O=C instanceof Array?Hg().domain(C.map(function(J,ie){return ie/(C.length-1)})).range(C):C;z=function(ie){return XA(O(ie),!0,!0)}}else{var V=XA(C,!0,!0);z=function(){return V}}for(var $=[],G=0,H=U;G1&&arguments[1]!==void 0?arguments[1]:1,B=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,U=C+1,z=[],O=0,V=U;O=O?B:U}),4)),k})):new D1.BufferGeometry,g=new D1.MeshLambertMaterial({color:16777215,transparent:!0,vertexColors:!0,side:D1.DoubleSide});g.onBeforeCompile=function(M){g.userData.shader=vq(M)};var x=new D1.Mesh(p,g);x.__globeObjType="hexBinPoints",x.__data=d,e.dataMapper.clear(),qo(e.scene),e.scene.add(x)}function _(M){var C=new D1.Mesh;C.__hexCenter=$ve(M.h3Idx),C.__hexGeoJson=Wve(M.h3Idx,!0).reverse();var k=C.__hexCenter[1];return C.__hexGeoJson.forEach(function(B){var U=B[0];Math.abs(k-U)>170&&(B[0]+=k>U?360:-360)}),C.__globeObjType="hexbin",C}function y(M,C){var k=function(ae,Q,re){return ae-(ae-Q)*re},B=Math.max(0,Math.min(1,+c(C))),U=co(M.__hexCenter,2),z=U[0],O=U[1],V=B===0?M.__hexGeoJson:M.__hexGeoJson.map(function(ie){var ae=co(ie,2),Q=ae[0],re=ae[1];return[[Q,O],[re,z]].map(function(oe){var fe=co(oe,2),ee=fe[0],me=fe[1];return k(ee,me,B)})}),$=e.hexTopCurvatureResolution;M.geometry&&M.geometry.dispose(),M.geometry=new NW([V],0,Wa,!1,!0,!0,$);var G={alt:+a(C)},H=function(ae){var Q=M.__currentTargetD=ae,re=Q.alt;M.scale.x=M.scale.y=M.scale.z=1+re;var oe=Wa/(re+1);M.geometry.setAttribute("surfaceRadius",ym(Array(M.geometry.getAttribute("position").count).fill(oe),1))},K=M.__currentTargetD||Object.assign({},G,{alt:-.001});if(Object.keys(G).some(function(ie){return K[ie]!==G[ie]})&&(e.hexBinMerge||!e.hexTransitionDuration||e.hexTransitionDuration<0?H(G):e.tweenGroup.add(new cd(K).to(G,e.hexTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(H).onComplete(function(){e.tweenGroup.remove(this)}).start())),!e.hexBinMerge){var W=l(C),J=o(C);[W,J].forEach(function(ie){if(!h.hasOwnProperty(ie)){var ae=$0(ie);h[ie]=_Y(new D1.MeshLambertMaterial({color:vm(ie),transparent:ae<1,opacity:ae,side:D1.DoubleSide}),vq)}}),M.material=[W,J].map(function(ie){return h[ie]})}}}}),c5e=function(e){return e*e},rg=function(e){return e*Math.PI/180};function rAt(n,e){var t=Math.sqrt,r=Math.cos,i=function(u){return c5e(Math.sin(u/2))},s=rg(n[1]),a=rg(e[1]),o=rg(n[0]),l=rg(e[0]);return 2*Math.asin(t(i(a-s)+r(s)*r(a)*i(l-o)))}var iAt=Math.sqrt(2*Math.PI);function sAt(n,e){return Math.exp(-c5e(n/e)/2)/(e*iAt)}var aAt=function(e){var t=co(e,2),r=t[0],i=t[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=a.lngAccessor,l=o===void 0?function(_){return _[0]}:o,c=a.latAccessor,u=c===void 0?function(_){return _[1]}:c,d=a.weightAccessor,h=d===void 0?function(){return 1}:d,p=a.bandwidth,g=[r,i],x=p*Math.PI/180;return ott(s.map(function(_){var y=h(_);if(!y)return 0;var M=rAt(g,[l(_),u(_)]);return sAt(M,x)*y}))},oAt=function(){var n=I1t(Aq().m(function e(t){var r,i,s,a,o,l,c,u,d,h,p,g,x,_,y,M,C,k,B,U,z,O,V,$,G,H,K,W,J,ie,ae,Q,re,oe,fe,ee,me,Ae,be,pe,ge=arguments,Te,ze,Xe;return Aq().w(function(Qe){for(;;)switch(Qe.n){case 0:if(i=ge.length>1&&ge[1]!==void 0?ge[1]:[],s=ge.length>2&&ge[2]!==void 0?ge[2]:{},a=s.lngAccessor,o=a===void 0?function(ot){return ot[0]}:a,l=s.latAccessor,c=l===void 0?function(ot){return ot[1]}:l,u=s.weightAccessor,d=u===void 0?function(){return 1}:u,h=s.bandwidth,(r=navigator)!==null&&r!==void 0&&r.gpu){Qe.n=1;break}return console.warn("WebGPU not enabled in browser. Please consider enabling it to improve performance."),Qe.a(2,t.map(function(ot){return aAt(ot,i,{lngAccessor:o,latAccessor:c,weightAccessor:d,bandwidth:h})}));case 1:return p=4,g=h1t,x=f1t,_=S1t,y=w1t,M=x1t,C=v1t,k=p1t,B=_1t,U=b1t,z=g1t,O=m1t,V=A1t,$=y1t,G=y(new RN(new Float32Array(t.flat().map(rg)),2),"vec2",t.length),H=y(new RN(new Float32Array(i.map(function(ot){return[rg(o(ot)),rg(c(ot)),d(ot)]}).flat()),3),"vec3",i.length),K=new RN(t.length,1),W=y(K,"float",t.length),J=M(Math.PI),ie=B(J.mul(2)),ae=function(bt){return bt.mul(bt)},Q=function(bt){return ae(U(bt.div(2)))},re=function(bt,ht){var Ce=M(bt[1]),lt=M(ht[1]),ft=M(bt[0]),et=M(ht[0]);return M(2).mul(O(B(Q(lt.sub(Ce)).add(z(Ce).mul(z(lt)).mul(Q(et.sub(ft)))))))},oe=function(bt,ht){return V($(ae(bt.div(ht)).div(2))).div(ht.mul(ie))},fe=_(rg(h)),ee=_(rg(h*p)),me=_(i.length),Ae=g(function(){var ot=G.element(C),bt=W.element(C);bt.assign(0),k(me,function(ht){var Ce=ht.i,lt=H.element(Ce),ft=lt.z;x(ft,function(){var et=re(lt.xy,ot.xy);x(et&&et.lessThan(ee),function(){bt.addAssign(oe(et,fe).mul(ft))})})})}),be=Ae().compute(t.length),pe=new Ywe,Qe.n=2,pe.computeAsync(be);case 2:return Te=Array,ze=Float32Array,Qe.n=3,pe.getArrayBufferAsync(K);case 3:return Xe=Qe.v,Qe.a(2,Te.from.call(Te,new ze(Xe)))}},e)}));return function(t){return n.apply(this,arguments)}}(),yE=window.THREE?window.THREE:{Mesh:ui,MeshLambertMaterial:op,SphereGeometry:gf},lAt=3.5,cAt=.1,Iue=100,uAt=function(e){var t=kg(Cat(e));return t.opacity=Math.cbrt(e),t.formatRgb()},u5e=xc({props:{heatmapsData:{default:[]},heatmapPoints:{default:function(e){return e}},heatmapPointLat:{default:function(e){return e[0]}},heatmapPointLng:{default:function(e){return e[1]}},heatmapPointWeight:{default:1},heatmapBandwidth:{default:2.5},heatmapColorFn:{default:function(){return uAt}},heatmapColorSaturation:{default:1.5},heatmapBaseAltitude:{default:.01},heatmapTopAltitude:{},heatmapsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;qo(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new bh(e,{objBindAttr:"__threeObjHeatmap"}).onCreateObj(function(){var s=new yE.Mesh(new yE.SphereGeometry(Wa),_Y(new yE.MeshLambertMaterial({vertexColors:!0,transparent:!0}),J1t));return s.__globeObjType="heatmap",s})},update:function(e){var t=En(e.heatmapPoints),r=En(e.heatmapPointLat),i=En(e.heatmapPointLng),s=En(e.heatmapPointWeight),a=En(e.heatmapBandwidth),o=En(e.heatmapColorFn),l=En(e.heatmapColorSaturation),c=En(e.heatmapBaseAltitude),u=En(e.heatmapTopAltitude);e.dataMapper.onUpdateObj(function(d,h){var p=a(h),g=o(h),x=l(h),_=c(h),y=u(h),M=t(h).map(function(z){var O=r(z),V=i(z),$=i0(O,V),G=$.x,H=$.y,K=$.z;return{x:G,y:H,z:K,lat:O,lng:V,weight:s(z)}}),C=Math.max(cAt,p/lAt),k=Math.ceil(360/(C||-1));d.geometry.parameters.widthSegments!==k&&(d.geometry.dispose(),d.geometry=new yE.SphereGeometry(Wa,k,k/2));var B=K1t(d.geometry.getAttribute("position")),U=B.map(function(z){var O=co(z,3),V=O[0],$=O[1],G=O[2],H=r5e({x:V,y:$,z:G}),K=H.lng,W=H.lat;return[K,W]});oAt(U,M,{latAccessor:function(O){return O.lat},lngAccessor:function(O){return O.lng},weightAccessor:function(O){return O.weight},bandwidth:p}).then(function(z){var O=xa(new Array(Iue)).map(function(H,K){return XA(g(K/(Iue-1)))}),V=function(K){var W=d.__currentTargetD=K,J=W.kdeVals,ie=W.topAlt,ae=W.saturation,Q=itt(J.map(Math.abs))||1e-15,re=$xe([0,Q/ae],O);d.geometry.setAttribute("color",ym(J.map(function(fe){return re(Math.abs(fe))}),4));var oe=Hg([0,Q],[Wa*(1+_),Wa*(1+(ie||_))]);d.geometry.setAttribute("r",ym(J.map(oe)))},$={kdeVals:z,topAlt:y,saturation:x},G=d.__currentTargetD||Object.assign({},$,{kdeVals:z.map(function(){return 0}),topAlt:y&&_,saturation:.5});G.kdeVals.length!==z.length&&(G.kdeVals=z.slice()),Object.keys($).some(function(H){return G[H]!==$[H]})&&(!e.heatmapsTransitionDuration||e.heatmapsTransitionDuration<0?V($):e.tweenGroup.add(new cd(G).to($,e.heatmapsTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(V).onComplete(function(){e.tweenGroup.remove(this)}).start()))})}).digest(e.heatmapsData)}}),O1=window.THREE?window.THREE:{DoubleSide:ao,Group:nd,LineBasicMaterial:Ac,LineSegments:o0,Mesh:ui,MeshBasicMaterial:oc},d5e=xc({props:{polygonsData:{default:[]},polygonGeoJsonGeometry:{default:"geometry"},polygonSideColor:{default:function(){return"#ffffaa"}},polygonSideMaterial:{},polygonCapColor:{default:function(){return"#ffffaa"}},polygonCapMaterial:{},polygonStrokeColor:{},polygonAltitude:{default:.01},polygonCapCurvatureResolution:{default:5},polygonsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;qo(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new bh(e,{objBindAttr:"__threeObjPolygon"}).id(function(s){return s.id}).onCreateObj(function(){var s=new O1.Group;return s.__defaultSideMaterial=_Y(new O1.MeshBasicMaterial({side:O1.DoubleSide,depthWrite:!0}),vq),s.__defaultCapMaterial=new O1.MeshBasicMaterial({side:O1.DoubleSide,depthWrite:!0}),s.add(new O1.Mesh(void 0,[s.__defaultSideMaterial,s.__defaultCapMaterial])),s.add(new O1.LineSegments(void 0,new O1.LineBasicMaterial)),s.__globeObjType="polygon",s})},update:function(e){var t=En(e.polygonGeoJsonGeometry),r=En(e.polygonAltitude),i=En(e.polygonCapCurvatureResolution),s=En(e.polygonCapColor),a=En(e.polygonCapMaterial),o=En(e.polygonSideColor),l=En(e.polygonSideMaterial),c=En(e.polygonStrokeColor),u=[];e.polygonsData.forEach(function(d){var h={data:d,capColor:s(d),capMaterial:a(d),sideColor:o(d),sideMaterial:l(d),strokeColor:c(d),altitude:+r(d),capCurvatureResolution:+i(d)},p=t(d),g=d.__id||"".concat(Math.round(Math.random()*1e9));d.__id=g,p.type==="Polygon"?u.push(aa({id:"".concat(g,"_0"),coords:p.coordinates},h)):p.type==="MultiPolygon"?u.push.apply(u,xa(p.coordinates.map(function(x,_){return aa({id:"".concat(g,"_").concat(_),coords:x},h)}))):console.warn("Unsupported GeoJson geometry type: ".concat(p.type,". Skipping geometry..."))}),e.dataMapper.onUpdateObj(function(d,h){var p=h.coords,g=h.capColor,x=h.capMaterial,_=h.sideColor,y=h.sideMaterial,M=h.strokeColor,C=h.altitude,k=h.capCurvatureResolution,B=co(d.children,2),U=B[0],z=B[1],O=!!M;z.visible=O;var V=!!(g||x),$=!!(_||y);dAt(U.geometry.parameters||{},{polygonGeoJson:p,curvatureResolution:k,closedTop:V,includeSides:$})||(U.geometry&&U.geometry.dispose(),U.geometry=new NW(p,0,Wa,!1,V,$,k)),O&&(!z.geometry.parameters||z.geometry.parameters.geoJson.coordinates!==p||z.geometry.parameters.resolution!==k)&&(z.geometry&&z.geometry.dispose(),z.geometry=new Eve({type:"Polygon",coordinates:p},Wa,k));var G=$?0:-1,H=V?$?1:0:-1;if(G>=0&&(U.material[G]=y||d.__defaultSideMaterial),H>=0&&(U.material[H]=x||d.__defaultCapMaterial),[[!y&&_,G],[!x&&g,H]].forEach(function(Q){var re=co(Q,2),oe=re[0],fe=re[1];if(!(!oe||fe<0)){var ee=U.material[fe],me=$0(oe);ee.color.set(vm(oe)),ee.transparent=me<1,ee.opacity=me}}),O){var K=z.material,W=$0(M);K.color.set(vm(M)),K.transparent=W<1,K.opacity=W}var J={alt:C},ie=function(re){var oe=d.__currentTargetD=re,fe=oe.alt;U.scale.x=U.scale.y=U.scale.z=1+fe,O&&(z.scale.x=z.scale.y=z.scale.z=1+fe+1e-4),eAt(d.__defaultSideMaterial,function(ee){return ee.uSurfaceRadius.value=Wa/(fe+1)})},ae=d.__currentTargetD||Object.assign({},J,{alt:-.001});Object.keys(J).some(function(Q){return ae[Q]!==J[Q]})&&(!e.polygonsTransitionDuration||e.polygonsTransitionDuration<0||ae.alt===J.alt?ie(J):e.tweenGroup.add(new cd(ae).to(J,e.polygonsTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(ie).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(u)}});function dAt(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return function(r,i){return r===i}};return Object.entries(e).every(function(r){var i=co(r,2),s=i[0],a=i[1];return n.hasOwnProperty(s)&&t(s)(n[s],a)})}var vb=window.THREE?window.THREE:{BufferGeometry:Pr,DoubleSide:ao,Mesh:ui,MeshLambertMaterial:op,Vector3:Fe},Due=Object.assign({},_W),Oue=Due.BufferGeometryUtils||Due,h5e=xc({props:{hexPolygonsData:{default:[]},hexPolygonGeoJsonGeometry:{default:"geometry"},hexPolygonColor:{default:function(){return"#ffffaa"}},hexPolygonAltitude:{default:.001},hexPolygonResolution:{default:3},hexPolygonMargin:{default:.2},hexPolygonUseDots:{default:!1},hexPolygonCurvatureResolution:{default:5},hexPolygonDotResolution:{default:12},hexPolygonsTransitionDuration:{default:0,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;qo(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new bh(e,{objBindAttr:"__threeObjHexPolygon"}).onCreateObj(function(){var s=new vb.Mesh(void 0,new vb.MeshLambertMaterial({side:vb.DoubleSide}));return s.__globeObjType="hexPolygon",s})},update:function(e){var t=En(e.hexPolygonGeoJsonGeometry),r=En(e.hexPolygonColor),i=En(e.hexPolygonAltitude),s=En(e.hexPolygonResolution),a=En(e.hexPolygonMargin),o=En(e.hexPolygonUseDots),l=En(e.hexPolygonCurvatureResolution),c=En(e.hexPolygonDotResolution);e.dataMapper.onUpdateObj(function(u,d){var h=t(d),p=s(d),g=i(d),x=Math.max(0,Math.min(1,+a(d))),_=o(d),y=l(d),M=c(d),C=r(d),k=$0(C);u.material.color.set(vm(C)),u.material.transparent=k<1,u.material.opacity=k;var B={alt:g,margin:x,curvatureResolution:y},U={geoJson:h,h3Res:p},z=u.__currentTargetD||Object.assign({},B,{alt:-.001}),O=u.__currentMemD||U;if(Object.keys(B).some(function(H){return z[H]!==B[H]})||Object.keys(U).some(function(H){return O[H]!==U[H]})){u.__currentMemD=U;var V=[];h.type==="Polygon"?Gle(h.coordinates,p,!0).forEach(function(H){return V.push(H)}):h.type==="MultiPolygon"?h.coordinates.forEach(function(H){return Gle(H,p,!0).forEach(function(K){return V.push(K)})}):console.warn("Unsupported GeoJson geometry type: ".concat(h.type,". Skipping geometry..."));var $=V.map(function(H){var K=$ve(H),W=Wve(H,!0).reverse(),J=K[1];return W.forEach(function(ie){var ae=ie[0];Math.abs(J-ae)>170&&(ie[0]+=J>ae?360:-360)}),{h3Idx:H,hexCenter:K,hexGeoJson:W}}),G=function(K){var W=u.__currentTargetD=K,J=W.alt,ie=W.margin,ae=W.curvatureResolution;u.geometry&&u.geometry.dispose(),u.geometry=$.length?(Oue.mergeGeometries||Oue.mergeBufferGeometries)($.map(function(Q){var re=co(Q.hexCenter,2),oe=re[0],fe=re[1];if(_){var ee=i0(oe,fe,J),me=i0(Q.hexGeoJson[0][1],Q.hexGeoJson[0][0],J),Ae=.85*(1-ie)*new vb.Vector3(ee.x,ee.y,ee.z).distanceTo(new vb.Vector3(me.x,me.y,me.z)),be=new z3(Ae,M);return be.rotateX(px(-oe)),be.rotateY(px(fe)),be.translate(ee.x,ee.y,ee.z),be}else{var pe=function(ze,Xe,Qe){return ze-(ze-Xe)*Qe},ge=ie===0?Q.hexGeoJson:Q.hexGeoJson.map(function(Te){var ze=co(Te,2),Xe=ze[0],Qe=ze[1];return[[Xe,fe],[Qe,oe]].map(function(ot){var bt=co(ot,2),ht=bt[0],Ce=bt[1];return pe(ht,Ce,ie)})});return new NW([ge],Wa,Wa*(1+J),!1,!0,!1,ae)}})):new vb.BufferGeometry};!e.hexPolygonsTransitionDuration||e.hexPolygonsTransitionDuration<0?G(B):e.tweenGroup.add(new cd(z).to(B,e.hexPolygonsTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(G).onComplete(function(){e.tweenGroup.remove(this)}).start())}}).digest(e.hexPolygonsData)}}),hAt=window.THREE?window.THREE:{Vector3:Fe};function fAt(n,e){var t=function(a,o){var l=a[a.length-1];return[].concat(xa(a),xa(Array(o-a.length).fill(l)))},r=Math.max(n.length,e.length),i=N9e.apply(void 0,xa([n,e].map(function(s){return s.map(function(a){var o=a.x,l=a.y,c=a.z;return[o,l,c]})}).map(function(s){return t(s,r)})));return function(s){return s===0?n:s===1?e:i(s).map(function(a){var o=co(a,3),l=o[0],c=o[1],u=o[2];return new hAt.Vector3(l,c,u)})}}var Z2=window.THREE?window.THREE:{BufferGeometry:Pr,Color:Fn,Group:nd,Line:K0,NormalBlending:ac,ShaderMaterial:Dl,Vector3:Fe},pAt=u3.default||u3,f5e=xc({props:{pathsData:{default:[]},pathPoints:{default:function(e){return e}},pathPointLat:{default:function(e){return e[0]}},pathPointLng:{default:function(e){return e[1]}},pathPointAlt:{default:.001},pathResolution:{default:2},pathColor:{default:function(){return"#ffffaa"}},pathStroke:{},pathDashLength:{default:1},pathDashGap:{default:0},pathDashInitialGap:{default:0},pathDashAnimateTime:{default:0},pathTransitionDuration:{default:1e3,triggerUpdate:!1},rendererSize:{}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},stateInit:function(e){var t=e.tweenGroup;return{tweenGroup:t,ticker:new pAt,sharedMaterial:new Z2.ShaderMaterial(aa(aa({},a5e()),{},{transparent:!0,blending:Z2.NormalBlending}))}},init:function(e,t){qo(e),t.scene=e,t.dataMapper=new bh(e,{objBindAttr:"__threeObjPath"}).onCreateObj(function(){var r=new Z2.Group;return r.__globeObjType="path",r}),t.ticker.onTick.add(function(r,i){t.dataMapper.entries().map(function(s){var a=co(s,2),o=a[1];return o}).filter(function(s){return s.children.length&&s.children[0].material&&s.children[0].__dashAnimateStep}).forEach(function(s){var a=s.children[0],o=a.__dashAnimateStep*i;if(a.type==="Line"){var l=a.material.uniforms.dashTranslate.value%1e9;a.material.uniforms.dashTranslate.value=l+o}else if(a.type==="Line2"){for(var c=a.material.dashOffset-o,u=a.material.dashSize+a.material.gapSize;c<=-u;)c+=u;a.material.dashOffset=c}})})},update:function(e){var t=En(e.pathPoints),r=En(e.pathPointLat),i=En(e.pathPointLng),s=En(e.pathPointAlt),a=En(e.pathStroke),o=En(e.pathColor),l=En(e.pathDashLength),c=En(e.pathDashGap),u=En(e.pathDashInitialGap),d=En(e.pathDashAnimateTime);e.dataMapper.onUpdateObj(function(_,y){var M=a(y),C=M!=null;if(!_.children.length||C===(_.children[0].type==="Line")){qo(_);var k=C?new M1t(new Qwe,new vY):new Z2.Line(new Z2.BufferGeometry,e.sharedMaterial.clone());_.add(k)}var B=_.children[0],U=p(t(y),r,i,s,e.pathResolution),z=d(y);if(B.__dashAnimateStep=z>0?1e3/z:0,C){B.material.resolution=e.rendererSize;{var $=l(y),G=c(y),H=u(y);B.material.dashed=G>0,B.material.dashed?B.material.defines.USE_DASH="":delete B.material.defines.USE_DASH,B.material.dashed&&(B.material.dashScale=1/h(U),B.material.dashSize=$,B.material.gapSize=G,B.material.dashOffset=-H)}{var K=o(y);if(K instanceof Array){var W=g(o(y),U.length-1,1,!1);B.geometry.setColors(W.array),B.material.vertexColors=!0}else{var J=K,ie=$0(J);B.material.color=new Z2.Color(vm(J)),B.material.transparent=ie<1,B.material.opacity=ie,B.material.vertexColors=!1}}B.material.needsUpdate=!0}else{Object.assign(B.material.uniforms,{dashSize:{value:l(y)},gapSize:{value:c(y)},dashOffset:{value:u(y)}});var O=g(o(y),U.length),V=x(U.length,1,!0);B.geometry.setAttribute("color",O),B.geometry.setAttribute("relDistance",V)}var ae=fAt(_.__currentTargetD&&_.__currentTargetD.points||[U[0]],U),Q=function(ee){var me=_.__currentTargetD=ee,Ae=me.stroke,be=me.interpolK,pe=_.__currentTargetD.points=ae(be);if(C){var ge;B.geometry.setPositions((ge=[]).concat.apply(ge,xa(pe.map(function(Te){var ze=Te.x,Xe=Te.y,Qe=Te.z;return[ze,Xe,Qe]})))),B.material.linewidth=Ae,B.material.dashed&&B.computeLineDistances()}else B.geometry.setFromPoints(pe),B.geometry.computeBoundingSphere()},re={stroke:M,interpolK:1},oe=Object.assign({},_.__currentTargetD||re,{interpolK:0});Object.keys(re).some(function(fe){return oe[fe]!==re[fe]})&&(!e.pathTransitionDuration||e.pathTransitionDuration<0?Q(re):e.tweenGroup.add(new cd(oe).to(re,e.pathTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(Q).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.pathsData);function h(_){var y=0,M;return _.forEach(function(C){M&&(y+=M.distanceTo(C)),M=C}),y}function p(_,y,M,C,k){var B=function(V,$,G){for(var H=[],K=1;K<=G;K++)H.push(V+($-V)*K/(G+1));return H},U=function(){var V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],$=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,G=[],H=null;return V.forEach(function(K){if(H){for(;Math.abs(H[1]-K[1])>180;)H[1]+=360*(H[1]$)for(var J=Math.floor(W/$),ie=B(H[0],K[0],J),ae=B(H[1],K[1],J),Q=B(H[2],K[2],J),re=0,oe=ie.length;re2&&arguments[2]!==void 0?arguments[2]:1,C=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,k=y+1,B;if(_ instanceof Array||_ instanceof Function){var U=_ instanceof Array?Hg().domain(_.map(function(K,W){return W/(_.length-1)})).range(_):_;B=function(W){return XA(U(W),C,!0)}}else{var z=XA(_,C,!0);B=function(){return z}}for(var O=[],V=0,$=k;V<$;V++)for(var G=B(V/($-1)),H=0;H1&&arguments[1]!==void 0?arguments[1]:1,M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,C=_+1,k=[],B=0,U=C;B0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:32;QR(this,e),t=ZR(this,e),t.type="CircleLineGeometry",t.parameters={radius:r,segmentCount:i};for(var s=[],a=0;a<=i;a++){var o=(a/i-.25)*Math.PI*2;s.push({x:Math.cos(o)*r,y:Math.sin(o)*r,z:0})}return t.setFromPoints(s),t}return JR(e,n),KR(e)}(mAt.BufferGeometry),bb=window.THREE?window.THREE:{Color:Fn,Group:nd,Line:K0,LineBasicMaterial:Ac,Vector3:Fe},AAt=u3.default||u3,g5e=xc({props:{ringsData:{default:[]},ringLat:{default:"lat"},ringLng:{default:"lng"},ringAltitude:{default:.0015},ringColor:{default:function(){return"#ffffaa"},triggerUpdate:!1},ringResolution:{default:64,triggerUpdate:!1},ringMaxRadius:{default:2,triggerUpdate:!1},ringPropagationSpeed:{default:1,triggerUpdate:!1},ringRepeatPeriod:{default:700,triggerUpdate:!1}},methods:{pauseAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.pause()},resumeAnimation:function(e){var t;(t=e.ticker)===null||t===void 0||t.resume()},_destructor:function(e){var t;(t=e.ticker)===null||t===void 0||t.dispose()}},init:function(e,t,r){var i=r.tweenGroup;qo(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new bh(e,{objBindAttr:"__threeObjRing",removeDelay:3e4}).onCreateObj(function(){var s=new bb.Group;return s.__globeObjType="ring",s}),t.ticker=new AAt,t.ticker.onTick.add(function(s){if(t.ringsData.length){var a=En(t.ringColor),o=En(t.ringAltitude),l=En(t.ringMaxRadius),c=En(t.ringPropagationSpeed),u=En(t.ringRepeatPeriod);t.dataMapper.entries().filter(function(d){var h=co(d,2),p=h[1];return p}).forEach(function(d){var h=co(d,2),p=h[0],g=h[1];if((g.__nextRingTime||0)<=s){var x=u(p)/1e3;g.__nextRingTime=s+(x<=0?1/0:x);var _=new bb.Line(new gAt(1,t.ringResolution),new bb.LineBasicMaterial),y=a(p),M=y instanceof Array||y instanceof Function,C;M?y instanceof Array?(C=Hg().domain(y.map(function(G,H){return H/(y.length-1)})).range(y),_.material.transparent=y.some(function(G){return $0(G)<1})):(C=y,_.material.transparent=!0):(_.material.color=new bb.Color(vm(y)),Q1t(_.material,$0(y)));var k=Wa*(1+o(p)),B=l(p),U=B*Math.PI/180,z=c(p),O=z<=0,V=function(H){var K=H.t,W=(O?1-K:K)*U;if(_.scale.x=_.scale.y=k*Math.sin(W),_.position.z=k*(1-Math.cos(W)),M){var J=C(K);_.material.color=new bb.Color(vm(J)),_.material.transparent&&(_.material.opacity=$0(J))}};if(z===0)V({t:0}),g.add(_);else{var $=Math.abs(B/z)*1e3;t.tweenGroup.add(new cd({t:0}).to({t:1},$).onUpdate(V).onStart(function(){return g.add(_)}).onComplete(function(){t.tweenGroup.remove(this),g.remove(_),hA(_)}).start())}}})}})},update:function(e){var t=En(e.ringLat),r=En(e.ringLng),i=En(e.ringAltitude),s=e.scene.localToWorld(new bb.Vector3(0,0,0));e.dataMapper.onUpdateObj(function(a,o){var l=t(o),c=r(o),u=i(o);Object.assign(a.position,i0(l,c,u)),a.lookAt(s)}).digest(e.ringsData)}}),xAt={0:{x_min:73,x_max:715,ha:792,o:"m 394 -29 q 153 129 242 -29 q 73 479 73 272 q 152 829 73 687 q 394 989 241 989 q 634 829 545 989 q 715 479 715 684 q 635 129 715 270 q 394 -29 546 -29 m 394 89 q 546 211 489 89 q 598 479 598 322 q 548 748 598 640 q 394 871 491 871 q 241 748 298 871 q 190 479 190 637 q 239 211 190 319 q 394 89 296 89 "},1:{x_min:215.671875,x_max:574,ha:792,o:"m 574 0 l 442 0 l 442 697 l 215 697 l 215 796 q 386 833 330 796 q 475 986 447 875 l 574 986 l 574 0 "},2:{x_min:59,x_max:731,ha:792,o:"m 731 0 l 59 0 q 197 314 59 188 q 457 487 199 315 q 598 691 598 580 q 543 819 598 772 q 411 867 488 867 q 272 811 328 867 q 209 630 209 747 l 81 630 q 182 901 81 805 q 408 986 271 986 q 629 909 536 986 q 731 694 731 826 q 613 449 731 541 q 378 316 495 383 q 201 122 235 234 l 731 122 l 731 0 "},3:{x_min:54,x_max:737,ha:792,o:"m 737 284 q 635 55 737 141 q 399 -25 541 -25 q 156 52 248 -25 q 54 308 54 140 l 185 308 q 245 147 185 202 q 395 96 302 96 q 539 140 484 96 q 602 280 602 190 q 510 429 602 390 q 324 454 451 454 l 324 565 q 487 584 441 565 q 565 719 565 617 q 515 835 565 791 q 395 879 466 879 q 255 824 307 879 q 203 661 203 769 l 78 661 q 166 909 78 822 q 387 992 250 992 q 603 921 513 992 q 701 723 701 844 q 669 607 701 656 q 578 524 637 558 q 696 434 655 499 q 737 284 737 369 "},4:{x_min:48,x_max:742.453125,ha:792,o:"m 742 243 l 602 243 l 602 0 l 476 0 l 476 243 l 48 243 l 48 368 l 476 958 l 602 958 l 602 354 l 742 354 l 742 243 m 476 354 l 476 792 l 162 354 l 476 354 "},5:{x_min:54.171875,x_max:738,ha:792,o:"m 738 314 q 626 60 738 153 q 382 -23 526 -23 q 155 47 248 -23 q 54 256 54 125 l 183 256 q 259 132 204 174 q 382 91 314 91 q 533 149 471 91 q 602 314 602 213 q 538 469 602 411 q 386 528 475 528 q 284 506 332 528 q 197 439 237 484 l 81 439 l 159 958 l 684 958 l 684 840 l 254 840 l 214 579 q 306 627 258 612 q 407 643 354 643 q 636 552 540 643 q 738 314 738 457 "},6:{x_min:53,x_max:739,ha:792,o:"m 739 312 q 633 62 739 162 q 400 -31 534 -31 q 162 78 257 -31 q 53 439 53 206 q 178 859 53 712 q 441 986 284 986 q 643 912 559 986 q 732 713 732 833 l 601 713 q 544 830 594 786 q 426 875 494 875 q 268 793 331 875 q 193 517 193 697 q 301 597 240 570 q 427 624 362 624 q 643 540 552 624 q 739 312 739 451 m 603 298 q 540 461 603 400 q 404 516 484 516 q 268 461 323 516 q 207 300 207 401 q 269 137 207 198 q 405 83 325 83 q 541 137 486 83 q 603 298 603 197 "},7:{x_min:58.71875,x_max:730.953125,ha:792,o:"m 730 839 q 469 448 560 641 q 335 0 378 255 l 192 0 q 328 441 235 252 q 593 830 421 630 l 58 830 l 58 958 l 730 958 l 730 839 "},8:{x_min:55,x_max:736,ha:792,o:"m 571 527 q 694 424 652 491 q 736 280 736 358 q 648 71 736 158 q 395 -26 551 -26 q 142 69 238 -26 q 55 279 55 157 q 96 425 55 359 q 220 527 138 491 q 120 615 153 562 q 88 726 88 668 q 171 904 88 827 q 395 986 261 986 q 618 905 529 986 q 702 727 702 830 q 670 616 702 667 q 571 527 638 565 m 394 565 q 519 610 475 565 q 563 717 563 655 q 521 823 563 781 q 392 872 474 872 q 265 824 312 872 q 224 720 224 783 q 265 613 224 656 q 394 565 312 565 m 395 91 q 545 150 488 91 q 597 280 597 204 q 546 408 597 355 q 395 465 492 465 q 244 408 299 465 q 194 280 194 356 q 244 150 194 203 q 395 91 299 91 "},9:{x_min:53,x_max:739,ha:792,o:"m 739 524 q 619 94 739 241 q 362 -32 516 -32 q 150 47 242 -32 q 59 244 59 126 l 191 244 q 246 129 191 176 q 373 82 301 82 q 526 161 466 82 q 597 440 597 255 q 363 334 501 334 q 130 432 216 334 q 53 650 53 521 q 134 880 53 786 q 383 986 226 986 q 659 841 566 986 q 739 524 739 719 m 388 449 q 535 514 480 449 q 585 658 585 573 q 535 805 585 744 q 388 873 480 873 q 242 809 294 873 q 191 658 191 745 q 239 514 191 572 q 388 449 292 449 "},ο:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},S:{x_min:0,x_max:788,ha:890,o:"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{x_min:183.25,x_max:608.328125,ha:792,o:"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},Τ:{x_min:-.4375,x_max:777.453125,ha:839,o:"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},y:{x_min:0,x_max:684.78125,ha:771,o:"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},Π:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},ΐ:{x_min:-111,x_max:339,ha:361,o:"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},g:{x_min:0,x_max:686,ha:838,o:"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{x_min:0,x_max:442,ha:539,o:"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},Κ:{x_min:0,x_max:819.5625,ha:893,o:"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},ƒ:{x_min:-46.265625,x_max:392,ha:513,o:"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},e:{x_min:0,x_max:714,ha:813,o:"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},ό:{x_min:0,x_max:712,ha:815,o:"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},J:{x_min:0,x_max:588,ha:699,o:"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{x_min:-1,x_max:503,ha:601,o:"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{x_min:-3,x_max:1008,ha:1106,o:"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 190 q 228 497 228 370 q 295 714 228 625 q 499 813 370 813 q 656 762 588 813 q 733 625 724 711 l 634 625 q 589 704 629 673 q 498 735 550 735 q 377 666 421 735 q 334 504 334 597 q 374 340 334 408 q 490 272 415 272 q 589 304 549 272 q 638 394 628 337 l 741 394 "},ώ:{x_min:0,x_max:922,ha:1030,o:"m 687 1040 l 498 819 l 415 819 l 549 1040 l 687 1040 m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 338 0 202 q 45 551 0 444 q 161 737 84 643 l 302 737 q 175 552 219 647 q 124 336 124 446 q 155 179 124 248 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 341 797 257 q 745 555 797 450 q 619 737 705 637 l 760 737 q 874 551 835 640 q 922 339 922 444 "},"^":{x_min:193.0625,x_max:598.609375,ha:792,o:"m 598 772 l 515 772 l 395 931 l 277 772 l 193 772 l 326 1013 l 462 1013 l 598 772 "},"«":{x_min:0,x_max:507.203125,ha:604,o:"m 506 136 l 284 302 l 284 440 l 506 608 l 507 485 l 360 371 l 506 255 l 506 136 m 222 136 l 0 302 l 0 440 l 222 608 l 221 486 l 73 373 l 222 256 l 222 136 "},D:{x_min:0,x_max:828,ha:935,o:"m 389 1013 q 714 867 593 1013 q 828 521 828 729 q 712 161 828 309 q 382 0 587 0 l 0 0 l 0 1013 l 389 1013 m 376 124 q 607 247 523 124 q 681 510 681 355 q 607 771 681 662 q 376 896 522 896 l 139 896 l 139 124 l 376 124 "},"∙":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},ÿ:{x_min:0,x_max:47,ha:125,o:"m 47 3 q 37 -7 47 -7 q 28 0 30 -7 q 39 -4 32 -4 q 45 3 45 -1 l 37 0 q 28 9 28 0 q 39 19 28 19 l 47 16 l 47 19 l 47 3 m 37 1 q 44 8 44 1 q 37 16 44 16 q 30 8 30 16 q 37 1 30 1 m 26 1 l 23 22 l 14 0 l 3 22 l 3 3 l 0 25 l 13 1 l 22 25 l 26 1 "},w:{x_min:0,x_max:1009.71875,ha:1100,o:"m 1009 738 l 783 0 l 658 0 l 501 567 l 345 0 l 222 0 l 0 738 l 130 738 l 284 174 l 432 737 l 576 738 l 721 173 l 881 737 l 1009 738 "},$:{x_min:0,x_max:700,ha:793,o:"m 664 717 l 542 717 q 490 825 531 785 q 381 872 450 865 l 381 551 q 620 446 540 522 q 700 241 700 370 q 618 45 700 116 q 381 -25 536 -25 l 381 -152 l 307 -152 l 307 -25 q 81 62 162 -25 q 0 297 0 149 l 124 297 q 169 146 124 204 q 307 81 215 89 l 307 441 q 80 536 148 469 q 13 725 13 603 q 96 910 13 839 q 307 982 180 982 l 307 1077 l 381 1077 l 381 982 q 574 917 494 982 q 664 717 664 845 m 307 565 l 307 872 q 187 831 233 872 q 142 724 142 791 q 180 618 142 656 q 307 565 218 580 m 381 76 q 562 237 562 96 q 517 361 562 313 q 381 423 472 409 l 381 76 "},"\\":{x_min:-.015625,x_max:425.0625,ha:522,o:"m 425 -129 l 337 -129 l 0 1041 l 83 1041 l 425 -129 "},µ:{x_min:0,x_max:697.21875,ha:747,o:"m 697 -4 q 629 -14 658 -14 q 498 97 513 -14 q 422 9 470 41 q 313 -23 374 -23 q 207 4 258 -23 q 119 81 156 32 l 119 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 173 124 246 q 308 83 216 83 q 452 178 402 83 q 493 359 493 255 l 493 738 l 617 738 l 617 214 q 623 136 617 160 q 673 92 637 92 q 697 96 684 92 l 697 -4 "},Ι:{x_min:42,x_max:181,ha:297,o:"m 181 0 l 42 0 l 42 1013 l 181 1013 l 181 0 "},Ύ:{x_min:0,x_max:1144.5,ha:1214,o:"m 1144 1012 l 807 416 l 807 0 l 667 0 l 667 416 l 325 1012 l 465 1012 l 736 533 l 1004 1012 l 1144 1012 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"’":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},Ν:{x_min:0,x_max:801,ha:915,o:"m 801 0 l 651 0 l 131 822 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 191 l 670 1013 l 801 1013 l 801 0 "},"-":{x_min:8.71875,x_max:350.390625,ha:478,o:"m 350 317 l 8 317 l 8 428 l 350 428 l 350 317 "},Q:{x_min:0,x_max:968,ha:1072,o:"m 954 5 l 887 -79 l 744 35 q 622 -11 687 2 q 483 -26 556 -26 q 127 130 262 -26 q 0 504 0 279 q 127 880 0 728 q 484 1041 262 1041 q 841 884 708 1041 q 968 507 968 735 q 933 293 968 398 q 832 104 899 188 l 954 5 m 723 191 q 802 330 777 248 q 828 499 828 412 q 744 790 828 673 q 483 922 650 922 q 228 791 322 922 q 142 505 142 673 q 227 221 142 337 q 487 91 323 91 q 632 123 566 91 l 520 215 l 587 301 l 723 191 "},ς:{x_min:1,x_max:676.28125,ha:740,o:"m 676 460 l 551 460 q 498 595 542 546 q 365 651 448 651 q 199 578 263 651 q 136 401 136 505 q 266 178 136 241 q 508 106 387 142 q 640 -50 640 62 q 625 -158 640 -105 q 583 -278 611 -211 l 465 -278 q 498 -182 490 -211 q 515 -80 515 -126 q 381 12 515 -15 q 134 91 197 51 q 1 388 1 179 q 100 651 1 542 q 354 761 199 761 q 587 680 498 761 q 676 460 676 599 "},M:{x_min:0,x_max:954,ha:1067,o:"m 954 0 l 819 0 l 819 869 l 537 0 l 405 0 l 128 866 l 128 0 l 0 0 l 0 1013 l 200 1013 l 472 160 l 757 1013 l 954 1013 l 954 0 "},Ψ:{x_min:0,x_max:1006,ha:1094,o:"m 1006 678 q 914 319 1006 429 q 571 200 814 200 l 571 0 l 433 0 l 433 200 q 92 319 194 200 q 0 678 0 429 l 0 1013 l 139 1013 l 139 679 q 191 417 139 492 q 433 326 255 326 l 433 1013 l 571 1013 l 571 326 l 580 326 q 813 423 747 326 q 868 679 868 502 l 868 1013 l 1006 1013 l 1006 678 "},C:{x_min:0,x_max:886,ha:944,o:"m 886 379 q 760 87 886 201 q 455 -26 634 -26 q 112 136 236 -26 q 0 509 0 283 q 118 882 0 737 q 469 1041 245 1041 q 748 955 630 1041 q 879 708 879 859 l 745 708 q 649 862 724 805 q 473 920 573 920 q 219 791 312 920 q 136 509 136 675 q 217 229 136 344 q 470 99 311 99 q 672 179 591 99 q 753 379 753 259 l 886 379 "},"!":{x_min:0,x_max:138,ha:236,o:"m 138 684 q 116 409 138 629 q 105 244 105 299 l 33 244 q 16 465 33 313 q 0 684 0 616 l 0 1013 l 138 1013 l 138 684 m 138 0 l 0 0 l 0 151 l 138 151 l 138 0 "},"{":{x_min:0,x_max:480.5625,ha:578,o:"m 480 -286 q 237 -213 303 -286 q 187 -45 187 -159 q 194 48 187 -15 q 201 141 201 112 q 164 264 201 225 q 0 314 118 314 l 0 417 q 164 471 119 417 q 201 605 201 514 q 199 665 201 644 q 193 772 193 769 q 241 941 193 887 q 480 1015 308 1015 l 480 915 q 336 866 375 915 q 306 742 306 828 q 310 662 306 717 q 314 577 314 606 q 288 452 314 500 q 176 365 256 391 q 289 275 257 337 q 314 143 314 226 q 313 84 314 107 q 310 -11 310 -5 q 339 -131 310 -94 q 480 -182 377 -182 l 480 -286 "},X:{x_min:-.015625,x_max:854.15625,ha:940,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 428 637 l 675 1013 l 836 1013 l 504 520 l 854 0 "},"#":{x_min:0,x_max:963.890625,ha:1061,o:"m 963 690 l 927 590 l 719 590 l 655 410 l 876 410 l 840 310 l 618 310 l 508 -3 l 393 -2 l 506 309 l 329 310 l 215 -2 l 102 -3 l 212 310 l 0 310 l 36 410 l 248 409 l 312 590 l 86 590 l 120 690 l 347 690 l 459 1006 l 573 1006 l 462 690 l 640 690 l 751 1006 l 865 1006 l 754 690 l 963 690 m 606 590 l 425 590 l 362 410 l 543 410 l 606 590 "},ι:{x_min:42,x_max:284,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 738 l 167 738 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 "},Ά:{x_min:0,x_max:906.953125,ha:982,o:"m 283 1040 l 88 799 l 5 799 l 145 1040 l 283 1040 m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1012 l 529 1012 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},")":{x_min:0,x_max:318,ha:415,o:"m 318 365 q 257 25 318 191 q 87 -290 197 -141 l 0 -290 q 140 21 93 -128 q 193 360 193 189 q 141 704 193 537 q 0 1024 97 850 l 87 1024 q 257 706 197 871 q 318 365 318 542 "},ε:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 314 0 265 q 128 390 67 353 q 56 460 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 "},Δ:{x_min:0,x_max:952.78125,ha:1028,o:"m 952 0 l 0 0 l 400 1013 l 551 1013 l 952 0 m 762 124 l 476 867 l 187 124 l 762 124 "},"}":{x_min:0,x_max:481,ha:578,o:"m 481 314 q 318 262 364 314 q 282 136 282 222 q 284 65 282 97 q 293 -58 293 -48 q 241 -217 293 -166 q 0 -286 174 -286 l 0 -182 q 143 -130 105 -182 q 171 -2 171 -93 q 168 81 171 22 q 165 144 165 140 q 188 275 165 229 q 306 365 220 339 q 191 455 224 391 q 165 588 165 505 q 168 681 165 624 q 171 742 171 737 q 141 865 171 827 q 0 915 102 915 l 0 1015 q 243 942 176 1015 q 293 773 293 888 q 287 675 293 741 q 282 590 282 608 q 318 466 282 505 q 481 417 364 417 l 481 314 "},"‰":{x_min:-3,x_max:1672,ha:1821,o:"m 846 0 q 664 76 732 0 q 603 244 603 145 q 662 412 603 344 q 846 489 729 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 846 0 962 0 m 845 103 q 945 143 910 103 q 981 243 981 184 q 947 340 981 301 q 845 385 910 385 q 745 342 782 385 q 709 243 709 300 q 742 147 709 186 q 845 103 781 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 m 1428 0 q 1246 76 1314 0 q 1185 244 1185 145 q 1244 412 1185 344 q 1428 489 1311 489 q 1610 412 1542 489 q 1672 244 1672 343 q 1612 76 1672 144 q 1428 0 1545 0 m 1427 103 q 1528 143 1492 103 q 1564 243 1564 184 q 1530 340 1564 301 q 1427 385 1492 385 q 1327 342 1364 385 q 1291 243 1291 300 q 1324 147 1291 186 q 1427 103 1363 103 "},a:{x_min:0,x_max:698.609375,ha:794,o:"m 698 0 q 661 -12 679 -7 q 615 -17 643 -17 q 536 12 564 -17 q 500 96 508 41 q 384 6 456 37 q 236 -25 312 -25 q 65 31 130 -25 q 0 194 0 88 q 118 390 0 334 q 328 435 180 420 q 488 483 476 451 q 495 523 495 504 q 442 619 495 584 q 325 654 389 654 q 209 617 257 654 q 152 513 161 580 l 33 513 q 123 705 33 633 q 332 772 207 772 q 528 712 448 772 q 617 531 617 645 l 617 163 q 624 108 617 126 q 664 90 632 90 l 698 94 l 698 0 m 491 262 l 491 372 q 272 329 350 347 q 128 201 128 294 q 166 113 128 144 q 264 83 205 83 q 414 130 346 83 q 491 262 491 183 "},"—":{x_min:0,x_max:941.671875,ha:1039,o:"m 941 334 l 0 334 l 0 410 l 941 410 l 941 334 "},"=":{x_min:8.71875,x_max:780.953125,ha:792,o:"m 780 510 l 8 510 l 8 606 l 780 606 l 780 510 m 780 235 l 8 235 l 8 332 l 780 332 l 780 235 "},N:{x_min:0,x_max:801,ha:914,o:"m 801 0 l 651 0 l 131 823 l 131 0 l 0 0 l 0 1013 l 151 1013 l 670 193 l 670 1013 l 801 1013 l 801 0 "},ρ:{x_min:0,x_max:712,ha:797,o:"m 712 369 q 620 94 712 207 q 362 -26 521 -26 q 230 2 292 -26 q 119 83 167 30 l 119 -278 l 0 -278 l 0 362 q 91 643 0 531 q 355 764 190 764 q 617 647 517 764 q 712 369 712 536 m 583 366 q 530 559 583 480 q 359 651 469 651 q 190 562 252 651 q 135 370 135 483 q 189 176 135 257 q 359 85 250 85 q 528 175 466 85 q 583 366 583 254 "},"¯":{x_min:0,x_max:941.671875,ha:938,o:"m 941 1033 l 0 1033 l 0 1109 l 941 1109 l 941 1033 "},Z:{x_min:0,x_max:779,ha:849,o:"m 779 0 l 0 0 l 0 113 l 621 896 l 40 896 l 40 1013 l 779 1013 l 778 887 l 171 124 l 779 124 l 779 0 "},u:{x_min:0,x_max:617,ha:729,o:"m 617 0 l 499 0 l 499 110 q 391 10 460 45 q 246 -25 322 -25 q 61 58 127 -25 q 0 258 0 136 l 0 738 l 125 738 l 125 284 q 156 148 125 202 q 273 82 197 82 q 433 165 369 82 q 493 340 493 243 l 493 738 l 617 738 l 617 0 "},k:{x_min:0,x_max:612.484375,ha:697,o:"m 612 738 l 338 465 l 608 0 l 469 0 l 251 382 l 121 251 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 402 l 456 738 l 612 738 "},Η:{x_min:0,x_max:803,ha:917,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},Α:{x_min:0,x_max:906.953125,ha:985,o:"m 906 0 l 756 0 l 650 303 l 251 303 l 143 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 609 421 l 452 866 l 293 421 l 609 421 "},s:{x_min:0,x_max:604,ha:697,o:"m 604 217 q 501 36 604 104 q 292 -23 411 -23 q 86 43 166 -23 q 0 238 0 114 l 121 237 q 175 122 121 164 q 300 85 223 85 q 415 112 363 85 q 479 207 479 147 q 361 309 479 276 q 140 372 141 370 q 21 544 21 426 q 111 708 21 647 q 298 761 190 761 q 492 705 413 761 q 583 531 583 643 l 462 531 q 412 625 462 594 q 298 657 363 657 q 199 636 242 657 q 143 558 143 608 q 262 454 143 486 q 484 394 479 397 q 604 217 604 341 "},B:{x_min:0,x_max:778,ha:876,o:"m 580 546 q 724 469 670 535 q 778 311 778 403 q 673 83 778 171 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 892 q 691 633 732 693 q 580 546 650 572 m 393 899 l 139 899 l 139 588 l 379 588 q 521 624 462 588 q 592 744 592 667 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 303 635 219 q 559 436 635 389 q 402 477 494 477 l 139 477 l 139 124 l 419 124 "},"…":{x_min:0,x_max:614,ha:708,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 m 378 0 l 236 0 l 236 151 l 378 151 l 378 0 m 614 0 l 472 0 l 472 151 l 614 151 l 614 0 "},"?":{x_min:0,x_max:607,ha:704,o:"m 607 777 q 543 599 607 674 q 422 474 482 537 q 357 272 357 391 l 236 272 q 297 487 236 395 q 411 619 298 490 q 474 762 474 691 q 422 885 474 838 q 301 933 371 933 q 179 880 228 933 q 124 706 124 819 l 0 706 q 94 963 0 872 q 302 1044 177 1044 q 511 973 423 1044 q 607 777 607 895 m 370 0 l 230 0 l 230 151 l 370 151 l 370 0 "},H:{x_min:0,x_max:803,ha:915,o:"m 803 0 l 667 0 l 667 475 l 140 475 l 140 0 l 0 0 l 0 1013 l 140 1013 l 140 599 l 667 599 l 667 1013 l 803 1013 l 803 0 "},ν:{x_min:0,x_max:675,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 738 l 340 147 l 541 738 l 675 738 "},c:{x_min:1,x_max:701.390625,ha:775,o:"m 701 264 q 584 53 681 133 q 353 -26 487 -26 q 91 91 188 -26 q 1 370 1 201 q 92 645 1 537 q 353 761 190 761 q 572 688 479 761 q 690 493 666 615 l 556 493 q 487 606 545 562 q 356 650 428 650 q 186 563 246 650 q 134 372 134 487 q 188 179 134 258 q 359 88 250 88 q 492 136 437 88 q 566 264 548 185 l 701 264 "},"¶":{x_min:0,x_max:566.671875,ha:678,o:"m 21 892 l 52 892 l 98 761 l 145 892 l 176 892 l 178 741 l 157 741 l 157 867 l 108 741 l 88 741 l 40 871 l 40 741 l 21 741 l 21 892 m 308 854 l 308 731 q 252 691 308 691 q 227 691 240 691 q 207 696 213 695 l 207 712 l 253 706 q 288 733 288 706 l 288 763 q 244 741 279 741 q 193 797 193 741 q 261 860 193 860 q 287 860 273 860 q 308 854 302 855 m 288 842 l 263 843 q 213 796 213 843 q 248 756 213 756 q 288 796 288 756 l 288 842 m 566 988 l 502 988 l 502 -1 l 439 -1 l 439 988 l 317 988 l 317 -1 l 252 -1 l 252 602 q 81 653 155 602 q 0 805 0 711 q 101 989 0 918 q 309 1053 194 1053 l 566 1053 l 566 988 "},β:{x_min:0,x_max:660,ha:745,o:"m 471 550 q 610 450 561 522 q 660 280 660 378 q 578 64 660 151 q 367 -22 497 -22 q 239 5 299 -22 q 126 82 178 32 l 126 -278 l 0 -278 l 0 593 q 54 903 0 801 q 318 1042 127 1042 q 519 964 436 1042 q 603 771 603 887 q 567 644 603 701 q 471 550 532 586 m 337 79 q 476 138 418 79 q 535 279 535 198 q 427 437 535 386 q 226 477 344 477 l 226 583 q 398 620 329 583 q 486 762 486 668 q 435 884 486 833 q 312 935 384 935 q 169 861 219 935 q 126 698 126 797 l 126 362 q 170 169 126 242 q 337 79 224 79 "},Μ:{x_min:0,x_max:954,ha:1068,o:"m 954 0 l 819 0 l 819 868 l 537 0 l 405 0 l 128 865 l 128 0 l 0 0 l 0 1013 l 199 1013 l 472 158 l 758 1013 l 954 1013 l 954 0 "},Ό:{x_min:.109375,x_max:1120,ha:1217,o:"m 1120 505 q 994 132 1120 282 q 642 -29 861 -29 q 290 130 422 -29 q 167 505 167 280 q 294 883 167 730 q 650 1046 430 1046 q 999 882 868 1046 q 1120 505 1120 730 m 977 504 q 896 784 977 669 q 644 915 804 915 q 391 785 484 915 q 307 504 307 669 q 391 224 307 339 q 644 95 486 95 q 894 224 803 95 q 977 504 977 339 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ή:{x_min:0,x_max:1158,ha:1275,o:"m 1158 0 l 1022 0 l 1022 475 l 496 475 l 496 0 l 356 0 l 356 1012 l 496 1012 l 496 599 l 1022 599 l 1022 1012 l 1158 1012 l 1158 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},"•":{x_min:0,x_max:663.890625,ha:775,o:"m 663 529 q 566 293 663 391 q 331 196 469 196 q 97 294 194 196 q 0 529 0 393 q 96 763 0 665 q 331 861 193 861 q 566 763 469 861 q 663 529 663 665 "},"¥":{x_min:.1875,x_max:819.546875,ha:886,o:"m 563 561 l 697 561 l 696 487 l 520 487 l 482 416 l 482 380 l 697 380 l 695 308 l 482 308 l 482 0 l 342 0 l 342 308 l 125 308 l 125 380 l 342 380 l 342 417 l 303 487 l 125 487 l 125 561 l 258 561 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 l 563 561 "},"(":{x_min:0,x_max:318.0625,ha:415,o:"m 318 -290 l 230 -290 q 61 23 122 -142 q 0 365 0 190 q 62 712 0 540 q 230 1024 119 869 l 318 1024 q 175 705 219 853 q 125 360 125 542 q 176 22 125 187 q 318 -290 223 -127 "},U:{x_min:0,x_max:796,ha:904,o:"m 796 393 q 681 93 796 212 q 386 -25 566 -25 q 101 95 208 -25 q 0 393 0 211 l 0 1013 l 138 1013 l 138 391 q 204 191 138 270 q 394 107 276 107 q 586 191 512 107 q 656 391 656 270 l 656 1013 l 796 1013 l 796 393 "},γ:{x_min:.5,x_max:744.953125,ha:822,o:"m 744 737 l 463 54 l 463 -278 l 338 -278 l 338 54 l 154 495 q 104 597 124 569 q 13 651 67 651 l 0 651 l 0 751 l 39 753 q 168 711 121 753 q 242 594 207 676 l 403 208 l 617 737 l 744 737 "},α:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 728 407 760 q 563 637 524 696 l 563 739 l 685 739 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 96 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 "},F:{x_min:0,x_max:683.328125,ha:717,o:"m 683 888 l 140 888 l 140 583 l 613 583 l 613 458 l 140 458 l 140 0 l 0 0 l 0 1013 l 683 1013 l 683 888 "},"­":{x_min:0,x_max:705.5625,ha:803,o:"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},":":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},Χ:{x_min:0,x_max:854.171875,ha:935,o:"m 854 0 l 683 0 l 423 409 l 166 0 l 0 0 l 347 519 l 18 1013 l 186 1013 l 427 637 l 675 1013 l 836 1013 l 504 521 l 854 0 "},"*":{x_min:116,x_max:674,ha:792,o:"m 674 768 l 475 713 l 610 544 l 517 477 l 394 652 l 272 478 l 178 544 l 314 713 l 116 766 l 153 876 l 341 812 l 342 1013 l 446 1013 l 446 811 l 635 874 l 674 768 "},"†":{x_min:0,x_max:777,ha:835,o:"m 458 804 l 777 804 l 777 683 l 458 683 l 458 0 l 319 0 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 "},"°":{x_min:0,x_max:347,ha:444,o:"m 173 802 q 43 856 91 802 q 0 977 0 905 q 45 1101 0 1049 q 173 1153 90 1153 q 303 1098 255 1153 q 347 977 347 1049 q 303 856 347 905 q 173 802 256 802 m 173 884 q 238 910 214 884 q 262 973 262 937 q 239 1038 262 1012 q 173 1064 217 1064 q 108 1037 132 1064 q 85 973 85 1010 q 108 910 85 937 q 173 884 132 884 "},V:{x_min:0,x_max:862.71875,ha:940,o:"m 862 1013 l 505 0 l 361 0 l 0 1013 l 143 1013 l 434 165 l 718 1012 l 862 1013 "},Ξ:{x_min:0,x_max:734.71875,ha:763,o:"m 723 889 l 9 889 l 9 1013 l 723 1013 l 723 889 m 673 463 l 61 463 l 61 589 l 673 589 l 673 463 m 734 0 l 0 0 l 0 124 l 734 124 l 734 0 "}," ":{x_min:0,x_max:0,ha:853},Ϋ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 588 1046 l 460 1046 l 460 1189 l 588 1189 l 588 1046 m 360 1046 l 232 1046 l 232 1189 l 360 1189 l 360 1046 m 819 1012 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1012 l 140 1012 l 411 533 l 679 1012 l 819 1012 "},"”":{x_min:0,x_max:347,ha:454,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 m 347 851 q 310 737 347 784 q 208 669 273 690 l 208 734 q 267 787 250 741 q 280 873 280 821 l 208 873 l 208 1013 l 347 1013 l 347 851 "},"@":{x_min:0,x_max:1260,ha:1357,o:"m 1098 -45 q 877 -160 1001 -117 q 633 -203 752 -203 q 155 -29 327 -203 q 0 360 0 127 q 176 802 0 616 q 687 1008 372 1008 q 1123 854 969 1008 q 1260 517 1260 718 q 1155 216 1260 341 q 868 82 1044 82 q 772 106 801 82 q 737 202 737 135 q 647 113 700 144 q 527 82 594 82 q 367 147 420 82 q 314 312 314 212 q 401 565 314 452 q 639 690 498 690 q 810 588 760 690 l 849 668 l 938 668 q 877 441 900 532 q 833 226 833 268 q 853 182 833 198 q 902 167 873 167 q 1088 272 1012 167 q 1159 512 1159 372 q 1051 793 1159 681 q 687 925 925 925 q 248 747 415 925 q 97 361 97 586 q 226 26 97 159 q 627 -122 370 -122 q 856 -87 737 -122 q 1061 8 976 -53 l 1098 -45 m 786 488 q 738 580 777 545 q 643 615 700 615 q 483 517 548 615 q 425 322 425 430 q 457 203 425 250 q 552 156 490 156 q 722 273 665 156 q 786 488 738 309 "},Ί:{x_min:0,x_max:499,ha:613,o:"m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 m 499 0 l 360 0 l 360 1012 l 499 1012 l 499 0 "},i:{x_min:14,x_max:136,ha:275,o:"m 136 873 l 14 873 l 14 1013 l 136 1013 l 136 873 m 136 0 l 14 0 l 14 737 l 136 737 l 136 0 "},Β:{x_min:0,x_max:778,ha:877,o:"m 580 545 q 724 468 671 534 q 778 310 778 402 q 673 83 778 170 q 432 0 575 0 l 0 0 l 0 1013 l 411 1013 q 629 957 541 1013 q 732 768 732 891 q 691 632 732 692 q 580 545 650 571 m 393 899 l 139 899 l 139 587 l 379 587 q 521 623 462 587 q 592 744 592 666 q 531 859 592 819 q 393 899 471 899 m 419 124 q 566 169 504 124 q 635 302 635 219 q 559 435 635 388 q 402 476 494 476 l 139 476 l 139 124 l 419 124 "},υ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 94 617 199 q 308 -24 455 -24 q 76 94 161 -24 q 0 352 0 199 l 0 739 l 126 739 l 126 355 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 355 492 257 l 492 739 l 617 739 l 617 352 "},"]":{x_min:0,x_max:275,ha:372,o:"m 275 -281 l 0 -281 l 0 -187 l 151 -187 l 151 920 l 0 920 l 0 1013 l 275 1013 l 275 -281 "},m:{x_min:0,x_max:1019,ha:1128,o:"m 1019 0 l 897 0 l 897 454 q 860 591 897 536 q 739 660 816 660 q 613 586 659 660 q 573 436 573 522 l 573 0 l 447 0 l 447 455 q 412 591 447 535 q 294 657 372 657 q 165 586 213 657 q 122 437 122 521 l 122 0 l 0 0 l 0 738 l 117 738 l 117 640 q 202 730 150 697 q 316 763 254 763 q 437 730 381 763 q 525 642 494 697 q 621 731 559 700 q 753 763 682 763 q 943 694 867 763 q 1019 512 1019 625 l 1019 0 "},χ:{x_min:8.328125,x_max:780.5625,ha:815,o:"m 780 -278 q 715 -294 747 -294 q 616 -257 663 -294 q 548 -175 576 -227 l 379 133 l 143 -277 l 9 -277 l 313 254 l 163 522 q 127 586 131 580 q 36 640 91 640 q 8 637 27 640 l 8 752 l 52 757 q 162 719 113 757 q 236 627 200 690 l 383 372 l 594 737 l 726 737 l 448 250 l 625 -69 q 670 -153 647 -110 q 743 -188 695 -188 q 780 -184 759 -188 l 780 -278 "},ί:{x_min:42,x_max:326.71875,ha:361,o:"m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 102 239 101 q 284 112 257 104 l 284 3 m 326 1040 l 137 819 l 54 819 l 189 1040 l 326 1040 "},Ζ:{x_min:0,x_max:779.171875,ha:850,o:"m 779 0 l 0 0 l 0 113 l 620 896 l 40 896 l 40 1013 l 779 1013 l 779 887 l 170 124 l 779 124 l 779 0 "},R:{x_min:0,x_max:781.953125,ha:907,o:"m 781 0 l 623 0 q 587 242 590 52 q 407 433 585 433 l 138 433 l 138 0 l 0 0 l 0 1013 l 396 1013 q 636 946 539 1013 q 749 731 749 868 q 711 597 749 659 q 608 502 674 534 q 718 370 696 474 q 729 207 722 352 q 781 26 736 62 l 781 0 m 373 551 q 533 594 465 551 q 614 731 614 645 q 532 859 614 815 q 373 896 465 896 l 138 896 l 138 551 l 373 551 "},o:{x_min:0,x_max:713,ha:821,o:"m 357 -25 q 94 91 194 -25 q 0 368 0 202 q 93 642 0 533 q 357 761 193 761 q 618 644 518 761 q 713 368 713 533 q 619 91 713 201 q 357 -25 521 -25 m 357 85 q 528 175 465 85 q 584 369 584 255 q 529 562 584 484 q 357 651 467 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 357 85 250 85 "},K:{x_min:0,x_max:819.46875,ha:906,o:"m 819 0 l 649 0 l 294 509 l 139 355 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},",":{x_min:0,x_max:142,ha:239,o:"m 142 -12 q 105 -132 142 -82 q 0 -205 68 -182 l 0 -138 q 57 -82 40 -124 q 70 0 70 -51 l 0 0 l 0 151 l 142 151 l 142 -12 "},d:{x_min:0,x_max:683,ha:796,o:"m 683 0 l 564 0 l 564 93 q 456 6 516 38 q 327 -25 395 -25 q 87 100 181 -25 q 0 365 0 215 q 90 639 0 525 q 343 763 187 763 q 564 647 486 763 l 564 1013 l 683 1013 l 683 0 m 582 373 q 529 562 582 484 q 361 653 468 653 q 190 561 253 653 q 135 365 135 479 q 189 175 135 254 q 358 85 251 85 q 529 178 468 85 q 582 373 582 258 "},"¨":{x_min:-109,x_max:247,ha:232,o:"m 247 1046 l 119 1046 l 119 1189 l 247 1189 l 247 1046 m 19 1046 l -109 1046 l -109 1189 l 19 1189 l 19 1046 "},E:{x_min:0,x_max:736.109375,ha:789,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},Y:{x_min:0,x_max:820,ha:886,o:"m 820 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 534 l 679 1012 l 820 1013 "},'"':{x_min:0,x_max:299,ha:396,o:"m 299 606 l 203 606 l 203 988 l 299 988 l 299 606 m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"‹":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"„":{x_min:0,x_max:364,ha:467,o:"m 141 -12 q 104 -132 141 -82 q 0 -205 67 -182 l 0 -138 q 56 -82 40 -124 q 69 0 69 -51 l 0 0 l 0 151 l 141 151 l 141 -12 m 364 -12 q 327 -132 364 -82 q 222 -205 290 -182 l 222 -138 q 279 -82 262 -124 q 292 0 292 -51 l 222 0 l 222 151 l 364 151 l 364 -12 "},δ:{x_min:1,x_max:710,ha:810,o:"m 710 360 q 616 87 710 196 q 356 -28 518 -28 q 99 82 197 -28 q 1 356 1 192 q 100 606 1 509 q 355 703 199 703 q 180 829 288 754 q 70 903 124 866 l 70 1012 l 643 1012 l 643 901 l 258 901 q 462 763 422 794 q 636 592 577 677 q 710 360 710 485 m 584 365 q 552 501 584 447 q 451 602 521 555 q 372 611 411 611 q 197 541 258 611 q 136 355 136 472 q 190 171 136 245 q 358 85 252 85 q 528 173 465 85 q 584 365 584 252 "},έ:{x_min:0,x_max:634.71875,ha:714,o:"m 634 234 q 527 38 634 110 q 300 -25 433 -25 q 98 29 183 -25 q 0 204 0 93 q 37 313 0 265 q 128 390 67 352 q 56 459 82 419 q 26 555 26 505 q 114 712 26 654 q 295 763 191 763 q 499 700 416 763 q 589 515 589 631 l 478 515 q 419 618 464 580 q 307 657 374 657 q 207 630 253 657 q 151 547 151 598 q 238 445 151 469 q 389 434 280 434 l 389 331 l 349 331 q 206 315 255 331 q 125 210 125 287 q 183 107 125 145 q 302 76 233 76 q 436 117 379 76 q 509 234 493 159 l 634 234 m 520 1040 l 331 819 l 248 819 l 383 1040 l 520 1040 "},ω:{x_min:0,x_max:922,ha:1031,o:"m 922 339 q 856 97 922 203 q 650 -26 780 -26 q 538 9 587 -26 q 461 103 489 44 q 387 12 436 46 q 277 -22 339 -22 q 69 97 147 -22 q 0 339 0 203 q 45 551 0 444 q 161 738 84 643 l 302 738 q 175 553 219 647 q 124 336 124 446 q 155 179 124 249 q 275 88 197 88 q 375 163 341 88 q 400 294 400 219 l 400 572 l 524 572 l 524 294 q 561 135 524 192 q 643 88 591 88 q 762 182 719 88 q 797 342 797 257 q 745 556 797 450 q 619 738 705 638 l 760 738 q 874 551 835 640 q 922 339 922 444 "},"´":{x_min:0,x_max:96,ha:251,o:"m 96 606 l 0 606 l 0 988 l 96 988 l 96 606 "},"±":{x_min:11,x_max:781,ha:792,o:"m 781 490 l 446 490 l 446 255 l 349 255 l 349 490 l 11 490 l 11 586 l 349 586 l 349 819 l 446 819 l 446 586 l 781 586 l 781 490 m 781 21 l 11 21 l 11 115 l 781 115 l 781 21 "},"|":{x_min:343,x_max:449,ha:792,o:"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},ϋ:{x_min:0,x_max:617,ha:725,o:"m 482 800 l 372 800 l 372 925 l 482 925 l 482 800 m 239 800 l 129 800 l 129 925 l 239 925 l 239 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 "},"§":{x_min:0,x_max:593,ha:690,o:"m 593 425 q 554 312 593 369 q 467 233 516 254 q 537 83 537 172 q 459 -74 537 -12 q 288 -133 387 -133 q 115 -69 184 -133 q 47 96 47 -6 l 166 96 q 199 7 166 40 q 288 -26 232 -26 q 371 -5 332 -26 q 420 60 420 21 q 311 201 420 139 q 108 309 210 255 q 0 490 0 383 q 33 602 0 551 q 124 687 66 654 q 75 743 93 712 q 58 812 58 773 q 133 984 58 920 q 300 1043 201 1043 q 458 987 394 1043 q 529 814 529 925 l 411 814 q 370 908 404 877 q 289 939 336 939 q 213 911 246 939 q 180 841 180 883 q 286 720 180 779 q 484 612 480 615 q 593 425 593 534 m 467 409 q 355 544 467 473 q 196 630 228 612 q 146 587 162 609 q 124 525 124 558 q 239 387 124 462 q 398 298 369 315 q 448 345 429 316 q 467 409 467 375 "},b:{x_min:0,x_max:685,ha:783,o:"m 685 372 q 597 99 685 213 q 347 -25 501 -25 q 219 5 277 -25 q 121 93 161 36 l 121 0 l 0 0 l 0 1013 l 121 1013 l 121 634 q 214 723 157 692 q 341 754 272 754 q 591 637 493 754 q 685 372 685 526 m 554 356 q 499 550 554 470 q 328 644 437 644 q 162 556 223 644 q 108 369 108 478 q 160 176 108 256 q 330 83 221 83 q 498 169 435 83 q 554 356 554 245 "},q:{x_min:0,x_max:683,ha:876,o:"m 683 -278 l 564 -278 l 564 97 q 474 8 533 39 q 345 -23 415 -23 q 91 93 188 -23 q 0 364 0 203 q 87 635 0 522 q 337 760 184 760 q 466 727 408 760 q 564 637 523 695 l 564 737 l 683 737 l 683 -278 m 582 375 q 527 564 582 488 q 358 652 466 652 q 190 565 253 652 q 135 377 135 488 q 189 179 135 261 q 361 84 251 84 q 530 179 469 84 q 582 375 582 260 "},Ω:{x_min:-.171875,x_max:969.5625,ha:1068,o:"m 969 0 l 555 0 l 555 123 q 744 308 675 194 q 814 558 814 423 q 726 812 814 709 q 484 922 633 922 q 244 820 334 922 q 154 567 154 719 q 223 316 154 433 q 412 123 292 199 l 412 0 l 0 0 l 0 124 l 217 124 q 68 327 122 210 q 15 572 15 444 q 144 911 15 781 q 484 1041 274 1041 q 822 909 691 1041 q 953 569 953 777 q 899 326 953 443 q 750 124 846 210 l 969 124 l 969 0 "},ύ:{x_min:0,x_max:617,ha:725,o:"m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 535 1040 l 346 819 l 262 819 l 397 1040 l 535 1040 "},z:{x_min:-.015625,x_max:613.890625,ha:697,o:"m 613 0 l 0 0 l 0 100 l 433 630 l 20 630 l 20 738 l 594 738 l 593 636 l 163 110 l 613 110 l 613 0 "},"™":{x_min:0,x_max:894,ha:1e3,o:"m 389 951 l 229 951 l 229 503 l 160 503 l 160 951 l 0 951 l 0 1011 l 389 1011 l 389 951 m 894 503 l 827 503 l 827 939 l 685 503 l 620 503 l 481 937 l 481 503 l 417 503 l 417 1011 l 517 1011 l 653 580 l 796 1010 l 894 1011 l 894 503 "},ή:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 721 124 755 q 200 630 193 687 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 m 479 1040 l 290 819 l 207 819 l 341 1040 l 479 1040 "},Θ:{x_min:0,x_max:960,ha:1056,o:"m 960 507 q 833 129 960 280 q 476 -32 698 -32 q 123 129 255 -32 q 0 507 0 280 q 123 883 0 732 q 476 1045 255 1045 q 832 883 696 1045 q 960 507 960 732 m 817 500 q 733 789 817 669 q 476 924 639 924 q 223 792 317 924 q 142 507 142 675 q 222 222 142 339 q 476 89 315 89 q 730 218 636 89 q 817 500 817 334 m 716 449 l 243 449 l 243 571 l 716 571 l 716 449 "},"®":{x_min:-3,x_max:1008,ha:1106,o:"m 503 532 q 614 562 566 532 q 672 658 672 598 q 614 747 672 716 q 503 772 569 772 l 338 772 l 338 532 l 503 532 m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 788 146 l 678 146 q 653 316 655 183 q 527 449 652 449 l 338 449 l 338 146 l 241 146 l 241 854 l 518 854 q 688 808 621 854 q 766 658 766 755 q 739 563 766 607 q 668 497 713 519 q 751 331 747 472 q 788 164 756 190 l 788 146 "},"~":{x_min:0,x_max:833,ha:931,o:"m 833 958 q 778 753 833 831 q 594 665 716 665 q 402 761 502 665 q 240 857 302 857 q 131 795 166 857 q 104 665 104 745 l 0 665 q 54 867 0 789 q 237 958 116 958 q 429 861 331 958 q 594 765 527 765 q 704 827 670 765 q 729 958 729 874 l 833 958 "},Ε:{x_min:0,x_max:736.21875,ha:778,o:"m 736 0 l 0 0 l 0 1013 l 725 1013 l 725 889 l 139 889 l 139 585 l 677 585 l 677 467 l 139 467 l 139 125 l 736 125 l 736 0 "},"³":{x_min:0,x_max:450,ha:547,o:"m 450 552 q 379 413 450 464 q 220 366 313 366 q 69 414 130 366 q 0 567 0 470 l 85 567 q 126 470 85 504 q 225 437 168 437 q 320 467 280 437 q 360 552 360 498 q 318 632 360 608 q 213 657 276 657 q 195 657 203 657 q 176 657 181 657 l 176 722 q 279 733 249 722 q 334 815 334 752 q 300 881 334 856 q 220 907 267 907 q 133 875 169 907 q 97 781 97 844 l 15 781 q 78 926 15 875 q 220 972 135 972 q 364 930 303 972 q 426 817 426 888 q 344 697 426 733 q 421 642 392 681 q 450 552 450 603 "},"[":{x_min:0,x_max:273.609375,ha:371,o:"m 273 -281 l 0 -281 l 0 1013 l 273 1013 l 273 920 l 124 920 l 124 -187 l 273 -187 l 273 -281 "},L:{x_min:0,x_max:645.828125,ha:696,o:"m 645 0 l 0 0 l 0 1013 l 140 1013 l 140 126 l 645 126 l 645 0 "},σ:{x_min:0,x_max:803.390625,ha:894,o:"m 803 628 l 633 628 q 713 368 713 512 q 618 93 713 204 q 357 -25 518 -25 q 94 91 194 -25 q 0 368 0 201 q 94 644 0 533 q 356 761 194 761 q 481 750 398 761 q 608 739 564 739 l 803 739 l 803 628 m 360 85 q 529 180 467 85 q 584 374 584 262 q 527 566 584 490 q 352 651 463 651 q 187 559 247 651 q 135 368 135 478 q 189 175 135 254 q 360 85 251 85 "},ζ:{x_min:0,x_max:573,ha:642,o:"m 573 -40 q 553 -162 573 -97 q 510 -278 543 -193 l 400 -278 q 441 -187 428 -219 q 462 -90 462 -132 q 378 -14 462 -14 q 108 45 197 -14 q 0 290 0 117 q 108 631 0 462 q 353 901 194 767 l 55 901 l 55 1012 l 561 1012 l 561 924 q 261 669 382 831 q 128 301 128 489 q 243 117 128 149 q 458 98 350 108 q 573 -40 573 80 "},θ:{x_min:0,x_max:674,ha:778,o:"m 674 496 q 601 160 674 304 q 336 -26 508 -26 q 73 153 165 -26 q 0 485 0 296 q 72 840 0 683 q 343 1045 166 1045 q 605 844 516 1045 q 674 496 674 692 m 546 579 q 498 798 546 691 q 336 935 437 935 q 178 798 237 935 q 126 579 137 701 l 546 579 m 546 475 l 126 475 q 170 233 126 348 q 338 80 230 80 q 504 233 447 80 q 546 475 546 346 "},Ο:{x_min:0,x_max:958,ha:1054,o:"m 485 1042 q 834 883 703 1042 q 958 511 958 735 q 834 136 958 287 q 481 -26 701 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 729 q 485 1042 263 1042 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 670 q 480 913 640 913 q 226 785 321 913 q 142 504 142 671 q 226 224 142 339 q 480 98 319 98 "},Γ:{x_min:0,x_max:705.28125,ha:749,o:"m 705 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 705 1012 l 705 886 "}," ":{x_min:0,x_max:0,ha:375},"%":{x_min:-3,x_max:1089,ha:1186,o:"m 845 0 q 663 76 731 0 q 602 244 602 145 q 661 412 602 344 q 845 489 728 489 q 1027 412 959 489 q 1089 244 1089 343 q 1029 76 1089 144 q 845 0 962 0 m 844 103 q 945 143 909 103 q 981 243 981 184 q 947 340 981 301 q 844 385 909 385 q 744 342 781 385 q 708 243 708 300 q 741 147 708 186 q 844 103 780 103 m 888 986 l 284 -25 l 199 -25 l 803 986 l 888 986 m 241 468 q 58 545 126 468 q -3 715 -3 615 q 56 881 -3 813 q 238 958 124 958 q 421 881 353 958 q 483 712 483 813 q 423 544 483 612 q 241 468 356 468 m 241 855 q 137 811 175 855 q 100 710 100 768 q 136 612 100 653 q 240 572 172 572 q 344 614 306 572 q 382 713 382 656 q 347 810 382 771 q 241 855 308 855 "},P:{x_min:0,x_max:726,ha:806,o:"m 424 1013 q 640 931 555 1013 q 726 719 726 850 q 637 506 726 587 q 413 426 548 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 379 889 l 140 889 l 140 548 l 372 548 q 522 589 459 548 q 593 720 593 637 q 528 845 593 801 q 379 889 463 889 "},Έ:{x_min:0,x_max:1078.21875,ha:1118,o:"m 1078 0 l 342 0 l 342 1013 l 1067 1013 l 1067 889 l 481 889 l 481 585 l 1019 585 l 1019 467 l 481 467 l 481 125 l 1078 125 l 1078 0 m 277 1040 l 83 799 l 0 799 l 140 1040 l 277 1040 "},Ώ:{x_min:.125,x_max:1136.546875,ha:1235,o:"m 1136 0 l 722 0 l 722 123 q 911 309 842 194 q 981 558 981 423 q 893 813 981 710 q 651 923 800 923 q 411 821 501 923 q 321 568 321 720 q 390 316 321 433 q 579 123 459 200 l 579 0 l 166 0 l 166 124 l 384 124 q 235 327 289 210 q 182 572 182 444 q 311 912 182 782 q 651 1042 441 1042 q 989 910 858 1042 q 1120 569 1120 778 q 1066 326 1120 443 q 917 124 1013 210 l 1136 124 l 1136 0 m 277 1040 l 83 800 l 0 800 l 140 1041 l 277 1040 "},_:{x_min:0,x_max:705.5625,ha:803,o:"m 705 -334 l 0 -334 l 0 -234 l 705 -234 l 705 -334 "},Ϊ:{x_min:-110,x_max:246,ha:275,o:"m 246 1046 l 118 1046 l 118 1189 l 246 1189 l 246 1046 m 18 1046 l -110 1046 l -110 1189 l 18 1189 l 18 1046 m 136 0 l 0 0 l 0 1012 l 136 1012 l 136 0 "},"+":{x_min:23,x_max:768,ha:792,o:"m 768 372 l 444 372 l 444 0 l 347 0 l 347 372 l 23 372 l 23 468 l 347 468 l 347 840 l 444 840 l 444 468 l 768 468 l 768 372 "},"½":{x_min:0,x_max:1050,ha:1149,o:"m 1050 0 l 625 0 q 712 178 625 108 q 878 277 722 187 q 967 385 967 328 q 932 456 967 429 q 850 484 897 484 q 759 450 798 484 q 721 352 721 416 l 640 352 q 706 502 640 448 q 851 551 766 551 q 987 509 931 551 q 1050 385 1050 462 q 976 251 1050 301 q 829 179 902 215 q 717 68 740 133 l 1050 68 l 1050 0 m 834 985 l 215 -28 l 130 -28 l 750 984 l 834 985 m 224 422 l 142 422 l 142 811 l 0 811 l 0 867 q 104 889 62 867 q 164 973 157 916 l 224 973 l 224 422 "},Ρ:{x_min:0,x_max:720,ha:783,o:"m 424 1013 q 637 933 554 1013 q 720 723 720 853 q 633 508 720 591 q 413 426 546 426 l 140 426 l 140 0 l 0 0 l 0 1013 l 424 1013 m 378 889 l 140 889 l 140 548 l 371 548 q 521 589 458 548 q 592 720 592 637 q 527 845 592 801 q 378 889 463 889 "},"'":{x_min:0,x_max:139,ha:236,o:"m 139 851 q 102 737 139 784 q 0 669 65 690 l 0 734 q 59 787 42 741 q 72 873 72 821 l 0 873 l 0 1013 l 139 1013 l 139 851 "},ª:{x_min:0,x_max:350,ha:397,o:"m 350 625 q 307 616 328 616 q 266 631 281 616 q 247 673 251 645 q 190 628 225 644 q 116 613 156 613 q 32 641 64 613 q 0 722 0 669 q 72 826 0 800 q 247 866 159 846 l 247 887 q 220 934 247 916 q 162 953 194 953 q 104 934 129 953 q 76 882 80 915 l 16 882 q 60 976 16 941 q 166 1011 104 1011 q 266 979 224 1011 q 308 891 308 948 l 308 706 q 311 679 308 688 q 331 670 315 670 l 350 672 l 350 625 m 247 757 l 247 811 q 136 790 175 798 q 64 726 64 773 q 83 682 64 697 q 132 667 103 667 q 207 690 174 667 q 247 757 247 718 "},"΅":{x_min:0,x_max:450,ha:553,o:"m 450 800 l 340 800 l 340 925 l 450 925 l 450 800 m 406 1040 l 212 800 l 129 800 l 269 1040 l 406 1040 m 110 800 l 0 800 l 0 925 l 110 925 l 110 800 "},T:{x_min:0,x_max:777,ha:835,o:"m 777 894 l 458 894 l 458 0 l 319 0 l 319 894 l 0 894 l 0 1013 l 777 1013 l 777 894 "},Φ:{x_min:0,x_max:915,ha:997,o:"m 527 0 l 389 0 l 389 122 q 110 231 220 122 q 0 509 0 340 q 110 785 0 677 q 389 893 220 893 l 389 1013 l 527 1013 l 527 893 q 804 786 693 893 q 915 509 915 679 q 805 231 915 341 q 527 122 696 122 l 527 0 m 527 226 q 712 310 641 226 q 779 507 779 389 q 712 705 779 627 q 527 787 641 787 l 527 226 m 389 226 l 389 787 q 205 698 275 775 q 136 505 136 620 q 206 308 136 391 q 389 226 276 226 "},"⁋":{x_min:0,x_max:0,ha:694},j:{x_min:-77.78125,x_max:167,ha:349,o:"m 167 871 l 42 871 l 42 1013 l 167 1013 l 167 871 m 167 -80 q 121 -231 167 -184 q -26 -278 76 -278 l -77 -278 l -77 -164 l -41 -164 q 26 -143 11 -164 q 42 -65 42 -122 l 42 737 l 167 737 l 167 -80 "},Σ:{x_min:0,x_max:756.953125,ha:819,o:"m 756 0 l 0 0 l 0 107 l 395 523 l 22 904 l 22 1013 l 745 1013 l 745 889 l 209 889 l 566 523 l 187 125 l 756 125 l 756 0 "},"›":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},"<":{x_min:17.984375,x_max:773.609375,ha:792,o:"m 773 40 l 18 376 l 17 465 l 773 799 l 773 692 l 159 420 l 773 149 l 773 40 "},"£":{x_min:0,x_max:704.484375,ha:801,o:"m 704 41 q 623 -10 664 5 q 543 -26 583 -26 q 359 15 501 -26 q 243 36 288 36 q 158 23 197 36 q 73 -21 119 10 l 6 76 q 125 195 90 150 q 175 331 175 262 q 147 443 175 383 l 0 443 l 0 512 l 108 512 q 43 734 43 623 q 120 929 43 854 q 358 1010 204 1010 q 579 936 487 1010 q 678 729 678 857 l 678 684 l 552 684 q 504 838 552 780 q 362 896 457 896 q 216 852 263 896 q 176 747 176 815 q 199 627 176 697 q 248 512 217 574 l 468 512 l 468 443 l 279 443 q 297 356 297 398 q 230 194 297 279 q 153 107 211 170 q 227 133 190 125 q 293 142 264 142 q 410 119 339 142 q 516 96 482 96 q 579 105 550 96 q 648 142 608 115 l 704 41 "},t:{x_min:0,x_max:367,ha:458,o:"m 367 0 q 312 -5 339 -2 q 262 -8 284 -8 q 145 28 183 -8 q 108 143 108 64 l 108 638 l 0 638 l 0 738 l 108 738 l 108 944 l 232 944 l 232 738 l 367 738 l 367 638 l 232 638 l 232 185 q 248 121 232 140 q 307 102 264 102 q 345 104 330 102 q 367 107 360 107 l 367 0 "},"¬":{x_min:0,x_max:706,ha:803,o:"m 706 411 l 706 158 l 630 158 l 630 335 l 0 335 l 0 411 l 706 411 "},λ:{x_min:0,x_max:750,ha:803,o:"m 750 -7 q 679 -15 716 -15 q 538 59 591 -15 q 466 214 512 97 l 336 551 l 126 0 l 0 0 l 270 705 q 223 837 247 770 q 116 899 190 899 q 90 898 100 899 l 90 1004 q 152 1011 125 1011 q 298 938 244 1011 q 373 783 326 901 l 605 192 q 649 115 629 136 q 716 95 669 95 l 736 95 q 750 97 745 97 l 750 -7 "},W:{x_min:0,x_max:1263.890625,ha:1351,o:"m 1263 1013 l 995 0 l 859 0 l 627 837 l 405 0 l 265 0 l 0 1013 l 136 1013 l 342 202 l 556 1013 l 701 1013 l 921 207 l 1133 1012 l 1263 1013 "},">":{x_min:18.0625,x_max:774,ha:792,o:"m 774 376 l 18 40 l 18 149 l 631 421 l 18 692 l 18 799 l 774 465 l 774 376 "},v:{x_min:0,x_max:675.15625,ha:761,o:"m 675 738 l 404 0 l 272 0 l 0 738 l 133 737 l 340 147 l 541 737 l 675 738 "},τ:{x_min:.28125,x_max:644.5,ha:703,o:"m 644 628 l 382 628 l 382 179 q 388 120 382 137 q 436 91 401 91 q 474 94 447 91 q 504 97 501 97 l 504 0 q 454 -9 482 -5 q 401 -14 426 -14 q 278 67 308 -14 q 260 233 260 118 l 260 628 l 0 628 l 0 739 l 644 739 l 644 628 "},ξ:{x_min:0,x_max:624.9375,ha:699,o:"m 624 -37 q 608 -153 624 -96 q 563 -278 593 -211 l 454 -278 q 491 -183 486 -200 q 511 -83 511 -126 q 484 -23 511 -44 q 370 1 452 1 q 323 0 354 1 q 283 -1 293 -1 q 84 76 169 -1 q 0 266 0 154 q 56 431 0 358 q 197 538 108 498 q 94 613 134 562 q 54 730 54 665 q 77 823 54 780 q 143 901 101 867 l 27 901 l 27 1012 l 576 1012 l 576 901 l 380 901 q 244 863 303 901 q 178 745 178 820 q 312 600 178 636 q 532 582 380 582 l 532 479 q 276 455 361 479 q 118 281 118 410 q 165 173 118 217 q 274 120 208 133 q 494 101 384 110 q 624 -37 624 76 "},"&":{x_min:-3,x_max:894.25,ha:992,o:"m 894 0 l 725 0 l 624 123 q 471 0 553 40 q 306 -41 390 -41 q 168 -7 231 -41 q 62 92 105 26 q 14 187 31 139 q -3 276 -3 235 q 55 433 -3 358 q 248 581 114 508 q 170 689 196 640 q 137 817 137 751 q 214 985 137 922 q 384 1041 284 1041 q 548 988 483 1041 q 622 824 622 928 q 563 666 622 739 q 431 556 516 608 l 621 326 q 649 407 639 361 q 663 493 653 426 l 781 493 q 703 229 781 352 l 894 0 m 504 818 q 468 908 504 877 q 384 940 433 940 q 293 907 331 940 q 255 818 255 875 q 289 714 255 767 q 363 628 313 678 q 477 729 446 682 q 504 818 504 771 m 556 209 l 314 499 q 179 395 223 449 q 135 283 135 341 q 146 222 135 253 q 183 158 158 192 q 333 80 241 80 q 556 209 448 80 "},Λ:{x_min:0,x_max:862.5,ha:942,o:"m 862 0 l 719 0 l 426 847 l 143 0 l 0 0 l 356 1013 l 501 1013 l 862 0 "},I:{x_min:41,x_max:180,ha:293,o:"m 180 0 l 41 0 l 41 1013 l 180 1013 l 180 0 "},G:{x_min:0,x_max:921,ha:1011,o:"m 921 0 l 832 0 l 801 136 q 655 15 741 58 q 470 -28 568 -28 q 126 133 259 -28 q 0 499 0 284 q 125 881 0 731 q 486 1043 259 1043 q 763 957 647 1043 q 905 709 890 864 l 772 709 q 668 866 747 807 q 486 926 589 926 q 228 795 322 926 q 142 507 142 677 q 228 224 142 342 q 483 94 323 94 q 712 195 625 94 q 796 435 796 291 l 477 435 l 477 549 l 921 549 l 921 0 "},ΰ:{x_min:0,x_max:617,ha:725,o:"m 524 800 l 414 800 l 414 925 l 524 925 l 524 800 m 183 800 l 73 800 l 73 925 l 183 925 l 183 800 m 617 352 q 540 93 617 199 q 308 -24 455 -24 q 76 93 161 -24 q 0 352 0 199 l 0 738 l 126 738 l 126 354 q 169 185 126 257 q 312 98 220 98 q 451 185 402 98 q 492 354 492 257 l 492 738 l 617 738 l 617 352 m 489 1040 l 300 819 l 216 819 l 351 1040 l 489 1040 "},"`":{x_min:0,x_max:138.890625,ha:236,o:"m 138 699 l 0 699 l 0 861 q 36 974 0 929 q 138 1041 72 1020 l 138 977 q 82 931 95 969 q 69 839 69 893 l 138 839 l 138 699 "},"·":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 "},Υ:{x_min:.328125,x_max:819.515625,ha:889,o:"m 819 1013 l 482 416 l 482 0 l 342 0 l 342 416 l 0 1013 l 140 1013 l 411 533 l 679 1013 l 819 1013 "},r:{x_min:0,x_max:355.5625,ha:432,o:"m 355 621 l 343 621 q 179 569 236 621 q 122 411 122 518 l 122 0 l 0 0 l 0 737 l 117 737 l 117 604 q 204 719 146 686 q 355 753 262 753 l 355 621 "},x:{x_min:0,x_max:675,ha:764,o:"m 675 0 l 525 0 l 331 286 l 144 0 l 0 0 l 256 379 l 12 738 l 157 737 l 336 473 l 516 738 l 661 738 l 412 380 l 675 0 "},μ:{x_min:0,x_max:696.609375,ha:747,o:"m 696 -4 q 628 -14 657 -14 q 498 97 513 -14 q 422 8 470 41 q 313 -24 374 -24 q 207 3 258 -24 q 120 80 157 31 l 120 -278 l 0 -278 l 0 738 l 124 738 l 124 343 q 165 172 124 246 q 308 82 216 82 q 451 177 402 82 q 492 358 492 254 l 492 738 l 616 738 l 616 214 q 623 136 616 160 q 673 92 636 92 q 696 95 684 92 l 696 -4 "},h:{x_min:0,x_max:615,ha:724,o:"m 615 472 l 615 0 l 490 0 l 490 454 q 456 590 490 535 q 338 654 416 654 q 186 588 251 654 q 122 436 122 522 l 122 0 l 0 0 l 0 1013 l 122 1013 l 122 633 q 218 727 149 694 q 362 760 287 760 q 552 676 484 760 q 615 472 615 600 "},".":{x_min:0,x_max:142,ha:239,o:"m 142 0 l 0 0 l 0 151 l 142 151 l 142 0 "},φ:{x_min:-2,x_max:878,ha:974,o:"m 496 -279 l 378 -279 l 378 -17 q 101 88 204 -17 q -2 367 -2 194 q 68 626 -2 510 q 283 758 151 758 l 283 646 q 167 537 209 626 q 133 373 133 462 q 192 177 133 254 q 378 93 259 93 l 378 758 q 445 764 426 763 q 476 765 464 765 q 765 659 653 765 q 878 377 878 553 q 771 96 878 209 q 496 -17 665 -17 l 496 -279 m 496 93 l 514 93 q 687 183 623 93 q 746 380 746 265 q 691 569 746 491 q 522 658 629 658 l 496 656 l 496 93 "},";":{x_min:0,x_max:142,ha:239,o:"m 142 585 l 0 585 l 0 738 l 142 738 l 142 585 m 142 -12 q 105 -132 142 -82 q 0 -206 68 -182 l 0 -138 q 58 -82 43 -123 q 68 0 68 -56 l 0 0 l 0 151 l 142 151 l 142 -12 "},f:{x_min:0,x_max:378,ha:472,o:"m 378 638 l 246 638 l 246 0 l 121 0 l 121 638 l 0 638 l 0 738 l 121 738 q 137 935 121 887 q 290 1028 171 1028 q 320 1027 305 1028 q 378 1021 334 1026 l 378 908 q 323 918 346 918 q 257 870 273 918 q 246 780 246 840 l 246 738 l 378 738 l 378 638 "},"“":{x_min:1,x_max:348.21875,ha:454,o:"m 140 670 l 1 670 l 1 830 q 37 943 1 897 q 140 1011 74 990 l 140 947 q 82 900 97 940 q 68 810 68 861 l 140 810 l 140 670 m 348 670 l 209 670 l 209 830 q 245 943 209 897 q 348 1011 282 990 l 348 947 q 290 900 305 940 q 276 810 276 861 l 348 810 l 348 670 "},A:{x_min:.03125,x_max:906.953125,ha:1008,o:"m 906 0 l 756 0 l 648 303 l 251 303 l 142 0 l 0 0 l 376 1013 l 529 1013 l 906 0 m 610 421 l 452 867 l 293 421 l 610 421 "},"‘":{x_min:1,x_max:139.890625,ha:236,o:"m 139 670 l 1 670 l 1 830 q 37 943 1 897 q 139 1011 74 990 l 139 947 q 82 900 97 940 q 68 810 68 861 l 139 810 l 139 670 "},ϊ:{x_min:-70,x_max:283,ha:361,o:"m 283 800 l 173 800 l 173 925 l 283 925 l 283 800 m 40 800 l -70 800 l -70 925 l 40 925 l 40 800 m 283 3 q 232 -10 257 -5 q 181 -15 206 -15 q 84 26 118 -15 q 41 200 41 79 l 41 737 l 166 737 l 167 215 q 171 141 167 157 q 225 101 182 101 q 247 103 238 101 q 283 112 256 104 l 283 3 "},π:{x_min:-.21875,x_max:773.21875,ha:857,o:"m 773 -7 l 707 -11 q 575 40 607 -11 q 552 174 552 77 l 552 226 l 552 626 l 222 626 l 222 0 l 97 0 l 97 626 l 0 626 l 0 737 l 773 737 l 773 626 l 676 626 l 676 171 q 695 103 676 117 q 773 90 714 90 l 773 -7 "},ά:{x_min:0,x_max:765.5625,ha:809,o:"m 765 -4 q 698 -14 726 -14 q 564 97 586 -14 q 466 7 525 40 q 337 -26 407 -26 q 88 98 186 -26 q 0 369 0 212 q 88 637 0 525 q 337 760 184 760 q 465 727 407 760 q 563 637 524 695 l 563 738 l 685 738 l 685 222 q 693 141 685 168 q 748 94 708 94 q 765 95 760 94 l 765 -4 m 584 371 q 531 562 584 485 q 360 653 470 653 q 192 566 254 653 q 135 379 135 489 q 186 181 135 261 q 358 84 247 84 q 528 176 465 84 q 584 371 584 260 m 604 1040 l 415 819 l 332 819 l 466 1040 l 604 1040 "},O:{x_min:0,x_max:958,ha:1057,o:"m 485 1041 q 834 882 702 1041 q 958 512 958 734 q 834 136 958 287 q 481 -26 702 -26 q 126 130 261 -26 q 0 504 0 279 q 127 880 0 728 q 485 1041 263 1041 m 480 98 q 731 225 638 98 q 815 504 815 340 q 733 783 815 669 q 480 912 640 912 q 226 784 321 912 q 142 504 142 670 q 226 224 142 339 q 480 98 319 98 "},n:{x_min:0,x_max:615,ha:724,o:"m 615 463 l 615 0 l 490 0 l 490 454 q 453 592 490 537 q 331 656 410 656 q 178 585 240 656 q 117 421 117 514 l 117 0 l 0 0 l 0 738 l 117 738 l 117 630 q 218 728 150 693 q 359 764 286 764 q 552 675 484 764 q 615 463 615 593 "},l:{x_min:41,x_max:166,ha:279,o:"m 166 0 l 41 0 l 41 1013 l 166 1013 l 166 0 "},"¤":{x_min:40.09375,x_max:728.796875,ha:825,o:"m 728 304 l 649 224 l 512 363 q 383 331 458 331 q 256 363 310 331 l 119 224 l 40 304 l 177 441 q 150 553 150 493 q 184 673 150 621 l 40 818 l 119 898 l 267 749 q 321 766 291 759 q 384 773 351 773 q 447 766 417 773 q 501 749 477 759 l 649 898 l 728 818 l 585 675 q 612 618 604 648 q 621 553 621 587 q 591 441 621 491 l 728 304 m 384 682 q 280 643 318 682 q 243 551 243 604 q 279 461 243 499 q 383 423 316 423 q 487 461 449 423 q 525 553 525 500 q 490 641 525 605 q 384 682 451 682 "},κ:{x_min:0,x_max:632.328125,ha:679,o:"m 632 0 l 482 0 l 225 384 l 124 288 l 124 0 l 0 0 l 0 738 l 124 738 l 124 446 l 433 738 l 596 738 l 312 466 l 632 0 "},p:{x_min:0,x_max:685,ha:786,o:"m 685 364 q 598 96 685 205 q 350 -23 504 -23 q 121 89 205 -23 l 121 -278 l 0 -278 l 0 738 l 121 738 l 121 633 q 220 726 159 691 q 351 761 280 761 q 598 636 504 761 q 685 364 685 522 m 557 371 q 501 560 557 481 q 330 651 437 651 q 162 559 223 651 q 108 366 108 479 q 162 177 108 254 q 333 87 224 87 q 502 178 441 87 q 557 371 557 258 "},"‡":{x_min:0,x_max:777,ha:835,o:"m 458 238 l 458 0 l 319 0 l 319 238 l 0 238 l 0 360 l 319 360 l 319 681 l 0 683 l 0 804 l 319 804 l 319 1015 l 458 1013 l 458 804 l 777 804 l 777 683 l 458 683 l 458 360 l 777 360 l 777 238 l 458 238 "},ψ:{x_min:0,x_max:808,ha:907,o:"m 465 -278 l 341 -278 l 341 -15 q 87 102 180 -15 q 0 378 0 210 l 0 739 l 133 739 l 133 379 q 182 195 133 275 q 341 98 242 98 l 341 922 l 465 922 l 465 98 q 623 195 563 98 q 675 382 675 278 l 675 742 l 808 742 l 808 381 q 720 104 808 213 q 466 -13 627 -13 l 465 -278 "},η:{x_min:.78125,x_max:697,ha:810,o:"m 697 -278 l 572 -278 l 572 454 q 540 587 572 536 q 425 650 501 650 q 271 579 337 650 q 206 420 206 509 l 206 0 l 81 0 l 81 489 q 73 588 81 562 q 0 644 56 644 l 0 741 q 68 755 38 755 q 158 720 124 755 q 200 630 193 686 q 297 726 234 692 q 434 761 359 761 q 620 692 544 761 q 697 516 697 624 l 697 -278 "}},vAt="normal",yAt=1189,bAt=-100,_At="normal",wAt={yMin:-334,xMin:-111,yMax:1189,xMax:1672},SAt=1e3,TAt={postscript_name:"Helvetiker-Regular",version_string:"Version 1.00 2004 initial release",vendor_url:"http://www.magenta.gr/",full_font_name:"Helvetiker",font_family_name:"Helvetiker",copyright:"Copyright (c) Μagenta ltd, 2004",description:"",trademark:"",designer:"",designer_url:"",unique_font_identifier:"Μagenta ltd:Helvetiker:22-10-104",license_url:"http://www.ellak.gr/fonts/MgOpen/license.html",license_description:`Copyright (c) 2004 by MAGENTA Ltd. All Rights Reserved.\r \r Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: \r \r The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.\r \r The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.\r \r This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.\r \r The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r \r THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},EAt=-334,NAt="Helvetiker",MAt=1522,CAt=50,PAt={glyphs:xAt,cssFontWeight:vAt,ascender:yAt,underlinePosition:bAt,cssFontStyle:_At,boundingBox:wAt,resolution:SAt,original_font_information:TAt,descender:EAt,familyName:NAt,lineHeight:MAt,underlineThickness:CAt},w0=aa(aa({},window.THREE?window.THREE:{BoxGeometry:Em,CircleGeometry:z3,DoubleSide:ao,Group:nd,Mesh:ui,MeshLambertMaterial:op,TextGeometry:KC,Vector3:Fe}),{},{Font:Kwe,TextGeometry:KC}),A5e=xc({props:{labelsData:{default:[]},labelLat:{default:"lat"},labelLng:{default:"lng"},labelAltitude:{default:.002},labelText:{default:"text"},labelSize:{default:.5},labelTypeFace:{default:PAt,onChange:function(e,t){t.font=new w0.Font(e)}},labelColor:{default:function(){return"lightgrey"}},labelRotation:{default:0},labelResolution:{default:3},labelIncludeDot:{default:!0},labelDotRadius:{default:.1},labelDotOrientation:{default:function(){return"bottom"}},labelsTransitionDuration:{default:1e3,triggerUpdate:!1}},init:function(e,t,r){var i=r.tweenGroup;qo(e),t.scene=e,t.tweenGroup=i;var s=new w0.CircleGeometry(1,32);t.dataMapper=new bh(e,{objBindAttr:"__threeObjLabel"}).onCreateObj(function(){var a=new w0.MeshLambertMaterial;a.side=ao;var o=new w0.Group;o.add(new w0.Mesh(s,a));var l=new w0.Mesh(void 0,a);o.add(l);var c=new w0.Mesh;return c.visible=!1,l.add(c),o.__globeObjType="label",o})},update:function(e){var t=En(e.labelLat),r=En(e.labelLng),i=En(e.labelAltitude),s=En(e.labelText),a=En(e.labelSize),o=En(e.labelRotation),l=En(e.labelColor),c=En(e.labelIncludeDot),u=En(e.labelDotRadius),d=En(e.labelDotOrientation),h=new Set(["right","top","bottom"]),p=2*Math.PI*Wa/360;e.dataMapper.onUpdateObj(function(g,x){var _=co(g.children,2),y=_[0],M=_[1],C=co(M.children,1),k=C[0],B=l(x),U=$0(B);M.material.color.set(vm(B)),M.material.transparent=U<1,M.material.opacity=U;var z=c(x),O=d(x);!z||!h.has(O)&&(O="bottom");var V=z?+u(x)*p:1e-12;y.scale.x=y.scale.y=V;var $=+a(x)*p;if(M.geometry&&M.geometry.dispose(),M.geometry=new w0.TextGeometry(s(x),{font:e.font,size:$,depth:0,bevelEnabled:!0,bevelThickness:0,bevelSize:0,curveSegments:e.labelResolution}),k.geometry&&k.geometry.dispose(),M.geometry.computeBoundingBox(),k.geometry=yY(w0.BoxGeometry,xa(new w0.Vector3().subVectors(M.geometry.boundingBox.max,M.geometry.boundingBox.min).clampScalar(0,1/0).toArray())),O!=="right"&&M.geometry.center(),z){var G=V+$/2;O==="right"&&(M.position.x=G),M.position.y={right:-$/2,top:G+$/2,bottom:-G-$/2}[O]}var H=function(ie){var ae=g.__currentTargetD=ie,Q=ae.lat,re=ae.lng,oe=ae.alt,fe=ae.rot,ee=ae.scale;Object.assign(g.position,i0(Q,re,oe)),g.lookAt(e.scene.localToWorld(new w0.Vector3(0,0,0))),g.rotateY(Math.PI),g.rotateZ(-fe*Math.PI/180),g.scale.x=g.scale.y=g.scale.z=ee},K={lat:+t(x),lng:+r(x),alt:+i(x),rot:+o(x),scale:1},W=g.__currentTargetD||Object.assign({},K,{scale:1e-12});Object.keys(K).some(function(J){return W[J]!==K[J]})&&(!e.labelsTransitionDuration||e.labelsTransitionDuration<0?H(K):e.tweenGroup.add(new cd(W).to(K,e.labelsTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(H).onComplete(function(){e.tweenGroup.remove(this)}).start()))}).digest(e.labelsData)}}),RAt=aa(aa({},window.THREE?window.THREE:{}),{},{CSS2DObject:HJe}),x5e=xc({props:{htmlElementsData:{default:[]},htmlLat:{default:"lat"},htmlLng:{default:"lng"},htmlAltitude:{default:0},htmlElement:{},htmlElementVisibilityModifier:{triggerUpdate:!1},htmlTransitionDuration:{default:1e3,triggerUpdate:!1},isBehindGlobe:{onChange:function(){this.updateObjVisibility()},triggerUpdate:!1}},methods:{updateObjVisibility:function(e,t){if(e.dataMapper){var r=t?[t]:e.dataMapper.entries().map(function(i){var s=co(i,2),a=s[1];return a}).filter(function(i){return i});r.forEach(function(i){var s=!e.isBehindGlobe||!e.isBehindGlobe(i.position);e.htmlElementVisibilityModifier?(i.visible=!0,e.htmlElementVisibilityModifier(i.element,s)):i.visible=s})}}},init:function(e,t,r){var i=r.tweenGroup;qo(e),t.scene=e,t.tweenGroup=i,t.dataMapper=new bh(e,{objBindAttr:"__threeObjHtml"}).onCreateObj(function(s){var a=En(t.htmlElement)(s),o=new RAt.CSS2DObject(a);return o.__globeObjType="html",o})},update:function(e,t){var r=this,i=En(e.htmlLat),s=En(e.htmlLng),a=En(e.htmlAltitude);t.hasOwnProperty("htmlElement")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(o,l){var c=function(h){var p=o.__currentTargetD=h,g=p.alt,x=p.lat,_=p.lng;Object.assign(o.position,i0(x,_,g)),r.updateObjVisibility(o)},u={lat:+i(l),lng:+s(l),alt:+a(l)};!e.htmlTransitionDuration||e.htmlTransitionDuration<0||!o.__currentTargetD?c(u):e.tweenGroup.add(new cd(o.__currentTargetD).to(u,e.htmlTransitionDuration).easing(Zl.Quadratic.InOut).onUpdate(c).onComplete(function(){e.tweenGroup.remove(this)}).start())}).digest(e.htmlElementsData)}}),_E=window.THREE?window.THREE:{Group:nd,Mesh:ui,MeshLambertMaterial:op,SphereGeometry:gf},v5e=xc({props:{objectsData:{default:[]},objectLat:{default:"lat"},objectLng:{default:"lng"},objectAltitude:{default:.01},objectFacesSurface:{default:!0},objectRotation:{},objectThreeObject:{default:new _E.Mesh(new _E.SphereGeometry(1,16,8),new _E.MeshLambertMaterial({color:"#ffffaa",transparent:!0,opacity:.7}))}},init:function(e,t){qo(e),t.scene=e,t.dataMapper=new bh(e,{objBindAttr:"__threeObjObject"}).onCreateObj(function(r){var i=En(t.objectThreeObject)(r);t.objectThreeObject===i&&(i=i.clone());var s=new _E.Group;return s.add(i),s.__globeObjType="object",s})},update:function(e,t){var r=En(e.objectLat),i=En(e.objectLng),s=En(e.objectAltitude),a=En(e.objectFacesSurface),o=En(e.objectRotation);t.hasOwnProperty("objectThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(l,c){var u=+r(c),d=+i(c),h=+s(c);Object.assign(l.position,i0(u,d,h)),a(c)?l.setRotationFromEuler(new gh(px(-u),px(d),0,"YXZ")):l.rotation.set(0,0,0);var p=l.children[0],g=o(c);g&&p.setRotationFromEuler(new gh(px(g.x||0),px(g.y||0),px(g.z||0)))}).digest(e.objectsData)}}),y5e=xc({props:{customLayerData:{default:[]},customThreeObject:{},customThreeObjectUpdate:{triggerUpdate:!1}},init:function(e,t){qo(e),t.scene=e,t.dataMapper=new bh(e,{objBindAttr:"__threeObjCustom"}).onCreateObj(function(r){var i=En(t.customThreeObject)(r,Wa);return i&&(t.customThreeObject===i&&(i=i.clone()),i.__globeObjType="custom"),i})},update:function(e,t){e.customThreeObjectUpdate||qo(e.scene);var r=En(e.customThreeObjectUpdate);t.hasOwnProperty("customThreeObject")&&e.dataMapper.clear(),e.dataMapper.onUpdateObj(function(i,s){return r(i,s,Wa)}).digest(e.customLayerData)}}),wE=window.THREE?window.THREE:{Camera:iy,Group:nd,Vector2:en,Vector3:Fe},LAt=["globeLayer","pointsLayer","arcsLayer","hexBinLayer","heatmapsLayer","polygonsLayer","hexedPolygonsLayer","pathsLayer","tilesLayer","particlesLayer","ringsLayer","labelsLayer","htmlElementsLayer","objectsLayer","customLayer"],b5e=Vd("globeLayer",i5e),kAt=Object.assign.apply(Object,xa(["globeImageUrl","bumpImageUrl","globeCurvatureResolution","globeTileEngineUrl","globeTileEngineMaxLevel","showGlobe","showGraticules","showAtmosphere","atmosphereColor","atmosphereAltitude"].map(function(n){return Gc({},n,b5e.linkProp(n))}))),IAt=Object.assign.apply(Object,xa(["globeMaterial","globeTileEngineClearCache"].map(function(n){return Gc({},n,b5e.linkMethod(n))}))),DAt=Vd("pointsLayer",s5e),OAt=Object.assign.apply(Object,xa(["pointsData","pointLat","pointLng","pointColor","pointAltitude","pointRadius","pointResolution","pointsMerge","pointsTransitionDuration"].map(function(n){return Gc({},n,DAt.linkProp(n))}))),jAt=Vd("arcsLayer",o5e),FAt=Object.assign.apply(Object,xa(["arcsData","arcStartLat","arcStartLng","arcStartAltitude","arcEndLat","arcEndLng","arcEndAltitude","arcColor","arcAltitude","arcAltitudeAutoScale","arcStroke","arcCurveResolution","arcCircularResolution","arcDashLength","arcDashGap","arcDashInitialGap","arcDashAnimateTime","arcsTransitionDuration"].map(function(n){return Gc({},n,jAt.linkProp(n))}))),BAt=Vd("hexBinLayer",l5e),UAt=Object.assign.apply(Object,xa(["hexBinPointsData","hexBinPointLat","hexBinPointLng","hexBinPointWeight","hexBinResolution","hexMargin","hexTopCurvatureResolution","hexTopColor","hexSideColor","hexAltitude","hexBinMerge","hexTransitionDuration"].map(function(n){return Gc({},n,BAt.linkProp(n))}))),zAt=Vd("heatmapsLayer",u5e),VAt=Object.assign.apply(Object,xa(["heatmapsData","heatmapPoints","heatmapPointLat","heatmapPointLng","heatmapPointWeight","heatmapBandwidth","heatmapColorFn","heatmapColorSaturation","heatmapBaseAltitude","heatmapTopAltitude","heatmapsTransitionDuration"].map(function(n){return Gc({},n,zAt.linkProp(n))}))),qAt=Vd("hexedPolygonsLayer",h5e),GAt=Object.assign.apply(Object,xa(["hexPolygonsData","hexPolygonGeoJsonGeometry","hexPolygonColor","hexPolygonAltitude","hexPolygonResolution","hexPolygonMargin","hexPolygonUseDots","hexPolygonCurvatureResolution","hexPolygonDotResolution","hexPolygonsTransitionDuration"].map(function(n){return Gc({},n,qAt.linkProp(n))}))),HAt=Vd("polygonsLayer",d5e),$At=Object.assign.apply(Object,xa(["polygonsData","polygonGeoJsonGeometry","polygonCapColor","polygonCapMaterial","polygonSideColor","polygonSideMaterial","polygonStrokeColor","polygonAltitude","polygonCapCurvatureResolution","polygonsTransitionDuration"].map(function(n){return Gc({},n,HAt.linkProp(n))}))),WAt=Vd("pathsLayer",f5e),XAt=Object.assign.apply(Object,xa(["pathsData","pathPoints","pathPointLat","pathPointLng","pathPointAlt","pathResolution","pathColor","pathStroke","pathDashLength","pathDashGap","pathDashInitialGap","pathDashAnimateTime","pathTransitionDuration"].map(function(n){return Gc({},n,WAt.linkProp(n))}))),YAt=Vd("tilesLayer",p5e),ZAt=Object.assign.apply(Object,xa(["tilesData","tileLat","tileLng","tileAltitude","tileWidth","tileHeight","tileUseGlobeProjection","tileMaterial","tileCurvatureResolution","tilesTransitionDuration"].map(function(n){return Gc({},n,YAt.linkProp(n))}))),QAt=Vd("particlesLayer",m5e),KAt=Object.assign.apply(Object,xa(["particlesData","particlesList","particleLat","particleLng","particleAltitude","particlesSize","particlesSizeAttenuation","particlesColor","particlesTexture"].map(function(n){return Gc({},n,QAt.linkProp(n))}))),JAt=Vd("ringsLayer",g5e),e2t=Object.assign.apply(Object,xa(["ringsData","ringLat","ringLng","ringAltitude","ringColor","ringResolution","ringMaxRadius","ringPropagationSpeed","ringRepeatPeriod"].map(function(n){return Gc({},n,JAt.linkProp(n))}))),t2t=Vd("labelsLayer",A5e),n2t=Object.assign.apply(Object,xa(["labelsData","labelLat","labelLng","labelAltitude","labelRotation","labelText","labelSize","labelTypeFace","labelColor","labelResolution","labelIncludeDot","labelDotRadius","labelDotOrientation","labelsTransitionDuration"].map(function(n){return Gc({},n,t2t.linkProp(n))}))),r2t=Vd("htmlElementsLayer",x5e),i2t=Object.assign.apply(Object,xa(["htmlElementsData","htmlLat","htmlLng","htmlAltitude","htmlElement","htmlElementVisibilityModifier","htmlTransitionDuration"].map(function(n){return Gc({},n,r2t.linkProp(n))}))),s2t=Vd("objectsLayer",v5e),a2t=Object.assign.apply(Object,xa(["objectsData","objectLat","objectLng","objectAltitude","objectRotation","objectFacesSurface","objectThreeObject"].map(function(n){return Gc({},n,s2t.linkProp(n))}))),o2t=Vd("customLayer",y5e),l2t=Object.assign.apply(Object,xa(["customLayerData","customThreeObject","customThreeObjectUpdate"].map(function(n){return Gc({},n,o2t.linkProp(n))}))),c2t=xc({props:aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa(aa({onGlobeReady:{triggerUpdate:!1},rendererSize:{default:new wE.Vector2(window.innerWidth,window.innerHeight),onChange:function(e,t){t.pathsLayer.rendererSize(e)},triggerUpdate:!1}},kAt),OAt),FAt),UAt),VAt),$At),GAt),XAt),ZAt),KAt),e2t),n2t),i2t),a2t),l2t),methods:aa({getGlobeRadius:Mue,getCoords:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=function(i){function s(){var a;QR(this,s);for(var o=arguments.length,l=new Array(o),c=0;cjue&&(this.dispatchEvent(wB),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>jue||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(wB),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Ks.NONE,this.keyState=Ks.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(wB),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(j1.copy(this._panEnd).sub(this._panStart),j1.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;j1.x*=e,j1.y*=t}j1.multiplyScalar(this._eye.length()*this.panSpeed),TE.copy(this._eye).cross(this.object.up).setLength(j1.x),TE.add(h2t.copy(this.object.up).setLength(j1.y)),this.object.position.add(TE),this.target.add(TE),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(j1.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){NE.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=NE.length();e?(this._eye.copy(this.object.position).sub(this.target),Fue.copy(this._eye).normalize(),EE.copy(this.object.up).normalize(),TB.crossVectors(EE,Fue).normalize(),EE.setLength(this._moveCurr.y-this._movePrev.y),TB.setLength(this._moveCurr.x-this._movePrev.x),NE.copy(EE.add(TB)),SB.crossVectors(NE,this._eye).normalize(),e*=this.rotateSpeed,_b.setFromAxisAngle(SB,e),this._eye.applyQuaternion(_b),this.object.up.applyQuaternion(_b),this._lastAxis.copy(SB),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),_b.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(_b),this.object.up.applyQuaternion(_b)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Ks.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Q0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=Q0.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return SE.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),SE}_getMouseOnCircle(e,t){return SE.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),SE}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tthis.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()Math.PI&&(r-=Qd),i<-Math.PI?i+=Qd:i>Math.PI&&(i-=Qd),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=a!=this._spherical.radius}if(nc.setFromSpherical(this._spherical),nc.applyQuaternion(this._quatInverse),t.copy(this.target).add(nc),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=nc.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const o=new Fe(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new Fe(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=nc.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(ME.origin.copy(this.object.position),ME.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ME.direction))EB||8*(1-this._lastQuaternion.dot(this.object.quaternion))>EB||this._lastTargetPosition.distanceToSquared(this.target)>EB?(this.dispatchEvent(Bue),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Qd/60*this.autoRotateSpeed*e:Qd/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){nc.setFromMatrixColumn(t,0),nc.multiplyScalar(-e),this._panOffset.add(nc)}_panUp(e,t){this.screenSpacePanning===!0?nc.setFromMatrixColumn(t,1):(nc.setFromMatrixColumn(t,0),nc.crossVectors(this.object.up,nc)),nc.multiplyScalar(e),this._panOffset.add(nc)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;nc.copy(i).sub(this.target);let s=nc.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/r.clientHeight,this.object.matrix),this._panUp(2*t*s/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,s=t-r.top,a=r.width,o=r.height;this._mouse.x=i/a*2-1,this._mouse.y=-(s/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qd*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qd*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Qd*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Qd*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Qd*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Qd*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(r*r+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),s=.5*(e.pageY+r.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Qd*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qd*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;tzue||8*(1-this._lastQuaternion.dot(t.quaternion))>zue)&&(this.dispatchEvent(V2t),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function G2t(n){if(!(n.altKey||this.enabled===!1)){switch(n.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function H2t(n){if(this.enabled!==!1){switch(n.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function $2t(n){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(n.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function W2t(n){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,r=e.size[1]/2;this._moveState.yawLeft=-(n.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(n.pageY-e.offset[1]-r)/r,this._updateRotationVector()}}function X2t(n){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(n.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function Y2t(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function Z2t(n){this.enabled!==!1&&n.preventDefault()}const Q2t={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }`,fragmentShader:` uniform float opacity; uniform sampler2D tDiffuse; varying vec2 vUv; void main() { vec4 texel = texture2D( tDiffuse, vUv ); gl_FragColor = opacity * texel; }`};class eL{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const K2t=new Yf(-1,1,1,-1,0,1);class J2t extends Pr{constructor(){super(),this.setAttribute("position",new tr([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new tr([0,2,0,0,2,0],2))}}const ext=new J2t;class txt{constructor(e){this._mesh=new ui(ext,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,K2t)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class nxt extends eL{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Dl?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=qg.clone(e.uniforms),this.material=new Dl({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new txt(this.material)}render(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class que extends eL{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,r){const i=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let a,o;this.inverse?(a=0,o=1):(a=1,o=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,a,4294967295),s.buffers.stencil.setClear(o),s.buffers.stencil.setLocked(!0),e.setRenderTarget(r),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(i.EQUAL,1,4294967295),s.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),s.buffers.stencil.setLocked(!0)}}class rxt extends eL{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ixt{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const r=e.getSize(new en);this._width=r.width,this._height=r.height,t=new dh(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:ba}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new nxt(Q2t),this.copyPass.material.blending=Yl,this.timer=new lR}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t=0&&i<1?(o=s,l=a):i>=1&&i<2?(o=a,l=s):i>=2&&i<3?(l=s,c=a):i>=3&&i<4?(l=a,c=s):i>=4&&i<5?(o=a,c=s):i>=5&&i<6&&(o=s,c=a);var u=t-s/2,d=o+u,h=l+u,p=c+u;return r(d,h,p)}var Gue={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function dxt(n){if(typeof n!="string")return n;var e=n.toLowerCase();return Gue[e]?"#"+Gue[e]:n}var hxt=/^#[a-fA-F0-9]{6}$/,fxt=/^#[a-fA-F0-9]{8}$/,pxt=/^#[a-fA-F0-9]{3}$/,mxt=/^#[a-fA-F0-9]{4}$/,MB=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,gxt=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Axt=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,xxt=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function A3(n){if(typeof n!="string")throw new Kp(3);var e=dxt(n);if(e.match(hxt))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(fxt)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(pxt))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(mxt)){var r=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:r}}var i=MB.exec(e);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10)};var s=gxt.exec(e.substring(0,50));if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10),alpha:parseFloat(""+s[4])>1?parseFloat(""+s[4])/100:parseFloat(""+s[4])};var a=Axt.exec(e);if(a){var o=parseInt(""+a[1],10),l=parseInt(""+a[2],10)/100,c=parseInt(""+a[3],10)/100,u="rgb("+JC(o,l,c)+")",d=MB.exec(u);if(!d)throw new Kp(4,e,u);return{red:parseInt(""+d[1],10),green:parseInt(""+d[2],10),blue:parseInt(""+d[3],10)}}var h=xxt.exec(e.substring(0,50));if(h){var p=parseInt(""+h[1],10),g=parseInt(""+h[2],10)/100,x=parseInt(""+h[3],10)/100,_="rgb("+JC(p,g,x)+")",y=MB.exec(_);if(!y)throw new Kp(4,e,_);return{red:parseInt(""+y[1],10),green:parseInt(""+y[2],10),blue:parseInt(""+y[3],10),alpha:parseFloat(""+h[4])>1?parseFloat(""+h[4])/100:parseFloat(""+h[4])}}throw new Kp(5)}function vxt(n){var e=n.red/255,t=n.green/255,r=n.blue/255,i=Math.max(e,t,r),s=Math.min(e,t,r),a=(i+s)/2;if(i===s)return n.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:n.alpha}:{hue:0,saturation:0,lightness:a};var o,l=i-s,c=a>.5?l/(2-i-s):l/(i+s);switch(i){case e:o=(t-r)/l+(t=1?T5e(n.hue,n.saturation,n.lightness):"rgba("+JC(n.hue,n.saturation,n.lightness)+","+n.alpha+")";throw new Kp(2)}function E5e(n,e,t){if(typeof n=="number"&&typeof e=="number"&&typeof t=="number")return _q("#"+cx(n)+cx(e)+cx(t));if(typeof n=="object"&&e===void 0&&t===void 0)return _q("#"+cx(n.red)+cx(n.green)+cx(n.blue));throw new Kp(6)}function tL(n,e,t,r){if(typeof n=="object"&&e===void 0&&t===void 0&&r===void 0)return n.alpha>=1?E5e(n.red,n.green,n.blue):"rgba("+n.red+","+n.green+","+n.blue+","+n.alpha+")";throw new Kp(7)}var Sxt=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Txt=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},Ext=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha>"u")},Nxt=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function f2(n){if(typeof n!="object")throw new Kp(8);if(Txt(n))return tL(n);if(Sxt(n))return E5e(n);if(Nxt(n))return wxt(n);if(Ext(n))return _xt(n);throw new Kp(8)}function N5e(n,e,t){return function(){var i=t.concat(Array.prototype.slice.call(arguments));return i.length>=e?n.apply(this,i):N5e(n,e,i)}}function Af(n){return N5e(n,n.length,[])}function Mxt(n,e){if(e==="transparent")return e;var t=h2(e);return f2(No({},t,{hue:t.hue+parseFloat(n)}))}Af(Mxt);function Q3(n,e,t){return Math.max(n,Math.min(e,t))}function Cxt(n,e){if(e==="transparent")return e;var t=h2(e);return f2(No({},t,{lightness:Q3(0,1,t.lightness-parseFloat(n))}))}Af(Cxt);function Pxt(n,e){if(e==="transparent")return e;var t=h2(e);return f2(No({},t,{saturation:Q3(0,1,t.saturation-parseFloat(n))}))}Af(Pxt);function Rxt(n,e){if(e==="transparent")return e;var t=h2(e);return f2(No({},t,{lightness:Q3(0,1,t.lightness+parseFloat(n))}))}Af(Rxt);function Lxt(n,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(n===0)return t;var r=A3(e),i=No({},r,{alpha:typeof r.alpha=="number"?r.alpha:1}),s=A3(t),a=No({},s,{alpha:typeof s.alpha=="number"?s.alpha:1}),o=i.alpha-a.alpha,l=parseFloat(n)*2-1,c=l*o===-1?l:l+o,u=1+l*o,d=(c/u+1)/2,h=1-d,p={red:Math.floor(i.red*d+a.red*h),green:Math.floor(i.green*d+a.green*h),blue:Math.floor(i.blue*d+a.blue*h),alpha:i.alpha*parseFloat(n)+a.alpha*(1-parseFloat(n))};return tL(p)}var kxt=Af(Lxt),M5e=kxt;function Ixt(n,e){if(e==="transparent")return e;var t=A3(e),r=typeof t.alpha=="number"?t.alpha:1,i=No({},t,{alpha:Q3(0,1,(r*100+parseFloat(n)*100)/100)});return tL(i)}var Dxt=Af(Ixt),Oxt=Dxt;function jxt(n,e){if(e==="transparent")return e;var t=h2(e);return f2(No({},t,{saturation:Q3(0,1,t.saturation+parseFloat(n))}))}Af(jxt);function Fxt(n,e){return e==="transparent"?e:f2(No({},h2(e),{hue:parseFloat(n)}))}Af(Fxt);function Bxt(n,e){return e==="transparent"?e:f2(No({},h2(e),{lightness:parseFloat(n)}))}Af(Bxt);function Uxt(n,e){return e==="transparent"?e:f2(No({},h2(e),{saturation:parseFloat(n)}))}Af(Uxt);function zxt(n,e){return e==="transparent"?e:M5e(parseFloat(n),"rgb(0, 0, 0)",e)}Af(zxt);function Vxt(n,e){return e==="transparent"?e:M5e(parseFloat(n),"rgb(255, 255, 255)",e)}Af(Vxt);function qxt(n,e){if(e==="transparent")return e;var t=A3(e),r=typeof t.alpha=="number"?t.alpha:1,i=No({},t,{alpha:Q3(0,1,+(r*100-parseFloat(n)*100).toFixed(2)/100)});return tL(i)}Af(qxt);var S6,wo,C5e,P5e,$1,Hue,R5e,L5e,PB,LN,_4,k5e,EY,wq,Sq,e7={},t7=[],Gxt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,nL=Array.isArray;function Jp(n,e){for(var t in e)n[t]=e[t];return n}function NY(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function Hxt(n,e,t){var r,i,s,a={};for(s in e)s=="key"?r=e[s]:s=="ref"?i=e[s]:a[s]=e[s];if(arguments.length>2&&(a.children=arguments.length>3?S6.call(arguments,2):t),typeof n=="function"&&n.defaultProps!=null)for(s in n.defaultProps)a[s]===void 0&&(a[s]=n.defaultProps[s]);return w4(n,a,r,i,null)}function w4(n,e,t,r,i){var s={type:n,props:e,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++C5e,__i:-1,__u:0};return i==null&&wo.vnode!=null&&wo.vnode(s),s}function rL(n){return n.children}function kN(n,e){this.props=n,this.context=e}function x3(n,e){if(e==null)return n.__?x3(n.__,n.__i+1):null;for(var t;ee&&$1.sort(L5e),n=$1.shift(),e=$1.length,$xt(n)}finally{$1.length=n7.__r=0}}function D5e(n,e,t,r,i,s,a,o,l,c,u){var d,h,p,g,x,_,y,M=r&&r.__k||t7,C=e.length;for(l=Wxt(t,e,M,l,C),d=0;d0?a=n.__k[s]=w4(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):n.__k[s]=a,l=s+h,a.__=n,a.__b=n.__b+1,o=null,(c=a.__i=Xxt(a,t,l,d))!=-1&&(d--,(o=t[c])&&(o.__u|=2)),o==null||o.__v==null?(c==-1&&(i>u?h--:il?h--:h++,a.__u|=4))):n.__k[s]=null;if(d)for(s=0;s(u?1:0)){for(i=t-1,s=t+1;i>=0||s=0?i--:s++])!=null&&!(2&c.__u)&&o==c.key&&l==c.type)return a}return-1}function Wue(n,e,t){e[0]=="-"?n.setProperty(e,t??""):n[e]=t==null?"":typeof t!="number"||Gxt.test(e)?t:t+"px"}function CE(n,e,t,r,i){var s,a;e:if(e=="style")if(typeof t=="string")n.style.cssText=t;else{if(typeof r=="string"&&(n.style.cssText=r=""),r)for(e in r)t&&e in t||Wue(n.style,e,"");if(t)for(e in t)r&&t[e]==r[e]||Wue(n.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(k5e,"$1")),a=e.toLowerCase(),e=a in n||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),n.l||(n.l={}),n.l[e+s]=t,t?r?t[_4]=r[_4]:(t[_4]=EY,n.addEventListener(e,s?Sq:wq,s)):n.removeEventListener(e,s?Sq:wq,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in n)try{n[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?n.removeAttribute(e):n.setAttribute(e,e=="popover"&&t==1?"":t))}}function Xue(n){return function(e){if(this.l){var t=this.l[e.type+n];if(e[LN]==null)e[LN]=EY++;else if(e[LN]0?n:nL(n)?n.map(B5e):n.constructor!==void 0?null:Jp({},n)}function Yxt(n,e,t,r,i,s,a,o,l){var c,u,d,h,p,g,x,_=t.props||e7,y=e.props,M=e.type;if(M=="svg"?i="http://www.w3.org/2000/svg":M=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c2&&(o.children=arguments.length>3?S6.call(arguments,2):t),w4(n.type,o,r||n.key,i||n.ref,null)}S6=t7.slice,wo={__e:function(n,e,t,r){for(var i,s,a;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(n)),a=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(n,r||{}),a=i.__d),a)return i.__E=i}catch(o){n=o}throw n}},C5e=0,P5e=function(n){return n!=null&&n.constructor===void 0},kN.prototype.setState=function(n,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Jp({},this.state),typeof n=="function"&&(n=n(Jp({},t),this.props)),n&&Jp(t,n),n!=null&&this.__v&&(e&&this._sb.push(e),$ue(this))},kN.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),$ue(this))},kN.prototype.render=rL,$1=[],R5e=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,L5e=function(n,e){return n.__v.__b-e.__v.__b},n7.__r=0,PB=Math.random().toString(8),LN="__d"+PB,_4="__a"+PB,k5e=/(PointerCapture)$|Capture$/i,EY=0,wq=Xue(!1),Sq=Xue(!0);function Yue(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",t==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n))}}var uvt=`.float-tooltip-kap { position: absolute; width: max-content; /* prevent shrinking near right edge */ max-width: max(50%, 150px); padding: 3px 5px; border-radius: 3px; font: 12px sans-serif; color: #eee; background: rgba(0,0,0,0.6); pointer-events: none; } `;cvt(uvt);var dvt=xc({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=r.style,s=i===void 0?{}:i,a=!!e&&r7(e)==="object"&&!!e.node&&typeof e.node=="function",o=Xh(a?e.node():e);o.style("position")==="static"&&o.style("position","relative"),t.tooltipEl=o.append("div").attr("class","float-tooltip-kap"),Object.entries(s).forEach(function(c){var u=rvt(c,2),d=u[0],h=u[1];return t.tooltipEl.style(d,h)}),t.tooltipEl.style("left","-10000px").style("display","none");var l="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,o.on("mousemove.".concat(l),function(c){t.mouseInside=!0;var u=Df(c),d=o.node(),h=d.offsetWidth,p=d.offsetHeight,g=[t.offsetX===null||t.offsetX===void 0?"-".concat(u[0]/h*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?p>130&&p-u[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",u[0]+"px").style("top",u[1]+"px").style("transform","translate(".concat(g.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),o.on("mouseover.".concat(l),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),o.on("mouseout.".concat(l),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):ovt(e.content)?(e.tooltipEl.text(""),lvt(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function hvt(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",t==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n))}}var fvt=`.scene-nav-info { position: absolute; bottom: 5px; width: 100%; text-align: center; color: slategrey; opacity: 0.7; font-size: 10px; font-family: sans-serif; pointer-events: none; user-select: none; } .scene-container canvas:focus { outline: none; }`;hvt(fvt);function Eq(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var r=null;if(e.hoverDuringDrag||!e.isPointerDragging){var i=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&i.sort(function(a,o){return e.hoverOrderComparator(a.object,o.object)});var s=i.find(function(a){return e.hoverFilter(a.object)})||null;r=s?s.object:null,e.intersection=s||null}r!==e.hoverObj&&(e.onHover(r,e.hoverObj,e.intersection),e.tooltip.content(r&&En(e.tooltipContent)(r,e.intersection)||null),e.hoverObj=r)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,r=t.x,i=t.y;return{x:r,y:i}},cameraPosition:function(e,t,r,i){var s=e.camera;if(t&&e.initialised){var a,o,l=t,c=r||{x:0,y:0,z:0};if((a=e.povPosTween)===null||a===void 0||a.end(),(o=e.povTgtTween)===null||o===void 0||o.end(),!i)h(l),p(c);else{var u=Object.assign({},s.position),d=g();e.tweenGroup.add(e.povPosTween=new cd(u).to(l,i).easing(Zl.Quadratic.Out).onUpdate(h).onComplete(function(){e.povPosTween=void 0,e.tweenGroup.remove(this)}).start()),e.tweenGroup.add(e.povTgtTween=new cd(d).to(c,i/3).easing(Zl.Quadratic.Out).onUpdate(p).onComplete(function(){e.povTgtTween=void 0,e.tweenGroup.remove(this)}).start())}return this}return Object.assign({},s.position,{lookAt:g()});function h(x){var _=x.x,y=x.y,M=x.z;_!==void 0&&(s.position.x=_),y!==void 0&&(s.position.y=y),M!==void 0&&(s.position.z=M)}function p(x){var _=new vo.Vector3(x.x,x.y,x.z);e.controls.enabled&&e.controls.target?e.controls.target=_:s.lookAt(_)}function g(){return Object.assign(new vo.Vector3(0,0,-1e3).applyQuaternion(s.quaternion).add(s.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,i=arguments.length,s=new Array(i>3?i-3:0),a=3;a2&&arguments[2]!==void 0?arguments[2]:0,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,s=e.camera;if(t){var a=new vo.Vector3(0,0,0),o=Math.max.apply(Math,Q2(Object.entries(t).map(function(p){var g=bvt(p,2),x=g[0],_=g[1];return Math.max.apply(Math,Q2(_.map(function(y){return Math.abs(a[x]-y)})))})))*2,l=(1-i*2/e.height)*s.fov,c=o/Math.atan(l*Math.PI/180),u=c/s.aspect,d=Math.max(c,u);if(d>0){var h=a.clone().sub(s.position).normalize().multiplyScalar(-d);this.cameraPosition(h,a,r)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},r=new vo.Box3(new vo.Vector3(0,0,0),new vo.Vector3(0,0,0)),i=e.objects.filter(t);return i.length?(i.forEach(function(s){return r.expandByObject(s)}),Object.assign.apply(Object,Q2(["x","y","z"].map(function(s){return gvt({},s,[r.min[s],r.max[s]])})))):null},getScreenCoords:function(e,t,r,i){var s=new vo.Vector3(t,r,i);return s.project(this.camera()),{x:(s.x+1)*e.width/2,y:-(s.y-1)*e.height/2}},getSceneCoords:function(e,t,r){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,s=new vo.Vector2(t/e.width*2-1,-(r/e.height)*2+1),a=new vo.Raycaster;return a.setFromCamera(s,e.camera),Object.assign({},a.ray.at(i,new vo.Vector3))},intersectingObjects:function(e,t,r){var i=new vo.Vector2(t/e.width*2-1,-(r/e.height)*2+1),s=new vo.Raycaster;return s.params.Line.threshold=e.lineHoverPrecision,s.params.Points.threshold=e.pointsHoverPrecision,s.setFromCamera(i,e.camera),s.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls},_destructor:function(e){var t,r,i;Svt(e.scene),(t=e.controls)===null||t===void 0||t.dispose(),(r=e.renderer)===null||r===void 0||r.dispose(),(i=e.postProcessingComposer)===null||i===void 0||i.dispose()}},stateInit:function(){return{scene:new vo.Scene,camera:new vo.PerspectiveCamera,timer:new vo.Timer,tweenGroup:new hR,lastRaycasterCheck:0}},init:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=r.controlType,s=i===void 0?"trackball":i,a=r.useWebGPU,o=a===void 0?!1:a,l=r.rendererConfig,c=l===void 0?{}:l,u=r.extraRenderers,d=u===void 0?[]:u,h=r.waitForLoadComplete,p=h===void 0?!0:h;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[s]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new dvt(t.container),t.pointerPos=new vo.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(g){return t.container.addEventListener(g,function(x){if(g==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&x.type==="pointermove"&&(x.pressure>0||t.isPointerPressed)&&(x.pointerType==="mouse"||x.movementX===void 0||[x.movementX,x.movementY].some(function(M){return Math.abs(M)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var _=y(t.container);t.pointerPos.x=x.pageX-_.left,t.pointerPos.y=x.pageY-_.top}function y(M){var C=M.getBoundingClientRect(),k=window.pageXOffset||document.documentElement.scrollLeft,B=window.pageYOffset||document.documentElement.scrollTop;return{top:C.top+B,left:C.left+k}}},{passive:!0})}),t.container.addEventListener("pointerup",function(g){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){g.button===0&&t.onClick(t.hoverObj||null,g,t.intersection),g.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,g,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(g){t.onRightClick&&g.preventDefault()}),t.renderer=new(o?Ywe:vo.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},c)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=d,t.extraRenderers.forEach(function(g){g.domElement.style.position="absolute",g.domElement.style.top="0px",g.domElement.style.pointerEvents="none",t.container.appendChild(g.domElement)}),t.postProcessingComposer=new ixt(t.renderer),t.postProcessingComposer.addPass(new sxt(t.scene,t.camera)),t.controls=new{trackball:f2t,orbit:C2t,fly:q2t}[s](t.camera,t.renderer.domElement),s==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(s==="trackball"||s==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(Q2(t.extraRenderers)).forEach(function(g){return g.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new vo.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!p,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var r,i=e.width,s=e.height;e.container.style.width="".concat(i,"px"),e.container.style.height="".concat(s,"px"),[e.renderer,e.postProcessingComposer].concat(Q2(e.extraRenderers)).forEach(function(p){return p.setSize(i,s)}),e.camera.aspect=i/s;var a=e.viewOffset.slice(0,2);a.some(function(p){return p})&&(r=e.camera).setViewOffset.apply(r,[i,s].concat(Q2(a),[i,s])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var o,l=e.width,c=e.height,u=e.viewOffset.slice(0,2);u.some(function(p){return p})?(o=e.camera).setViewOffset.apply(o,[l,c].concat(Q2(u),[l,c])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new vo.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var d=A3(e.backgroundColor).alpha;d===void 0&&(d=1),e.renderer.setClearColor(new vo.Color(Oxt(1,e.backgroundColor)),d)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new vo.TextureLoader().load(e.backgroundImageUrl,function(p){p.colorSpace=vo.SRGBColorSpace,e.skysphere.material=new vo.MeshBasicMaterial({map:p,side:vo.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&h()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&h())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(p){return e.scene.remove(p)}),e.lights.forEach(function(p){return e.scene.add(p)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(p){return e.scene.remove(p)}),e.objects.forEach(function(p){return e.scene.add(p)}));function h(){e.loadComplete=e.scene.visible=!0}}});function Tvt(n,e){e===void 0&&(e={});var t=e.insertAt;if(!(typeof document>"u")){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",t==="top"&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n))}}var Evt=`.scene-container .clickable { cursor: pointer; }`;Tvt(Evt);function Nq(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t1?o-1:0),c=1;c1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,i=o();if(t.lat===void 0&&t.lng===void 0&&t.altitude===void 0)return i;var s,a=Object.assign({},i,t);if(["lat","lng","altitude"].forEach(function(c){return a[c]=+a[c]}),(s=e.povTween)===null||s===void 0||s.end(),!r)l(a);else{for(;i.lng-a.lng>180;)i.lng-=360;for(;i.lng-a.lng<-180;)i.lng+=360;e.tweenGroup.add(e.povTween=new cd(i).to(a,r).easing(Zl.Cubic.InOut).onUpdate(l).onComplete(function(){e.povTween=void 0,e.tweenGroup.remove(this)}).start())}return this;function o(){return e.globe.toGeoCoords(e.renderObjs.cameraPosition())}function l(c){var u=c.lat,d=c.lng,h=c.altitude;e.renderObjs.cameraPosition(e.globe.getCoords(u,d,h)),e.globe.setPointOfView(e.renderObjs.camera())}},getScreenCoords:function(e){for(var t,r=arguments.length,i=new Array(r>1?r-1:0),s=1;s{(async()=>{try{const z=await(await fetch(`${Kue}/api/map/markers`,{credentials:"include"})).json();z.markers&&t(z.markers),z.migrations&&i(z.migrations)}catch(U){console.error("Failed to fetch map markers:",U)}finally{a(!1)}})()},[]);const _=de.useMemo(()=>d==="all"?e:e.filter(B=>B.type===d),[e,d]),y=de.useMemo(()=>{const B=e.length,U=e.filter(V=>V.type==="naissance").length,z=e.filter(V=>V.type==="deces").length,O=e.filter(V=>V.type==="evenement").length;return{total:B,births:U,deaths:z,events:O}},[e]),M=de.useMemo(()=>_.map(B=>{let U="#f59e0b";return B.type==="naissance"&&(U="#10b981"),B.type==="deces"&&(U="#ef4444"),{lat:B.lat,lng:B.lon,size:B.type==="naissance"||B.type==="deces"?.6:.4,color:U,label:`${B.type==="naissance"?"🍼":B.type==="deces"?"🕊️":"🌟"} ${B.name} (${B.location||""})`,data:B}}),[_]),C=de.useMemo(()=>p?r.map(B=>({startLat:B.startLat,startLng:B.startLng,endLat:B.endLat,endLng:B.endLng,color:B.from_type==="naissance"?["#10b981","#ef4444"]:["#f59e0b","#3b82f6"],label:`Migration : ${B.person} (${B.from_location||""} ➔ ${B.to_location||""})`,person:B})):[],[r,p]);if(s)return f.jsxs("div",{className:"w-full h-[75vh] flex flex-col items-center justify-center bg-[#fdfbf7] rounded-3xl border border-[#d4c4a8]/30 shadow-xl gap-3",children:[f.jsx("div",{className:"w-12 h-12 border-4 border-amber-300 border-t-amber-700 rounded-full animate-spin"}),f.jsx("p",{className:"text-[#8b7355] font-serif italic font-bold",children:"Cartographie des ancêtres et des migrations..."})]});const k=e.length>0?VM.latLngBounds(e.map(B=>[B.lat,B.lon])):[[40,-10],[50,10]];return f.jsxs(Gn.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},className:"relative w-full h-[78vh] rounded-[2.5rem] overflow-hidden shadow-2xl border-4 border-[#d4c4a8] bg-slate-950 flex flex-col",children:[f.jsxs("div",{className:"absolute top-4 left-4 right-4 z-[1000] flex flex-wrap items-center justify-between gap-2 pointer-events-none",children:[f.jsxs("div",{className:"pointer-events-auto bg-white/95 backdrop-blur-md px-3 py-1.5 rounded-2xl shadow-xl border border-slate-200/90 flex items-center gap-1",children:[f.jsxs("button",{onClick:()=>l("2d"),className:`px-3 py-1.5 rounded-xl text-xs font-black transition flex items-center gap-1.5 ${o==="2d"?"bg-slate-900 text-amber-300 shadow-xs":"text-slate-700 hover:bg-slate-100"}`,children:[f.jsx(ECe,{}),f.jsx("span",{children:"Carte 2D"})]}),f.jsxs("button",{onClick:()=>l("3d"),className:`px-3 py-1.5 rounded-xl text-xs font-black transition flex items-center gap-1.5 ${o==="3d"?"bg-slate-900 text-amber-300 shadow-xs":"text-slate-700 hover:bg-slate-100"}`,children:[f.jsx(mH,{}),f.jsx("span",{children:"Globe 3D"})]}),o==="3d"&&f.jsxs("div",{className:"flex items-center ml-1 pl-1 border-l border-slate-200 gap-1",children:[f.jsxs("button",{onClick:()=>u("day"),title:"Mode Jour (Satellite)",className:`px-2 py-1 rounded-lg text-xs font-bold transition flex items-center gap-1 ${c==="day"?"bg-amber-400 text-slate-950 shadow-xs":"text-slate-600 hover:bg-slate-100"}`,children:[f.jsx("span",{children:"☀️"})," Jour"]}),f.jsxs("button",{onClick:()=>u("night"),title:"Mode Nuit (Lumières & Étoiles)",className:`px-2 py-1 rounded-lg text-xs font-bold transition flex items-center gap-1 ${c==="night"?"bg-indigo-950 text-indigo-200 border border-indigo-700 shadow-xs":"text-slate-600 hover:bg-slate-100"}`,children:[f.jsx("span",{children:"🌙"})," Nuit"]})]})]}),f.jsxs("div",{className:"pointer-events-auto bg-white/95 backdrop-blur-md px-3 py-1.5 rounded-2xl shadow-xl border border-slate-200/90 flex items-center gap-1.5 overflow-x-auto no-scrollbar",children:[f.jsxs("span",{className:"text-slate-400 text-[10px] font-black uppercase flex items-center gap-1 mr-1",children:[f.jsx(gH,{className:"text-[9px]"})," Filtres :"]}),f.jsxs("button",{onClick:()=>h("all"),className:`px-2.5 py-1 rounded-xl text-xs font-bold transition whitespace-nowrap ${d==="all"?"bg-amber-100 text-amber-950 border border-amber-300 font-black":"text-slate-600 hover:bg-slate-100"}`,children:["✨ Tous (",y.total,")"]}),f.jsxs("button",{onClick:()=>h("naissance"),className:`px-2.5 py-1 rounded-xl text-xs font-bold transition flex items-center gap-1 whitespace-nowrap ${d==="naissance"?"bg-emerald-100 text-emerald-950 border border-emerald-300 font-black":"text-slate-600 hover:bg-slate-100"}`,children:[f.jsx("span",{children:"🍼"})," Naissances (",y.births,")"]}),f.jsxs("button",{onClick:()=>h("deces"),className:`px-2.5 py-1 rounded-xl text-xs font-bold transition flex items-center gap-1 whitespace-nowrap ${d==="deces"?"bg-rose-100 text-rose-950 border border-rose-300 font-black":"text-slate-600 hover:bg-slate-100"}`,children:[f.jsx("span",{children:"🕊️"})," Décès (",y.deaths,")"]}),f.jsxs("button",{onClick:()=>h("evenement"),className:`px-2.5 py-1 rounded-xl text-xs font-bold transition flex items-center gap-1 whitespace-nowrap ${d==="evenement"?"bg-amber-100 text-amber-900 border border-amber-300 font-black":"text-slate-600 hover:bg-slate-100"}`,children:[f.jsx("span",{children:"🌟"})," Événements (",y.events,")"]}),f.jsx("div",{className:"h-4 w-px bg-slate-200 mx-0.5"}),f.jsxs("button",{onClick:()=>g(!p),className:`px-2.5 py-1 rounded-xl text-xs font-bold transition flex items-center gap-1 whitespace-nowrap ${p?"bg-indigo-100 text-indigo-900 border border-indigo-300 font-black":"text-slate-400 hover:bg-slate-100"}`,title:"Afficher/Masquer les trajectoires migratoires familiales",children:[f.jsx(gCe,{className:"text-[10px]"}),f.jsx("span",{children:"Trajectoires"})]})]})]}),f.jsx("div",{className:"w-full h-full relative",children:o==="2d"?f.jsxs(wHe,{bounds:k,scrollWheelZoom:!0,style:{height:"100%",width:"100%"},className:"z-10",children:[f.jsx(EHe,{attribution:Xvt,url:Wvt}),p&&r.map((B,U)=>f.jsx(THe,{positions:[B.start_coords,B.end_coords],pathOptions:{color:B.from_type==="naissance"?"#10b981":"#f59e0b",weight:2.5,dashArray:"6, 8",opacity:.7},children:f.jsx(Hse,{children:f.jsxs("div",{className:"text-xs p-1",children:[f.jsxs("p",{className:"font-bold text-slate-800",children:["✈️ Trajectoire de ",B.person]}),f.jsxs("p",{className:"text-slate-600 mt-1",children:["De : ",B.from_location||"Lieu d'origine"]}),f.jsxs("p",{className:"text-slate-600",children:["Vers : ",B.to_location||"Lieu de destination"]})]})})},`mig-${U}`)),_.map((B,U)=>{let z="orange";B.type==="naissance"&&(z="green"),B.type==="deces"&&(z="red");const O=new VM.Icon({iconUrl:`https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-${z}.png`,shadowUrl:"https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png",iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]});return f.jsx(SHe,{position:[B.lat,B.lon],icon:O,children:f.jsx(Hse,{className:"font-sans",children:f.jsxs("div",{className:"text-center w-44 p-1",children:[B.photo&&f.jsx("img",{src:B.photo.startsWith("/")?`${Kue}${B.photo}`:B.photo,alt:B.name,className:"w-14 h-14 rounded-full mx-auto object-cover border-2 border-amber-300 mb-2 shadow-sm"}),f.jsx("h3",{className:"font-black text-slate-900 text-xs font-serif",children:B.name}),f.jsxs("div",{className:"text-[11px] text-slate-600 mt-1 space-y-0.5",children:[B.type==="naissance"&&f.jsxs("span",{className:"inline-block px-2 py-0.5 rounded-full bg-emerald-50 text-emerald-800 border border-emerald-200 font-bold text-[10px]",children:["🍼 Né(e) à ",B.location]}),B.type==="deces"&&f.jsxs("span",{className:"inline-block px-2 py-0.5 rounded-full bg-rose-50 text-rose-800 border border-rose-200 font-bold text-[10px]",children:["🕊️ Décédé(e) à ",B.location]}),B.type==="evenement"&&f.jsxs("span",{className:"inline-block px-2 py-0.5 rounded-full bg-amber-50 text-amber-800 border border-amber-200 font-bold text-[10px]",children:["🌟 ",B.title||"Événement"," à ",B.location]}),B.date&&f.jsxs("p",{className:"font-bold text-slate-700 mt-1",children:["📅 ",B.date]})]}),f.jsxs("button",{onClick:()=>n&&n({slug:B.slug||B.personne_slug,prenom:B.name.split(" ")[0],nom:B.name.split(" ").slice(1).join(" ")}),className:"mt-2.5 text-[10px] uppercase font-black text-white bg-slate-900 px-3 py-1.5 rounded-xl hover:bg-amber-600 transition flex items-center justify-center gap-1 w-full shadow-xs",children:[f.jsx("span",{children:"👁️ Voir la Fiche"}),f.jsx(nN,{className:"text-[8px]"})]})]})})},`marker-${B.slug}-${U}`)})]}):f.jsx("div",{className:"w-full h-full cursor-grab active:cursor-grabbing bg-slate-950 flex items-center justify-center",children:f.jsx(sL,{ref:x,globeImageUrl:c==="night"?"//unpkg.com/three-globe/example/img/earth-night.jpg":"//unpkg.com/three-globe/example/img/earth-blue-marble.jpg",backgroundImageUrl:c==="night"?"//unpkg.com/three-globe/example/img/night-sky.png":void 0,pointsData:M,pointLabel:"label",pointColor:"color",pointAltitude:"size",pointRadius:.6,onPointClick:B=>{B.data&&n&&n({slug:B.data.slug||B.data.personne_slug,prenom:B.data.name.split(" ")[0],nom:B.data.name.split(" ").slice(1).join(" ")})},arcsData:C,arcColor:"color",arcDashLength:.4,arcDashGap:3,arcDashInitialGap:()=>Math.random()*5,arcDashAnimateTime:2e3,arcAltitude:.15,atmosphereColor:"#60a5fa",atmosphereAltitude:.15})})}),f.jsxs("div",{className:"absolute bottom-4 left-4 z-[1000] bg-white/90 backdrop-blur-md px-4 py-2 rounded-2xl shadow-lg border border-slate-200 text-xs font-bold flex items-center gap-4 text-slate-700",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"w-3 h-3 rounded-full bg-emerald-500 inline-block border border-white shadow-2xs"}),f.jsx("span",{children:"Naissances"})]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"w-3 h-3 rounded-full bg-rose-500 inline-block border border-white shadow-2xs"}),f.jsx("span",{children:"Décès"})]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"w-3 h-3 rounded-full bg-amber-500 inline-block border border-white shadow-2xs"}),f.jsx("span",{children:"Événements"})]})]})]})}const K5e=de.createContext(null),Jue="https://famille.ravin-cloud.fr",Zvt=({children:n})=>{const[e,t]=de.useState(null),[r,i]=de.useState(!0),s=de.useCallback(async()=>{try{const o=new URLSearchParams(window.location.search),l=o.get("token")||o.get("magic_token");if(l)try{await fetch(`${Jue}/api/magic_login?token=${encodeURIComponent(l)}&format=json`,{credentials:"include"})}catch(u){console.warn("Direct magic token auth failed:",u)}const c=await fetch(`${Jue}/api/me`,{credentials:"include"});if(c.ok){const u=await c.json();t(u)}else l||window.location.hostname==="localhost"||window.location.protocol==="capacitor:"?t({name:"Ravin",email:"famille.ravin@gmail.com",role:"admin",picture:"https://ui-avatars.com/api/?name=Ravin"}):t(null)}catch(o){console.error("Error fetching user:",o),new URLSearchParams(window.location.search).get("token")||window.location.hostname==="localhost"||window.location.protocol==="capacitor:"?t({name:"Ravin",email:"famille.ravin@gmail.com",role:"admin",picture:"https://ui-avatars.com/api/?name=Ravin"}):t(null)}finally{i(!1)}},[]);de.useEffect(()=>{s()},[s]);const a={user:e,loading:r,refetch:s};return f.jsx(K5e.Provider,{value:a,children:n})},o1=()=>de.useContext(K5e),ede="https://famille.ravin-cloud.fr";function Qvt({currentTab:n,onNavigate:e,onAddPerson:t,onOpenScanner:r,onOpenMuseum:i,onOpenGlobe:s,onToggleChat:a,onOpenIngestion:o,onOpenAdmin:l,onOpenUserProfile:c}){var B;const{user:u,refetch:d}=o1(),[h,p]=de.useState(!1),g=de.useRef(null);de.useEffect(()=>{function U(z){g.current&&!g.current.contains(z.target)&&p(!1)}return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);const x=async()=>{try{(await fetch(`${ede}/api/logout`,{credentials:"include"})).ok&&d&&d()}catch(U){console.error("Logout error:",U)}},_=[{id:"membres",icon:jA,label:"Membres",emoji:"👥"},{id:"arbre",icon:X4,label:"Arbre",emoji:"🌳"},{id:"timeline",icon:pH,label:"Frise",emoji:"⏳"},{id:"carte",icon:mH,label:"Carte",emoji:"🗺️"},{id:"journal",icon:bM,label:"Journal",emoji:"📖"},{id:"studio_ia",icon:ld,label:"IA",emoji:"✨"},{id:"medias",icon:Zpe,label:"Médias",emoji:"🖼️"},{id:"stats",icon:eme,label:"Stats",emoji:"📊"}],y=(u==null?void 0:u.name)||(u==null?void 0:u.preferred_username)||((B=u==null?void 0:u.email)==null?void 0:B.split("@")[0])||"Membre",M=y.charAt(0).toUpperCase(),C=u!=null&&u.picture?u.picture.startsWith("/")?`${ede}${u.picture}`:u.picture:null,k=(u==null?void 0:u.role)==="admin"||(u==null?void 0:u.role)==="super_admin";return f.jsx("nav",{className:"sticky top-0 z-40 w-full bg-slate-900/95 backdrop-blur-xl border-b border-amber-500/20 shadow-lg text-slate-100 pt-[env(safe-area-inset-top)]",children:f.jsxs("div",{className:"max-w-[1920px] mx-auto px-2 sm:px-6 h-14 sm:h-16 flex items-center justify-between gap-2 sm:gap-4",children:[f.jsxs("div",{onClick:()=>e("membres"),className:"flex items-center gap-2 sm:gap-3 cursor-pointer group shrink-0",children:[f.jsx("div",{className:"w-9 h-9 sm:w-10 sm:h-10 rounded-xl bg-gradient-to-tr from-amber-600 via-amber-500 to-amber-300 flex items-center justify-center text-lg sm:text-xl shadow-[0_0_15px_rgba(245,158,11,0.4)] group-hover:scale-105 transition-transform duration-300",children:"🏛️"}),f.jsxs("div",{className:"hidden lg:block",children:[f.jsx("h1",{className:"text-sm font-serif font-black tracking-wide text-amber-200 group-hover:text-amber-100 leading-tight",children:"Archives Familiales"}),f.jsx("p",{className:"text-[10px] text-amber-400/80 font-medium tracking-wider uppercase",children:"Mémoire & Générations"})]})]}),f.jsx("div",{className:"hidden md:flex items-center gap-1 bg-slate-950/60 p-1.5 rounded-full border border-white/10 shadow-inner",children:_.map(U=>{const z=U.icon,O=n===U.id;return f.jsxs("button",{onClick:()=>e(U.id),className:`relative px-3.5 py-1.5 rounded-full text-xs font-serif font-bold transition-all duration-200 flex items-center gap-1.5 ${O?"text-amber-200 shadow-sm":"text-slate-400 hover:text-slate-200 hover:bg-white/5"}`,children:[O&&f.jsx(Gn.div,{layoutId:"top-nav-active-pill",className:"absolute inset-0 rounded-full bg-gradient-to-r from-amber-600/50 via-amber-500/40 to-amber-600/50 border border-amber-400/60 shadow-[0_0_12px_rgba(245,158,11,0.3)]",transition:{type:"spring",stiffness:500,damping:35}}),f.jsx(z,{className:`relative z-10 text-xs ${O?"text-amber-300":"opacity-75"}`}),f.jsx("span",{className:"relative z-10",children:U.label})]},U.id)})}),f.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2.5",children:[f.jsxs("button",{onClick:o||a,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-indigo-600/30 to-purple-600/30 hover:from-indigo-600/50 hover:to-purple-600/50 text-indigo-300 text-xs font-bold border border-indigo-400/40 shadow-xs transition-all hover:scale-105 active:scale-95 animate-pulse hover:animate-none",title:"Déposer des lettres, textes bruts, conversations ou photos pour mise à jour IA",children:[f.jsx(ld,{className:"text-[11px] text-indigo-300"}),f.jsx("span",{className:"hidden md:inline",children:"Ingestion IA"})]}),f.jsxs("button",{onClick:t,className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-emerald-600/20 hover:bg-emerald-600/30 text-emerald-300 text-xs font-bold border border-emerald-500/40 shadow-xs transition-all hover:scale-105 active:scale-95",title:"Ajouter une personne à l'arbre",children:[f.jsx(F_,{className:"text-[11px]"}),f.jsx("span",{className:"hidden xl:inline",children:"Ajouter"})]}),f.jsxs("button",{onClick:r,className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-cyan-600/20 hover:bg-cyan-600/30 text-cyan-300 text-xs font-bold border border-cyan-500/40 shadow-xs transition-all hover:scale-105 active:scale-95",title:"Scanner une CNI, un acte ou une photo ancienne",children:[f.jsx(fm,{className:"text-[11px]"}),f.jsx("span",{className:"hidden xl:inline",children:"Scanner"})]}),f.jsxs("button",{onClick:i,className:"hidden lg:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-amber-600/20 hover:bg-amber-600/30 text-amber-300 text-xs font-bold border border-amber-500/40 shadow-xs transition-all hover:scale-105 active:scale-95",title:"Explorer le Musée 3D des ancêtres",children:[f.jsx("span",{className:"text-xs",children:"🏛️"}),f.jsx("span",{className:"hidden xl:inline",children:"Musée 3D"})]}),f.jsxs("div",{className:"relative",ref:g,children:[f.jsxs("button",{onClick:()=>p(!h),className:"flex items-center gap-2 p-1 sm:pl-2 sm:pr-2.5 rounded-full bg-slate-800/80 hover:bg-slate-700/80 border border-white/10 hover:border-amber-400/40 transition-all shadow-md group",children:[f.jsxs("div",{className:"relative",children:[C?f.jsx("img",{src:C,alt:y,className:"w-8 h-8 rounded-full object-cover border border-amber-400/70 group-hover:border-amber-300 shadow-xs",onError:U=>{U.target.style.display="none"}}):f.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-tr from-amber-600 to-amber-400 text-slate-900 font-black text-xs flex items-center justify-center border border-amber-300 shadow-xs",children:M}),k&&f.jsx("span",{className:"absolute -top-1 -right-1 w-3.5 h-3.5 rounded-full bg-amber-400 text-slate-950 flex items-center justify-center text-[8px] font-black shadow-xs",children:"👑"})]}),f.jsxs("div",{className:"hidden sm:block text-left",children:[f.jsx("p",{className:"text-xs font-bold text-slate-200 leading-none truncate max-w-[100px]",children:y.split(" ")[0]}),f.jsx("p",{className:"text-[9px] font-semibold text-amber-400/90 uppercase tracking-wide leading-none mt-0.5",children:k?"Admin":"Membre"})]}),f.jsx(B1,{className:`text-[10px] text-slate-400 transition-transform duration-200 ${h?"rotate-180 text-amber-300":""}`})]}),f.jsx(Da,{children:h&&f.jsxs(Gn.div,{initial:{opacity:0,y:10,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.96},transition:{duration:.18,ease:"easeOut"},className:"absolute right-0 mt-2.5 w-80 rounded-2xl bg-slate-900/95 border border-amber-500/30 backdrop-blur-2xl shadow-[0_20px_50px_rgba(0,0,0,0.8)] p-3 z-50 ring-1 ring-white/10",children:[f.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-xl bg-gradient-to-r from-amber-950/40 via-slate-800 to-slate-800 border border-amber-500/20 mb-2",children:[C?f.jsx("img",{src:C,alt:y,className:"w-12 h-12 rounded-full object-cover border-2 border-amber-400 shadow-md"}):f.jsx("div",{className:"w-12 h-12 rounded-full bg-gradient-to-tr from-amber-600 to-amber-400 text-slate-950 font-black text-lg flex items-center justify-center border-2 border-amber-300 shadow-md",children:M}),f.jsxs("div",{className:"overflow-hidden flex-1",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("p",{className:"text-sm font-bold text-white truncate",children:y}),k&&f.jsx("span",{className:"text-amber-400 text-xs",children:"👑"})]}),f.jsx("p",{className:"text-xs text-slate-400 truncate",children:u==null?void 0:u.email}),f.jsx("div",{className:"mt-1 flex items-center gap-1.5",children:f.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wider ${k?"bg-amber-400/20 text-amber-300 border border-amber-400/40":"bg-emerald-400/20 text-emerald-300 border border-emerald-400/40"}`,children:(u==null?void 0:u.role)==="super_admin"?"Super Admin":k?"Administrateur":"Membre Famille"})})]})]}),f.jsx("div",{className:"space-y-1 py-1",children:f.jsxs("button",{onClick:()=>{p(!1),c()},className:"w-full flex items-center justify-between px-3 py-2.5 rounded-xl text-xs font-bold text-slate-200 hover:text-white hover:bg-white/10 transition-colors group",children:[f.jsxs("div",{className:"flex items-center gap-2.5",children:[f.jsx("div",{className:"w-7 h-7 rounded-lg bg-amber-500/20 text-amber-300 flex items-center justify-center group-hover:scale-110 transition-transform",children:f.jsx(hm,{className:"text-xs"})}),f.jsx("span",{children:"Mon Espace & Profil"})]}),f.jsx("span",{className:"text-[10px] text-amber-400/80 bg-amber-400/10 px-2 py-0.5 rounded-full border border-amber-400/20",children:"Personnaliser"})]})}),k&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-amber-500/20 space-y-1",children:[f.jsxs("div",{className:"px-3 py-1 flex items-center justify-between",children:[f.jsxs("span",{className:"text-[10px] font-black uppercase tracking-wider text-amber-400 font-serif flex items-center gap-1.5",children:[f.jsx("span",{children:"👑"})," Administration & Droits"]}),f.jsx("span",{className:"text-[9px] bg-amber-500/20 text-amber-300 px-1.5 py-0.5 rounded font-mono font-bold",children:"Admin"})]}),f.jsxs("button",{onClick:()=>{p(!1),l()},className:"w-full flex items-center justify-between px-3 py-2 rounded-xl text-xs font-semibold text-slate-200 hover:text-white hover:bg-amber-500/15 border border-transparent hover:border-amber-500/30 transition-all",children:[f.jsxs("div",{className:"flex items-center gap-2.5",children:[f.jsx("div",{className:"w-7 h-7 rounded-lg bg-amber-500/20 text-amber-300 flex items-center justify-center",children:f.jsx(uH,{className:"text-xs"})}),f.jsx("span",{children:"Panneau d'Administration"})]}),f.jsx("span",{className:"text-slate-500 text-xs",children:"→"})]}),f.jsxs("button",{onClick:()=>{p(!1),l()},className:"w-full flex items-center justify-between px-3 py-2 rounded-xl text-xs font-semibold text-slate-200 hover:text-white hover:bg-amber-500/15 border border-transparent hover:border-amber-500/30 transition-all",children:[f.jsxs("div",{className:"flex items-center gap-2.5",children:[f.jsx("div",{className:"w-7 h-7 rounded-lg bg-amber-500/20 text-amber-300 flex items-center justify-center",children:f.jsx(Wpe,{className:"text-xs"})}),f.jsx("span",{children:"Permissions par Nom / Branche"})]}),f.jsx("span",{className:"text-slate-500 text-xs",children:"→"})]})]}),f.jsxs("div",{className:"mt-2 pt-2 border-t border-white/10 space-y-1",children:[f.jsxs("div",{className:"px-3 py-1 text-[10px] font-black uppercase tracking-wider text-slate-400 font-serif flex items-center gap-1",children:[f.jsx("span",{children:"✨"})," Expériences & Immersion"]}),f.jsxs("div",{className:"grid grid-cols-2 gap-1 px-1",children:[f.jsxs("button",{onClick:()=>{p(!1),i()},className:"flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs font-medium text-slate-300 hover:text-white hover:bg-white/5 transition",children:[f.jsx("span",{children:"🏛️"}),f.jsx("span",{children:"Musée 3D"})]}),f.jsxs("button",{onClick:()=>{p(!1),s()},className:"flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs font-medium text-slate-300 hover:text-white hover:bg-white/5 transition",children:[f.jsx("span",{children:"🌍"}),f.jsx("span",{children:"Globe 3D"})]}),f.jsxs("button",{onClick:()=>{p(!1),a()},className:"flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs font-medium text-slate-300 hover:text-white hover:bg-white/5 transition",children:[f.jsx("span",{children:"💬"}),f.jsx("span",{children:"Assistant IA"})]}),f.jsxs("button",{onClick:()=>{p(!1),r()},className:"flex items-center gap-2 px-2.5 py-2 rounded-lg text-xs font-medium text-slate-300 hover:text-white hover:bg-white/5 transition",children:[f.jsx("span",{children:"📷"}),f.jsx("span",{children:"Scanner CNI"})]})]})]}),f.jsx("div",{className:"mt-2 pt-2 border-t border-white/10",children:f.jsxs("button",{onClick:x,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-xl text-xs font-bold text-red-400 hover:text-red-300 hover:bg-red-500/10 transition-colors",children:[f.jsx(Xpe,{className:"text-xs"}),f.jsx("span",{children:"Se Déconnecter"})]})})]})})]})]})]})})}const RB="https://famille.ravin-cloud.fr",Kvt=()=>{var i;const{user:n,loading:e,refetch:t}=o1(),r=async()=>{try{(await fetch(`${RB}/api/logout`,{credentials:"include"})).ok?t():console.error("Logout failed")}catch(s){console.error("Error during logout:",s)}};if(e)return f.jsx("div",{className:"w-24 h-8 bg-gray-200 rounded animate-pulse"});if(n){const s=n.name||n.preferred_username||((i=n.email)==null?void 0:i.split("@")[0])||"Membre",a=s.charAt(0).toUpperCase(),o=()=>{window.dispatchEvent(new CustomEvent("OPEN_USER_PROFILE_MODAL"))},l=n.picture?n.picture.startsWith("/")?`${RB}${n.picture}`:n.picture:null;return f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"text-right",children:f.jsx("button",{onClick:r,className:"text-xs font-medium text-slate-400 hover:text-red-500 transition-colors bg-white/50 px-3 py-1 rounded-full border border-slate-200",children:"Déconnexion"})}),f.jsxs("div",{onClick:o,className:"relative cursor-pointer group",title:"Personnaliser mon profil",children:[l?f.jsx("img",{src:l,alt:s,className:"w-10 h-10 rounded-full border-2 border-emerald-500 shadow-md object-cover group-hover:border-amber-400 transition-all group-hover:scale-105",onError:c=>{c.target.style.display="none"}}):f.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-tr from-emerald-600 to-teal-400 text-white font-bold flex items-center justify-center text-sm shadow-md border-2 border-emerald-400 group-hover:border-amber-400 transition-all group-hover:scale-105",children:a}),f.jsx("span",{className:"absolute -bottom-1 -right-1 w-4 h-4 rounded-full bg-amber-400 text-slate-900 flex items-center justify-center text-[9px] font-black shadow group-hover:scale-110 transition",children:"✏️"})]})]})}return f.jsxs("a",{href:`${RB}/api/login/google`,className:"flex items-center justify-center gap-3 px-6 py-4 font-semibold text-slate-700 bg-white rounded-2xl shadow-[0_8px_20px_0_rgba(0,0,0,0.08)] hover:shadow-[0_12px_28px_rgba(0,0,0,0.12)] hover:-translate-y-1 transition-all duration-300 w-full max-w-sm",children:[f.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",children:[f.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z",fill:"#4285F4"}),f.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),f.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),f.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continuer avec Google"]})},tde="https://famille.ravin-cloud.fr";function J5e({slug:n,onClose:e}){const[t,r]=de.useState(null),[i,s]=de.useState(!0),a=async()=>{s(!0);try{const c=await fetch(`${tde}/api/newspaper/${n}`,{credentials:"include"}),u=await c.json();if(!c.ok)throw new Error(u.error||"Erreur de génération du journal");r(u)}catch(c){jt.error(c.message)}finally{s(!1)}};if(de.useEffect(()=>{a()},[n]),i)return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-md p-4",children:f.jsxs("div",{className:"bg-[#f4e4bc] p-8 rounded-2xl border-4 border-[#8b6d43] flex flex-col items-center max-w-md w-full shadow-2xl relative overflow-hidden",children:[f.jsx("div",{className:"absolute -top-12 -right-12 w-32 h-32 bg-[#8b6d43]/10 rounded-full blur-xl pointer-events-none"}),f.jsx("div",{className:"animate-spin text-[#5c4a30] mb-4",children:f.jsx(sz,{size:56})}),f.jsx("p",{className:"text-[#3a2f1f] font-serif text-2xl font-black text-center tracking-tight",children:'Composition de la "Une" en cours...'}),f.jsx("p",{className:"text-[#8b6d43] font-serif text-sm text-center mt-2 italic",children:"Le typographe ajuste la presse rotative et grave l'illustration d'époque."})]})});if(!t)return null;const o=Rg(t.person_name||""),l=t.person_photo?t.person_photo.startsWith("/")?`${tde}${t.person_photo}`:t.person_photo:o?"/avatar_female.png":"/avatar_male.png";return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/85 backdrop-blur-md p-2 sm:p-6 overflow-y-auto",children:f.jsxs("div",{className:"relative max-w-5xl w-full bg-[#fcf8ec] shadow-[0_0_60px_rgba(0,0,0,0.8)] my-auto flex flex-col my-6 sm:my-auto rounded-sm border border-[#d4c4a8]",children:[f.jsx("div",{className:"absolute inset-0 pointer-events-none opacity-25",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.6'/%3E%3C/svg%3E")`,mixBlendMode:"multiply"}}),f.jsxs("div",{className:"sticky top-0 z-30 bg-[#3a2f1f]/90 backdrop-blur-md p-3 px-6 flex items-center justify-between text-[#fcf8ec] border-b-2 border-[#8b6d43]",children:[f.jsxs("div",{className:"flex items-center gap-2 font-serif text-sm font-bold tracking-wider",children:[f.jsx(sz,{className:"text-amber-400",size:18}),f.jsx("span",{className:"uppercase text-amber-200",children:"Journal d'Époque & Gazette Familiale"})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("button",{onClick:a,className:"px-3 py-1.5 bg-amber-700/80 hover:bg-amber-600 text-[#fcf8ec] rounded-lg text-xs font-bold font-serif flex items-center gap-1.5 transition-all",title:"Régénérer une nouvelle édition",children:[f.jsx(ld,{size:12})," Régénérer l'Édition"]}),f.jsxs("button",{onClick:()=>window.print(),className:"px-3 py-1.5 bg-[#5c4a30] hover:bg-[#8b6d43] text-[#fcf8ec] rounded-lg text-xs font-bold font-serif flex items-center gap-1.5 transition-all",children:[f.jsx(yCe,{size:12})," Imprimer"]}),f.jsx("button",{onClick:e,className:"p-2 bg-red-900/80 hover:bg-red-800 text-white rounded-full transition-transform hover:scale-110 ml-2",children:f.jsx($a,{size:14})})]})]}),f.jsxs("div",{id:"newspaper-content",className:"p-6 sm:p-12 text-[#2a2215] font-serif relative",style:{border:"8px double #4a3b26",margin:"12px"},children:[f.jsxs("div",{className:"flex justify-between items-center text-[11px] sm:text-xs border-b border-[#4a3b26] pb-1 font-bold uppercase tracking-widest text-[#5c4a30]",children:[f.jsxs("span",{className:"flex items-center gap-1",children:[f.jsx(dCe,{})," ",t.motto||"Organe illustré d'informations & de mémoire"]}),f.jsx("span",{children:t.edition_number||"Édition Spéciale - N° 1.895"})]}),f.jsxs("div",{className:"border-b-4 border-double border-[#4a3b26] py-4 mb-4 text-center",children:[f.jsx("h1",{className:"text-4xl sm:text-7xl font-black uppercase tracking-tight text-[#1a150e] py-1",style:{fontFamily:'"Playfair Display", "Georgia", "Times New Roman", serif',textShadow:"2px 2px 0px rgba(139,109,67,0.15)",letterSpacing:"-0.02em"},children:t.journal_name||"LA GAZETTE DE L'ÉPOQUE"}),f.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 border-t-2 border-b-2 border-[#4a3b26] py-1.5 my-2 font-bold uppercase text-[10px] sm:text-xs text-[#4a3b26] tracking-wider text-center items-center",children:[f.jsxs("div",{children:["📅 ",t.date_edition||"12 Octobre 1898"]}),f.jsxs("div",{children:["⛅ ",t.weather_report||"Météo: Temps frais & ensoleillé"]}),f.jsx("div",{className:"hidden sm:block",children:"🏛️ Tirage: 150 000 Ex."}),f.jsxs("div",{children:["💰 ",t.price||"Prix: 5 Centimes"]})]})]}),f.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8",children:[f.jsxs("div",{className:"lg:col-span-8 space-y-6",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-2xl sm:text-4xl font-black leading-tight text-[#1a150e] mb-2",style:{fontFamily:'"Playfair Display", "Times New Roman", serif'},children:t.headline_title}),t.sub_headline&&f.jsx("p",{className:"text-sm sm:text-base font-bold italic text-[#5c4a30] border-l-2 border-[#8b6d43] pl-3 py-1 bg-[#f4e4bc]/40",children:t.sub_headline})]}),f.jsxs("div",{className:"my-4 p-3 bg-[#f3e7c8] border-2 border-[#4a3b26] shadow-md flex flex-col sm:flex-row gap-4 items-center",children:[f.jsxs("div",{className:"relative shrink-0 w-36 h-44 sm:w-44 sm:h-52 border-4 border-[#3a2f1f] shadow-inner bg-slate-900 overflow-hidden",children:[f.jsx("img",{src:l,alt:t.person_name,className:"w-full h-full object-cover filter sepia contrast-125 brightness-90 grayscale-[30%]",onError:c=>{c.target.src="/avatar_male.png"}}),f.jsx("div",{className:"absolute inset-0 bg-amber-900/20 mix-blend-color pointer-events-none"}),f.jsx("div",{className:"absolute bottom-1 right-1 text-[8px] bg-black/70 text-amber-200 px-1 rounded uppercase tracking-widest font-mono",children:"Cliché 1898"})]}),f.jsxs("div",{className:"flex-1 space-y-2 text-left",children:[f.jsxs("p",{className:"text-xs font-bold uppercase tracking-wider text-[#8b6d43] border-b border-[#8b6d43]/40 pb-1",children:["📸 Portrait d'Époque de ",t.person_name||"L'Individu"]}),f.jsx("p",{className:"text-xs italic leading-relaxed text-[#3a2f1f]",children:t.photo_caption||"Photographie prise sur le vif, immortalisant la prestance et le regard éclairé du sujet au sommet de son parcours."}),t.historical_quote&&f.jsxs("div",{className:"mt-2 text-[11px] font-serif italic text-[#4a3b26] flex items-start gap-1 bg-[#fbf3db] p-2 rounded border border-[#8b6d43]/30",children:[f.jsx(hH,{className:"text-[#8b6d43] shrink-0 mt-0.5",size:10}),f.jsx("span",{children:t.historical_quote})]})]})]}),f.jsx("div",{className:"columns-1 sm:columns-2 gap-6 text-justify leading-relaxed text-sm sm:text-base text-[#2a2215]",style:{columnRule:"1px solid #c4b496"},children:t.headline_article?t.headline_article.split(` `).map((c,u)=>f.jsx("p",{className:`mb-3 ${u===0?"first-letter:text-5xl first-letter:font-black first-letter:float-left first-letter:mr-2 first-letter:mt-1 first-letter:text-[#4a3b26] first-letter:font-serif":"indent-4"}`,children:c},u)):f.jsx("p",{children:"Chargement du récit de l'époque..."})})]}),f.jsxs("div",{className:"lg:col-span-4 space-y-6 border-t-2 lg:border-t-0 lg:border-l-2 border-[#4a3b26] pt-6 lg:pt-0 lg:pl-6",children:[t.telegrams&&f.jsxs("div",{className:"bg-[#f4e8cb] border-2 border-dashed border-[#8b6d43] p-3 rounded-sm shadow-sm",children:[f.jsx("h4",{className:"font-extrabold text-xs uppercase tracking-widest text-[#8b6d43] border-b border-[#8b6d43]/30 pb-1 mb-2 flex items-center gap-1",children:"📡 Dépêche Télégraphique"}),f.jsx("p",{className:"text-xs italic leading-snug text-[#3a2f1f]",children:t.telegrams})]}),f.jsxs("div",{className:"space-y-2 border-b-2 border-[#4a3b26] pb-4",children:[f.jsx("h3",{className:"text-base font-extrabold uppercase border-b-2 border-[#4a3b26] pb-1 text-[#1a150e]",children:t.side_article_title||"L'Événement du Siècle"}),f.jsxs("div",{className:"w-full h-28 bg-slate-900 border border-[#4a3b26] overflow-hidden my-2 relative",children:[f.jsx("img",{src:"https://images.unsplash.com/photo-1544620347-c4fd4a3d5957?q=80&w=800&auto=format&fit=crop",alt:"Contexte historique",className:"w-full h-full object-cover filter sepia contrast-110 brightness-75"}),f.jsx("div",{className:"absolute bottom-0 inset-x-0 bg-black/70 text-amber-100 text-[9px] px-2 py-0.5 italic text-center",children:"Les grandes innovations de l'époque"})]}),f.jsx("div",{className:"text-xs text-justify leading-relaxed text-[#3a2f1f] space-y-2",children:t.side_article?t.side_article.split(` `).map((c,u)=>f.jsx("p",{children:c},u)):f.jsx("p",{children:"Chargement du contexte historique..."})})]}),f.jsxs("div",{className:"border-4 border-double border-[#5c4a30] p-4 text-center bg-[#f2e2c4] shadow-inner relative overflow-hidden",children:[f.jsx("div",{className:"absolute top-1 left-1 text-[8px] uppercase tracking-widest text-[#8b6d43]",children:"Réclame Illustrée"}),f.jsx("h4",{className:"font-extrabold text-sm uppercase tracking-wider mb-1 mt-2 text-[#4a3b26] border-b border-[#8b6d43]/40 pb-1",children:t.advertisement_title||"PROGRÈS DE L'INDUSTRIE"}),f.jsx("p",{className:"italic text-xs text-[#2a2215] my-2 leading-snug",children:t.advertisement||"Machine à coudre de précision & Élixirs de santé souverains pour toute la famille."}),f.jsx("div",{className:"mt-3 inline-block px-3 py-1 bg-[#3a2f1f] text-[#fcf8ec] text-[10px] font-bold uppercase tracking-widest rounded-xs",children:"En vente dans toutes les pharmacopées"})]})]})]}),f.jsxs("div",{className:"border-t-2 border-[#4a3b26] mt-8 pt-3 flex flex-col sm:flex-row justify-between items-center text-[10px] uppercase font-bold text-[#5c4a30] gap-2",children:[f.jsx("span",{children:"Imprimerie Centrale des Archives Familiales - Dépôt Légal 1898"}),f.jsx("span",{children:"Conservé pour la Postérité Généalogique"})]})]})]})})}var e4e={exports:{}},hy={};/** * @license React * react-reconciler-constants.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */hy.ConcurrentRoot=1;hy.ContinuousEventPriority=4;hy.DefaultEventPriority=16;hy.DiscreteEventPriority=1;hy.IdleEventPriority=536870912;hy.LegacyRoot=0;e4e.exports=hy;var s_=e4e.exports;function Jvt(n){let e;const t=new Set,r=(c,u)=>{const d=typeof c=="function"?c(e):c;if(d!==e){const h=e;e=u?d:Object.assign({},e,d),t.forEach(p=>p(e,h))}},i=()=>e,s=(c,u=i,d=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let h=u(e);function p(){const g=u(e);if(!d(h,g)){const x=h;c(h=g,x)}}return t.add(p),()=>t.delete(p)},l={setState:r,getState:i,subscribe:(c,u,d)=>u||d?s(c,u,d):(t.add(c),()=>t.delete(c)),destroy:()=>t.clear()};return e=n(r,i,l),l}const eyt=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),nde=eyt?de.useEffect:de.useLayoutEffect;function tyt(n){const e=typeof n=="function"?Jvt(n):n,t=(r=e.getState,i=Object.is)=>{const[,s]=de.useReducer(_=>_+1,0),a=e.getState(),o=de.useRef(a),l=de.useRef(r),c=de.useRef(i),u=de.useRef(!1),d=de.useRef();d.current===void 0&&(d.current=r(a));let h,p=!1;(o.current!==a||l.current!==r||c.current!==i||u.current)&&(h=r(a),p=!i(d.current,h)),nde(()=>{p&&(d.current=h),o.current=a,l.current=r,c.current=i,u.current=!1});const g=de.useRef(a);nde(()=>{const _=()=>{try{const M=e.getState(),C=l.current(M);c.current(d.current,C)||(o.current=M,d.current=C,s())}catch{u.current=!0,s()}},y=e.subscribe(_);return e.getState()!==g.current&&_(),y},[]);const x=p?h:d.current;return de.useDebugValue(x),x};return Object.assign(t,e),t[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const r=[t,e];return{next(){const i=r.length<=0;return{value:r.shift(),done:i}}}},t}const nyt=n=>typeof n=="object"&&typeof n.then=="function",Px=[];function t4e(n,e,t=(r,i)=>r===i){if(n===e)return!0;if(!n||!e)return!1;const r=n.length;if(e.length!==r)return!1;for(let i=0;i0&&(s.timeout&&clearTimeout(s.timeout),s.timeout=setTimeout(s.remove,r.lifespan)),s.response;if(!t)throw s.promise}const i={keys:e,equal:r.equal,remove:()=>{const s=Px.indexOf(i);s!==-1&&Px.splice(s,1)},promise:(nyt(n)?n:n(...e)).then(s=>{i.response=s,r.lifespan&&r.lifespan>0&&(i.timeout=setTimeout(i.remove,r.lifespan))}).catch(s=>i.error=s)};if(Px.push(i),!t)throw i.promise}const r4e=(n,e,t)=>n4e(n,e,!1,t),ryt=(n,e,t)=>void n4e(n,e,!0,t),iyt=n=>{if(n===void 0||n.length===0)Px.splice(0,Px.length);else{const e=Px.find(t=>t4e(n,t.keys,t.equal));e&&e.remove()}};var i4e={exports:{}},LB={exports:{}},kB={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var rde;function syt(){return rde||(rde=1,function(n){function e(Q,re){var oe=Q.length;Q.push(re);e:for(;0>>1,ee=Q[fe];if(0>>1;fei(be,oe))pei(ge,be)?(Q[fe]=ge,Q[pe]=oe,fe=pe):(Q[fe]=be,Q[Ae]=oe,fe=Ae);else if(pei(ge,oe))Q[fe]=ge,Q[pe]=oe,fe=pe;else break e}}return re}function i(Q,re){var oe=Q.sortIndex-re.sortIndex;return oe!==0?oe:Q.id-re.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();n.unstable_now=function(){return a.now()-o}}var l=[],c=[],u=1,d=null,h=3,p=!1,g=!1,x=!1,_=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(Q){for(var re=t(c);re!==null;){if(re.callback===null)r(c);else if(re.startTime<=Q)r(c),re.sortIndex=re.expirationTime,e(l,re);else break;re=t(c)}}function k(Q){if(x=!1,C(Q),!g)if(t(l)!==null)g=!0,ie(B);else{var re=t(c);re!==null&&ae(k,re.startTime-Q)}}function B(Q,re){g=!1,x&&(x=!1,y(O),O=-1),p=!0;var oe=h;try{for(C(re),d=t(l);d!==null&&(!(d.expirationTime>re)||Q&&!G());){var fe=d.callback;if(typeof fe=="function"){d.callback=null,h=d.priorityLevel;var ee=fe(d.expirationTime<=re);re=n.unstable_now(),typeof ee=="function"?d.callback=ee:d===t(l)&&r(l),C(re)}else r(l);d=t(l)}if(d!==null)var me=!0;else{var Ae=t(c);Ae!==null&&ae(k,Ae.startTime-re),me=!1}return me}finally{d=null,h=oe,p=!1}}var U=!1,z=null,O=-1,V=5,$=-1;function G(){return!(n.unstable_now()-$Q||125fe?(Q.sortIndex=oe,e(c,Q),t(l)===null&&Q===t(c)&&(x?(y(O),O=-1):x=!0,ae(k,oe-fe))):(Q.sortIndex=ee,e(l,Q),g||p||(g=!0,ie(B))),Q},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(Q){var re=h;return function(){var oe=h;h=re;try{return Q.apply(this,arguments)}finally{h=oe}}}}(kB)),kB}var ide;function ayt(){return ide||(ide=1,LB.exports=syt()),LB.exports}/** * @license React * react-reconciler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var oyt=function(e){var t={},r=de,i=ayt(),s=Object.assign;function a(R){for(var I="https://reactjs.org/docs/error-decoder.html?invariant="+R,Y=1;Y$t||ye[gt]!==Le[$t]){var mn=` `+ye[gt].replace(" at new "," at ");return R.displayName&&mn.includes("")&&(mn=mn.replace("",R.displayName)),mn}while(1<=gt&&0<=$t);break}}}finally{Ii=!1,Error.prepareStackTrace=Y}return(R=R?R.displayName||R.name:"")?wa(R):""}var wt=Object.prototype.hasOwnProperty,_e=[],Dt=-1;function Xt(R){return{current:R}}function vn(R){0>Dt||(R.current=_e[Dt],_e[Dt]=null,Dt--)}function Sn(R,I){Dt++,_e[Dt]=R.current,R.current=I}var hn={},Tn=Xt(hn),Re=Xt(!1),Wn=hn;function Ar(R,I){var Y=R.type.contextTypes;if(!Y)return hn;var se=R.stateNode;if(se&&se.__reactInternalMemoizedUnmaskedChildContext===I)return se.__reactInternalMemoizedMaskedChildContext;var ye={},Le;for(Le in Y)ye[Le]=I[Le];return se&&(R=R.stateNode,R.__reactInternalMemoizedUnmaskedChildContext=I,R.__reactInternalMemoizedMaskedChildContext=ye),ye}function Un(R){return R=R.childContextTypes,R!=null}function zn(){vn(Re),vn(Tn)}function Nr(R,I,Y){if(Tn.current!==hn)throw Error(a(168));Sn(Tn,I),Sn(Re,Y)}function ii(R,I,Y){var se=R.stateNode;if(I=I.childContextTypes,typeof se.getChildContext!="function")return Y;se=se.getChildContext();for(var ye in se)if(!(ye in I))throw Error(a(108,O(R)||"Unknown",ye));return s({},Y,se)}function Kr(R){return R=(R=R.stateNode)&&R.__reactInternalMemoizedMergedChildContext||hn,Wn=Tn.current,Sn(Tn,R),Sn(Re,Re.current),!0}function Ir(R,I,Y){var se=R.stateNode;if(!se)throw Error(a(169));Y?(R=ii(R,I,Wn),se.__reactInternalMemoizedMergedChildContext=R,vn(Re),vn(Tn),Sn(Tn,R)):vn(Re),Sn(Re,Y)}var In=Math.clz32?Math.clz32:Ai,Ri=Math.log,sr=Math.LN2;function Ai(R){return R>>>=0,R===0?32:31-(Ri(R)/sr|0)|0}var fs=64,Ki=4194304;function js(R){switch(R&-R){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: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 R&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return R&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return R}}function oi(R,I){var Y=R.pendingLanes;if(Y===0)return 0;var se=0,ye=R.suspendedLanes,Le=R.pingedLanes,gt=Y&268435455;if(gt!==0){var $t=gt&~ye;$t!==0?se=js($t):(Le&=gt,Le!==0&&(se=js(Le)))}else gt=Y&~ye,gt!==0?se=js(gt):Le!==0&&(se=js(Le));if(se===0)return 0;if(I!==0&&I!==se&&!(I&ye)&&(ye=se&-se,Le=I&-I,ye>=Le||ye===16&&(Le&4194240)!==0))return I;if(se&4&&(se|=Y&16),I=R.entangledLanes,I!==0)for(R=R.entanglements,I&=se;0Y;Y++)I.push(R);return I}function Sa(R,I,Y){R.pendingLanes|=I,I!==536870912&&(R.suspendedLanes=0,R.pingedLanes=0),R=R.eventTimes,I=31-In(I),R[I]=Y}function Fa(R,I){var Y=R.pendingLanes&~I;R.pendingLanes=I,R.suspendedLanes=0,R.pingedLanes=0,R.expiredLanes&=I,R.mutableReadLanes&=I,R.entangledLanes&=I,I=R.entanglements;var se=R.eventTimes;for(R=R.expirationTimes;0>=gt,ye-=gt,Jo=1<<32-In(I)+ye|Y<Vs?(Lc=Si,Si=null):Lc=Si.sibling;var qs=Xr(an,Si,dn[Vs],cr);if(qs===null){Si===null&&(Si=Lc);break}R&&Si&&qs.alternate===null&&I(an,Si),Zt=Le(qs,Zt,Vs),Oi===null?Mr=qs:Oi.sibling=qs,Oi=qs,Si=Lc}if(Vs===dn.length)return Y(an,Si),$r&&Li(an,Vs),Mr;if(Si===null){for(;VsVs?(Lc=Si,Si=null):Lc=Si.sibling;var p1=Xr(an,Si,qs.value,cr);if(p1===null){Si===null&&(Si=Lc);break}R&&Si&&p1.alternate===null&&I(an,Si),Zt=Le(p1,Zt,Vs),Oi===null?Mr=p1:Oi.sibling=p1,Oi=p1,Si=Lc}if(qs.done)return Y(an,Si),$r&&Li(an,Vs),Mr;if(Si===null){for(;!qs.done;Vs++,qs=dn.next())qs=wi(an,qs.value,cr),qs!==null&&(Zt=Le(qs,Zt,Vs),Oi===null?Mr=qs:Oi.sibling=qs,Oi=qs);return $r&&Li(an,Vs),Mr}for(Si=se(an,Si);!qs.done;Vs++,qs=dn.next())qs=Pa(Si,an,Vs,qs.value,cr),qs!==null&&(R&&qs.alternate!==null&&Si.delete(qs.key===null?Vs:qs.key),Zt=Le(qs,Zt,Vs),Oi===null?Mr=qs:Oi.sibling=qs,Oi=qs);return R&&Si.forEach(function(Q4e){return I(an,Q4e)}),$r&&Li(an,Vs),Mr}function Sf(an,Zt,dn,cr){if(typeof dn=="object"&&dn!==null&&dn.type===u&&dn.key===null&&(dn=dn.props.children),typeof dn=="object"&&dn!==null){switch(dn.$$typeof){case l:e:{for(var Mr=dn.key,Oi=Zt;Oi!==null;){if(Oi.key===Mr){if(Mr=dn.type,Mr===u){if(Oi.tag===7){Y(an,Oi.sibling),Zt=ye(Oi,dn.props.children),Zt.return=an,an=Zt;break e}}else if(Oi.elementType===Mr||typeof Mr=="object"&&Mr!==null&&Mr.$$typeof===C&&mo(Mr)===Oi.type){Y(an,Oi.sibling),Zt=ye(Oi,dn.props),Zt.ref=Sc(an,Oi,dn),Zt.return=an,an=Zt;break e}Y(an,Oi);break}else I(an,Oi);Oi=Oi.sibling}dn.type===u?(Zt=T2(dn.props.children,an.mode,cr,dn.key),Zt.return=an,an=Zt):(cr=k6(dn.type,dn.key,dn.props,null,an.mode,cr),cr.ref=Sc(an,Zt,dn),cr.return=an,an=cr)}return gt(an);case c:e:{for(Oi=dn.key;Zt!==null;){if(Zt.key===Oi)if(Zt.tag===4&&Zt.stateNode.containerInfo===dn.containerInfo&&Zt.stateNode.implementation===dn.implementation){Y(an,Zt.sibling),Zt=ye(Zt,dn.children||[]),Zt.return=an,an=Zt;break e}else{Y(an,Zt);break}else I(an,Zt);Zt=Zt.sibling}Zt=uL(dn,an.mode,cr),Zt.return=an,an=Zt}return gt(an);case C:return Oi=dn._init,Sf(an,Zt,Oi(dn._payload),cr)}if(J(dn))return Lr(an,Zt,dn,cr);if(U(dn))return ku(an,Zt,dn,cr);ec(an,dn)}return typeof dn=="string"&&dn!==""||typeof dn=="number"?(dn=""+dn,Zt!==null&&Zt.tag===6?(Y(an,Zt.sibling),Zt=ye(Zt,dn),Zt.return=an,an=Zt):(Y(an,Zt),Zt=cL(dn,an.mode,cr),Zt.return=an,an=Zt),gt(an)):Y(an,Zt)}return Sf}var Ma=fd(!0),Ui=fd(!1),bl={},ys=Xt(bl),nl=Xt(bl),_l=Xt(bl);function Ro(R){if(R===bl)throw Error(a(174));return R}function pd(R,I){Sn(_l,I),Sn(nl,R),Sn(ys,bl),R=ae(I),vn(ys),Sn(ys,R)}function zl(){vn(ys),vn(nl),vn(_l)}function rl(R){var I=Ro(_l.current),Y=Ro(ys.current);I=Q(Y,R.type,I),Y!==I&&(Sn(nl,R),Sn(ys,I))}function Tc(R){nl.current===R&&(vn(ys),vn(nl))}var Hi=Xt(0);function tc(R){for(var I=R;I!==null;){if(I.tag===13){var Y=I.memoizedState;if(Y!==null&&(Y=Y.dehydrated,Y===null||nn(Y)||Nt(Y)))return I}else if(I.tag===19&&I.memoizedProps.revealOrder!==void 0){if(I.flags&128)return I}else if(I.child!==null){I.child.return=I,I=I.child;continue}if(I===R)break;for(;I.sibling===null;){if(I.return===null||I.return===R)return null;I=I.return}I.sibling.return=I.return,I=I.sibling}return null}var Eu=[];function Zc(){for(var R=0;RY?Y:4,R(!0);var se=da.transition;da.transition={};try{R(!1),I()}finally{nr=Y,da.transition=se}}function he(){return il().memoizedState}function Me(R,I,Y){var se=_f(R);Y={lane:se,action:Y,hasEagerState:!1,eagerState:null,next:null},Mt(R)?Jt(I,Y):(rn(R,I,Y),Y=Gl(),R=Pc(R,se,Y),R!==null&&_n(R,I,se))}function He(R,I,Y){var se=_f(R),ye={lane:se,action:Y,hasEagerState:!1,eagerState:null,next:null};if(Mt(R))Jt(I,ye);else{rn(R,I,ye);var Le=R.alternate;if(R.lanes===0&&(Le===null||Le.lanes===0)&&(Le=I.lastRenderedReducer,Le!==null))try{var gt=I.lastRenderedState,$t=Le(gt,Y);if(ye.hasEagerState=!0,ye.eagerState=$t,Hs($t,gt))return}catch{}finally{}Y=Gl(),R=Pc(R,se,Y),R!==null&&_n(R,I,se)}}function Mt(R){var I=R.alternate;return R===Br||I!==null&&I===Br}function Jt(R,I){Nu=wl=!0;var Y=R.pending;Y===null?I.next=I:(I.next=Y.next,Y.next=I),R.pending=I}function rn(R,I,Y){_s!==null&&R.mode&1&&!(Fr&2)?(R=I.interleaved,R===null?(Y.next=Y,Oe===null?Oe=[I]:Oe.push(I)):(Y.next=R.next,R.next=Y),I.interleaved=Y):(R=I.pending,R===null?Y.next=Y:(Y.next=R.next,R.next=Y),I.pending=Y)}function _n(R,I,Y){if(Y&4194240){var se=I.lanes;se&=R.pendingLanes,Y|=se,I.lanes=Y,Wo(R,Y)}}var Xn={readContext:ce,useCallback:go,useContext:go,useEffect:go,useImperativeHandle:go,useInsertionEffect:go,useLayoutEffect:go,useMemo:go,useReducer:go,useRef:go,useState:go,useDebugValue:go,useDeferredValue:go,useTransition:go,useMutableSource:go,useSyncExternalStore:go,useId:go,unstable_isNewReconciler:!1},wr={readContext:ce,useCallback:function(R,I){return Ao().memoizedState=[R,I===void 0?null:I],R},useContext:ce,useEffect:Sh,useImperativeHandle:function(R,I,Y){return Y=Y!=null?Y.concat([R]):null,Gd(4194308,4,h0.bind(null,I,R),Y)},useLayoutEffect:function(R,I){return Gd(4194308,4,R,I)},useInsertionEffect:function(R,I){return Gd(4,2,R,I)},useMemo:function(R,I){var Y=Ao();return I=I===void 0?null:I,R=R(),Y.memoizedState=[R,I],R},useReducer:function(R,I,Y){var se=Ao();return I=Y!==void 0?Y(I):I,se.memoizedState=se.baseState=I,R={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:R,lastRenderedState:I},se.queue=R,R=R.dispatch=Me.bind(null,Br,R),[se.memoizedState,R]},useRef:function(R){var I=Ao();return R={current:R},I.memoizedState=R},useState:sl,useDebugValue:ko,useDeferredValue:function(R){var I=sl(R),Y=I[0],se=I[1];return Sh(function(){var ye=da.transition;da.transition={};try{se(R)}finally{da.transition=ye}},[R]),Y},useTransition:function(){var R=sl(!1),I=R[0];return R=X.bind(null,R[1]),Ao().memoizedState=R,[I,R]},useMutableSource:function(){},useSyncExternalStore:function(R,I,Y){var se=Br,ye=Ao();if($r){if(Y===void 0)throw Error(a(407));Y=Y()}else{if(Y=I(),_s===null)throw Error(a(349));ts&30||Cu(se,I,Y)}ye.memoizedState=Y;var Le={value:Y,getSnapshot:I};return ye.queue=Le,Sh(wh.bind(null,se,Le,R),[R]),se.flags|=2048,Lo(9,cp.bind(null,se,Le,Y,I),void 0,null),Y},useId:function(){var R=Ao(),I=_s.identifierPrefix;if($r){var Y=Bl,se=Jo;Y=(se&~(1<<32-In(se)-1)).toString(32)+Y,I=":"+I+"R"+Y,Y=Ua++,0Rm&&(I.flags|=128,se=!0,pn(ye,!1),I.lanes=4194304)}else{if(!se)if(R=tc(Le),R!==null){if(I.flags|=128,se=!0,R=R.updateQueue,R!==null&&(I.updateQueue=R,I.flags|=4),pn(ye,!0),ye.tail===null&&ye.tailMode==="hidden"&&!Le.alternate&&!$r)return xn(I),null}else 2*Es()-ye.renderingStartTime>Rm&&Y!==1073741824&&(I.flags|=128,se=!0,pn(ye,!1),I.lanes=4194304);ye.isBackwards?(Le.sibling=I.child,I.child=Le):(R=ye.last,R!==null?R.sibling=Le:I.child=Le,ye.last=Le)}return ye.tail!==null?(I=ye.tail,ye.rendering=I,ye.tail=I.sibling,ye.renderingStartTime=Es(),I.sibling=null,R=Hi.current,Sn(Hi,se?R&1|2:R&1),I):(xn(I),null);case 22:case 23:return vy(),se=I.memoizedState!==null,R!==null&&R.memoizedState!==null!==se&&(I.flags|=8192),se&&I.mode&1?Ca&1073741824&&(xn(I),Qe&&I.subtreeFlags&6&&(I.flags|=8192)):xn(I),null;case 24:return null;case 25:return null}throw Error(a(156,I.tag))}var fy=o.ReactCurrentOwner,Io=!1;function eo(R,I,Y,se){I.child=R===null?Ui(I,null,Y,se):Ma(I,R.child,Y,se)}function ql(R,I,Y,se,ye){Y=Y.render;var Le=I.ref;return vs(I,ye),se=md(R,I,Y,se,Le,ye),Y=lp(),R!==null&&!Io?(I.updateQueue=R.updateQueue,I.flags&=-2053,R.lanes&=~ye,te(R,I,ye)):($r&&Y&&yl(I),I.flags|=1,eo(R,I,se,ye),I.child)}function fp(R,I,Y,se,ye){if(R===null){var Le=Y.type;return typeof Le=="function"&&!lL(Le)&&Le.defaultProps===void 0&&Y.compare===null&&Y.defaultProps===void 0?(I.tag=15,I.type=Le,Eh(R,I,Le,se,ye)):(R=k6(Y.type,null,se,I,I.mode,ye),R.ref=I.ref,R.return=I,I.child=R)}if(Le=R.child,!(R.lanes&ye)){var gt=Le.memoizedProps;if(Y=Y.compare,Y=Y!==null?Y:Wc,Y(gt,se)&&R.ref===I.ref)return te(R,I,ye)}return I.flags|=1,R=f1(Le,se),R.ref=I.ref,R.return=I,I.child=R}function Eh(R,I,Y,se,ye){if(R!==null&&Wc(R.memoizedProps,se)&&R.ref===I.ref)if(Io=!1,(R.lanes&ye)!==0)R.flags&131072&&(Io=!0);else return I.lanes=R.lanes,te(R,I,ye);return p2(R,I,Y,se,ye)}function l1(R,I,Y){var se=I.pendingProps,ye=se.children,Le=R!==null?R.memoizedState:null;if(se.mode==="hidden")if(!(I.mode&1))I.memoizedState={baseLanes:0,cachePool:null},Sn(Ps,Ca),Ca|=Y;else if(Y&1073741824)I.memoizedState={baseLanes:0,cachePool:null},se=Le!==null?Le.baseLanes:Y,Sn(Ps,Ca),Ca|=se;else return R=Le!==null?Le.baseLanes|Y:Y,I.lanes=I.childLanes=1073741824,I.memoizedState={baseLanes:R,cachePool:null},I.updateQueue=null,Sn(Ps,Ca),Ca|=R,null;else Le!==null?(se=Le.baseLanes|Y,I.memoizedState=null):se=Y,Sn(Ps,Ca),Ca|=se;return eo(R,I,ye,Y),I.child}function Nh(R,I){var Y=I.ref;(R===null&&Y!==null||R!==null&&R.ref!==Y)&&(I.flags|=512,I.flags|=2097152)}function p2(R,I,Y,se,ye){var Le=Un(Y)?Wn:Tn.current;return Le=Ar(I,Le),vs(I,ye),Y=md(R,I,Y,se,Le,ye),se=lp(),R!==null&&!Io?(I.updateQueue=R.updateQueue,I.flags&=-2053,R.lanes&=~ye,te(R,I,ye)):($r&&se&&yl(I),I.flags|=1,eo(R,I,Y,ye),I.child)}function py(R,I,Y,se,ye){if(Un(Y)){var Le=!0;Kr(I)}else Le=!1;if(vs(I,ye),I.stateNode===null)R!==null&&(R.alternate=null,I.alternate=null,I.flags|=2),Ns(I,Y,se),Bi(I,Y,se,ye),se=!0;else if(R===null){var gt=I.stateNode,$t=I.memoizedProps;gt.props=$t;var mn=gt.context,qn=Y.contextType;typeof qn=="object"&&qn!==null?qn=ce(qn):(qn=Un(Y)?Wn:Tn.current,qn=Ar(I,qn));var br=Y.getDerivedStateFromProps,wi=typeof br=="function"||typeof gt.getSnapshotBeforeUpdate=="function";wi||typeof gt.UNSAFE_componentWillReceiveProps!="function"&&typeof gt.componentWillReceiveProps!="function"||($t!==se||mn!==qn)&&ps(I,gt,se,qn),at=!1;var Xr=I.memoizedState;gt.state=Xr,Dr(I,se,gt,ye),mn=I.memoizedState,$t!==se||Xr!==mn||Re.current||at?(typeof br=="function"&&(sa(I,Y,br,se),mn=I.memoizedState),($t=at||Fi(I,Y,$t,se,Xr,mn,qn))?(wi||typeof gt.UNSAFE_componentWillMount!="function"&&typeof gt.componentWillMount!="function"||(typeof gt.componentWillMount=="function"&>.componentWillMount(),typeof gt.UNSAFE_componentWillMount=="function"&>.UNSAFE_componentWillMount()),typeof gt.componentDidMount=="function"&&(I.flags|=4194308)):(typeof gt.componentDidMount=="function"&&(I.flags|=4194308),I.memoizedProps=se,I.memoizedState=mn),gt.props=se,gt.state=mn,gt.context=qn,se=$t):(typeof gt.componentDidMount=="function"&&(I.flags|=4194308),se=!1)}else{gt=I.stateNode,qt(R,I),$t=I.memoizedProps,qn=I.type===I.elementType?$t:ca(I.type,$t),gt.props=qn,wi=I.pendingProps,Xr=gt.context,mn=Y.contextType,typeof mn=="object"&&mn!==null?mn=ce(mn):(mn=Un(Y)?Wn:Tn.current,mn=Ar(I,mn));var Pa=Y.getDerivedStateFromProps;(br=typeof Pa=="function"||typeof gt.getSnapshotBeforeUpdate=="function")||typeof gt.UNSAFE_componentWillReceiveProps!="function"&&typeof gt.componentWillReceiveProps!="function"||($t!==wi||Xr!==mn)&&ps(I,gt,se,mn),at=!1,Xr=I.memoizedState,gt.state=Xr,Dr(I,se,gt,ye);var Lr=I.memoizedState;$t!==wi||Xr!==Lr||Re.current||at?(typeof Pa=="function"&&(sa(I,Y,Pa,se),Lr=I.memoizedState),(qn=at||Fi(I,Y,qn,se,Xr,Lr,mn)||!1)?(br||typeof gt.UNSAFE_componentWillUpdate!="function"&&typeof gt.componentWillUpdate!="function"||(typeof gt.componentWillUpdate=="function"&>.componentWillUpdate(se,Lr,mn),typeof gt.UNSAFE_componentWillUpdate=="function"&>.UNSAFE_componentWillUpdate(se,Lr,mn)),typeof gt.componentDidUpdate=="function"&&(I.flags|=4),typeof gt.getSnapshotBeforeUpdate=="function"&&(I.flags|=1024)):(typeof gt.componentDidUpdate!="function"||$t===R.memoizedProps&&Xr===R.memoizedState||(I.flags|=4),typeof gt.getSnapshotBeforeUpdate!="function"||$t===R.memoizedProps&&Xr===R.memoizedState||(I.flags|=1024),I.memoizedProps=se,I.memoizedState=Lr),gt.props=se,gt.state=Lr,gt.context=mn,se=qn):(typeof gt.componentDidUpdate!="function"||$t===R.memoizedProps&&Xr===R.memoizedState||(I.flags|=4),typeof gt.getSnapshotBeforeUpdate!="function"||$t===R.memoizedProps&&Xr===R.memoizedState||(I.flags|=1024),se=!1)}return Hd(R,I,Y,se,Le,ye)}function Hd(R,I,Y,se,ye,Le){Nh(R,I);var gt=(I.flags&128)!==0;if(!se&&!gt)return ye&&Ir(I,Y,!1),te(R,I,Le);se=I.stateNode,fy.current=I;var $t=gt&&typeof Y.getDerivedStateFromError!="function"?null:se.render();return I.flags|=1,R!==null&>?(I.child=Ma(I,R.child,null,Le),I.child=Ma(I,null,$t,Le)):eo(R,I,$t,Le),I.memoizedState=se.state,ye&&Ir(I,Y,!0),I.child}function A(R){var I=R.stateNode;I.pendingContext?Nr(R,I.pendingContext,I.pendingContext!==I.context):I.context&&Nr(R,I.context,!1),pd(R,I.containerInfo)}function w(R,I,Y,se,ye){return Ys(),tl(ye),I.flags|=256,eo(R,I,Y,se),I.child}var S={dehydrated:null,treeContext:null,retryLane:0};function N(R){return{baseLanes:R,cachePool:null}}function E(R,I,Y){var se=I.pendingProps,ye=Hi.current,Le=!1,gt=(I.flags&128)!==0,$t;if(($t=gt)||($t=R!==null&&R.memoizedState===null?!1:(ye&2)!==0),$t?(Le=!0,I.flags&=-129):(R===null||R.memoizedState!==null)&&(ye|=1),Sn(Hi,ye&1),R===null)return Yc(I),R=I.memoizedState,R!==null&&(R=R.dehydrated,R!==null)?(I.mode&1?Nt(R)?I.lanes=8:I.lanes=1073741824:I.lanes=1,null):(ye=se.children,R=se.fallback,Le?(se=I.mode,Le=I.child,ye={mode:"hidden",children:ye},!(se&1)&&Le!==null?(Le.childLanes=0,Le.pendingProps=ye):Le=I6(ye,se,0,null),R=T2(R,se,Y,null),Le.return=I,R.return=I,Le.sibling=R,I.child=Le,I.child.memoizedState=N(Y),I.memoizedState=S,R):P(I,ye));if(ye=R.memoizedState,ye!==null){if($t=ye.dehydrated,$t!==null){if(gt)return I.flags&256?(I.flags&=-257,T(R,I,Y,Error(a(422)))):I.memoizedState!==null?(I.child=R.child,I.flags|=128,null):(Le=se.fallback,ye=I.mode,se=I6({mode:"visible",children:se.children},ye,0,null),Le=T2(Le,ye,Y,null),Le.flags|=2,se.return=I,Le.return=I,se.sibling=Le,I.child=se,I.mode&1&&Ma(I,R.child,null,Y),I.child.memoizedState=N(Y),I.memoizedState=S,Le);if(!(I.mode&1))I=T(R,I,Y,null);else if(Nt($t))I=T(R,I,Y,Error(a(419)));else if(se=(Y&R.childLanes)!==0,Io||se){if(se=_s,se!==null){switch(Y&-Y){case 4:Le=2;break;case 16:Le=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:Le=32;break;case 536870912:Le=268435456;break;default:Le=0}se=Le&(se.suspendedLanes|Y)?0:Le,se!==0&&se!==ye.retryLane&&(ye.retryLane=se,Pc(R,se,-1))}tw(),I=T(R,I,Y,Error(a(421)))}else nn($t)?(I.flags|=128,I.child=R.child,I=nw.bind(null,R),m($t,I),I=null):(Y=ye.treeContext,bt&&(Ms=Rn($t),ms=I,$r=!0,Na=null,wc=!1,Y!==null&&(Ba[Ja++]=Jo,Ba[Ja++]=Bl,Ba[Ja++]=vl,Jo=Y.id,Bl=Y.overflow,vl=I)),I=P(I,I.pendingProps.children),I.flags|=4096);return I}return Le?(se=v(R,I,se.children,se.fallback,Y),Le=I.child,ye=R.child.memoizedState,Le.memoizedState=ye===null?N(Y):{baseLanes:ye.baseLanes|Y,cachePool:null},Le.childLanes=R.childLanes&~Y,I.memoizedState=S,se):(Y=D(R,I,se.children,Y),I.memoizedState=null,Y)}return Le?(se=v(R,I,se.children,se.fallback,Y),Le=I.child,ye=R.child.memoizedState,Le.memoizedState=ye===null?N(Y):{baseLanes:ye.baseLanes|Y,cachePool:null},Le.childLanes=R.childLanes&~Y,I.memoizedState=S,se):(Y=D(R,I,se.children,Y),I.memoizedState=null,Y)}function P(R,I){return I=I6({mode:"visible",children:I},R.mode,0,null),I.return=R,R.child=I}function D(R,I,Y,se){var ye=R.child;return R=ye.sibling,Y=f1(ye,{mode:"visible",children:Y}),!(I.mode&1)&&(Y.lanes=se),Y.return=I,Y.sibling=null,R!==null&&(se=I.deletions,se===null?(I.deletions=[R],I.flags|=16):se.push(R)),I.child=Y}function v(R,I,Y,se,ye){var Le=I.mode;R=R.child;var gt=R.sibling,$t={mode:"hidden",children:Y};return!(Le&1)&&I.child!==R?(Y=I.child,Y.childLanes=0,Y.pendingProps=$t,I.deletions=null):(Y=f1(R,$t),Y.subtreeFlags=R.subtreeFlags&14680064),gt!==null?se=f1(gt,se):(se=T2(se,Le,ye,null),se.flags|=2),se.return=I,Y.return=I,Y.sibling=se,I.child=Y,se}function T(R,I,Y,se){return se!==null&&tl(se),Ma(I,R.child,null,Y),R=P(I,I.pendingProps.children),R.flags|=2,I.memoizedState=null,R}function j(R,I,Y){R.lanes|=I;var se=R.alternate;se!==null&&(se.lanes|=I),Ws(R.return,I,Y)}function q(R,I,Y,se,ye){var Le=R.memoizedState;Le===null?R.memoizedState={isBackwards:I,rendering:null,renderingStartTime:0,last:se,tail:Y,tailMode:ye}:(Le.isBackwards=I,Le.rendering=null,Le.renderingStartTime=0,Le.last=se,Le.tail=Y,Le.tailMode=ye)}function Z(R,I,Y){var se=I.pendingProps,ye=se.revealOrder,Le=se.tail;if(eo(R,I,se.children,Y),se=Hi.current,se&2)se=se&1|2,I.flags|=128;else{if(R!==null&&R.flags&128)e:for(R=I.child;R!==null;){if(R.tag===13)R.memoizedState!==null&&j(R,Y,I);else if(R.tag===19)j(R,Y,I);else if(R.child!==null){R.child.return=R,R=R.child;continue}if(R===I)break e;for(;R.sibling===null;){if(R.return===null||R.return===I)break e;R=R.return}R.sibling.return=R.return,R=R.sibling}se&=1}if(Sn(Hi,se),!(I.mode&1))I.memoizedState=null;else switch(ye){case"forwards":for(Y=I.child,ye=null;Y!==null;)R=Y.alternate,R!==null&&tc(R)===null&&(ye=Y),Y=Y.sibling;Y=ye,Y===null?(ye=I.child,I.child=null):(ye=Y.sibling,Y.sibling=null),q(I,!1,ye,Y,Le);break;case"backwards":for(Y=null,ye=I.child,I.child=null;ye!==null;){if(R=ye.alternate,R!==null&&tc(R)===null){I.child=ye;break}R=ye.sibling,ye.sibling=Y,Y=ye,ye=R}q(I,!0,Y,null,Le);break;case"together":q(I,!1,null,null,void 0);break;default:I.memoizedState=null}return I.child}function te(R,I,Y){if(R!==null&&(I.dependencies=R.dependencies),Wd|=I.lanes,!(Y&I.childLanes))return null;if(R!==null&&I.child!==R.child)throw Error(a(153));if(I.child!==null){for(R=I.child,Y=f1(R,R.pendingProps),I.child=Y,Y.return=I;R.sibling!==null;)R=R.sibling,Y=Y.sibling=f1(R,R.pendingProps),Y.return=I;Y.sibling=null}return I.child}function ne(R,I,Y){switch(I.tag){case 3:A(I),Ys();break;case 5:rl(I);break;case 1:Un(I.type)&&Kr(I);break;case 4:pd(I,I.stateNode.containerInfo);break;case 10:qd(I,I.type._context,I.memoizedProps.value);break;case 13:var se=I.memoizedState;if(se!==null)return se.dehydrated!==null?(Sn(Hi,Hi.current&1),I.flags|=128,null):Y&I.child.childLanes?E(R,I,Y):(Sn(Hi,Hi.current&1),R=te(R,I,Y),R!==null?R.sibling:null);Sn(Hi,Hi.current&1);break;case 19:if(se=(Y&I.childLanes)!==0,R.flags&128){if(se)return Z(R,I,Y);I.flags|=128}var ye=I.memoizedState;if(ye!==null&&(ye.rendering=null,ye.tail=null,ye.lastEffect=null),Sn(Hi,Hi.current),se)break;return null;case 22:case 23:return I.lanes=0,l1(R,I,Y)}return te(R,I,Y)}function le(R,I){switch(Co(I),I.tag){case 1:return Un(I.type)&&zn(),R=I.flags,R&65536?(I.flags=R&-65537|128,I):null;case 3:return zl(),vn(Re),vn(Tn),Zc(),R=I.flags,R&65536&&!(R&128)?(I.flags=R&-65537|128,I):null;case 5:return Tc(I),null;case 13:if(vn(Hi),R=I.memoizedState,R!==null&&R.dehydrated!==null){if(I.alternate===null)throw Error(a(340));Ys()}return R=I.flags,R&65536?(I.flags=R&-65537|128,I):null;case 19:return vn(Hi),null;case 4:return zl(),null;case 10:return Ea(I.type._context),null;case 22:case 23:return vy(),null;case 24:return null;default:return null}}var xe=!1,Ee=!1,Ue=typeof WeakSet=="function"?WeakSet:Set,we=null;function ke(R,I){var Y=R.ref;if(Y!==null)if(typeof Y=="function")try{Y(null)}catch(se){Rc(R,I,se)}else Y.current=null}function je(R,I,Y){try{Y()}catch(se){Rc(R,I,se)}}var Je=!1;function xt(R,I){for(re(R.containerInfo),we=I;we!==null;)if(R=we,I=R.child,(R.subtreeFlags&1028)!==0&&I!==null)I.return=R,we=I;else for(;we!==null;){R=we;try{var Y=R.alternate;if(R.flags&1024)switch(R.tag){case 0:case 11:case 15:break;case 1:if(Y!==null){var se=Y.memoizedProps,ye=Y.memoizedState,Le=R.stateNode,gt=Le.getSnapshotBeforeUpdate(R.elementType===R.type?se:ca(R.type,se),ye);Le.__reactInternalSnapshotBeforeUpdate=gt}break;case 3:Qe&&Be(R.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch($t){Rc(R,R.return,$t)}if(I=R.sibling,I!==null){I.return=R.return,we=I;break}we=R.return}return Y=Je,Je=!1,Y}function Ye(R,I,Y){var se=I.updateQueue;if(se=se!==null?se.lastEffect:null,se!==null){var ye=se=se.next;do{if((ye.tag&R)===R){var Le=ye.destroy;ye.destroy=void 0,Le!==void 0&&je(I,Y,Le)}ye=ye.next}while(ye!==se)}}function Ke(R,I){if(I=I.updateQueue,I=I!==null?I.lastEffect:null,I!==null){var Y=I=I.next;do{if((Y.tag&R)===R){var se=Y.create;Y.destroy=se()}Y=Y.next}while(Y!==I)}}function kt(R){var I=R.ref;if(I!==null){var Y=R.stateNode;switch(R.tag){case 5:R=ie(Y);break;default:R=Y}typeof I=="function"?I(R):I.current=R}}function Rt(R,I,Y){if(Za&&typeof Za.onCommitFiberUnmount=="function")try{Za.onCommitFiberUnmount($c,I)}catch{}switch(I.tag){case 0:case 11:case 14:case 15:if(R=I.updateQueue,R!==null&&(R=R.lastEffect,R!==null)){var se=R=R.next;do{var ye=se,Le=ye.destroy;ye=ye.tag,Le!==void 0&&(ye&2||ye&4)&&je(I,Y,Le),se=se.next}while(se!==R)}break;case 1:if(ke(I,Y),R=I.stateNode,typeof R.componentWillUnmount=="function")try{R.props=I.memoizedProps,R.state=I.memoizedState,R.componentWillUnmount()}catch(gt){Rc(I,Y,gt)}break;case 5:ke(I,Y);break;case 4:Qe?Kn(R,I,Y):ot&&ot&&(I=I.stateNode.containerInfo,Y=rt(I),Bt(I,Y))}}function Wt(R,I,Y){for(var se=I;;)if(Rt(R,se,Y),se.child===null||Qe&&se.tag===4){if(se===I)break;for(;se.sibling===null;){if(se.return===null||se.return===I)return;se=se.return}se.sibling.return=se.return,se=se.sibling}else se.child.return=se,se=se.child}function Kt(R){var I=R.alternate;I!==null&&(R.alternate=null,Kt(I)),R.child=null,R.deletions=null,R.sibling=null,R.tag===5&&(I=R.stateNode,I!==null&&ft(I)),R.stateNode=null,R.return=null,R.dependencies=null,R.memoizedProps=null,R.memoizedState=null,R.pendingProps=null,R.stateNode=null,R.updateQueue=null}function tn(R){return R.tag===5||R.tag===3||R.tag===4}function Zn(R){e:for(;;){for(;R.sibling===null;){if(R.return===null||tn(R.return))return null;R=R.return}for(R.sibling.return=R.return,R=R.sibling;R.tag!==5&&R.tag!==6&&R.tag!==18;){if(R.flags&2||R.child===null||R.tag===4)continue e;R.child.return=R,R=R.child}if(!(R.flags&2))return R.stateNode}}function On(R){if(Qe){e:{for(var I=R.return;I!==null;){if(tn(I))break e;I=I.return}throw Error(a(160))}var Y=I;switch(Y.tag){case 5:I=Y.stateNode,Y.flags&32&&(Pe(I),Y.flags&=-33),Y=Zn(R),fr(R,Y,I);break;case 3:case 4:I=Y.stateNode.containerInfo,Y=Zn(R),Rr(R,Y,I);break;default:throw Error(a(161))}}}function Rr(R,I,Y){var se=R.tag;if(se===5||se===6)R=R.stateNode,I?mt(Y,R,I):We(Y,R);else if(se!==4&&(R=R.child,R!==null))for(Rr(R,I,Y),R=R.sibling;R!==null;)Rr(R,I,Y),R=R.sibling}function fr(R,I,Y){var se=R.tag;if(se===5||se===6)R=R.stateNode,I?dt(Y,R,I):Ve(Y,R);else if(se!==4&&(R=R.child,R!==null))for(fr(R,I,Y),R=R.sibling;R!==null;)fr(R,I,Y),R=R.sibling}function Kn(R,I,Y){for(var se=I,ye=!1,Le,gt;;){if(!ye){ye=se.return;e:for(;;){if(ye===null)throw Error(a(160));switch(Le=ye.stateNode,ye.tag){case 5:gt=!1;break e;case 3:Le=Le.containerInfo,gt=!0;break e;case 4:Le=Le.containerInfo,gt=!0;break e}ye=ye.return}ye=!0}if(se.tag===5||se.tag===6)Wt(R,se,Y),gt?tt(Le,se.stateNode):Ft(Le,se.stateNode);else if(se.tag===18)gt?la(Le,se.stateNode):Os(Le,se.stateNode);else if(se.tag===4){if(se.child!==null){Le=se.stateNode.containerInfo,gt=!0,se.child.return=se,se=se.child;continue}}else if(Rt(R,se,Y),se.child!==null){se.child.return=se,se=se.child;continue}if(se===I)break;for(;se.sibling===null;){if(se.return===null||se.return===I)return;se=se.return,se.tag===4&&(ye=!1)}se.sibling.return=se.return,se=se.sibling}}function Qn(R,I){if(Qe){switch(I.tag){case 0:case 11:case 14:case 15:Ye(3,I,I.return),Ke(3,I),Ye(5,I,I.return);return;case 1:return;case 5:var Y=I.stateNode;if(Y!=null){var se=I.memoizedProps;R=R!==null?R.memoizedProps:se;var ye=I.type,Le=I.updateQueue;I.updateQueue=null,Le!==null&&Ut(Y,Le,ye,R,se,I)}return;case 6:if(I.stateNode===null)throw Error(a(162));Y=I.memoizedProps,ct(I.stateNode,R!==null?R.memoizedProps:Y,Y);return;case 3:bt&&R!==null&&R.memoizedState.isDehydrated&&jr(I.stateNode.containerInfo);return;case 12:return;case 13:kn(I);return;case 19:kn(I);return;case 17:return}throw Error(a(163))}switch(I.tag){case 0:case 11:case 14:case 15:Ye(3,I,I.return),Ke(3,I),Ye(5,I,I.return);return;case 12:return;case 13:kn(I);return;case 19:kn(I);return;case 3:bt&&R!==null&&R.memoizedState.isDehydrated&&jr(I.stateNode.containerInfo);break;case 22:case 23:return}e:if(ot){switch(I.tag){case 1:case 5:case 6:break e;case 3:case 4:I=I.stateNode,Bt(I.containerInfo,I.pendingChildren);break e}throw Error(a(163))}}function kn(R){var I=R.updateQueue;if(I!==null){R.updateQueue=null;var Y=R.stateNode;Y===null&&(Y=R.stateNode=new Ue),I.forEach(function(se){var ye=rw.bind(null,R,se);Y.has(se)||(Y.add(se),se.then(ye,ye))})}}function pi(R,I){for(we=I;we!==null;){I=we;var Y=I.deletions;if(Y!==null)for(var se=0;se";case Vi:return":has("+(Tl(R)||"")+")";case Wr:return'[role="'+R.value+'"]';case $i:return'"'+R.value+'"';case Bs:return'[data-testname="'+R.value+'"]';default:throw Error(a(365))}}function $d(R,I){var Y=[];R=[R,0];for(var se=0;seye&&(ye=gt),se&=~Le}if(se=ye,se=Es()-se,se=(120>se?120:480>se?480:1080>se?1080:1920>se?1920:3e3>se?3e3:4320>se?4320:1960*Pu(se/1960))-se,10R?16:R,mp===null)var se=!1;else{if(R=mp,mp=null,Ay=0,Fr&6)throw Error(a(331));var ye=Fr;for(Fr|=4,we=R.current;we!==null;){var Le=we,gt=Le.child;if(we.flags&16){var $t=Le.deletions;if($t!==null){for(var mn=0;mn<$t.length;mn++){var qn=$t[mn];for(we=qn;we!==null;){var br=we;switch(br.tag){case 0:case 11:case 15:Ye(8,br,Le)}var wi=br.child;if(wi!==null)wi.return=br,we=wi;else for(;we!==null;){br=we;var Xr=br.sibling,Pa=br.return;if(Kt(br),br===qn){we=null;break}if(Xr!==null){Xr.return=Pa,we=Xr;break}we=Pa}}}var Lr=Le.alternate;if(Lr!==null){var ku=Lr.child;if(ku!==null){Lr.child=null;do{var Sf=ku.sibling;ku.sibling=null,ku=Sf}while(ku!==null)}}we=Le}}if(Le.subtreeFlags&2064&>!==null)gt.return=Le,we=gt;else e:for(;we!==null;){if(Le=we,Le.flags&2048)switch(Le.tag){case 0:case 11:case 15:Ye(9,Le,Le.return)}var an=Le.sibling;if(an!==null){an.return=Le.return,we=an;break e}we=Le.return}}var Zt=R.current;for(we=Zt;we!==null;){gt=we;var dn=gt.child;if(gt.subtreeFlags&2064&&dn!==null)dn.return=gt,we=dn;else e:for(gt=Zt;we!==null;){if($t=we,$t.flags&2048)try{switch($t.tag){case 0:case 11:case 15:Ke(9,$t)}}catch(Mr){Rc($t,$t.return,Mr)}if($t===gt){we=null;break e}var cr=$t.sibling;if(cr!==null){cr.return=$t.return,we=cr;break e}we=$t.return}}if(Fr=ye,Qa(),Za&&typeof Za.onPostCommitFiberRoot=="function")try{Za.onPostCommitFiberRoot($c,R)}catch{}se=!0}return se}finally{nr=Y,As.transition=I}}return!1}function S2(R,I,Y){I=yn(Y,I),I=Th(R,I,1),gn(R,I),I=Gl(),R=x2(R,1),R!==null&&(Sa(R,1,I),Ru(R,I))}function Rc(R,I,Y){if(R.tag===3)S2(R,R,Y);else for(;I!==null;){if(I.tag===3){S2(I,R,Y);break}else if(I.tag===1){var se=I.stateNode;if(typeof I.type.getDerivedStateFromError=="function"||typeof se.componentDidCatch=="function"&&(eu===null||!eu.has(se))){R=yn(Y,R),R=Pm(I,R,1),gn(I,R),R=Gl(),I=x2(I,1),I!==null&&(Sa(I,1,R),Ru(I,R));break}}I=I.return}}function R6(R,I,Y){var se=R.pingCache;se!==null&&se.delete(I),I=Gl(),R.pingedLanes|=R.suspendedLanes&Y,_s===R&&(zs&Y)===Y&&(Rs===4||Rs===3&&(zs&130023424)===zs&&500>Es()-c1?Yd(R,0):El|=Y),Ru(R,I)}function L6(R,I){I===0&&(R.mode&1?(I=Ki,Ki<<=1,!(Ki&130023424)&&(Ki=4194304)):I=1);var Y=Gl();R=x2(R,I),R!==null&&(Sa(R,I,Y),Ru(R,Y))}function nw(R){var I=R.memoizedState,Y=0;I!==null&&(Y=I.retryLane),L6(R,Y)}function rw(R,I){var Y=0;switch(R.tag){case 13:var se=R.stateNode,ye=R.memoizedState;ye!==null&&(Y=ye.retryLane);break;case 19:se=R.stateNode;break;default:throw Error(a(314))}se!==null&&se.delete(I),L6(R,Y)}var VY;VY=function(R,I,Y){if(R!==null)if(R.memoizedProps!==I.pendingProps||Re.current)Io=!0;else{if(!(R.lanes&Y)&&!(I.flags&128))return Io=!1,ne(R,I,Y);Io=!!(R.flags&131072)}else Io=!1,$r&&I.flags&1048576&&Xc(I,_c,I.index);switch(I.lanes=0,I.tag){case 2:var se=I.type;R!==null&&(R.alternate=null,I.alternate=null,I.flags|=2),R=I.pendingProps;var ye=Ar(I,Tn.current);vs(I,Y),ye=md(null,I,se,R,ye,Y);var Le=lp();return I.flags|=1,typeof ye=="object"&&ye!==null&&typeof ye.render=="function"&&ye.$$typeof===void 0?(I.tag=1,I.memoizedState=null,I.updateQueue=null,Un(se)?(Le=!0,Kr(I)):Le=!1,I.memoizedState=ye.state!==null&&ye.state!==void 0?ye.state:null,Et(I),ye.updater=us,I.stateNode=ye,ye._reactInternals=I,Bi(I,se,R,Y),I=Hd(null,I,se,!0,Le,Y)):(I.tag=0,$r&&Le&&yl(I),eo(null,I,ye,Y),I=I.child),I;case 16:se=I.elementType;e:{switch(R!==null&&(R.alternate=null,I.alternate=null,I.flags|=2),R=I.pendingProps,ye=se._init,se=ye(se._payload),I.type=se,ye=I.tag=W4e(se),R=ca(se,R),ye){case 0:I=p2(null,I,se,R,Y);break e;case 1:I=py(null,I,se,R,Y);break e;case 11:I=ql(null,I,se,R,Y);break e;case 14:I=fp(null,I,se,ca(se.type,R),Y);break e}throw Error(a(306,se,""))}return I;case 0:return se=I.type,ye=I.pendingProps,ye=I.elementType===se?ye:ca(se,ye),p2(R,I,se,ye,Y);case 1:return se=I.type,ye=I.pendingProps,ye=I.elementType===se?ye:ca(se,ye),py(R,I,se,ye,Y);case 3:e:{if(A(I),R===null)throw Error(a(387));se=I.pendingProps,Le=I.memoizedState,ye=Le.element,qt(R,I),Dr(I,se,null,Y);var gt=I.memoizedState;if(se=gt.element,bt&&Le.isDehydrated)if(Le={element:se,isDehydrated:!1,cache:gt.cache,transitions:gt.transitions},I.updateQueue.baseState=Le,I.memoizedState=Le,I.flags&256){ye=Error(a(423)),I=w(R,I,se,Y,ye);break e}else if(se!==ye){ye=Error(a(424)),I=w(R,I,se,Y,ye);break e}else for(bt&&(Ms=Ln(I.stateNode.containerInfo),ms=I,$r=!0,Na=null,wc=!1),Y=Ui(I,null,se,Y),I.child=Y;Y;)Y.flags=Y.flags&-3|4096,Y=Y.sibling;else{if(Ys(),se===ye){I=te(R,I,Y);break e}eo(R,I,se,Y)}I=I.child}return I;case 5:return rl(I),R===null&&Yc(I),se=I.type,ye=I.pendingProps,Le=R!==null?R.memoizedProps:null,gt=ye.children,be(se,ye)?gt=null:Le!==null&&be(se,Le)&&(I.flags|=32),Nh(R,I),eo(R,I,gt,Y),I.child;case 6:return R===null&&Yc(I),null;case 13:return E(R,I,Y);case 4:return pd(I,I.stateNode.containerInfo),se=I.pendingProps,R===null?I.child=Ma(I,null,se,Y):eo(R,I,se,Y),I.child;case 11:return se=I.type,ye=I.pendingProps,ye=I.elementType===se?ye:ca(se,ye),ql(R,I,se,ye,Y);case 7:return eo(R,I,I.pendingProps,Y),I.child;case 8:return eo(R,I,I.pendingProps.children,Y),I.child;case 12:return eo(R,I,I.pendingProps.children,Y),I.child;case 10:e:{if(se=I.type._context,ye=I.pendingProps,Le=I.memoizedProps,gt=ye.value,qd(I,se,gt),Le!==null)if(Hs(Le.value,gt)){if(Le.children===ye.children&&!Re.current){I=te(R,I,Y);break e}}else for(Le=I.child,Le!==null&&(Le.return=I);Le!==null;){var $t=Le.dependencies;if($t!==null){gt=Le.child;for(var mn=$t.firstContext;mn!==null;){if(mn.context===se){if(Le.tag===1){mn=un(-1,Y&-Y),mn.tag=2;var qn=Le.updateQueue;if(qn!==null){qn=qn.shared;var br=qn.pending;br===null?mn.next=mn:(mn.next=br.next,br.next=mn),qn.pending=mn}}Le.lanes|=Y,mn=Le.alternate,mn!==null&&(mn.lanes|=Y),Ws(Le.return,Y,I),$t.lanes|=Y;break}mn=mn.next}}else if(Le.tag===10)gt=Le.type===I.type?null:Le.child;else if(Le.tag===18){if(gt=Le.return,gt===null)throw Error(a(341));gt.lanes|=Y,$t=gt.alternate,$t!==null&&($t.lanes|=Y),Ws(gt,Y,I),gt=Le.sibling}else gt=Le.child;if(gt!==null)gt.return=Le;else for(gt=Le;gt!==null;){if(gt===I){gt=null;break}if(Le=gt.sibling,Le!==null){Le.return=gt.return,gt=Le;break}gt=gt.return}Le=gt}eo(R,I,ye.children,Y),I=I.child}return I;case 9:return ye=I.type,se=I.pendingProps.children,vs(I,Y),ye=ce(ye),se=se(ye),I.flags|=1,eo(R,I,se,Y),I.child;case 14:return se=I.type,ye=ca(se,I.pendingProps),ye=ca(se.type,ye),fp(R,I,se,ye,Y);case 15:return Eh(R,I,I.type,I.pendingProps,Y);case 17:return se=I.type,ye=I.pendingProps,ye=I.elementType===se?ye:ca(se,ye),R!==null&&(R.alternate=null,I.alternate=null,I.flags|=2),I.tag=1,Un(se)?(R=!0,Kr(I)):R=!1,vs(I,Y),Ns(I,se,ye),Bi(I,se,ye,Y),Hd(null,I,se,!0,R,Y);case 19:return Z(R,I,Y);case 22:return l1(R,I,Y)}throw Error(a(156,I.tag))};function qY(R,I){return Xo(R,I)}function $4e(R,I,Y,se){this.tag=R,this.key=Y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=I,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=se,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wf(R,I,Y,se){return new $4e(R,I,Y,se)}function lL(R){return R=R.prototype,!(!R||!R.isReactComponent)}function W4e(R){if(typeof R=="function")return lL(R)?1:0;if(R!=null){if(R=R.$$typeof,R===x)return 11;if(R===M)return 14}return 2}function f1(R,I){var Y=R.alternate;return Y===null?(Y=wf(R.tag,I,R.key,R.mode),Y.elementType=R.elementType,Y.type=R.type,Y.stateNode=R.stateNode,Y.alternate=R,R.alternate=Y):(Y.pendingProps=I,Y.type=R.type,Y.flags=0,Y.subtreeFlags=0,Y.deletions=null),Y.flags=R.flags&14680064,Y.childLanes=R.childLanes,Y.lanes=R.lanes,Y.child=R.child,Y.memoizedProps=R.memoizedProps,Y.memoizedState=R.memoizedState,Y.updateQueue=R.updateQueue,I=R.dependencies,Y.dependencies=I===null?null:{lanes:I.lanes,firstContext:I.firstContext},Y.sibling=R.sibling,Y.index=R.index,Y.ref=R.ref,Y}function k6(R,I,Y,se,ye,Le){var gt=2;if(se=R,typeof R=="function")lL(R)&&(gt=1);else if(typeof R=="string")gt=5;else e:switch(R){case u:return T2(Y.children,ye,Le,I);case d:gt=8,ye|=8;break;case h:return R=wf(12,Y,I,ye|2),R.elementType=h,R.lanes=Le,R;case _:return R=wf(13,Y,I,ye),R.elementType=_,R.lanes=Le,R;case y:return R=wf(19,Y,I,ye),R.elementType=y,R.lanes=Le,R;case k:return I6(Y,ye,Le,I);default:if(typeof R=="object"&&R!==null)switch(R.$$typeof){case p:gt=10;break e;case g:gt=9;break e;case x:gt=11;break e;case M:gt=14;break e;case C:gt=16,se=null;break e}throw Error(a(130,R==null?R:typeof R,""))}return I=wf(gt,Y,I,ye),I.elementType=R,I.type=se,I.lanes=Le,I}function T2(R,I,Y,se){return R=wf(7,R,se,I),R.lanes=Y,R}function I6(R,I,Y,se){return R=wf(22,R,se,I),R.elementType=k,R.lanes=Y,R.stateNode={},R}function cL(R,I,Y){return R=wf(6,R,null,I),R.lanes=Y,R}function uL(R,I,Y){return I=wf(4,R.children!==null?R.children:[],R.key,I),I.lanes=Y,I.stateNode={containerInfo:R.containerInfo,pendingChildren:null,implementation:R.implementation},I}function X4e(R,I,Y,se,ye){this.tag=I,this.containerInfo=R,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=ze,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ji(0),this.expirationTimes=Ji(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ji(0),this.identifierPrefix=se,this.onRecoverableError=ye,bt&&(this.mutableSourceEagerHydrationData=null)}function GY(R,I,Y,se,ye,Le,gt,$t,mn){return R=new X4e(R,I,Y,$t,mn),I===1?(I=1,Le===!0&&(I|=8)):I=0,Le=wf(3,null,null,I),R.current=Le,Le.stateNode=R,Le.memoizedState={element:se,isDehydrated:Y,cache:null,transitions:null},Et(Le),R}function HY(R){if(!R)return hn;R=R._reactInternals;e:{if(V(R)!==R||R.tag!==1)throw Error(a(170));var I=R;do{switch(I.tag){case 3:I=I.stateNode.context;break e;case 1:if(Un(I.type)){I=I.stateNode.__reactInternalMemoizedMergedChildContext;break e}}I=I.return}while(I!==null);throw Error(a(171))}if(R.tag===1){var Y=R.type;if(Un(Y))return ii(R,Y,I)}return I}function $Y(R){var I=R._reactInternals;if(I===void 0)throw typeof R.render=="function"?Error(a(188)):(R=Object.keys(R).join(","),Error(a(268,R)));return R=H(I),R===null?null:R.stateNode}function WY(R,I){if(R=R.memoizedState,R!==null&&R.dehydrated!==null){var Y=R.retryLane;R.retryLane=Y!==0&&Y=qn&&Le>=wi&&ye<=br&><=Xr){R.splice(I,1);break}else if(se!==qn||Y.width!==mn.width||Xrgt){if(!(Le!==wi||Y.height!==mn.height||brye)){qn>se&&(mn.width+=qn-se,mn.x=se),brLe&&(mn.height+=wi-Le,mn.y=Le),XrY&&(Y=gt)),gt ")+` No matching component was found for: `)+R.join(" > ")}return null},t.getPublicRootInstance=function(R){if(R=R.current,!R.child)return null;switch(R.child.tag){case 5:return ie(R.child.stateNode);default:return R.child.stateNode}},t.injectIntoDevTools=function(R){if(R={bundleType:R.bundleType,version:R.version,rendererPackageName:R.rendererPackageName,rendererConfig:R.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:o.ReactCurrentDispatcher,findHostInstanceByFiber:Y4e,findFiberByHostInstance:R.findFiberByHostInstance||Z4e,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")R=!1;else{var I=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(I.isDisabled||!I.supportsFiber)R=!0;else{try{$c=I.inject(R),Za=I}catch{}R=!!I.checkDCE}}return R},t.isAlreadyRendering=function(){return!1},t.observeVisibleRects=function(R,I,Y,se){if(!Lt)throw Error(a(363));R=to(R,I);var ye=ue(R,Y,se).disconnect;return{disconnect:function(){ye()}}},t.registerMutableSourceForHydration=function(R,I){var Y=I._getVersion;Y=Y(I._source),R.mutableSourceEagerHydrationData==null?R.mutableSourceEagerHydrationData=[I,Y]:R.mutableSourceEagerHydrationData.push(I,Y)},t.runWithPriority=function(R,I){var Y=nr;try{return nr=R,I()}finally{nr=Y}},t.shouldError=function(){return null},t.shouldSuspend=function(){return!1},t.updateContainer=function(R,I,Y,se){var ye=I.current,Le=Gl(),gt=_f(ye);return Y=HY(Y),I.context===null?I.context=Y:I.pendingContext=Y,I=un(Le,gt),I.payload={element:R},se=se===void 0?null:se,se!==null&&(I.callback=se),gn(ye,I),R=Pc(ye,gt,Le),R!==null&&dr(R,ye,gt),gt},t};i4e.exports=oyt;var lyt=i4e.exports;const cyt=Vv(lyt);var s4e={exports:{}},a4e={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */(function(n){function e(Q,re){var oe=Q.length;Q.push(re);e:for(;0>>1,ee=Q[fe];if(0>>1;fei(be,oe))pei(ge,be)?(Q[fe]=ge,Q[pe]=oe,fe=pe):(Q[fe]=be,Q[Ae]=oe,fe=Ae);else if(pei(ge,oe))Q[fe]=ge,Q[pe]=oe,fe=pe;else break e}}return re}function i(Q,re){var oe=Q.sortIndex-re.sortIndex;return oe!==0?oe:Q.id-re.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;n.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();n.unstable_now=function(){return a.now()-o}}var l=[],c=[],u=1,d=null,h=3,p=!1,g=!1,x=!1,_=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(Q){for(var re=t(c);re!==null;){if(re.callback===null)r(c);else if(re.startTime<=Q)r(c),re.sortIndex=re.expirationTime,e(l,re);else break;re=t(c)}}function k(Q){if(x=!1,C(Q),!g)if(t(l)!==null)g=!0,ie(B);else{var re=t(c);re!==null&&ae(k,re.startTime-Q)}}function B(Q,re){g=!1,x&&(x=!1,y(O),O=-1),p=!0;var oe=h;try{for(C(re),d=t(l);d!==null&&(!(d.expirationTime>re)||Q&&!G());){var fe=d.callback;if(typeof fe=="function"){d.callback=null,h=d.priorityLevel;var ee=fe(d.expirationTime<=re);re=n.unstable_now(),typeof ee=="function"?d.callback=ee:d===t(l)&&r(l),C(re)}else r(l);d=t(l)}if(d!==null)var me=!0;else{var Ae=t(c);Ae!==null&&ae(k,Ae.startTime-re),me=!1}return me}finally{d=null,h=oe,p=!1}}var U=!1,z=null,O=-1,V=5,$=-1;function G(){return!(n.unstable_now()-$Q||125fe?(Q.sortIndex=oe,e(c,Q),t(l)===null&&Q===t(c)&&(x?(y(O),O=-1):x=!0,ae(k,oe-fe))):(Q.sortIndex=ee,e(l,Q),g||p||(g=!0,ie(B))),Q},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(Q){var re=h;return function(){var oe=h;h=re;try{return Q.apply(this,arguments)}finally{h=oe}}}})(a4e);s4e.exports=a4e;var sde=s4e.exports;const PY={},RY=n=>void Object.assign(PY,n);function uyt(n,e){function t(u,{args:d=[],attach:h,...p},g){let x=`${u[0].toUpperCase()}${u.slice(1)}`,_;if(u==="primitive"){if(p.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const y=p.object;_=Rb(y,{type:u,root:g,attach:h,primitive:!0})}else{const y=PY[x];if(!y)throw new Error(`R3F: ${x} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(d))throw new Error("R3F: The args prop must be an array!");_=Rb(new y(...d),{type:u,root:g,attach:h,memoizedProps:{args:d}})}return _.__r3f.attach===void 0&&(_.isBufferGeometry?_.__r3f.attach="geometry":_.isMaterial&&(_.__r3f.attach="material")),x!=="inject"&&OB(_,p),_}function r(u,d){let h=!1;if(d){var p,g;(p=d.__r3f)!=null&&p.attach?DB(u,d,d.__r3f.attach):d.isObject3D&&u.isObject3D&&(u.add(d),h=!0),h||(g=u.__r3f)==null||g.objects.push(d),d.__r3f||Rb(d,{}),d.__r3f.parent=u,Cq(d),Lb(d)}}function i(u,d,h){let p=!1;if(d){var g,x;if((g=d.__r3f)!=null&&g.attach)DB(u,d,d.__r3f.attach);else if(d.isObject3D&&u.isObject3D){d.parent=u,d.dispatchEvent({type:"added"}),u.dispatchEvent({type:"childadded",child:d});const _=u.children.filter(M=>M!==d),y=_.indexOf(h);u.children=[..._.slice(0,y),d,..._.slice(y)],p=!0}p||(x=u.__r3f)==null||x.objects.push(d),d.__r3f||Rb(d,{}),d.__r3f.parent=u,Cq(d),Lb(d)}}function s(u,d,h=!1){u&&[...u].forEach(p=>a(d,p,h))}function a(u,d,h){if(d){var p,g,x;if(d.__r3f&&(d.__r3f.parent=null),(p=u.__r3f)!=null&&p.objects&&(u.__r3f.objects=u.__r3f.objects.filter(k=>k!==d)),(g=d.__r3f)!=null&&g.attach)ude(u,d,d.__r3f.attach);else if(d.isObject3D&&u.isObject3D){var _;u.remove(d),(_=d.__r3f)!=null&&_.root&&xyt(IN(d),d)}const M=(x=d.__r3f)==null?void 0:x.primitive,C=!M&&(h===void 0?d.dispose!==null:h);if(!M){var y;s((y=d.__r3f)==null?void 0:y.objects,d,C),s(d.children,d,C)}if(delete d.__r3f,C&&d.dispose&&d.type!=="Scene"){const k=()=>{try{d.dispose()}catch{}};typeof IS_REACT_ACT_ENVIRONMENT>"u"?sde.unstable_scheduleCallback(sde.unstable_IdlePriority,k):k()}Lb(u)}}function o(u,d,h,p){var g;const x=(g=u.__r3f)==null?void 0:g.parent;if(!x)return;const _=t(d,h,u.__r3f.root);if(u.children){for(const y of u.children)y.__r3f&&r(_,y);u.children=u.children.filter(y=>!y.__r3f)}u.__r3f.objects.forEach(y=>r(_,y)),u.__r3f.objects=[],u.__r3f.autoRemovedBeforeAppend||a(x,u),_.parent&&(_.__r3f.autoRemovedBeforeAppend=!0),r(x,_),_.raycast&&_.__r3f.eventCount&&IN(_).getState().internal.interaction.push(_),[p,p.alternate].forEach(y=>{y!==null&&(y.stateNode=_,y.ref&&(typeof y.ref=="function"?y.ref(_):y.ref.current=_))})}const l=()=>{};return{reconciler:cyt({createInstance:t,removeChild:a,appendChild:r,appendInitialChild:r,insertBefore:i,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(u,d)=>{if(!d)return;const h=u.getState().scene;h.__r3f&&(h.__r3f.root=u,r(h,d))},removeChildFromContainer:(u,d)=>{d&&a(u.getState().scene,d)},insertInContainerBefore:(u,d,h)=>{if(!d||!h)return;const p=u.getState().scene;p.__r3f&&i(p,d,h)},getRootHostContext:()=>null,getChildHostContext:u=>u,finalizeInitialChildren(u){var d;return!!((d=u==null?void 0:u.__r3f)!=null?d:{}).handlers},prepareUpdate(u,d,h,p){var g;if(((g=u==null?void 0:u.__r3f)!=null?g:{}).primitive&&p.object&&p.object!==u)return[!0];{const{args:_=[],children:y,...M}=p,{args:C=[],children:k,...B}=h;if(!Array.isArray(_))throw new Error("R3F: the args prop must be an array!");if(_.some((z,O)=>z!==C[O]))return[!0];const U=f4e(u,M,B,!0);return U.changes.length?[!1,U]:null}},commitUpdate(u,[d,h],p,g,x,_){d?o(u,p,x,_):OB(u,h)},commitMount(u,d,h,p){var g;const x=(g=u.__r3f)!=null?g:{};u.raycast&&x.handlers&&x.eventCount&&IN(u).getState().internal.interaction.push(u)},getPublicInstance:u=>u,prepareForCommit:()=>null,preparePortalMount:u=>Rb(u.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(u){var d;const{attach:h,parent:p}=(d=u.__r3f)!=null?d:{};h&&p&&ude(p,u,h),u.isObject3D&&(u.visible=!1),Lb(u)},unhideInstance(u,d){var h;const{attach:p,parent:g}=(h=u.__r3f)!=null?h:{};p&&g&&DB(g,u,p),(u.isObject3D&&d.visible==null||d.visible)&&(u.visible=!0),Lb(u)},createTextInstance:l,hideTextInstance:l,unhideTextInstance:l,getCurrentEventPriority:()=>e?e():s_.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&qa.fun(performance.now)?performance.now:qa.fun(Date.now)?Date.now:()=>0,scheduleTimeout:qa.fun(setTimeout)?setTimeout:void 0,cancelTimeout:qa.fun(clearTimeout)?clearTimeout:void 0}),applyProps:OB}}var ade,ode;const IB=n=>"colorSpace"in n||"outputColorSpace"in n,o4e=()=>{var n;return(n=PY.ColorManagement)!=null?n:null},l4e=n=>n&&n.isOrthographicCamera,dyt=n=>n&&n.hasOwnProperty("current"),E6=typeof window<"u"&&((ade=window.document)!=null&&ade.createElement||((ode=window.navigator)==null?void 0:ode.product)==="ReactNative")?de.useLayoutEffect:de.useEffect;function c4e(n){const e=de.useRef(n);return E6(()=>void(e.current=n),[n]),e}function hyt({set:n}){return E6(()=>(n(new Promise(()=>null)),()=>n(!1)),[n]),null}let u4e=class extends de.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}};u4e.getDerivedStateFromError=()=>({error:!0});const d4e="__default",lde=new Map,fyt=n=>n&&!!n.memoized&&!!n.changes;function h4e(n){var e;const t=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(n)?Math.min(Math.max(n[0],t),n[1]):n}const u5=n=>{var e;return(e=n.__r3f)==null?void 0:e.root.getState()};function IN(n){let e=n.__r3f.root;for(;e.getState().previousRoot;)e=e.getState().previousRoot;return e}const qa={obj:n=>n===Object(n)&&!qa.arr(n)&&typeof n!="function",fun:n=>typeof n=="function",str:n=>typeof n=="string",num:n=>typeof n=="number",boo:n=>typeof n=="boolean",und:n=>n===void 0,arr:n=>Array.isArray(n),equ(n,e,{arrays:t="shallow",objects:r="reference",strict:i=!0}={}){if(typeof n!=typeof e||!!n!=!!e)return!1;if(qa.str(n)||qa.num(n)||qa.boo(n))return n===e;const s=qa.obj(n);if(s&&r==="reference")return n===e;const a=qa.arr(n);if(a&&t==="reference")return n===e;if((a||s)&&n===e)return!0;let o;for(o in n)if(!(o in e))return!1;if(s&&t==="shallow"&&r==="shallow"){for(o in i?e:n)if(!qa.equ(n[o],e[o],{strict:i,objects:"reference"}))return!1}else for(o in i?e:n)if(n[o]!==e[o])return!1;if(qa.und(o)){if(a&&n.length===0&&e.length===0||s&&Object.keys(n).length===0&&Object.keys(e).length===0)return!0;if(n!==e)return!1}return!0}};function pyt(n){const e={nodes:{},materials:{}};return n&&n.traverse(t=>{t.name&&(e.nodes[t.name]=t),t.material&&!e.materials[t.material.name]&&(e.materials[t.material.name]=t.material)}),e}function myt(n){n.dispose&&n.type!=="Scene"&&n.dispose();for(const e in n)e.dispose==null||e.dispose(),delete n[e]}function Rb(n,e){const t=n;return t.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},n}function Mq(n,e){let t=n;if(e.includes("-")){const r=e.split("-"),i=r.pop();return t=r.reduce((s,a)=>s[a],n),{target:t,key:i}}else return{target:t,key:e}}const cde=/-\d+$/;function DB(n,e,t){if(qa.str(t)){if(cde.test(t)){const s=t.replace(cde,""),{target:a,key:o}=Mq(n,s);Array.isArray(a[o])||(a[o]=[])}const{target:r,key:i}=Mq(n,t);e.__r3f.previousAttach=r[i],r[i]=e}else e.__r3f.previousAttach=t(n,e)}function ude(n,e,t){var r,i;if(qa.str(t)){const{target:s,key:a}=Mq(n,t),o=e.__r3f.previousAttach;o===void 0?delete s[a]:s[a]=o}else(r=e.__r3f)==null||r.previousAttach==null||r.previousAttach(n,e);(i=e.__r3f)==null||delete i.previousAttach}function f4e(n,{children:e,key:t,ref:r,...i},{children:s,key:a,ref:o,...l}={},c=!1){const u=n.__r3f,d=Object.entries(i),h=[];if(c){const g=Object.keys(l);for(let x=0;x{var _;if((_=n.__r3f)!=null&&_.primitive&&g==="object"||qa.equ(x,l[g]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(g))return h.push([g,x,!0,[]]);let y=[];g.includes("-")&&(y=g.split("-")),h.push([g,x,!1,y]);for(const M in i){const C=i[M];M.startsWith(`${g}-`)&&h.push([M,C,!1,M.split("-")])}});const p={...i};return u!=null&&u.memoizedProps&&u!=null&&u.memoizedProps.args&&(p.args=u.memoizedProps.args),u!=null&&u.memoizedProps&&u!=null&&u.memoizedProps.attach&&(p.attach=u.memoizedProps.attach),{memoized:p,changes:h}}function OB(n,e){var t;const r=n.__r3f,i=r==null?void 0:r.root,s=i==null||i.getState==null?void 0:i.getState(),{memoized:a,changes:o}=fyt(e)?e:f4e(n,e),l=r==null?void 0:r.eventCount;n.__r3f&&(n.__r3f.memoizedProps=a);for(let h=0;hC[k],n),!(M&&M.set))){const[C,...k]=_.reverse();y=k.reverse().reduce((B,U)=>B[U],n),p=C}if(g===d4e+"remove")if(y.constructor){let C=lde.get(y.constructor);C||(C=new y.constructor,lde.set(y.constructor,C)),g=C[p]}else g=0;if(x&&r)g?r.handlers[p]=g:delete r.handlers[p],r.eventCount=Object.keys(r.handlers).length;else if(M&&M.set&&(M.copy||M instanceof Fx)){if(Array.isArray(g))M.fromArray?M.fromArray(g):M.set(...g);else if(M.copy&&g&&g.constructor&&M.constructor===g.constructor)M.copy(g);else if(g!==void 0){var c;const C=(c=M)==null?void 0:c.isColor;!C&&M.setScalar?M.setScalar(g):M instanceof Fx&&g instanceof Fx?M.mask=g.mask:M.set(g),!o4e()&&s&&!s.linear&&C&&M.convertSRGBToLinear()}}else{var u;if(y[p]=g,(u=y[p])!=null&&u.isTexture&&y[p].format===Oa&&y[p].type===ma&&s){const C=y[p];IB(C)&&IB(s.gl)?C.colorSpace=s.gl.outputColorSpace:C.encoding=s.gl.outputEncoding}}Lb(n)}if(r&&r.parent&&n.raycast&&l!==r.eventCount){const h=IN(n).getState().internal,p=h.interaction.indexOf(n);p>-1&&h.interaction.splice(p,1),r.eventCount&&h.interaction.push(n)}return!(o.length===1&&o[0][0]==="onUpdate")&&o.length&&(t=n.__r3f)!=null&&t.parent&&Cq(n),n}function Lb(n){var e,t;const r=(e=n.__r3f)==null||(t=e.root)==null||t.getState==null?void 0:t.getState();r&&r.internal.frames===0&&r.invalidate()}function Cq(n){n.onUpdate==null||n.onUpdate(n)}function gyt(n,e){n.manual||(l4e(n)?(n.left=e.width/-2,n.right=e.width/2,n.top=e.height/2,n.bottom=e.height/-2):n.aspect=e.width/e.height,n.updateProjectionMatrix(),n.updateMatrixWorld())}function PE(n){return(n.eventObject||n.object).uuid+"/"+n.index+n.instanceId}function Ayt(){var n;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return s_.DefaultEventPriority;switch((n=e.event)==null?void 0:n.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return s_.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return s_.ContinuousEventPriority;default:return s_.DefaultEventPriority}}function p4e(n,e,t,r){const i=t.get(e);i&&(t.delete(e),t.size===0&&(n.delete(r),i.target.releasePointerCapture(r)))}function xyt(n,e){const{internal:t}=n.getState();t.interaction=t.interaction.filter(r=>r!==e),t.initialHits=t.initialHits.filter(r=>r!==e),t.hovered.forEach((r,i)=>{(r.eventObject===e||r.object===e)&&t.hovered.delete(i)}),t.capturedMap.forEach((r,i)=>{p4e(t.capturedMap,e,r,i)})}function vyt(n){function e(l){const{internal:c}=n.getState(),u=l.offsetX-c.initialClick[0],d=l.offsetY-c.initialClick[1];return Math.round(Math.sqrt(u*u+d*d))}function t(l){return l.filter(c=>["Move","Over","Enter","Out","Leave"].some(u=>{var d;return(d=c.__r3f)==null?void 0:d.handlers["onPointer"+u]}))}function r(l,c){const u=n.getState(),d=new Set,h=[],p=c?c(u.internal.interaction):u.internal.interaction;for(let y=0;y{const C=u5(y.object),k=u5(M.object);return!C||!k?y.distance-M.distance:k.events.priority-C.events.priority||y.distance-M.distance}).filter(y=>{const M=PE(y);return d.has(M)?!1:(d.add(M),!0)});u.events.filter&&(x=u.events.filter(x,u));for(const y of x){let M=y.object;for(;M;){var _;(_=M.__r3f)!=null&&_.eventCount&&h.push({...y,eventObject:M}),M=M.parent}}if("pointerId"in l&&u.internal.capturedMap.has(l.pointerId))for(let y of u.internal.capturedMap.get(l.pointerId).values())d.has(PE(y.intersection))||h.push(y.intersection);return h}function i(l,c,u,d){const h=n.getState();if(l.length){const p={stopped:!1};for(const g of l){const x=u5(g.object)||h,{raycaster:_,pointer:y,camera:M,internal:C}=x,k=new Fe(y.x,y.y,0).unproject(M),B=$=>{var G,H;return(G=(H=C.capturedMap.get($))==null?void 0:H.has(g.eventObject))!=null?G:!1},U=$=>{const G={intersection:g,target:c.target};C.capturedMap.has($)?C.capturedMap.get($).set(g.eventObject,G):C.capturedMap.set($,new Map([[g.eventObject,G]])),c.target.setPointerCapture($)},z=$=>{const G=C.capturedMap.get($);G&&p4e(C.capturedMap,g.eventObject,G,$)};let O={};for(let $ in c){let G=c[$];typeof G!="function"&&(O[$]=G)}let V={...g,...O,pointer:y,intersections:l,stopped:p.stopped,delta:u,unprojectedPoint:k,ray:_.ray,camera:M,stopPropagation(){const $="pointerId"in c&&C.capturedMap.get(c.pointerId);if((!$||$.has(g.eventObject))&&(V.stopped=p.stopped=!0,C.hovered.size&&Array.from(C.hovered.values()).find(G=>G.eventObject===g.eventObject))){const G=l.slice(0,l.indexOf(g));s([...G,g])}},target:{hasPointerCapture:B,setPointerCapture:U,releasePointerCapture:z},currentTarget:{hasPointerCapture:B,setPointerCapture:U,releasePointerCapture:z},nativeEvent:c};if(d(V),p.stopped===!0)break}}return l}function s(l){const{internal:c}=n.getState();for(const u of c.hovered.values())if(!l.length||!l.find(d=>d.object===u.object&&d.index===u.index&&d.instanceId===u.instanceId)){const h=u.eventObject.__r3f,p=h==null?void 0:h.handlers;if(c.hovered.delete(PE(u)),h!=null&&h.eventCount){const g={...u,intersections:l};p.onPointerOut==null||p.onPointerOut(g),p.onPointerLeave==null||p.onPointerLeave(g)}}}function a(l,c){for(let u=0;us([]);case"onLostPointerCapture":return c=>{const{internal:u}=n.getState();"pointerId"in c&&u.capturedMap.has(c.pointerId)&&requestAnimationFrame(()=>{u.capturedMap.has(c.pointerId)&&(u.capturedMap.delete(c.pointerId),s([]))})}}return function(u){const{onPointerMissed:d,internal:h}=n.getState();h.lastEvent.current=u;const p=l==="onPointerMove",g=l==="onClick"||l==="onContextMenu"||l==="onDoubleClick",_=r(u,p?t:void 0),y=g?e(u):0;l==="onPointerDown"&&(h.initialClick=[u.offsetX,u.offsetY],h.initialHits=_.map(C=>C.eventObject)),g&&!_.length&&y<=2&&(a(u,h.interaction),d&&d(u)),p&&s(_);function M(C){const k=C.eventObject,B=k.__r3f,U=B==null?void 0:B.handlers;if(B!=null&&B.eventCount)if(p){if(U.onPointerOver||U.onPointerEnter||U.onPointerOut||U.onPointerLeave){const z=PE(C),O=h.hovered.get(z);O?O.stopped&&C.stopPropagation():(h.hovered.set(z,C),U.onPointerOver==null||U.onPointerOver(C),U.onPointerEnter==null||U.onPointerEnter(C))}U.onPointerMove==null||U.onPointerMove(C)}else{const z=U[l];z?(!g||h.initialHits.includes(k))&&(a(u,h.interaction.filter(O=>!h.initialHits.includes(O))),z(C)):g&&h.initialHits.includes(k)&&a(u,h.interaction.filter(O=>!h.initialHits.includes(O)))}}i(_,u,y,M)}}return{handlePointer:o}}const m4e=n=>!!(n!=null&&n.render),g4e=de.createContext(null),yyt=(n,e)=>{const t=tyt((o,l)=>{const c=new Fe,u=new Fe,d=new Fe;function h(y=l().camera,M=u,C=l().size){const{width:k,height:B,top:U,left:z}=C,O=k/B;M.isVector3?d.copy(M):d.set(...M);const V=y.getWorldPosition(c).distanceTo(d);if(l4e(y))return{width:k/y.zoom,height:B/y.zoom,top:U,left:z,factor:1,distance:V,aspect:O};{const $=y.fov*Math.PI/180,G=2*Math.tan($/2)*V,H=G*(k/B);return{width:H,height:G,top:U,left:z,factor:k/H,distance:V,aspect:O}}}let p;const g=y=>o(M=>({performance:{...M.performance,current:y}})),x=new en;return{set:o,get:l,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(y=1)=>n(l(),y),advance:(y,M)=>e(y,M,l()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new wxe,pointer:x,mouse:x,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const y=l();p&&clearTimeout(p),y.performance.current!==y.performance.min&&g(y.performance.min),p=setTimeout(()=>g(l().performance.max),y.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:h},setEvents:y=>o(M=>({...M,events:{...M.events,...y}})),setSize:(y,M,C,k,B)=>{const U=l().camera,z={width:y,height:M,top:k||0,left:B||0,updateStyle:C};o(O=>({size:z,viewport:{...O.viewport,...h(U,u,z)}}))},setDpr:y=>o(M=>{const C=h4e(y);return{viewport:{...M.viewport,dpr:C,initialDpr:M.viewport.initialDpr||C}}}),setFrameloop:(y="always")=>{const M=l().clock;M.stop(),M.elapsedTime=0,y!=="never"&&(M.start(),M.elapsedTime=0),o(()=>({frameloop:y}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:de.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(y,M,C)=>{const k=l().internal;return k.priority=k.priority+(M>0?1:0),k.subscribers.push({ref:y,priority:M,store:C}),k.subscribers=k.subscribers.sort((B,U)=>B.priority-U.priority),()=>{const B=l().internal;B!=null&&B.subscribers&&(B.priority=B.priority-(M>0?1:0),B.subscribers=B.subscribers.filter(U=>U.ref!==y))}}}}}),r=t.getState();let i=r.size,s=r.viewport.dpr,a=r.camera;return t.subscribe(()=>{const{camera:o,size:l,viewport:c,gl:u,set:d}=t.getState();if(l.width!==i.width||l.height!==i.height||c.dpr!==s){var h;i=l,s=c.dpr,gyt(o,l),u.setPixelRatio(c.dpr);const p=(h=l.updateStyle)!=null?h:typeof HTMLCanvasElement<"u"&&u.domElement instanceof HTMLCanvasElement;u.setSize(l.width,l.height,p)}o!==a&&(a=o,d(p=>({viewport:{...p.viewport,...p.viewport.getCurrentViewport(o)}})))}),t.subscribe(o=>n(o)),t};let RE,byt=new Set,_yt=new Set,wyt=new Set;function jB(n,e){if(n.size)for(const{callback:t}of n.values())t(e)}function d5(n,e){switch(n){case"before":return jB(byt,e);case"after":return jB(_yt,e);case"tail":return jB(wyt,e)}}let FB,BB;function UB(n,e,t){let r=e.clock.getDelta();for(e.frameloop==="never"&&typeof n=="number"&&(r=n-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=n),FB=e.internal.subscribers,RE=0;RE0)&&!((u=s.gl.xr)!=null&&u.isPresenting)&&(r+=UB(c,s))}if(t=!1,d5("after",c),r===0)return d5("tail",c),e=!1,cancelAnimationFrame(i)}function o(c,u=1){var d;if(!c)return n.forEach(h=>o(h.store.getState(),u));(d=c.gl.xr)!=null&&d.isPresenting||!c.internal.active||c.frameloop==="never"||(u>1?c.internal.frames=Math.min(60,c.internal.frames+u):t?c.internal.frames=2:c.internal.frames=1,e||(e=!0,requestAnimationFrame(a)))}function l(c,u=!0,d,h){if(u&&d5("before",c),d)UB(c,d,h);else for(const p of n.values())UB(c,p.store.getState());u&&d5("after",c)}return{loop:a,invalidate:o,advance:l}}function A4e(){const n=de.useContext(g4e);if(!n)throw new Error("R3F: Hooks can only be used within the Canvas component!");return n}function Jd(n=t=>t,e){return A4e()(n,e)}function N6(n,e=0){const t=A4e(),r=t.getState().internal.subscribe,i=c4e(n);return E6(()=>r(i,e,t),[e,r,t]),null}const dde=new WeakMap;function x4e(n,e){return function(t,...r){let i=dde.get(t);return i||(i=new t,dde.set(t,i)),n&&n(i),Promise.all(r.map(s=>new Promise((a,o)=>i.load(s,l=>{l.scene&&Object.assign(l,pyt(l.scene)),a(l)},e,l=>o(new Error(`Could not load ${s}: ${l==null?void 0:l.message}`))))))}}function M6(n,e,t,r){const i=Array.isArray(e)?e:[e],s=r4e(x4e(t,r),[n,...i],{equal:qa.equ});return Array.isArray(e)?s:s[0]}M6.preload=function(n,e,t){const r=Array.isArray(e)?e:[e];return ryt(x4e(t),[n,...r])};M6.clear=function(n,e){const t=Array.isArray(e)?e:[e];return iyt([n,...t])};const v3=new Map,{invalidate:hde,advance:fde}=Syt(v3),{reconciler:i7,applyProps:wb}=uyt(v3,Ayt),Sb={objects:"shallow",strict:!1},Tyt=(n,e)=>{const t=typeof n=="function"?n(e):n;return m4e(t)?t:new hW({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...n})};function Eyt(n,e){const t=typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement;if(e){const{width:r,height:i,top:s,left:a,updateStyle:o=t}=e;return{width:r,height:i,top:s,left:a,updateStyle:o}}else if(typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&n.parentElement){const{width:r,height:i,top:s,left:a}=n.parentElement.getBoundingClientRect();return{width:r,height:i,top:s,left:a,updateStyle:t}}else if(typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)return{width:n.width,height:n.height,top:0,left:0,updateStyle:t};return{width:0,height:0,top:0,left:0}}function Nyt(n){const e=v3.get(n),t=e==null?void 0:e.fiber,r=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const i=typeof reportError=="function"?reportError:console.error,s=r||yyt(hde,fde),a=t||i7.createContainer(s,s_.ConcurrentRoot,null,!1,null,"",i,null);e||v3.set(n,{fiber:a,store:s});let o,l=!1,c;return{configure(u={}){let{gl:d,size:h,scene:p,events:g,onCreated:x,shadows:_=!1,linear:y=!1,flat:M=!1,legacy:C=!1,orthographic:k=!1,frameloop:B="always",dpr:U=[1,2],performance:z,raycaster:O,camera:V,onPointerMissed:$}=u,G=s.getState(),H=G.gl;G.gl||G.set({gl:H=Tyt(d,n)});let K=G.raycaster;K||G.set({raycaster:K=new cW});const{params:W,...J}=O||{};if(qa.equ(J,K,Sb)||wb(K,{...J}),qa.equ(W,K.params,Sb)||wb(K,{params:{...K.params,...W}}),!G.camera||G.camera===c&&!qa.equ(c,V,Sb)){c=V;const oe=V instanceof iy,fe=oe?V:k?new Yf(0,0,0,0,.1,1e3):new Ga(75,0,.1,1e3);oe||(fe.position.z=5,V&&(wb(fe,V),("aspect"in V||"left"in V||"right"in V||"bottom"in V||"top"in V)&&(fe.manual=!0,fe.updateProjectionMatrix())),!G.camera&&!(V!=null&&V.rotation)&&fe.lookAt(0,0,0)),G.set({camera:fe}),K.camera=fe}if(!G.scene){let oe;p!=null&&p.isScene?oe=p:(oe=new B3,p&&wb(oe,p)),G.set({scene:Rb(oe)})}if(!G.xr){var ie;const oe=(me,Ae)=>{const be=s.getState();be.frameloop!=="never"&&fde(me,!0,be,Ae)},fe=()=>{const me=s.getState();me.gl.xr.enabled=me.gl.xr.isPresenting,me.gl.xr.setAnimationLoop(me.gl.xr.isPresenting?oe:null),me.gl.xr.isPresenting||hde(me)},ee={connect(){const me=s.getState().gl;me.xr.addEventListener("sessionstart",fe),me.xr.addEventListener("sessionend",fe)},disconnect(){const me=s.getState().gl;me.xr.removeEventListener("sessionstart",fe),me.xr.removeEventListener("sessionend",fe)}};typeof((ie=H.xr)==null?void 0:ie.addEventListener)=="function"&&ee.connect(),G.set({xr:ee})}if(H.shadowMap){const oe=H.shadowMap.enabled,fe=H.shadowMap.type;if(H.shadowMap.enabled=!!_,qa.boo(_))H.shadowMap.type=y_;else if(qa.str(_)){var ae;const ee={basic:A$,percentage:EA,soft:y_,variance:Vf};H.shadowMap.type=(ae=ee[_])!=null?ae:y_}else qa.obj(_)&&Object.assign(H.shadowMap,_);(oe!==H.shadowMap.enabled||fe!==H.shadowMap.type)&&(H.shadowMap.needsUpdate=!0)}const Q=o4e();Q&&("enabled"in Q?Q.enabled=!C:"legacyMode"in Q&&(Q.legacyMode=C)),l||wb(H,{outputEncoding:y?3e3:3001,toneMapping:M?cc:QS}),G.legacy!==C&&G.set(()=>({legacy:C})),G.linear!==y&&G.set(()=>({linear:y})),G.flat!==M&&G.set(()=>({flat:M})),d&&!qa.fun(d)&&!m4e(d)&&!qa.equ(d,H,Sb)&&wb(H,d),g&&!G.events.handlers&&G.set({events:g(s)});const re=Eyt(n,h);return qa.equ(re,G.size,Sb)||G.setSize(re.width,re.height,re.updateStyle,re.top,re.left),U&&G.viewport.dpr!==h4e(U)&&G.setDpr(U),G.frameloop!==B&&G.setFrameloop(B),G.onPointerMissed||G.set({onPointerMissed:$}),z&&!qa.equ(z,G.performance,Sb)&&G.set(oe=>({performance:{...oe.performance,...z}})),o=x,l=!0,this},render(u){return l||this.configure(),i7.updateContainer(f.jsx(Myt,{store:s,children:u,onCreated:o,rootElement:n}),a,null,()=>{}),s},unmount(){v4e(n)}}}function Myt({store:n,children:e,onCreated:t,rootElement:r}){return E6(()=>{const i=n.getState();i.set(s=>({internal:{...s.internal,active:!0}})),t&&t(i),n.getState().events.connected||i.events.connect==null||i.events.connect(r)},[]),f.jsx(g4e.Provider,{value:n,children:e})}function v4e(n,e){const t=v3.get(n),r=t==null?void 0:t.fiber;if(r){const i=t==null?void 0:t.store.getState();i&&(i.internal.active=!1),i7.updateContainer(null,r,null,()=>{i&&setTimeout(()=>{try{var s,a,o,l;i.events.disconnect==null||i.events.disconnect(),(s=i.gl)==null||(a=s.renderLists)==null||a.dispose==null||a.dispose(),(o=i.gl)==null||o.forceContextLoss==null||o.forceContextLoss(),(l=i.gl)!=null&&l.xr&&i.xr.disconnect(),myt(i),v3.delete(n)}catch{}},500)})}}i7.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:de.version});const zB={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function Cyt(n){const{handlePointer:e}=vyt(n);return{priority:1,enabled:!0,compute(t,r,i){r.pointer.set(t.offsetX/r.size.width*2-1,-(t.offsetY/r.size.height)*2+1),r.raycaster.setFromCamera(r.pointer,r.camera)},connected:void 0,handlers:Object.keys(zB).reduce((t,r)=>({...t,[r]:e(r)}),{}),update:()=>{var t;const{events:r,internal:i}=n.getState();(t=i.lastEvent)!=null&&t.current&&r.handlers&&r.handlers.onPointerMove(i.lastEvent.current)},connect:t=>{var r;const{set:i,events:s}=n.getState();s.disconnect==null||s.disconnect(),i(a=>({events:{...a.events,connected:t}})),Object.entries((r=s.handlers)!=null?r:[]).forEach(([a,o])=>{const[l,c]=zB[a];t.addEventListener(l,o,{passive:c})})},disconnect:()=>{const{set:t,events:r}=n.getState();if(r.connected){var i;Object.entries((i=r.handlers)!=null?i:[]).forEach(([s,a])=>{if(r&&r.connected instanceof HTMLElement){const[o]=zB[s];r.connected.removeEventListener(o,a)}}),t(s=>({events:{...s.events,connected:void 0}}))}}}}function pde(n,e){let t;return(...r)=>{window.clearTimeout(t),t=window.setTimeout(()=>n(...r),e)}}function Pyt({debounce:n,scroll:e,polyfill:t,offsetSize:r}={debounce:0,scroll:!1,offsetSize:!1}){const i=t||(typeof window>"u"?class{}:window.ResizeObserver);if(!i)throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");const[s,a]=de.useState({left:0,top:0,width:0,height:0,bottom:0,right:0,x:0,y:0}),o=de.useRef({element:null,scrollContainers:null,resizeObserver:null,lastBounds:s,orientationHandler:null}),l=n?typeof n=="number"?n:n.scroll:null,c=n?typeof n=="number"?n:n.resize:null,u=de.useRef(!1);de.useEffect(()=>(u.current=!0,()=>void(u.current=!1)));const[d,h,p]=de.useMemo(()=>{const y=()=>{if(!o.current.element)return;const{left:M,top:C,width:k,height:B,bottom:U,right:z,x:O,y:V}=o.current.element.getBoundingClientRect(),$={left:M,top:C,width:k,height:B,bottom:U,right:z,x:O,y:V};o.current.element instanceof HTMLElement&&r&&($.height=o.current.element.offsetHeight,$.width=o.current.element.offsetWidth),Object.freeze($),u.current&&!Iyt(o.current.lastBounds,$)&&a(o.current.lastBounds=$)};return[y,c?pde(y,c):y,l?pde(y,l):y]},[a,r,l,c]);function g(){o.current.scrollContainers&&(o.current.scrollContainers.forEach(y=>y.removeEventListener("scroll",p,!0)),o.current.scrollContainers=null),o.current.resizeObserver&&(o.current.resizeObserver.disconnect(),o.current.resizeObserver=null),o.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",o.current.orientationHandler))}function x(){o.current.element&&(o.current.resizeObserver=new i(p),o.current.resizeObserver.observe(o.current.element),e&&o.current.scrollContainers&&o.current.scrollContainers.forEach(y=>y.addEventListener("scroll",p,{capture:!0,passive:!0})),o.current.orientationHandler=()=>{p()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",o.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",o.current.orientationHandler))}const _=y=>{!y||y===o.current.element||(g(),o.current.element=y,o.current.scrollContainers=y4e(y),x())};return Lyt(p,!!e),Ryt(h),de.useEffect(()=>{g(),x()},[e,p,h]),de.useEffect(()=>g,[]),[_,s,d]}function Ryt(n){de.useEffect(()=>{const e=n;return window.addEventListener("resize",e),()=>void window.removeEventListener("resize",e)},[n])}function Lyt(n,e){de.useEffect(()=>{if(e){const t=n;return window.addEventListener("scroll",t,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",t,!0)}},[n,e])}function y4e(n){const e=[];if(!n||n===document.body)return e;const{overflow:t,overflowX:r,overflowY:i}=window.getComputedStyle(n);return[t,r,i].some(s=>s==="auto"||s==="scroll")&&e.push(n),[...e,...y4e(n.parentElement)]}const kyt=["x","y","top","bottom","left","right","width","height"],Iyt=(n,e)=>kyt.every(t=>n[t]===e[t]);var Dyt=Object.defineProperty,Oyt=Object.defineProperties,jyt=Object.getOwnPropertyDescriptors,mde=Object.getOwnPropertySymbols,Fyt=Object.prototype.hasOwnProperty,Byt=Object.prototype.propertyIsEnumerable,gde=(n,e,t)=>e in n?Dyt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Ade=(n,e)=>{for(var t in e||(e={}))Fyt.call(e,t)&&gde(n,t,e[t]);if(mde)for(var t of mde(e))Byt.call(e,t)&&gde(n,t,e[t]);return n},Uyt=(n,e)=>Oyt(n,jyt(e)),xde,vde;typeof window<"u"&&((xde=window.document)!=null&&xde.createElement||((vde=window.navigator)==null?void 0:vde.product)==="ReactNative")?de.useLayoutEffect:de.useEffect;function b4e(n,e,t){if(!n)return;if(t(n)===!0)return n;let r=n.child;for(;r;){const i=b4e(r,e,t);if(i)return i;r=r.sibling}}function _4e(n){try{return Object.defineProperties(n,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return n}}const yde=console.error;console.error=function(){const n=[...arguments].join("");if(n!=null&&n.startsWith("Warning:")&&n.includes("useContext")){console.error=yde;return}return yde.apply(this,arguments)};const LY=_4e(de.createContext(null));class w4e extends de.Component{render(){return de.createElement(LY.Provider,{value:this._reactInternals},this.props.children)}}function zyt(){const n=de.useContext(LY);if(n===null)throw new Error("its-fine: useFiber must be called within a !");const e=de.useId();return de.useMemo(()=>{for(const r of[n,n==null?void 0:n.alternate]){if(!r)continue;const i=b4e(r,!1,s=>{let a=s.memoizedState;for(;a;){if(a.memoizedState===e)return!0;a=a.next}});if(i)return i}},[n,e])}function Vyt(){const n=zyt(),[e]=de.useState(()=>new Map);e.clear();let t=n;for(;t;){if(t.type&&typeof t.type=="object"){const i=t.type._context===void 0&&t.type.Provider===t.type?t.type:t.type._context;i&&i!==LY&&!e.has(i)&&e.set(i,de.useContext(_4e(i)))}t=t.return}return e}function qyt(){const n=Vyt();return de.useMemo(()=>Array.from(n.keys()).reduce((e,t)=>r=>de.createElement(e,null,de.createElement(t.Provider,Uyt(Ade({},r),{value:n.get(t)}))),e=>de.createElement(w4e,Ade({},e))),[n])}const Gyt=de.forwardRef(function({children:e,fallback:t,resize:r,style:i,gl:s,events:a=Cyt,eventSource:o,eventPrefix:l,shadows:c,linear:u,flat:d,legacy:h,orthographic:p,frameloop:g,dpr:x,performance:_,raycaster:y,camera:M,scene:C,onPointerMissed:k,onCreated:B,...U},z){de.useMemo(()=>RY(GJe),[]);const O=qyt(),[V,$]=Pyt({scroll:!0,debounce:{scroll:50,resize:0},...r}),G=de.useRef(null),H=de.useRef(null);de.useImperativeHandle(z,()=>G.current);const K=c4e(k),[W,J]=de.useState(!1),[ie,ae]=de.useState(!1);if(W)throw W;if(ie)throw ie;const Q=de.useRef(null);E6(()=>{const oe=G.current;$.width>0&&$.height>0&&oe&&(Q.current||(Q.current=Nyt(oe)),Q.current.configure({gl:s,events:a,shadows:c,linear:u,flat:d,legacy:h,orthographic:p,frameloop:g,dpr:x,performance:_,raycaster:y,camera:M,scene:C,size:$,onPointerMissed:(...fe)=>K.current==null?void 0:K.current(...fe),onCreated:fe=>{fe.events.connect==null||fe.events.connect(o?dyt(o)?o.current:o:H.current),l&&fe.setEvents({compute:(ee,me)=>{const Ae=ee[l+"X"],be=ee[l+"Y"];me.pointer.set(Ae/me.size.width*2-1,-(be/me.size.height)*2+1),me.raycaster.setFromCamera(me.pointer,me.camera)}}),B==null||B(fe)}}),Q.current.render(f.jsx(O,{children:f.jsx(u4e,{set:ae,children:f.jsx(de.Suspense,{fallback:f.jsx(hyt,{set:J}),children:e??null})})})))}),de.useEffect(()=>{const oe=G.current;if(oe)return()=>v4e(oe)},[]);const re=o?"none":"auto";return f.jsx("div",{ref:H,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:re,...i},...U,children:f.jsx("div",{ref:V,style:{width:"100%",height:"100%"},children:f.jsx("canvas",{ref:G,style:{display:"block"},children:t})})})}),Hyt=de.forwardRef(function(e,t){return f.jsx(w4e,{children:f.jsx(Gyt,{...e,ref:t})})}),S4e=parseInt(Sm.replace(/\D+/g,"")),T4e=S4e>=125?"uv1":"uv2";var $yt=Object.defineProperty,Wyt=(n,e,t)=>e in n?$yt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Xyt=(n,e,t)=>(Wyt(n,e+"",t),t);class Yyt{constructor(){Xyt(this,"_listeners")}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let s=0,a=i.length;se in n?Zyt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Yr=(n,e,t)=>(Qyt(n,typeof e!="symbol"?e+"":e,t),t);const LE=new r2,bde=new Bf,Kyt=Math.cos(70*(Math.PI/180)),_de=(n,e)=>(n%e+e)%e;let Jyt=class extends Yyt{constructor(e,t){super(),Yr(this,"object"),Yr(this,"domElement"),Yr(this,"enabled",!0),Yr(this,"target",new Fe),Yr(this,"minDistance",0),Yr(this,"maxDistance",1/0),Yr(this,"minZoom",0),Yr(this,"maxZoom",1/0),Yr(this,"minPolarAngle",0),Yr(this,"maxPolarAngle",Math.PI),Yr(this,"minAzimuthAngle",-1/0),Yr(this,"maxAzimuthAngle",1/0),Yr(this,"enableDamping",!1),Yr(this,"dampingFactor",.05),Yr(this,"enableZoom",!0),Yr(this,"zoomSpeed",1),Yr(this,"enableRotate",!0),Yr(this,"rotateSpeed",1),Yr(this,"enablePan",!0),Yr(this,"panSpeed",1),Yr(this,"screenSpacePanning",!0),Yr(this,"keyPanSpeed",7),Yr(this,"zoomToCursor",!1),Yr(this,"autoRotate",!1),Yr(this,"autoRotateSpeed",2),Yr(this,"reverseOrbit",!1),Yr(this,"reverseHorizontalOrbit",!1),Yr(this,"reverseVerticalOrbit",!1),Yr(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Yr(this,"mouseButtons",{LEFT:sc.ROTATE,MIDDLE:sc.DOLLY,RIGHT:sc.PAN}),Yr(this,"touches",{ONE:$h.ROTATE,TWO:$h.DOLLY_PAN}),Yr(this,"target0"),Yr(this,"position0"),Yr(this,"zoom0"),Yr(this,"_domElementKeyEvents",null),Yr(this,"getPolarAngle"),Yr(this,"getAzimuthalAngle"),Yr(this,"setPolarAngle"),Yr(this,"setAzimuthalAngle"),Yr(this,"getDistance"),Yr(this,"getZoomScale"),Yr(this,"listenToKeyEvents"),Yr(this,"stopListenToKeyEvents"),Yr(this,"saveState"),Yr(this,"reset"),Yr(this,"update"),Yr(this,"connect"),Yr(this,"dispose"),Yr(this,"dollyIn"),Yr(this,"dollyOut"),Yr(this,"getScale"),Yr(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>u.phi,this.getAzimuthalAngle=()=>u.theta,this.setPolarAngle=tt=>{let Pe=_de(tt,2*Math.PI),nt=u.phi;nt<0&&(nt+=2*Math.PI),Pe<0&&(Pe+=2*Math.PI);let qe=Math.abs(Pe-nt);2*Math.PI-qe{let Pe=_de(tt,2*Math.PI),nt=u.theta;nt<0&&(nt+=2*Math.PI),Pe<0&&(Pe+=2*Math.PI);let qe=Math.abs(Pe-nt);2*Math.PI-qer.object.position.distanceTo(r.target),this.listenToKeyEvents=tt=>{tt.addEventListener("keydown",Ve),this._domElementKeyEvents=tt},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Ve),this._domElementKeyEvents=null},this.saveState=()=>{r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=()=>{r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(i),r.update(),l=o.NONE},this.update=(()=>{const tt=new Fe,Pe=new Fe(0,1,0),nt=new zo().setFromUnitVectors(e.up,Pe),qe=nt.clone().invert(),yt=new Fe,Qt=new zo,Be=2*Math.PI;return function(){const rt=r.object.position;nt.setFromUnitVectors(e.up,Pe),qe.copy(nt).invert(),tt.copy(rt).sub(r.target),tt.applyQuaternion(nt),u.setFromVector3(tt),r.autoRotate&&l===o.NONE&&W(H()),r.enableDamping?(u.theta+=d.theta*r.dampingFactor,u.phi+=d.phi*r.dampingFactor):(u.theta+=d.theta,u.phi+=d.phi);let zt=r.minAzimuthAngle,Yt=r.maxAzimuthAngle;isFinite(zt)&&isFinite(Yt)&&(zt<-Math.PI?zt+=Be:zt>Math.PI&&(zt-=Be),Yt<-Math.PI?Yt+=Be:Yt>Math.PI&&(Yt-=Be),zt<=Yt?u.theta=Math.max(zt,Math.min(Yt,u.theta)):u.theta=u.theta>(zt+Yt)/2?Math.max(zt,u.theta):Math.min(Yt,u.theta)),u.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,u.phi)),u.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(p,r.dampingFactor):r.target.add(p),r.zoomToCursor&&V||r.object.isOrthographicCamera?u.radius=me(u.radius):u.radius=me(u.radius*h),tt.setFromSpherical(u),tt.applyQuaternion(qe),rt.copy(r.target).add(tt),r.object.matrixAutoUpdate||r.object.updateMatrix(),r.object.lookAt(r.target),r.enableDamping===!0?(d.theta*=1-r.dampingFactor,d.phi*=1-r.dampingFactor,p.multiplyScalar(1-r.dampingFactor)):(d.set(0,0,0),p.set(0,0,0));let Bt=!1;if(r.zoomToCursor&&V){let $e=null;if(r.object instanceof Ga&&r.object.isPerspectiveCamera){const ut=tt.length();$e=me(ut*h);const Gt=ut-$e;r.object.position.addScaledVector(z,Gt),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ut=new Fe(O.x,O.y,0);ut.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/h)),r.object.updateProjectionMatrix(),Bt=!0;const Gt=new Fe(O.x,O.y,0);Gt.unproject(r.object),r.object.position.sub(Gt).add(ut),r.object.updateMatrixWorld(),$e=tt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;$e!==null&&(r.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar($e).add(r.object.position):(LE.origin.copy(r.object.position),LE.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(LE.direction))c||8*(1-Qt.dot(r.object.quaternion))>c?(r.dispatchEvent(i),yt.copy(r.object.position),Qt.copy(r.object.quaternion),Bt=!1,!0):!1}})(),this.connect=tt=>{r.domElement=tt,r.domElement.style.touchAction="none",r.domElement.addEventListener("contextmenu",vt),r.domElement.addEventListener("pointerdown",Ht),r.domElement.addEventListener("pointercancel",_t),r.domElement.addEventListener("wheel",ue)},this.dispose=()=>{var tt,Pe,nt,qe,yt,Qt;r.domElement&&(r.domElement.style.touchAction="auto"),(tt=r.domElement)==null||tt.removeEventListener("contextmenu",vt),(Pe=r.domElement)==null||Pe.removeEventListener("pointerdown",Ht),(nt=r.domElement)==null||nt.removeEventListener("pointercancel",_t),(qe=r.domElement)==null||qe.removeEventListener("wheel",ue),(yt=r.domElement)==null||yt.ownerDocument.removeEventListener("pointermove",Se),(Qt=r.domElement)==null||Qt.ownerDocument.removeEventListener("pointerup",_t),r._domElementKeyEvents!==null&&r._domElementKeyEvents.removeEventListener("keydown",Ve)};const r=this,i={type:"change"},s={type:"start"},a={type:"end"},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=o.NONE;const c=1e-6,u=new fS,d=new fS;let h=1;const p=new Fe,g=new en,x=new en,_=new en,y=new en,M=new en,C=new en,k=new en,B=new en,U=new en,z=new Fe,O=new en;let V=!1;const $=[],G={};function H(){return 2*Math.PI/60/60*r.autoRotateSpeed}function K(){return Math.pow(.95,r.zoomSpeed)}function W(tt){r.reverseOrbit||r.reverseHorizontalOrbit?d.theta+=tt:d.theta-=tt}function J(tt){r.reverseOrbit||r.reverseVerticalOrbit?d.phi+=tt:d.phi-=tt}const ie=(()=>{const tt=new Fe;return function(nt,qe){tt.setFromMatrixColumn(qe,0),tt.multiplyScalar(-nt),p.add(tt)}})(),ae=(()=>{const tt=new Fe;return function(nt,qe){r.screenSpacePanning===!0?tt.setFromMatrixColumn(qe,1):(tt.setFromMatrixColumn(qe,0),tt.crossVectors(r.object.up,tt)),tt.multiplyScalar(nt),p.add(tt)}})(),Q=(()=>{const tt=new Fe;return function(nt,qe){const yt=r.domElement;if(yt&&r.object instanceof Ga&&r.object.isPerspectiveCamera){const Qt=r.object.position;tt.copy(Qt).sub(r.target);let Be=tt.length();Be*=Math.tan(r.object.fov/2*Math.PI/180),ie(2*nt*Be/yt.clientHeight,r.object.matrix),ae(2*qe*Be/yt.clientHeight,r.object.matrix)}else yt&&r.object instanceof Yf&&r.object.isOrthographicCamera?(ie(nt*(r.object.right-r.object.left)/r.object.zoom/yt.clientWidth,r.object.matrix),ae(qe*(r.object.top-r.object.bottom)/r.object.zoom/yt.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function re(tt){r.object instanceof Ga&&r.object.isPerspectiveCamera||r.object instanceof Yf&&r.object.isOrthographicCamera?h=tt:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function oe(tt){re(h/tt)}function fe(tt){re(h*tt)}function ee(tt){if(!r.zoomToCursor||!r.domElement)return;V=!0;const Pe=r.domElement.getBoundingClientRect(),nt=tt.clientX-Pe.left,qe=tt.clientY-Pe.top,yt=Pe.width,Qt=Pe.height;O.x=nt/yt*2-1,O.y=-(qe/Qt)*2+1,z.set(O.x,O.y,1).unproject(r.object).sub(r.object.position).normalize()}function me(tt){return Math.max(r.minDistance,Math.min(r.maxDistance,tt))}function Ae(tt){g.set(tt.clientX,tt.clientY)}function be(tt){ee(tt),k.set(tt.clientX,tt.clientY)}function pe(tt){y.set(tt.clientX,tt.clientY)}function ge(tt){x.set(tt.clientX,tt.clientY),_.subVectors(x,g).multiplyScalar(r.rotateSpeed);const Pe=r.domElement;Pe&&(W(2*Math.PI*_.x/Pe.clientHeight),J(2*Math.PI*_.y/Pe.clientHeight)),g.copy(x),r.update()}function Te(tt){B.set(tt.clientX,tt.clientY),U.subVectors(B,k),U.y>0?oe(K()):U.y<0&&fe(K()),k.copy(B),r.update()}function ze(tt){M.set(tt.clientX,tt.clientY),C.subVectors(M,y).multiplyScalar(r.panSpeed),Q(C.x,C.y),y.copy(M),r.update()}function Xe(tt){ee(tt),tt.deltaY<0?fe(K()):tt.deltaY>0&&oe(K()),r.update()}function Qe(tt){let Pe=!1;switch(tt.code){case r.keys.UP:Q(0,r.keyPanSpeed),Pe=!0;break;case r.keys.BOTTOM:Q(0,-r.keyPanSpeed),Pe=!0;break;case r.keys.LEFT:Q(r.keyPanSpeed,0),Pe=!0;break;case r.keys.RIGHT:Q(-r.keyPanSpeed,0),Pe=!0;break}Pe&&(tt.preventDefault(),r.update())}function ot(){if($.length==1)g.set($[0].pageX,$[0].pageY);else{const tt=.5*($[0].pageX+$[1].pageX),Pe=.5*($[0].pageY+$[1].pageY);g.set(tt,Pe)}}function bt(){if($.length==1)y.set($[0].pageX,$[0].pageY);else{const tt=.5*($[0].pageX+$[1].pageX),Pe=.5*($[0].pageY+$[1].pageY);y.set(tt,Pe)}}function ht(){const tt=$[0].pageX-$[1].pageX,Pe=$[0].pageY-$[1].pageY,nt=Math.sqrt(tt*tt+Pe*Pe);k.set(0,nt)}function Ce(){r.enableZoom&&ht(),r.enablePan&&bt()}function lt(){r.enableZoom&&ht(),r.enableRotate&&ot()}function ft(tt){if($.length==1)x.set(tt.pageX,tt.pageY);else{const nt=Ft(tt),qe=.5*(tt.pageX+nt.x),yt=.5*(tt.pageY+nt.y);x.set(qe,yt)}_.subVectors(x,g).multiplyScalar(r.rotateSpeed);const Pe=r.domElement;Pe&&(W(2*Math.PI*_.x/Pe.clientHeight),J(2*Math.PI*_.y/Pe.clientHeight)),g.copy(x)}function et(tt){if($.length==1)M.set(tt.pageX,tt.pageY);else{const Pe=Ft(tt),nt=.5*(tt.pageX+Pe.x),qe=.5*(tt.pageY+Pe.y);M.set(nt,qe)}C.subVectors(M,y).multiplyScalar(r.panSpeed),Q(C.x,C.y),y.copy(M)}function At(tt){const Pe=Ft(tt),nt=tt.pageX-Pe.x,qe=tt.pageY-Pe.y,yt=Math.sqrt(nt*nt+qe*qe);B.set(0,yt),U.set(0,Math.pow(B.y/k.y,r.zoomSpeed)),oe(U.y),k.copy(B)}function Lt(tt){r.enableZoom&&At(tt),r.enablePan&&et(tt)}function st(tt){r.enableZoom&&At(tt),r.enableRotate&&ft(tt)}function Ht(tt){var Pe,nt;r.enabled!==!1&&($.length===0&&((Pe=r.domElement)==null||Pe.ownerDocument.addEventListener("pointermove",Se),(nt=r.domElement)==null||nt.ownerDocument.addEventListener("pointerup",_t)),Ut(tt),tt.pointerType==="touch"?We(tt):It(tt))}function Se(tt){r.enabled!==!1&&(tt.pointerType==="touch"?ct(tt):De(tt))}function _t(tt){var Pe,nt,qe;dt(tt),$.length===0&&((Pe=r.domElement)==null||Pe.releasePointerCapture(tt.pointerId),(nt=r.domElement)==null||nt.ownerDocument.removeEventListener("pointermove",Se),(qe=r.domElement)==null||qe.ownerDocument.removeEventListener("pointerup",_t)),r.dispatchEvent(a),l=o.NONE}function It(tt){let Pe;switch(tt.button){case 0:Pe=r.mouseButtons.LEFT;break;case 1:Pe=r.mouseButtons.MIDDLE;break;case 2:Pe=r.mouseButtons.RIGHT;break;default:Pe=-1}switch(Pe){case sc.DOLLY:if(r.enableZoom===!1)return;be(tt),l=o.DOLLY;break;case sc.ROTATE:if(tt.ctrlKey||tt.metaKey||tt.shiftKey){if(r.enablePan===!1)return;pe(tt),l=o.PAN}else{if(r.enableRotate===!1)return;Ae(tt),l=o.ROTATE}break;case sc.PAN:if(tt.ctrlKey||tt.metaKey||tt.shiftKey){if(r.enableRotate===!1)return;Ae(tt),l=o.ROTATE}else{if(r.enablePan===!1)return;pe(tt),l=o.PAN}break;default:l=o.NONE}l!==o.NONE&&r.dispatchEvent(s)}function De(tt){if(r.enabled!==!1)switch(l){case o.ROTATE:if(r.enableRotate===!1)return;ge(tt);break;case o.DOLLY:if(r.enableZoom===!1)return;Te(tt);break;case o.PAN:if(r.enablePan===!1)return;ze(tt);break}}function ue(tt){r.enabled===!1||r.enableZoom===!1||l!==o.NONE&&l!==o.ROTATE||(tt.preventDefault(),r.dispatchEvent(s),Xe(tt),r.dispatchEvent(a))}function Ve(tt){r.enabled===!1||r.enablePan===!1||Qe(tt)}function We(tt){switch(mt(tt),$.length){case 1:switch(r.touches.ONE){case $h.ROTATE:if(r.enableRotate===!1)return;ot(),l=o.TOUCH_ROTATE;break;case $h.PAN:if(r.enablePan===!1)return;bt(),l=o.TOUCH_PAN;break;default:l=o.NONE}break;case 2:switch(r.touches.TWO){case $h.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;Ce(),l=o.TOUCH_DOLLY_PAN;break;case $h.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;lt(),l=o.TOUCH_DOLLY_ROTATE;break;default:l=o.NONE}break;default:l=o.NONE}l!==o.NONE&&r.dispatchEvent(s)}function ct(tt){switch(mt(tt),l){case o.TOUCH_ROTATE:if(r.enableRotate===!1)return;ft(tt),r.update();break;case o.TOUCH_PAN:if(r.enablePan===!1)return;et(tt),r.update();break;case o.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;Lt(tt),r.update();break;case o.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;st(tt),r.update();break;default:l=o.NONE}}function vt(tt){r.enabled!==!1&&tt.preventDefault()}function Ut(tt){$.push(tt)}function dt(tt){delete G[tt.pointerId];for(let Pe=0;Pe<$.length;Pe++)if($[Pe].pointerId==tt.pointerId){$.splice(Pe,1);return}}function mt(tt){let Pe=G[tt.pointerId];Pe===void 0&&(Pe=new en,G[tt.pointerId]=Pe),Pe.set(tt.pageX,tt.pageY)}function Ft(tt){const Pe=tt.pointerId===$[0].pointerId?$[1]:$[0];return G[Pe.pointerId]}this.dollyIn=(tt=K())=>{fe(tt),r.update()},this.dollyOut=(tt=K())=>{oe(tt),r.update()},this.getScale=()=>h,this.setScale=tt=>{re(tt),r.update()},this.getZoomScale=()=>K(),t!==void 0&&this.connect(t),this.update()}};const wde=new So,kE=new Fe;class kY extends d6{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],r=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(r),this.setAttribute("position",new tr(e,3)),this.setAttribute("uv",new tr(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,r=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),r.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const r=new VA(t,6,1);return this.setAttribute("instanceStart",new kl(r,3,0)),this.setAttribute("instanceEnd",new kl(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e,t=3){let r;e instanceof Float32Array?r=e:Array.isArray(e)&&(r=new Float32Array(e));const i=new VA(r,t*2,1);return this.setAttribute("instanceColorStart",new kl(i,t,0)),this.setAttribute("instanceColorEnd",new kl(i,t,t)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new KP(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new So);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),wde.setFromBufferAttribute(t),this.boundingBox.union(wde))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Vo),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let s=0,a=e.count;s #include #include #include uniform float linewidth; uniform vec2 resolution; attribute vec3 instanceStart; attribute vec3 instanceEnd; #ifdef USE_COLOR #ifdef USE_LINE_COLOR_ALPHA varying vec4 vLineColor; attribute vec4 instanceColorStart; attribute vec4 instanceColorEnd; #else varying vec3 vLineColor; attribute vec3 instanceColorStart; attribute vec3 instanceColorEnd; #endif #endif #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #ifdef USE_DASH uniform float dashScale; attribute float instanceDistanceStart; attribute float instanceDistanceEnd; varying float vLineDistance; #endif void trimSegment( const in vec4 start, inout vec4 end ) { // trim end segment so it terminates between the camera plane and the near plane // conservative estimate of the near plane float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column float nearEstimate = - 0.5 * b / a; float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); end.xyz = mix( start.xyz, end.xyz, alpha ); } void main() { #ifdef USE_COLOR vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; #endif #ifdef USE_DASH vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; vUv = uv; #endif float aspect = resolution.x / resolution.y; // camera space vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); #ifdef WORLD_UNITS worldStart = start.xyz; worldEnd = end.xyz; #else vUv = uv; #endif // special case for perspective projection, and segments that terminate either in, or behind, the camera plane // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space // but we need to perform ndc-space calculations in the shader, so we must address this issue directly // perhaps there is a more elegant solution -- WestLangley bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column if ( perspective ) { if ( start.z < 0.0 && end.z >= 0.0 ) { trimSegment( start, end ); } else if ( end.z < 0.0 && start.z >= 0.0 ) { trimSegment( end, start ); } } // clip space vec4 clipStart = projectionMatrix * start; vec4 clipEnd = projectionMatrix * end; // ndc space vec3 ndcStart = clipStart.xyz / clipStart.w; vec3 ndcEnd = clipEnd.xyz / clipEnd.w; // direction vec2 dir = ndcEnd.xy - ndcStart.xy; // account for clip-space aspect ratio dir.x *= aspect; dir = normalize( dir ); #ifdef WORLD_UNITS // get the offset direction as perpendicular to the view vector vec3 worldDir = normalize( end.xyz - start.xyz ); vec3 offset; if ( position.y < 0.5 ) { offset = normalize( cross( start.xyz, worldDir ) ); } else { offset = normalize( cross( end.xyz, worldDir ) ); } // sign flip if ( position.x < 0.0 ) offset *= - 1.0; float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) ); // don't extend the line if we're rendering dashes because we // won't be rendering the endcaps #ifndef USE_DASH // extend the line bounds to encompass endcaps start.xyz += - worldDir * linewidth * 0.5; end.xyz += worldDir * linewidth * 0.5; // shift the position of the quad so it hugs the forward edge of the line offset.xy -= dir * forwardOffset; offset.z += 0.5; #endif // endcaps if ( position.y > 1.0 || position.y < 0.0 ) { offset.xy += dir * 2.0 * forwardOffset; } // adjust for linewidth offset *= linewidth * 0.5; // set the world position worldPos = ( position.y < 0.5 ) ? start : end; worldPos.xyz += offset; // project the worldpos vec4 clip = projectionMatrix * worldPos; // shift the depth of the projected points so the line // segments overlap neatly vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; clip.z = clipPose.z * clip.w; #else vec2 offset = vec2( dir.y, - dir.x ); // undo aspect ratio adjustment dir.x /= aspect; offset.x /= aspect; // sign flip if ( position.x < 0.0 ) offset *= - 1.0; // endcaps if ( position.y < 0.0 ) { offset += - dir; } else if ( position.y > 1.0 ) { offset += dir; } // adjust for linewidth offset *= linewidth; // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... offset /= resolution.y; // select end vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; // back to clip space offset *= clip.w; clip.xy += offset; #endif gl_Position = clip; vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation #include #include #include } `,fragmentShader:` uniform vec3 diffuse; uniform float opacity; uniform float linewidth; #ifdef USE_DASH uniform float dashOffset; uniform float dashSize; uniform float gapSize; #endif varying float vLineDistance; #ifdef WORLD_UNITS varying vec4 worldPos; varying vec3 worldStart; varying vec3 worldEnd; #ifdef USE_DASH varying vec2 vUv; #endif #else varying vec2 vUv; #endif #include #include #include #include #ifdef USE_COLOR #ifdef USE_LINE_COLOR_ALPHA varying vec4 vLineColor; #else varying vec3 vLineColor; #endif #endif vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { float mua; float mub; vec3 p13 = p1 - p3; vec3 p43 = p4 - p3; vec3 p21 = p2 - p1; float d1343 = dot( p13, p43 ); float d4321 = dot( p43, p21 ); float d1321 = dot( p13, p21 ); float d4343 = dot( p43, p43 ); float d2121 = dot( p21, p21 ); float denom = d2121 * d4343 - d4321 * d4321; float numer = d1343 * d4321 - d1321 * d4343; mua = numer / denom; mua = clamp( mua, 0.0, 1.0 ); mub = ( d1343 + d4321 * ( mua ) ) / d4343; mub = clamp( mub, 0.0, 1.0 ); return vec2( mua, mub ); } void main() { #include #ifdef USE_DASH if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX #endif float alpha = opacity; #ifdef WORLD_UNITS // Find the closest points on the view ray and the line segment vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; vec3 lineDir = worldEnd - worldStart; vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); vec3 p1 = worldStart + lineDir * params.x; vec3 p2 = rayEnd * params.y; vec3 delta = p1 - p2; float len = length( delta ); float norm = len / linewidth; #ifndef USE_DASH #ifdef USE_ALPHA_TO_COVERAGE float dnorm = fwidth( norm ); alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); #else if ( norm > 0.5 ) { discard; } #endif #endif #else #ifdef USE_ALPHA_TO_COVERAGE // artifacts appear on some hardware if a derivative is taken within a conditional float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; float dlen = fwidth( len2 ); if ( abs( vUv.y ) > 1.0 ) { alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); } #else if ( abs( vUv.y ) > 1.0 ) { float a = vUv.x; float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; float len2 = a * a + b * b; if ( len2 > 1.0 ) discard; } #endif #endif vec4 diffuseColor = vec4( diffuse, alpha ); #ifdef USE_COLOR #ifdef USE_LINE_COLOR_ALPHA diffuseColor *= vLineColor; #else diffuseColor.rgb *= vLineColor; #endif #endif #include gl_FragColor = diffuseColor; #include #include <${S4e>=154?"colorspace_fragment":"encodings_fragment"}> #include #include } `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){t===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(t){!!t!="USE_DASH"in this.defines&&(this.needsUpdate=!0),t===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(t){!!t!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),t===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}const VB=new gr,Sde=new Fe,Tde=new Fe,au=new gr,ou=new gr,Ip=new gr,qB=new Fe,GB=new ir,du=new uW,Ede=new Fe,IE=new So,DE=new Vo,Dp=new gr;let $p,Hx;function Nde(n,e,t){return Dp.set(0,0,-e,1).applyMatrix4(n.projectionMatrix),Dp.multiplyScalar(1/Dp.w),Dp.x=Hx/t.width,Dp.y=Hx/t.height,Dp.applyMatrix4(n.projectionMatrixInverse),Dp.multiplyScalar(1/Dp.w),Math.abs(Math.max(Dp.x,Dp.y))}function ebt(n,e){const t=n.matrixWorld,r=n.geometry,i=r.attributes.instanceStart,s=r.attributes.instanceEnd,a=Math.min(r.instanceCount,i.count);for(let o=0,l=a;od&&ou.z>d)continue;if(au.z>d){const C=au.z-ou.z,k=(au.z-d)/C;au.lerp(ou,k)}else if(ou.z>d){const C=ou.z-au.z,k=(ou.z-d)/C;ou.lerp(au,k)}au.applyMatrix4(r),ou.applyMatrix4(r),au.multiplyScalar(1/au.w),ou.multiplyScalar(1/ou.w),au.x*=s.x/2,au.y*=s.y/2,ou.x*=s.x/2,ou.y*=s.y/2,du.start.copy(au),du.start.z=0,du.end.copy(ou),du.end.z=0;const x=du.closestPointToPointParameter(qB,!0);du.at(x,Ede);const _=Q0.lerp(au.z,ou.z,x),y=_>=-1&&_<=1,M=qB.distanceTo(Ede)y.size),p=de.useMemo(()=>a?new N4e:new nbt,[a]),[g]=de.useState(()=>new IY),x=(r==null||(u=r[0])==null?void 0:u.length)===4?4:3,_=de.useMemo(()=>{const y=a?new kY:new E4e,M=e.map(C=>{const k=Array.isArray(C);return C instanceof Fe||C instanceof gr?[C.x,C.y,C.z]:C instanceof en?[C.x,C.y,0]:k&&C.length===3?[C[0],C[1],C[2]]:k&&C.length===2?[C[0],C[1],0]:C});if(y.setPositions(M.flat()),r){t=16777215;const C=r.map(k=>k instanceof Fn?k.toArray():k);y.setColors(C.flat(),x)}return y},[e,a,r,x]);return de.useLayoutEffect(()=>{p.computeLineDistances()},[e,p]),de.useLayoutEffect(()=>{o?g.defines.USE_DASH="":delete g.defines.USE_DASH,g.needsUpdate=!0},[o,g]),de.useEffect(()=>()=>{_.dispose(),g.dispose()},[_]),de.createElement("primitive",No({object:p,ref:c},l),de.createElement("primitive",{object:_,attach:"geometry"}),de.createElement("primitive",No({object:g,attach:"material",color:t,vertexColors:!!r,resolution:[h.width,h.height],linewidth:(d=i??s)!==null&&d!==void 0?d:1,dashed:o,transparent:x===4},l)))});function ibt(){var n=Object.create(null);function e(i,s){var a=i.id,o=i.name,l=i.dependencies;l===void 0&&(l=[]);var c=i.init;c===void 0&&(c=function(){});var u=i.getTransferables;if(u===void 0&&(u=null),!n[a])try{l=l.map(function(h){return h&&h.isWorkerModule&&(e(h,function(p){if(p instanceof Error)throw p}),h=n[h.id].value),h}),c=r("<"+o+">.init",c),u&&(u=r("<"+o+">.getTransferables",u));var d=null;typeof c=="function"?d=c.apply(void 0,l):console.error("worker module init function failed to rehydrate"),n[a]={id:a,value:d,getTransferables:u},s(d)}catch(h){h&&h.noLog||console.error(h),s(h)}}function t(i,s){var a,o=i.id,l=i.args;(!n[o]||typeof n[o].value!="function")&&s(new Error("Worker module "+o+": not found or its 'init' did not return a function"));try{var c=(a=n[o]).value.apply(a,l);c&&typeof c.then=="function"?c.then(u,function(d){return s(d instanceof Error?d:new Error(""+d))}):u(c)}catch(d){s(d)}function u(d){try{var h=n[o].getTransferables&&n[o].getTransferables(d);(!h||!Array.isArray(h)||!h.length)&&(h=void 0),s(d,h)}catch(p){console.error(p),s(p)}}}function r(i,s){var a=void 0;self.troikaDefine=function(l){return a=l};var o=URL.createObjectURL(new Blob(["/** "+i.replace(/\*/g,"")+` **/ troikaDefine( `+s+` )`],{type:"application/javascript"}));try{importScripts(o)}catch(l){console.error(l)}return URL.revokeObjectURL(o),delete self.troikaDefine,a}self.addEventListener("message",function(i){var s=i.data,a=s.messageId,o=s.action,l=s.data;try{o==="registerModule"&&e(l,function(c){c instanceof Error?postMessage({messageId:a,success:!1,error:c.message}):postMessage({messageId:a,success:!0,result:{isCallable:typeof c=="function"}})}),o==="callModule"&&t(l,function(c,u){c instanceof Error?postMessage({messageId:a,success:!1,error:c.message}):postMessage({messageId:a,success:!0,result:c},u||void 0)})}catch(c){postMessage({messageId:a,success:!1,error:c.stack})}})}function sbt(n){var e=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return e._getInitResult().then(function(i){if(typeof i=="function")return i.apply(void 0,t);throw new Error("Worker module function was called but `init` did not return a callable function")})};return e._getInitResult=function(){var t=n.dependencies,r=n.init;t=Array.isArray(t)?t.map(function(s){return s&&(s=s.onMainThread||s,s._getInitResult&&(s=s._getInitResult())),s}):[];var i=Promise.all(t).then(function(s){return r.apply(null,s)});return e._getInitResult=function(){return i},i},e}var M4e=function(){var n=!1;if(typeof window<"u"&&typeof window.document<"u")try{var e=new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"})));e.terminate(),n=!0}catch(t){console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+t.message+"]")}return M4e=function(){return n},n},abt=0,obt=0,HB=!1,S4=Object.create(null),T4=Object.create(null),Pq=Object.create(null);function K3(n){if((!n||typeof n.init!="function")&&!HB)throw new Error("requires `options.init` function");var e=n.dependencies,t=n.init,r=n.getTransferables,i=n.workerId,s=sbt(n);i==null&&(i="#default");var a="workerModule"+ ++abt,o=n.name||a,l=null;e=e&&e.map(function(u){return typeof u=="function"&&!u.workerModuleData&&(HB=!0,u=K3({workerId:i,name:"<"+o+"> function dependency: "+u.name,init:`function(){return ( `+DN(u)+` )}`}),HB=!1),u&&u.workerModuleData&&(u=u.workerModuleData),u});function c(){for(var u=[],d=arguments.length;d--;)u[d]=arguments[d];if(!M4e())return s.apply(void 0,u);if(!l){l=Mde(i,"registerModule",c.workerModuleData);var h=function(){l=null,T4[i].delete(h)};(T4[i]||(T4[i]=new Set)).add(h)}return l.then(function(p){var g=p.isCallable;if(g)return Mde(i,"callModule",{id:a,args:u});throw new Error("Worker module function was called but `init` did not return a callable function")})}return c.workerModuleData={isWorkerModule:!0,id:a,name:o,dependencies:e,init:DN(t),getTransferables:r&&DN(r)},c.onMainThread=s,c}function lbt(n){T4[n]&&T4[n].forEach(function(e){e()}),S4[n]&&(S4[n].terminate(),delete S4[n])}function DN(n){var e=n.toString();return!/^function/.test(e)&&/^\w+\s*\(/.test(e)&&(e="function "+e),e}function cbt(n){var e=S4[n];if(!e){var t=DN(ibt);e=S4[n]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+n.replace(/\*/g,"")+` **/ ;(`+t+")()"],{type:"application/javascript"}))),e.onmessage=function(r){var i=r.data,s=i.messageId,a=Pq[s];if(!a)throw new Error("WorkerModule response with empty or unknown messageId");delete Pq[s],a(i)}}return e}function Mde(n,e,t){return new Promise(function(r,i){var s=++obt;Pq[s]=function(a){a.success?r(a.result):i(new Error("Error in worker "+e+" call: "+a.error))},cbt(n).postMessage({messageId:s,action:e,data:t})})}function C4e(){var n=function(e){function t(re,oe,fe,ee,me,Ae,be,pe){var ge=1-be;pe.x=ge*ge*re+2*ge*be*fe+be*be*me,pe.y=ge*ge*oe+2*ge*be*ee+be*be*Ae}function r(re,oe,fe,ee,me,Ae,be,pe,ge,Te){var ze=1-ge;Te.x=ze*ze*ze*re+3*ze*ze*ge*fe+3*ze*ge*ge*me+ge*ge*ge*be,Te.y=ze*ze*ze*oe+3*ze*ze*ge*ee+3*ze*ge*ge*Ae+ge*ge*ge*pe}function i(re,oe){for(var fe=/([MLQCZ])([^MLQCZ]*)/g,ee,me,Ae,be,pe;ee=fe.exec(re);){var ge=ee[2].replace(/^\s*|\s*$/g,"").split(/[,\s]+/).map(function(Te){return parseFloat(Te)});switch(ee[1]){case"M":be=me=ge[0],pe=Ae=ge[1];break;case"L":(ge[0]!==be||ge[1]!==pe)&&oe("L",be,pe,be=ge[0],pe=ge[1]);break;case"Q":{oe("Q",be,pe,be=ge[2],pe=ge[3],ge[0],ge[1]);break}case"C":{oe("C",be,pe,be=ge[4],pe=ge[5],ge[0],ge[1],ge[2],ge[3]);break}case"Z":(be!==me||pe!==Ae)&&oe("L",be,pe,me,Ae);break}}}function s(re,oe,fe){fe===void 0&&(fe=16);var ee={x:0,y:0};i(re,function(me,Ae,be,pe,ge,Te,ze,Xe,Qe){switch(me){case"L":oe(Ae,be,pe,ge);break;case"Q":{for(var ot=Ae,bt=be,ht=1;ht0;)ue[Ve]=arguments[Ve+2];var We=Lt[De]||(Lt[De]=fe.getUniformLocation(st,De));fe["uniform"+It].apply(fe,[We].concat(ue))},setAttribute:function(It,De,ue,Ve,We){var ct=At[It];ct||(ct=At[It]={buf:fe.createBuffer(),loc:fe.getAttribLocation(st,It),data:null}),fe.bindBuffer(fe.ARRAY_BUFFER,ct.buf),fe.vertexAttribPointer(ct.loc,De,fe.FLOAT,!1,0,0),fe.enableVertexAttribArray(ct.loc),me?fe.vertexAttribDivisor(ct.loc,Ve):ze("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(ct.loc,Ve),We!==ct.data&&(fe.bufferData(fe.ARRAY_BUFFER,We,ue),ct.data=We)}})}}}be[Ce].transaction(et)},ot=function(Ce,lt){ge++;try{fe.activeTexture(fe.TEXTURE0+ge);var ft=pe[Ce];ft||(ft=pe[Ce]=fe.createTexture(),fe.bindTexture(fe.TEXTURE_2D,ft),fe.texParameteri(fe.TEXTURE_2D,fe.TEXTURE_MIN_FILTER,fe.NEAREST),fe.texParameteri(fe.TEXTURE_2D,fe.TEXTURE_MAG_FILTER,fe.NEAREST)),fe.bindTexture(fe.TEXTURE_2D,ft),lt(ft,ge)}finally{ge--}},bt=function(Ce,lt,ft){var et=fe.createFramebuffer();Te.push(et),fe.bindFramebuffer(fe.FRAMEBUFFER,et),fe.activeTexture(fe.TEXTURE0+lt),fe.bindTexture(fe.TEXTURE_2D,Ce),fe.framebufferTexture2D(fe.FRAMEBUFFER,fe.COLOR_ATTACHMENT0,fe.TEXTURE_2D,Ce,0);try{ft(et)}finally{fe.deleteFramebuffer(et),fe.bindFramebuffer(fe.FRAMEBUFFER,Te[--Te.length-1]||null)}},ht=function(){Ae={},be={},pe={},ge=-1,Te.length=0};var me=typeof WebGL2RenderingContext<"u"&&fe instanceof WebGL2RenderingContext,Ae={},be={},pe={},ge=-1,Te=[];fe.canvas.addEventListener("webglcontextlost",function(Ce){ht(),Ce.preventDefault()},!1),l.set(fe,ee={gl:fe,isWebGL2:me,getExtension:ze,withProgram:Qe,withTexture:ot,withTextureFramebuffer:bt,handleContextLoss:ht})}oe(ee)}function d(re,oe,fe,ee,me,Ae,be,pe){be===void 0&&(be=15),pe===void 0&&(pe=null),u(re,function(ge){var Te=ge.gl,ze=ge.withProgram,Xe=ge.withTexture;Xe("copy",function(Qe,ot){Te.texImage2D(Te.TEXTURE_2D,0,Te.RGBA,me,Ae,0,Te.RGBA,Te.UNSIGNED_BYTE,oe),ze("copy",a,o,function(bt){var ht=bt.setUniform,Ce=bt.setAttribute;Ce("aUV",2,Te.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),ht("1i","image",ot),Te.bindFramebuffer(Te.FRAMEBUFFER,pe||null),Te.disable(Te.BLEND),Te.colorMask(be&8,be&4,be&2,be&1),Te.viewport(fe,ee,me,Ae),Te.scissor(fe,ee,me,Ae),Te.drawArrays(Te.TRIANGLES,0,3)})})})}function h(re,oe,fe){var ee=re.width,me=re.height;u(re,function(Ae){var be=Ae.gl,pe=new Uint8Array(ee*me*4);be.readPixels(0,0,ee,me,be.RGBA,be.UNSIGNED_BYTE,pe),re.width=oe,re.height=fe,d(be,pe,0,0,ee,me)})}var p=Object.freeze({__proto__:null,withWebGLContext:u,renderImageData:d,resizeWebGLCanvasWithoutClearing:h});function g(re,oe,fe,ee,me,Ae){Ae===void 0&&(Ae=1);var be=new Uint8Array(re*oe),pe=ee[2]-ee[0],ge=ee[3]-ee[1],Te=[];s(fe,function(Ce,lt,ft,et){Te.push({x1:Ce,y1:lt,x2:ft,y2:et,minX:Math.min(Ce,ft),minY:Math.min(lt,et),maxX:Math.max(Ce,ft),maxY:Math.max(lt,et)})}),Te.sort(function(Ce,lt){return Ce.maxX-lt.maxX});for(var ze=0;zeLt.minX&<-etLt.minY){var st=y(Ce,lt,Lt.x1,Lt.y1,Lt.x2,Lt.y2);stlt!=At.y2>lt&&Ce<(At.x2-At.x1)*(lt-At.y1)/(At.y2-At.y1)+At.x1;Lt&&(ft+=At.y1p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function x(et,At){var Lt=36,st=0,Ht=new Map,Se=At&&new Map,_t;return et.split(",").forEach(function It(De){if(De.indexOf("+")!==-1)for(var ue=+De;ue--;)It(_t);else{_t=De;var Ve=De.split(">"),We=Ve[0],ct=Ve[1];We=String.fromCodePoint(st+=parseInt(We,Lt)),ct=String.fromCodePoint(st+=parseInt(ct,Lt)),Ht.set(We,ct),At&&Se.set(ct,We)}}),{map:Ht,reverseMap:Se}}var _,y,M;function C(){if(!_){var et=x(g.pairs,!0),At=et.map,Lt=et.reverseMap;_=At,y=Lt,M=x(g.canonical,!1).map}}function k(et){return C(),_.get(et)||null}function B(et){return C(),y.get(et)||null}function U(et){return C(),M.get(et)||null}var z=r.L,O=r.R,V=r.EN,$=r.ES,G=r.ET,H=r.AN,K=r.CS,W=r.B,J=r.S,ie=r.ON,ae=r.BN,Q=r.NSM,re=r.AL,oe=r.LRO,fe=r.RLO,ee=r.LRE,me=r.RLE,Ae=r.PDF,be=r.LRI,pe=r.RLI,ge=r.FSI,Te=r.PDI;function ze(et,At){for(var Lt=125,st=new Uint32Array(et.length),Ht=0;Ht0)tt--;else if(nt>0){for(Pe=0;!mt[mt.length-1]._isolate;)mt.pop();var rt=mt[mt.length-1]._isolInitIndex;rt!=null&&(De.set(rt,qe),De.set(qe,rt)),mt.pop(),nt--}Ft=mt[mt.length-1],It[qe]=Ft._level,Ft._override&&_t(qe,Ft._override)}else yt&Ae?(tt===0&&(Pe>0?Pe--:!Ft._isolate&&mt.length>1&&(mt.pop(),Ft=mt[mt.length-1])),It[qe]=Ft._level):yt&W&&(It[qe]=Ve.level);else It[qe]=Ft._level,Ft._override&&yt!==ae&&_t(qe,Ft._override)}for(var zt=[],Yt=null,Bt=Ve.start;Bt<=Ve.end;Bt++){var $e=st[Bt];if(!($e&l)){var ut=It[Bt],Gt=$e&s,it=$e===Te;Yt&&ut===Yt._level?(Yt._end=Bt,Yt._endsWithIsolInit=Gt):zt.push(Yt={_start:Bt,_end:Bt,_level:ut,_startsWithPDI:it,_endsWithIsolInit:Gt})}}for(var Ot=[],nn=0;nn=0;jr--)if(!(st[jr]&l)){lr=It[jr];break}var Qr=Ln[Ln.length-1],Os=It[Qr],la=Ve.level;if(!(st[Qr]&s)){for(var Pi=Qr+1;Pi<=Ve.end;Pi++)if(!(st[Pi]&l)){la=It[Pi];break}}Ot.push({_seqIndices:Ln,_sosType:Math.max(lr,Hn)%2?O:z,_eosType:Math.max(la,Os)%2?O:z})}}for(var ra=0;ra=0;Xt--)if(!(st[Jn[Xt]]&l)){Dt=st[Jn[Xt]];break}_t(_e,Dt&(s|Te)?ie:Dt)}}if(Se.get(V))for(var vn=0;vn=-1;hn--){var Tn=hn===-1?wa:st[Jn[hn]];if(Tn&a){Tn===re&&_t(Sn,H);break}}}if(Se.get(re))for(var Re=0;Re=0&&(zn=st[Jn[ii]],!!(zn&l));ii--);for(var Kr=Ar+1;Kr=0&&st[Jn[Ri]]&(G|l);Ri--)_t(Jn[Ri],V);for(Ir++;Ir=0&&st[Jn[fs]]&l;fs--)_t(Jn[fs],ie);for(var Ki=sr+1;Ki=0;Xo--){var Dn=Fa[Xo].char;if(Dn===Hc||Dn===B(U(nr))||k(U(Dn))===nr){Sa.push([Fa[Xo].seqIndex,Wo]),Fa.length=Xo;break}}}Sa.sort(function(Ea,Ws){return Ea[0]-Ws[0]})}for(var Yo=0;Yo=0;Fs--){var xl=Jn[Fs];if(st[xl]&Ji){var Hs=st[xl]&fi?O:z;Hs!==Ge?Gs=Hs:Gs=Ge;break}}}if(Gs){if(st[Jn[Es]]=st[Jn[Jl]]=Gs,Gs!==Ge){for(var fo=Es+1;fo=0;qr--)if(st[Jn[qr]]&l)yc=qr;else{Qa=st[Jn[qr]]&fi?O:z;break}for(var Wc=Ii,$s=Qo+1;$s=0&&h(et[Ko])&c;Ko--)It[Ko]=Ve.level}}return{levels:It,paragraphs:ue};function Tu(Ea,Ws){for(var vs=Ea;vs=It&&h(et[Ve])&c;Ve--)ue[Ve]=_t.level;for(var We=_t.level,ct=1/0,vt=0;vtWe&&(We=Ut),Ut=ct;dt--)for(var mt=0;mt=dt){for(var Ft=mt;mt+1=dt;)mt++;mt>Ft&&Se.push([Ft+It,mt+It])}}}),Se}function lt(et,At,Lt,st){var Ht=ft(et,At,Lt,st),Se=[].concat(et);return Ht.forEach(function(_t,It){Se[It]=(At.levels[_t]&1?bt(et[_t]):null)||et[_t]}),Se.join("")}function ft(et,At,Lt,st){for(var Ht=Ce(et,At,Lt,st),Se=[],_t=0;_t/gm;function t(r,i){let s=di[i];return s?Rq(s):r}return n.replace(e,t)}const lu=[];for(let n=0;n<256;n++)lu[n]=(n<16?"0":"")+n.toString(16);function dbt(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(lu[n&255]+lu[n>>8&255]+lu[n>>16&255]+lu[n>>24&255]+"-"+lu[e&255]+lu[e>>8&255]+"-"+lu[e>>16&15|64]+lu[e>>24&255]+"-"+lu[t&63|128]+lu[t>>8&255]+"-"+lu[t>>16&255]+lu[t>>24&255]+lu[r&255]+lu[r>>8&255]+lu[r>>16&255]+lu[r>>24&255]).toUpperCase()}const K2=Object.assign||function(){let n=arguments[0];for(let e=1,t=arguments.length;en.type,set:c=>{n.type=c}},isDerivedFrom:{writable:!0,configurable:!0,value:function(c){const u=this.baseMaterial;return c===u||u.isDerivedMaterial&&u.isDerivedFrom(c)||!1}},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return n.customProgramCacheKey()+"|"+t}},onBeforeCompile:{get(){return s},set(c){this[i]=c}},copy:{writable:!0,configurable:!0,value:function(c){return n.copy.call(this,c),!n.isShaderMaterial&&!n.isDerivedMaterial&&(K2(this.extensions,c.extensions),K2(this.defines,c.defines),K2(this.uniforms,qg.clone(c.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const c=new n.constructor;return o(c).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let c=this._depthMaterial;return c||(c=this._depthMaterial=Lq(n.isDerivedMaterial?n.getDepthMaterial():new tR({depthPacking:N2e}),e),c.defines.IS_DEPTH_MATERIAL="",c.uniforms=this.uniforms),c}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let c=this._distanceMaterial;return c||(c=this._distanceMaterial=Lq(n.isDerivedMaterial?n.getDistanceMaterial():new nR,e),c.defines.IS_DISTANCE_MATERIAL="",c.uniforms=this.uniforms),c}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:c,_distanceMaterial:u}=this;c&&c.dispose(),u&&u.dispose(),n.dispose.call(this)}}};return r[t]=a,new a}function pbt(n,{vertexShader:e,fragmentShader:t},r,i){let{vertexDefs:s,vertexMainIntro:a,vertexMainOutro:o,vertexTransform:l,fragmentDefs:c,fragmentMainIntro:u,fragmentMainOutro:d,fragmentColorTransform:h,customRewriter:p,timeUniform:g}=r;if(s=s||"",a=a||"",o=o||"",c=c||"",u=u||"",d=d||"",(l||p)&&(e=Rq(e)),(h||p)&&(t=t.replace(/^[ \t]*#include <((?:tonemapping|encodings|colorspace|fog|premultiplied_alpha|dithering)_fragment)>/gm,` //!BEGIN_POST_CHUNK $1 $& //!END_POST_CHUNK `),t=Rq(t)),p){let x=p({vertexShader:e,fragmentShader:t});e=x.vertexShader,t=x.fragmentShader}if(h){let x=[];t=t.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,_=>(x.push(_),"")),d=`${h} ${x.join(` `)} ${d}`}if(g){const x=` uniform float ${g}; `;s=x+s,c=x+c}return l&&(e=`vec3 troika_position_${i}; vec3 troika_normal_${i}; vec2 troika_uv_${i}; ${e} `,s=`${s} void troikaVertexTransform${i}(inout vec3 position, inout vec3 normal, inout vec2 uv) { ${l} } `,a=` troika_position_${i} = vec3(position); troika_normal_${i} = vec3(normal); troika_uv_${i} = vec2(uv); troikaVertexTransform${i}(troika_position_${i}, troika_normal_${i}, troika_uv_${i}); ${a} `,e=e.replace(/\b(position|normal|uv)\b/g,(x,_,y,M)=>/\battribute\s+vec[23]\s+$/.test(M.substr(0,y))?_:`troika_${_}_${i}`),n.map&&n.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${i}`))),e=Rde(e,i,s,a,o),t=Rde(t,i,c,u,d),{vertexShader:e,fragmentShader:t}}function Rde(n,e,t,r,i){return(r||i||t)&&(n=n.replace(P4e,` ${t} void troikaOrigMain${e}() {`),n+=` void main() { ${r} troikaOrigMain${e}(); ${i} }`),n}function mbt(n,e){return n==="uniforms"?void 0:typeof e=="function"?e.toString():e}let gbt=0;const Lde=new Map;function Abt(n){const e=JSON.stringify(n,mbt);let t=Lde.get(e);return t==null&&Lde.set(e,t=++gbt),t}/*! Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering. Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE */function xbt(){return typeof window>"u"&&(self.window=self),function(n){var e={parse:function(i){var s=e._bin,a=new Uint8Array(i);if(s.readASCII(a,0,4)=="ttcf"){var o=4;s.readUshort(a,o),o+=2,s.readUshort(a,o),o+=2;var l=s.readUint(a,o);o+=4;for(var c=[],u=0;u>>a&1&&s++;return s},e._lctf.readClassDef=function(i,s){var a=e._bin,o=[],l=a.readUshort(i,s);if(s+=2,l==1){var c=a.readUshort(i,s);s+=2;var u=a.readUshort(i,s);s+=2;for(var d=0;d0&&(l.featureParams=o+c);var u=a.readUshort(i,s);s+=2,l.tab=[];for(var d=0;d0&&(l.default=e._lctf.readLangSysTable(i,o+c));var u=a.readUshort(i,s);s+=2;for(var d=0;d255?-1:e.CFF.glyphByUnicode(i,e.CFF.tableSE[s])},e.CFF.readEncoding=function(i,s,a){e._bin;var o=[".notdef"],l=i[s];if(s++,l!=0)throw"error: unknown encoding format: "+l;var c=i[s];s++;for(var u=0;u>4,M=15&_;if(y!=15&&x.push(y),M!=15&&x.push(M),M==15)break}for(var C="",k=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],B=0;B=c.xMax||c.yMin>=c.yMax)return null;if(c.noc>0){c.endPts=[];for(var u=0;u=1&&u.fmt<=2){h=l.readUshort(i,a),a+=2;var p=l.readUshort(i,a);a+=2;var g=e._lctf.numOfOnes(h),x=e._lctf.numOfOnes(p);if(u.fmt==1){u.pairsets=[];var _=l.readUshort(i,a);a+=2;for(var y=0;y<_;y++){var M=c+l.readUshort(i,a);a+=2;var C=l.readUshort(i,M);M+=2;for(var k=[],B=0;B=1&&u.fmt<=2){if(u.fmt==1)u.delta=l.readShort(i,a),a+=2;else if(u.fmt==2){var h=l.readUshort(i,a);a+=2,u.newg=l.readUshorts(i,a,h),a+=2*u.newg.length}}else if(s==2&&u.fmt==1){h=l.readUshort(i,a),a+=2,u.seqs=[];for(var p=0;p>>8;if((g&=15)!=0)throw"unknown kern table format: "+g;s=e.kern.readFormat0(i,s,d)}return d},e.kern.parseV1=function(i,s,a,o){var l=e._bin;l.readFixed(i,s),s+=4;var c=l.readUint(i,s);s+=4;for(var u={glyph1:[],rval:[]},d=0;d>>8;if((p&=15)!=0)throw"unknown kern table format: "+p;s=e.kern.readFormat0(i,s,u)}return u},e.kern.readFormat0=function(i,s,a){var o=e._bin,l=-1,c=o.readUshort(i,s);s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2,o.readUshort(i,s),s+=2;for(var u=0;u=l.map.length?0:l.map[s];if(l.format==4){for(var c=-1,u=0;us?0:65535&(l.idRangeOffset[c]!=0?l.glyphIdArray[s-l.startCount[c]+(l.idRangeOffset[c]>>1)-(l.idRangeOffset.length-c)]:s+l.idDelta[c])}if(l.format==12){if(s>l.groups[l.groups.length-1][1])return 0;for(u=0;u-1?e.U._simpleGlyph(o,a):e.U._compoGlyph(o,s,a))},e.U._simpleGlyph=function(i,s){for(var a=0;al)){for(var _=!0,y=0,M=0;Ml)){for(_=!0,M=0;M>1,c.length=0,d=!0;else if(H=="o3"||H=="o23")c.length%2!=0&&!d&&(h=c.shift()+o.nominalWidthX),u+=c.length>>1,c.length=0,d=!0;else if(H=="o4")c.length>1&&!d&&(h=c.shift()+o.nominalWidthX,d=!0),p&&e.U.P.closePath(l),_+=c.pop(),e.U.P.moveTo(l,x,_),p=!0;else if(H=="o5")for(;c.length>0;)x+=c.shift(),_+=c.shift(),e.U.P.lineTo(l,x,_);else if(H=="o6"||H=="o7")for(var K=c.length,W=H=="o6",J=0;JMath.abs(O-_)?x=z+c.shift():_=O+c.shift(),e.U.P.curveTo(l,y,M,C,k,V,$),e.U.P.curveTo(l,B,U,z,O,x,_));else if(H=="o14"){if(c.length>0&&!d&&(h=c.shift()+a.nominalWidthX,d=!0),c.length==4){var Q=c.shift(),re=c.shift(),oe=c.shift(),fe=c.shift(),ee=e.CFF.glyphBySE(a,oe),me=e.CFF.glyphBySE(a,fe);e.U._drawCFF(a.CharStrings[ee],s,a,o,l),s.x=Q,s.y=re,e.U._drawCFF(a.CharStrings[me],s,a,o,l)}p&&(e.U.P.closePath(l),p=!1)}else if(H=="o19"||H=="o20")c.length%2!=0&&!d&&(h=c.shift()+o.nominalWidthX),u+=c.length>>1,c.length=0,d=!0,g+=u+7>>3;else if(H=="o21")c.length>2&&!d&&(h=c.shift()+o.nominalWidthX,d=!0),_+=c.pop(),x+=c.pop(),p&&e.U.P.closePath(l),e.U.P.moveTo(l,x,_),p=!0;else if(H=="o22")c.length>1&&!d&&(h=c.shift()+o.nominalWidthX,d=!0),x+=c.pop(),p&&e.U.P.closePath(l),e.U.P.moveTo(l,x,_),p=!0;else if(H=="o25"){for(;c.length>6;)x+=c.shift(),_+=c.shift(),e.U.P.lineTo(l,x,_);y=x+c.shift(),M=_+c.shift(),C=y+c.shift(),k=M+c.shift(),x=C+c.shift(),_=k+c.shift(),e.U.P.curveTo(l,y,M,C,k,x,_)}else if(H=="o26")for(c.length%2&&(x+=c.shift());c.length>0;)y=x,M=_+c.shift(),x=C=y+c.shift(),_=(k=M+c.shift())+c.shift(),e.U.P.curveTo(l,y,M,C,k,x,_);else if(H=="o27")for(c.length%2&&(_+=c.shift());c.length>0;)M=_,C=(y=x+c.shift())+c.shift(),k=M+c.shift(),x=C+c.shift(),_=k,e.U.P.curveTo(l,y,M,C,k,x,_);else if(H=="o10"||H=="o29"){var Ae=H=="o10"?o:a;if(c.length==0)console.debug("error: empty stack");else{var be=c.pop(),pe=Ae.Subrs[be+Ae.Bias];s.x=x,s.y=_,s.nStems=u,s.haveWidth=d,s.width=h,s.open=p,e.U._drawCFF(pe,s,a,o,l),x=s.x,_=s.y,u=s.nStems,d=s.haveWidth,h=s.width,p=s.open}}else if(H=="o30"||H=="o31"){var ge=c.length,Te=(ae=0,H=="o31");for(ae+=ge-(K=-3&ge);ae>>1|(21845&p)<<1;g=(61680&(g=(52428&g)>>>2|(13107&g)<<2))>>>4|(3855&g)<<4,h[p]=((65280&g)>>>8|(255&g)<<8)>>>1}var x=function(H,K,W){for(var J=H.length,ie=0,ae=new t(K);ie>>oe]=fe}return Q},_=new e(288);for(p=0;p<144;++p)_[p]=8;for(p=144;p<256;++p)_[p]=9;for(p=256;p<280;++p)_[p]=7;for(p=280;p<288;++p)_[p]=8;var y=new e(32);for(p=0;p<32;++p)y[p]=5;var M=x(_,9),C=x(y,5),k=function(H){for(var K=H[0],W=1;WK&&(K=H[W]);return K},B=function(H,K,W){var J=K/8|0;return(H[J]|H[J+1]<<8)>>(7&K)&W},U=function(H,K){var W=K/8|0;return(H[W]|H[W+1]<<8|H[W+2]<<16)>>(7&K)},z=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],O=function(H,K,W){var J=new Error(K||z[H]);if(J.code=H,Error.captureStackTrace&&Error.captureStackTrace(J,O),!W)throw J;return J},V=function(H,K,W){var J=H.length;if(!J||W&&!W.l&&J<5)return K||new e(0);var ie=!K||W,ae=!W||W.i;W||(W={}),K||(K=new e(3*J));var Q,re=function(Ft){var tt=K.length;if(Ft>tt){var Pe=new e(Math.max(2*tt,Ft));Pe.set(K),K=Pe}},oe=W.f||0,fe=W.p||0,ee=W.b||0,me=W.l,Ae=W.d,be=W.m,pe=W.n,ge=8*J;do{if(!me){W.f=oe=B(H,fe,1);var Te=B(H,fe+1,3);if(fe+=3,!Te){var ze=H[(Lt=((Q=fe)/8|0)+(7&Q&&1)+4)-4]|H[Lt-3]<<8,Xe=Lt+ze;if(Xe>J){ae&&O(0);break}ie&&re(ee+ze),K.set(H.subarray(Lt,Xe),ee),W.b=ee+=ze,W.p=fe=8*Xe;continue}if(Te==1)me=M,Ae=C,be=9,pe=5;else if(Te==2){var Qe=B(H,fe,31)+257,ot=B(H,fe+10,15)+4,bt=Qe+B(H,fe+5,31)+1;fe+=14;for(var ht=new e(bt),Ce=new e(19),lt=0;lt>>4)<16)ht[lt++]=Lt;else{var Ht=0,Se=0;for(Lt==16?(Se=3+B(H,fe,3),fe+=2,Ht=ht[lt-1]):Lt==17?(Se=3+B(H,fe,7),fe+=3):Lt==18&&(Se=11+B(H,fe,127),fe+=7);Se--;)ht[lt++]=Ht}}var _t=ht.subarray(0,Qe),It=ht.subarray(Qe);be=k(_t),pe=k(It),me=x(_t,be),Ae=x(It,pe)}else O(1);if(fe>ge){ae&&O(0);break}}ie&&re(ee+131072);for(var De=(1<>>4;if((fe+=15&Ht)>ge){ae&&O(0);break}if(Ht||O(2),We<256)K[ee++]=We;else{if(We==256){Ve=fe,me=null;break}var ct=We-254;if(We>264){var vt=i[lt=We-257];ct=B(H,fe,(1<>>4;if(Ut||O(3),fe+=15&Ut,It=d[dt],dt>3&&(vt=s[dt],It+=U(H,fe)&(1<ge){ae&&O(0);break}ie&&re(ee+131072);for(var mt=ee+ct;eeFt.length)&&(Pe=Ft.length);var nt=new(Ft instanceof t?t:Ft instanceof r?r:e)(Pe-tt);return nt.set(Ft.subarray(tt,Pe)),nt}(K,0,ee)},$=new e(0),G=typeof TextDecoder<"u"&&new TextDecoder;try{G.decode($,{stream:!0})}catch{}return n.convert_streams=function(H){var K=new DataView(H),W=0;function J(){var Qe=K.getUint16(W);return W+=2,Qe}function ie(){var Qe=K.getUint32(W);return W+=4,Qe}function ae(Qe){ze.setUint16(Xe,Qe),Xe+=2}function Q(Qe){ze.setUint32(Xe,Qe),Xe+=4}for(var re={signature:ie(),flavor:ie(),length:ie(),numTables:J(),reserved:J(),totalSfntSize:ie(),majorVersion:J(),minorVersion:J(),metaOffset:ie(),metaLength:ie(),metaOrigLength:ie(),privOffset:ie(),privLength:ie()},oe=0;Math.pow(2,oe)<=re.numTables;)oe++;oe--;for(var fe=16*Math.pow(2,oe),ee=16*re.numTables-fe,me=12,Ae=[],be=0;be{let[H,K]=G.split("+");H=parseInt(H,36),K=K?parseInt(K,36):0,u.set($+=H,O[V]);for(let W=K;W--;)u.set(++$,O[V])})}}return u.get(z)||c}const h=1,p=2,g=3,x=4,_=[null,"isol","init","fina","medi"];function y(z){const O=new Uint8Array(z.length);let V=c,$=h,G=-1;for(let H=0;H65535&&H++)}return O}function M(z,O){const V=[];for(let G=0;G65535&&G++,V.push(n.U.codeToGlyph(z,H))}const $=z.GSUB;if($){const{lookupList:G,featureList:H}=$;let K;const W=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws|ccmp)$/,J=[];H.forEach(ie=>{if(W.test(ie.tag))for(let ae=0;ae=0;J--)if(O[J]!==-1&&(!W||W(O[J])))return J;return-1}function H(W){return k(z,W)===1}function K(W,J){for(let ie=0;ie<3;ie++)V[J*3+ie]+=W[ie]||0}}function k(z,O){const V=z.GDEF&&z.GDEF.glyphClassDef;return V?n.U._getGlyphClass(O,V):0}function B(...z){for(let O=0;O0},forEachGlyph(W,J,ie,ae){let Q=0;const re=1/K.unitsPerEm*J,oe=M(z,W);let fe=0;const ee=C(z,oe);return oe.forEach((me,Ae)=>{if(me!==-1){let be=O[me];if(!be){const{cmds:pe,crds:ge}=n.U.glyphToPath(z,me);let Te="",ze=0;for(let ht=0,Ce=pe.length;ht1?",":"")+ge[ze++]}let Xe,Qe,ot,bt;if(ge.length){Xe=Qe=1/0,ot=bt=-1/0;for(let ht=0,Ce=ge.length;htot&&(ot=lt),ft>bt&&(bt=ft)}}else Xe=ot=Qe=bt=0;be=O[me]={index:me,advanceWidth:z.hmtx.aWidth[me],xMin:Xe,yMin:Qe,xMax:ot,yMax:bt,path:Te}}ae.call(null,be,Q+ee[Ae*3]*re,ee[Ae*3+1]*re,fe),Q+=ee[Ae*3+2]*re,ie&&(Q+=ie*J)}fe+=W.codePointAt(fe)>65535?2:1}),Q}};return K}return function(O){const V=new Uint8Array(O,0,4),$=n._bin.readASCII(V,0,4);if($==="wOFF")O=e(O);else if($==="wOF2")throw new Error("woff2 fonts not supported");return U(n.parse(O)[0])}}const bbt=K3({name:"Typr Font Parser",dependencies:[xbt,vbt,ybt],init(n,e,t){const r=n(),i=e();return t(r,i)}});/*! Custom bundle of @unicode-font-resolver/client v1.0.2 (https://github.com/lojjic/unicode-font-resolver) for use in Troika text rendering. Original MIT license applies */function _bt(){return function(n){var e=function(){this.buckets=new Map};e.prototype.add=function(C){var k=C>>5;this.buckets.set(k,(this.buckets.get(k)||0)|1<<(31&C))},e.prototype.has=function(C){var k=this.buckets.get(C>>5);return k!==void 0&&(k&1<<(31&C))!=0},e.prototype.serialize=function(){var C=[];return this.buckets.forEach(function(k,B){C.push((+B).toString(36)+":"+k.toString(36))}),C.join(",")},e.prototype.deserialize=function(C){var k=this;this.buckets.clear(),C.split(",").forEach(function(B){var U=B.split(":");k.buckets.set(parseInt(U[0],36),parseInt(U[1],36))})};var t=Math.pow(2,8),r=t-1,i=~r;function s(C){var k=function(U){return U&i}(C).toString(16),B=function(U){return(U&i)+t-1}(C).toString(16);return"codepoint-index/plane"+(C>>16)+"/"+k+"-"+B+".json"}function a(C,k){var B=C&r,U=k.codePointAt(B/6|0);return((U=(U||48)-48)&1<65535&&(fe++,oe=fe)},oe=0;oe65535&&(me++,ee=me)},ee=0;ee65535&&(me++,H[me]=H[me-1])}return{fontUrls:Array.from(G.keys()),chars:H}})},Object.defineProperty(n,"__esModule",{value:!0}),n}({})}function wbt(n,e){const t=Object.create(null),r=Object.create(null);function i(a,o){const l=c=>{console.error(`Failure loading font ${a}`,c)};try{const c=new XMLHttpRequest;c.open("get",a,!0),c.responseType="arraybuffer",c.onload=function(){if(c.status>=400)l(new Error(c.statusText));else if(c.status>0)try{const u=n(c.response);u.src=a,o(u)}catch(u){l(u)}},c.onerror=l,c.send()}catch(c){l(c)}}function s(a,o){let l=t[a];l?o(l):r[a]?r[a].push(o):(r[a]=[o],i(a,c=>{c.src=a,t[a]=c,r[a].forEach(u=>u(c)),delete r[a]}))}return function(a,o,{lang:l,fonts:c=[],style:u="normal",weight:d="normal",unicodeFontsURL:h}={}){const p=new Uint8Array(a.length),g=[];a.length||M();const x=new Map,_=[];if(u!=="italic"&&(u="normal"),typeof d!="number"&&(d=d==="bold"?700:400),c&&!Array.isArray(c)&&(c=[c]),c=c.slice().filter(k=>!k.lang||k.lang.test(l)).reverse(),c.length){let z=0;(function O(V=0){for(let $=V,G=a.length;$0&&/\s/.test(a[$]))p[$]=p[$-1],z===2&&(_[_.length-1][1]=$);else for(let K=p[$],W=c.length;K<=W;K++)if(K===W){const J=z===2?_[_.length-1]:_[_.length]=[$,$];J[1]=$,z=2}else{p[$]=K;const{src:J,unicodeRange:ie}=c[K];if(!ie||C(H,ie)){const ae=t[J];if(!ae){s(J,()=>{O($)});return}if(ae.supportsCodePoint(H)){let Q=x.get(ae);typeof Q!="number"&&(Q=g.length,g.push(ae),x.set(ae,Q)),p[$]=Q,z=1;break}}}H>65535&&$+1a.substring(B[0],B[1]+1)).join(` `);e.getFontsForString(k,{lang:l||void 0,style:u,weight:d,dataUrl:h}).then(({fontUrls:B,chars:U})=>{const z=g.length;let O=0;_.forEach($=>{for(let G=0,H=$[1]-$[0];G<=H;G++)p[$[0]+G]=U[O++]+z;O++});let V=0;B.forEach(($,G)=>{s($,H=>{g[G+z]=H,++V===B.length&&M()})})})}else M()}function M(){o({chars:p,fonts:g})}function C(k,B){for(let U=0;U{let V,$;const G=[];for(let H=0;H-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),g=g.replace(/\r\n/g,` `).replace(/\r/g,` `)),M=+M,B=+B,z=+z,U=U||"normal",$=+$,a({text:g,lang:_,style:k,weight:C,fonts:typeof x=="string"?[{src:x}]:x,unicodeFontsURL:ie,preResolvedFonts:ae},Ae=>{me.fontLoad=d()-ee;const be=isFinite(z);let pe=null,ge=null,Te=null,ze=null,Xe=null,Qe=null,ot=null,bt=null,ht=0,Ce=0,lt=G!=="nowrap";const ft=new Map,et=d();let At=$,Lt=0,st=new h;const Ht=[st];Ae.forEach(ue=>{const{fontObj:Ve}=ue,{ascender:We,descender:ct,unitsPerEm:vt,lineGap:Ut,capHeight:dt,xHeight:mt}=Ve;let Ft=ft.get(Ve);if(!Ft){const yt=M/vt,Qt=U==="normal"?(We-ct+Ut)*yt:U*M,Be=(Qt-(We-ct)*yt)/2,pt=Math.min(Qt,(We-ct)*yt),rt=(We+ct)/2*yt+pt/2;Ft={index:ft.size,src:Ve.src,fontObj:Ve,fontSizeMult:yt,unitsPerEm:vt,ascender:We*yt,descender:ct*yt,capHeight:dt*yt,xHeight:mt*yt,lineHeight:Qt,baseline:-Be-We*yt,caretTop:rt,caretBottom:rt-pt},ft.set(Ve,Ft)}const{fontSizeMult:tt}=Ft,Pe=g.slice(ue.start,ue.end+1);let nt,qe;Ve.forEachGlyph(Pe,M,B,(yt,Qt,Be,pt)=>{Qt+=Lt,pt+=ue.start,nt=Qt,qe=yt;const rt=g.charAt(pt),zt=yt.advanceWidth*tt,Yt=st.count;let Bt;if("isEmpty"in yt||(yt.isWhitespace=!!rt&&new RegExp(i).test(rt),yt.canBreakAfter=!!rt&&s.test(rt),yt.isEmpty=yt.xMin===yt.xMax||yt.yMin===yt.yMax||r.test(rt)),!yt.isWhitespace&&!yt.isEmpty&&Ce++,lt&&be&&!yt.isWhitespace&&Qt+zt+At>z&&Yt){if(st.glyphAt(Yt-1).glyphObj.canBreakAfter)Bt=new h,At=-Qt;else for(let ut=Yt;ut--;)if(ut===0&&H==="break-word"){Bt=new h,At=-Qt;break}else if(st.glyphAt(ut).glyphObj.canBreakAfter){Bt=st.splitAt(ut+1);const Gt=Bt.glyphAt(0).x;At-=Gt;for(let it=Bt.count;it--;)Bt.glyphAt(it).x-=Gt;break}Bt&&(st.isSoftWrapped=!0,st=Bt,Ht.push(st),ht=z)}let $e=st.glyphAt(st.count);$e.glyphObj=yt,$e.x=Qt+At,$e.y=Be,$e.width=zt,$e.charIndex=pt,$e.fontData=Ft,rt===` `&&(st=new h,Ht.push(st),At=-(Qt+zt+B*M)+$)}),Lt=nt+qe.advanceWidth*tt+B*M});let Se=0;Ht.forEach(ue=>{let Ve=!0;for(let We=ue.count;We--;){const ct=ue.glyphAt(We);Ve&&!ct.glyphObj.isWhitespace&&(ue.width=ct.x+ct.width,ue.width>ht&&(ht=ue.width),Ve=!1);let{lineHeight:vt,capHeight:Ut,xHeight:dt,baseline:mt}=ct.fontData;vt>ue.lineHeight&&(ue.lineHeight=vt);const Ft=mt-ue.baseline;Ft<0&&(ue.baseline+=Ft,ue.cap+=Ft,ue.ex+=Ft),ue.cap=Math.max(ue.cap,ue.baseline+Ut),ue.ex=Math.max(ue.ex,ue.baseline+dt)}ue.baseline-=Se,ue.cap-=Se,ue.ex-=Se,Se+=ue.lineHeight});let _t=0,It=0;if(K&&(typeof K=="number"?_t=-K:typeof K=="string"&&(_t=-ht*(K==="left"?0:K==="center"?.5:K==="right"?1:c(K)))),W&&(typeof W=="number"?It=-W:typeof W=="string"&&(It=W==="top"?0:W==="top-baseline"?-Ht[0].baseline:W==="top-cap"?-Ht[0].cap:W==="top-ex"?-Ht[0].ex:W==="middle"?Se/2:W==="bottom"?Se:W==="bottom-baseline"?-Ht[Ht.length-1].baseline:c(W)*Se)),!J){const ue=e.getEmbeddingLevels(g,O);pe=new Uint16Array(Ce),ge=new Uint8Array(Ce),Te=new Float32Array(Ce*2),ze={},ot=[1/0,1/0,-1/0,-1/0],bt=[],Q&&(Qe=new Float32Array(g.length*4)),oe&&(Xe=new Uint8Array(Ce*3));let Ve=0,We=-1,ct=-1,vt,Ut;if(Ht.forEach((dt,mt)=>{let{count:Ft,width:tt}=dt;if(Ft>0){let Pe=0;for(let pt=Ft;pt--&&dt.glyphAt(pt).glyphObj.isWhitespace;)Pe++;let nt=0,qe=0;if(V==="center")nt=(ht-tt)/2;else if(V==="right")nt=ht-tt;else if(V==="justify"&&dt.isSoftWrapped){let pt=0;for(let rt=Ft-Pe;rt--;)dt.glyphAt(rt).glyphObj.isWhitespace&&pt++;qe=(ht-tt)/pt}if(qe||nt){let pt=0;for(let rt=0;rt=rt){let ut=$e,Gt=$e;for(;Gtzt)break;GtQt=pt;for(let pt=0;pt1&&u(Qe,We,it),We=Bt}if(oe){const{charIndex:Bt}=rt;for(;Bt>ct;)ct++,oe.hasOwnProperty(ct)&&(Ut=oe[ct])}if(!Qt.isWhitespace&&!Qt.isEmpty){const Bt=Ve++,{fontSizeMult:$e,src:ut,index:Gt}=rt.fontData,it=ze[ut]||(ze[ut]={});it[zt]||(it[zt]={path:Qt.path,pathBounds:[Qt.xMin,Qt.yMin,Qt.xMax,Qt.yMax]});const Ot=rt.x+_t,nn=rt.y+dt.baseline+It;Te[Bt*2]=Ot,Te[Bt*2+1]=nn;const Nt=Ot+Qt.xMin*$e,m=nn+Qt.yMin*$e,Ie=Ot+Qt.xMax*$e,An=nn+Qt.yMax*$e;Ntot[2]&&(ot[2]=Ie),An>ot[3]&&(ot[3]=An),Bt%re===0&&(vt={start:Bt,end:Bt,rect:[1/0,1/0,-1/0,-1/0]},bt.push(vt)),vt.end++;const Ln=vt.rect;if(NtLn[2]&&(Ln[2]=Ie),An>Ln[3]&&(Ln[3]=An),pe[Bt]=zt,ge[Bt]=Gt,oe){const Rn=Bt*3;Xe[Rn]=Ut>>16&255,Xe[Rn+1]=Ut>>8&255,Xe[Rn+2]=Ut&255}}}}}),Qe){const dt=g.length-We;dt>1&&u(Qe,We,dt)}}const De=[];ft.forEach(({index:ue,src:Ve,unitsPerEm:We,ascender:ct,descender:vt,lineHeight:Ut,capHeight:dt,xHeight:mt})=>{De[ue]={src:Ve,unitsPerEm:We,ascender:ct,descender:vt,lineHeight:Ut,capHeight:dt,xHeight:mt}}),me.typesetting=d()-et,fe({glyphIds:pe,glyphFontIndices:ge,glyphPositions:Te,glyphData:ze,fontData:De,caretPositions:Qe,glyphColors:Xe,chunkedBounds:bt,fontSize:M,topBaseline:It+Ht[0].baseline,blockBounds:[_t,It-Se,_t+ht,It],visibleBounds:ot,timings:me})})}function l(g,x){o({...g,metricsOnly:!0},_=>{const[y,M,C,k]=_.blockBounds;x({width:C-y,height:k-M})})}function c(g){let x=g.match(/^([\d.]+)%$/),_=x?parseFloat(x[1]):NaN;return isNaN(_)?0:_/100}function u(g,x,_){const y=g[x*4],M=g[x*4+1],C=g[x*4+2],k=g[x*4+3],B=(M-y)/_;for(let U=0;U<_;U++){const z=(x+U)*4;g[z]=y+B*U,g[z+1]=y+B*(U+1),g[z+2]=C,g[z+3]=k}}function d(){return(self.performance||Date).now()}function h(){this.data=[]}const p=["glyphObj","x","y","width","charIndex","fontData"];return h.prototype={width:0,lineHeight:0,baseline:0,cap:0,ex:0,isSoftWrapped:!1,get count(){return Math.ceil(this.data.length/p.length)},glyphAt(g){let x=h.flyweight;return x.data=this.data,x.index=g,x},splitAt(g){let x=new h;return x.data=this.data.splice(g*p.length),x}},h.flyweight=p.reduce((g,x,_,y)=>(Object.defineProperty(g,x,{get(){return this.data[this.index*p.length+_]},set(M){this.data[this.index*p.length+_]=M}}),g),{data:null,index:0}),{typeset:o,measure:l}}const $x=()=>(self.performance||Date).now(),aL=C4e();let kde;function Ebt(n,e,t,r,i,s,a,o,l,c,u=!0){return u?Mbt(n,e,t,r,i,s,a,o,l,c).then(null,d=>(kde||(console.warn("WebGL SDF generation failed, falling back to JS",d),kde=!0),Dde(n,e,t,r,i,s,a,o,l,c))):Dde(n,e,t,r,i,s,a,o,l,c)}const ON=[],Nbt=5;let kq=0;function R4e(){const n=$x();for(;ON.length&&$x()-nnew Promise((e,t)=>{ON.push(()=>{const r=$x();try{aL.webgl.generateIntoCanvas(...n),e({timing:$x()-r})}catch(i){t(i)}}),kq||(kq=setTimeout(R4e,0))}),Cbt=4,Pbt=2e3,Ide={};let Rbt=0;function Dde(n,e,t,r,i,s,a,o,l,c){const u="TroikaTextSDFGenerator_JS_"+Rbt++%Cbt;let d=Ide[u];return d||(d=Ide[u]={workerModule:K3({name:u,workerId:u,dependencies:[C4e,$x],init(h,p){const g=h().javascript.generate;return function(...x){const _=p();return{textureData:g(...x),timing:p()-_}}},getTransferables(h){return[h.textureData.buffer]}}),requests:0,idleTimer:null}),d.requests++,clearTimeout(d.idleTimer),d.workerModule(n,e,t,r,i,s).then(({textureData:h,timing:p})=>{const g=$x(),x=new Uint8Array(h.length*4);for(let _=0;_{lbt(u)},Pbt)),{timing:p}})}function Lbt(n){n._warm||(aL.webgl.isSupported(n),n._warm=!0)}const kbt=aL.webglUtils.resizeWebGLCanvasWithoutClearing,V5={unicodeFontsURL:null,sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},Ibt=new Fn;function Tb(){return(self.performance||Date).now()}const Ode=Object.create(null);function L4e(n,e){n=jbt({},n);const t=Tb(),r=[];if(n.font&&r.push({label:"user",src:Fbt(n.font)}),n.font=r,n.text=""+n.text,n.sdfGlyphSize=n.sdfGlyphSize||V5.sdfGlyphSize,n.unicodeFontsURL=n.unicodeFontsURL||V5.unicodeFontsURL,n.colorRanges!=null){let h={};for(let p in n.colorRanges)if(n.colorRanges.hasOwnProperty(p)){let g=n.colorRanges[p];typeof g!="number"&&(g=Ibt.set(g).getHex()),h[p]=g}n.colorRanges=h}Object.freeze(n);const{textureWidth:i,sdfExponent:s}=V5,{sdfGlyphSize:a}=n,o=i/a*4;let l=Ode[a];if(!l){const h=document.createElement("canvas");h.width=i,h.height=a*256/o,l=Ode[a]={glyphCount:0,sdfGlyphSize:a,sdfCanvas:h,sdfTexture:new Aa(h,void 0,void 0,void 0,Ci,Ci),contextLost:!1,glyphsByFont:new Map},l.sdfTexture.generateMipmaps=!1,Dbt(l)}const{sdfTexture:c,sdfCanvas:u}=l;D4e(n).then(h=>{const{glyphIds:p,glyphFontIndices:g,fontData:x,glyphPositions:_,fontSize:y,timings:M}=h,C=[],k=new Float32Array(p.length*4);let B=0,U=0;const z=Tb(),O=x.map(K=>{let W=l.glyphsByFont.get(K.src);return W||l.glyphsByFont.set(K.src,W=new Map),W});p.forEach((K,W)=>{const J=g[W],{src:ie,unitsPerEm:ae}=x[J];let Q=O[J].get(K);if(!Q){const{path:me,pathBounds:Ae}=h.glyphData[ie][K],be=Math.max(Ae[2]-Ae[0],Ae[3]-Ae[1])/a*(V5.sdfMargin*a+.5),pe=l.glyphCount++,ge=[Ae[0]-be,Ae[1]-be,Ae[2]+be,Ae[3]+be];O[J].set(K,Q={path:me,atlasIndex:pe,sdfViewBox:ge}),C.push(Q)}const{sdfViewBox:re}=Q,oe=_[U++],fe=_[U++],ee=y/ae;k[B++]=oe+re[0]*ee,k[B++]=fe+re[1]*ee,k[B++]=oe+re[2]*ee,k[B++]=fe+re[3]*ee,p[W]=Q.atlasIndex}),M.quads=(M.quads||0)+(Tb()-z);const V=Tb();M.sdf={};const $=u.height,G=Math.ceil(l.glyphCount/o),H=Math.pow(2,Math.ceil(Math.log2(G*a)));H>$&&(console.info(`Increasing SDF texture size ${$}->${H}`),kbt(u,i,H),c.dispose()),Promise.all(C.map(K=>k4e(K,l,n.gpuAccelerateSDF).then(({timing:W})=>{M.sdf[K.atlasIndex]=W}))).then(()=>{C.length&&!l.contextLost&&(I4e(l),c.needsUpdate=!0),M.sdfTotal=Tb()-V,M.total=Tb()-t,e(Object.freeze({parameters:n,sdfTexture:c,sdfGlyphSize:a,sdfExponent:s,glyphBounds:k,glyphAtlasIndices:p,glyphColors:h.glyphColors,caretPositions:h.caretPositions,chunkedBounds:h.chunkedBounds,ascender:h.ascender,descender:h.descender,lineHeight:h.lineHeight,capHeight:h.capHeight,xHeight:h.xHeight,topBaseline:h.topBaseline,blockBounds:h.blockBounds,visibleBounds:h.visibleBounds,timings:h.timings}))})}),Promise.resolve().then(()=>{l.contextLost||Lbt(u)})}function k4e({path:n,atlasIndex:e,sdfViewBox:t},{sdfGlyphSize:r,sdfCanvas:i,contextLost:s},a){if(s)return Promise.resolve({timing:-1});const{textureWidth:o,sdfExponent:l}=V5,c=Math.max(t[2]-t[0],t[3]-t[1]),u=Math.floor(e/4),d=u%(o/r)*r,h=Math.floor(u/(o/r))*r,p=e%4;return Ebt(r,r,n,t,c,l,i,d,h,p,a)}function Dbt(n){const e=n.sdfCanvas;e.addEventListener("webglcontextlost",t=>{console.log("Context Lost",t),t.preventDefault(),n.contextLost=!0}),e.addEventListener("webglcontextrestored",t=>{console.log("Context Restored",t),n.contextLost=!1;const r=[];n.glyphsByFont.forEach(i=>{i.forEach(s=>{r.push(k4e(s,n,!0))})}),Promise.all(r).then(()=>{I4e(n),n.sdfTexture.needsUpdate=!0})})}function Obt({font:n,characters:e,sdfGlyphSize:t},r){let i=Array.isArray(e)?e.join(` `):""+e;L4e({font:n,sdfGlyphSize:t,text:i},r)}function jbt(n,e){for(let t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}let OE;function Fbt(n){return OE||(OE=typeof document>"u"?{}:document.createElement("a")),OE.href=n,OE.href}function I4e(n){if(typeof createImageBitmap!="function"){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:e,sdfTexture:t}=n,{width:r,height:i}=e,s=n.sdfCanvas.getContext("webgl");let a=t.image.data;(!a||a.length!==r*i*4)&&(a=new Uint8Array(r*i*4),t.image={width:r,height:i,data:a},t.flipY=!1,t.isDataTexture=!0),s.readPixels(0,0,r,i,s.RGBA,s.UNSIGNED_BYTE,a)}}const Bbt=K3({name:"Typesetter",dependencies:[Tbt,Sbt,ubt],init(n,e,t){return n(e,t())}}),D4e=K3({name:"Typesetter",dependencies:[Bbt],init(n){return function(e){return new Promise(t=>{n.typeset(e,t)})}},getTransferables(n){const e=[];for(let t in n)n[t]&&n[t].buffer&&e.push(n[t].buffer);return e}});D4e.onMainThread;const jde={};function Ubt(n){let e=jde[n];return e||(e=jde[n]=new Nm(1,1,n,n).translate(.5,.5,0)),e}const zbt="aTroikaGlyphBounds",Fde="aTroikaGlyphIndex",Vbt="aTroikaGlyphColor";class qbt extends d6{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new Vo,this.boundingBox=new So}computeBoundingSphere(){}computeBoundingBox(){}set detail(e){if(e!==this._detail){this._detail=e,(typeof e!="number"||e<1)&&(e=1);let t=Ubt(e);["position","normal","uv"].forEach(r=>{this.attributes[r]=t.attributes[r].clone()}),this.setIndex(t.getIndex().clone())}}get detail(){return this._detail}set curveRadius(e){e!==this._curveRadius&&(this._curveRadius=e,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(e,t,r,i,s){this.updateAttributeData(zbt,e,4),this.updateAttributeData(Fde,t,1),this.updateAttributeData(Vbt,s,3),this._blockBounds=r,this._chunkedBounds=i,this.instanceCount=t.length,this._updateBounds()}_updateBounds(){const e=this._blockBounds;if(e){const{curveRadius:t,boundingBox:r}=this;if(t){const{PI:i,floor:s,min:a,max:o,sin:l,cos:c}=Math,u=i/2,d=i*2,h=Math.abs(t),p=e[0]/h,g=e[2]/h,x=s((p+u)/d)!==s((g+u)/d)?-h:a(l(p)*h,l(g)*h),_=s((p-u)/d)!==s((g-u)/d)?h:o(l(p)*h,l(g)*h),y=s((p+i)/d)!==s((g+i)/d)?h*2:o(h-c(p)*h,h-c(g)*h);r.min.set(x,e[1],t<0?-y:0),r.max.set(_,e[3],t<0?0:y)}else r.min.set(e[0],e[1],0),r.max.set(e[2],e[3],0);r.getBoundingSphere(this.boundingSphere)}}applyClipRect(e){let t=this.getAttribute(Fde).count,r=this._chunkedBounds;if(r)for(let i=r.length;i--;){t=r[i].end;let s=r[i].rect;if(s[1]e.y&&s[0]e.x)break}this.instanceCount=t}updateAttributeData(e,t,r){const i=this.getAttribute(e);t?i&&i.array.length===t.length?(i.array.set(t),i.needsUpdate=!0):(this.setAttribute(e,new jd(t,r)),delete this._maxInstanceCount,this.dispose()):i&&this.deleteAttribute(e)}}const Gbt=` uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform vec4 uTroikaTotalBounds; uniform vec4 uTroikaClipRect; uniform mat3 uTroikaOrient; uniform bool uTroikaUseGlyphColors; uniform float uTroikaEdgeOffset; uniform float uTroikaBlurRadius; uniform vec2 uTroikaPositionOffset; uniform float uTroikaCurveRadius; attribute vec4 aTroikaGlyphBounds; attribute float aTroikaGlyphIndex; attribute vec3 aTroikaGlyphColor; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec3 vTroikaGlyphColor; varying vec2 vTroikaGlyphDimensions; `,Hbt=` vec4 bounds = aTroikaGlyphBounds; bounds.xz += uTroikaPositionOffset.x; bounds.yw -= uTroikaPositionOffset.y; vec4 outlineBounds = vec4( bounds.xy - uTroikaEdgeOffset - uTroikaBlurRadius, bounds.zw + uTroikaEdgeOffset + uTroikaBlurRadius ); vec4 clippedBounds = vec4( clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw), clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw) ); vec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy); position.xy = mix(bounds.xy, bounds.zw, clippedXY); uv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy); float rad = uTroikaCurveRadius; if (rad != 0.0) { float angle = position.x / rad; position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad); normal.xz = vec2(sin(angle), cos(angle)); } position = uTroikaOrient * position; normal = uTroikaOrient * normal; vTroikaGlyphUV = clippedXY.xy; vTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]); float txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize; vec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize; vec2 txStartUV = txUvPerSquare * vec2( mod(floor(aTroikaGlyphIndex / 4.0), txCols), floor(floor(aTroikaGlyphIndex / 4.0) / txCols) ); vTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare); vTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0); `,$bt=` uniform sampler2D uTroikaSDFTexture; uniform vec2 uTroikaSDFTextureSize; uniform float uTroikaSDFGlyphSize; uniform float uTroikaSDFExponent; uniform float uTroikaEdgeOffset; uniform float uTroikaFillOpacity; uniform float uTroikaBlurRadius; uniform vec3 uTroikaStrokeColor; uniform float uTroikaStrokeWidth; uniform float uTroikaStrokeOpacity; uniform bool uTroikaSDFDebug; varying vec2 vTroikaGlyphUV; varying vec4 vTroikaTextureUVBounds; varying float vTroikaTextureChannel; varying vec2 vTroikaGlyphDimensions; float troikaSdfValueToSignedDistance(float alpha) { // Inverse of exponential encoding in webgl-sdf-generator float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y); float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension; float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0); return signedDist; } float troikaGlyphUvToSdfValue(vec2 glyphUV) { vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV); vec4 rgba = texture2D(uTroikaSDFTexture, textureUV); float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1 return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a; } float troikaGlyphUvToDistance(vec2 uv) { return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv)); } float troikaGetAADist() { #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300 return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5; #else return vTroikaGlyphDimensions.x / 64.0; #endif } float troikaGetFragDistValue() { vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize); float distance = troikaGlyphUvToDistance(clampedGlyphUV); // Extrapolate distance when outside bounds: distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions); return distance; } float troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) { #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL) float alpha = step(-distanceOffset, -distance); #else float alpha = smoothstep( distanceOffset + aaDist, distanceOffset - aaDist, distance ); #endif return alpha; } `,Wbt=` float aaDist = troikaGetAADist(); float fragDistance = troikaGetFragDistValue(); float edgeAlpha = uTroikaSDFDebug ? troikaGlyphUvToSdfValue(vTroikaGlyphUV) : troikaGetEdgeAlpha(fragDistance, uTroikaEdgeOffset, max(aaDist, uTroikaBlurRadius)); #if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL) vec4 fillRGBA = gl_FragColor; fillRGBA.a *= uTroikaFillOpacity; vec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity); if (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb; gl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep( -uTroikaStrokeWidth - aaDist, -uTroikaStrokeWidth + aaDist, fragDistance )); gl_FragColor.a *= edgeAlpha; #endif if (edgeAlpha == 0.0) { discard; } `;function Xbt(n){const e=Lq(n,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new en},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new gr(0,0,0,0)},uTroikaClipRect:{value:new gr(0,0,0,0)},uTroikaEdgeOffset:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new en},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new Fn},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new ni},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:Gbt,vertexTransform:Hbt,fragmentDefs:$bt,fragmentColorTransform:Wbt,customRewriter({vertexShader:t,fragmentShader:r}){let i=/\buniform\s+vec3\s+diffuse\b/;return i.test(r)&&(r=r.replace(i,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),i.test(t)||(t=t.replace(P4e,`uniform vec3 diffuse; $& vTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse; `))),{vertexShader:t,fragmentShader:r}}});return e.transparent=!0,e.forceSinglePass=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}const DY=new oc({color:16777215,side:ao,transparent:!0}),Bde=8421504,Ude=new ir,jE=new Fe,$B=new Fe,h5=[],Ybt=new Fe,WB="+x+y";function zde(n){return Array.isArray(n)?n[0]:n}let O4e=()=>{const n=new ui(new Nm(1,1),DY);return O4e=()=>n,n},j4e=()=>{const n=new ui(new Nm(1,1,32,1),DY);return j4e=()=>n,n};const Zbt={type:"syncstart"},Qbt={type:"synccomplete"},F4e=["font","fontSize","fontStyle","fontWeight","lang","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],Kbt=F4e.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");let B4e=class extends ui{constructor(){const e=new qbt;super(e,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.unicodeFontsURL=null,this.fontSize=.1,this.fontWeight="normal",this.fontStyle="normal",this.lang=null,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=Bde,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=WB,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(e){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(e):(this._isSyncing=!0,this.dispatchEvent(Zbt),L4e({text:this.text,font:this.font,lang:this.lang,fontSize:this.fontSize||.1,fontWeight:this.fontWeight||"normal",fontStyle:this.fontStyle||"normal",letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF,unicodeFontsURL:this.unicodeFontsURL},t=>{this._isSyncing=!1,this._textRenderInfo=t,this.geometry.updateGlyphs(t.glyphBounds,t.glyphAtlasIndices,t.blockBounds,t.chunkedBounds,t.glyphColors);const r=this._queuedSyncs;r&&(this._queuedSyncs=null,this._needsSync=!0,this.sync(()=>{r.forEach(i=>i&&i())})),this.dispatchEvent(Qbt),e&&e()})))}onBeforeRender(e,t,r,i,s,a){this.sync(),s.isTroikaTextMaterial&&this._prepareForRender(s)}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}createDerivedMaterial(e){return Xbt(e)}get material(){let e=this._derivedMaterial;const t=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=DY.clone());if((!e||!e.isDerivedFrom(t))&&(e=this._derivedMaterial=this.createDerivedMaterial(t),t.addEventListener("dispose",function r(){t.removeEventListener("dispose",r),e.dispose()})),this.hasOutline()){let r=e._outlineMtl;return r||(r=e._outlineMtl=Object.create(e,{id:{value:e.id+.1}}),r.isTextOutlineMaterial=!0,r.depthWrite=!1,r.map=null,e.addEventListener("dispose",function i(){e.removeEventListener("dispose",i),r.dispose()})),[r,e]}else return e}set material(e){e&&e.isTroikaTextMaterial?(this._derivedMaterial=e,this._baseMaterial=e.baseMaterial):this._baseMaterial=e}hasOutline(){return!!(this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY)}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(e){this.geometry.detail=e}get curveRadius(){return this.geometry.curveRadius}set curveRadius(e){this.geometry.curveRadius=e}get customDepthMaterial(){return zde(this.material).getDepthMaterial()}set customDepthMaterial(e){}get customDistanceMaterial(){return zde(this.material).getDistanceMaterial()}set customDistanceMaterial(e){}_prepareForRender(e){const t=e.isTextOutlineMaterial,r=e.uniforms,i=this.textRenderInfo;if(i){const{sdfTexture:o,blockBounds:l}=i;r.uTroikaSDFTexture.value=o,r.uTroikaSDFTextureSize.value.set(o.image.width,o.image.height),r.uTroikaSDFGlyphSize.value=i.sdfGlyphSize,r.uTroikaSDFExponent.value=i.sdfExponent,r.uTroikaTotalBounds.value.fromArray(l),r.uTroikaUseGlyphColors.value=!t&&!!i.glyphColors;let c=0,u=0,d=0,h,p,g,x=0,_=0;if(t){let{outlineWidth:M,outlineOffsetX:C,outlineOffsetY:k,outlineBlur:B,outlineOpacity:U}=this;c=this._parsePercent(M)||0,u=Math.max(0,this._parsePercent(B)||0),h=U,x=this._parsePercent(C)||0,_=this._parsePercent(k)||0}else d=Math.max(0,this._parsePercent(this.strokeWidth)||0),d&&(g=this.strokeColor,r.uTroikaStrokeColor.value.set(g??Bde),p=this.strokeOpacity,p==null&&(p=1)),h=this.fillOpacity;r.uTroikaEdgeOffset.value=c,r.uTroikaPositionOffset.value.set(x,_),r.uTroikaBlurRadius.value=u,r.uTroikaStrokeWidth.value=d,r.uTroikaStrokeOpacity.value=p,r.uTroikaFillOpacity.value=h??1,r.uTroikaCurveRadius.value=this.curveRadius||0;let y=this.clipRect;if(y&&Array.isArray(y)&&y.length===4)r.uTroikaClipRect.value.fromArray(y);else{const M=(this.fontSize||.1)*100;r.uTroikaClipRect.value.set(l[0]-M,l[1]-M,l[2]+M,l[3]+M)}this.geometry.applyClipRect(r.uTroikaClipRect.value)}r.uTroikaSDFDebug.value=!!this.debugSDF,e.polygonOffset=!!this.depthOffset,e.polygonOffsetFactor=e.polygonOffsetUnits=this.depthOffset||0;const s=t?this.outlineColor||0:this.color;if(s==null)delete e.color;else{const o=e.hasOwnProperty("color")?e.color:e.color=new Fn;(s!==o._input||typeof s=="object")&&o.set(o._input=s)}let a=this.orientation||WB;if(a!==e._orientation){let o=r.uTroikaOrient.value;a=a.replace(/[^-+xyz]/g,"");let l=a!==WB&&a.match(/^([-+])([xyz])([-+])([xyz])$/);if(l){let[,c,u,d,h]=l;jE.set(0,0,0)[u]=c==="-"?1:-1,$B.set(0,0,0)[h]=d==="-"?-1:1,Ude.lookAt(Ybt,jE.cross($B),$B),o.setFromMatrix4(Ude)}else o.identity();e._orientation=a}}_parsePercent(e){if(typeof e=="string"){let t=e.match(/^(-?[\d.]+)%$/),r=t?parseFloat(t[1]):NaN;e=(isNaN(r)?0:r/100)*this.fontSize}return e}localPositionToTextCoords(e,t=new en){t.copy(e);const r=this.curveRadius;return r&&(t.x=Math.atan2(e.x,Math.abs(r)-Math.abs(e.z))*Math.abs(r)),t}worldPositionToTextCoords(e,t=new en){return jE.copy(e),this.localPositionToTextCoords(this.worldToLocal(jE),t)}raycast(e,t){const{textRenderInfo:r,curveRadius:i}=this;if(r){const s=r.blockBounds,a=i?j4e():O4e(),o=a.geometry,{position:l,uv:c}=o.attributes;for(let u=0;u{this[r]=e[r]}),this}clone(){return new this.constructor().copy(this)}};F4e.forEach(n=>{const e="_private_"+n;Object.defineProperty(B4e.prototype,n,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})});new Fn;const Vde=de.forwardRef(({sdfGlyphSize:n=64,anchorX:e="center",anchorY:t="middle",font:r,fontSize:i=1,children:s,characters:a,onSync:o,...l},c)=>{const u=Jd(({invalidate:g})=>g),[d]=de.useState(()=>new B4e),[h,p]=de.useMemo(()=>{const g=[];let x="";return de.Children.forEach(s,_=>{typeof _=="string"||typeof _=="number"?x+=_:g.push(_)}),[g,x]},[s]);return r4e(()=>new Promise(g=>Obt({font:r,characters:a},g)),["troika-text",r,a]),de.useLayoutEffect(()=>void d.sync(()=>{u(),o&&o(d)})),de.useEffect(()=>()=>d.dispose(),[d]),de.createElement("primitive",No({object:d,ref:c,font:r,text:p,anchorX:e,anchorY:t,fontSize:i,sdfGlyphSize:n},l),h)});function Jbt(n,e,t,r){const i=class extends Dl{constructor(a={}){const o=Object.entries(n);super({uniforms:o.reduce((l,[c,u])=>{const d=qg.clone({[c]:{value:u}});return{...l,...d}},{}),vertexShader:e,fragmentShader:t}),this.key="",o.forEach(([l])=>Object.defineProperty(this,l,{get:()=>this.uniforms[l].value,set:c=>this.uniforms[l].value=c})),Object.assign(this,a)}};return i.key=Q0.generateUUID(),i}const XB=n=>n===Object(n)&&!Array.isArray(n)&&typeof n!="function";function OY(n,e){const t=Jd(s=>s.gl),r=M6(ry,XB(n)?Object.values(n):n);return de.useLayoutEffect(()=>{e==null||e(r)},[e]),de.useEffect(()=>{if("initTexture"in t){let s=[];Array.isArray(r)?s=r:r instanceof Aa?s=[r]:XB(r)&&(s=Object.values(r)),s.forEach(a=>{a instanceof Aa&&t.initTexture(a)})}},[t,r]),de.useMemo(()=>{if(XB(n)){const s={};let a=0;for(const o in n)s[o]=r[a++];return s}else return r},[n,r])}OY.preload=n=>M6.preload(ry,n);OY.clear=n=>M6.clear(ry,n);const e_t=()=>parseInt(Sm.replace(/\D+/g,"")),U4e=e_t(),qde=Jbt({color:new Fn("white"),scale:new en(1,1),imageBounds:new en(1,1),resolution:1024,map:null,zoom:1,radius:0,grayscale:0,opacity:1},` varying vec2 vUv; varying vec2 vPos; void main() { gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.); vUv = uv; vPos = position.xy; } `,` // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44 varying vec2 vUv; varying vec2 vPos; uniform vec2 scale; uniform vec2 imageBounds; uniform float resolution; uniform vec3 color; uniform sampler2D map; uniform float radius; uniform float zoom; uniform float grayscale; uniform float opacity; const vec3 luma = vec3(.299, 0.587, 0.114); vec4 toGrayscale(vec4 color, float intensity) { return vec4(mix(color.rgb, vec3(dot(color.rgb, luma)), intensity), color.a); } vec2 aspect(vec2 size) { return size / min(size.x, size.y); } const float PI = 3.14159265; // from https://iquilezles.org/articles/distfunctions float udRoundBox( vec2 p, vec2 b, float r ) { return length(max(abs(p)-b+r,0.0))-r; } void main() { vec2 s = aspect(scale); vec2 i = aspect(imageBounds); float rs = s.x / s.y; float ri = i.x / i.y; vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x); vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new; vec2 uv = vUv * s / new + offset; vec2 zUv = (uv - vec2(0.5, 0.5)) / zoom + vec2(0.5, 0.5); vec2 res = vec2(scale * resolution); vec2 halfRes = 0.5 * res; float b = udRoundBox(vUv.xy * res - halfRes, halfRes, resolution * radius); vec3 a = mix(vec3(1.0,0.0,0.0), vec3(0.0,0.0,0.0), smoothstep(0.0, 1.0, b)); gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity * a), grayscale); #include #include <${U4e>=154?"colorspace_fragment":"encodings_fragment"}> } `),z4e=de.forwardRef(({children:n,color:e,segments:t=1,scale:r=1,zoom:i=1,grayscale:s=0,opacity:a=1,radius:o=0,texture:l,toneMapped:c,transparent:u,side:d,...h},p)=>{RY({ImageMaterial:qde});const g=de.useRef(null),x=Jd(C=>C.size),_=Array.isArray(r)?[r[0],r[1]]:[r,r],y=[l.image.width,l.image.height],M=Math.max(x.width,x.height);return de.useImperativeHandle(p,()=>g.current,[]),de.useLayoutEffect(()=>{g.current.geometry.parameters&&g.current.material.scale.set(_[0]*g.current.geometry.parameters.width,_[1]*g.current.geometry.parameters.height)},[_[0],_[1]]),de.createElement("mesh",No({ref:g,scale:Array.isArray(r)?[...r,1]:r},h),de.createElement("planeGeometry",{args:[1,1,t,t]}),de.createElement("imageMaterial",{color:e,map:l,zoom:i,grayscale:s,opacity:a,scale:_,imageBounds:y,resolution:M,radius:o,toneMapped:c,transparent:u,side:d,key:qde.key}),n)}),t_t=de.forwardRef(({url:n,...e},t)=>{const r=OY(n);return de.createElement(z4e,No({},e,{texture:r,ref:t}))}),n_t=de.forwardRef(({url:n,...e},t)=>de.createElement(z4e,No({},e,{ref:t}))),r_t=de.forwardRef((n,e)=>{if(n.url)return de.createElement(t_t,No({},n,{ref:e}));if(n.texture)return de.createElement(n_t,No({},n,{ref:e}));throw new Error(" requires a url or texture")}),i_t=de.forwardRef(({makeDefault:n,camera:e,regress:t,domElement:r,enableDamping:i=!0,keyEvents:s=!1,onChange:a,onStart:o,onEnd:l,...c},u)=>{const d=Jd(U=>U.invalidate),h=Jd(U=>U.camera),p=Jd(U=>U.gl),g=Jd(U=>U.events),x=Jd(U=>U.setEvents),_=Jd(U=>U.set),y=Jd(U=>U.get),M=Jd(U=>U.performance),C=e||h,k=r||g.connected||p.domElement,B=de.useMemo(()=>new Jyt(C),[C]);return N6(()=>{B.enabled&&B.update()},-1),de.useEffect(()=>(s&&B.connect(s===!0?k:s),B.connect(k),()=>void B.dispose()),[s,k,t,B,d]),de.useEffect(()=>{const U=V=>{d(),t&&M.regress(),a&&a(V)},z=V=>{o&&o(V)},O=V=>{l&&l(V)};return B.addEventListener("change",U),B.addEventListener("start",z),B.addEventListener("end",O),()=>{B.removeEventListener("start",z),B.removeEventListener("end",O),B.removeEventListener("change",U)}},[a,o,l,B,d,x]),de.useEffect(()=>{if(n){const U=y().controls;return _({controls:B}),()=>_({controls:U})}},[n,B]),de.createElement("primitive",No({ref:u,object:B,enableDamping:i},c))});class s_t extends Dl{constructor(){super({uniforms:{time:{value:0},pixelRatio:{value:1}},vertexShader:` uniform float pixelRatio; uniform float time; attribute float size; attribute float speed; attribute float opacity; attribute vec3 noise; attribute vec3 color; varying vec3 vColor; varying float vOpacity; void main() { vec4 modelPosition = modelMatrix * vec4(position, 1.0); modelPosition.y += sin(time * speed + modelPosition.x * noise.x * 100.0) * 0.2; modelPosition.z += cos(time * speed + modelPosition.x * noise.y * 100.0) * 0.2; modelPosition.x += cos(time * speed + modelPosition.x * noise.z * 100.0) * 0.2; vec4 viewPosition = viewMatrix * modelPosition; vec4 projectionPostion = projectionMatrix * viewPosition; gl_Position = projectionPostion; gl_PointSize = size * 25. * pixelRatio; gl_PointSize *= (1.0 / - viewPosition.z); vColor = color; vOpacity = opacity; } `,fragmentShader:` varying vec3 vColor; varying float vOpacity; void main() { float distanceToCenter = distance(gl_PointCoord, vec2(0.5)); float strength = 0.05 / distanceToCenter - 0.1; gl_FragColor = vec4(vColor, strength * vOpacity); #include #include <${U4e>=154?"colorspace_fragment":"encodings_fragment"}> } `})}get time(){return this.uniforms.time.value}set time(e){this.uniforms.time.value=e}get pixelRatio(){return this.uniforms.pixelRatio.value}set pixelRatio(e){this.uniforms.pixelRatio.value=e}}const V4e=n=>n&&n.constructor===Float32Array,a_t=n=>[n.r,n.g,n.b],q4e=n=>n instanceof en||n instanceof Fe||n instanceof gr,G4e=n=>Array.isArray(n)?n:q4e(n)?n.toArray():[n,n,n];function f5(n,e,t){return de.useMemo(()=>{if(e!==void 0){if(V4e(e))return e;if(e instanceof Fn){const r=Array.from({length:n*3},()=>a_t(e)).flat();return Float32Array.from(r)}else if(q4e(e)||Array.isArray(e)){const r=Array.from({length:n*3},()=>G4e(e)).flat();return Float32Array.from(r)}return Float32Array.from({length:n},()=>e)}return Float32Array.from({length:n},t)},[e])}const o_t=de.forwardRef(({noise:n=1,count:e=100,speed:t=1,opacity:r=1,scale:i=1,size:s,color:a,children:o,...l},c)=>{de.useMemo(()=>RY({SparklesImplMaterial:s_t}),[]);const u=de.useRef(null),d=Jd(C=>C.viewport.dpr),h=G4e(i),p=de.useMemo(()=>Float32Array.from(Array.from({length:e},()=>h.map(Q0.randFloatSpread)).flat()),[e,...h]),g=f5(e,s,Math.random),x=f5(e,r),_=f5(e,t),y=f5(e*3,n),M=f5(a===void 0?e*3:e,V4e(a)?a:new Fn(a),()=>1);return N6(C=>{u.current&&u.current.material&&(u.current.material.time=C.clock.elapsedTime)}),de.useImperativeHandle(c,()=>u.current,[]),de.createElement("points",No({key:`particle-${e}-${JSON.stringify(i)}`},l,{ref:u}),de.createElement("bufferGeometry",null,de.createElement("bufferAttribute",{attach:"attributes-position",args:[p,3]}),de.createElement("bufferAttribute",{attach:"attributes-size",args:[g,1]}),de.createElement("bufferAttribute",{attach:"attributes-opacity",args:[x,1]}),de.createElement("bufferAttribute",{attach:"attributes-speed",args:[_,1]}),de.createElement("bufferAttribute",{attach:"attributes-color",args:[M,3]}),de.createElement("bufferAttribute",{attach:"attributes-noise",args:[y,3]})),o||de.createElement("sparklesImplMaterial",{transparent:!0,pixelRatio:d,depthWrite:!1}))}),Iq="https://famille.ravin-cloud.fr";function l_t(){const[e,t]=de.useMemo(()=>{const i=new Float32Array(18e3),s=new Float32Array(6e3*3),a=new Fn;for(let o=0;o<6e3;o++){const l=20+Math.random()*120,c=Math.random()*2*Math.PI,u=(Math.random()-.5)*500,d=u*.015;i[o*3]=l*Math.cos(c+d),i[o*3+1]=l*Math.sin(c+d),i[o*3+2]=u;const h=["#38bdf8","#34d399","#fbbf24","#f472b6","#a78bfa"];a.set(h[o%h.length]),s[o*3]=a.r,s[o*3+1]=a.g,s[o*3+2]=a.b}return[i,s]},[]),r=de.useRef();return N6(i=>{r.current&&(r.current.rotation.z=i.clock.elapsedTime*.015)}),f.jsxs("points",{ref:r,children:[f.jsxs("bufferGeometry",{children:[f.jsx("bufferAttribute",{attach:"attributes-position",count:6e3,array:e,itemSize:3}),f.jsx("bufferAttribute",{attach:"attributes-color",count:6e3,array:t,itemSize:3})]}),f.jsx("pointsMaterial",{size:.35,vertexColors:!0,transparent:!0,opacity:.65,blending:Kh,depthWrite:!1})]})}function c_t({person:n,position:e,url:t,name:r,birthYear:i,baseColor:s,isSelected:a,isHovered:o,onHover:l,onUnhover:c,onClick:u}){let d=t;t?t.startsWith("/")&&(d=`${Iq}${t}`):d=Rg(n||r)?"/avatar_female.png":"/avatar_male.png";const h=de.useRef(),p=s||"#00ffcc";N6(x=>{if(h.current){const _=x.clock.elapsedTime;h.current.position.y=e[1]+Math.sin(_*1.8+e[0])*.12,h.current.position.x=e[0]+Math.cos(_*1.2+e[2])*.08}});const g=a?1.3:o?1.2:1;return f.jsxs("group",{ref:h,position:e,scale:[g,g,g],onClick:u,onPointerOver:x=>{x.stopPropagation(),l()},onPointerOut:c,children:[f.jsxs("mesh",{position:[0,0,-.2],children:[f.jsx("circleGeometry",{args:[2.8,32]}),f.jsx("meshBasicMaterial",{color:p,transparent:!0,opacity:a?.45:o?.35:.12,blending:Kh,depthWrite:!1})]}),f.jsxs("mesh",{position:[0,0,-.05],children:[f.jsx("ringGeometry",{args:[1.55,1.62,64]}),f.jsx("meshBasicMaterial",{color:a||o?"#ffffff":p,transparent:!0,opacity:a?1:o?.9:.6,blending:Kh})]}),f.jsx(r_t,{url:d,scale:[2.8,2.8],transparent:!0,opacity:.96}),f.jsx(Vde,{position:[0,-1.9,0],fontSize:.24,color:a?"#38bdf8":o?"#ffffff":"#e2e8f0",anchorX:"center",anchorY:"middle",letterSpacing:.12,outlineWidth:.02,outlineColor:"#020617",children:r.toUpperCase()}),i&&f.jsxs(Vde,{position:[0,-2.25,0],fontSize:.17,color:p,anchorX:"center",anchorY:"middle",letterSpacing:.08,children:["✦ ",i," ✦"]})]})}function u_t({targetPosition:n,autoTour:e,onTourStep:t}){const{camera:r}=Jd(),i=de.useRef(new Fe(0,0,-50)),s=de.useRef(20);return N6((a,o)=>{if(n){const l=new Fe(n[0],n[1]+1.2,n[2]+9);r.position.lerp(l,o*3.5);const c=new Fe(n[0],n[1],n[2]);i.current.lerp(c,o*4),r.lookAt(i.current)}else if(e){s.current-=o*12,s.current<-300&&(s.current=20),r.position.z=Q0.lerp(r.position.z,s.current,o*2),r.position.x=Math.sin(a.clock.elapsedTime*.3)*12,r.position.y=4+Math.cos(a.clock.elapsedTime*.2)*3;const l=new Fe(0,0,r.position.z-40);i.current.lerp(l,o*2),r.lookAt(i.current)}}),null}function d_t({people:n,selectedPerson:e,hoveredSlug:t,onHoverSlug:r,onSelectPerson:i,targetPos:s,autoTour:a}){const o=de.useMemo(()=>{const c={};return n.forEach((d,h)=>{let p=2026;if(d.date_naissance){const z=new Date(d.date_naissance).getFullYear();isNaN(z)||(p=z)}else if(d.annee_naissance){const z=parseInt(d.annee_naissance,10);isNaN(z)||(p=z)}const g=2026-p,x=-g*2,_=137.508*(Math.PI/180),y=h*_,M=7+g*.12+Math.sqrt(h)*2.4,C=Math.cos(y)*M,k=Math.sin(y)*M;let B="#38bdf8",U="Époque Contemporaine";p>=2e3?(B="#34d399",U="XXIe Siècle"):p>=1970?(B="#38bdf8",U="Fin XXe Siècle"):p>=1940?(B="#c084fc",U="Mi-XXe Siècle"):p>=1900?(B="#fbbf24",U="Début XXe Siècle"):(B="#f43f5e",U="Ancêtres & Origines"),c[d.slug]={pos:[C,k,x],auraColor:B,eraName:U,birthYear:p,person:d}}),c},[n]),l=de.useMemo(()=>{const c=[];return n.forEach(u=>{var g,x;const d=(g=o[u.slug])==null?void 0:g.pos;if(!d)return;(Array.isArray(u.parents)?u.parents:u.parents?[u.parents]:[]).forEach(_=>{var M;const y=(M=o[_])==null?void 0:M.pos;y&&c.push({start:d,end:y,type:"parent",key:`${u.slug}->${_}`,isRelatedToSelected:e&&(u.slug===e.slug||_===e.slug)})});const p=u.conjoint;if(p){const _=(x=o[p])==null?void 0:x.pos;_&&c.push({start:d,end:_,type:"conjoint",key:`${u.slug}<->${p}`,isRelatedToSelected:e&&(u.slug===e.slug||p===e.slug)})}}),c},[n,o,e]);return f.jsxs("group",{children:[f.jsx("ambientLight",{intensity:.65}),f.jsx(l_t,{}),f.jsx(o_t,{count:1500,scale:250,size:2.5,speed:.15,opacity:.35,color:"#ffffff"}),f.jsx(u_t,{targetPosition:s,autoTour:a}),l.map(c=>{const u=c.type==="conjoint",d=u?"#f43f5e":c.isRelatedToSelected?"#38bdf8":"#2dd4bf",h=c.isRelatedToSelected?2.5:u?1.5:1.2,p=c.isRelatedToSelected?.9:u?.55:.35;return f.jsx(rbt,{points:[c.start,c.end],color:d,lineWidth:h,transparent:!0,opacity:p,blending:Kh},c.key)}),Object.entries(o).map(([c,u])=>f.jsx(c_t,{person:u.person,position:u.pos,url:u.person.photo_url||u.person.photo,name:`${u.person.prenom} ${u.person.nom}`,birthYear:u.birthYear,baseColor:u.auraColor,isSelected:(e==null?void 0:e.slug)===c,isHovered:t===c,onHover:()=>r(c),onUnhover:()=>r(null),onClick:d=>{d.stopPropagation(),i(u.person)}},c))]})}function h_t({onClose:n,onSelectPerson:e}){var k,B;const[t,r]=de.useState([]),[i,s]=de.useState(null),[a,o]=de.useState(null),[l,c]=de.useState(null),[u,d]=de.useState(!1),[h,p]=de.useState(""),[g,x]=de.useState("all");de.useEffect(()=>{fetch(`${Iq}/api/people`,{credentials:"include"}).then(U=>{if(!U.ok)throw new Error(`HTTP error ${U.status}`);return U.json()}).then(U=>r(U.people||[])).catch(U=>console.error("Erreur chargement personnes musée 3D:",U))},[]);const _=de.useMemo(()=>{if(!h||h.length<2)return[];const U=h.toLowerCase();return t.filter(z=>`${z.prenom||""} ${z.nom||""}`.toLowerCase().includes(U)).slice(0,6)},[t,h]),y=U=>{s(U),d(!1),p("");const z=2026;let O=z;if(U.date_naissance){const Q=new Date(U.date_naissance).getFullYear();isNaN(Q)||(O=Q)}else if(U.annee_naissance){const Q=parseInt(U.annee_naissance,10);isNaN(Q)||(O=Q)}const V=t.findIndex(Q=>Q.slug===U.slug),$=V>=0?V:0,G=z-O,H=-G*2,K=137.508*(Math.PI/180),W=$*K,J=7+G*.12+Math.sqrt($)*2.4,ie=Math.cos(W)*J,ae=Math.sin(W)*J;c([ie,ae,H])},M=U=>{d(!1);const O=-(2026-U)*2;c([0,2,O+15])},C=()=>{s(null),d(!1),c([0,5,20])};return f.jsxs("div",{className:"fixed inset-0 z-50 bg-[#020208] text-white select-none overflow-hidden font-sans",children:[f.jsxs("div",{className:"absolute top-4 left-4 right-4 z-20 flex items-center justify-between gap-3 pointer-events-none",children:[f.jsx("div",{className:"flex items-center gap-3 pointer-events-auto",children:f.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2 rounded-2xl bg-slate-900/80 backdrop-blur-xl border border-slate-700/60 shadow-2xl",children:[f.jsx("span",{className:"text-xl animate-pulse",children:"🌌"}),f.jsxs("div",{children:[f.jsx("h1",{className:"text-xs sm:text-sm font-black tracking-wider uppercase text-cyan-300",children:"Constellation Familiale 3D"}),f.jsxs("p",{className:"text-[10px] text-slate-400",children:[t.length," étoiles dans la galaxie • Axe Z temporel"]})]})]})}),f.jsxs("div",{className:"relative w-48 sm:w-72 pointer-events-auto hidden md:block",children:[f.jsxs("div",{className:"flex items-center bg-slate-900/90 border border-slate-700/80 rounded-2xl px-3 py-2 text-xs backdrop-blur-xl focus-within:border-cyan-400 shadow-xl transition",children:[f.jsx(X0,{className:"text-slate-400 mr-2 shrink-0"}),f.jsx("input",{type:"text",value:h,onChange:U=>p(U.target.value),placeholder:"Rechercher une étoile...",className:"bg-transparent border-none outline-none text-white placeholder-slate-500 text-xs w-full font-medium"}),h&&f.jsx("button",{onClick:()=>p(""),className:"text-slate-400 hover:text-white text-xs",children:"✕"})]}),_.length>0&&f.jsx("div",{className:"absolute top-full left-0 right-0 mt-1.5 bg-slate-900/95 border border-slate-700 rounded-2xl p-1.5 shadow-2xl backdrop-blur-xl space-y-1",children:_.map(U=>{var z;return f.jsxs("div",{onClick:()=>y(U),className:"flex items-center gap-2.5 p-2 rounded-xl hover:bg-cyan-950/60 cursor-pointer border border-transparent hover:border-cyan-500/40 transition",children:[f.jsx("div",{className:"w-6 h-6 rounded-full bg-cyan-900 text-cyan-200 text-[10px] font-bold flex items-center justify-center shrink-0",children:(z=U.prenom)==null?void 0:z[0]}),f.jsxs("div",{className:"flex flex-col min-w-0",children:[f.jsxs("span",{className:"text-xs font-bold text-white truncate",children:[U.prenom," ",U.nom]}),f.jsx("span",{className:"text-[10px] text-slate-400",children:U.date_naissance||U.annee_naissance||"Année inconnue"})]})]},U.slug)})})]}),f.jsxs("div",{className:"flex items-center gap-2 pointer-events-auto",children:[f.jsxs("button",{onClick:()=>{d(!u),u||c(null)},className:`flex items-center gap-2 px-3 sm:px-4 py-2 rounded-2xl text-xs font-bold transition-all backdrop-blur-xl border ${u?"bg-gradient-to-r from-pink-500 to-rose-600 border-pink-400 text-white shadow-lg shadow-pink-500/30 animate-pulse":"bg-slate-900/80 border-slate-700 text-slate-200 hover:bg-slate-800"}`,title:"Voyage cinématographique dans le temps",children:[u?f.jsx(TCe,{}):f.jsx(_Ce,{}),f.jsx("span",{className:"hidden sm:inline",children:u?"Pause Voyage":"Voyage Cosmique"})]}),f.jsx("button",{onClick:C,className:"p-2.5 bg-slate-900/80 hover:bg-slate-800 text-slate-200 rounded-2xl border border-slate-700/80 backdrop-blur-xl transition",title:"Réinitialiser la vue",children:f.jsx(xCe,{size:12})}),f.jsx("button",{onClick:n,className:"p-2.5 bg-rose-950/60 hover:bg-rose-600 text-rose-200 hover:text-white rounded-2xl border border-rose-800/60 backdrop-blur-xl transition",title:"Quitter la constellation",children:f.jsx($a,{size:14})})]})]}),f.jsxs("div",{className:"absolute bottom-6 left-4 right-4 z-20 flex flex-col sm:flex-row items-center justify-between gap-3 pointer-events-none",children:[f.jsxs("div",{className:"flex items-center gap-1.5 p-1.5 rounded-2xl bg-slate-900/85 backdrop-blur-xl border border-slate-700/60 shadow-2xl pointer-events-auto overflow-x-auto max-w-full",children:[f.jsx("button",{onClick:()=>M(2015),className:"px-3 py-1.5 rounded-xl text-xs font-bold text-emerald-300 hover:bg-emerald-950/60 transition shrink-0 border border-emerald-500/30",children:"🌟 XXIe Siècle (2000+)"}),f.jsx("button",{onClick:()=>M(1980),className:"px-3 py-1.5 rounded-xl text-xs font-bold text-sky-300 hover:bg-sky-950/60 transition shrink-0 border border-sky-500/30",children:"🚀 Époque Récente (1970-1999)"}),f.jsx("button",{onClick:()=>M(1950),className:"px-3 py-1.5 rounded-xl text-xs font-bold text-purple-300 hover:bg-purple-950/60 transition shrink-0 border border-purple-500/30",children:"📻 Mi-XXe Siècle (1940-1969)"}),f.jsx("button",{onClick:()=>M(1900),className:"px-3 py-1.5 rounded-xl text-xs font-bold text-amber-300 hover:bg-amber-950/60 transition shrink-0 border border-amber-500/30",children:"🏛️ Ancêtres (1900 & avant)"})]}),f.jsxs("div",{className:"hidden lg:flex items-center gap-3 px-4 py-2 rounded-2xl bg-slate-900/80 backdrop-blur-xl border border-slate-700/60 text-[11px] font-semibold text-slate-300 pointer-events-auto",children:[f.jsxs("span",{className:"flex items-center gap-1 text-emerald-400",children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-400 shadow"})," Filiation"]}),f.jsxs("span",{className:"flex items-center gap-1 text-rose-400",children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-rose-400 shadow"})," Mariage"]}),f.jsx("span",{className:"text-slate-500",children:"• Glisser pour pivoter • Molette pour zoomer"})]})]}),i&&f.jsxs("div",{className:"absolute top-20 left-4 sm:left-6 z-30 w-72 sm:w-80 p-4 rounded-3xl bg-slate-900/90 backdrop-blur-2xl border border-cyan-500/40 shadow-2xl shadow-cyan-950/80 space-y-3 animate-fade-in",children:[f.jsxs("div",{className:"flex items-start justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-12 h-12 rounded-2xl overflow-hidden border-2 border-cyan-400 shadow-md bg-slate-800 flex items-center justify-center shrink-0",children:i.photo||i.photo_url?f.jsx("img",{src:(i.photo_url||i.photo).startsWith("/")?`${Iq}${i.photo_url||i.photo}`:i.photo_url||i.photo,alt:"",className:"w-full h-full object-cover"}):f.jsxs("div",{className:"w-full h-full bg-gradient-to-tr from-cyan-600 to-blue-500 flex items-center justify-center text-white font-black",children:[(k=i.prenom)==null?void 0:k[0],(B=i.nom)==null?void 0:B[0]]})}),f.jsxs("div",{className:"min-w-0",children:[f.jsxs("h3",{className:"text-sm font-black text-white truncate",children:[i.prenom," ",i.nom]}),f.jsx("p",{className:"text-[11px] text-cyan-300 font-semibold",children:i.date_naissance||i.annee_naissance?`Né(e) en ${i.date_naissance||i.annee_naissance}`:"Date inconnue"})]})]}),f.jsx("button",{onClick:()=>s(null),className:"text-slate-400 hover:text-white text-xs p-1",children:"✕"})]}),i.biographie&&f.jsxs("p",{className:"text-[11px] text-slate-300 line-clamp-2 italic bg-slate-800/60 p-2 rounded-xl border border-slate-700/50",children:["« ",i.biographie," »"]}),f.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[f.jsx("button",{onClick:()=>y(i),className:"px-3 py-2 rounded-xl bg-slate-800 hover:bg-slate-700 text-cyan-300 text-xs font-bold flex items-center justify-center gap-1.5 transition border border-cyan-500/30",children:f.jsx("span",{children:"🚀 Recentrer"})}),f.jsxs("button",{onClick:()=>{e&&e(i)},className:"px-3 py-2 rounded-xl bg-gradient-to-r from-cyan-500 to-blue-600 hover:from-cyan-400 hover:to-blue-500 text-slate-950 text-xs font-black flex items-center justify-center gap-1.5 shadow-lg transition",children:[f.jsx("span",{children:"📜 Fiche"}),f.jsx(_A,{size:10})]})]})]}),f.jsx(de.Suspense,{fallback:f.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-[#020208]",children:[f.jsx("div",{className:"w-16 h-16 border-4 border-cyan-500/20 border-t-cyan-400 rounded-full animate-spin mb-4"}),f.jsx("span",{className:"text-cyan-400 font-sans text-xs tracking-[0.3em] uppercase animate-pulse",children:"Génération de la Galaxie Familiale..."})]}),children:f.jsxs(Hyt,{camera:{position:[0,5,20],fov:60},children:[f.jsx("color",{attach:"background",args:["#020208"]}),f.jsx("fog",{attach:"fog",args:["#020208",15,320]}),f.jsx(d_t,{people:t,selectedPerson:i,hoveredSlug:a,onHoverSlug:o,onSelectPerson:y,targetPos:l,autoTour:u}),f.jsx(i_t,{enablePan:!0,enableZoom:!0,maxDistance:350,minDistance:2,target:[0,0,-50],autoRotate:!u&&!l&&!i,autoRotateSpeed:.4,dampingFactor:.05})]})})]})}const Gde="https://famille.ravin-cloud.fr";function f_t({onClose:n,onSelectPerson:e}){const[t,r]=de.useState([]),[i,s]=de.useState([]),[a,o]=de.useState([]),l=de.useRef();return de.useEffect(()=>{fetch(`${Gde}/api/people`,{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP error ${c.status}`);return c.json()}).then(c=>{const u=c.people||[];r(u),fetch(`${Gde}/api/map/markers`,{credentials:"include"}).then(d=>d.ok?d.json():{markers:[]}).then(d=>{if(d.markers){const h=d.markers.map(p=>({lat:p.lat,lng:p.lon,size:.5,color:"#d4af37",label:p.personne_nom,person:u.find(g=>g.slug===p.personne_slug)}));if(s(h),h.length>1){const p=[];for(let g=0;g.5&&p.push({startLat:h[g].lat,startLng:h[g].lng,endLat:h[g+1].lat,endLng:h[g+1].lng,color:["#8b7355","#d4af37"]});o(p)}}}).catch(d=>console.error(d))}).catch(c=>console.error(c))},[]),f.jsxs("div",{className:"fixed inset-0 z-50 bg-black flex flex-col",children:[f.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-4",children:[f.jsx("div",{className:"bg-black/50 text-white/70 px-4 py-2 rounded-full backdrop-blur-sm pointer-events-none border border-white/10 text-sm font-serif italic",children:"Globe des Origines"}),f.jsx("button",{onClick:n,className:"p-3 bg-red-800 text-white hover:bg-red-900 rounded-full shadow-lg transition-transform hover:scale-110",children:f.jsx($a,{})})]}),f.jsx("div",{className:"flex-1 cursor-grab active:cursor-grabbing",children:f.jsx(sL,{ref:l,globeImageUrl:"//unpkg.com/three-globe/example/img/earth-night.jpg",backgroundImageUrl:"//unpkg.com/three-globe/example/img/night-sky.png",pointsData:i,pointLabel:"label",pointColor:"color",pointAltitude:"size",pointRadius:.5,onPointClick:c=>c.person&&e(c.person),arcsData:a,arcColor:"color",arcDashLength:.4,arcDashGap:4,arcDashInitialGap:()=>Math.random()*5,arcDashAnimateTime:2e3})})]})}const Hde="https://famille.ravin-cloud.fr";function H4e({people:n,onClose:e}){const[t,r]=de.useState([]),[i,s]=de.useState(!1),[a,o]=de.useState(null),[l,c]=de.useState(null),[u,d]=de.useState(localStorage.getItem("preferred_ai_engine")||"azure"),h=g=>{r(x=>x.includes(g)?x.filter(_=>_!==g):[...x,g])},p=async()=>{if(t.length===0){jt.error("Veuillez sélectionner au moins un membre.");return}s(!0),o(null),c(null),jt.loading("Génération du podcast familial en cours...",{id:"family-podcast"});try{const g=await fetch(`${Hde}/api/podcast/family`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({slugs:t,engine:u})}),x=await g.json();if(!g.ok)throw new Error(x.error||"Erreur lors de la génération.");o(`${Hde}${x.url}`),c(x.script||null),jt.success("Podcast généré avec succès !",{id:"family-podcast"})}catch(g){jt.error(g.message,{id:"family-podcast"})}finally{s(!1)}};return f.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm flex items-center justify-center p-4",children:f.jsxs(Gn.div,{className:"bg-white rounded-3xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden shadow-2xl",initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},children:[f.jsxs("div",{className:"p-6 border-b border-slate-100 flex justify-between items-center bg-slate-50",children:[f.jsxs("h2",{className:"text-2xl font-bold text-slate-800 flex items-center gap-2",children:[f.jsx(bCe,{className:"text-purple-600"})," Podcast de Famille"]}),f.jsx("button",{onClick:e,className:"p-2 text-slate-400 hover:text-red-500 rounded-full hover:bg-red-50 transition-colors",children:f.jsx($a,{size:20})})]}),f.jsxs("div",{className:"p-6 overflow-y-auto flex-1 bg-[#fcfcfc]",children:[f.jsx("p",{className:"text-slate-600 mb-6",children:"Sélectionnez les membres de la famille que vous souhaitez inclure dans cet épisode de podcast. L'IA va créer une histoire croisée et la synthétiser en audio."}),f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-6",children:n.map(g=>f.jsxs("label",{className:`flex items-center p-4 border rounded-2xl cursor-pointer transition-all ${t.includes(g.slug)?"border-purple-500 bg-purple-50 shadow-sm":"border-slate-200 hover:border-purple-300 hover:bg-slate-50"}`,children:[f.jsx("input",{type:"checkbox",className:"hidden",checked:t.includes(g.slug),onChange:()=>h(g.slug)}),f.jsx("div",{className:`w-6 h-6 rounded-full border-2 flex items-center justify-center mr-3 ${t.includes(g.slug)?"border-purple-500 bg-purple-500":"border-slate-300"}`,children:t.includes(g.slug)&&f.jsx("div",{className:"w-2.5 h-2.5 bg-white rounded-full"})}),f.jsxs("div",{className:"flex items-center gap-3",children:[g.photo_url||g.photo?f.jsx("img",{src:g.photo_url||g.photo,alt:g.prenom,className:"w-10 h-10 rounded-full object-cover shadow-sm"}):f.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-tr from-slate-200 to-slate-300 flex items-center justify-center text-slate-500 font-bold",children:g.prenom[0]}),f.jsxs("div",{children:[f.jsxs("p",{className:"font-bold text-slate-800 leading-tight",children:[g.prenom," ",g.nom]}),f.jsx("p",{className:"text-xs text-slate-500",children:g.date_naissance?new Date(g.date_naissance).getFullYear():"?"})]})]})]},g.slug))}),f.jsx("div",{className:"flex justify-center mb-6",children:f.jsx(wH,{engine:u,setEngine:d})}),a&&f.jsx(Gn.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"mt-4",children:f.jsxs("div",{className:"bg-purple-50 rounded-2xl p-6 border border-purple-200 flex flex-col items-center gap-4 shadow-sm",children:[f.jsxs("p",{className:"font-bold text-purple-900 text-lg flex items-center gap-2",children:[f.jsx("span",{children:"🎧"})," Votre épisode est prêt !"]}),f.jsx("audio",{controls:!0,autoPlay:!0,src:a,className:"w-full max-w-md outline-none rounded-lg"}),l&&f.jsxs("details",{className:"w-full max-w-md text-xs text-purple-900 bg-white/80 p-3.5 rounded-xl border border-purple-200",children:[f.jsx("summary",{className:"font-semibold text-purple-800 hover:text-purple-950 cursor-pointer select-none",children:"📜 Lire le texte du récit"}),f.jsx("p",{className:"mt-2 text-slate-700 leading-relaxed font-sans select-text whitespace-pre-wrap",children:l})]}),f.jsx("a",{href:a,download:"podcast_famille.mp3",className:"mt-1 text-xs font-bold text-purple-700 hover:text-purple-900 underline",children:"Télécharger le fichier MP3"})]})})]}),f.jsxs("div",{className:"p-6 border-t border-slate-100 bg-white flex justify-end gap-3",children:[f.jsx("button",{onClick:e,className:"px-6 py-3 font-bold text-slate-600 bg-slate-100 hover:bg-slate-200 rounded-xl transition-colors",children:"Fermer"}),f.jsx("button",{onClick:p,disabled:i||t.length===0,className:`px-8 py-3 font-bold text-white rounded-xl shadow-md transition-all flex items-center gap-2 ${i||t.length===0?"bg-purple-400 cursor-not-allowed":"bg-purple-600 hover:bg-purple-700 shadow-purple-600/20"}`,children:i?"Génération en cours...":"🎤 Créer le Podcast"})]})]})})}const p_t="https://famille.ravin-cloud.fr";function m_t({currentTab:n,onGoHome:e}){return de.useEffect(()=>{fetch(`${p_t}/api/telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event_type:"error_404",feature:"navigation_error",path:n||window.location.pathname})}).catch(t=>console.error("Telemetry failed silently",t))},[n]),f.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh] text-center px-4",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.8,y:20},animate:{opacity:1,scale:1,y:0},transition:{type:"spring",bounce:.5},className:"bg-white/80 backdrop-blur-xl p-8 md:p-12 rounded-[2.5rem] shadow-[0_20px_50px_rgba(0,0,0,0.05)] border border-white/60 max-w-lg w-full relative overflow-hidden",children:[f.jsx("div",{className:"absolute -top-20 -right-20 w-40 h-40 bg-red-400/10 rounded-full blur-3xl pointer-events-none"}),f.jsx("div",{className:"absolute -bottom-20 -left-20 w-40 h-40 bg-orange-400/10 rounded-full blur-3xl pointer-events-none"}),f.jsx("div",{className:"w-24 h-24 mx-auto bg-red-50 text-red-500 rounded-full flex items-center justify-center text-4xl mb-6 shadow-inner border border-red-100",children:f.jsx(vM,{})}),f.jsx("h1",{className:"text-4xl font-black text-slate-800 tracking-tight mb-2",children:"Erreur 404"}),f.jsx("h2",{className:"text-xl font-bold text-slate-500 mb-6",children:"Page introuvable"}),f.jsxs("p",{className:"text-slate-600 mb-8 leading-relaxed",children:["Il semblerait que vous vous soyez égaré dans les archives familiales. Le chemin ",f.jsx("span",{className:"font-mono bg-slate-100 text-slate-800 px-2 py-1 rounded text-sm",children:n})," n'existe pas ou plus.",f.jsx("br",{}),f.jsx("br",{}),f.jsx("span",{className:"text-xs text-slate-400 block",children:"Les administrateurs (et l'IA) ont été notifiés automatiquement de cette erreur."})]}),f.jsxs(Gn.button,{whileHover:{scale:1.05},whileTap:{scale:.95},onClick:e,className:"w-full sm:w-auto inline-flex items-center justify-center gap-2 px-8 py-4 bg-gradient-to-r from-emerald-500 to-teal-600 text-white font-bold rounded-2xl shadow-lg hover:shadow-xl transition-all",children:[f.jsx(tN,{size:20}),"Retourner à l'accueil"]})]})})}function $de(n){if(!n)return null;if(typeof n=="number")return new Date(n,0,1);const e=String(n).trim().replace(/^['"]+|['"]+$/g,"");if(!e)return null;if(/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(e)){const[r,i,s]=e.split("/");return new Date(parseInt(s,10),parseInt(i,10)-1,parseInt(r,10))}if(/^\d{4}(-\d{1,2})?(-\d{1,2})?$/.test(e)){const r=e.split("-"),i=parseInt(r[0],10),s=r[1]?parseInt(r[1],10)-1:0,a=r[2]?parseInt(r[2],10):1;return new Date(i,s,a)}if(/^\d{4}$/.test(e))return new Date(parseInt(e,10),0,1);const t=new Date(e);return isNaN(t.getTime())?null:t}function Wde(n){var t;if(!n)return"M";const e=(n.sexe||n.gender||n.genre||((t=n.frontmatter)==null?void 0:t.sexe)||"").toString().trim().toUpperCase();return e==="M"||e==="HOMME"||e==="H"||e==="MASCULIN"||e==="MALE"?"M":e==="F"||e==="FEMME"||e==="FEMININ"||e==="FEMALE"||Rg(n)?"F":"M"}const J2=["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],Xde=["Jan","Fév","Mar","Avr","Mai","Juin","Juil","Aoû","Sep","Oct","Nov","Déc"];function g_t({people:n=[],onSelectPerson:e}){const{user:t}=o1();t&&(t.role==="admin"||t.role);const[r,i]=de.useState(null),[s,a]=de.useState(null),[o,l]=de.useState(""),c=de.useMemo(()=>{if(!n||n.length===0)return null;let _=0,y=0,M=0,C=0,k=0,B=0;const U={},z={},O=Array(12).fill(0),V=Array.from({length:12},()=>[]);let $=null,G=-1;const H=[],K=[],W=[],J=[],ie=[],ae=[],Q=[],re=new Date,oe=re.getFullYear(),fe=re.getMonth(),ee=re.getDate();n.forEach(Te=>{var st,Ht,Se,_t,It,De,ue,Ve,We,ct,vt,Ut,dt;const ze=(Te.prenom||((st=Te.frontmatter)==null?void 0:st.prenom)||((Ht=Te.data)==null?void 0:Ht.prenom)||"").trim(),Xe=(Te.nom||((Se=Te.frontmatter)==null?void 0:Se.nom)||((_t=Te.data)==null?void 0:_t.nom)||"").trim(),Qe=Te.date_naissance||((It=Te.frontmatter)==null?void 0:It.date_naissance)||((De=Te.data)==null?void 0:De.date_naissance),ot=Te.date_deces||((ue=Te.frontmatter)==null?void 0:ue.date_deces)||((Ve=Te.data)==null?void 0:Ve.date_deces),bt=Te.lieu_naissance||((We=Te.frontmatter)==null?void 0:We.lieu_naissance)||((ct=Te.data)==null?void 0:ct.lieu_naissance),ht=Te.profession||((vt=Te.frontmatter)==null?void 0:vt.profession)||((Ut=Te.data)==null?void 0:Ut.profession),Ce=Te.conjoint||((dt=Te.frontmatter)==null?void 0:dt.conjoint),lt=Te.photo||Te.photo_url,ft=!!ot;if(Wde(Te)==="M"?(_++,H.push(Te)):(y++,K.push(Te)),!!(Qe&&bt&&ht&<)?(B++,J.push(Te)):ie.push(Te),Ce&&(Array.isArray(Ce)?Ce.length>0:Ce)&&(k++,W.push(Te)),ze){const mt=ze.split(" ")[0];mt&&mt.length>1&&(U[mt]=(U[mt]||0)+1)}if(bt){const mt=bt.trim();mt&&(z[mt]=(z[mt]||0)+1)}const Lt=$de(Qe);if(Lt){const mt=Lt.getMonth();O[mt]++,V[mt].push(Te);const Ft=$de(ot)||re,tt=Math.floor((Ft-Lt)/(1e3*60*60*24*365.25));if(tt>=0&&tt<120&&(M+=tt,C++,ae.push({person:Te,age:tt,isDead:ft,birthStr:Qe,deathStr:ot}),tt>G&&(G=tt,$={name:`${ze} ${Xe}`.trim(),age:tt,person:Te})),!ft){const Pe=Lt.getDate(),nt=Lt.getMonth();let qe=new Date(oe,nt,Pe);qeTe.daysLeft-ze.daysLeft),ae.sort((Te,ze)=>ze.age-Te.age);const me=C>0?Math.round(M/C):0,Ae=Object.entries(U).sort((Te,ze)=>ze[1]-Te[1]).slice(0,6),be=Object.entries(z).sort((Te,ze)=>ze[1]-Te[1]).slice(0,6),pe=Math.max(...O,1),ge=O.indexOf(Math.max(...O));return{total:n.length,males:_,females:y,maleList:H,femaleList:K,averageAge:me,topNames:Ae,topPlaces:be,oldestPerson:$,maxAge:G,marriedCount:k,marriedList:W,completeProfiles:B,completeList:J,incompleteList:ie,agedList:ae,birthMonths:O,peopleByMonth:V,maxMonthBirths:pe,bestMonth:O[ge]>0?J2[ge]:"Aucun",bestMonthIndex:ge,bestMonthCount:O[ge],upcomingBirthdays:Q}},[n]);if(!c)return f.jsx("div",{className:"p-8 text-center text-slate-500 font-serif",children:"Aucune donnée à analyser."});const u=c.total>0?Math.round(c.males/c.total*100):0,d=c.total>0?Math.round(c.females/c.total*100):0,h=r!==null?r:c.bestMonthIndex,p=c.peopleByMonth[h]||[],g=de.useMemo(()=>{if(!s||!s.peopleList)return[];if(!o.trim())return s.peopleList;const _=o.toLowerCase().trim();return s.peopleList.filter(y=>{const M=y.person||y,C=`${M.prenom||""} ${M.nom||""} ${M.surnom||""}`.toLowerCase(),k=(M.lieu_naissance||"").toLowerCase(),B=(M.profession||"").toLowerCase();return C.includes(_)||k.includes(_)||B.includes(_)})},[s,o]),x=_=>{a(_),l("")};return f.jsxs(Gn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"p-3 sm:p-6 lg:p-8 max-w-7xl mx-auto space-y-8 pb-32",children:[f.jsxs("div",{className:"text-center space-y-2 mb-8",children:[f.jsx("span",{className:"px-4 py-1 rounded-full bg-amber-50 text-amber-800 font-serif font-bold text-xs uppercase tracking-widest border border-amber-200/80 shadow-xs",children:"📊 Données Démographiques & Mémoire"}),f.jsx("h2",{className:"text-2xl sm:text-4xl font-serif font-black text-slate-900 tracking-tight",children:"Statistiques & Anniversaires"}),f.jsxs("p",{className:"text-slate-500 text-xs sm:text-sm max-w-2xl mx-auto",children:["Explorez les chiffres clés, la courbe des naissances et le calendrier des anniversaires de vos ",f.jsxs("span",{className:"font-bold text-slate-700",children:[c.total," membres"]}),"."]})]}),c.upcomingBirthdays.length>0&&f.jsxs("div",{className:"bg-gradient-to-br from-amber-900 via-slate-900 to-indigo-950 rounded-3xl p-5 sm:p-7 text-white shadow-xl border border-amber-500/30 relative overflow-hidden",children:[f.jsx("div",{className:"absolute -right-10 -bottom-10 w-60 h-60 rounded-full bg-amber-500/10 blur-3xl pointer-events-none"}),f.jsx("div",{className:"absolute -left-10 -top-10 w-60 h-60 rounded-full bg-indigo-500/10 blur-3xl pointer-events-none"}),f.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 mb-6 border-b border-white/10 pb-4",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-12 h-12 rounded-2xl bg-gradient-to-tr from-amber-500 to-amber-300 text-slate-950 flex items-center justify-center text-2xl shadow-lg shrink-0",children:"🎂"}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-lg sm:text-xl font-serif font-bold text-amber-200",children:"Prochains Anniversaires"}),f.jsx("p",{className:"text-xs text-slate-300",children:"Ne manquez aucune célébration de la famille cette année"})]})]}),f.jsxs("button",{onClick:()=>x({title:"🎂 Calendrier de Tous les Anniversaires",subtitle:"Classés par ordre chronologique des prochains anniversaires",icon:"🎂",peopleList:c.upcomingBirthdays.map(_=>({..._.person,badgeText:_.daysLeft===0?"Aujourd'hui ! 🎉":_.daysLeft===1?"Demain !":`Dans ${_.daysLeft} jours (${_.birthDateFormatted})`,subText:`Fêtera ses ${_.turningAge} ans`}))}),className:"self-start md:self-auto px-4 py-2 rounded-full bg-white/10 hover:bg-white/20 text-amber-200 text-xs font-bold border border-white/15 transition-all hover:scale-105",children:["Voir toute l'année (",c.upcomingBirthdays.length,") →"]})]}),f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3.5",children:c.upcomingBirthdays.slice(0,4).map((_,y)=>{const M=_.person,C=_.daysLeft===0,k=_.daysLeft===1;return f.jsxs(Gn.div,{whileHover:{scale:1.03},onClick:()=>{e&&e(M)},className:`cursor-pointer p-4 rounded-2xl backdrop-blur-md transition-all border flex flex-col justify-between ${y===0?"bg-gradient-to-br from-amber-500/25 via-amber-400/15 to-white/5 border-amber-400/50 shadow-[0_0_20px_rgba(245,158,11,0.2)]":"bg-white/5 hover:bg-white/10 border-white/10"}`,children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(q0,{person:M,className:"w-12 h-12 shrink-0 border-2 border-amber-300/80 shadow-md"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"flex items-center gap-1.5",children:f.jsxs("p",{className:"font-bold text-sm text-white truncate",children:[M.prenom," ",M.nom]})}),f.jsx("p",{className:"text-xs text-amber-300 font-semibold mt-0.5",children:_.birthDateFormatted})]})]}),f.jsxs("div",{className:"mt-3 pt-2.5 border-t border-white/10 flex items-center justify-between",children:[f.jsxs("span",{className:"text-[11px] text-slate-300",children:["Fêtera ",f.jsxs("strong",{className:"text-white font-bold",children:[_.turningAge," ans"]})]}),f.jsx("span",{className:`px-2.5 py-0.5 rounded-full text-[10px] font-black uppercase tracking-wider ${C?"bg-emerald-400 text-slate-950 animate-pulse":k?"bg-amber-400 text-slate-950":"bg-white/10 text-amber-200 border border-white/10"}`,children:C?"Aujourd'hui ! 🎉":k?"Demain !":`J-${_.daysLeft}`})]})]},M.slug||y)})})]}),f.jsxs("div",{className:"bg-white rounded-3xl p-5 sm:p-8 shadow-sm border border-slate-200/80 space-y-6",children:[f.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 border-b border-slate-100 pb-4",children:[f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"text-xl",children:"📈"}),f.jsx("h3",{className:"text-lg sm:text-xl font-serif font-black text-slate-900",children:"Courbe de Répartition des Naissances"})]}),f.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:"Cliquez sur un mois ou sur la courbe pour afficher les membres nés à cette période"})]}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs("span",{className:"text-xs font-bold text-amber-800 bg-amber-50 border border-amber-200 px-3 py-1 rounded-full",children:["🏆 Pic annuel : ",f.jsx("strong",{className:"font-black",children:c.bestMonth})," (",c.bestMonthCount," naissances)"]})})]}),f.jsx("div",{className:"w-full h-52 sm:h-64 relative pt-4",children:f.jsxs("svg",{className:"w-full h-full overflow-visible",viewBox:"0 0 1200 240",preserveAspectRatio:"none",children:[f.jsxs("defs",{children:[f.jsxs("linearGradient",{id:"curveGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[f.jsx("stop",{offset:"0%",stopColor:"#f59e0b",stopOpacity:"0.45"}),f.jsx("stop",{offset:"100%",stopColor:"#f59e0b",stopOpacity:"0.0"})]}),f.jsxs("linearGradient",{id:"lineGradient",x1:"0",y1:"0",x2:"1",y2:"0",children:[f.jsx("stop",{offset:"0%",stopColor:"#d97706"}),f.jsx("stop",{offset:"50%",stopColor:"#f59e0b"}),f.jsx("stop",{offset:"100%",stopColor:"#b45309"})]})]}),[0,.25,.5,.75,1].map((_,y)=>f.jsx("line",{x1:"40",y1:200-_*160,x2:"1160",y2:200-_*160,stroke:"#e2e8f0",strokeDasharray:"4 4",strokeWidth:"1"},y)),(()=>{const _=c.birthMonths.map((C,k)=>{const B=50+k*100,U=200-C/c.maxMonthBirths*160;return{x:B,y:U}});let y=`M ${_[0].x} ${_[0].y}`;for(let C=0;C<_.length-1;C++){const k=_[C],B=_[C+1],U=k.x+(B.x-k.x)/2,z=k.y,O=k.x+(B.x-k.x)/2,V=B.y;y+=` C ${U} ${z}, ${O} ${V}, ${B.x} ${B.y}`}const M=`${y} L ${_[_.length-1].x} 200 L ${_[0].x} 200 Z`;return f.jsxs(f.Fragment,{children:[f.jsx("path",{d:M,fill:"url(#curveGradient)"}),f.jsx("path",{d:y,fill:"none",stroke:"url(#lineGradient)",strokeWidth:"4",strokeLinecap:"round"})]})})(),c.birthMonths.map((_,y)=>{const M=50+y*100,C=200-_/c.maxMonthBirths*160,k=h===y;return f.jsxs("g",{className:"cursor-pointer",onClick:()=>i(y),children:[k&&f.jsx("line",{x1:M,y1:"20",x2:M,y2:"200",stroke:"#f59e0b",strokeWidth:"2",strokeDasharray:"2 2"}),f.jsx("circle",{cx:M,y:C,r:k?"9":"6",fill:k?"#b45309":"#f59e0b",stroke:"#ffffff",strokeWidth:"3",className:"transition-all duration-200 hover:scale-125"}),f.jsx("text",{x:M,y:C-12,textAnchor:"middle",fill:k?"#92400e":"#475569",fontSize:k?"14":"11",fontWeight:"bold",fontFamily:"serif",children:_}),f.jsx("text",{x:M,y:"225",textAnchor:"middle",fill:k?"#b45309":"#64748b",fontSize:"12",fontWeight:k?"bold":"normal",fontFamily:"serif",children:Xde[y]})]},y)})]})}),f.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 lg:grid-cols-12 gap-1.5 pt-2",children:J2.map((_,y)=>{const M=c.birthMonths[y],C=h===y;return f.jsxs("button",{onClick:()=>i(y),className:`flex flex-col items-center justify-center p-2 rounded-2xl border transition-all ${C?"bg-amber-500 text-slate-950 font-bold border-amber-400 shadow-md scale-105":"bg-slate-50 hover:bg-amber-50/50 text-slate-600 border-slate-200/80"}`,children:[f.jsx("span",{className:"text-[11px] font-serif",children:Xde[y]}),f.jsx("span",{className:`text-xs font-black mt-0.5 ${C?"text-slate-950":"text-amber-700"}`,children:M})]},y)})}),f.jsxs("div",{className:"mt-6 pt-5 border-t border-slate-100 bg-amber-50/30 p-4 rounded-2xl",children:[f.jsxs("div",{className:"flex items-center justify-between mb-3",children:[f.jsxs("h4",{className:"font-serif font-bold text-slate-900 text-sm flex items-center gap-2",children:[f.jsx("span",{children:"📅"})," Nés en ",J2[h]," (",p.length," membres) :"]}),p.length>0&&f.jsx("button",{onClick:()=>x({title:`📅 Nés en ${J2[h]}`,subtitle:`${p.length} membre(s) répertorié(s) pour ce mois`,icon:"🎂",peopleList:p.map(_=>({..._,badgeText:_.date_naissance||"Date exacte non précisée"}))}),className:"text-xs font-bold text-amber-700 hover:text-amber-900 transition",children:"Ouvrir la liste complète →"})]}),p.length>0?f.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2.5",children:p.slice(0,6).map((_,y)=>f.jsxs("div",{onClick:()=>{e&&e(_)},className:"cursor-pointer flex items-center justify-between p-2.5 rounded-xl bg-white border border-slate-200/80 hover:border-amber-400 hover:shadow-sm transition group",children:[f.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[f.jsx(q0,{person:_,className:"w-9 h-9 shrink-0 shadow-xs"}),f.jsxs("div",{className:"truncate",children:[f.jsxs("p",{className:"text-xs font-bold text-slate-800 group-hover:text-amber-800 truncate",children:[_.prenom," ",_.nom]}),f.jsxs("p",{className:"text-[10px] text-slate-500 truncate",children:[_.date_naissance||"Jour inconnu"," ",_.lieu_naissance?`• ${_.lieu_naissance}`:""]})]})]}),f.jsx("span",{className:"text-xs text-slate-400 group-hover:text-amber-600 transition",children:"→"})]},_.slug||y))}):f.jsxs("p",{className:"text-xs text-slate-400 italic py-2",children:["Aucun membre répertorié né en ",J2[h],"."]})]})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5",children:[f.jsxs(Gn.div,{whileHover:{y:-4},onClick:()=>x({title:"👥 Tous les Membres de la Famille",subtitle:`Répertoire complet des ${c.total} personnes enregistrées`,icon:"👥",peopleList:n.map(_=>({..._,badgeText:Wde(_)==="M"?"Homme 👨":"Femme 👩",subText:_.date_naissance?`Né(e) le ${_.date_naissance}`:"Date non renseignée"}))}),className:"cursor-pointer bg-white p-6 rounded-3xl shadow-sm border border-slate-200/80 flex flex-col items-center text-center relative overflow-hidden group hover:shadow-xl hover:border-indigo-300 transition-all",children:[f.jsx("div",{className:"w-12 h-12 rounded-2xl bg-indigo-50 text-indigo-600 flex items-center justify-center mb-3 shadow-inner group-hover:scale-110 transition-transform",children:f.jsx(lCe,{size:22})}),f.jsx("h3",{className:"text-4xl font-extrabold text-slate-900 mb-0.5",children:c.total}),f.jsx("p",{className:"text-xs font-black tracking-widest text-slate-400 uppercase",children:"Membres au Total"}),f.jsxs("div",{className:"w-full mt-5 space-y-2",children:[f.jsxs("div",{className:"flex justify-between text-xs font-bold px-1",children:[f.jsxs("span",{onClick:_=>{_.stopPropagation(),x({title:"👨 Hommes de la Famille",subtitle:`${c.males} hommes répertoriés (${u}%)`,icon:"👨",peopleList:c.maleList.map(y=>({...y,badgeText:"Homme",subText:y.date_naissance?`Né le ${y.date_naissance}`:"Date inconnue"}))})},className:"text-sky-600 hover:underline cursor-pointer",children:["👨 ",c.males," Hommes (",u,"%)"]}),f.jsxs("span",{onClick:_=>{_.stopPropagation(),x({title:"👩 Femmes de la Famille",subtitle:`${c.females} femmes répertoriées (${d}%)`,icon:"👩",peopleList:c.femaleList.map(y=>({...y,badgeText:"Femme",subText:y.date_naissance?`Née le ${y.date_naissance}`:"Date inconnue"}))})},className:"text-rose-600 hover:underline cursor-pointer",children:["👩 ",c.females," Femmes (",d,"%)"]})]}),f.jsxs("div",{className:"w-full h-3 bg-slate-100 rounded-full overflow-hidden flex shadow-inner",children:[f.jsx("div",{style:{width:`${u}%`},className:"bg-sky-500 h-full transition-all duration-500"}),f.jsx("div",{style:{width:`${d}%`},className:"bg-rose-500 h-full transition-all duration-500"})]}),f.jsx("p",{className:"text-[10px] text-slate-400 text-center mt-1",children:"Cliquer pour voir la liste"})]})]}),f.jsxs(Gn.div,{whileHover:{y:-4},onClick:()=>x({title:"⏳ Classement par Âge & Doyens",subtitle:`Membres classés du plus âgé au plus jeune (Âge moyen: ${c.averageAge} ans)`,icon:"👑",peopleList:c.agedList.map(_=>({..._.person,badgeText:`${_.age} ans ${_.isDead?"(Décédé(e))":"(Vivant(e))"}`,subText:_.birthStr?`Né(e) en ${_.birthStr.slice(0,4)}`:""}))}),className:"cursor-pointer bg-white p-6 rounded-3xl shadow-sm border border-slate-200/80 flex flex-col items-center text-center relative overflow-hidden group hover:shadow-xl hover:border-emerald-300 transition-all",children:[f.jsx("div",{className:"w-12 h-12 rounded-2xl bg-emerald-50 text-emerald-600 flex items-center justify-center mb-3 shadow-inner group-hover:scale-110 transition-transform",children:f.jsx(hCe,{size:22})}),f.jsxs("h3",{className:"text-4xl font-extrabold text-slate-900 mb-0.5",children:[c.averageAge>0?c.averageAge:"—",f.jsx("span",{className:"text-lg text-slate-400 ml-1 font-normal",children:"ans"})]}),f.jsx("p",{className:"text-xs font-black tracking-widest text-slate-400 uppercase",children:"Âge Moyen"}),c.oldestPerson?f.jsxs("div",{className:"mt-4 pt-3 border-t border-slate-100 w-full text-xs text-slate-500",children:["👑 Doyen(ne) connu(e): ",f.jsx("br",{}),f.jsx("strong",{className:"text-slate-800 font-bold text-xs block truncate mt-0.5",children:c.oldestPerson.name}),f.jsxs("span",{className:"text-emerald-600 font-extrabold",children:["(",c.maxAge," ans)"]})]}):f.jsx("div",{className:"mt-4 text-xs text-slate-400 italic",children:"Dates à compléter"}),f.jsx("p",{className:"text-[10px] text-slate-400 mt-2",children:"Cliquer pour voir le palmarès"})]}),f.jsxs(Gn.div,{whileHover:{y:-4},onClick:()=>{i(c.bestMonthIndex),x({title:`🎂 Naissances en ${c.bestMonth}`,subtitle:`Mois record de l'année avec ${c.bestMonthCount} naissance(s)`,icon:"🎂",peopleList:(c.peopleByMonth[c.bestMonthIndex]||[]).map(_=>({..._,badgeText:_.date_naissance||"Date exacte inconnue"}))})},className:"cursor-pointer bg-white p-6 rounded-3xl shadow-sm border border-slate-200/80 flex flex-col items-center text-center relative overflow-hidden group hover:shadow-xl hover:border-amber-300 transition-all",children:[f.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-50 text-amber-600 flex items-center justify-center mb-3 shadow-inner group-hover:scale-110 transition-transform",children:f.jsx(vH,{size:22})}),f.jsx("h3",{className:"text-2xl font-extrabold text-slate-900 mb-0.5 truncate max-w-full",children:c.bestMonth}),f.jsx("p",{className:"text-xs font-black tracking-widest text-slate-400 uppercase",children:"Mois des Naissances"}),f.jsxs("p",{className:"mt-4 text-xs text-slate-500 font-medium",children:["Pic d'anniversaires avec ",f.jsx("strong",{className:"text-amber-600 font-extrabold",children:c.bestMonthCount})," naissances !"]}),f.jsx("p",{className:"text-[10px] text-slate-400 mt-2",children:"Cliquer pour explorer ce mois"})]}),f.jsxs("div",{className:"bg-white p-6 rounded-3xl shadow-sm border border-slate-200/80 flex flex-col items-center relative overflow-hidden group hover:shadow-xl transition-all",children:[f.jsx("div",{className:"w-12 h-12 rounded-2xl bg-purple-50 text-purple-600 flex items-center justify-center mb-2 shadow-inner",children:f.jsx(GCe,{size:22})}),f.jsx("p",{className:"text-xs font-black tracking-widest text-slate-400 uppercase mb-2.5",children:"Prénoms Fréquents"}),f.jsx("div",{className:"w-full space-y-1.5",children:c.topNames.length>0?c.topNames.map(([_,y],M)=>f.jsxs("button",{onClick:()=>x({title:`🏷️ Membres prénommés "${_}"`,subtitle:`${y} personne(s) portant ce prénom`,icon:"🏷️",peopleList:n.filter(C=>(C.prenom||"").toLowerCase().startsWith(_.toLowerCase())).map(C=>({...C,badgeText:C.prenom}))}),className:"flex justify-between items-center w-full bg-slate-50 hover:bg-purple-50 px-2.5 py-1.5 rounded-xl border border-slate-100 text-xs transition cursor-pointer",children:[f.jsx("span",{className:"font-bold text-slate-800",children:_}),f.jsxs("span",{className:"bg-purple-100 text-purple-700 px-2 py-0.5 rounded-full font-black text-[10px]",children:[y," pers. →"]})]},M)):f.jsx("p",{className:"text-xs text-slate-400 italic text-center py-2",children:"Aucun prénom"})})]})]}),f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 pt-2",children:[f.jsxs("div",{className:"bg-white p-6 rounded-3xl shadow-sm border border-slate-200/80 space-y-4",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-xl bg-rose-50 text-rose-600 flex items-center justify-center shadow-inner",children:f.jsx(bA,{size:20})}),f.jsxs("div",{children:[f.jsx("h4",{className:"font-extrabold text-slate-900 text-base",children:"Lieux d'Origine Emblématiques"}),f.jsx("p",{className:"text-xs text-slate-500",children:"Communes et villes les plus représentées"})]})]}),f.jsx("div",{className:"space-y-2 pt-1",children:c.topPlaces.length>0?c.topPlaces.map(([_,y],M)=>f.jsxs("div",{onClick:()=>x({title:`📍 Nés à ${_}`,subtitle:`${y} membre(s) originaires de ce lieu`,icon:"📍",peopleList:n.filter(C=>(C.lieu_naissance||"").trim().toLowerCase()===_.toLowerCase()).map(C=>({...C,badgeText:_}))}),className:"cursor-pointer flex items-center justify-between p-2.5 bg-slate-50 hover:bg-rose-50/60 rounded-2xl border border-slate-100 text-xs transition",children:[f.jsxs("div",{className:"flex items-center gap-2 font-bold text-slate-700 min-w-0",children:[f.jsx("span",{className:"text-rose-500",children:"📍"}),f.jsx("span",{className:"truncate",children:_})]}),f.jsxs("span",{className:"px-2.5 py-1 rounded-full bg-rose-100 text-rose-700 font-extrabold text-[10px] shrink-0",children:[y," naissance(s) →"]})]},M)):f.jsx("p",{className:"text-xs text-slate-400 italic p-2",children:"Aucun lieu de naissance renseigné"})})]}),f.jsxs("div",{className:"bg-white p-6 rounded-3xl shadow-sm border border-slate-200/80 space-y-4 flex flex-col justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-xl bg-teal-50 text-teal-600 flex items-center justify-center shadow-inner",children:f.jsx(td,{size:20})}),f.jsxs("div",{children:[f.jsx("h4",{className:"font-extrabold text-slate-900 text-base",children:"Qualité des Fiches Familiales"}),f.jsx("p",{className:"text-xs text-slate-500",children:"Niveau de renseignement des membres"})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3 pt-1",children:[f.jsxs("div",{onClick:()=>x({title:"✨ Fiches 100% Complètes",subtitle:`${c.completeProfiles} profils ayant date, lieu, profession et photo`,icon:"✨",peopleList:c.completeList.map(_=>({..._,badgeText:"100% Complet"}))}),className:"cursor-pointer p-3.5 bg-emerald-50/80 hover:bg-emerald-100/80 border border-emerald-200/80 rounded-2xl flex flex-col items-center text-center transition",children:[f.jsx("span",{className:"text-2xl font-black text-emerald-700",children:c.completeProfiles}),f.jsx("span",{className:"text-[11px] font-bold text-emerald-800 mt-0.5",children:"Fiches Complètes →"})]}),f.jsxs("div",{onClick:()=>x({title:"⚠️ Fiches à Compléter",subtitle:`${c.total-c.completeProfiles} profils nécessitant des dates, photos ou détails`,icon:"⚠️",peopleList:c.incompleteList.map(_=>({..._,badgeText:"À compléter",subText:(_.date_naissance?"":"Date manquante • ")+(_.photo?"":"Photo manquante")}))}),className:"cursor-pointer p-3.5 bg-orange-50/80 hover:bg-orange-100/80 border border-orange-200/80 rounded-2xl flex flex-col items-center text-center transition",children:[f.jsx("span",{className:"text-2xl font-black text-orange-600",children:c.total-c.completeProfiles}),f.jsx("span",{className:"text-[11px] font-bold text-orange-800 mt-0.5",children:"À Compléter →"})]})]}),f.jsxs("div",{onClick:()=>x({title:"💍 Unions & Conjoints Répertoriés",subtitle:`${c.marriedCount} personnes ayant une union ou mariage enregistré`,icon:"💍",peopleList:c.marriedList.map(_=>({..._,badgeText:Array.isArray(_.conjoint)?_.conjoint.join(", "):String(_.conjoint||"Union")}))}),className:"cursor-pointer flex items-center justify-between text-xs text-slate-600 p-2 rounded-xl hover:bg-indigo-50 border border-transparent hover:border-indigo-100 transition",children:[f.jsxs("span",{className:"flex items-center gap-1.5 font-bold",children:[f.jsx("span",{children:"💍"})," Unions & Conjoints répertoriés :"]}),f.jsxs("span",{className:"font-extrabold text-indigo-600",children:[c.marriedCount," personnes →"]})]})]})]}),f.jsx(Da,{children:s&&f.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-3 sm:p-6 bg-slate-950/70 backdrop-blur-md",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"bg-white rounded-3xl shadow-2xl border border-slate-200 w-full max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",children:[f.jsxs("div",{className:"p-5 sm:p-6 border-b border-slate-100 flex items-start justify-between gap-3 bg-slate-50/50",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f.jsx("div",{className:"w-10 h-10 rounded-2xl bg-amber-500/20 text-amber-700 flex items-center justify-center text-xl shrink-0",children:s.icon||"📊"}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("h3",{className:"text-base sm:text-lg font-serif font-black text-slate-900 truncate",children:s.title}),f.jsx("p",{className:"text-xs text-slate-500 truncate",children:s.subtitle})]})]}),f.jsx("button",{onClick:()=>a(null),className:"w-8 h-8 rounded-full bg-slate-200 hover:bg-slate-300 text-slate-700 flex items-center justify-center text-sm font-bold transition shrink-0",children:f.jsx($a,{})})]}),f.jsx("div",{className:"px-5 py-3 border-b border-slate-100 bg-white",children:f.jsxs("div",{className:"relative",children:[f.jsx(X0,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-400 text-xs"}),f.jsx("input",{type:"text",placeholder:"Filtrer par nom, lieu, profession...",value:o,onChange:_=>l(_.target.value),className:"w-full pl-9 pr-4 py-2 text-xs rounded-xl bg-slate-100 border border-slate-200 focus:outline-none focus:ring-2 focus:ring-amber-500/50"})]})}),f.jsx("div",{className:"p-4 sm:p-6 overflow-y-auto space-y-2 flex-1",children:g.length>0?g.map((_,y)=>{const M=_.person||_,C=_.badgeText,k=_.subText;return f.jsxs("div",{onClick:()=>{a(null),e&&e(M)},className:"cursor-pointer p-3 rounded-2xl bg-slate-50 hover:bg-amber-50/60 border border-slate-200/80 hover:border-amber-400 transition flex items-center justify-between gap-3 group",children:[f.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[f.jsx(q0,{person:M,className:"w-10 h-10 shrink-0 shadow-xs"}),f.jsxs("div",{className:"min-w-0",children:[f.jsxs("p",{className:"text-sm font-bold text-slate-800 group-hover:text-amber-900 truncate",children:[M.prenom," ",M.nom," ",M.surnom?`(${M.surnom})`:""]}),f.jsxs("p",{className:"text-xs text-slate-500 truncate",children:[k||(M.date_naissance?`Né(e) le ${M.date_naissance}`:"")," ",M.lieu_naissance?`• ${M.lieu_naissance}`:""]})]})]}),f.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[C&&f.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-extrabold bg-amber-100 text-amber-800 border border-amber-200",children:C}),f.jsx("span",{className:"text-xs font-bold text-amber-700 group-hover:translate-x-0.5 transition-transform",children:"Voir →"})]})]},M.slug||y)}):f.jsx("div",{className:"text-center py-8 text-slate-400 text-xs italic",children:"Aucun résultat trouvé pour cette recherche."})}),f.jsxs("div",{className:"p-4 border-t border-slate-100 bg-slate-50 flex justify-between items-center text-xs text-slate-500",children:[f.jsxs("span",{children:[g.length," membre(s) affiché(s)"]}),f.jsx("button",{onClick:()=>a(null),className:"px-4 py-1.5 rounded-xl bg-slate-200 hover:bg-slate-300 text-slate-800 font-bold transition",children:"Fermer"})]})]})})})]})}const FE="https://famille.ravin-cloud.fr";function A_t({person:n,onClose:e,onUpdated:t,onDelete:r}){const[i,s]=de.useState({prenom:n.prenom||"",nom:n.nom||"",nom_jeune_fille:n.nom_jeune_fille||n.nom_naissance||"",nom_marital:n.nom_marital||"",surnom:n.surnom||"",sexe:n.sexe||"Homme",email:n.email||"",instagram:n.instagram||n.reseaux_sociaux&&n.reseaux_sociaux.instagram||"",facebook:n.facebook||n.reseaux_sociaux&&n.reseaux_sociaux.facebook||"",tiktok:n.tiktok||n.reseaux_sociaux&&n.reseaux_sociaux.tiktok||"",linkedin:n.linkedin||n.reseaux_sociaux&&n.reseaux_sociaux.linkedin||"",twitter:n.twitter||n.x||n.reseaux_sociaux&&(n.reseaux_sociaux.twitter||n.reseaux_sociaux.x)||"",date_naissance:n.date_naissance||n.annee_naissance||"",lieu_naissance:n.lieu_naissance||n.ville_naissance||"",date_deces:n.date_deces||n.annee_deces||"",lieu_deces:n.lieu_deces||n.ville_deces||"",profession:n.profession||"",date_mariage:n.date_mariage||"",lieu_mariage:n.lieu_mariage||"",date_divorce:n.date_divorce||"",lieu_divorce:n.lieu_divorce||"",type_union:n.type_union||n.statut_union||"En couple",photo_url:n.photo_url||n.photo||"",hobbies:Array.isArray(n.hobbies)?n.hobbies.join(", "):n.hobbies||"",traits_personnalite:Array.isArray(n.traits_personnalite)?n.traits_personnalite.join(", "):n.traits_personnalite||"",biographie:n.biographie||"",evenements_marquants:Array.isArray(n.evenements_marquants)?n.evenements_marquants.join(", "):n.evenements_marquants||"",notes:n.notes||""}),[a,o]=de.useState(""),[l,c]=de.useState(!1),[u,d]=de.useState(!1),[h,p]=de.useState(!1),[g,x]=de.useState(!1),_=k=>{const{name:B,value:U}=k.target;s(z=>({...z,[B]:U}))},y=async k=>{const B=(k||a||i.instagram||i.tiktok||i.facebook||i.linkedin||i.twitter||"").trim();if(!B){jt.error("Veuillez renseigner un lien de profil (Instagram, TikTok, Facebook, LinkedIn, etc.)");return}c(!0);const U=jt.loading("Récupération de la photo de profil...");try{const z=await fetch(`${FE}/api/people/${n.slug}/fetch_social_avatar`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:B,slug:n.slug,save:!0})}),O=await z.json();if(!z.ok)throw new Error(O.error||"Impossible de récupérer l'avatar");s(V=>{const $={...V,photo_url:O.photo_url};return O.platform==="instagram"&&!V.instagram&&($.instagram=B),O.platform==="tiktok"&&!V.tiktok&&($.tiktok=B),O.platform==="facebook"&&!V.facebook&&($.facebook=B),O.platform==="linkedin"&&!V.linkedin&&($.linkedin=B),O.platform==="twitter"&&!V.twitter&&($.twitter=B),$}),jt.success(O.message||`Photo de profil ${O.platform} enregistrée avec succès !`,{id:U,icon:"📸"})}catch(z){jt.error(z.message||"Erreur lors de la récupération",{id:U})}finally{c(!1)}},M=async k=>{if(k.preventDefault(),!i.prenom.trim()||!i.nom.trim()){jt.error("Le prénom et le nom sont obligatoires.");return}d(!0);const B=jt.loading("Mise à jour de la fiche...");try{const U=await fetch(`${FE}/api/people/${n.slug}/update`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(i)}),z=await U.json();if(!U.ok)throw new Error(z.error||"Erreur de sauvegarde");jt.success("Fiche modifiée avec succès !",{id:B}),t&&t(z.slug||n.slug),e()}catch(U){jt.error(`Erreur: ${U.message}`,{id:B})}finally{d(!1)}},C=async()=>{p(!0);const k=jt.loading("Suppression de la fiche...");try{const B=await fetch(`${FE}/api/people/${n.slug}`,{method:"DELETE",credentials:"include"}),U=await B.json();if(!B.ok)throw new Error(U.error||"Erreur lors de la suppression");jt.success(`Fiche de ${n.prenom} ${n.nom} supprimée.`,{id:k}),r&&r(n.slug),e()}catch(B){jt.error(`Erreur: ${B.message}`,{id:k})}finally{p(!1)}};return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-950/80 backdrop-blur-md overflow-y-auto",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"w-full max-w-2xl bg-slate-900 border border-slate-800 rounded-[2.5rem] p-6 sm:p-8 shadow-2xl text-slate-100 relative my-8 max-h-[90vh] overflow-y-auto custom-scrollbar",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-4 mb-6 sticky top-0 bg-slate-900 z-10",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"p-3 bg-emerald-500/20 text-emerald-400 rounded-2xl border border-emerald-500/30",children:f.jsx(hm,{size:20})}),f.jsxs("div",{children:[f.jsxs("h2",{className:"text-xl font-extrabold text-white",children:["Modifier la fiche de ",f.jsxs("span",{className:"text-emerald-400",children:[n.prenom," ",n.nom]})]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Éditez les informations de l'archivage familial"})]})]}),f.jsx("button",{onClick:e,className:"p-2.5 bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white rounded-full transition-colors",children:f.jsx($a,{size:16})})]}),f.jsxs("form",{onSubmit:M,className:"space-y-5",children:[f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"Prénom *"}),f.jsx("input",{type:"text",name:"prenom",value:i.prenom,onChange:_,required:!0,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"Nom *"}),f.jsx("input",{type:"text",name:"nom",value:i.nom,onChange:_,required:!0,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"Sexe"}),f.jsxs("select",{name:"sexe",value:i.sexe,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500 cursor-pointer",children:[f.jsx("option",{value:"Homme",children:"♂️ Homme"}),f.jsx("option",{value:"Femme",children:"♀️ Femme"})]})]})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"Nom de jeune fille / Naissance"}),f.jsx("input",{type:"text",name:"nom_jeune_fille",placeholder:"Nom de naissance...",value:i.nom_jeune_fille,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"Nom marital / Nom d'usage"}),f.jsx("input",{type:"text",name:"nom_marital",placeholder:"Nom d'époux / épouse...",value:i.nom_marital,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"Surnom / Sobriquet"}),f.jsx("input",{type:"text",name:"surnom",placeholder:"Ex: Bobo, Doudou...",value:i.surnom,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(wK,{className:"text-emerald-400"})," Date de Naissance"]}),f.jsx("input",{type:"text",name:"date_naissance",placeholder:"AAAA-MM-JJ ou 1985",value:i.date_naissance,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(bA,{className:"text-emerald-400"})," Lieu de Naissance"]}),f.jsx("input",{type:"text",name:"lieu_naissance",placeholder:"Paris, France...",value:i.lieu_naissance,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(wK,{className:"text-slate-400"})," Date de Décès (si applicable)"]}),f.jsx("input",{type:"text",name:"date_deces",placeholder:"AAAA-MM-JJ ou 1985",value:i.date_deces,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(bA,{className:"text-slate-400"})," Lieu de Décès"]}),f.jsx("input",{type:"text",name:"lieu_deces",placeholder:"Lyon, France...",value:i.lieu_deces,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(Wp,{className:"text-emerald-400"})," Profession"]}),f.jsx("input",{type:"text",name:"profession",placeholder:"Ingénieur, Médecin, Enseignant...",value:i.profession,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(Y0,{className:"text-pink-400"})," Date de Mariage"]}),f.jsx("input",{type:"text",name:"date_mariage",placeholder:"AAAA-MM-JJ",value:i.date_mariage,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(bA,{className:"text-pink-400"})," Lieu de Mariage"]}),f.jsx("input",{type:"text",name:"lieu_mariage",placeholder:"Marseille, France...",value:i.lieu_mariage,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"Type d'union"}),f.jsxs("select",{name:"type_union",value:i.type_union,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500 cursor-pointer",children:[f.jsx("option",{value:"En couple",children:"En couple"}),f.jsx("option",{value:"Marié(e)",children:"Marié(e)"}),f.jsx("option",{value:"Pacsé(e)",children:"Pacsé(e)"}),f.jsx("option",{value:"Divorcé(e)",children:"Divorcé(e)"}),f.jsx("option",{value:"Séparé(e)",children:"Séparé(e)"}),f.jsx("option",{value:"Célibataire",children:"Célibataire"}),f.jsx("option",{value:"Veuf/Veuve",children:"Veuf/Veuve"})]})]})]}),(i.type_union==="Divorcé(e)"||i.type_union==="Séparé(e)"||i.date_divorce)&&f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 bg-purple-950/20 p-3 rounded-2xl border border-purple-900/40",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-purple-300 mb-1",children:"Date de Divorce / Séparation"}),f.jsx("input",{type:"text",name:"date_divorce",placeholder:"AAAA-MM-JJ",value:i.date_divorce,onChange:_,className:"w-full bg-slate-950 border border-purple-800/60 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-purple-400"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-purple-300 mb-1",children:"Lieu de Divorce"}),f.jsx("input",{type:"text",name:"lieu_divorce",placeholder:"Tribunal de Grande Instance...",value:i.lieu_divorce,onChange:_,className:"w-full bg-slate-950 border border-purple-800/60 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-purple-400"})]})]}),f.jsxs("div",{className:"bg-slate-950/80 border border-slate-800/90 rounded-2xl p-4 space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("label",{className:"text-xs font-bold text-white flex items-center gap-2",children:[f.jsx(fm,{className:"text-indigo-400"})," Photo & Import Réseaux Sociaux"]}),i.photo_url&&f.jsxs("span",{className:"text-[10px] text-emerald-400 font-semibold flex items-center gap-1",children:[f.jsx(td,{})," Photo active"]})]}),f.jsxs("div",{className:"bg-gradient-to-r from-indigo-950/40 via-purple-950/30 to-pink-950/30 border border-indigo-500/30 rounded-xl p-3 space-y-2",children:[f.jsxs("div",{className:"text-[11px] font-bold text-indigo-300 flex items-center gap-1.5",children:[f.jsx(ld,{className:"text-pink-400"})," Récupérer automatiquement la photo de profil depuis un lien :"]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("input",{type:"text",placeholder:"Lien Instagram, TikTok, Facebook, LinkedIn, X, ou image...",value:a,onChange:k=>o(k.target.value),className:"flex-1 bg-slate-900 border border-indigo-500/40 rounded-xl px-3 py-2 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-pink-400"}),f.jsxs("button",{type:"button",onClick:()=>y(a),disabled:l,className:"px-3 py-2 bg-gradient-to-r from-indigo-600 to-pink-600 hover:from-indigo-500 hover:to-pink-500 text-white rounded-xl text-xs font-bold transition-all shadow-md flex items-center gap-1.5 shrink-0 disabled:opacity-50",children:[l?f.jsx(vu,{className:"animate-spin"}):f.jsx(T3,{}),f.jsx("span",{children:l?"Récupération...":"⚡ Importer Photo"})]})]}),f.jsx("p",{className:"text-[10px] text-slate-400",children:"💡 L'image est automatiquement téléchargée et stockée sur votre NAS."})]}),(()=>{const k=(()=>{const B=new Set;return n.photo&&B.add(n.photo),n.photo_url&&B.add(n.photo_url),n.avatar&&B.add(n.avatar),Array.isArray(n.photos)&&n.photos.forEach(U=>{typeof U=="string"?B.add(U):U&&U.src&&B.add(U.src)}),Array.isArray(n.evenements_marquants)&&n.evenements_marquants.forEach(U=>{typeof U=="object"&&U!==null&&(U.photo&&B.add(U.photo),U.event_photo&&B.add(U.event_photo),Array.isArray(U.photos)&&U.photos.forEach(z=>typeof z=="string"&&B.add(z)))}),Array.from(B).filter(Boolean)})();return k.length===0?null:f.jsxs("div",{className:"space-y-2 pt-2 border-t border-slate-800/80",children:[f.jsxs("label",{className:"block text-[11px] font-bold text-amber-300 flex items-center justify-between",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:["📸 Choisir parmi ses photos (",k.length,") :"]}),f.jsx("span",{className:"text-[10px] text-slate-400 font-normal",children:"Cliquez pour sélectionner"})]}),f.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2 max-h-36 overflow-y-auto p-2 bg-slate-900/80 rounded-xl border border-slate-800",children:k.map((B,U)=>{const z=B.startsWith("/")?`${FE}${B}`:B,O=i.photo_url===B||i.photo_url===z;return f.jsxs("button",{type:"button",onClick:()=>s(V=>({...V,photo_url:B})),className:`relative aspect-square rounded-lg overflow-hidden border-2 transition-all cursor-pointer ${O?"border-emerald-400 ring-2 ring-emerald-400/50 scale-95":"border-slate-800 hover:border-amber-400 opacity-70 hover:opacity-100"}`,title:"Définir comme photo de profil",children:[f.jsx("img",{src:z,alt:"Thumbnail",className:"w-full h-full object-cover"}),O&&f.jsx("div",{className:"absolute inset-0 bg-emerald-500/40 flex items-center justify-center",children:f.jsx("span",{className:"bg-emerald-500 text-white rounded-full p-1 text-[10px] font-black",children:"✓"})})]},U)})})]})})(),f.jsxs("div",{children:[f.jsx("label",{className:"block text-[11px] font-medium text-slate-400 mb-1",children:"Chemin ou URL de la Photo"}),f.jsx("input",{type:"text",name:"photo_url",placeholder:"/uploads/photo.jpg ou https://...",value:i.photo_url,onChange:_,className:"w-full bg-slate-900 border border-slate-800 rounded-xl px-3 py-2 text-xs text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{className:"pt-2 border-t border-slate-800/80 space-y-2.5",children:[f.jsx("span",{className:"text-[11px] font-bold text-slate-300 flex items-center gap-1.5",children:"Liens & Contacts Personnels :"}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5",children:[f.jsxs("div",{children:[f.jsxs("label",{className:"block text-[10px] font-semibold text-slate-400 mb-1 flex items-center gap-1",children:[f.jsx(AH,{className:"text-slate-400"})," Email"]}),f.jsx("input",{type:"email",name:"email",placeholder:"exemple@domaine.com",value:i.email,onChange:_,className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2.5 py-1.5 text-xs text-white focus:outline-none focus:border-indigo-500"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsxs("label",{className:"text-[10px] font-semibold text-pink-400 flex items-center gap-1",children:[f.jsx(Gpe,{})," Instagram"]}),i.instagram&&f.jsx("button",{type:"button",onClick:()=>y(i.instagram),className:"text-[9px] text-pink-300 hover:text-white underline flex items-center gap-0.5",children:"⚡ Photo"})]}),f.jsx("input",{type:"text",name:"instagram",placeholder:"https://instagram.com/nom ou @pseudo",value:i.instagram,onChange:_,className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2.5 py-1.5 text-xs text-white focus:outline-none focus:border-pink-500"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsxs("label",{className:"text-[10px] font-semibold text-cyan-400 flex items-center gap-1",children:[f.jsx(Vpe,{})," TikTok"]}),i.tiktok&&f.jsx("button",{type:"button",onClick:()=>y(i.tiktok),className:"text-[9px] text-cyan-300 hover:text-white underline flex items-center gap-0.5",children:"⚡ Photo"})]}),f.jsx("input",{type:"text",name:"tiktok",placeholder:"https://tiktok.com/@pseudo",value:i.tiktok,onChange:_,className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2.5 py-1.5 text-xs text-white focus:outline-none focus:border-cyan-500"})]}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsxs("label",{className:"text-[10px] font-semibold text-blue-400 flex items-center gap-1",children:[f.jsx(Hpe,{})," Facebook"]}),i.facebook&&f.jsx("button",{type:"button",onClick:()=>y(i.facebook),className:"text-[9px] text-blue-300 hover:text-white underline flex items-center gap-0.5",children:"⚡ Photo"})]}),f.jsx("input",{type:"text",name:"facebook",placeholder:"https://facebook.com/nom",value:i.facebook,onChange:_,className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2.5 py-1.5 text-xs text-white focus:outline-none focus:border-blue-500"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-[10px] font-semibold text-sky-400 mb-1 flex items-center gap-1",children:[f.jsx(qpe,{})," LinkedIn"]}),f.jsx("input",{type:"text",name:"linkedin",placeholder:"https://linkedin.com/in/nom",value:i.linkedin,onChange:_,className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2.5 py-1.5 text-xs text-white focus:outline-none focus:border-sky-500"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-[10px] font-semibold text-slate-300 mb-1 flex items-center gap-1",children:[f.jsx(zpe,{})," X / Twitter"]}),f.jsx("input",{type:"text",name:"twitter",placeholder:"https://x.com/pseudo",value:i.twitter,onChange:_,className:"w-full bg-slate-900 border border-slate-800 rounded-lg px-2.5 py-1.5 text-xs text-white focus:outline-none focus:border-slate-400"})]})]})]})]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:"🎨 Hobbies (séparés par des virgules)"}),f.jsx("input",{type:"text",name:"hobbies",placeholder:"Musique, Jardinage, Peinture...",value:i.hobbies,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold text-slate-400 mb-1 flex items-center gap-1.5",children:[f.jsx(fCe,{className:"text-amber-400"})," Traits de Personnalité"]}),f.jsx("input",{type:"text",name:"traits_personnalite",placeholder:"Calme, Curieux, Généreux...",value:i.traits_personnalite,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl px-3.5 py-2.5 text-sm text-white focus:outline-none focus:border-emerald-500"})]})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-bold text-slate-400 mb-1",children:"📖 Biographie & Anecdotes"}),f.jsx("textarea",{name:"biographie",rows:4,placeholder:"Écrivez quelques mots sur son parcours...",value:i.biographie,onChange:_,className:"w-full bg-slate-950 border border-slate-800 rounded-xl p-3 text-sm text-white focus:outline-none focus:border-emerald-500 resize-none"})]}),g&&f.jsxs("div",{className:"p-4 bg-red-950/60 border border-red-800/80 rounded-2xl space-y-3",children:[f.jsxs("p",{className:"text-xs font-bold text-red-300",children:["⚠️ Êtes-vous sûr de vouloir supprimer définitivement la fiche de ",f.jsxs("strong",{className:"text-white",children:[n.prenom," ",n.nom]})," ? Cette action est irréversible."]}),f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("button",{type:"button",onClick:C,disabled:h,className:"px-4 py-2 bg-red-600 hover:bg-red-500 text-white rounded-xl text-xs font-bold transition-all shadow-md",children:h?"Suppression...":"Oui, supprimer définitivement"}),f.jsx("button",{type:"button",onClick:()=>x(!1),className:"px-4 py-2 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded-xl text-xs font-bold transition-all",children:"Annuler"})]})]}),f.jsxs("div",{className:"pt-4 border-t border-slate-800 flex items-center justify-between gap-3",children:[!g&&f.jsxs("button",{type:"button",onClick:()=>x(!0),className:"px-4 py-2.5 bg-red-950/40 hover:bg-red-900/60 text-red-400 border border-red-800/50 rounded-xl text-xs font-bold flex items-center gap-2 transition-all",children:[f.jsx(z0,{size:12})," Supprimer la fiche"]}),f.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[f.jsx("button",{type:"button",onClick:e,className:"px-5 py-2.5 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded-xl text-xs font-bold transition-all",children:"Annuler"}),f.jsxs("button",{type:"submit",disabled:u,className:"px-6 py-2.5 bg-emerald-600 hover:bg-emerald-500 text-white rounded-xl text-xs font-bold flex items-center gap-2 transition-all shadow-lg shadow-emerald-600/30 disabled:opacity-50",children:[f.jsx(dH,{size:14})," ",u?"Enregistrement...":"Enregistrer"]})]})]})]})]})})}const Oh="https://famille.ravin-cloud.fr";function x_t({isOpen:n,onClose:e}){var st,Ht;const{user:t}=o1(),r=(t==null?void 0:t.role)==="super_admin",[i,s]=de.useState("access"),[a,o]=de.useState({}),[l,c]=de.useState([]),[u,d]=de.useState(!0),[h,p]=de.useState(""),[g,x]=de.useState(null),[_,y]=de.useState(!1),[M,C]=de.useState(""),[k,B]=de.useState("all"),[U,z]=de.useState([]),[O,V]=de.useState(!1),[$,G]=de.useState("all"),[H,K]=de.useState(null),[W,J]=de.useState(""),[ie,ae]=de.useState("user"),[Q,re]=de.useState("approved"),[oe,fe]=de.useState(!0),[ee,me]=de.useState([]);de.useEffect(()=>{n&&Ae()},[n]);const Ae=async()=>{d(!0);try{const[Se,_t]=await Promise.all([fetch(`${Oh}/api/admin/users`,{credentials:"include"}),fetch(`${Oh}/api/admin/surnames`,{credentials:"include"})]);if(Se.ok){const It=await Se.json();o(It)}else li.error("Erreur lors de la récupération des utilisateurs");if(_t.ok){const It=await _t.json();c(It)}}catch(Se){console.error(Se),li.error("Erreur de connexion avec le serveur d'administration")}finally{d(!1)}},be=async()=>{y(!0);try{const Se=await fetch(`${Oh}/api/admin/logs`,{credentials:"include"});if(Se.ok){const _t=await Se.json();x(_t)}else li.error("Impossible de récupérer les logs")}catch{li.error("Erreur réseau lors de la récupération des logs")}finally{y(!1)}},pe=async()=>{if(window.confirm("Êtes-vous sûr de vouloir réinitialiser le fichier de log (max 1 Mo) ?"))try{const Se=await fetch(`${Oh}/api/admin/logs/clear`,{method:"POST",credentials:"include"});if(Se.ok)li.success("Journal de log réinitialisé"),be();else{const _t=await Se.json();li.error(_t.error||"Erreur lors de la réinitialisation")}}catch{li.error("Erreur réseau")}},ge=async()=>{V(!0);try{const Se=await fetch(`${Oh}/api/admin/ai-generations${$!=="all"?`?type=${$}`:""}`,{credentials:"include"});if(Se.ok){const _t=await Se.json();z(_t.generations||[])}}catch(Se){console.error("Failed to load AI archive",Se)}finally{V(!1)}},Te=async Se=>{if(window.confirm("Supprimer définitivement cet élément de l'archive IA ?"))try{(await fetch(`${Oh}/api/admin/ai-generations/${Se}`,{method:"DELETE",credentials:"include"})).ok&&(li.success("Génération supprimée de l'archive"),ge())}catch{li.error("Erreur de suppression")}},ze=async(Se,_t)=>{const It=a[Se]||{role:"user",status:"approved",allowed_last_names:[]};let De=It.allowed_last_names||[],ue;_t==="*"?De.includes("*")?ue=[]:ue=["*"]:De.includes("*")?ue=l.filter(Ve=>Ve!==_t):De.includes(_t)?ue=De.filter(Ve=>Ve!==_t):ue=[...De,_t],o(Ve=>({...Ve,[Se]:{...Ve[Se],allowed_last_names:ue}}));try{const Ve=await fetch(`${Oh}/api/admin/permissions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:Se,role:It.role||"user",status:It.status||"approved",allowed_last_names:ue})});if(Ve.ok)li.success(`Permissions mises à jour pour ${Se}`,{duration:1500});else{const We=await Ve.json();li.error(We.error||"Erreur lors de la mise à jour"),Ae()}}catch{li.error("Erreur de connexion"),Ae()}},Xe=async(Se,_t=["*"])=>{const It=a[Se]||{};try{const De=await fetch(`${Oh}/api/admin/permissions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:Se,role:It.role==="admin"&&r?"admin":"user",status:"approved",allowed_last_names:_t})});if(De.ok)li.success(`Compte approuvé pour ${Se} !`),Ae();else{const ue=await De.json();li.error(ue.error||"Erreur lors de l'approbation")}}catch{li.error("Erreur de connexion")}},Qe=async Se=>{if(window.confirm(`Voulez-vous bloquer / refuser l'accès pour ${Se} ?`))try{const _t=await fetch(`${Oh}/api/admin/permissions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:Se,role:"user",status:"rejected",allowed_last_names:[]})});if(_t.ok)li.success(`Accès refusé pour ${Se}`),Ae();else{const It=await _t.json();li.error(It.error||"Erreur lors du refus")}}catch{li.error("Erreur de connexion")}},ot=async(Se,_t)=>{try{const It=await fetch(`${Oh}/api/admin/claim/${_t}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:Se})});if(It.ok)li.success(`Revendication ${_t==="approve"?"approuvée":"rejetée"}.`),Ae();else{const De=await It.json();li.error(De.error||"Erreur")}}catch{li.error("Erreur de connexion")}},bt=async Se=>{if(window.confirm(`Supprimer définitivement les règles pour ${Se} ?`))try{const _t=await fetch(`${Oh}/api/admin/users`,{method:"DELETE",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:Se})});if(_t.ok)li.success(`Utilisateur ${Se} supprimé`),Ae();else{const It=await _t.json();li.error(It.error||"Erreur lors de la suppression")}}catch{li.error("Erreur de connexion")}},ht=async Se=>{if(Se.preventDefault(),!W.trim()){li.error("Veuillez saisir une adresse e-mail");return}const _t=oe?["*"]:ee;try{const It=await fetch(`${Oh}/api/admin/permissions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:W.trim(),role:ie,status:Q,allowed_last_names:_t})});if(It.ok)li.success(`Droits enregistrés pour ${W}`),J(""),me([]),fe(!0),Ae();else{const De=await It.json();li.error(De.error||"Erreur lors de l'enregistrement")}}catch{li.error("Erreur réseau")}},Ce=(Se,_t)=>{J(Se),ae(_t.role||"user"),re(_t.status||"approved");const It=_t.allowed_last_names||[];It.includes("*")?(fe(!0),me([])):(fe(!1),me(It))};if(!n)return null;const lt=Object.entries(a||{}),ft=lt.filter(([Se,_t])=>_t&&_t.status==="pending");lt.filter(([Se,_t])=>_t&&_t.status!=="pending");const et=lt.reduce((Se,[_t,It])=>(It&&It.pending_claim&&(Se[_t]=It),Se),{}),At=lt.filter(([Se,_t])=>{const It=h.toLowerCase();return Se.toLowerCase().includes(It)||(_t==null?void 0:_t.name)&&_t.name.toLowerCase().includes(It)}),Lt=((g==null?void 0:g.recent_lines)||[]).filter(Se=>{if(k==="errors"&&!Se.includes("[ERREUR")&&!Se.includes("[EXCEPTION")&&!Se.includes("[CRITICAL")||k==="actions"&&!Se.includes("[ACTION"))return!1;if(M.trim()){const _t=M.toLowerCase();return Se.toLowerCase().includes(_t)}return!0});return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-md p-2 sm:p-4 overflow-y-auto",children:f.jsxs("div",{className:"bg-slate-900 border border-slate-700/80 rounded-3xl w-full max-w-6xl max-h-[92vh] flex flex-col shadow-2xl overflow-hidden text-slate-100 font-sans",children:[f.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-slate-800 bg-slate-950/90 sticky top-0 z-20",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-2xl bg-amber-500/20 border border-amber-500/40 flex items-center justify-center text-amber-400",children:f.jsx(_K,{className:"text-xl"})}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h2",{className:"text-lg sm:text-xl font-bold bg-gradient-to-r from-amber-400 via-amber-200 to-yellow-100 bg-clip-text text-transparent",children:"Administration Globale & Sécurité"}),f.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-bold bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:r?"Super Admin":"Admin"})]}),f.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:"Gestion des droits d'accès, suivi des activités utilisateurs et traçage des erreurs en temps réel."})]})]}),f.jsx("button",{onClick:e,className:"p-2.5 text-slate-400 hover:text-white rounded-xl hover:bg-slate-800 transition-colors",children:f.jsx($a,{size:18})})]}),f.jsxs("div",{className:"flex items-center gap-2 px-6 pt-3 pb-2 border-b border-slate-800/80 bg-slate-950/60 overflow-x-auto",children:[f.jsxs("button",{onClick:()=>s("access"),className:`px-4 py-2 rounded-xl text-xs font-bold transition flex items-center gap-2 whitespace-nowrap ${i==="access"?"bg-amber-500/20 text-amber-300 border border-amber-500/40 shadow-sm":"text-slate-400 hover:text-white hover:bg-slate-800/60"}`,children:[f.jsx(uH,{})," Matrice des Droits & Accès"]}),f.jsxs("button",{onClick:()=>{s("logs"),be()},className:`px-4 py-2 rounded-xl text-xs font-bold transition flex items-center gap-2 whitespace-nowrap ${i==="logs"?"bg-sky-500/20 text-sky-300 border border-sky-500/40 shadow-sm":"text-slate-400 hover:text-white hover:bg-slate-800/60"}`,children:[f.jsx(Qpe,{})," Journal d'Activité & Erreurs",g&&f.jsxs("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] bg-slate-800 text-slate-300 border border-slate-700",children:[g.size_kb," Ko"]})]}),f.jsxs("button",{onClick:()=>{s("ai_archive"),ge()},className:`px-4 py-2 rounded-xl text-xs font-bold transition flex items-center gap-2 whitespace-nowrap ${i==="ai_archive"?"bg-purple-500/20 text-purple-300 border border-purple-500/40 shadow-sm":"text-slate-400 hover:text-white hover:bg-slate-800/60"}`,children:[f.jsx("span",{children:"🤖"})," Archive des Générations IA",U.length>0&&f.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] bg-purple-900/60 text-purple-300 border border-purple-700",children:U.length})]})]}),f.jsx("div",{className:"p-4 sm:p-6 overflow-y-auto space-y-8 flex-1",children:i==="logs"?f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[f.jsxs("div",{className:"bg-slate-800/80 border border-slate-700/80 rounded-2xl p-4 flex flex-col justify-between",children:[f.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[f.jsx("span",{children:"Taille du Journal"}),f.jsx("span",{className:"text-[10px] bg-sky-500/20 text-sky-300 px-2 py-0.5 rounded-full font-bold",children:"Max 1 Mo"})]}),f.jsxs("div",{className:"mt-2 text-2xl font-black text-sky-400",children:[(g==null?void 0:g.size_kb)||0," ",f.jsx("span",{className:"text-sm font-normal text-slate-400",children:"Ko / 1024 Ko"})]}),f.jsx("div",{className:"w-full bg-slate-900 rounded-full h-1.5 mt-3 overflow-hidden",children:f.jsx("div",{className:"bg-gradient-to-r from-sky-400 to-blue-600 h-full rounded-full transition-all duration-500",style:{width:`${Math.min(100,((g==null?void 0:g.size_bytes)||0)/(1024*1024)*100)}%`}})})]}),f.jsxs("div",{className:"bg-slate-800/80 border border-slate-700/80 rounded-2xl p-4",children:[f.jsx("span",{className:"text-xs text-slate-400",children:"Lignes enregistrées"}),f.jsx("div",{className:"mt-2 text-2xl font-black text-amber-400",children:(g==null?void 0:g.total_lines)||0}),f.jsx("span",{className:"text-[11px] text-slate-500",children:"Derniers 500 événements"})]}),f.jsxs("div",{className:"bg-slate-800/80 border border-slate-700/80 rounded-2xl p-4",children:[f.jsx("span",{className:"text-xs text-slate-400",children:"Erreurs & Exceptions"}),f.jsx("div",{className:"mt-2 text-2xl font-black text-rose-400",children:((st=g==null?void 0:g.recent_lines)==null?void 0:st.filter(Se=>Se.includes("[ERREUR")||Se.includes("[EXCEPTION")||Se.includes("[CRITICAL")).length)||0}),f.jsx("span",{className:"text-[11px] text-rose-400/80",children:"Sur les logs récents"})]}),f.jsxs("div",{className:"bg-slate-800/80 border border-slate-700/80 rounded-2xl p-4",children:[f.jsx("span",{className:"text-xs text-slate-400",children:"Actions Utilisateurs"}),f.jsx("div",{className:"mt-2 text-2xl font-black text-emerald-400",children:((Ht=g==null?void 0:g.recent_lines)==null?void 0:Ht.filter(Se=>Se.includes("[ACTION")).length)||0}),f.jsx("span",{className:"text-[11px] text-emerald-400/80",children:"Créations, modifs, liens"})]})]}),f.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3 bg-slate-950/60 p-3 rounded-2xl border border-slate-800",children:[f.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto flex-1",children:[f.jsxs("div",{className:"relative w-full sm:w-80",children:[f.jsx(X0,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-slate-500 text-xs"}),f.jsx("input",{type:"text",value:M,onChange:Se=>C(Se.target.value),placeholder:"Filtrer (utilisateur, IP, route, mot clé)...",className:"w-full pl-9 pr-3 py-2 bg-slate-900 border border-slate-700/80 rounded-xl text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:border-sky-500"})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:()=>B("all"),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition ${k==="all"?"bg-slate-700 text-white":"text-slate-400 hover:text-white"}`,children:"Tous"}),f.jsx("button",{onClick:()=>B("errors"),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition flex items-center gap-1 ${k==="errors"?"bg-rose-500/20 text-rose-300 border border-rose-500/30":"text-slate-400 hover:text-rose-400"}`,children:"🚨 Erreurs"}),f.jsx("button",{onClick:()=>B("actions"),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition flex items-center gap-1 ${k==="actions"?"bg-emerald-500/20 text-emerald-300 border border-emerald-500/30":"text-slate-400 hover:text-emerald-400"}`,children:"⚡ Actions"})]})]}),f.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[f.jsxs("button",{onClick:be,disabled:_,className:"p-2.5 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded-xl text-xs transition flex items-center gap-1.5",title:"Actualiser les logs",children:[f.jsx(AM,{className:_?"animate-spin text-sky-400":""}),f.jsx("span",{children:"Actualiser"})]}),f.jsxs("a",{href:`${Oh}/api/admin/logs/download`,className:"px-3.5 py-2 bg-sky-600 hover:bg-sky-500 text-white rounded-xl text-xs font-bold transition flex items-center gap-1.5 shadow-md shadow-sky-600/20",children:[f.jsx(T3,{}),f.jsx("span",{children:"Télécharger (.log)"})]}),r&&f.jsx("button",{onClick:pe,className:"p-2 bg-rose-600/20 hover:bg-rose-600/30 text-rose-400 border border-rose-500/30 rounded-xl text-xs transition",title:"Réinitialiser le journal",children:f.jsx(z0,{})})]})]}),f.jsxs("div",{className:"bg-slate-950 border border-slate-800 rounded-2xl p-4 overflow-hidden shadow-inner",children:[f.jsxs("div",{className:"flex items-center justify-between pb-3 mb-3 border-b border-slate-800 text-[11px] text-slate-500 font-mono",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(uCe,{className:"text-sky-400"}),f.jsxs("span",{children:["Journal en direct (Fichier : ",(g==null?void 0:g.log_path)||"activity_errors.log",")"]})]}),f.jsx("span",{children:"Du plus récent au plus ancien"})]}),f.jsx("div",{className:"font-mono text-xs overflow-x-auto max-h-[50vh] space-y-1.5 pr-2",children:Lt.length===0?f.jsx("div",{className:"text-center py-12 text-slate-600 italic",children:"Aucun événement ne correspond aux critères de filtre."}):Lt.map((Se,_t)=>{const It=Se.includes("[ERREUR")||Se.includes("[EXCEPTION")||Se.includes("[CRITICAL"),De=Se.includes("[ACTION"),ue=Se.includes("[LOG_RESET")||Se.includes("INITIALISATION");let Ve="text-slate-300",We="hover:bg-slate-900/60";return It?(Ve="text-rose-400 font-medium",We="bg-rose-950/20 border-l-2 border-rose-500 hover:bg-rose-950/30"):De?(Ve="text-emerald-300",We="bg-emerald-950/10 border-l-2 border-emerald-500 hover:bg-emerald-950/20"):ue&&(Ve="text-amber-300 font-bold",We="bg-amber-950/20 border-l-2 border-amber-500"),f.jsx("div",{className:`px-2.5 py-1 rounded-lg transition-colors whitespace-pre-wrap break-all ${We} ${Ve}`,children:Se},_t)})})]})]}):i==="ai_archive"?f.jsxs("div",{className:"space-y-6",children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 bg-slate-800/80 p-4 rounded-2xl border border-slate-700/80",children:[f.jsxs("div",{children:[f.jsxs("h3",{className:"text-base font-bold text-white flex items-center gap-2",children:[f.jsx("span",{children:"🤖"})," Archive Centrale des Générations IA"]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Retrouvez tout ce que l'IA a généré (Gazettes, Podcasts, Romans, Livres, Analyses)."})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("div",{className:"flex bg-slate-900 p-1 rounded-xl border border-slate-700 text-xs",children:["all","gazette","podcast","roman","livre"].map(Se=>f.jsx("button",{onClick:()=>{G(Se)},className:`px-3 py-1 rounded-lg capitalize font-bold transition ${$===Se?"bg-purple-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:Se==="all"?"✨ Tout":Se},Se))}),f.jsx("button",{onClick:ge,className:"p-2 bg-slate-700 hover:bg-slate-600 rounded-xl text-slate-200 transition",title:"Actualiser l'archive",children:f.jsx(AM,{size:12,className:O?"animate-spin":""})})]})]}),O?f.jsx("div",{className:"py-16 text-center text-slate-400 font-sans text-xs",children:"Chargement de l'archive IA..."}):U.length===0?f.jsx("div",{className:"py-16 text-center text-slate-500 font-sans text-sm bg-slate-800/30 rounded-2xl border border-dashed border-slate-700",children:"Aucune génération IA archivée pour le moment."}):f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:U.map(Se=>f.jsxs("div",{className:"bg-slate-800/80 p-4 rounded-2xl border border-slate-700 hover:border-purple-500/40 shadow-sm transition space-y-3 flex flex-col justify-between",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"text-[10px] font-black uppercase px-2 py-0.5 rounded-full bg-purple-900/60 text-purple-300 border border-purple-700",children:Se.type}),f.jsxs("span",{className:"text-[10px] text-slate-400",children:[Se.created_at," • ",Se.target_person]})]}),f.jsx("h4",{className:"font-bold text-white text-sm",children:Se.title}),f.jsxs("p",{className:"text-xs text-slate-300 line-clamp-3 italic bg-slate-950/40 p-2.5 rounded-xl border border-slate-800 font-serif",children:['"',Se.preview,'"']})]}),f.jsxs("div",{className:"pt-2 border-t border-slate-700/60 flex items-center justify-between gap-2",children:[f.jsxs("button",{onClick:()=>K(Se),className:"px-3 py-1.5 rounded-xl bg-purple-600 hover:bg-purple-500 text-white text-xs font-bold transition flex items-center gap-1.5",children:[f.jsx("span",{children:"👁️"})," Consulter"]}),f.jsx("button",{onClick:()=>Te(Se.id),className:"p-2 text-rose-400 hover:bg-rose-950/30 rounded-xl transition",title:"Supprimer définitivement",children:f.jsx(z0,{size:12})})]})]},Se.id))}),H&&f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4",children:f.jsxs("div",{className:"bg-slate-900 w-full max-w-2xl rounded-3xl p-6 shadow-2xl border border-purple-500/40 space-y-4 max-h-[85vh] flex flex-col text-slate-100",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 pb-3",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[10px] font-black uppercase text-purple-300 bg-purple-950 px-2.5 py-0.5 rounded-full border border-purple-700",children:H.type}),f.jsx("h3",{className:"text-lg font-bold text-white mt-1",children:H.title}),f.jsxs("p",{className:"text-xs text-slate-400",children:["Généré le ",H.created_at," pour ",H.target_person]})]}),f.jsx("button",{onClick:()=>K(null),className:"text-slate-400 hover:text-white font-bold text-lg",children:"✕"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-4 bg-slate-950 rounded-2xl border border-slate-800 text-sm font-mono whitespace-pre-wrap text-slate-200 custom-scrollbar",children:typeof H.content=="object"?JSON.stringify(H.content,null,2):H.content||H.preview}),f.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-slate-800",children:[f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(typeof H.content=="object"?JSON.stringify(H.content,null,2):H.content),li.success("Copié dans le presse-papier !")},className:"px-4 py-2 bg-slate-800 hover:bg-slate-700 text-white text-xs font-bold rounded-xl",children:"📋 Copier"}),f.jsx("button",{onClick:()=>K(null),className:"px-4 py-2 bg-purple-600 hover:bg-purple-500 text-white text-xs font-bold rounded-xl",children:"Fermer"})]})]})})]}):f.jsxs(f.Fragment,{children:[Object.keys(et).length>0&&f.jsxs("div",{className:"bg-slate-900 border border-slate-700 rounded-2xl overflow-hidden shadow-2xl mb-8",children:[f.jsxs("div",{className:"px-6 py-4 bg-gradient-to-r from-blue-900 to-slate-900 border-b border-slate-700 flex justify-between items-center",children:[f.jsxs("h3",{className:"text-xl font-black text-white font-serif tracking-tight flex items-center gap-2",children:[f.jsx(M7,{className:"text-blue-400"}),"Revendications de Profils"]}),f.jsxs("span",{className:"bg-blue-600/30 text-blue-400 text-xs px-2.5 py-1 rounded-full font-bold border border-blue-500/50",children:[Object.keys(et).length," en attente"]})]}),f.jsx("div",{className:"p-4 space-y-3",children:Object.entries(et).map(([Se,_t])=>f.jsxs("div",{className:"bg-slate-800 p-4 rounded-xl border border-slate-700 flex flex-col md:flex-row md:items-center justify-between gap-4",children:[f.jsxs("div",{children:[f.jsx("h4",{className:"text-slate-200 font-bold",children:Se}),f.jsxs("p",{className:"text-sm text-slate-400 mt-1",children:["Demande à être rattaché à la fiche : ",f.jsxs("span",{className:"font-bold text-blue-300",children:['"',_t.pending_claim,'"']})]})]}),f.jsxs("div",{className:"flex gap-2 shrink-0",children:[f.jsxs("button",{onClick:()=>ot(Se,"approve"),className:"px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white rounded-xl text-sm font-bold shadow-md transition flex items-center gap-2",children:[f.jsx(yM,{})," Accepter"]}),f.jsxs("button",{onClick:()=>ot(Se,"reject"),className:"px-4 py-2 bg-rose-600 hover:bg-rose-500 text-white rounded-xl text-sm font-bold shadow-md transition flex items-center gap-2",children:[f.jsx($a,{})," Refuser"]})]})]},Se))})]}),ft.length>0&&f.jsxs("div",{className:"bg-amber-950/30 border-2 border-amber-500/40 rounded-2xl p-5 shadow-lg relative overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between mb-4",children:[f.jsxs("div",{className:"flex items-center gap-2.5",children:[f.jsxs("span",{className:"flex h-3 w-3 relative",children:[f.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),f.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-amber-500"})]}),f.jsxs("h3",{className:"text-sm font-bold text-amber-300 uppercase tracking-wider",children:["Demandes en attente de validation (",ft.length,")"]})]}),f.jsx("span",{className:"text-xs text-amber-400/80 font-medium",children:"🔒 Accès bloqué par défaut tant que vous ne validez pas"})]}),f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:ft.map(([Se,_t])=>f.jsxs("div",{className:"bg-slate-900/90 border border-amber-500/30 rounded-xl p-4 flex flex-col justify-between gap-3 shadow-md",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[_t.picture?f.jsx("img",{src:_t.picture,alt:"",className:"w-10 h-10 rounded-full border border-amber-400/40 object-cover"}):f.jsx("div",{className:"w-10 h-10 rounded-full bg-slate-800 border border-slate-700 flex items-center justify-center text-slate-400",children:f.jsx(hm,{})}),f.jsxs("div",{className:"overflow-hidden",children:[f.jsx("p",{className:"font-semibold text-white text-sm truncate",children:_t.name||Se.split("@")[0]}),f.jsx("p",{className:"text-xs text-slate-400 truncate",children:Se})]})]}),f.jsxs("div",{className:"flex items-center gap-2 pt-2 border-t border-slate-800",children:[f.jsxs("button",{onClick:()=>Xe(Se,["*"]),className:"flex-1 py-2 px-3 bg-emerald-600 hover:bg-emerald-500 text-white rounded-lg text-xs font-bold flex items-center justify-center gap-1.5 shadow-sm transition",children:[f.jsx(yM,{size:12}),"Valider (Accès Total)"]}),f.jsx("button",{onClick:()=>Xe(Se,[]),className:"py-2 px-3 bg-slate-800 hover:bg-slate-700 text-slate-300 rounded-lg text-xs font-medium border border-slate-700 transition",title:"Valider le compte mais choisir les noms dans la matrice ci-dessous",children:"Valider (À configurer)"}),f.jsx("button",{onClick:()=>Qe(Se),className:"py-2 px-3 bg-red-950/60 hover:bg-red-900 text-red-300 rounded-lg text-xs font-medium border border-red-800/50 transition",title:"Refuser",children:f.jsx($a,{size:12})})]})]},Se))})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[f.jsxs("div",{children:[f.jsxs("h3",{className:"text-base font-bold text-white flex items-center gap-2",children:[f.jsx("span",{children:"📊"})," Matrice Interactive des Permissions par Nom de Famille"]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Cochez directement les cases pour autoriser l'accès à un nom de famille spécifique."})]}),f.jsxs("div",{className:"relative w-full sm:w-64",children:[f.jsx(X0,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 text-xs"}),f.jsx("input",{type:"text",placeholder:"Rechercher un utilisateur...",value:h,onChange:Se=>p(Se.target.value),className:"w-full bg-slate-800/80 border border-slate-700 rounded-xl pl-8 pr-3 py-1.5 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-amber-400"})]})]}),f.jsx("div",{className:"border border-slate-700/80 rounded-2xl overflow-hidden bg-slate-950/60 shadow-xl",children:f.jsx("div",{className:"overflow-x-auto max-h-[480px]",children:f.jsxs("table",{className:"w-full text-left text-xs border-collapse",children:[f.jsx("thead",{className:"bg-slate-950 sticky top-0 z-10 text-slate-400 uppercase tracking-wider font-semibold border-b border-slate-800",children:f.jsxs("tr",{children:[f.jsx("th",{className:"p-3.5 min-w-[220px] sticky left-0 bg-slate-950 z-20",children:"Utilisateur"}),f.jsx("th",{className:"p-3.5 min-w-[110px] text-center",children:"Rôle"}),f.jsx("th",{className:"p-3.5 min-w-[100px] text-center",children:"Statut"}),f.jsx("th",{className:"p-3.5 min-w-[90px] text-center bg-amber-500/10 text-amber-300 font-bold border-x border-amber-500/20",children:"⭐ Tous (*)"}),l.map(Se=>f.jsx("th",{className:"p-3.5 min-w-[90px] text-center whitespace-nowrap",children:Se},Se)),f.jsx("th",{className:"p-3.5 min-w-[80px] text-center",children:"Actions"})]})}),f.jsx("tbody",{className:"divide-y divide-slate-800/60 text-slate-300",children:At.map(([Se,_t])=>{const It=_t.allowed_last_names||[],De=It.includes("*"),ue=_t.role||"user",Ve=_t.status||"approved",We=Ve==="pending",ct=Ve==="rejected";return f.jsxs("tr",{className:`hover:bg-slate-800/40 transition-colors ${We?"bg-amber-950/10":""}`,children:[f.jsx("td",{className:"p-3.5 sticky left-0 bg-slate-900/95 z-10 border-r border-slate-800",children:f.jsxs("div",{className:"flex items-center gap-2.5",children:[_t.picture?f.jsx("img",{src:_t.picture,alt:"",className:"w-7 h-7 rounded-full object-cover border border-slate-700 shrink-0"}):f.jsx("div",{className:"w-7 h-7 rounded-full bg-slate-800 flex items-center justify-center text-slate-400 shrink-0",children:f.jsx(hm,{size:12})}),f.jsxs("div",{className:"truncate",children:[f.jsxs("div",{className:"font-semibold text-white truncate flex items-center gap-1.5",children:[_t.name||Se.split("@")[0],ue==="super_admin"&&f.jsx(_K,{className:"text-amber-400 text-xs shrink-0",title:"Super Admin"}),ue==="admin"&&f.jsx(iCe,{className:"text-blue-400 text-xs shrink-0",title:"Admin"})]}),f.jsx("div",{className:"text-[11px] text-slate-400 truncate",children:Se})]})]})}),f.jsx("td",{className:"p-3.5 text-center",children:f.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold ${ue==="super_admin"?"bg-amber-500/20 text-amber-300 border border-amber-500/40":ue==="admin"?"bg-blue-500/20 text-blue-300 border border-blue-500/40":"bg-slate-800 text-slate-300 border border-slate-700"}`,children:ue==="super_admin"?"Super Admin":ue==="admin"?"Admin":"Utilisateur"})}),f.jsx("td",{className:"p-3.5 text-center",children:f.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-semibold ${Ve==="approved"?"bg-emerald-500/20 text-emerald-300":Ve==="pending"?"bg-amber-500/20 text-amber-300 animate-pulse":"bg-red-500/20 text-red-300"}`,children:Ve==="approved"?"Validé":Ve==="pending"?"En attente":"Refusé"})}),f.jsx("td",{className:"p-3.5 text-center bg-amber-500/5 border-x border-amber-500/20",children:f.jsx("input",{type:"checkbox",checked:De,disabled:We||ct,onChange:()=>ze(Se,"*"),className:"w-4 h-4 rounded text-amber-500 bg-slate-900 border-slate-700 focus:ring-amber-400 cursor-pointer disabled:opacity-30",title:"Accès total à tous les noms"})}),l.map(vt=>{const Ut=De||It.includes(vt);return f.jsx("td",{className:"p-3.5 text-center",children:f.jsx("input",{type:"checkbox",checked:Ut,disabled:De||We||ct,onChange:()=>ze(Se,vt),className:`w-4 h-4 rounded bg-slate-900 border-slate-700 cursor-pointer ${De?"text-amber-500 opacity-60":"text-emerald-500 focus:ring-emerald-400"} disabled:opacity-30`,title:De?"Inclus via l'accès total (*)":`Autoriser ${vt}`})},vt)}),f.jsx("td",{className:"p-3.5 text-center whitespace-nowrap",children:f.jsxs("div",{className:"flex items-center justify-center gap-1.5",children:[f.jsx("button",{onClick:()=>Ce(Se,_t),className:"p-1.5 text-slate-400 hover:text-amber-300 hover:bg-slate-800 rounded transition",title:"Modifier",children:f.jsx(Pg,{size:13})}),ue!=="super_admin"&&f.jsx("button",{onClick:()=>bt(Se),className:"p-1.5 text-slate-400 hover:text-red-400 hover:bg-slate-800 rounded transition",title:"Supprimer",children:f.jsx(z0,{size:12})})]})})]},Se)})})]})})})]}),f.jsxs("form",{onSubmit:ht,className:"bg-slate-950/80 p-5 rounded-2xl border border-slate-800 space-y-4",children:[f.jsxs("h3",{className:"text-sm font-bold text-slate-200 uppercase tracking-wider flex items-center gap-2",children:[f.jsx("span",{children:"✏️"})," Ajouter manuellement ou modifier un compte"]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-medium text-slate-400 mb-1",children:"Adresse e-mail Google :"}),f.jsx("input",{type:"email",value:W,onChange:Se=>J(Se.target.value),placeholder:"ex: membre@gmail.com",required:!0,className:"w-full bg-slate-900 border border-slate-700 rounded-xl px-3 py-2 text-xs text-white focus:outline-none focus:border-amber-400"})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-medium text-slate-400 mb-1",children:"Rôle :"}),f.jsxs("select",{value:ie,onChange:Se=>ae(Se.target.value),disabled:!r&&ie==="admin",className:"w-full bg-slate-900 border border-slate-700 rounded-xl px-3 py-2 text-xs text-white focus:outline-none focus:border-amber-400 disabled:opacity-50",children:[f.jsx("option",{value:"user",children:"Utilisateur Standard"}),r&&f.jsx("option",{value:"admin",children:"Administrateur (Lauriane)"}),r&&f.jsx("option",{value:"super_admin",children:"Super Administrateur (Ravin)"})]}),!r&&f.jsx("span",{className:"text-[10px] text-slate-500 mt-0.5 block",children:"Seul le Super Admin peut nommer des administrateurs."})]}),f.jsxs("div",{children:[f.jsx("label",{className:"block text-xs font-medium text-slate-400 mb-1",children:"Statut :"}),f.jsxs("select",{value:Q,onChange:Se=>re(Se.target.value),className:"w-full bg-slate-900 border border-slate-700 rounded-xl px-3 py-2 text-xs text-white focus:outline-none focus:border-amber-400",children:[f.jsx("option",{value:"approved",children:"Validé (Approved)"}),f.jsx("option",{value:"pending",children:"En attente (Pending)"}),f.jsx("option",{value:"rejected",children:"Refusé / Bloqué (Rejected)"})]})]})]}),f.jsxs("div",{className:"pt-2 flex items-center justify-between",children:[f.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer text-xs text-slate-300",children:[f.jsx("input",{type:"checkbox",checked:oe,onChange:Se=>fe(Se.target.checked),className:"w-4 h-4 rounded text-amber-500 bg-slate-900 border-slate-700 focus:ring-amber-400"}),f.jsxs("span",{children:[f.jsx("strong",{children:"Accès Général Total (*)"})," (Permet de voir tous les membres de la famille)"]})]}),f.jsx("button",{type:"submit",className:"px-5 py-2.5 bg-amber-500 hover:bg-amber-400 text-slate-950 font-bold rounded-xl text-xs shadow-lg shadow-amber-500/20 transition-all hover:scale-105 active:scale-95",children:"Enregistrer les Droits"})]})]})]})}),f.jsxs("div",{className:"px-6 py-4 border-t border-slate-800 bg-slate-950 flex justify-between items-center text-xs text-slate-500",children:[f.jsx("span",{children:"Famille History • Sécurité & Droits d'Accès RGPD"}),f.jsx("button",{onClick:e,className:"px-4 py-2 bg-slate-800 hover:bg-slate-700 text-slate-200 rounded-xl font-medium transition",children:"Fermer"})]})]})})}const jh="https://famille.ravin-cloud.fr";function v_t({person:n,people:e,onSelectPerson:t,onEditPerson:r,onUpdatePerson:i,onNavigateToTree:s,onClose:a,onGeneratePodcast:o,isPodcastLoading:l,onDetective:c,isDetectiveLoading:u,onViewSource:d,onOpenNewspaper:h,onShareImage:p,onAddToAgenda:g,onEnhancePhoto:x,isPhotoEnhancing:_,onSelectPersonForChat:y,onVoiceIntent:M,onDataUpdate:C,refreshKey:k}){var De;const{user:B,refetch:U}=o1(),[z,O]=de.useState("timeline"),[V,$]=de.useState(""),[G,H]=de.useState(!1),[K,W]=de.useState(null),[J,ie]=de.useState(!1),[ae,Q]=de.useState((n==null?void 0:n.validations)||{}),[re,oe]=de.useState(!1),[fe,ee]=de.useState(!1),[me,Ae]=de.useState(!1);ln.useEffect(()=>{Q((n==null?void 0:n.validations)||{})},[n]);const be=async(ue="all")=>{oe(!0);try{const Ve=await fetch(`${jh}/api/people/${n.slug}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({field:ue})}),We=await Ve.json();Ve.ok?(Q(We.validations),jt.success(We.message||"Information confirmée avec succès !",{icon:"✅"}),C&&C(We.message)):jt.error(We.error||"Erreur lors de la confirmation")}catch{jt.error("Erreur de connexion au serveur")}finally{oe(!1)}},pe=async()=>{if(!B){jt.error("Vous devez être connecté pour revendiquer votre profil.");return}if(B.claimed_profile===(n==null?void 0:n.slug)){jt.success("C'est déjà votre profil validé !");return}if(B.pending_claim===(n==null?void 0:n.slug)){jt("Votre demande de revendication est déjà en attente de validation par un administrateur.",{icon:"⏳"});return}ie(!0);try{const ue=await fetch(`${jh}/api/admin/claim`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({slug:n.slug})}),Ve=await ue.json();ue.ok?(jt.success(Ve.message||"Demande de revendication envoyée avec succès !"),U&&U()):jt.error(Ve.error||"Erreur lors de la revendication")}catch{jt.error("Erreur de connexion au serveur")}finally{ie(!1)}};if(!n)return null;const ge=ue=>{if(!ue)return null;const Ve=String(ue).trim();if(!Ve)return null;const We=Ve.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(We){const[ct,vt,Ut,dt]=We;return`${dt}/${Ut}/${vt}`}try{const ct=new Date(Ve);if(!isNaN(ct.getTime()))return ct.toLocaleDateString("fr-FR",{day:"numeric",month:"long",year:"numeric"})}catch{}return Ve},Te=ge((n==null?void 0:n.date_naissance)||(n==null?void 0:n.annee_naissance)),ze=ge(n==null?void 0:n.date_mariage),Xe=ge(n==null?void 0:n.date_divorce),Qe=ge((n==null?void 0:n.date_deces)||(n==null?void 0:n.annee_deces)),bt=(ue=>{if(!ue)return null;try{const Ve=new Date(ue);if(isNaN(Ve.getTime()))return null;const We=new Date;let ct=We.getFullYear()-Ve.getFullYear();const vt=We.getMonth()-Ve.getMonth();return(vt<0||vt===0&&We.getDate(){if(ue==null||ue.preventDefault(),!V.trim()||G)return;const Ve=V.trim();$(""),H(!0),W("");try{const We=await fetch(`${jh}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({message:`À propos de ${n.prenom} ${n.nom}: ${Ve}`,prenom:n.prenom,nom:n.nom,history:[]})});if(!We.ok)throw new Error("Erreur de communication avec l'assistant");const ct=We.body.getReader(),vt=new TextDecoder;let Ut="",dt="";for(;;){const{done:mt,value:Ft}=await ct.read();if(mt)break;dt+=vt.decode(Ft,{stream:!0});const tt=dt.split(` `);dt=tt.pop();for(const Pe of tt)if(Pe.trim().startsWith("data: ")){const nt=Pe.replace("data: ","").trim();if(nt&&nt!=="[DONE]")try{const qe=JSON.parse(nt);qe.service_event?(jt.success(qe.message),C&&C(qe.message)):qe.choices&&qe.choices[0].delta&&qe.choices[0].delta.content&&(Ut+=qe.choices[0].delta.content,W(Ut))}catch{}}}Ut.trim()&&W(Ut)}catch(We){console.error("Direct chat error:",We),jt.error("Impossible de joindre l'assistant pour le moment.")}finally{H(!1)}},[Ce,lt]=de.useState(!1),ft=async()=>{if(window.confirm(`Voulez-vous restaurer la version précédente de la fiche de ${n.prenom} ${n.nom} ?`)){lt(!0);try{const ue=await fetch(`${jh}/api/people/${n.slug}/undo`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include"}),Ve=await ue.json();ue.ok?(jt.success(Ve.message||"Version précédente restaurée avec succès !"),setRefreshKey(We=>We+1),t&&t(n)):jt.error(Ve.error||"Impossible de restaurer la version précédente.")}catch{jt.error("Erreur réseau lors de la restauration.")}finally{lt(!1)}}},[et,At]=de.useState(null),Lt=n.photo_url||n.photo?(n.photo_url||n.photo).startsWith("/")?`${jh}${n.photo_url||n.photo}`:n.photo_url||n.photo:null,st=!n.date_naissance||!n.lieu_naissance||!n.profession||!Lt,Ht=(ue=0)=>{const Ve=Array.isArray(n.evenements_marquants)?n.evenements_marquants.filter(Ut=>Ut&&typeof Ut=="object"&&Ut.photo):[],We=n.galerie_photos||[],ct=[],vt=new Set;Lt&&(vt.add(Lt),ct.push({src:Lt,title:`Photo de profil de ${n.prenom} ${n.nom}`,source:"Photo Principale"})),Ve.forEach(Ut=>{const dt=Ut.photo.startsWith("http")?Ut.photo:Ut.photo.startsWith("/")?`${jh}${Ut.photo}`:`${jh}/${Ut.photo}`;vt.has(dt)||(vt.add(dt),ct.push({src:dt,date:Ut.date,title:Ut.titre||Ut.description||`Souvenir de ${n.prenom}`,lieu:Ut.lieu,source:Ut.source||"Gazette Famileo"}))}),We.forEach(Ut=>{const dt=Ut.startsWith("http")?Ut:Ut.startsWith("/")?`${jh}${Ut}`:`${jh}/${Ut}`;vt.has(dt)||(vt.add(dt),ct.push({src:dt,title:`Souvenir de famille - ${n.prenom}`,source:"Album Familial"}))}),ct.length>0?At({photos:ct,initialIndex:Math.min(ue,ct.length-1),title:`Galerie de ${n.prenom} ${n.nom}`}):jt("Aucune photo disponible pour cette fiche",{icon:"🖼️"})},Se=async ue=>{if(!ue||!(n!=null&&n.slug))return;const Ve=jt.loading("Mise à jour de la photo de profil...");try{const We=await fetch(`${jh}/api/people/${n.slug}/set-profile-photo`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({photo_url:ue})}),ct=await We.json();if(!We.ok)throw new Error(ct.error||"Erreur lors de la mise à jour");jt.success("Photo de profil mise à jour !",{id:Ve,icon:"⭐"}),typeof i=="function"&&i({...n,photo:ue,photo_url:ue,avatar:ue}),typeof C=="function"&&C()}catch(We){jt.error(We.message||"Impossible d'enregistrer la photo",{id:Ve})}},_t=de.useMemo(()=>!n.parents||n.parents.length===0?[]:n.parents.map(ue=>{const Ve=(e||[]).find(We=>We.slug===ue||We.slug===String(ue).toLowerCase());return{slug:ue,name:Ve?`${Ve.prenom} ${Ve.nom}`:ue.replace(/-/g," "),person:Ve}}),[n.parents,e]),It=de.useMemo(()=>n.freres_soeurs&&n.freres_soeurs.length>0?n.freres_soeurs.map(ue=>{const Ve=(e||[]).find(We=>We.slug===ue||We.slug===String(ue).toLowerCase());return{slug:ue,name:Ve?`${Ve.prenom} ${Ve.nom}`:ue.replace(/-/g," "),person:Ve}}):n.parents&&n.parents.length>0?(e||[]).filter(ue=>ue.slug!==n.slug&&ue.parents&&ue.parents.some(Ve=>n.parents.includes(Ve))).map(ue=>({slug:ue.slug,name:`${ue.prenom} ${ue.nom}`,person:ue})):[],[n.freres_soeurs,n.parents,n.slug,e]);return de.useMemo(()=>{if(!n.conjoint)return null;const ue=(e||[]).find(Ve=>Ve.slug===n.conjoint||Ve.slug===String(n.conjoint).toLowerCase());return{slug:n.conjoint,name:ue?`${ue.prenom} ${ue.nom}`:n.conjoint.replace(/-/g," "),person:ue}},[n.conjoint,e]),de.useMemo(()=>(e||[]).filter(ue=>ue.parents&&ue.parents.includes(n.slug)).map(ue=>({slug:ue.slug,name:`${ue.prenom} ${ue.nom}`,person:ue})),[n.slug,e]),f.jsxs(Gn.div,{className:"p-4 sm:p-6 bg-white/80 backdrop-blur-2xl rounded-[2.5rem] shadow-[0_20px_50px_rgba(0,0,0,0.06)] border border-white/80 space-y-6 mt-4 relative overflow-hidden",initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},children:[f.jsx("div",{className:"absolute -top-12 -left-12 w-48 h-48 bg-emerald-400/10 rounded-full blur-3xl pointer-events-none"}),f.jsx("div",{className:"absolute -bottom-12 -right-12 w-48 h-48 bg-purple-400/10 rounded-full blur-3xl pointer-events-none"}),f.jsxs("div",{className:"flex flex-wrap items-center justify-between z-20 relative gap-2",children:[f.jsxs("button",{onClick:a,className:"px-3.5 py-2 bg-white/90 hover:bg-white backdrop-blur-md rounded-xl shadow-xs border border-slate-200 transition-all flex items-center gap-2 text-slate-700 font-bold hover:scale-105 active:scale-95 text-xs",children:[f.jsx(C7,{})," Retour"]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s&&f.jsxs("button",{onClick:()=>s(n.slug),className:"px-3.5 py-2 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white font-bold rounded-xl text-xs flex items-center gap-1.5 transition-all shadow-sm hover:scale-105 active:scale-95 border border-emerald-400/40",title:"Voir cette personne directement dans l'arbre familial",children:[f.jsx("span",{children:"🌳"})," Voir dans l'Arbre"]}),r&&f.jsxs("button",{onClick:()=>r(n),className:"px-3.5 py-2 bg-gradient-to-r from-amber-500 via-amber-600 to-yellow-500 hover:from-amber-400 hover:to-yellow-400 text-slate-950 font-black rounded-xl text-xs flex items-center gap-1.5 transition-all shadow-sm hover:scale-105 active:scale-95 border border-amber-300",children:[f.jsx(Pg,{size:12,className:"text-slate-950"})," ✏️ Modifier"]}),f.jsxs("button",{onClick:()=>Ae(!0),className:"px-3.5 py-2 bg-gradient-to-r from-amber-600 via-yellow-600 to-amber-700 hover:from-amber-500 hover:to-yellow-500 text-white font-black rounded-xl text-xs flex items-center gap-1.5 transition-all shadow-md hover:scale-105 active:scale-95 border border-amber-400/50",title:"Ouvrir le support multi-fenêtres d'archives vivantes (Données factuelles, Actes scannés, Photos, Textes libres, Événements remarquables)",children:[f.jsx(bK,{className:"text-amber-200"})," 📂 Dossier Vivant"]})]})]}),f.jsxs("div",{className:"bg-gradient-to-br from-slate-900 via-slate-800 to-slate-900 text-white rounded-3xl p-5 sm:p-6 shadow-xl border border-slate-800 relative z-10 space-y-5",children:[f.jsxs("div",{className:"flex flex-col sm:flex-row items-center sm:items-start gap-5",children:[f.jsxs("div",{className:"relative shrink-0 group/avatar",children:[f.jsx(q0,{person:n,className:"w-24 h-24 sm:w-28 sm:h-28",rounded:"rounded-2xl border-4 border-slate-700/80 shadow-2xl ring-4 ring-emerald-500/20 group-hover/avatar:ring-amber-400/50 transition-all cursor-pointer",dark:!0,onClick:()=>Ht(0)}),f.jsx("div",{onClick:()=>Ht(0),className:"absolute inset-0 bg-black/40 rounded-2xl opacity-0 group-hover/avatar:opacity-100 transition-opacity flex items-center justify-center cursor-pointer pointer-events-none",children:f.jsx("span",{className:"text-white text-xs font-bold bg-black/70 px-2 py-1 rounded-lg backdrop-blur-xs",children:"🔍 Galerie"})}),Lt&&x&&f.jsx("button",{onClick:ue=>{ue.stopPropagation(),x(n.slug)},disabled:_,title:"Restaurer la photo avec l'IA",className:"absolute -bottom-2 -right-2 bg-emerald-500 text-white rounded-full p-2 shadow-lg border border-emerald-400 hover:scale-110 transition-transform disabled:opacity-50 text-xs z-10",children:"✨"})]}),f.jsxs("div",{className:"flex-1 text-center sm:text-left space-y-2 min-w-0",children:[f.jsxs("div",{className:"flex flex-wrap items-baseline justify-center sm:justify-start gap-2",children:[f.jsxs("h1",{className:"text-2xl sm:text-3xl font-black tracking-tight text-white flex flex-wrap items-baseline gap-2",children:[f.jsx("span",{children:n.prenom}),f.jsx("span",{className:"uppercase text-amber-400 font-extrabold",children:n.nom}),(n.nom_jeune_fille||n.nom_naissance)&&(n.nom_jeune_fille||n.nom_naissance).toUpperCase()!==(n.nom||"").toUpperCase()&&f.jsxs("span",{className:"text-sm font-normal text-slate-300 italic",children:["(née ",(n.nom_jeune_fille||n.nom_naissance).toUpperCase(),")"]}),n.surnom&&f.jsxs("span",{className:"text-sm font-bold text-purple-300",children:["« ",n.surnom," »"]})]}),Rg(n)?f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-rose-500/20 border border-rose-400/50 text-rose-300 font-bold text-xs flex items-center gap-1 shadow-xs",children:"♀ Femme"}):f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-sky-500/20 border border-sky-400/50 text-sky-300 font-bold text-xs flex items-center gap-1 shadow-xs",children:"♂ Homme"}),n.is_sosa_root&&f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-amber-500/20 border border-amber-400/40 text-amber-300 font-bold text-[10px] flex items-center gap-1",children:"👑 SOSA 1"})]}),f.jsxs("div",{className:"flex flex-wrap items-center justify-center sm:justify-start gap-2 pt-1 text-xs",children:[n.profession?f.jsxs("span",{className:"px-3.5 py-1 bg-gradient-to-r from-amber-500/25 to-yellow-500/15 border border-amber-400/50 text-amber-200 font-bold rounded-full flex items-center gap-1.5 shadow-xs",children:[f.jsx(Wp,{className:"text-amber-400"}),f.jsxs("span",{children:["Profession : ",f.jsx("strong",{className:"text-white font-extrabold",children:n.profession})]})]}):f.jsxs("span",{className:"px-3 py-1 bg-slate-800/80 border border-slate-700 text-slate-400 font-medium rounded-full flex items-center gap-1.5 text-xs",children:[f.jsx(Wp,{className:"text-slate-500"})," Profession à renseigner"]}),Te?f.jsxs("span",{className:"px-3 py-1 bg-emerald-950/60 border border-emerald-500/40 text-emerald-200 font-medium rounded-full flex items-center gap-1.5 shadow-sm",children:[f.jsx("span",{className:"font-black text-[9px] text-emerald-950 bg-emerald-300 px-1.5 py-0.2 rounded shrink-0",children:"N"}),f.jsx("span",{className:"font-bold",children:Te}),n.lieu_naissance&&f.jsxs("span",{className:"text-slate-400 font-normal",children:["(",n.lieu_naissance,")"]}),bt!==null&&!Qe&&f.jsxs("span",{className:"text-emerald-400 font-bold",children:["(",bt," ans)"]})]}):f.jsxs("span",{className:"px-3 py-1 bg-orange-950/40 border border-orange-500/40 text-orange-200 font-medium rounded-full flex items-center gap-1.5",children:[f.jsx("span",{className:"font-black text-[9px] text-orange-950 bg-orange-300 px-1.5 py-0.2 rounded shrink-0",children:"N"}),f.jsx("span",{className:"italic text-orange-300",children:"Date de naissance inconnue"})]}),ze&&f.jsxs("span",{className:"px-3 py-1 bg-rose-950/60 border border-rose-500/40 text-rose-200 font-medium rounded-full flex items-center gap-1.5 shadow-sm",children:[f.jsx("span",{className:"font-black text-[9px] text-rose-950 bg-rose-300 px-1.5 py-0.2 rounded shrink-0",children:"💍 M"}),f.jsx("span",{className:"font-bold",children:ze}),n.lieu_mariage&&f.jsxs("span",{className:"text-slate-400 font-normal",children:["(",n.lieu_mariage,")"]})]}),Xe&&f.jsxs("span",{className:"px-3 py-1 bg-purple-950/60 border border-purple-500/40 text-purple-200 font-medium rounded-full flex items-center gap-1.5 shadow-sm",children:[f.jsx("span",{className:"font-black text-[9px] text-purple-950 bg-purple-300 px-1.5 py-0.2 rounded shrink-0",children:"Div"}),f.jsx("span",{className:"font-bold",children:Xe}),n.lieu_divorce&&f.jsxs("span",{className:"text-slate-400 font-normal",children:["(",n.lieu_divorce,")"]})]}),Qe&&f.jsxs("span",{className:"px-3 py-1 bg-slate-800 border border-slate-600 text-slate-200 font-medium rounded-full flex items-center gap-1.5 shadow-sm",children:[f.jsx("span",{className:"font-black text-[9px] text-slate-950 bg-slate-300 px-1.5 py-0.2 rounded shrink-0",children:"† D"}),f.jsx("span",{className:"font-bold",children:Qe}),n.lieu_deces&&f.jsxs("span",{className:"text-slate-400 font-normal",children:["(",n.lieu_deces,")"]})]})]}),(n.email||n.instagram||n.tiktok||n.facebook||n.linkedin||n.twitter||n.reseaux_sociaux&&Object.keys(n.reseaux_sociaux).length>0)&&f.jsxs("div",{className:"flex flex-wrap items-center justify-center sm:justify-start gap-2 pt-1",children:[n.email&&f.jsxs("a",{href:`mailto:${n.email}`,className:"px-2.5 py-1 bg-slate-800/90 hover:bg-slate-700 text-slate-300 hover:text-white rounded-full text-[11px] font-medium border border-slate-700 flex items-center gap-1.5 transition-all shadow-xs",title:`Envoyer un email à ${n.email}`,children:[f.jsx(AH,{className:"text-indigo-400 text-xs"}),f.jsx("span",{children:n.email})]}),(n.instagram||n.reseaux_sociaux&&n.reseaux_sociaux.instagram)&&f.jsxs("a",{href:n.instagram||n.reseaux_sociaux.instagram,target:"_blank",rel:"noopener noreferrer",className:"px-2.5 py-1 bg-pink-950/50 hover:bg-pink-900/60 text-pink-300 hover:text-pink-100 rounded-full text-[11px] font-medium border border-pink-500/40 flex items-center gap-1.5 transition-all shadow-xs",children:[f.jsx(Gpe,{className:"text-pink-400 text-xs"}),f.jsx("span",{children:"Instagram"})]}),(n.tiktok||n.reseaux_sociaux&&n.reseaux_sociaux.tiktok)&&f.jsxs("a",{href:n.tiktok||n.reseaux_sociaux.tiktok,target:"_blank",rel:"noopener noreferrer",className:"px-2.5 py-1 bg-cyan-950/50 hover:bg-cyan-900/60 text-cyan-300 hover:text-cyan-100 rounded-full text-[11px] font-medium border border-cyan-500/40 flex items-center gap-1.5 transition-all shadow-xs",children:[f.jsx(Vpe,{className:"text-cyan-400 text-xs"}),f.jsx("span",{children:"TikTok"})]}),(n.facebook||n.reseaux_sociaux&&n.reseaux_sociaux.facebook)&&f.jsxs("a",{href:n.facebook||n.reseaux_sociaux.facebook,target:"_blank",rel:"noopener noreferrer",className:"px-2.5 py-1 bg-blue-950/50 hover:bg-blue-900/60 text-blue-300 hover:text-blue-100 rounded-full text-[11px] font-medium border border-blue-500/40 flex items-center gap-1.5 transition-all shadow-xs",children:[f.jsx(Hpe,{className:"text-blue-400 text-xs"}),f.jsx("span",{children:"Facebook"})]}),(n.linkedin||n.reseaux_sociaux&&n.reseaux_sociaux.linkedin)&&f.jsxs("a",{href:n.linkedin||n.reseaux_sociaux.linkedin,target:"_blank",rel:"noopener noreferrer",className:"px-2.5 py-1 bg-sky-950/50 hover:bg-sky-900/60 text-sky-300 hover:text-sky-100 rounded-full text-[11px] font-medium border border-sky-500/40 flex items-center gap-1.5 transition-all shadow-xs",children:[f.jsx(qpe,{className:"text-sky-400 text-xs"}),f.jsx("span",{children:"LinkedIn"})]}),(n.twitter||n.reseaux_sociaux&&(n.reseaux_sociaux.twitter||n.reseaux_sociaux.x))&&f.jsxs("a",{href:n.twitter||n.reseaux_sociaux.twitter||n.reseaux_sociaux.x,target:"_blank",rel:"noopener noreferrer",className:"px-2.5 py-1 bg-slate-800 hover:bg-slate-700 text-slate-300 hover:text-white rounded-full text-[11px] font-medium border border-slate-600 flex items-center gap-1.5 transition-all shadow-xs",children:[f.jsx(zpe,{className:"text-slate-300 text-xs"}),f.jsx("span",{children:"X"})]})]}),st&&f.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-lg bg-orange-500/20 border border-orange-500/40 text-orange-300 text-xs font-semibold mt-2",children:[f.jsx("span",{children:"⚠️"})," Information manquante sur la fiche"]})]})]}),f.jsxs("div",{className:"bg-slate-800/80 p-3.5 rounded-2xl border border-slate-700/80 space-y-2",children:[f.jsxs("form",{onSubmit:ht,className:"flex items-center gap-2",children:[f.jsx("input",{type:"text",value:V,onChange:ue=>$(ue.target.value),placeholder:`Posez une question sur ${n.prenom} ou dictez son histoire...`,className:"flex-1 bg-slate-900 border border-slate-700 rounded-xl px-3.5 py-2 text-xs sm:text-sm text-white focus:outline-none focus:border-amber-400 transition"}),f.jsxs("button",{type:"submit",disabled:G,className:"px-4 py-2 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-400 hover:to-teal-500 text-white font-bold rounded-xl text-xs flex items-center gap-1.5 shadow-md disabled:opacity-50 transition shrink-0",children:[f.jsx(Ype,{})," ",G?"...":"Poser"]}),f.jsx("button",{type:"button",onClick:()=>y(n),title:"Ouvrir le Chat Vocal complet",className:"p-2 bg-purple-600 hover:bg-purple-500 text-white rounded-xl shadow-md transition shrink-0 text-xs",children:f.jsx(BS,{})})]}),f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap text-[11px] text-slate-400 pt-1",children:[f.jsx("span",{className:"font-semibold text-amber-300",children:"💡 Idées :"}),f.jsx("button",{type:"button",onClick:()=>$("Raconte-moi son histoire de vie"),className:"hover:text-amber-200 underline",children:"Raconter son histoire"}),f.jsx("span",{children:"•"}),f.jsx("button",{type:"button",onClick:()=>$("Quels sont ses ancêtres connus ?"),className:"hover:text-amber-200 underline",children:"Ancêtres connus"}),f.jsx("span",{children:"•"}),f.jsx("button",{type:"button",onClick:()=>$("Quel était son métier ?"),className:"hover:text-amber-200 underline",children:"Son métier"})]}),K&&f.jsxs(Gn.div,{initial:{opacity:0,y:5},animate:{opacity:1,y:0},className:"mt-2 p-3 bg-slate-900/90 rounded-xl border border-emerald-500/40 text-xs text-slate-200 leading-relaxed font-sans space-y-1 relative",children:[f.jsxs("div",{className:"flex items-center justify-between text-emerald-400 font-bold text-[11px]",children:[f.jsx("span",{className:"flex items-center gap-1",children:"✨ Réponse de l'IA"}),f.jsx("button",{onClick:()=>W(null),className:"text-slate-400 hover:text-white",children:"✕"})]}),f.jsx("p",{children:K})]})]}),f.jsxs("div",{className:"flex items-center gap-1.5 pt-2 border-t border-slate-800/80 overflow-x-auto no-scrollbar pb-1",children:[f.jsxs("button",{onClick:()=>Ae(!0),className:"px-3.5 py-1.5 rounded-xl bg-gradient-to-r from-amber-500/25 to-yellow-500/25 hover:from-amber-500/40 hover:to-yellow-500/40 border border-amber-400/50 text-amber-200 font-extrabold text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0 cursor-pointer",title:"Ouvrir le support multi-fenêtres d'archives vivantes (Données factuelles, Actes scannés, Photos, Textes libres, Événements remarquables)",children:[f.jsx(bK,{className:"text-amber-400 text-xs"}),f.jsx("span",{className:"whitespace-nowrap",children:"📂 Dossier Vivant"})]}),s&&f.jsxs("button",{onClick:()=>s(n.slug),className:"px-3 py-1.5 rounded-xl bg-emerald-500/15 hover:bg-emerald-500/25 border border-emerald-500/30 text-emerald-300 font-bold text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0",title:"Voir dans l'arbre généalogique",children:[f.jsx("span",{children:"🌳"}),f.jsx("span",{className:"whitespace-nowrap",children:"Arbre"})]}),r&&f.jsxs("button",{onClick:()=>r(n),className:"px-3 py-1.5 rounded-xl bg-amber-500/15 hover:bg-amber-500/25 border border-amber-400/30 text-amber-300 font-bold text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0",title:"Modifier la fiche",children:[f.jsx(Pg,{className:"text-amber-400 text-xs"}),f.jsx("span",{className:"whitespace-nowrap",children:"Modifier"})]}),f.jsxs("button",{onClick:ft,disabled:Ce,className:"px-3 py-1.5 rounded-xl bg-rose-500/15 hover:bg-rose-500/25 border border-rose-400/30 text-rose-300 font-bold text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0 disabled:opacity-50",title:"Annuler la dernière modification et restaurer la version précédente",children:[f.jsx("span",{children:"↩️"}),f.jsx("span",{className:"whitespace-nowrap",children:Ce?"Annulation...":"Annuler (Undo)"})]}),f.jsxs("button",{onClick:pe,disabled:J||(B==null?void 0:B.claimed_profile)===(n==null?void 0:n.slug)||(B==null?void 0:B.pending_claim)===(n==null?void 0:n.slug),className:`px-3 py-1.5 rounded-xl text-xs flex items-center gap-1.5 transition shadow-xs shrink-0 ${(B==null?void 0:B.claimed_profile)===(n==null?void 0:n.slug)?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-300 font-bold opacity-100 cursor-default":(B==null?void 0:B.pending_claim)===(n==null?void 0:n.slug)?"bg-amber-600/20 border border-amber-500/30 text-amber-300 font-bold opacity-90 cursor-default":"bg-blue-600/15 hover:bg-blue-600/25 border border-blue-500/30 text-blue-200 font-semibold hover:scale-105 disabled:opacity-50"}`,title:"Revendiquer ce profil comme étant le vôtre",children:[f.jsx(M7,{className:`text-xs ${(B==null?void 0:B.claimed_profile)===(n==null?void 0:n.slug)?"text-emerald-400":(B==null?void 0:B.pending_claim)===(n==null?void 0:n.slug)?"text-amber-400":"text-blue-400"}`}),f.jsx("span",{className:"whitespace-nowrap",children:(B==null?void 0:B.claimed_profile)===(n==null?void 0:n.slug)?"C'est vous":(B==null?void 0:B.pending_claim)===(n==null?void 0:n.slug)?"En attente":J?"Envoi...":"C'est moi !"})]}),f.jsxs("button",{onClick:()=>o(n.slug),disabled:l,className:"px-3 py-1.5 rounded-xl bg-purple-600/15 hover:bg-purple-600/25 border border-purple-500/30 text-purple-200 font-medium text-xs flex items-center gap-1.5 transition shadow-xs disabled:opacity-50 hover:scale-105 shrink-0",title:"Générer un récit audio avec l'IA",children:[f.jsx("span",{children:"🎧"}),f.jsx("span",{className:"whitespace-nowrap",children:l?"Génération...":"Podcast IA"})]}),f.jsxs("button",{onClick:h,className:"px-3 py-1.5 rounded-xl bg-amber-600/15 hover:bg-amber-600/25 border border-amber-500/30 text-amber-200 font-medium text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0",title:"Générer une gazette d'époque",children:[f.jsx("span",{children:"📰"}),f.jsx("span",{className:"whitespace-nowrap",children:"Gazette"})]}),f.jsxs("button",{onClick:()=>c(n.slug),disabled:u,className:"px-3 py-1.5 rounded-xl bg-indigo-600/15 hover:bg-indigo-600/25 border border-indigo-500/30 text-indigo-200 font-medium text-xs flex items-center gap-1.5 transition shadow-xs disabled:opacity-50 hover:scale-105 shrink-0",title:"Enquête IA sur les zones d'ombres",children:[f.jsx("span",{children:"🕵️"}),f.jsx("span",{className:"whitespace-nowrap",children:u?"Analyse...":"Détective IA"})]}),f.jsxs("button",{onClick:p,className:"px-3 py-1.5 rounded-xl bg-pink-600/15 hover:bg-pink-600/25 border border-pink-500/30 text-pink-200 font-medium text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0",title:"Générer une jolie carte de visite à partager",children:[f.jsx(pCe,{className:"text-pink-400 text-xs"}),f.jsx("span",{className:"whitespace-nowrap",children:"Partager"})]}),f.jsxs("button",{onClick:g,className:"px-3 py-1.5 rounded-xl bg-teal-600/15 hover:bg-teal-600/25 border border-teal-500/30 text-teal-200 font-medium text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0",title:"Ajouter les anniversaires et commémorations à votre calendrier",children:[f.jsx($Ce,{className:"text-teal-400 text-xs"}),f.jsx("span",{className:"whitespace-nowrap",children:"Agenda"})]}),f.jsxs("button",{onClick:()=>d(n.slug),className:"px-3 py-1.5 rounded-xl bg-slate-800/80 hover:bg-slate-700 border border-slate-700 text-slate-300 font-medium text-xs flex items-center gap-1.5 transition shadow-xs hover:scale-105 shrink-0",title:"Consulter le fichier Markdown source",children:[f.jsx("span",{children:"📄"}),f.jsx("span",{className:"whitespace-nowrap",children:"Source MD"})]})]})]}),(()=>{var We;const ue=((We=ae==null?void 0:ae.profil_global)==null?void 0:We.status)==="verified"||Object.values(ae).some(ct=>ct.status==="verified"),Ve=(ae==null?void 0:ae.profil_global)||Object.values(ae)[0];return f.jsxs("div",{className:`p-4 rounded-3xl border flex flex-col sm:flex-row items-center justify-between gap-3 shadow-md transition-all ${ue?"bg-gradient-to-r from-emerald-950/90 via-slate-900 to-emerald-950/90 border-emerald-500/50 text-white":"bg-gradient-to-r from-amber-950/80 via-slate-900 to-indigo-950/80 border-amber-500/40 text-white"}`,children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:`w-10 h-10 rounded-2xl flex items-center justify-center text-lg shrink-0 ${ue?"bg-emerald-500/20 text-emerald-400 border border-emerald-400/40":"bg-amber-500/20 text-amber-300 border border-amber-400/40"}`,children:ue?f.jsx(td,{size:20}):"🤖"}),f.jsxs("div",{className:"space-y-0.5",children:[f.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f.jsx("span",{className:"font-extrabold text-xs sm:text-sm",children:ue?"Fiche vérifiée et confirmée par un humain":"Informations & Déductions de l'IA"}),ue&&Ve&&f.jsxs("span",{className:"px-2.5 py-0.5 rounded-full bg-emerald-500/20 border border-emerald-400/30 text-emerald-300 text-[10px] font-bold",children:["Validé par ",Ve.confirmed_by," • ",Ve.confirmed_at]})]}),f.jsx("p",{className:"text-[11px] text-slate-300",children:ue?"Ces informations ont été validées par les membres de la famille.":"Les filiations, dates et récits déduits par l'IA peuvent être confirmés en 1 clic pour pérenniser l'arbre."})]})]}),f.jsx("div",{className:"flex items-center gap-2 shrink-0 w-full sm:w-auto justify-end",children:f.jsxs("button",{type:"button",onClick:()=>be("all"),disabled:re,className:`px-4 py-2.5 rounded-xl text-xs font-black flex items-center gap-1.5 shadow-lg transition hover:scale-105 active:scale-95 disabled:opacity-50 ${ue?"bg-emerald-600 hover:bg-emerald-500 text-white border border-emerald-400/50":"bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-400 hover:to-teal-500 text-white shadow-emerald-950/40"}`,children:[f.jsx(td,{})," ",re?"Validation...":ue?"Re-confirmer la fiche":"✅ Confirmer toute la fiche"]})})]})})(),f.jsxs("div",{className:"flex items-center gap-1.5 border-b border-amber-900/10 pb-2 overflow-x-auto no-scrollbar",children:[f.jsxs("button",{onClick:()=>O("timeline"),className:`px-4 py-2.5 rounded-xl font-serif font-bold text-xs sm:text-sm flex items-center gap-2 transition shrink-0 ${z==="timeline"?"bg-gradient-to-r from-amber-600 via-amber-500 to-amber-700 text-white shadow-md shadow-amber-600/25 border border-amber-400/40":"bg-slate-100 hover:bg-slate-200 text-slate-700 font-sans"}`,children:[f.jsx("span",{children:"⏱️"})," Chronologie de Vie"]}),f.jsxs("button",{onClick:()=>O("biographie"),className:`px-4 py-2.5 rounded-xl font-serif font-bold text-xs sm:text-sm flex items-center gap-2 transition shrink-0 ${z==="biographie"?"bg-gradient-to-r from-amber-600 via-amber-500 to-amber-700 text-white shadow-md shadow-amber-600/25 border border-amber-400/40":"bg-slate-100 hover:bg-slate-200 text-slate-700 font-sans"}`,children:[f.jsx("span",{children:"📖"})," Biographie & Récit"]}),f.jsxs("button",{onClick:()=>O("famille"),className:`px-4 py-2.5 rounded-xl font-serif font-bold text-xs sm:text-sm flex items-center gap-2 transition shrink-0 ${z==="famille"?"bg-gradient-to-r from-amber-600 via-amber-500 to-amber-700 text-white shadow-md shadow-amber-600/25 border border-amber-400/40":"bg-slate-100 hover:bg-slate-200 text-slate-700 font-sans"}`,children:[f.jsx("span",{children:"👨‍👩‍👧‍👦"})," Lignage & Famille"]}),f.jsxs("button",{onClick:()=>O("anecdotes"),className:`px-4 py-2.5 rounded-xl font-serif font-bold text-xs sm:text-sm flex items-center gap-2 transition shrink-0 ${z==="anecdotes"?"bg-gradient-to-r from-amber-600 via-amber-500 to-amber-700 text-white shadow-md shadow-amber-600/25 border border-amber-400/40":"bg-slate-100 hover:bg-slate-200 text-slate-700 font-sans"}`,children:[f.jsx("span",{children:"✨"})," Événements & Anecdotes"]})]}),f.jsxs("div",{className:"pt-2",children:[f.jsxs("div",{className:"mb-5 p-4 sm:p-5 bg-gradient-to-br from-slate-900 via-slate-900 to-slate-950 border border-slate-800 rounded-3xl shadow-xl space-y-4",children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-800/80 pb-3",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.date_naissance&&f.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-xl bg-emerald-500/15 border border-emerald-500/30 text-emerald-300 text-xs font-bold shadow-xs",children:[f.jsx("span",{className:"font-black bg-emerald-500/30 px-1.5 py-0.2 rounded text-[10px]",children:"🐣 N"}),f.jsxs("span",{children:[n.date_naissance," ",n.lieu_naissance?`(${n.lieu_naissance})`:""]})]}),n.date_mariage&&f.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-xl bg-rose-500/15 border border-rose-500/30 text-rose-300 text-xs font-bold shadow-xs",children:[f.jsx("span",{className:"font-black bg-rose-500/30 px-1.5 py-0.2 rounded text-[10px]",children:"💍 M"}),f.jsx("span",{children:n.date_mariage})]}),n.date_deces&&f.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 rounded-xl bg-slate-700/50 border border-slate-600/60 text-slate-200 text-xs font-bold shadow-xs",children:[f.jsx("span",{className:"font-black bg-slate-600 px-1.5 py-0.2 rounded text-[10px]",children:"🕊️ D"}),f.jsxs("span",{children:[n.date_deces," ",n.lieu_deces?`(${n.lieu_deces})`:""]})]})]}),n.profession?f.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-1.5 bg-gradient-to-r from-amber-500/25 to-yellow-500/15 border border-amber-400/40 rounded-xl text-amber-200 text-xs sm:text-sm font-extrabold shadow-xs",children:[f.jsx(Wp,{className:"text-amber-400"}),f.jsxs("span",{children:["Profession : ",f.jsx("span",{className:"text-white font-black",children:n.profession})]})]}):f.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1 bg-slate-800/80 border border-slate-700/80 rounded-xl text-slate-400 text-xs",children:[f.jsx(Wp,{className:"text-slate-500"})," Profession non renseignée"]})]}),f.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-xs",children:[f.jsxs("div",{className:"p-3 bg-slate-800/60 rounded-2xl border border-slate-700/60 space-y-1.5",children:[f.jsxs("span",{className:"text-[11px] font-black uppercase tracking-wider text-emerald-400 flex items-center gap-1.5",children:[f.jsx("span",{children:"👨‍👩‍👧"})," Parents :"]}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:_t.length>0?_t.map(ue=>f.jsxs("button",{onClick:()=>ue.person&&t&&t(ue.person),disabled:!ue.person,className:`px-3 py-1.5 rounded-xl font-bold flex items-center gap-1.5 transition shadow-xs ${ue.person?"bg-emerald-600/25 hover:bg-emerald-600/40 border border-emerald-500/40 text-emerald-200 hover:scale-105 active:scale-95 cursor-pointer":"bg-slate-800 border border-slate-700 text-slate-300 cursor-default"}`,title:ue.person?`Voir la fiche de ${ue.name}`:void 0,children:[f.jsx("span",{className:"text-xs",children:"👤"}),f.jsx("span",{children:ue.name})]},ue.slug)):f.jsx("span",{className:"text-slate-400 italic",children:"Parents non renseignés"})})]}),f.jsxs("div",{className:"p-3 bg-slate-800/60 rounded-2xl border border-slate-700/60 space-y-1.5",children:[f.jsxs("span",{className:"text-[11px] font-black uppercase tracking-wider text-amber-400 flex items-center gap-1.5",children:[f.jsx("span",{children:"👫"})," Frères & Sœurs (Fratrie) :"]}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:It.length>0?It.map(ue=>f.jsxs("button",{onClick:()=>ue.person&&t&&t(ue.person),disabled:!ue.person,className:`px-3 py-1.5 rounded-xl font-bold flex items-center gap-1.5 transition shadow-xs ${ue.person?"bg-amber-600/25 hover:bg-amber-600/40 border border-amber-500/40 text-amber-200 hover:scale-105 active:scale-95 cursor-pointer":"bg-slate-800 border border-slate-700 text-slate-300 cursor-default"}`,title:ue.person?`Voir la fiche de ${ue.name}`:void 0,children:[f.jsx("span",{className:"text-xs",children:"👥"}),f.jsx("span",{children:ue.name})]},ue.slug)):f.jsx("span",{className:"text-slate-400 italic",children:"Aucun frère / sœur répertorié"})})]})]})]}),(n.evenements_marquants||n.notes)&&z==="biographie"&&f.jsxs("div",{className:"mb-5 grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.evenements_marquants&&n.evenements_marquants.length>0&&f.jsxs("div",{className:"p-4 rounded-3xl bg-amber-500/10 border border-amber-500/30 shadow-md space-y-2.5",children:[f.jsxs("h4",{className:"text-amber-300 font-black text-xs flex items-center gap-2 uppercase tracking-wider",children:[f.jsx("span",{children:"🌟"})," Événements Marquants (",n.evenements_marquants.length,")"]}),f.jsx("div",{className:"space-y-2",children:n.evenements_marquants.map((ue,Ve)=>{const We=typeof ue=="object",ct=We&&(ue.date||ue.annee)||"",vt=We?ue.titre||ue.title||ue.description||"":ue,Ut=We&&ue.description!==vt?ue.description:"",dt=We?ue.photo||ue.photo_url:null,mt=dt?dt.startsWith("/")?`${jh}${dt}`:dt:null;return f.jsxs("div",{className:"p-2.5 bg-slate-900/80 rounded-2xl border border-amber-400/20 text-xs text-amber-100 flex items-start gap-2.5",children:[mt&&f.jsx("img",{src:mt,alt:"event",className:"w-12 h-12 rounded-xl object-cover border border-amber-400/30 shrink-0"}),f.jsxs("div",{className:"space-y-0.5 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[ct&&f.jsx("span",{className:"font-mono font-bold text-[10px] px-1.5 py-0.2 rounded bg-amber-500/20 text-amber-300",children:ct}),f.jsx("span",{className:"font-extrabold text-white",children:vt})]}),Ut&&f.jsx("p",{className:"text-[11px] text-slate-300 leading-tight",children:Ut})]})]},Ve)})})]}),n.notes&&f.jsxs("div",{className:"p-4 rounded-3xl bg-sky-950/40 border border-sky-500/30 shadow-md space-y-2",children:[f.jsxs("h4",{className:"text-sky-300 font-black text-xs flex items-center gap-2 uppercase tracking-wider",children:[f.jsx("span",{children:"📝"})," Notes & Anecdotes"]}),f.jsx("div",{className:"p-3 bg-slate-900/80 rounded-2xl border border-sky-400/20 text-xs text-sky-100 leading-relaxed italic whitespace-pre-wrap font-sans",children:n.notes})]})]}),z==="timeline"&&f.jsx("div",{className:"space-y-4",children:f.jsxs("div",{className:"p-4 bg-slate-900 text-white rounded-2xl shadow-md border border-slate-800",children:[f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsxs("h3",{className:"text-sm font-bold text-emerald-400 flex items-center gap-2 uppercase tracking-wider",children:[f.jsx(pH,{})," Chronologie des événements de vie"]}),f.jsx("span",{className:"text-[11px] text-slate-400 italic",children:"Glissez horizontalement ou cliquez pour naviguer"})]}),f.jsx(yme,{person:n,refreshKey:k,onNavigateToPerson:t})]})}),z==="biographie"&&f.jsxs("div",{className:"space-y-4",children:[n.biographie?f.jsxs("div",{className:"p-5 bg-slate-900 text-slate-100 rounded-2xl space-y-3 shadow-md border border-slate-800",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-slate-800 pb-2",children:[f.jsxs("h3",{className:"text-xs font-black text-amber-400 uppercase tracking-wider flex items-center gap-2",children:[f.jsx(xH,{})," Récit de Vie Officiel"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[((De=ae==null?void 0:ae.biographie)==null?void 0:De.status)==="verified"?f.jsxs("span",{className:"px-2.5 py-0.5 rounded-full bg-emerald-500/20 text-emerald-300 border border-emerald-400/30 text-[10px] font-bold flex items-center gap-1",children:[f.jsx(td,{className:"text-emerald-400"})," Validé par ",ae.biographie.confirmed_by," (",ae.biographie.confirmed_at,")"]}):f.jsxs("button",{type:"button",onClick:()=>be("biographie"),className:"px-2.5 py-0.5 rounded-full bg-emerald-600 hover:bg-emerald-500 text-white text-[10px] font-bold flex items-center gap-1 transition shadow-sm hover:scale-105 active:scale-95",children:[f.jsx(td,{size:10})," Confirmer ce récit"]}),f.jsx("span",{className:"px-2.5 py-0.5 rounded-full bg-gradient-to-r from-purple-600 via-fuchsia-600 to-indigo-600 text-white text-[10px] font-black shadow-sm flex items-center gap-1 border border-purple-300/40",children:"✨ Résumé IA"})]})]}),f.jsx("div",{className:"text-xs sm:text-sm leading-relaxed text-slate-200 font-sans whitespace-pre-wrap",children:n.biographie})]}):f.jsxs("div",{className:"p-6 text-center text-slate-400 italic bg-slate-50 rounded-2xl border border-slate-200",children:["Aucune biographie rédigée pour le moment. Utilisez le bouton ",f.jsx("b",{children:'"Discuter"'})," ou ",f.jsx("b",{children:'"Modifier"'})," pour ajouter son histoire."]}),(()=>{const ue=ct=>ct?Array.isArray(ct)?ct:typeof ct=="string"?ct.split(",").map(vt=>vt.trim()).filter(Boolean):[String(ct)]:[],Ve=ue(n.traits_personnalite),We=ue(n.hobbies);return Ve.length===0&&We.length===0?null:f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 pt-2",children:[Ve.length>0&&f.jsxs("div",{className:"p-4 bg-indigo-50/80 border border-indigo-100 rounded-2xl space-y-2",children:[f.jsxs("p",{className:"text-xs font-extrabold text-indigo-800 uppercase tracking-wider flex items-center gap-1.5",children:[f.jsx("span",{children:"🧠"})," Traits de Caractère"]}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ve.map((ct,vt)=>f.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-semibold bg-white text-indigo-700 border border-indigo-200 shadow-sm",children:ct},vt))})]}),We.length>0&&f.jsxs("div",{className:"p-4 bg-teal-50/80 border border-teal-100 rounded-2xl space-y-2",children:[f.jsxs("p",{className:"text-xs font-extrabold text-teal-800 uppercase tracking-wider flex items-center gap-1.5",children:[f.jsx("span",{children:"🎨"})," Hobbies & Passions"]}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:We.map((ct,vt)=>f.jsx("span",{className:"px-3 py-1 rounded-full text-xs font-semibold bg-white text-teal-800 border border-teal-200 shadow-sm",children:ct},vt))})]})]})})()]}),z==="famille"&&f.jsxs("div",{className:"p-5 bg-slate-50 border border-slate-200 rounded-2xl space-y-4",children:[f.jsxs("h3",{className:"text-xs font-black text-slate-700 uppercase tracking-wider flex items-center gap-2",children:[f.jsx(jA,{className:"text-emerald-600"})," Récapitulatif Familial Direct"]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 text-xs",children:[f.jsxs("div",{className:"bg-white p-3.5 rounded-xl border border-slate-200 shadow-sm space-y-2",children:[f.jsx("p",{className:"font-bold text-slate-500 uppercase tracking-wider text-[11px]",children:"👨‍👩‍👦 Parents :"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.parents&&n.parents.length>0?n.parents.map(ue=>{const Ve=e.find(We=>We.slug===ue);return Ve?f.jsxs("button",{onClick:()=>t(Ve),className:"px-3 py-1.5 bg-emerald-50 hover:bg-emerald-100 border border-emerald-200 rounded-lg text-emerald-900 font-bold shadow-sm transition",children:[Ve.prenom," ",Ve.nom]},ue):null}):f.jsx("span",{className:"text-slate-400 italic",children:"Non renseignés"})})]}),f.jsxs("div",{className:"bg-white p-3.5 rounded-xl border border-slate-200 shadow-sm space-y-2",children:[f.jsx("p",{className:"font-bold text-slate-500 uppercase tracking-wider text-[11px]",children:"👫 Frères & Sœurs :"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.parents&&n.parents.length>0&&e.filter(ue=>ue.slug!==n.slug&&ue.parents&&ue.parents.some(Ve=>n.parents.includes(Ve))).length>0?e.filter(ue=>ue.slug!==n.slug&&ue.parents&&ue.parents.some(Ve=>n.parents.includes(Ve))).map(ue=>f.jsxs("button",{onClick:()=>t(ue),className:"px-3 py-1.5 bg-amber-50 hover:bg-amber-100 border border-amber-200 rounded-lg text-amber-900 font-bold shadow-sm transition",children:[ue.prenom," ",ue.nom]},ue.slug)):f.jsx("span",{className:"text-slate-400 italic",children:"Aucun frère / sœur"})})]}),f.jsxs("div",{className:"bg-white p-3.5 rounded-xl border border-slate-200 shadow-sm space-y-2",children:[f.jsx("p",{className:"font-bold text-slate-500 uppercase tracking-wider text-[11px]",children:"💍 Conjoint(e) :"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.conjoint?[n.conjoint].map(ue=>{const Ve=e.find(We=>We.slug===ue);return Ve?f.jsxs("button",{onClick:()=>t(Ve),className:"px-3 py-1.5 bg-rose-50 hover:bg-rose-100 border border-rose-200 rounded-lg text-rose-900 font-bold shadow-sm transition",children:[Ve.prenom," ",Ve.nom]},ue):null}):f.jsx("span",{className:"text-slate-400 italic",children:"Aucun conjoint"})})]}),f.jsxs("div",{className:"bg-white p-3.5 rounded-xl border border-slate-200 shadow-sm space-y-2",children:[f.jsx("p",{className:"font-bold text-slate-500 uppercase tracking-wider text-[11px]",children:"👶 Enfants :"}),f.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.filter(ue=>ue.parents&&ue.parents.includes(n.slug)).length>0?e.filter(ue=>ue.parents&&ue.parents.includes(n.slug)).map(ue=>f.jsxs("button",{onClick:()=>t(ue),className:"px-3 py-1.5 bg-blue-50 hover:bg-blue-100 border border-blue-200 rounded-lg text-blue-900 font-bold shadow-sm transition",children:[ue.prenom," ",ue.nom]},ue.slug)):f.jsx("span",{className:"text-slate-400 italic",children:"Aucun enfant"})})]})]})]}),z==="anecdotes"&&f.jsxs("div",{className:"space-y-4",children:[n.evenements_marquants&&n.evenements_marquants.length>0&&f.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-2xl space-y-3",children:[f.jsxs("p",{className:"text-xs font-black text-amber-800 uppercase tracking-wider flex items-center gap-1.5",children:[f.jsx(V0,{className:"text-amber-500"})," Événements Marquants (",n.evenements_marquants.length,")"]}),f.jsx("div",{className:"space-y-2.5",children:n.evenements_marquants.map((ue,Ve)=>{const We=typeof ue=="object",ct=We&&(ue.annee||ue.date)||"",vt=We?ue.titre||ue.title||ue.description||"":ue,Ut=We&&ue.description!==vt?ue.description:"",dt=We?ue.photo||ue.photo_url:null,mt=dt?dt.startsWith("http")?dt:dt.startsWith("/")?`${jh}${dt}`:`${jh}/${dt}`:null;return f.jsxs("div",{className:"p-3 bg-white/90 rounded-xl border border-amber-200/80 shadow-2xs space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("span",{className:"font-extrabold text-xs text-amber-950 flex items-center gap-1.5",children:[f.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-500"}),vt]}),ct&&f.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-amber-100 text-amber-900 text-[10px] font-mono font-bold",children:["📅 ",ct]})]}),Ut&&f.jsx("p",{className:"text-xs text-slate-600 pl-3.5 leading-relaxed",children:Ut}),mt&&f.jsx("div",{className:"pl-3.5 pt-1",children:f.jsx("img",{src:mt,alt:vt,className:"max-h-36 rounded-xl border border-slate-200 object-cover shadow-xs hover:scale-102 transition-transform"})})]},Ve)})})]}),n.notes&&f.jsxs("div",{className:"p-4 bg-sky-50 border border-sky-200 rounded-2xl space-y-1.5",children:[f.jsxs("p",{className:"text-xs font-black text-sky-800 uppercase tracking-wider flex items-center gap-1.5",children:[f.jsx("span",{children:"📝"})," Notes & Observations Familiales"]}),f.jsx("p",{className:"text-xs text-sky-950 leading-relaxed italic whitespace-pre-wrap",children:n.notes})]}),!n.notes&&(!n.evenements_marquants||n.evenements_marquants.length===0)&&f.jsx("div",{className:"p-6 text-center text-slate-400 italic bg-slate-50 rounded-2xl border border-slate-200",children:"Aucun événement marquant ou note renseignée."})]})]}),f.jsx(a2e,{isOpen:!!et,onClose:()=>At(null),photos:(et==null?void 0:et.photos)||[],initialIndex:(et==null?void 0:et.initialIndex)||0,title:(et==null?void 0:et.title)||"Galerie Photos",onSetProfilePhoto:Se,currentAvatarUrl:Lt,people:e,onRefreshPeople:C}),me&&f.jsx(s2e,{isOpen:me,onClose:()=>Ae(!1),person:n,people:e,onUpdatePerson:i,onNavigateToPerson:t})]})}const p5="https://famille.ravin-cloud.fr",YB=()=>new Date().toISOString().split("T")[0];function y_t(){const[n,e]=de.useState(YB()),[t,r]=de.useState([]),[i,s]=de.useState(""),[a,o]=de.useState(!0),[l,c]=de.useState([{role:"assistant",content:"Bonjour ! Racontez-moi votre journée, je la mettrai en forme pour le journal."}]),[u,d]=de.useState(""),[h,p]=de.useState(!1),[g,x]=de.useState(!1),[_,y]=de.useState(localStorage.getItem("preferred_ai_engine")||"azure"),M=de.useRef(null),C=de.useCallback(async z=>{try{const O=await fetch(`${p5}/api/diary/entry/${z}`,{credentials:"include"});if(O.ok){const V=await O.json();s(V.content||"")}else s("")}catch(O){console.error(`Failed to load entry for ${z}:`,O)}c([{role:"assistant",content:`Vous consultez le journal du ${z}. Que souhaitez-vous y ajouter ?`}])},[]);de.useEffect(()=>{(async()=>{try{const O=await fetch(`${p5}/api/diary/entries`,{credentials:"include"});O.ok&&r(await O.json())}catch(O){console.error("Failed to load entry dates:",O)}})()},[]),de.useEffect(()=>{C(n)},[n,C]),de.useEffect(()=>{var z;(z=M.current)==null||z.scrollIntoView({behavior:"smooth"})},[l]);const k=async()=>{const z=fetch(`${p5}/api/diary/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({date:n,content:i})}).then(O=>O.json());jt.promise(z,{loading:"Sauvegarde...",success:()=>(t.includes(n)||r(O=>[...O,n].sort().reverse()),`Journal du ${n} sauvegardé (et synchronisé avec la timeline).`),error:"Erreur de sauvegarde."})},B=async z=>{var $,G,H;if(z.preventDefault(),!u.trim())return;const O=u;d("");const V=[...l,{role:"user",content:O}];c(V),p(!0);try{const K=await fetch(`${p5}/api/diary/chat`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({history:V,current_entry:i,engine:_})});if(!K.body)throw new Error("Empty response");const W=K.body.getReader(),J=new TextDecoder;let ie="";for(;;){const{done:ae,value:Q}=await W.read();if(ae)break;const oe=J.decode(Q,{stream:!0}).split(` `);for(const fe of oe)if(fe.startsWith("data: ")){const ee=fe.substring(6);if(ee.trim()==="[DONE]")continue;const Ae=(H=(G=($=JSON.parse(ee).choices)==null?void 0:$[0])==null?void 0:G.delta)==null?void 0:H.content;Ae&&(ie+=Ae)}}c(ae=>[...ae,{role:"assistant",content:ie}])}catch(K){console.error("Chat failed:",K),jt.error("Erreur de l'IA.")}finally{p(!1)}},U=async()=>{x(!0);try{const z=await fetch(`${p5}/api/diary/generate`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({history:l,engine:_})}).then(O=>O.json());z&&z.entry&&(s(z.entry),jt.success("Entrée générée avec succès ! Pensez à sauvegarder."))}catch{jt.error("Échec de la génération.")}finally{x(!1)}};return f.jsxs("div",{className:"h-[calc(100vh-4.5rem)] w-full bg-[#fbf9f4] flex overflow-hidden font-serif pb-[60px] md:pb-0",children:[f.jsx(Da,{children:a&&f.jsxs(Gn.div,{initial:{width:0,opacity:0},animate:{width:280,opacity:1},exit:{width:0,opacity:0},className:"h-full bg-white border-r border-[#d4c4a8]/50 shadow-sm flex flex-col z-20 shrink-0",children:[f.jsxs("div",{className:"p-5 border-b border-slate-100 flex items-center gap-3 bg-[#fcfbf7]",children:[f.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-100 text-amber-800 flex items-center justify-center shadow-xs",children:f.jsx(SCe,{size:16})}),f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg font-bold text-slate-800 font-serif tracking-tight",children:"Journal de Famille"}),f.jsx("p",{className:"text-[10px] text-slate-400 font-sans",children:"Souvenirs & Chroniques"})]})]}),f.jsx("div",{className:"p-4",children:f.jsxs("button",{onClick:()=>e(YB()),className:`w-full py-2.5 px-4 rounded-xl flex items-center gap-3 transition-colors ${n===YB()?"bg-amber-600 text-white shadow-md":"bg-slate-50 text-slate-700 hover:bg-slate-100"}`,children:[f.jsx(B_,{}),f.jsx("span",{className:"font-semibold text-xs font-sans",children:"Aujourd'hui"})]})}),f.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[f.jsxs("h3",{className:"text-[10px] font-bold text-slate-400 uppercase tracking-wider mb-2 px-2 font-sans",children:["Récits Archivés (",t.length,")"]}),f.jsx("div",{className:"space-y-1",children:t.map(z=>f.jsx("button",{onClick:()=>e(z),className:`w-full text-left px-3.5 py-2 rounded-xl text-xs font-medium transition-colors font-sans ${n===z?"bg-slate-900 text-amber-200 shadow-sm":"text-slate-600 hover:bg-slate-100"}`,children:new Date(z).toLocaleDateString("fr-FR",{weekday:"short",year:"numeric",month:"short",day:"numeric"})},z))})]})]})}),f.jsxs("div",{className:"flex-1 flex flex-col relative h-full",children:[f.jsxs("header",{className:"h-14 px-6 bg-[#fdfbf7]/90 backdrop-blur-md border-b border-[#d4c4a8]/50 flex items-center justify-between shrink-0 z-10",children:[f.jsxs("div",{className:"flex items-center gap-4",children:[f.jsx("button",{onClick:()=>o(!a),className:"p-2 text-slate-500 hover:bg-slate-100 rounded-lg",children:f.jsx(n4,{className:`transition-transform ${a?"":"rotate-180"}`})}),f.jsx("input",{type:"date",value:n,onChange:z=>e(z.target.value),className:"bg-transparent text-base font-bold text-slate-800 font-sans focus:outline-none cursor-pointer"})]}),f.jsxs("button",{onClick:k,className:"flex items-center gap-2 bg-slate-900 hover:bg-amber-600 text-white px-4 py-2 rounded-xl font-sans text-xs font-bold transition-all shadow-sm cursor-pointer",children:[f.jsx(dH,{})," Sauvegarder"]})]}),f.jsxs("div",{className:"bg-amber-50/80 border-b border-amber-200/60 px-6 py-2 text-xs text-amber-900 flex items-center justify-between font-sans shrink-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{children:"📖"}),f.jsx("span",{className:"font-bold",children:"Journal & Mémoires :"}),f.jsx("span",{className:"text-amber-800/80 hidden sm:inline",children:"Racontez vos anecdotes et souvenirs de famille. Chaque récit apparaît automatiquement sur la Frise chronologique."})]}),f.jsx("span",{className:"text-[10px] text-amber-800 bg-amber-100/90 px-2.5 py-0.5 rounded-full font-bold border border-amber-300/60",children:"⏳ Synchronisé avec la Frise"})]}),f.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[f.jsx("div",{className:"flex-1 flex justify-center overflow-y-auto custom-scrollbar bg-[#fcfcfc]",children:f.jsx("div",{className:"w-full max-w-3xl p-10 md:p-16",children:f.jsx("textarea",{value:i,onChange:z=>s(z.target.value),placeholder:"Commencez à écrire ici, ou utilisez l'assistant IA sur la droite pour vous aider à raconter vos souvenirs...",className:"w-full min-h-full bg-transparent resize-none outline-none text-lg md:text-xl text-slate-800 leading-relaxed placeholder:text-slate-300",style:{minHeight:"600px"}})})}),f.jsxs("div",{className:"w-80 lg:w-96 bg-white border-l border-slate-200 shadow-sm flex flex-col shrink-0 font-sans",children:[f.jsxs("div",{className:"p-4 border-b border-slate-100 bg-indigo-50/50 flex flex-col gap-2",children:[f.jsxs("div",{className:"flex justify-between items-center",children:[f.jsxs("h3",{className:"font-bold text-indigo-900 flex items-center gap-2",children:[f.jsx(ld,{className:"text-indigo-500"})," Assistant IA"]}),f.jsx("button",{onClick:U,disabled:g,className:"text-xs bg-indigo-600 text-white px-3 py-1.5 rounded-md font-semibold shadow-sm hover:bg-indigo-700 disabled:opacity-50",children:g?"Génération...":"Écrire l'entrée"})]}),f.jsx("div",{className:"flex justify-center mt-2",children:f.jsx(wH,{engine:_,setEngine:y})})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 custom-scrollbar",children:[l.map((z,O)=>f.jsx("div",{className:`flex ${z.role==="user"?"justify-end":"justify-start"}`,children:f.jsx("div",{className:`max-w-[85%] p-3 rounded-2xl text-sm ${z.role==="user"?"bg-slate-800 text-white rounded-br-none":"bg-indigo-50 text-slate-800 border border-indigo-100 rounded-bl-none"}`,children:z.content})},O)),h&&f.jsx("div",{className:"flex justify-start",children:f.jsxs("div",{className:"bg-indigo-50 text-slate-500 border border-indigo-100 p-3 rounded-2xl rounded-bl-none flex items-center gap-1",children:[f.jsx("div",{className:"w-1.5 h-1.5 bg-indigo-400 rounded-full animate-bounce"}),f.jsx("div",{className:"w-1.5 h-1.5 bg-indigo-400 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),f.jsx("div",{className:"w-1.5 h-1.5 bg-indigo-400 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})}),f.jsx("div",{ref:M})]}),f.jsx("form",{onSubmit:B,className:"p-4 border-t border-slate-100 bg-slate-50",children:f.jsxs("div",{className:"relative flex items-center",children:[f.jsx("input",{type:"text",value:u,onChange:z=>d(z.target.value),placeholder:"Racontez à l'IA...",className:"w-full bg-white border border-slate-200 rounded-full py-2.5 pl-4 pr-12 text-sm focus:outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500"}),f.jsx("button",{type:"submit",disabled:!u.trim()||h,className:"absolute right-1.5 w-8 h-8 flex items-center justify-center bg-indigo-600 hover:bg-indigo-700 text-white rounded-full transition-colors disabled:opacity-50 disabled:hover:bg-indigo-600",children:f.jsx(Ype,{size:12,className:"-ml-0.5"})})]})})]})]})]}),f.jsx("style",{dangerouslySetInnerHTML:{__html:` .custom-scrollbar::-webkit-scrollbar { width: 6px; } .custom-scrollbar::-webkit-scrollbar-track { background: transparent; } .custom-scrollbar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; } .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #94a3b8; } `}})]})}const ex="https://famille.ravin-cloud.fr";function b_t({people:n=[],onSelectPerson:e,onOpenIngestion:t}){var me;const{user:r}=o1(),i=(r==null?void 0:r.role)==="admin"||(r==null?void 0:r.role)==="super_admin",[s,a]=de.useState("hub"),[o,l]=de.useState(((me=n[0])==null?void 0:me.slug)||""),[c,u]=de.useState(null),[d,h]=de.useState(!1),[p,g]=de.useState(!1),[x,_]=de.useState(0),[y,M]=de.useState(!1),[C,k]=de.useState(null),[B,U]=de.useState(!1),[z,O]=de.useState(null),[V,$]=de.useState([]),[G,H]=de.useState(!1),[K,W]=de.useState("all"),[J,ie]=de.useState(null);de.useEffect(()=>{n.length>0&&!o&&l(n[0].slug)},[n,o]);const ae=async()=>{H(!0);try{const be=await(await fetch(`${ex}/api/admin/ai-generations${K!=="all"?`?type=${K}`:""}`,{credentials:"include"})).json();$(be.generations||[])}catch(Ae){console.error("Failed to load AI archive",Ae)}finally{H(!1)}};de.useEffect(()=>{s==="archive"&&ae()},[s,K]);const Q=async()=>{g(!0),_(15);try{const Ae=setInterval(()=>{_(ze=>ze<90?ze+12:ze)},500),be=await fetch(`${ex}/api/book/export/pdf`,{credentials:"include"});if(clearInterval(Ae),_(100),!be.ok)throw new Error("Erreur lors de la compilation du livre");const pe=await be.blob(),ge=window.URL.createObjectURL(pe),Te=document.createElement("a");Te.href=ge,Te.download=`Livre_de_Famille_${new Date().getFullYear()}.pdf`,document.body.appendChild(Te),Te.click(),Te.remove(),jt.success("Livre de famille généré et téléchargé avec succès !"),fetch(`${ex}/api/admin/ai-generations/record`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({type:"livre",title:`Livre de Famille Complet (${n.length} membres)`,target_person:"Toute la famille",content:`Compilation PDF de l'ensemble de la famille (${n.length} fiches biographiques et arbres généalogiques).`})}).catch(ze=>console.error("Error recording ai generation",ze))}catch(Ae){jt.error(Ae.message||"Erreur lors de la génération du livre.")}finally{g(!1)}},re=async()=>{M(!0);try{const Ae=await fetch(`${ex}/api/novel/generate`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({focus:"family_roots"})}),be=await Ae.json();if(!Ae.ok)throw new Error(be.error||"Erreur lors de l'écriture du roman");const pe=be.novel||be.chapter;k(pe),jt.success("Chapitre rédigé avec succès !"),fetch(`${ex}/api/admin/ai-generations/record`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({type:"roman",title:"Saga Familiale : Le Premier Chapitre",target_person:"Toute la famille",content:pe})}).catch(ge=>console.error("Error recording ai generation",ge))}catch(Ae){jt.error(Ae.message||"Erreur de génération.")}finally{M(!1)}},oe=async()=>{var Ae;U(!0);try{const be=o||((Ae=n[0])==null?void 0:Ae.slug);if(be){const ge=await fetch(`${ex}/api/detective/${be}`,{credentials:"include"}),Te=await ge.json();if(ge.ok&&Te.clues){O([{type:"ai_clues",message:Te.clues,person:n.find(ze=>ze.slug===be)}]),jt.success("Enquête IA détective terminée !");return}}const pe=[];n.forEach(ge=>{!ge.date_naissance&&!ge.naissance&&pe.push({type:"warning",message:`Date de naissance manquante pour ${ge.prenom} ${ge.nom}`}),ge.lieu_naissance||pe.push({type:"suggestion",message:`Lieu d'origine non renseigné pour ${ge.prenom} ${ge.nom}`})}),O(pe.length>0?pe:[{type:"success",message:"Aucune incohérence majeure détectée dans l'arbre."}]),jt.success("Audit de cohérence complété.")}catch(be){jt.error(be.message||"Erreur audit.")}finally{U(!1)}},fe=async Ae=>{try{await fetch(`${ex}/api/admin/ai-generations/${Ae}`,{method:"DELETE",credentials:"include"}),$(be=>be.filter(pe=>pe.id!==Ae)),(J==null?void 0:J.id)===Ae&&ie(null),jt.success("Élément supprimé de l'archive.")}catch{jt.error("Échec de la suppression.")}},ee=[{id:"ingestion",icon:"💬",title:"Assistant & Dépôt Intelligent (Lettres, Récits, Photos)",category:"Ingestion Multimodale IA",badge:"Multimodal",badgeColor:"bg-indigo-100 text-indigo-900 border-indigo-300",description:"Glissez-déposez des photos de documents d'époque, des lettres manuscrites ou collez des récits : l'IA extrait toutes les personnes, déduit les dates, mariages, filiations et prépare les fiches pour validation.",actionLabel:"Ouvrir le Dépôt & Assistant IA",actionIcon:ld,onAction:()=>{t&&t()},options:f.jsx("div",{className:"text-xs text-indigo-800/80 bg-indigo-50/80 p-3 rounded-xl border border-indigo-200",children:"⚡ Analyse intelligente des textes bruts, photos de documents, arbres manuscrits et enregistrements vocaux."})},{id:"livre",icon:"📖",title:"Le Grand Livre de Famille",category:"Édition & PDF",badge:"Ouvrage Complet",badgeColor:"bg-amber-100 text-amber-900 border-amber-300",description:"Compile toutes les biographies, portraits d'époque, frises et l'arbre généalogique complet dans un magnifique PDF haute définition prêt pour l'impression.",actionLabel:p?`Génération en cours (${x}%)...`:"Générer & Télécharger le Livre",actionIcon:p?vu:T3,disabled:p,onAction:Q,options:f.jsxs("div",{className:"text-xs text-amber-800/80 bg-amber-50/80 p-3 rounded-xl border border-amber-200",children:["✨ Inclut automatiquement ",n.length," membres, l'arbre graphique et l'index chronologique."]})},{id:"gazette",icon:"📰",title:"La Gazette Familiale d'Époque",category:"Journalisme Historique",badge:"Une de Journal",badgeColor:"bg-emerald-100 text-emerald-900 border-emerald-300",description:`Génère la "Une" spectaculaire d'un grand quotidien d'époque (XIXe - XXe siècle) célébrant la vie, les événements réels et la mémoire de l'ancêtre choisi.`,actionLabel:"Composer la Une de Gazette",actionIcon:sz,onAction:()=>{if(!o)return jt.error("Veuillez sélectionner un membre.");u(o)},options:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("label",{className:"text-xs font-bold text-slate-700",children:"Choisir l'ancêtre :"}),f.jsx("select",{value:o,onChange:Ae=>l(Ae.target.value),className:"text-xs bg-white border border-slate-300 rounded-xl px-3 py-1.5 font-sans font-bold text-slate-800 shadow-xs focus:outline-none focus:ring-2 focus:ring-amber-500",children:n.map(Ae=>f.jsxs("option",{value:Ae.slug,children:[Ae.prenom," ",Ae.nom," ",Ae.date_naissance?`(${String(Ae.date_naissance).split("-")[0]})`:""]},Ae.slug))})]})},{id:"podcast",icon:"🎙️",title:"Le Podcast & Récits Audio des Aïeux",category:"Voix & Immersion",badge:"Synthèse Vocale",badgeColor:"bg-indigo-100 text-indigo-900 border-indigo-300",description:"Écrit et récite à haute voix une chronique biographique captivante et chaleureuse racontant l'épopée d'un membre ou d'une branche familiale.",actionLabel:"Ouvrir le Studio Podcast",actionIcon:BS,onAction:()=>h(!0),options:f.jsx("div",{className:"text-xs text-indigo-800/80 bg-indigo-50/80 p-3 rounded-xl border border-indigo-200",children:"🎧 Voix naturelles haute fidélité (Henri & Denise) synchronisées pour une écoute instantanée."})},{id:"roman",icon:"📜",title:"Le Roman Historique de Famille",category:"Littérature & Récit",badge:"Style Prix Goncourt",badgeColor:"bg-purple-100 text-purple-900 border-purple-300",description:"L'IA plonge dans les faits réels de votre famille et tisse le premier chapitre d'une saga romanesque émouvante, immersive et riche en détails d'époque.",actionLabel:y?"Rédaction par l'IA...":"Écrire le Premier Chapitre",actionIcon:y?vu:jCe,disabled:y,onAction:re,options:null},{id:"detective",icon:"🕵️‍♂️",title:"Le Détective Généalogique IA",category:"Audit & Analyse",badge:"Vérification Cohérence",badgeColor:"bg-sky-100 text-sky-900 border-sky-300",description:"Passe au crible l'ensemble de l'arbre généalogique pour repérer les incohérences de dates, les doublons potentiels et suggérer de nouvelles pistes.",actionLabel:B?"Enquête en cours...":"Lancer l'Enquête Généalogique",actionIcon:B?vu:sCe,disabled:B,onAction:oe,options:null}];return f.jsxs("div",{className:"max-w-6xl mx-auto space-y-8 pb-12 font-serif",children:[f.jsxs("div",{className:"relative rounded-[2.5rem] p-8 sm:p-12 bg-gradient-to-br from-[#2c3e50] via-[#1a252f] to-[#0f172a] text-white shadow-2xl border-4 border-[#d4c4a8]/40 overflow-hidden",children:[f.jsx("div",{className:"absolute top-0 right-0 w-96 h-96 bg-amber-500/10 rounded-full blur-3xl pointer-events-none"}),f.jsxs("div",{className:"relative z-10 flex flex-col md:flex-row items-start md:items-center justify-between gap-6",children:[f.jsxs("div",{className:"space-y-2 max-w-2xl",children:[f.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-amber-400/20 border border-amber-300/40 text-amber-200 text-xs font-black uppercase tracking-wider",children:[f.jsx(ld,{})," Studio d'Éditions & IA Générative"]}),f.jsx("h1",{className:"text-3xl sm:text-5xl font-bold tracking-tight text-[#fdfbf7]",children:"Créations & Mémoire Familiale"}),f.jsx("p",{className:"text-slate-300 text-sm sm:text-base leading-relaxed",children:"Donnez vie à l'histoire de vos ancêtres : générez des livres reliés, des unes de journaux d'époque, des récits audio contés et des sagas romanesques."})]}),f.jsxs("div",{className:"flex bg-slate-900/80 p-1.5 rounded-2xl border border-white/10 shadow-inner shrink-0",children:[f.jsxs("button",{onClick:()=>a("hub"),className:`px-4 py-2 rounded-xl text-xs font-black transition flex items-center gap-2 ${s==="hub"?"bg-amber-500 text-slate-950 shadow-md font-bold":"text-slate-300 hover:text-white"}`,children:[f.jsx("span",{children:"✨"})," Studio Créatif"]}),f.jsxs("button",{onClick:()=>a("archive"),className:`px-4 py-2 rounded-xl text-xs font-black transition flex items-center gap-2 ${s==="archive"?"bg-amber-500 text-slate-950 shadow-md font-bold":"text-slate-300 hover:text-white"}`,children:[f.jsx("span",{children:"🤖"})," Archive des Générations"]})]})]})]}),s==="hub"?f.jsxs("div",{className:"space-y-6",children:[f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:ee.map(Ae=>{const be=Ae.actionIcon;return f.jsxs(Gn.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"bg-[#fdfbf7] rounded-3xl p-6 border-2 border-[#d4c4a8]/60 shadow-lg hover:shadow-xl transition-all flex flex-col justify-between gap-4 relative overflow-hidden group",children:[f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-3xl p-3 bg-amber-50 rounded-2xl border border-amber-200/80 shadow-xs",children:Ae.icon}),f.jsxs("div",{children:[f.jsx("span",{className:"text-[10px] font-black uppercase tracking-wider text-slate-400",children:Ae.category}),f.jsx("h2",{className:"text-xl font-bold text-slate-900 leading-snug",children:Ae.title})]})]}),f.jsx("span",{className:`px-2.5 py-1 rounded-full text-[10px] font-black border ${Ae.badgeColor}`,children:Ae.badge})]}),f.jsx("p",{className:"text-xs sm:text-sm text-slate-600 leading-relaxed",children:Ae.description}),Ae.options&&f.jsx("div",{className:"pt-2",children:Ae.options})]}),f.jsx("div",{className:"pt-4 border-t border-slate-200/60 flex items-center justify-between gap-3",children:f.jsxs("button",{onClick:Ae.onAction,disabled:Ae.disabled,className:"w-full py-3 px-5 rounded-2xl bg-slate-900 hover:bg-amber-600 text-white text-xs font-black tracking-wide uppercase shadow-md hover:shadow-lg transition flex items-center justify-center gap-2 disabled:opacity-50 cursor-pointer",children:[f.jsx(be,{className:Ae.disabled?"animate-spin":""}),f.jsx("span",{children:Ae.actionLabel})]})})]},Ae.id)})}),C&&f.jsxs(Gn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"bg-[#fcf8ec] p-8 sm:p-12 rounded-[2.5rem] border-4 border-[#8b7355] shadow-2xl relative",children:[f.jsxs("div",{className:"flex items-center justify-between pb-6 border-b border-[#8b7355]/30",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-3xl",children:"📜"}),f.jsxs("div",{children:[f.jsx("h3",{className:"text-2xl font-bold text-[#3a2f1f]",children:"Chapitre I : L'Origine des Nôtres"}),f.jsx("p",{className:"text-xs text-[#8b7355] italic",children:"Roman de Famille généré par l'IA"})]})]}),f.jsx("button",{onClick:()=>k(null),className:"px-4 py-2 text-xs font-bold bg-[#8b7355] text-white rounded-xl hover:bg-[#6e5a42] transition",children:"Fermer"})]}),f.jsx("div",{className:"mt-6 prose max-w-none text-slate-800 leading-relaxed font-serif whitespace-pre-line text-base sm:text-lg",children:C})]}),z&&f.jsxs(Gn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"bg-white p-6 sm:p-8 rounded-3xl border-2 border-sky-300 shadow-xl space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("h3",{className:"text-xl font-bold text-slate-900 flex items-center gap-2",children:[f.jsx("span",{children:"🕵️‍♂️"})," Rapport de l'Enquête Généalogique"]}),f.jsx("button",{onClick:()=>O(null),className:"text-xs text-slate-500 hover:text-slate-800 font-bold",children:"Fermer"})]}),f.jsx("div",{className:"space-y-3",children:z.map((Ae,be)=>Ae.type==="ai_clues"?f.jsxs("div",{className:"p-4 rounded-2xl text-xs font-sans bg-sky-50 text-sky-950 border border-sky-200 space-y-2",children:[Ae.person&&f.jsxs("div",{className:"font-bold text-sm text-sky-900 flex items-center gap-2",children:[f.jsx("span",{children:"🔍"})," Enquête ciblée sur ",Ae.person.prenom," ",Ae.person.nom," :"]}),f.jsx("div",{className:"whitespace-pre-line leading-relaxed font-sans text-xs text-slate-800 bg-white/70 p-4 rounded-xl border border-sky-100",children:Ae.message})]},be):f.jsxs("div",{className:`p-3.5 rounded-2xl text-xs font-sans flex items-start gap-3 ${Ae.type==="warning"?"bg-rose-50 text-rose-900 border border-rose-200":Ae.type==="suggestion"?"bg-amber-50 text-amber-900 border border-amber-200":"bg-emerald-50 text-emerald-900 border border-emerald-200"}`,children:[f.jsx("span",{className:"text-base mt-0.5",children:Ae.type==="warning"?"⚠️":Ae.type==="suggestion"?"💡":"✅"}),f.jsx("div",{children:f.jsx("p",{className:"font-bold",children:Ae.message})})]},be))})]})]}):f.jsxs("div",{className:"bg-[#fdfbf7] p-6 sm:p-8 rounded-[2.5rem] border-2 border-[#d4c4a8] shadow-xl space-y-6",children:[f.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[f.jsxs("div",{children:[f.jsxs("h2",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[f.jsx("span",{children:"🤖"})," Archive de toutes les Générations IA"]}),f.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"Historique de l'ensemble des gazettes, récits audio, livres et romans générés pour la famille."})]}),f.jsx("div",{className:"flex items-center gap-1.5 bg-slate-100 p-1 rounded-2xl border border-slate-200 text-xs font-sans",children:["all","gazette","podcast","roman","livre"].map(Ae=>f.jsx("button",{onClick:()=>W(Ae),className:`px-3 py-1.5 rounded-xl capitalize font-bold transition ${K===Ae?"bg-slate-900 text-amber-300 shadow-xs":"text-slate-600 hover:bg-slate-200"}`,children:Ae==="all"?"✨ Tout":Ae},Ae))})]}),G?f.jsx("div",{className:"py-16 text-center text-slate-400 animate-pulse font-sans text-xs",children:"Chargement de l'archive des créations..."}):V.length===0?f.jsx("div",{className:"py-16 text-center text-slate-400 font-sans text-sm",children:"Aucune génération archivée pour le moment. Utilisez le Studio Créatif pour concevoir vos premiers récits !"}):f.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:V.map(Ae=>f.jsxs("div",{className:"bg-white p-5 rounded-2xl border border-slate-200/80 shadow-xs hover:shadow-md transition space-y-3 flex flex-col justify-between",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f.jsx("span",{className:"text-xs font-black uppercase px-2.5 py-0.5 rounded-full bg-amber-50 text-amber-900 border border-amber-200",children:Ae.type}),f.jsxs("span",{className:"text-[10px] text-slate-400 font-sans flex items-center gap-1",children:[f.jsx(qCe,{className:"text-[9px]"})," ",Ae.created_at]})]}),f.jsx("h4",{className:"font-bold text-slate-900 text-sm leading-snug",children:Ae.title}),f.jsxs("p",{className:"text-xs text-slate-600 line-clamp-3 font-sans italic bg-slate-50 p-2.5 rounded-xl border border-slate-100",children:['"',Ae.preview,'"']})]}),f.jsxs("div",{className:"pt-3 border-t border-slate-100 flex items-center justify-between gap-2 font-sans",children:[f.jsxs("button",{onClick:()=>ie(Ae),className:"px-3 py-1.5 rounded-xl bg-slate-900 text-white text-xs font-bold hover:bg-amber-600 transition flex items-center gap-1",children:[f.jsx("span",{children:"👁️"})," Consulter"]}),i&&f.jsx("button",{onClick:()=>fe(Ae.id),className:"p-2 text-rose-500 hover:bg-rose-50 rounded-xl transition",title:"Supprimer de l'archive",children:f.jsx(z0,{size:12})})]})]},Ae.id))})]}),J&&f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 backdrop-blur-sm p-4",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-[#fcfbf9] w-full max-w-2xl rounded-3xl p-6 sm:p-8 shadow-2xl border-2 border-[#d4c4a8] space-y-4 max-h-[85vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 pb-4",children:[f.jsxs("div",{children:[f.jsx("span",{className:"text-[10px] font-black uppercase text-amber-800 bg-amber-100 px-2.5 py-0.5 rounded-full border border-amber-200",children:J.type}),f.jsx("h3",{className:"text-xl font-bold text-slate-900 mt-1",children:J.title}),f.jsxs("p",{className:"text-xs text-slate-500 font-sans",children:["Généré le ",J.created_at," par ",J.author]})]}),f.jsx("button",{onClick:()=>ie(null),className:"text-slate-400 hover:text-slate-800 text-lg font-bold",children:"✕"})]}),f.jsx("div",{className:"flex-1 overflow-y-auto space-y-4 font-serif text-slate-800 text-sm leading-relaxed p-4 bg-white rounded-2xl border border-slate-200 whitespace-pre-line custom-scrollbar",children:typeof J.content=="object"?JSON.stringify(J.content,null,2):J.content||J.preview}),f.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-slate-200",children:[f.jsx("button",{onClick:()=>{navigator.clipboard.writeText(typeof J.content=="object"?JSON.stringify(J.content,null,2):J.content),jt.success("Texte copié dans le presse-papier !")},className:"px-4 py-2 bg-slate-100 hover:bg-slate-200 text-slate-800 text-xs font-bold rounded-xl font-sans",children:"📋 Copier le contenu"}),f.jsx("button",{onClick:()=>ie(null),className:"px-4 py-2 bg-slate-900 hover:bg-amber-600 text-white text-xs font-bold rounded-xl font-sans",children:"Fermer"})]})]})}),c&&f.jsx(J5e,{slug:c,onClose:()=>u(null)}),d&&f.jsx(H4e,{people:n,onClose:()=>h(!1)})]})}const ZB="https://famille.ravin-cloud.fr";function __t({isOpen:n,onClose:e,people:t=[],onDataUpdated:r}){const[i,s]=de.useState(""),[a,o]=de.useState(null),[l,c]=de.useState(null),[u,d]=de.useState(!1),[h,p]=de.useState(null),[g,x]=de.useState(!1),[_,y]=de.useState(!1),[M,C]=de.useState(!1),k=de.useRef(null),B=de.useRef(null),U=de.useRef([]);if(!n)return null;const z=ae=>{var re;const Q=(re=ae.target.files)==null?void 0:re[0];if(Q){o(Q);const oe=new FileReader;oe.onload=fe=>c(fe.target.result),oe.readAsDataURL(Q)}},O=ae=>{if(ae.preventDefault(),C(!1),ae.dataTransfer.files&&ae.dataTransfer.files[0]){const Q=ae.dataTransfer.files[0];if(Q.type.startsWith("image/")){o(Q);const re=new FileReader;re.onload=oe=>c(oe.target.result),re.readAsDataURL(Q)}}else{const Q=ae.dataTransfer.getData("text");Q&&s(re=>re?`${re} ${Q}`:Q)}},V=async()=>{try{const ae=await navigator.mediaDevices.getUserMedia({audio:!0});B.current=new MediaRecorder(ae),U.current=[],B.current.ondataavailable=Q=>{Q.data.size>0&&U.current.push(Q.data)},B.current.onstop=async()=>{const Q=new Blob(U.current,{type:"audio/webm"}),re=new FormData;re.append("audio",Q,"recording.webm");const oe=jt.loading("Transcription vocale...");try{const ee=await(await fetch(`${ZB}/api/voice/transcribe`,{method:"POST",credentials:"include",body:re})).json();ee.text?(s(me=>me?`${me} ${ee.text}`:ee.text),jt.success("Voix transcrite !",{id:oe})):jt.error("Aucune parole détectée.",{id:oe})}catch(fe){jt.error("Erreur transcription : "+fe.message,{id:oe})}},B.current.start(),y(!0),jt("Enregistrement vocal en cours... Parlez naturellement.")}catch(ae){jt.error("Microphone inaccessible : "+ae.message)}},$=()=>{B.current&&_&&(B.current.stop(),B.current.stream.getTracks().forEach(ae=>ae.stop()),y(!1))},G=async()=>{if(!i.trim()&&!l){jt.error("Veuillez déposer du texte, une lettre ou une photo.");return}d(!0);const ae=jt.loading("L'IA analyse le document et recherche les correspondances...");try{const Q={text:i,image:l||null,mime_type:(a==null?void 0:a.type)||"image/jpeg"},re=await fetch(`${ZB}/api/chat/analyze_memory`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(Q)}),oe=await re.json();if(!re.ok||!oe.success)throw new Error(oe.error||"Erreur lors de l’analyse.");const fe=(oe.propositions||[]).map((ee,me)=>{var Ae,be;return{...ee,id:me,enabled:!0,actionType:ee.is_new?"create":"update",selectedSlug:ee.matched_slug||((be=(Ae=ee.candidate_matches)==null?void 0:Ae[0])==null?void 0:be.slug)||""}});p({summary:oe.summary,propositions:fe}),jt.success(`${fe.length} personne(s) identifiée(s) !`,{id:ae})}catch(Q){jt.error(Q.message,{id:ae})}finally{d(!1)}},H=ae=>{p(Q=>({...Q,propositions:Q.propositions.map(re=>re.id===ae?{...re,enabled:!re.enabled}:re)}))},K=(ae,Q)=>{p(re=>({...re,propositions:re.propositions.map(oe=>oe.id===ae?{...oe,actionType:Q,is_new:Q==="create",matched_slug:Q==="create"?null:oe.selectedSlug||oe.matched_slug}:oe)}))},W=(ae,Q)=>{p(re=>({...re,propositions:re.propositions.map(oe=>oe.id===ae?{...oe,selectedSlug:Q,matched_slug:Q,is_new:!1,actionType:"update"}:oe)}))},J=async()=>{var re;if(!h||!((re=h.propositions)!=null&&re.length))return;const ae=h.propositions.filter(oe=>oe.enabled);if(ae.length===0){jt.error("Veuillez sélectionner au moins une fiche à mettre à jour.");return}x(!0);const Q=jt.loading("Application des mises à jour sur les fiches familiales...");try{const oe={propositions:ae.map(me=>({...me,matched_slug:me.actionType==="create"?null:me.selectedSlug||me.matched_slug,is_new:me.actionType==="create"}))},fe=await fetch(`${ZB}/api/chat/apply_memory_propositions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(oe)}),ee=await fe.json();if(!fe.ok||!ee.success)throw new Error(ee.error||"Erreur lors de l’enregistrement.");jt.success(ee.message||"Mises à jour enregistrées avec succès !",{id:Q}),r&&r(),e()}catch(oe){jt.error(oe.message,{id:Q})}finally{x(!1)}},ie=()=>{s(""),o(null),c(null),p(null)};return f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-2 sm:p-4 bg-black/80 backdrop-blur-md overflow-y-auto",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:15},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:15},className:"bg-slate-900 border border-slate-700/80 rounded-3xl w-full max-w-4xl shadow-2xl overflow-hidden flex flex-col max-h-[92vh]",children:[f.jsxs("div",{className:"px-6 py-4 bg-gradient-to-r from-slate-900 via-indigo-950/70 to-slate-900 border-b border-slate-700/60 flex items-center justify-between",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-2xl bg-indigo-500/20 border border-indigo-400/30 flex items-center justify-center text-indigo-400 text-lg shadow-inner",children:f.jsx(ld,{className:"animate-pulse"})}),f.jsxs("div",{children:[f.jsxs("h2",{className:"text-xl font-black text-white flex items-center gap-2",children:["Assistant d'Ingestion & Dépôt Intelligent",f.jsx("span",{className:"text-[10px] uppercase font-bold tracking-wider px-2 py-0.5 rounded-full bg-indigo-500/30 text-indigo-300 border border-indigo-400/30",children:"Multimodal IA"})]}),f.jsx("p",{className:"text-xs text-slate-400",children:"Déposez des lettres, récits, photos d'actes ou conversations : l'IA déduit les relations et met à jour les fiches."})]})]}),f.jsx("button",{onClick:e,className:"w-8 h-8 rounded-full bg-slate-800 hover:bg-slate-700 text-slate-400 hover:text-white flex items-center justify-center transition-colors",children:f.jsx($a,{})})]}),f.jsx("div",{className:"p-6 overflow-y-auto flex-1 space-y-6",children:h?f.jsxs("div",{className:"space-y-6",children:[f.jsx("div",{className:"p-4 rounded-2xl bg-indigo-950/40 border border-indigo-500/30",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"p-2 rounded-xl bg-indigo-600/30 text-indigo-300 shrink-0 mt-0.5",children:f.jsx(xH,{})}),f.jsxs("div",{className:"space-y-1",children:[f.jsx("h3",{className:"text-sm font-bold text-indigo-200",children:"Résumé de la déduction IA"}),f.jsx("p",{className:"text-xs text-slate-300 leading-relaxed",children:h.summary})]})]})}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("h4",{className:"text-sm font-black text-white uppercase tracking-wider",children:["📋 Propositions par fiche (",h.propositions.length,")"]}),f.jsx("span",{className:"text-xs text-slate-400",children:"Vérifiez et ajustez avant d'enregistrer"})]}),h.propositions.map(ae=>{var fe,ee;const Q=ae.proposed_fields||{},re=Q.sexe==="F",oe=(t||[]).find(me=>me.slug===(ae.selectedSlug||ae.matched_slug));return f.jsx(Gn.div,{layout:!0,className:`p-4 rounded-2xl border transition-all ${ae.enabled?re?"bg-rose-950/20 border-rose-500/30 shadow-sm":"bg-sky-950/20 border-sky-500/30 shadow-sm":"bg-slate-900/40 border-slate-800 opacity-60"}`,children:f.jsx("div",{className:"flex items-start justify-between gap-4",children:f.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[f.jsx("input",{type:"checkbox",checked:ae.enabled,onChange:()=>H(ae.id),className:"mt-1 w-4 h-4 rounded border-slate-700 text-indigo-600 focus:ring-indigo-500 cursor-pointer"}),f.jsxs("div",{className:"space-y-1 flex-1",children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("span",{className:"text-base font-black text-white",children:ae.person_name}),ae.actionType==="create"?f.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-bold px-2 py-0.5 rounded-full bg-emerald-500/20 text-emerald-300 border border-emerald-500/40",children:[f.jsx(F_,{})," Nouvelle personne"]}):f.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-bold px-2 py-0.5 rounded-full bg-indigo-500/20 text-indigo-300 border border-indigo-500/40",children:[f.jsx(M7,{})," Fiche existante : ",oe?`${oe.prenom} ${oe.nom}`:ae.selectedSlug]})]}),f.jsxs("div",{className:"flex flex-wrap items-center gap-3 pt-2 text-xs",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("label",{className:"text-slate-400 font-semibold",children:"Action :"}),f.jsxs("select",{value:ae.actionType,onChange:me=>K(ae.id,me.target.value),className:"bg-slate-800 border border-slate-700 text-slate-200 text-xs rounded-lg px-2 py-1 focus:outline-none focus:border-indigo-500",children:[f.jsx("option",{value:"update",children:"Mettre à jour un membre existant"}),f.jsx("option",{value:"create",children:"Créer une nouvelle fiche"})]})]}),ae.actionType==="update"&&f.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-[200px]",children:[f.jsx("label",{className:"text-slate-400 font-semibold",children:"Membre :"}),f.jsxs("select",{value:ae.selectedSlug||"",onChange:me=>W(ae.id,me.target.value),className:"bg-slate-800 border border-slate-700 text-slate-200 text-xs rounded-lg px-2 py-1 flex-1 focus:outline-none focus:border-indigo-500",children:[f.jsx("option",{value:"",children:"-- Choisir le membre --"}),t.map(me=>f.jsxs("option",{value:me.slug,children:[me.prenom," ",me.nom," ",me.surnom?`(dit ${me.surnom})`:""]},me.slug))]})]})]}),ae.explanation&&f.jsxs("p",{className:"text-xs text-slate-400 italic pt-1",children:["💡 ",ae.explanation]}),f.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2 pt-3 text-xs",children:[Q.date_naissance&&f.jsxs("div",{className:"p-2 rounded-xl bg-slate-800/80 border border-slate-700/60 flex items-center gap-2 text-slate-300",children:[f.jsx(B_,{className:"text-emerald-400"}),f.jsxs("span",{children:["Naiss: ",f.jsx("strong",{children:Q.date_naissance})]})]}),Q.lieu_naissance&&f.jsxs("div",{className:"p-2 rounded-xl bg-slate-800/80 border border-slate-700/60 flex items-center gap-2 text-slate-300",children:[f.jsx(bA,{className:"text-emerald-400"}),f.jsxs("span",{children:["Lieu: ",f.jsx("strong",{children:Q.lieu_naissance})]})]}),Q.date_mariage&&f.jsxs("div",{className:"p-2 rounded-xl bg-slate-800/80 border border-slate-700/60 flex items-center gap-2 text-slate-300",children:[f.jsx(Y0,{className:"text-rose-400"}),f.jsxs("span",{children:["Mariage: ",f.jsx("strong",{children:Q.date_mariage})]})]}),Q.conjoint_slug&&f.jsxs("div",{className:"p-2 rounded-xl bg-slate-800/80 border border-slate-700/60 flex items-center gap-2 text-slate-300",children:[f.jsx(Y0,{className:"text-rose-400"}),f.jsxs("span",{children:["Conjoint: ",f.jsx("strong",{children:Q.conjoint_slug})]})]}),((fe=Q.parents_slugs)==null?void 0:fe.length)>0&&f.jsxs("div",{className:"p-2 rounded-xl bg-slate-800/80 border border-slate-700/60 flex items-center gap-2 text-slate-300 sm:col-span-2",children:[f.jsx(jA,{className:"text-indigo-400"}),f.jsxs("span",{children:["Parents: ",f.jsx("strong",{children:Q.parents_slugs.join(", ")})]})]})]}),((ee=ae.proposed_events)==null?void 0:ee.length)>0&&f.jsxs("div",{className:"mt-2 space-y-1",children:[f.jsx("span",{className:"text-[11px] font-bold text-slate-400 uppercase",children:"Événements ajoutés :"}),ae.proposed_events.map((me,Ae)=>f.jsxs("div",{className:"text-xs text-slate-300 bg-slate-800/50 px-2.5 py-1 rounded-lg border border-slate-700/40",children:[f.jsx("strong",{children:me.date||"•"})," — ",me.title]},Ae))]})]})]})})},ae.id)})]}),f.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-slate-800",children:[f.jsx("button",{type:"button",onClick:()=>p(null),className:"px-4 py-2 rounded-xl text-xs font-bold text-slate-400 hover:text-slate-200 border border-slate-700 transition",children:"← Revenir à la saisie"}),f.jsx("button",{type:"button",onClick:J,disabled:g,className:"inline-flex items-center gap-2 px-6 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-bold shadow-lg shadow-emerald-600/30 transition-all hover:scale-[1.02] active:scale-95 disabled:opacity-50",children:g?f.jsxs(f.Fragment,{children:[f.jsx(vu,{className:"animate-spin"}),f.jsx("span",{children:"Enregistrement..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(td,{}),f.jsx("span",{children:"Valider & Mettre à jour l'Arbre"})]})})]})]}):f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{onDragOver:ae=>{ae.preventDefault(),C(!0)},onDragLeave:()=>C(!1),onDrop:O,className:`relative border-2 border-dashed rounded-2xl p-4 sm:p-6 transition-all text-center ${M?"border-indigo-400 bg-indigo-950/30":"border-slate-700 hover:border-slate-600 bg-slate-800/40"}`,children:l?f.jsxs("div",{className:"relative inline-block",children:[f.jsx("img",{src:l,alt:"Document déposé",className:"max-h-48 rounded-xl border border-slate-600 shadow-md object-contain"}),f.jsx("button",{onClick:()=>{o(null),c(null)},className:"absolute -top-2 -right-2 p-1.5 rounded-full bg-rose-600 text-white shadow-lg hover:bg-rose-700 transition",title:"Supprimer la photo",children:f.jsx(oCe,{className:"text-xs"})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:[f.jsx("div",{className:"w-12 h-12 rounded-full bg-indigo-600/20 text-indigo-400 flex items-center justify-center text-xl",children:f.jsx(ICe,{})}),f.jsx("p",{className:"text-sm font-semibold text-slate-200",children:"Glissez-déposez une photo de lettre, acte, ou document d'époque"}),f.jsx("p",{className:"text-xs text-slate-400",children:"ou cliquez pour importer depuis vos fichiers"}),f.jsx("button",{type:"button",onClick:()=>{var ae;return(ae=k.current)==null?void 0:ae.click()},className:"mt-2 px-3.5 py-1.5 rounded-full bg-slate-800 hover:bg-slate-700 text-slate-300 text-xs font-semibold border border-slate-600 transition",children:"Choisir une image"}),f.jsx("input",{ref:k,type:"file",accept:"image/*",className:"hidden",onChange:z})]})}),f.jsxs("div",{children:[f.jsxs("div",{className:"flex items-center justify-between mb-2",children:[f.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-slate-400 flex items-center gap-2",children:[f.jsx("span",{children:"✍️"})," Texte, lettre, extrait ou anecdotes familiales"]}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs("button",{type:"button",onClick:_?$:V,className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-bold transition-all shadow-sm ${_?"bg-rose-600 text-white animate-pulse":"bg-slate-800 hover:bg-slate-700 text-slate-300 border border-slate-700"}`,children:[f.jsx(BS,{}),f.jsx("span",{children:_?"Arrêter dictée":"Dicter à la voix"})]})})]}),f.jsx("textarea",{value:i,onChange:ae=>s(ae.target.value),placeholder:"Exemple : « Dans une lettre retrouvée datant de juillet 1954, oncle Robert Job explique qu'il s'est marié avec Thérèse à Pondichéry avant la naissance de leur fils aîné Joseph en 1956... »",rows:6,className:"w-full bg-slate-950/80 border border-slate-700 rounded-2xl p-3.5 text-slate-100 text-sm focus:outline-none focus:border-indigo-500 transition shadow-inner resize-y placeholder:text-slate-500"})]}),f.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[f.jsx("button",{type:"button",onClick:ie,className:"px-4 py-2 rounded-xl text-xs font-bold text-slate-400 hover:text-slate-200 transition",children:"Effacer"}),f.jsx("button",{type:"button",onClick:G,disabled:u||!i.trim()&&!l,className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-gradient-to-r from-indigo-600 to-purple-600 hover:from-indigo-500 hover:to-purple-500 text-white text-sm font-bold shadow-lg shadow-indigo-600/30 transition-all disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] active:scale-95",children:u?f.jsxs(f.Fragment,{children:[f.jsx(vu,{className:"animate-spin"}),f.jsx("span",{children:"Analyse IA en cours..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(ld,{}),f.jsx("span",{children:"Analyser le document & Extraire les fiches"})]})})]})]})})]})})}const Yde=["« Les racines d'une famille s'étendent à travers les siècles et éclairent notre avenir. »","« Chaque ancêtre a écrit une page du grand livre dont nous sommes aujourd'hui les héritiers. »","« La mémoire est le trésor le plus précieux que nous transmettons de génération en génération. »","« Préparation de votre sanctuaire généalogique et historique... »"];function w_t({message:n="Accès aux archives familiales..."}){const[e,t]=de.useState(0);return de.useEffect(()=>{const r=setInterval(()=>{t(i=>(i+1)%Yde.length)},3200);return()=>clearInterval(r)},[]),f.jsxs("div",{className:"fixed inset-0 z-[999] flex flex-col items-center justify-center bg-[#070b14] text-white font-sans overflow-hidden select-none",children:[f.jsx("div",{className:"absolute top-1/4 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[600px] h-[600px] bg-amber-500/10 rounded-full blur-[150px] pointer-events-none"}),f.jsx("div",{className:"absolute -bottom-32 -right-32 w-96 h-96 bg-emerald-600/15 rounded-full blur-[140px] pointer-events-none"}),f.jsx("div",{className:"absolute -top-32 -left-32 w-96 h-96 bg-amber-600/10 rounded-full blur-[140px] pointer-events-none"}),f.jsx("div",{className:"absolute inset-0 opacity-[0.03] bg-[radial-gradient(#d4af37_1px,transparent_1px)] [background-size:24px_24px] pointer-events-none"}),f.jsxs(Gn.div,{initial:{opacity:0,scale:.92},animate:{opacity:1,scale:1},transition:{duration:.8,ease:[.16,1,.3,1]},className:"relative z-10 flex flex-col items-center max-w-lg px-8 text-center space-y-7",children:[f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:"absolute inset-0 bg-amber-400/20 rounded-full blur-2xl animate-pulse"}),f.jsx(Gn.div,{animate:{rotate:[0,2,-2,0],scale:[1,1.03,1]},transition:{repeat:1/0,duration:6,ease:"easeInOut"},className:"relative w-28 h-28 rounded-3xl bg-gradient-to-br from-amber-300 via-amber-600 to-amber-900 p-[1.5px] shadow-[0_0_50px_rgba(245,158,11,0.25)] flex items-center justify-center",children:f.jsxs("div",{className:"w-full h-full bg-[#0b0f19] rounded-[22px] flex flex-col items-center justify-center text-4xl shadow-inner border border-amber-500/20 relative overflow-hidden",children:[f.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-amber-500/10 to-transparent pointer-events-none"}),f.jsx("span",{className:"text-3xl drop-shadow-[0_2px_10px_rgba(245,158,11,0.5)]",children:"🌳"}),f.jsxs("div",{className:"absolute bottom-1.5 flex items-center gap-1",children:[f.jsx("span",{className:"w-1 h-1 rounded-full bg-amber-400"}),f.jsx("span",{className:"text-[7px] font-black tracking-[0.25em] text-amber-300/80 uppercase",children:"HERITAGE"}),f.jsx("span",{className:"w-1 h-1 rounded-full bg-amber-400"})]})]})})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"flex items-center justify-center gap-2",children:[f.jsx("span",{className:"h-[1px] w-8 bg-gradient-to-r from-transparent to-amber-400/60"}),f.jsx("span",{className:"text-[10px] font-extrabold uppercase tracking-[0.3em] text-amber-400/90 font-serif",children:"Maison & Lignage"}),f.jsx("span",{className:"h-[1px] w-8 bg-gradient-to-l from-transparent to-amber-400/60"})]}),f.jsx("h2",{className:"text-3xl sm:text-4xl font-serif font-black bg-gradient-to-r from-amber-100 via-amber-200 to-amber-400 bg-clip-text text-transparent tracking-tight drop-shadow-sm",children:"Histoire Familiale"}),f.jsx("p",{className:"text-xs sm:text-sm font-medium text-amber-200/70 tracking-wide",children:n})]}),f.jsx("div",{className:"w-72 h-1 bg-slate-900 rounded-full overflow-hidden border border-amber-500/20 p-[1px] shadow-[0_0_15px_rgba(245,158,11,0.15)]",children:f.jsx(Gn.div,{className:"h-full bg-gradient-to-r from-amber-600 via-amber-300 to-amber-500 rounded-full shadow-[0_0_12px_rgba(245,158,11,0.8)]",animate:{x:["-100%","150%"]},transition:{repeat:1/0,duration:2,ease:"easeInOut"},style:{width:"45%"}})}),f.jsx(Gn.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.6},className:"min-h-[44px] flex items-center justify-center",children:f.jsx("p",{className:"text-xs font-serif italic text-slate-400 max-w-sm leading-relaxed text-amber-100/60",children:Yde[e]})},e)]})]})}class S_t extends ln.Component{constructor(e){super(e),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("ErrorBoundary caught an error:",e,t),this.setState({errorInfo:t});try{fetch("https://famille.ravin-cloud.fr/api/logs/client-error",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({message:(e==null?void 0:e.toString())||"Unknown React error",stack:((e==null?void 0:e.stack)||"")+` `+((t==null?void 0:t.componentStack)||""),url:window.location.href,userAgent:navigator.userAgent})}).catch(()=>{})}catch{}}render(){var e;return this.state.hasError?f.jsxs("div",{className:"min-h-screen bg-slate-950 text-white flex flex-col items-center justify-center p-6 text-center font-sans",children:[f.jsx("div",{className:"w-20 h-20 bg-rose-500/20 text-rose-400 rounded-3xl border border-rose-500/30 flex items-center justify-center text-3xl mb-6 shadow-[0_0_30px_rgba(244,63,94,0.3)]",children:"⚠️"}),f.jsx("h1",{className:"text-2xl sm:text-3xl font-black text-white mb-2",children:"Une interruption temporaire est survenue"}),f.jsx("p",{className:"text-slate-400 max-w-md text-sm mb-6",children:"L'application a rencontré un problème d'affichage. Cliquez ci-dessous pour recharger l'espace familial."}),f.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[f.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),window.location.reload()},className:"px-6 py-3 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-400 hover:to-teal-500 text-slate-950 font-bold text-sm rounded-xl shadow-lg transition-all",children:"🔄 Recharger la page"}),f.jsx("button",{onClick:()=>{localStorage.clear(),sessionStorage.clear(),window.location.href="/"},className:"px-4 py-3 bg-slate-800 hover:bg-slate-700 text-slate-300 font-medium text-sm rounded-xl border border-slate-700 transition-all",children:"Nettoyer le cache"})]}),this.state.error&&f.jsxs("details",{className:"w-full max-w-xl text-left bg-slate-900/90 border border-slate-800 rounded-xl p-4 text-xs text-slate-400",children:[f.jsx("summary",{className:"cursor-pointer font-bold text-slate-300 hover:text-white",children:"🔍 Détails techniques de l'erreur"}),f.jsxs("pre",{className:"mt-3 overflow-x-auto whitespace-pre-wrap font-mono text-[11px] text-rose-400 bg-black/40 p-3 rounded-lg border border-white/5",children:[this.state.error.toString(),(e=this.state.errorInfo)==null?void 0:e.componentStack]})]})]}):this.props.children}}const T_t="https://famille.ravin-cloud.fr";function E_t(){const{user:n,refetch:e}=o1(),t=async()=>{try{await fetch(`${T_t}/api/logout`,{credentials:"include"}),window.location.reload()}catch(r){console.error("Logout error:",r)}};return f.jsxs("div",{className:"min-h-screen bg-slate-950 text-slate-100 flex flex-col items-center justify-center p-6 relative overflow-hidden font-sans",children:[f.jsx("div",{className:"absolute top-1/4 left-1/2 -translate-x-1/2 -translate-y-1/2 w-96 h-96 bg-amber-500/10 rounded-full blur-3xl pointer-events-none"}),f.jsx("div",{className:"absolute bottom-1/4 left-1/3 w-80 h-80 bg-indigo-500/10 rounded-full blur-3xl pointer-events-none"}),f.jsxs("div",{className:"w-full max-w-lg bg-slate-900/90 border border-slate-800 rounded-3xl p-8 shadow-2xl backdrop-blur-xl relative z-10 text-center",children:[f.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-2xl bg-gradient-to-tr from-amber-500/20 to-amber-400/10 border border-amber-500/30 flex items-center justify-center text-amber-400 shadow-lg shadow-amber-500/10",children:f.jsx(kCe,{className:"text-3xl animate-pulse"})}),f.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-amber-500/10 border border-amber-500/20 text-amber-400 text-xs font-semibold uppercase tracking-wider mb-4",children:[f.jsx(uH,{className:"text-xs"}),"Accès Sécurisé • En attente"]}),f.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"Compte en attente de validation"}),f.jsxs("p",{className:"text-slate-400 text-sm mb-6 leading-relaxed",children:["Bonjour ",f.jsx("span",{className:"font-semibold text-slate-200",children:(n==null?void 0:n.name)||(n==null?void 0:n.email)}),". Votre compte a bien été enregistré. Pour garantir la confidentialité des archives familiales, un administrateur doit valider votre identité et configurer vos accès."]}),f.jsxs("div",{className:"bg-slate-800/60 border border-slate-700/60 rounded-2xl p-4 mb-6 text-left space-y-2",children:[f.jsxs("div",{className:"flex items-center gap-3 text-xs text-slate-300",children:[f.jsx(MCe,{className:"text-amber-400 shrink-0"}),f.jsxs("span",{children:[f.jsx("strong",{children:"Accès restreint par défaut :"})," Vous n'avez accès à aucune fiche familiale tant que vos droits ne sont pas configurés."]})]}),f.jsxs("div",{className:"flex items-center gap-3 text-xs text-slate-400 pt-1 border-t border-slate-700/40",children:[f.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400 animate-ping shrink-0"}),f.jsx("span",{children:"Une notification a été envoyée à l'administrateur."})]})]}),f.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[f.jsxs("button",{onClick:()=>e(),className:"flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-amber-500 hover:bg-amber-400 text-slate-950 font-bold text-sm shadow-lg shadow-amber-500/20 transition-all hover:scale-105 active:scale-95",children:[f.jsx(AM,{className:"text-xs"}),"Vérifier l'activation"]}),f.jsxs("button",{onClick:t,className:"flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-300 font-medium text-sm border border-slate-700 transition-colors",children:[f.jsx(Xpe,{className:"text-xs"}),"Se déconnecter"]})]}),f.jsx("div",{className:"mt-8 pt-4 border-t border-slate-800/80 text-xs text-slate-500",children:"Famille History • Espace Privé & Sécurisé"})]})]})}const BE="https://famille.ravin-cloud.fr";function N_t({isOpen:n,onClose:e,people:t=[],onOpenPersonDetail:r}){const{user:i,refetch:s}=o1(),a=de.useRef(null),[o,l]=de.useState(""),[c,u]=de.useState(""),[d,h]=de.useState(""),[p,g]=de.useState(""),[x,_]=de.useState(""),[y,M]=de.useState(!1),[C,k]=de.useState(!1);if(de.useEffect(()=>{i&&n&&(l(i.name||i.preferred_username||""),u(i.bio||""),h(i.telephone||""),g(i.claimed_profile||""),_(i.picture||""))},[i,n]),!n||!i)return null;const B=async O=>{var H;const V=(H=O.target.files)==null?void 0:H[0];if(!V)return;const $=new FormData;$.append("file",V),M(!0);const G=jt.loading("Envoi de la photo de profil...");try{const K=await fetch(`${BE}/api/user/profile/picture`,{method:"POST",credentials:"include",body:$}),W=await K.json();if(K.ok&&W.picture){const J=W.picture.startsWith("/")?`${BE}${W.picture}`:W.picture;_(J),jt.success("Photo de profil mise à jour !",{id:G}),s&&s()}else jt.error(W.error||"Erreur lors de l'envoi",{id:G})}catch(K){console.error(K),jt.error("Erreur de connexion au serveur",{id:G})}finally{M(!1)}},U=async O=>{O.preventDefault(),k(!0);const V=jt.loading("Enregistrement de votre profil...");try{const $=await fetch(`${BE}/api/user/profile`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:o.trim(),bio:c.trim(),telephone:d.trim(),claimed_profile:p||null,picture:x})}),G=await $.json();$.ok?(jt.success("Profil personnalisé avec succès ! ✨",{id:V}),s&&await s(),e()):jt.error(G.error||"Erreur lors de la sauvegarde",{id:V})}catch($){console.error($),jt.error("Erreur de connexion",{id:V})}finally{k(!1)}},z=t.find(O=>O.slug===p);return f.jsx(Da,{children:f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-6 bg-black/80 backdrop-blur-md overflow-y-auto",children:f.jsxs(Gn.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"relative w-full max-w-xl bg-gradient-to-b from-slate-900 via-slate-800 to-slate-950 text-white rounded-3xl shadow-2xl border border-slate-700/80 overflow-hidden my-auto",children:[f.jsxs("div",{className:"px-6 py-5 border-b border-slate-700/80 flex items-center justify-between bg-slate-900/60",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-2xl",children:"✨"}),f.jsxs("div",{children:[f.jsx("h2",{className:"text-lg sm:text-xl font-serif font-black text-white",children:"Mon Profil Familial"}),f.jsx("p",{className:"text-xs text-slate-400",children:"Personnalisez votre présence dans la mémoire de famille."})]})]}),f.jsx("button",{onClick:e,className:"p-2 rounded-full bg-slate-800 text-slate-400 hover:text-white hover:bg-slate-700 transition",title:"Fermer",children:f.jsx($a,{size:16})})]}),f.jsxs("form",{onSubmit:U,className:"p-6 space-y-6 max-h-[75vh] overflow-y-auto custom-scrollbar",children:[f.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-5 p-4 rounded-2xl bg-slate-800/60 border border-slate-700/50",children:[f.jsxs("div",{className:"relative group",children:[f.jsxs("div",{className:"w-24 h-24 rounded-2xl overflow-hidden border-2 border-emerald-400 shadow-xl bg-slate-900 flex items-center justify-center relative",children:[x?f.jsx("img",{src:x.startsWith("/")?`${BE}${x}`:x,alt:"Avatar",className:"w-full h-full object-cover"}):f.jsx("div",{className:"w-full h-full bg-gradient-to-tr from-emerald-600 to-teal-500 flex items-center justify-center text-white text-3xl font-black font-serif",children:(o||i.email||"M")[0].toUpperCase()}),y&&f.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:f.jsx(vu,{className:"animate-spin text-emerald-400 text-2xl"})})]}),f.jsx("button",{type:"button",onClick:()=>{var O;return(O=a.current)==null?void 0:O.click()},disabled:y,className:"absolute -bottom-2 -right-2 p-2.5 rounded-full bg-emerald-500 hover:bg-emerald-400 text-slate-950 font-bold shadow-lg border-2 border-slate-900 transition hover:scale-110 active:scale-95 cursor-pointer",title:"Changer ma photo de profil",children:f.jsx(fm,{size:14})}),f.jsx("input",{type:"file",ref:a,onChange:B,accept:"image/*",className:"hidden"})]}),f.jsxs("div",{className:"flex-1 text-center sm:text-left space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 flex-wrap",children:[f.jsx("span",{className:"font-bold text-white text-base sm:text-lg",children:o||"Utilisateur"}),f.jsx("span",{className:`text-[10px] uppercase font-extrabold px-2 py-0.5 rounded-full border ${i.role==="super_admin"?"bg-amber-500/20 text-amber-300 border-amber-500/40":i.role==="admin"?"bg-purple-500/20 text-purple-300 border-purple-500/40":"bg-emerald-500/20 text-emerald-300 border-emerald-500/40"}`,children:i.role==="super_admin"?"👑 Super Admin":i.role==="admin"?"🛡️ Administrateur":"👤 Membre"})]}),f.jsxs("p",{className:"text-xs text-slate-400 flex items-center justify-center sm:justify-start gap-1.5",children:[f.jsx(AH,{size:11,className:"text-slate-500"})," ",i.email]}),f.jsx("button",{type:"button",onClick:()=>{var O;return(O=a.current)==null?void 0:O.click()},className:"text-xs text-emerald-400 hover:text-emerald-300 font-semibold underline mt-1",children:"Cliquez ici pour changer votre photo"})]})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-slate-300 mb-1.5 flex items-center gap-1.5",children:[f.jsx(LCe,{className:"text-emerald-400"})," Nom & Prénom d'affichage"]}),f.jsx("input",{type:"text",value:o,onChange:O=>l(O.target.value),placeholder:"Ex: Jean Dupont",required:!0,className:"w-full bg-slate-800/90 border border-slate-700 rounded-xl px-4 py-2.5 text-sm font-semibold text-white placeholder-slate-500 focus:outline-none focus:border-emerald-400 transition"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-slate-300 mb-1.5 flex items-center gap-1.5",children:[f.jsx(hH,{className:"text-emerald-400"})," Bio / Message pour la famille"]}),f.jsx("textarea",{value:c,onChange:O=>u(O.target.value),rows:2,placeholder:"Ex: Passionné par l'histoire des grands-parents, contactez-moi pour toute anecdote !",className:"w-full bg-slate-800/90 border border-slate-700 rounded-xl px-4 py-2.5 text-sm font-medium text-white placeholder-slate-500 focus:outline-none focus:border-emerald-400 transition resize-none"})]}),f.jsxs("div",{children:[f.jsxs("label",{className:"block text-xs font-bold uppercase tracking-wider text-slate-300 mb-1.5 flex items-center gap-1.5",children:[f.jsx(wCe,{className:"text-emerald-400"})," Numéro de téléphone (optionnel)"]}),f.jsx("input",{type:"tel",value:d,onChange:O=>h(O.target.value),placeholder:"Ex: 06 12 34 56 78",className:"w-full bg-slate-800/90 border border-slate-700 rounded-xl px-4 py-2.5 text-sm font-semibold text-white placeholder-slate-500 focus:outline-none focus:border-emerald-400 transition"})]}),f.jsxs("div",{className:"p-4 rounded-2xl bg-gradient-to-r from-emerald-950/40 via-slate-800/60 to-emerald-950/30 border border-emerald-500/30 space-y-3",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsxs("label",{className:"text-xs font-bold uppercase tracking-wider text-emerald-300 flex items-center gap-1.5",children:[f.jsx(xM,{className:"text-emerald-400"})," Mon Identité dans l'Arbre Familial"]}),z&&f.jsxs("span",{className:"text-[11px] font-bold text-emerald-400 flex items-center gap-1 bg-emerald-900/60 px-2 py-0.5 rounded-full border border-emerald-500/40",children:[f.jsx(td,{})," Relié"]})]}),f.jsx("p",{className:"text-xs text-slate-300 leading-relaxed",children:"Associez votre compte à votre fiche dans l'arbre généalogique. En cliquant sur votre profil ou sur votre nom, vous accéderez instantanément à votre histoire."}),f.jsxs("select",{value:p,onChange:O=>g(O.target.value),className:"w-full bg-slate-900 border border-emerald-500/50 rounded-xl px-3 py-2.5 text-sm font-semibold text-emerald-100 outline-none focus:border-emerald-400 cursor-pointer",children:[f.jsxs("option",{value:"",children:["-- Sélectionner ma fiche dans l'arbre (",t.length," personnes) --"]}),t.map(O=>f.jsxs("option",{value:O.slug,children:[O.prenom," ",O.nom," ",O.date_naissance?`(${String(O.date_naissance).substring(0,4)})`:""]},O.slug))]}),z&&f.jsxs("div",{className:"flex items-center justify-between pt-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(q0,{person:z,className:"w-8 h-8",rounded:"rounded-lg"}),f.jsxs("span",{className:"text-xs font-bold text-white",children:[z.prenom," ",z.nom]})]}),r&&f.jsx("button",{type:"button",onClick:()=>{e(),r(z)},className:"text-xs font-bold text-emerald-300 hover:text-emerald-200 underline",children:"Ouvrir ma fiche généalogique →"})]})]})]}),f.jsxs("div",{className:"pt-2 flex items-center justify-end gap-3 border-t border-slate-700/80",children:[f.jsx("button",{type:"button",onClick:e,className:"px-5 py-2.5 rounded-xl bg-slate-800 hover:bg-slate-700 text-slate-300 font-bold text-sm transition",children:"Annuler"}),f.jsxs("button",{type:"submit",disabled:C,className:"px-6 py-2.5 rounded-xl bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-400 hover:to-teal-500 text-slate-950 font-black text-sm shadow-lg shadow-emerald-500/20 transition-all hover:scale-105 active:scale-95 flex items-center gap-2 disabled:opacity-50",children:[C?f.jsx(vu,{className:"animate-spin"}):f.jsx(dH,{}),f.jsx("span",{children:"Enregistrer mon Profil"})]})]})]})]})})})}const S0="https://famille.ravin-cloud.fr",M_t={initial:{opacity:0,y:20},in:{opacity:1,y:0},out:{opacity:0,y:-20}};function C_t(){var Qt;const{user:n,loading:e}=o1(),t=new URLSearchParams(window.location.search).get("tab")||"membres",[r,i]=de.useState(t),[s,a]=de.useState([]),[o,l]=de.useState(null),[c,u]=de.useState(!1),[d,h]=de.useState(null),[p,g]=de.useState(0),[x,_]=de.useState(""),[y,M]=de.useState(!1),[C,k]=de.useState(!1),[B,U]=de.useState(""),[z,O]=de.useState(null),[V,$]=de.useState(!1),[G,H]=de.useState(null),[K,W]=de.useState(!1),[J,ie]=de.useState(null),ae=de.useRef(null),[Q,re]=de.useState(!1),[oe,fe]=de.useState(!1),[ee,me]=de.useState(!1),[Ae,be]=de.useState(!1),[pe,ge]=de.useState(!1),[Te,ze]=de.useState(null),[Xe,Qe]=de.useState(!1),[ot,bt]=de.useState(!1),[ht,Ce]=de.useState(null),[lt,ft]=de.useState(null),[et,At]=de.useState(!1),[Lt,st]=de.useState(!1),[Ht,Se]=de.useState(!1);de.useEffect(()=>{if(o){const Be=s.find(pt=>pt.slug===o.slug);Be&&(Be.date_naissance!==o.date_naissance||Be.date_mariage!==o.date_mariage||Be.conjoint!==o.conjoint||JSON.stringify(Be.parents)!==JSON.stringify(o.parents))&&l(Be)}},[s]);const _t=async Be=>{$(!0),H(null),jt.loading("Génération du podcast en cours (IA)...",{id:"podcast"});try{const pt=await fetch(`${S0}/api/podcast/${Be}`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({engine:"azure"})}),rt=await pt.json();if(!pt.ok)throw new Error(rt.error||"Erreur inconnue");H({url:`${S0}${rt.url}`,script:rt.script}),jt.success("Récit audio prêt !",{id:"podcast"})}catch(pt){jt.error(pt.message,{id:"podcast"})}finally{$(!1)}},It=async Be=>{W(!0),ie(null);try{const pt=await fetch(`${S0}/api/detective/${Be}`,{credentials:"include"});if(!pt.ok)throw new Error("Erreur de détective");const rt=await pt.json();ie(rt.clues)}catch(pt){jt.error(pt.message)}finally{W(!1)}},De=async()=>{if(ae.current)try{jt.loading("Génération de l'image haute qualité...",{id:"print-toast"});const Be=await dme(ae.current,{cacheBust:!0,quality:1,pixelRatio:2}),pt=document.createElement("a");pt.download=`Carte_Collection_${o.prenom}_${o.nom}.png`,pt.href=Be,pt.click(),jt.success("Image téléchargée !",{id:"print-toast"})}catch(Be){console.error(Be),jt.error("Erreur lors de la génération de l'image.",{id:"print-toast"})}},ue=()=>{if(!o.date_naissance){jt.error("Date de naissance inconnue");return}if(String(o.date_naissance||"").split("-").length<2)return;const pt=new Date(o.date_naissance);if(isNaN(pt.getTime())){jt.error("Format de date invalide");return}const rt=String(pt.getMonth()+1).padStart(2,"0"),zt=String(pt.getDate()).padStart(2,"0"),Yt=`2024${rt}${zt}T090000Z`,Bt=`2024${rt}${zt}T100000Z`,$e=`BEGIN:VCALENDAR VERSION:2.0 BEGIN:VEVENT SUMMARY:Anniversaire de ${o.prenom} ${o.nom} DTSTART:${Yt} DTEND:${Bt} RRULE:FREQ=YEARLY DESCRIPTION:Généalogie Famille History - Pensez à commémorer la mémoire de ${o.prenom}. END:VEVENT END:VCALENDAR`,ut=new Blob([$e],{type:"text/calendar;charset=utf-8"}),Gt=document.createElement("a");Gt.href=URL.createObjectURL(ut),Gt.download=`Anniversaire_${o.prenom}_${o.nom}.ics`,Gt.click(),jt.success("Fichier d'agenda téléchargé !")},Ve=async Be=>{re(!0),jt.loading("Restauration de la photo en cours...",{id:"enhance"});try{const pt=await fetch(`${S0}/api/photo/enhance/${Be}`,{method:"POST",credentials:"include"}),rt=await pt.json();if(!pt.ok)throw new Error(rt.error||"Erreur inconnue");jt.success("Photo restaurée avec succès !",{id:"enhance"}),l(zt=>({...zt,photo:rt.new_photo_url,photo_url:rt.new_photo_url})),await vt()}catch(pt){jt.error(pt.message,{id:"enhance"})}finally{re(!1)}},We=Be=>{bt(!1),Be.type==="document"||Be.type==="personne"?ft(Be.data):jt("L'IA n'a pas reconnu de visage ou de document.")},ct=async Be=>{await Ut(Be.prenom||"Inconnu",Be.nom||"Inconnu"),ft(null),jt.success("Données sauvegardées !")},vt=async()=>{h(null);try{const Be=await fetch(`${S0}/api/people`,{credentials:"include"});if(Be.ok){const pt=await Be.json();if(pt.people&&pt.people.length>0){a(pt.people);return}}}catch(Be){console.warn("API people fetch failed, trying local fallback:",Be)}try{const Be=await fetch("./data/people.json");if(Be.ok){const pt=await Be.json();a(pt.people||[]);return}}catch(Be){console.error("Local fallback failed:",Be),h("Impossible de charger les données familiales.")}},Ut=async(Be,pt)=>{if(!(!Be||!pt))try{await fetch(`${S0}/api/people`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({prenom:Be,nom:pt})}),jt.success(`${Be} ${pt} a été ajouté(e) avec succès !`),await vt(),u(!1),i("membres")}catch(rt){console.error(rt),jt.error("Erreur lors de la création.")}},dt=Be=>{g(pt=>pt+1),jt.success(Be||"Information sauvegardée !"),vt()},mt=Be=>{l(Be),H(null),ie(null),Be?window.history.pushState({tab:"membres",slug:Be.slug},"",`?tab=membres&person=${Be.slug}`):window.history.pushState({tab:"membres",slug:null},"","?tab=membres")},Ft=Be=>{i(Be),l(null),window.history.pushState({tab:Be,slug:null},"",`?tab=${Be}`)},tt=Be=>{mt(Be),M(!0)};ln.useEffect(()=>{const Be=rt=>{const zt=rt.detail,Yt=s.find(Bt=>Bt.slug===zt);Yt&&(i("membres"),mt(Yt))},pt=()=>{st(!0)};return window.addEventListener("OPEN_PROFILE",Be),window.addEventListener("OPEN_USER_PROFILE_MODAL",pt),()=>{window.removeEventListener("OPEN_PROFILE",Be),window.removeEventListener("OPEN_USER_PROFILE_MODAL",pt)}},[s]);const Pe=async Be=>{U("Chargement..."),k(!0);try{const rt=await(await fetch(`${S0}/api/people/${Be}`,{credentials:"include"})).json();U(rt.markdown||"Erreur: Impossible de charger le contenu.")}catch{U("Erreur de connexion.")}},nt=async Be=>{if(O({transcript:Be.transcript||"Aucune parole détectée.",intent:Be.actions&&Be.actions.length>0?"multi-actions":"unknown",target:null}),setTimeout(()=>O(null),5e3),Be.actions&&Be.actions.length>0){let pt=!1;for(const rt of Be.actions)if(rt.intent==="navigate"&&rt.target_slug){const zt=s.find(Yt=>Yt.slug===rt.target_slug);zt?(l(zt),i("membres"),jt.success(`Navigation vers ${zt.prenom}`)):jt.error(`Personne introuvable: ${rt.target_slug}`)}else if(rt.intent==="journal"){jt.success("Enregistrement dans le journal...");const zt=new Date().toISOString().split("T")[0];try{const Yt=await fetch(`${S0}/api/diary/entry/${zt}`,{credentials:"include"});let Bt="";Yt.ok&&(Bt=(await Yt.json()).content||""),Bt+=` 📝 *Note vocale :* ${Be.transcript} `,await fetch(`${S0}/api/diary/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({date:zt,content:Bt})}),jt.success("Souvenir ajouté au journal !"),g($e=>$e+1)}catch{jt.error("Erreur lors de la sauvegarde du journal.")}i("journal")}else rt.intent==="save_event"?rt.status==="saved"?(jt.success(`✅ ${rt.summary||"Histoire mise à jour pour "+rt.target_slug}`),pt=!0):jt.error(`❌ Échec pour ${rt.target_slug}`):jt.error(`L'IA a retourné une action non reconnue (${rt.intent}).`);pt&&(g(rt=>rt+1),await vt())}else jt.error("L'IA n'a pas reconnu d'action valide ou de personnes.")};de.useEffect(()=>{vt()},[]),de.useEffect(()=>{window.history.state||window.history.replaceState({tab:t,slug:null},"",window.location.search||`?tab=${t}`);const Be=pt=>{if(pt.state)if(pt.state.tab&&i(pt.state.tab),pt.state.slug){const rt=s.find(zt=>zt.slug===pt.state.slug);l(rt||null)}else l(null);else l(null),i("membres")};return window.addEventListener("popstate",Be),()=>window.removeEventListener("popstate",Be)},[s,t]),de.useEffect(()=>{const Be=pt=>{const rt=pt.detail.target_person;if(!rt)return;const zt=s.find(Yt=>`${Yt.prenom} ${Yt.nom}`.toLowerCase().includes(rt.toLowerCase()));zt?(l(zt),jt.success(`Branche de ${zt.prenom} ouverte`)):jt.error(`Fiche non trouvée pour ${rt}`)};return window.addEventListener("timeline-navigate",Be),()=>window.removeEventListener("timeline-navigate",Be)},[s]);const qe=s.filter(Be=>`${Be.prenom} ${Be.nom}`.toLowerCase().includes(x.toLowerCase()));return e?f.jsx(w_t,{message:"Connexion à l'espace familial..."}):n?n.status==="pending"||n.status==="rejected"?f.jsx(E_t,{}):((n.name||n.preferred_username||((Qt=n.email)==null?void 0:Qt.split("@")[0])||"Famille").split(" ")[0],f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"gradient-bg opacity-30",children:f.jsxs("ul",{className:"circles",children:[f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{})]})}),f.jsx(UPe,{position:"bottom-center"}),f.jsx(Qvt,{currentTab:r,onNavigate:Ft,onAddPerson:()=>u(!0),onOpenScanner:()=>bt(!0),onOpenMuseum:()=>me(!0),onOpenGlobe:()=>be(!0),onToggleChat:()=>M(!0),onOpenIngestion:()=>Se(!0),onOpenAdmin:()=>At(!0),onOpenUserProfile:()=>st(!0)}),r==="journal"?f.jsx(y_t,{}):f.jsxs("div",{className:`pt-2 sm:pt-4 pb-24 md:pb-10 mx-auto w-full transition-all duration-300 ${r==="arbre"||r==="genealogie"?"max-w-[1920px] px-1 sm:px-4":"max-w-7xl px-1 sm:px-4 md:px-6"}`,children:[d&&f.jsxs("div",{className:"fixed top-20 left-1/2 -translate-x-1/2 w-full max-w-md z-50 p-4 bg-red-500 text-white rounded-xl shadow-lg flex justify-between items-center",children:[f.jsx("span",{children:d}),f.jsx("button",{onClick:()=>h(null),className:"ml-4 font-bold",children:"X"})]}),f.jsx(Da,{mode:"wait",children:f.jsxs(Gn.main,{className:"px-1 sm:px-3 space-y-5",variants:M_t,initial:"initial",animate:"in",exit:"out",transition:{type:"tween",ease:"anticipate",duration:.5},children:[r==="membres"&&f.jsx("div",{className:"space-y-4",children:o?f.jsxs(f.Fragment,{children:[f.jsx(v_t,{person:o,people:s,onSelectPerson:mt,onEditPerson:Ce,onUpdatePerson:Be=>{l(Be),vt()},onNavigateToTree:Be=>i("arbre"),onClose:()=>mt(null),onGeneratePodcast:_t,isPodcastLoading:V,onDetective:It,isDetectiveLoading:K,onViewSource:Pe,onOpenNewspaper:()=>fe(!0),onShareImage:De,onAddToAgenda:ue,onEnhancePhoto:Ve,isPhotoEnhancing:Q,onSelectPersonForChat:tt,onVoiceIntent:nt,onDataUpdate:dt,refreshKey:p}),f.jsx(V7e,{ref:ae,person:o,API_URL:S0}),oe&&f.jsx(J5e,{slug:o.slug,onClose:()=>fe(!1)}),G&&f.jsx(Gn.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"pt-4 px-2 relative z-10",children:f.jsxs("div",{className:"bg-purple-900/40 rounded-2xl p-4 border border-purple-500/30 flex flex-col items-center gap-3 shadow-lg backdrop-blur-sm",children:[f.jsxs("div",{className:"flex items-center justify-between w-full max-w-md",children:[f.jsxs("p",{className:"text-sm font-bold text-purple-200 flex items-center gap-2",children:[f.jsx("span",{children:"🎙️"})," Récit audio de ",o==null?void 0:o.prenom]}),f.jsx("button",{onClick:()=>H(null),className:"text-slate-400 hover:text-white text-xs font-bold px-2 py-1 rounded-lg hover:bg-white/10 transition",children:"✕ Fermer"})]}),f.jsx("audio",{controls:!0,autoPlay:!0,src:typeof G=="string"?G:G.url,className:"w-full max-w-md outline-none rounded-lg"}),typeof G=="object"&&G.script&&f.jsxs("details",{className:"w-full max-w-md text-xs text-purple-200/90 bg-purple-950/50 p-3 rounded-xl border border-purple-800/40",children:[f.jsx("summary",{className:"font-semibold text-purple-300 hover:text-white cursor-pointer select-none",children:"📜 Voir le texte du récit"}),f.jsx("p",{className:"mt-2 text-slate-200 leading-relaxed font-sans select-text",children:G.script})]})]})}),J&&f.jsx(Gn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"pt-4 px-2 relative z-10",children:f.jsxs("div",{className:"bg-slate-800 text-slate-200 rounded-2xl p-6 shadow-xl border border-slate-700",children:[f.jsxs("h3",{className:"text-lg font-bold text-emerald-400 mb-4 flex items-center gap-2",children:[f.jsx("span",{children:"🕵️"})," Rapport du Détective Privé"]}),f.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-slate-300",children:f.jsx("pre",{className:"whitespace-pre-wrap font-sans bg-transparent border-0 p-0 text-sm leading-relaxed",children:J})})]})})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center bg-white p-4 rounded-xl shadow-sm border border-slate-100 gap-4",children:[f.jsx("input",{type:"text",placeholder:"Rechercher un membre...",className:"w-full sm:w-auto flex-1 p-3 border border-slate-300 rounded-full bg-slate-50 focus:bg-white shadow-inner focus:outline-none focus:ring-2 focus:ring-emerald-500/50 transition-all",value:x,onChange:Be=>_(Be.target.value)}),f.jsxs("button",{onClick:()=>me(!0),className:"px-5 py-3 w-full sm:w-auto bg-gradient-to-r from-[#8b7355] to-[#d4c4a8] text-white font-bold rounded-full shadow-[0_5px_15px_rgba(139,115,85,0.4)] hover:shadow-[0_8px_25px_rgba(139,115,85,0.6)] transition-all flex items-center justify-center gap-2",children:[f.jsx("span",{children:"🏛️"})," Musée 3D"]})]}),f.jsx(K7e,{items:qe,onSelect:mt,onCreate:()=>u(!0),onEditPerson:Ce})]})}),r==="timeline"&&f.jsx(yme,{person:o,people:s,onSelectPerson:mt,onEditPerson:Be=>Ce(Be),onNavigateToPerson:Be=>{const pt=s.find(rt=>rt.slug===Be||`${rt.prenom} ${rt.nom}`.toLowerCase()===Be.toLowerCase()||rt.prenom.toLowerCase()===Be.toLowerCase());pt&&(mt(pt),i("membres"))},onEventEdited:dt},p),r==="arbre"&&f.jsx(lHe,{onNodeClick:Be=>{mt(Be),i("membres")},onEditPerson:Ce,onNavigateToTimeline:Be=>{mt(Be),i("timeline")}}),r==="carte"&&f.jsxs("div",{className:"space-y-4",children:[f.jsx("div",{className:"flex justify-end",children:f.jsxs("button",{onClick:()=>be(!0),className:"px-5 py-2.5 bg-[#1a202c] text-blue-300 font-bold rounded-lg border border-blue-900 hover:bg-[#2d3748] shadow-md transition-all flex items-center gap-2",children:[f.jsx("span",{children:"🌍"})," Globe 3D Interactif"]})}),f.jsx(Yvt,{onNodeClick:Be=>{const pt=s.find(rt=>rt.slug===Be.slug)||Be;mt(pt),i("membres")}})]}),r==="medias"&&f.jsx(cHe,{people:s,onRefreshPeople:vt,onSelectPerson:Be=>{mt(Be),i("membres")}}),(r==="livre"||r==="studio_ia")&&f.jsx(b_t,{people:s,onSelectPerson:Be=>{mt(Be),i("membres")},onOpenIngestion:()=>Se(!0)}),r==="stats"&&f.jsx(g_t,{people:s,onSelectPerson:Be=>{i("membres"),mt(Be)}}),!["membres","timeline","arbre","carte","medias","livre","studio_ia","stats","journal"].includes(r)&&f.jsx(m_t,{currentTab:r,onGoHome:()=>i("membres")})]},r)})]}),n&&f.jsxs(f.Fragment,{children:[f.jsx($7e,{onAddPerson:()=>u(!0),onToggleChat:()=>M(!0),onOpenScanner:()=>bt(!0),onOpenIngestion:()=>Se(!0)}),f.jsx(VPe,{onIntent:nt})]}),f.jsx(Da,{children:z&&f.jsx(Gn.div,{initial:{opacity:0,y:50,scale:.9},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:20,scale:.8},className:"fixed bottom-24 left-1/2 -translate-x-1/2 w-[90%] max-w-md bg-slate-900/90 backdrop-blur-xl text-white p-5 rounded-3xl shadow-2xl z-[100] border border-white/10",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-500/20 flex items-center justify-center shrink-0",children:f.jsx("span",{className:"text-xl",children:"🎙️"})}),f.jsxs("div",{className:"flex-1",children:[f.jsx("p",{className:"text-sm text-emerald-400 font-bold mb-1 uppercase tracking-wider",children:"Ce que j'ai entendu"}),f.jsxs("p",{className:"text-lg font-serif italic mb-3 leading-tight",children:['"',z.transcript,'"']}),f.jsxs("div",{className:"bg-black/40 rounded-xl p-3 border border-white/5",children:[f.jsx("p",{className:"text-xs text-slate-400 font-bold uppercase tracking-wider mb-1",children:"Analyse IA"}),f.jsxs("p",{className:"text-sm text-slate-200",children:[f.jsx("span",{className:"font-bold text-white",children:"Action : "})," ",z.intent]}),z.target&&f.jsxs("p",{className:"text-sm text-slate-200",children:[f.jsx("span",{className:"font-bold text-white",children:"Cible : "})," ",z.target]})]})]})]})})}),f.jsx(q7e,{current:r,onNavigate:Ft}),Ae&&f.jsx(f_t,{onClose:()=>be(!1),onSelectPerson:Be=>{be(!1),tt(Be)}}),ee&&f.jsx(h_t,{onClose:()=>me(!1),onSelectPerson:Be=>{me(!1),tt(Be)}}),Xe&&f.jsx(H4e,{people:s,onClose:()=>Qe(!1)}),f.jsx(N_t,{isOpen:Lt,onClose:()=>st(!1),people:s,onOpenPersonDetail:Be=>{i("membres"),mt(Be)}}),ot&&f.jsx(GPe,{onAnalyzeResult:We,onClose:()=>bt(!1)}),lt&&f.jsx(HPe,{data:lt,onSave:ct,onCancel:()=>ft(null)}),c&&f.jsx(cz,{onSubmit:Ut,onCancel:()=>u(!1)}),C&&f.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onClick:()=>k(!1),children:f.jsxs("div",{className:"bg-white rounded-lg shadow-2xl p-6 w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:Be=>Be.stopPropagation(),children:[f.jsx("h2",{className:"font-bold mb-4",children:"Source Markdown"}),f.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs bg-slate-100 p-4 rounded-md",children:B}),f.jsx("button",{onClick:()=>k(!1),className:"mt-4 px-4 py-2 bg-gray-200 rounded-md",children:"Fermer"})]})}),f.jsx(Da,{children:y&&f.jsx(Gn.div,{initial:{opacity:0,y:50},animate:{opacity:1,y:0},exit:{opacity:0,y:50},className:"fixed inset-0 z-[60]",children:f.jsx(QPe,{person:o,people:s,onSelectPerson:l,onClose:()=>M(!1),onDataUpdate:dt})})}),ht&&f.jsx(A_t,{person:ht,onClose:()=>Ce(null),onUpdated:async Be=>{if(Ce(null),await vt(),Be)try{const zt=((await(await fetch(`${S0}/api/people`,{credentials:"include"})).json()).people||[]).find(Yt=>Yt.slug===Be);zt&&l(zt)}catch{}},onDelete:async()=>{Ce(null),l(null),await vt()}}),f.jsx(__t,{isOpen:Ht,onClose:()=>Se(!1),people:s,onDataUpdated:vt}),f.jsx(x_t,{isOpen:et,onClose:()=>At(!1)})]})):f.jsxs("div",{className:"w-screen h-screen",children:[f.jsx("div",{className:"gradient-bg",children:f.jsxs("ul",{className:"circles",children:[f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{}),f.jsx("li",{})]})}),f.jsx("div",{className:"relative z-10 flex items-center justify-center h-full",children:f.jsxs(Gn.div,{className:"w-full max-w-md p-8 space-y-6 bg-white/80 backdrop-blur-xl rounded-2xl shadow-2xl text-center",initial:{opacity:0,y:50},animate:{opacity:1,y:0},transition:{duration:.8,ease:"easeOut"},children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h1",{className:"text-3xl font-extrabold tracking-tight text-slate-800",children:"Histoire Familiale"}),f.jsx("p",{className:"text-slate-600",children:"Connectez-vous pour revivre et partager vos souvenirs."})]}),f.jsx("div",{className:"pt-6 flex justify-center",children:f.jsx(Kvt,{})})]})})]})}c0e(document.getElementById("root")).render(f.jsx(ln.StrictMode,{children:f.jsx(S_t,{children:f.jsx(Zvt,{children:f.jsx(C_t,{})})})}));export{pa as _,kb as c,Vv as g};